MCPcopy Create free account
hub / github.com/culvertsoft/mgen / registerClass

Function registerClass

mgen-javascriptlib/src/main/javascript/mgen-lib.js:206–230  ·  view source on GitHub ↗
(obj, path)

Source from the content-addressed store, hash-verified

204 }
205
206 function registerClass(obj, path) {
207 var currentClassType, currentClassPath, collidingClassType, collidingClassPath,
208
209 ClassConstructor = createClass(obj);
210
211 treeIndexSet(ClassRegistry, path, ClassConstructor);
212 if (!ClassRegistry[getShortName(path)]) {
213 ClassRegistry[getShortName(path)] = ClassConstructor;
214 } else {
215 // we have a collision. Lets create a list of all the collisions and then later turn it into a warning for the user.
216
217 currentClassType = (new ClassConstructor("NO_CONSTRUCT")).__t;
218 currentClassPath = tmpWrap(currentClassType);
219
220 if (typeof ClassRegistry[getShortName(path)] === "function") {
221 collidingClassType = (new ClassRegistry[getShortName(path)]("NO_CONSTRUCT")).__t;
222 collidingClassPath = tmpWrap(collidingClassType);
223
224 ClassRegistry[getShortName(path)] = [collidingClassPath, currentClassPath];
225 } else {
226 // append to collision list
227 ClassRegistry[getShortName(path)].push(currentClassPath);
228 }
229 }
230 }
231
232 function createClass(obj) {
233 var _c = {}; // the _c object is used to trick the function.name property to be correct for the class.

Callers 1

mgen-lib.jsFile · 0.85

Calls 4

createClassFunction · 0.85
treeIndexSetFunction · 0.85
getShortNameFunction · 0.85
tmpWrapFunction · 0.85

Tested by

no test coverage detected