CrxOop CrxOop: Bringing Object Oriented Programming, and Proper Prototype Based Programming, To Javascript
The aim of the library documented below is to provide developers with a solution to allow development using interfaces and classes as they are known in other object oriented programming (OOP) languages such as C++, C#, Java and PHP. Further more, V1.4 introduces structures, a generalization of the concept of prototypal inheritance, known here as POBP.
Subject
Body*
Email
SUBMIT CLOSE
Menu

7.5 crxOop.isStructureInheriting

crxOop.isStructureInheriting can be used to inspect during run time if a structure, not an instance, inherits another structure. If any of the parameters is not a valid structure definition object, or registered structure name, crxOop.isStructureInheriting will issue a fatal error.

JS (Tree)
crx_registerStructure("ExampleStructure1",
{
});

crx_registerStructure("ExampleStructure2",
{
   INHERITS: ["ExampleStructure1"]
});

crx_registerStructure("ExampleStructure3",
{
   INHERITS: ["ExampleStructure2"]
});

console.log((crxOop.isStructureInheriting("ExampleStructure1", "ExampleStructure2") ? "true" : "false"));
console.log((crxOop.isStructureInheriting("ExampleStructure2", "ExampleStructure1") ? "true" : "false"));
console.log((crxOop.isStructureInheriting("ExampleStructure3", "ExampleStructure2") ? "true" : "false"));
console.log((crxOop.isStructureInheriting("ExampleStructure3", "ExampleStructure3") ? "true" : "false"));
console.log((crxOop.isStructureInheriting("ExampleStructure1", "ExampleStructure3") ? "true" : "false"));
false
true
true
false
false
JS (Verbose)
crx_registerStructure("ExampleStructure1",
{
   "VERBOSE": 1
});

crx_registerStructure("ExampleStructure2",
{
   "VERBOSE": 1,
   INHERITS: ["ExampleStructure1"]
});

crx_registerStructure("ExampleStructure3",
{
   "VERBOSE": 1,
   INHERITS: ["ExampleStructure2"]
});

console.log((crxOop.isStructureInheriting("ExampleStructure1", "ExampleStructure2") ? "true" : "false"));
console.log((crxOop.isStructureInheriting("ExampleStructure2", "ExampleStructure1") ? "true" : "false"));
console.log((crxOop.isStructureInheriting("ExampleStructure3", "ExampleStructure2") ? "true" : "false"));
console.log((crxOop.isStructureInheriting("ExampleStructure3", "ExampleStructure3") ? "true" : "false"));
console.log((crxOop.isStructureInheriting("ExampleStructure1", "ExampleStructure3") ? "true" : "false"));
false
true
true
false
false

Notice how a structure is not inheriting itself. If you also want this case to return true, check the next section on crxOop.isStructureContaining().