<div dir="ltr">Here's the start of a Functional Description of the JSON Proto Expander.  I was not aware of the scope of this, it includes namespaces/scopes as strings, the proto expander itself, a flattener to remove empty objects, and an extern prototype load and search routines.  I can totally understand why this is a big task.<div><br></div><div>The main interface looks like this:</div><div><br></div><div>// Replace ExternProtoDeclare with ProtoDeclare</div><div>object = this.externalPrototypeExpander( file, object );</div><div>// Run the Proto Expander<br>object = this.realPrototypeExpander( file, object, false );</div><div><br></div><div>// Remove unused objects<br>this.zapIs( object );</div><div><br></div><div>// remove empty objects created by zapIs<br>object = this.flattener( object );</div><div><br></div><div>If someone wants to put this on a group google doc or github, they have my permission.<br><div><br></div><div>    flattenerArray : function ( object, parentArray )</div><div>-- Flatten array<br>    flattenerObject : function ( object, parentArray, arrayLen )</div><div>-- Flatten object</div><div>    flattener : function ( object, parentArray, arrayLen )</div><div>-- main flattener routine<br>    pushScope : function ( s )</div><div>-- push a namespace on the stack<br>    popScope : function ()</div><div>-- pop a namespace off the stack<br>    saveDef : function ( def )</div><div>-- put the def in the namespace<br>    getDef : function ( def )</div><div>-- get the correct def for the namespace we are in<br>    getField : function ( scope, field )</div><div>-- get a field in the namespace<br>    getScope : function ( def )</div><div>-- get current namespace<br>    scopeLength : function ()</div><div>-- get length of namespace stack<br>    upScope : function ( i )</div><div>-- move window up a level in namespace stack (for searching)<br>    setValueFromInterface : function ( field, object, objectfield )</div><div>-- set object "spot" by examining interface<br>    getObjectField : function ( f, type )<br>    findFieldByName : function ( fields, objectfield )<br>    getScriptFieldFieldTypeFieldByNameAttribute : function ( fields, objectfield )<br>    getScriptFieldFieldTypeField : function ( fields, field )<br>    setScriptFields : function ( fields, def )<br>    setScriptField : function ( scope, field, f, objectfield, type, def )<br>    setEnv : function ( scope, protoField, newobject, nodeField, type, newdef )<br>    getEnv : function ( scope, protoField )<br>    setConnectField : function ( scope, field, newobject, objectfield, type, newdef )</div><div>-- set spots for connect field<br>    setConnectFields : function ( object, p, newobject )</div><div>-- set spots for connect fields<br>    setScriptConnectFields : function ( file, object, p, newobject )</div><div>-- set spots for connect fields and scripts.<br>    getInterface : function ( field )<br>    setInterface : function ( field, fieldname )<br>    clearScope : function ( field, object )<br>    extractConnectedDef : function ( scope, field )<br>    setObjectValues : function ( scope, field, fieldOrNode, value )</div><div>-- set object values in "spots"<br>    setObjectValue : function ( scope, field, obj, fieldOrNode, value )</div><div>-- set object value in "spot"<br>    zap : function ( field, object )<br>    zapIs : function ( object )<br>    prototypeExpander : function ( file, object )</div><div>-- Proto Expander interface<br>    readCode : function ( data, fileExt, protoexp, done, p, newobject )<br>    handleScript : function ( file, object, p, newobject )</div><div>    handleProtoDeclare : function ( file, object, p )<br>    handleProtoInterface : function ( file, object, p )<br>    handleProtoInstance : function ( file, object, p )<br>    realPrototypeExpander : function ( file, object, inScript )</div><div><br></div><div>-- The rest of these are for the ExternProtoExpander<br>    searchForProtoDeclare : function ( object, name )<br>    searchAndReplaceProto : function ( filename, json, protoname, founddef, obj, objret )<br>    loadedProto : function ( data, protoname, obj, filename, protoexp, objret )<br>    doLoad : function ( data, u, protoexp, done, p, obj )<br>    processURLs : function ( localArray, path )<br>    loadURLs : function ( loadpath, urls, loadedCallback, protoexp, done, externProtoDeclare, obj )<br>    load : function ( p, file, object, protoexp, done )<br>    externalPrototypeExpander : function ( file, object )<br></div></div></div>