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

6.1 crxOop.typeOf

crxOop.typeOf complements the native 'typeof', but CrxOop only understands four types,

  • $CRX_DEFINITION__INTERFACE: An interface definition object.
  • $CRX_DEFINITION__CLASS: A class definition object.
  • $CRX_DEFINITION__STRUCTURE: A structure definition object.
  • $CRX_OBJECT: An instance of a class or a structure.
  • $CRX__native: Every thing else. A native type.
JS (Tree)
var ExampleInterfaceDefinition =
{
   "function1": 0
};
crx_registerInterface("ExampleInterface", ExampleInterfaceDefinition);

var ExampleClassDefinition =
{
   PUBLIC:
   {
      VARS:
      {
         "publicVar": "I am ExampleClass"
      }
   }
};
crx_registerClass("ExampleClass", ExampleClassDefinition);

var ExampleStructureDefinition =
{
   SHARED:
   {
      PUBLIC:
      {
         VARS:
         {
            "sharedPublicVar": "I am ExampleStructure"
         }
      }
   }
}
crx_registerStructure("ExampleStructure", ExampleStructureDefinition);

console.log(crxOop.typeOf(ExampleInterfaceDefinition));
console.log(crxOop.typeOf("ExampleInterface"));
console.log(crxOop.typeOf(ExampleClassDefinition));
console.log(crxOop.typeOf("ExampleClass"));
console.log(crxOop.typeOf(ExampleStructureDefinition));
console.log(crxOop.typeOf("ExampleStructure"));
console.log(crxOop.typeOf(crx_new("ExampleClass")));
console.log(crxOop.typeOf(crx_new("ExampleStructure")));
console.log(crxOop.typeOf("a string"));
console.log(crxOop.typeOf(5));
$CRX_DEFINITION__INTERFACE
$CRX__native
$CRX_DEFINITION__CLASS
$CRX__native
$CRX_DEFINITION__STRUCTURE
$CRX__native
$CRX_OBJECT
$CRX_OBJECT
$CRX__native
$CRX__native
JS (Verbose)
var ExampleInterfaceDefinition =
{
   "function1": 0
};
crx_registerInterface("ExampleInterface", ExampleInterfaceDefinition);

var ExampleClassDefinition =
{
   "VERBOSE": 1,
   "public var publicVar": "I am ExampleClass"
};
crx_registerClass("ExampleClass", ExampleClassDefinition);

var ExampleStructureDefinition =
{
   "VERBOSE": 1,
   "shared public var sharedPublicVar": "I am ExampleStructure"
}
crx_registerStructure("ExampleStructure", ExampleStructureDefinition);

console.log(crxOop.typeOf(ExampleInterfaceDefinition));
console.log(crxOop.typeOf("ExampleInterface"));
console.log(crxOop.typeOf(ExampleClassDefinition));
console.log(crxOop.typeOf("ExampleClass"));
console.log(crxOop.typeOf(ExampleStructureDefinition));
console.log(crxOop.typeOf("ExampleStructure"));
console.log(crxOop.typeOf(crx_new("ExampleClass")));
console.log(crxOop.typeOf(crx_new("ExampleStructure")));
console.log(crxOop.typeOf("a string"));
console.log(crxOop.typeOf(5));
$CRX_DEFINITION__INTERFACE
$CRX__native
$CRX_DEFINITION__CLASS
$CRX__native
$CRX_DEFINITION__STRUCTURE
$CRX__native
$CRX_OBJECT
$CRX_OBJECT
$CRX__native
$CRX__native

Notice how registered names of classes and interface are still of type $CRX__native.