
studiofactory_files_xxx.pl	load/save routines for files with extention .xxx
	At the moment {stf, syn}



----

Global variables begin with 'the' and are created with rv():
rv('int theCurrentChannel;');

Function and variable names use camelCapping. All words joined together
with first letter of each word in caps except for the first word.
Local variables begin with 'my'. Parameters to functions begin with 'a'.

static bool isCurrentProject(int aProject) {
	return (aProject == theCurrentProject);
}

Functions that begin with 'is' return a flag stating a true/false condition.
isWindowActive(... aWindow), isModuleSelected(... aModule) etc.

----

Code layout

	if (a==b
	|| c==d) {
		...code...;
	}

	if (a==b) {
		...code...;
	} else {
		...code...;
	}

	switch(x) {
	case y:
		...code...;
		break;
	default:
		break;
	}


----




Most of the StudioFactory source is generated with perl files.

---- type of source code ----
Insert vabatim c/c++ code with

rc(EOF);
	// c-code comes here
EOF

rs(EOF);
	// c-code lowlevel support routines come here
EOF


'rs' code is placed before 'rc' in the final file.
Use 'static' for all functions and variables because they will
reside in the same cpp file anyway.

use 'rd()' or 'rd .=' for definitions.
use 'rv()' or 'setvar(,,)' for variables. The function rv() automagically adds
newline and the static keyword! Example:
rv('bool quitFlag=false;');
results in following code:
static bool quitFlag=false;

or if they have complex behaviour create the variable with setvar instead
setvar(<type>, <varname>, <defaultvalue>);
Default value is optional.

setvar('int', 'theCurrentChannel', '0');
the the currentchannel can be set with 'setTheCurrentChannel(<channel>)'
note how the first 'T' is automagically in uppercase. Each set function
contains a ~cc~<varname>~ so extra code can be added with
cc('<varname>', <code>); See further below how the cc mechanism works.

---- generation of structs and enums ----

gStruct('StructName');
gEnum('EnumName');

add elements with
cc('StructNameStruct', '...;');
cc('EnumNameEnum', '...');


---- compile time string replacement ----

In perl mode add cc() calls for creating replacement strings.

For example in the routine that changes the current language setting
(eg setTheCurrentLanguage) the following piece of code is inserted:
~cc~theCurrentLanguage~

Now any routine that is interrested in knowing that the current language is
changed can make a call to cc('theCurrentLanguage', ...); (while in perl mode)
For example we want to update the config window whenever the current
language changes:
cc('theCurrentLanguage', 'configWindowRefresh=true;');

This enables flexible source layout and allows compile-time add and removal of
pieces of code from the system without introducing the #ifdef mess normally
assiciated with flexible c/c++ code.

cc(,) calls are normally placed at the beginning of perl files, so it
is easy to spot dependencies with other modules.

For enums there is a 3 parameter version of cc.
The third parameter is the seperator between elements, which inserted at the end
of each line except for the last line. This makes some compilers more happy.
gEnum('Xxx');
cc('XxxEnum', 'XXX_ELEMENT', ',');


For initialisation and termination pairs use cc(,) for init and cci(,) for
termination. cci(,) places the replacement string is backwards order. So
the order of calls for termination is a mirror image of the initialisation.

Small list of possible names in use by cc strings:

***Init		initialisation code
	mainInit
	windowInit

***Term		termination code (use cci instead of cc)
	mainTerm
	windowTerm

***Struct	name elements for a struct definition.
		These are defined with gStruct(<name>)
	ContextStruct
	ProjectStruct

***Enum		name elements for a enum definition.
		These are defined with gEnum(<name>)

the***		is called when named global variable is updated.
	theCurrentProject
	theCurrentLanguage

show***		subwindow is requested to open
	showAudioMixer
	showAudioOutputScope
	showColorSelector
	showConfigPanel
	showMidiActivityMonitor
	showMidiScope
	showPatchConfig
	showProjectBrowser
	showTransport

