Core
Descendant Class Summary |
---|
Core.Arrays.LargeMap |
Core.Debug |
Core.ListenerList |
Core.ResourceBundle |
Class Method Summary | |
---|---|
Internal | _copyFunction() Creates a duplicate copy of a function by wrapping the original in a closure. |
Internal | _createFunction() Creates an empty function. |
Public | extend() Creates a new class, optionally extending an existing class. |
Public | get() Retrieves a value from an object hierarchy. |
Internal | _isVirtual() Determines if the specified propertyName of the specified object is a virtual property, i. |
Internal | _inherit() Installs properties from source object into destination object. |
Public | method() Creates a new function which executes a specific method of an object instance. |
Internal | _processMixins() Add properties of mixin objects to destination object. |
Public | set() Sets a value in an object hierarchy. |
Internal | _verifyAbstractImpl() Verifies that a concrete derivative of an abstract class implements abstract properties present in the base class. |
f
- the function
Core.extend(definition)
Core.extend(baseClass, definition)
Each property of the definition object will be added to the prototype of the returned defined class.
Properties that begin with a dollar-sign ($
) will be processed specially:
$construct
property, which must be a function, will be used as the constructor.
The $load
property, which must be a function, f provided, will be used as a static initializer,
executed once when the class is *defined*. The this pointer will be set to the class when
this method is executed.$static
property, an object, if provided, will have its properties installed as class variables.$abstract
property, an object or true
, if provided, will define methods that
must be implemented by derivative classes. If the value is simply true
, the object will be marked as
abstract (such that it does not necessarily need to provide implementations of abstract methods defined in its
base class.)$virtual
property, an object, if provided, defines methods that will be placed into the prototype
that may be overridden by subclasses. Attempting to override a property/method of the superclass that
is not defined in the virtual block will result in an exception. Having the default behavior NOT allow
for overriding ensures that namespacing between super- and sub-types if all internal variables are instance
during Core.extend()
.Use of this method enables a class to be derived WITHOUT executing the constructor of the base class in order to create a prototype for the derived class. This method uses a "shared prototype" architecture, where two objects are created, a "prototype class" and a "constructor class". These two objects share the same prototype, but the "prototype class" has an empty constructor. When a class created with this method is derived, the "prototype class" is used to create a prototype for the derivative.
This method will return the constructor class, which contains an internal reference to the prototype class that will be used if the returned class is later derived by this method.
baseClass
(Function)
- the base classdefinition
(Object)
- an associative array containing methods and properties of the class{ a: { b: 4, c: 2 }}
Core.get(o, ["a", "b"]) will return 4
.
Core.get(o, ["a", "c"]) will return 2
.
Core.get(o, ["a", "d"]) will return null
.
Core.get(o, ["a"]) will return { b: 4, c: 2 }
.
Core.get(o, ["b"]) will return null
.
Core.get(o, ["d"]) will return null
.
object
- an arbitrary object from which the value should be retrievedpath
(Array)
- an array of object property names describing the path to retrieveIn the case where the destination object already has a property defined and the "virtualProperties" argument is provided, the "virtualProperties" collection will be checked to ensure that property is allowed to be overridden. If "virtualProperties" is omitted, any property may be overridden.
destination
- the destination objectsoruce
- the source objectvirtualProperties
- (optional) collection of virtual properties from base class.instance
- the object instancemethod
(Function)
- the method to be invoked on the instancedestination
- the destination objectmixins
(Array)
- the mixin objects to add{ a: { b: 4, c: 2 } }
Core.set(o, ["a", "b"], 5)
will update the value of 'o' to be: { a: { b: 5, c: 2 } }
Core.set(o, ["a", "d"], 7)
will update the value of 'o' to be:
{ a: { b: 4, c: 2, d: 7 } }
Core.set(o, ["e"], 9)
will update the value of 'o' to be: { a: { b: 4, c: 2 }, e: 9 }
Core.set(o, ["f", "g"], 8)
will update the value of 'o' to be:
{ a: { b: 4, c: 2 }, f: { g: 8 } }
Core.set(o, ["a"], 10)
will update the value of 'o' to be: { a: 10 }
object
- an arbitrary object from which the value should be retrievedpath
(Array)
- an array of object property names describing the path to retrieveconstructorClass
- the class to verify