lib/ProfileObject.js
function( instVar, valVar, pageszVar, offsetVar, prefix, indent ) {
		var code = "", usedProps = {}, defaultAssign = "$inst.$prop = $value",
			replaceVariableMacro = (function(s,v) {
				var i = this.properties.indexOf(v);
				if (i >= 0) {
					usedProps[v] = true;
				} else {
					throw "Macro "+s+" refers to a property not part of property table!"; 
				}
			}).bind(this);

		//
		// [default] - Default empty constructor
		//
		if (this.init == "default") {

		//
		// [constructor] - Call constructor
		//
		} else if (this.init == 'constructor') {
			code += prefix + this.name+".call("+instVar;
			for (var i=0, l=this.initConstructorArgs.length; i<l; i++) {
				var arg = this.initConstructorArgs[i],
					partIdx = arg.search(/[\.\[]/),
					part = "", found = false;

				// Try to translate constructor arguments to components of the value
				// array when possivle
				if (partIdx == -1) partIdx = arg.length;
				part = arg.substr(0,partIdx);
				for (var j=0, jl=this.properties.length; j<jl; ++j) {
					if (this.properties[j] == part) {
						arg = valVar + "["+offsetVar+'+'+pageszVar+'*'+j+"]" + arg.substr(partIdx);
						usedProps[part] = true;
						found = true;
						break;
					}
				}

				// Warn user if not found
				if (!found) {
					console.warn("Could not find property '"+arg+"' in "+this.name+". Assuming literal");
				}

				// Update constructor call
				code += ",\n"+prefix+indent+arg;
			}
			code += ");\n";

		//
		// [other] - Custom user function
		//
		} else {
			console.warn("Using custom init function for "+this.name);
			code += prefix + this.init + "(" + instVar +", " + valVar + ");\n";
			
		}

		// Replace variable macros in the property assigners & track handled properties
		for (var k in this.propCustomAssign) {
			this.propCustomAssign[k] = this.propCustomAssign[k]
				.replace(/\$\$(\w+)/g, replaceVariableMacro);
		}

		// Get default assign function
		if (this.propAssign) defaultAssign = this.propAssign;
		defaultAssign = defaultAssign
			.replace(/\$\$(\w+)/g, replaceVariableMacro);

		// Call property initializer (might be shared with other instances)
		if (this.initProperties) {
			for (var i=0, l=this.properties.length; i<l; ++i) {
				var prop = this.properties[i];
				// Skip properties used in the constructor
				if (usedProps[prop] && !this.keepUsedProperties) continue;
				if (this.propCustomAssign[prop]) {
					code += prefix + this.propCustomAssign[prop]
						.replace(/\$inst/g, instVar)
						.replace(/\$prop/g, prop)
						.replace(/\$values/g, valVar)
						.replace(/\$value/g, valVar+"["+offsetVar+'+'+pageszVar+'*'+i+"]") + ";\n";
				} else {
					code += prefix + defaultAssign
						.replace(/\$inst/g, instVar)
						.replace(/\$prop/g, prop)
						.replace(/\$values/g, valVar)
						.replace(/\$value/g, valVar+"["+offsetVar+'+'+pageszVar+'*'+i+"]") + ";\n";
				}
			}
		}

		// Call post-init
		if (this.postInit) {
			code += "\n" + prefix + "// Custom init function\n";
			code += prefix + this.postInit.replace(/\n/g, "\n"+prefix)
					.replace(/\$inst/g, instVar)
					.replace(/\$values/g, valVar)
					.replace(/\$\$(\w+)/g, replaceVariableMacro);
		}

		return code;
	}
function( instVar, valVar, pageszVar, offsetVar, prefix, indent ) {
		var code = "", usedProps = {}, defaultAssign = "$inst.$prop = $value",
			replaceVariableMacro = (function(s,v) {
				var i = this.properties.indexOf(v);
				if (i >= 0) {
					usedProps[v] = true;
				} else {
					throw "Macro "+s+" refers to a property not part of property table!"; 
				}
			}).bind(this);

		//
		// [default] - Default empty constructor
		//
		if (this.init == "default") {

		//
		// [constructor] - Call constructor
		//
		} else if (this.init == 'constructor') {
			code += prefix + this.name+".call("+instVar;
			for (var i=0, l=this.initConstructorArgs.length; i<l; i++) {
				var arg = this.initConstructorArgs[i],
					partIdx = arg.search(/[\.\[]/),
					part = "", found = false;

				// Try to translate constructor arguments to components of the value
				// array when possivle
				if (partIdx == -1) partIdx = arg.length;
				part = arg.substr(0,partIdx);
				for (var j=0, jl=this.properties.length; j<jl; ++j) {
					if (this.properties[j] == part) {
						arg = valVar + "["+offsetVar+'+'+pageszVar+'*'+j+"]" + arg.substr(partIdx);
						usedProps[part] = true;
						found = true;
						break;
					}
				}

				// Warn user if not found
				if (!found) {
					console.warn("Could not find property '"+arg+"' in "+this.name+". Assuming literal");
				}

				// Update constructor call
				code += ",\n"+prefix+indent+arg;
			}
			code += ");\n";

		//
		// [other] - Custom user function
		//
		} else {
			console.warn("Using custom init function for "+this.name);
			code += prefix + this.init + "(" + instVar +", " + valVar + ");\n";
			
		}

		// Replace variable macros in the property assigners & track handled properties
		for (var k in this.propCustomAssign) {
			this.propCustomAssign[k] = this.propCustomAssign[k]
				.replace(/\$\$(\w+)/g, replaceVariableMacro);
		}

		// Get default assign function
		if (this.propAssign) defaultAssign = this.propAssign;
		defaultAssign = defaultAssign
			.replace(/\$\$(\w+)/g, replaceVariableMacro);

		// Call property initializer (might be shared with other instances)
		if (this.initProperties) {
			for (var i=0, l=this.properties.length; i<l; ++i) {
				var prop = this.properties[i];
				// Skip properties used in the constructor
				if (usedProps[prop] && !this.keepUsedProperties) continue;
				if (this.propCustomAssign[prop]) {
					code += prefix + this.propCustomAssign[prop]
						.replace(/\$inst/g, instVar)
						.replace(/\$prop/g, prop)
						.replace(/\$values/g, valVar)
						.replace(/\$value/g, valVar+"["+offsetVar+'+'+pageszVar+'*'+i+"]") + ";\n";
				} else {
					code += prefix + defaultAssign
						.replace(/\$inst/g, instVar)
						.replace(/\$prop/g, prop)
						.replace(/\$values/g, valVar)
						.replace(/\$value/g, valVar+"["+offsetVar+'+'+pageszVar+'*'+i+"]") + ";\n";
				}
			}
		}

		// Call post-init
		if (this.postInit) {
			code += "\n" + prefix + "// Custom init function\n";
			code += prefix + this.postInit.replace(/\n/g, "\n"+prefix)
					.replace(/\$inst/g, instVar)
					.replace(/\$values/g, valVar)
					.replace(/\$\$(\w+)/g, replaceVariableMacro);
		}

		return code;
	}
Generate the piece of code that initializes an instance of the object