Compare commits

...

2 Commits

Author SHA1 Message Date
Theunis J. Botha ad211bb5b5 index generation for components and system 2021-07-03 16:11:19 +02:00
Theunis J. Botha 40c9c55009 components start 2021-07-03 10:40:05 +02:00
39 changed files with 1104 additions and 656 deletions

View File

@ -2,9 +2,10 @@ r3 create R3 r3-base
r3 create Event normal
r3 create R3Object extends Event
r3 create Utils normal
r3 create Component extends R3Object
r3 create Project extends R3Object
r3 create System system-base
r3 create SystemSocket system
r3 create SystemLinking system
r3 create SystemTest system
r3 create Component extends R3Object ./r3-component/
r3 create Image extends Component ./r3-component/

View File

@ -1,6 +1,15 @@
//GENERATE_IMPORTS_START
const R3 = require('./r3-r3.js');
const System = require('./r3-system/r3-system.js');
const Event = require('./r3-event.js');
const Utils = require('./r3-utils.js');
//GENERATE_IMPORTS_END
R3.System.Linking.start();
R3.System.Socket.start();
module.exports = R3;
module.exports = {
//GENERATE_EXPORTS_START
R3,
System,
Event,
Utils
//GENERATE_EXPORTS_END
}

View File

@ -1,232 +0,0 @@
const Event = require('./r3-event');
const Utils = require('./r3-utils');
const R3Object = require('r3-r3-object.js');
/**
GENERATE_INHERITED_START
Inherited from Event
Properties:
<no inherited properties>
Methods:
- async(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Async()' passing it the arguments
- emit(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Emit()' passing it the arguments
- subscribe(eventId, callback)
Simply calls 'Subscribe()' passing it the arguments
Static Methods:
- Async(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data, clientCallback and clientErrorCallback as
arguments. If an error occurs during clientCallback it additionally will execute clientErrorCallback with the
error as argument.
- Emit(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data as arg. Calls clientCallback directly after
the event result is obtained, passing it the result. If an exception occurs during execution, the
clientErrorCallback is called with the error as argument.
- Subscribe(eventId, callback)
Subscribes to 'eventName', ex. Event.BEFORE_RENDER and executes 'callback()' when eventName is raised
Inherited from R3Object
Properties:
register=true
Methods:
<no inherited methods>
Static Methods:
<no inherited static methods>
GENERATE_INHERITED_END
Of the form x=<value>
CUSTOM_OPTIONS_START
CUSTOM_OPTIONS_END
Of the form x=<instance.property>
CUSTOM_INSTANCE_OPTIONS_MAPPING_START
CUSTOM_INSTANCE_OPTIONS_MAPPING_END
CUSTOM_LINKED_OBJECTS_START
CUSTOM_LINKED_OBJECTS_END
CUSTOM_EXCLUDED_FROM_INSTANCE_OPTIONS_START
CUSTOM_EXCLUDED_FROM_INSTANCE_OPTIONS_END
CUSTOM_METHODS_START
CUSTOM_METHODS_END
CUSTOM_STATIC_METHODS_START
CUSTOM_STATIC_METHODS_END
**/
class Component extends R3Object {
//GENERATE_CONSTRUCTOR_EXTENDS_START
constructor(options) {
if (Utils.UndefinedOrNull(options)) {
options = {};
}
super(options);
this.emit(Event.OBJECT_CREATED, this);
//GENERATE_OPTIONS_INIT_START
//GENERATE_OPTIONS_INIT_END
//CUSTOM_OPTIONS_INIT_START
//CUSTOM_OPTIONS_INIT_END
Object.assign(this, options);
//CUSTOM_BEFORE_INIT_START
this.emit(Event.COMPONENT_INITIALIZED, this);
//CUSTOM_BEFORE_INIT_END
this.emit(Event.OBJECT_INITIALIZED, this);
//CUSTOM_AFTER_INIT_START
//CUSTOM_AFTER_INIT_END
}
//GENERATE_CONSTRUCTOR_EXTENDS_END
//GENERATE_CREATE_INSTANCE_START
createInstance() {
//GENERATE_CREATE_INSTANCE_BEFORE_START
this.emit(Event.CREATE_INSTANCE_BEFORE, this);
//GENERATE_CREATE_INSTANCE_BEFORE_END
//CUSTOM_CREATE_INSTANCE_START
//CUSTOM_CREATE_INSTANCE_END
//GENERATE_CREATE_INSTANCE_AFTER_START
this[this.runtime].createInstance(
this,
{
//GENERATE_CREATE_INSTANCE_OPTIONS_START
//GENERATE_CREATE_INSTANCE_OPTIONS_END
}
)
this.emit(Event.INSTANCE_CREATED, this);
//GENERATE_CREATE_INSTANCE_AFTER_END
}
//GENERATE_CREATE_INSTANCE_END
//GENERATE_UPDATE_INSTANCE_START
updateInstance(property) {
//GENERATE_UPDATE_INSTANCE_BEFORE_START
this.emit(Event.UPDATE_INSTANCE_BEFORE, this);
//GENERATE_UPDATE_INSTANCE_BEFORE_END
//GENERATE_UPDATE_INSTANCE_OPTIONS_START
//GENERATE_UPDATE_INSTANCE_OPTIONS_END
//CUSTOM_UPDATE_INSTANCE_START
//CUSTOM_UPDATE_INSTANCE_END
//GENERATE_UPDATE_INSTANCE_AFTER_START
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
//GENERATE_UPDATE_INSTANCE_AFTER_END
}
//GENERATE_UPDATE_INSTANCE_END
//GENERATE_UPDATE_FROM_INSTANCE_START
updateFromInstance(property) {
//GENERATE_UPDATE_FROM_INSTANCE_BEFORE_START
this.emit(Event.UPDATE_FROM_INSTANCE_BEFORE, this);
//GENERATE_UPDATE_FROM_INSTANCE_BEFORE_END
//GENERATE_UPDATE_FROM_INSTANCE_OPTIONS_START
//GENERATE_UPDATE_FROM_INSTANCE_OPTIONS_END
//CUSTOM_UPDATE_FROM_INSTANCE_START
//CUSTOM_UPDATE_FROM_INSTANCE_END
//GENERATE_UPDATE_FROM_INSTANCE_AFTER_START
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
//GENERATE_UPDATE_FROM_INSTANCE_AFTER_END
}
//GENERATE_UPDATE_FROM_INSTANCE_END
//GENERATE_DISPOSE_START
dispose() {
//GENERATE_DISPOSE_BEFORE_START
this.subscribe(
Event.INSTANCE_DISPOSED,
function(object) {
if (object === this) {
this.emit(Event.DISPOSE_OBJECT, this);
}
}
);
//GENERATE_DISPOSE_BEFORE_END
//CUSTOM_DISPOSE_START
//CUSTOM_DISPOSE_END
//GENERATE_DISPOSE_AFTER_START
this.disposeInstance();
//GENERATE_DISPOSE_AFTER_END
}
//GENERATE_DISPOSE_END
//GENERATE_DISPOSE_INSTANCE_START
disposeInstance() {
//GENERATE_DISPOSE_INSTANCE_BEFORE_START
console.log('Disposing instance of ' + this.name);
//GENERATE_DISPOSE_INSTANCE_BEFORE_END
//CUSTOM_DISPOSE_INSTANCE_START
//CUSTOM_DISPOSE_INSTANCE_END
//GENERATE_DISPOSE_INSTANCE_AFTER_START
this.emit(Event.DISPOSE_INSTANCE, this);
//GENERATE_DISPOSE_INSTANCE_AFTER_END
}
//GENERATE_DISPOSE_INSTANCE_END
//GENERATE_METHODS_START
//GENERATE_METHODS_END
//GENERATE_STATIC_METHODS_START
//GENERATE_STATIC_METHODS_END
//CUSTOM_IMPLEMENTATION_START
//CUSTOM_IMPLEMENTATION_END
}
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_START
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_END
module.exports = Component;

View File

@ -0,0 +1,11 @@
//GENERATE_IMPORTS_START
const Component = require('./r3-component.js');
const Image = require('./r3-image.js');
//GENERATE_IMPORTS_END
module.exports = {
//GENERATE_EXPORTS_START
Component,
Image
//GENERATE_EXPORTS_END
}

View File

@ -0,0 +1,352 @@
const Event = require('.././r3-event');
const Utils = require('.././r3-utils');
const R3Object = require('.././r3-r3-object.js');
/**
GENERATE_INHERITED_START
[Inherited from Event]
Properties:
<no inherited properties>
Methods:
- async(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Async()' passing it the arguments
- emit(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Emit()' passing it the arguments
- subscribe(eventId, callback)
Simply calls 'Subscribe()' passing it the arguments
Static Methods:
- Async(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data, clientCallback and clientErrorCallback as
arguments. If an error occurs during clientCallback it additionally will execute clientErrorCallback with the
error as argument.
- Emit(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data as arg. Calls clientCallback directly after
the event result is obtained, passing it the result. If an exception occurs during execution, the
clientErrorCallback is called with the error as argument.
- Subscribe(eventId, callback)
Subscribes to 'eventName', ex. Event.BEFORE_RENDER and executes 'callback()' when eventName is raised
[Inherited from R3Object]
Properties:
- register (Default value true)
Methods:
<no inherited methods>
Static Methods:
<no inherited static methods>
[Belonging to Component]
Properties:
- x (Default value 0)
- y (Default value 0)
- z (Default value 0)
Methods:
- createInstance()
Creates an instance of this object based on the runtime.
- updateInstance(property)
Updates the instance property, ex. 'x', or specify 'all' to update all properties based on the current object
property(ies)
- updateFromInstance(property)
Updates the object property, ex. 'x', or specify 'all' to update all properties of this object based on the
value of the instance property(ies)
- dispose()
Sends out a notification that this object wants to be deleted. It will first send out a message to delete it's
instance, because an object instance should not exist without an object parent (except maybe for particles)
- disposeInstance()
This will signal all systems that an instance wants to be deleted. Once it has been deleted, another event
will be triggered to notify listeners of the deletion of this instance. This can give 'dispose()' a chance to
dispose the object parent this instance.
- toApiObject()
Transforms the current object into JSON ready to be stored to the back-end.
Static Methods:
<no static methods>
GENERATE_INHERITED_END
Of the form x=<value>
CUSTOM_OPTIONS_START
x=0
y=0
z=0
CUSTOM_OPTIONS_END
Of the form x=<instance.property>
CUSTOM_INSTANCE_OPTIONS_MAPPING_START
CUSTOM_INSTANCE_OPTIONS_MAPPING_END
CUSTOM_LINKED_OBJECTS_START
CUSTOM_LINKED_OBJECTS_END
CUSTOM_EXCLUDED_FROM_INSTANCE_OPTIONS_START
CUSTOM_EXCLUDED_FROM_INSTANCE_OPTIONS_END
CUSTOM_METHODS_START
createInstance() - Creates an instance of this object based on the runtime.
updateInstance(property) - Updates the instance property, ex. 'x', or specify 'all' to update all properties based on the current object property(ies)
updateFromInstance(property) - Updates the object property, ex. 'x', or specify 'all' to update all properties of this object based on the value of the instance property(ies)
dispose() - Sends out a notification that this object wants to be deleted. It will first send out a message to delete it's instance, because an object instance should not exist without an object parent (except maybe for particles)
disposeInstance() - This will signal all systems that an instance wants to be deleted. Once it has been deleted, another event will be triggered to notify listeners of the deletion of this instance. This can give 'dispose()' a chance to dispose the object parent this instance.
toApiObject() - Transforms the current object into JSON ready to be stored to the back-end. @returns JSON
CUSTOM_METHODS_END
CUSTOM_STATIC_METHODS_START
CUSTOM_STATIC_METHODS_END
**/
class Component extends R3Object {
//GENERATE_CONSTRUCTOR_EXTENDS_START
constructor(options) {
if (Utils.UndefinedOrNull(options)) {
options = {};
}
super(options);
this.emit(Event.OBJECT_CREATED, this);
//GENERATE_OPTIONS_INIT_START
if (typeof options === 'undefined') {
options = {};
}
if (Utils.UndefinedOrNull(options.x)) {
options.x = 0;
}
if (Utils.UndefinedOrNull(options.y)) {
options.y = 0;
}
if (Utils.UndefinedOrNull(options.z)) {
options.z = 0;
}
//GENERATE_OPTIONS_INIT_END
//CUSTOM_OPTIONS_INIT_START
//CUSTOM_OPTIONS_INIT_END
Object.assign(this, options);
//CUSTOM_BEFORE_INIT_START
//CUSTOM_BEFORE_INIT_END
this.emit(Event.OBJECT_INITIALIZED, this);
//CUSTOM_AFTER_INIT_START
//CUSTOM_AFTER_INIT_END
}
//GENERATE_CONSTRUCTOR_EXTENDS_END
//GENERATE_METHODS_START
/**
* createInstance()
* - Creates an instance of this object based on the runtime.
*/
createInstance() {
//GENERATE_CREATE_INSTANCE_METHOD_START
this.emit(Event.CREATE_INSTANCE_BEFORE, this);
this[this.runtime].createInstance(
this,
{
//GENERATE_CREATE_INSTANCE_OPTIONS_START
'x': this.x,
'y': this.y,
'z': this.z
//GENERATE_CREATE_INSTANCE_OPTIONS_END
}
)
this.emit(Event.INSTANCE_CREATED, this);
//GENERATE_CREATE_INSTANCE_METHOD_END
//CUSTOM_CREATE_INSTANCE_METHOD_START
//CUSTOM_CREATE_INSTANCE_METHOD_END
}
/**
* updateInstance()
* - Updates the instance property, ex. 'x', or specify 'all' to update all properties based on the current object
* property(ies)
* @param property
*/
updateInstance(property) {
//GENERATE_UPDATE_INSTANCE_METHOD_START
this.emit(Event.UPDATE_INSTANCE_BEFORE, this);
//GENERATE_UPDATE_INSTANCE_OPTIONS_START
if (property === 'x') {
this.instance.x = this.x;
if (property !== 'all') {
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
return;
}
}
if (property === 'y') {
this.instance.y = this.y;
if (property !== 'all') {
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
return;
}
}
if (property === 'z') {
this.instance.z = this.z;
if (property !== 'all') {
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
return;
}
}
//GENERATE_UPDATE_INSTANCE_OPTIONS_END
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
//GENERATE_UPDATE_INSTANCE_METHOD_END
//CUSTOM_UPDATE_INSTANCE_METHOD_START
//CUSTOM_UPDATE_INSTANCE_METHOD_END
}
/**
* updateFromInstance()
* - Updates the object property, ex. 'x', or specify 'all' to update all properties of this object based on the
* value of the instance property(ies)
* @param property
*/
updateFromInstance(property) {
//GENERATE_UPDATE_FROM_INSTANCE_METHOD_START
this.emit(Event.UPDATE_FROM_INSTANCE_BEFORE, this);
//GENERATE_UPDATE_FROM_INSTANCE_OPTIONS_START
if (property === 'x' || property === 'all') {
this.x = this.instance.x;
if (property !== 'all') {
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
return;
}
}
if (property === 'y' || property === 'all') {
this.y = this.instance.y;
if (property !== 'all') {
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
return;
}
}
if (property === 'z' || property === 'all') {
this.z = this.instance.z;
if (property !== 'all') {
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
return;
}
}
//GENERATE_UPDATE_FROM_INSTANCE_OPTIONS_END
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
//GENERATE_UPDATE_FROM_INSTANCE_METHOD_END
//CUSTOM_UPDATE_FROM_INSTANCE_METHOD_START
//CUSTOM_UPDATE_FROM_INSTANCE_METHOD_END
}
/**
* dispose()
* - Sends out a notification that this object wants to be deleted. It will first send out a message to delete it's
* instance, because an object instance should not exist without an object parent (except maybe for particles)
*/
dispose() {
//GENERATE_DISPOSE_METHOD_START
this.subscribe(
Event.INSTANCE_DISPOSED,
function(object) {
if (object === this) {
this.emit(Event.DISPOSE_OBJECT, this);
}
}
);
this.disposeInstance();
//GENERATE_DISPOSE_METHOD_END
//CUSTOM_DISPOSE_METHOD_START
//CUSTOM_DISPOSE_METHOD_END
}
/**
* disposeInstance()
* - This will signal all systems that an instance wants to be deleted. Once it has been deleted, another event
* will be triggered to notify listeners of the deletion of this instance. This can give 'dispose()' a chance to
* dispose the object parent this instance.
*/
disposeInstance() {
//GENERATE_DISPOSE_INSTANCE_METHOD_START
console.log('Disposing instance of ' + this.name);
this.emit(Event.DISPOSE_INSTANCE, this);
//GENERATE_DISPOSE_INSTANCE_METHOD_END
//CUSTOM_DISPOSE_INSTANCE_METHOD_START
//CUSTOM_DISPOSE_INSTANCE_METHOD_END
}
/**
* toApiObject()
* - Transforms the current object into JSON ready to be stored to the back-end. \n * @returns JSON
*/
toApiObject() {
//GENERATE_TO_API_OBJECT_METHOD_START
//GENERATE_TO_API_OBJECT_METHOD_END
//CUSTOM_TO_API_OBJECT_METHOD_START
//CUSTOM_TO_API_OBJECT_METHOD_END
}
//GENERATE_METHODS_END
//GENERATE_STATIC_METHODS_START
//GENERATE_STATIC_METHODS_END
//CUSTOM_IMPLEMENTATION_START
//CUSTOM_IMPLEMENTATION_END
}
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_START
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_END
module.exports = Component;

View File

@ -0,0 +1,327 @@
const Event = require('.././r3-event');
const Utils = require('.././r3-utils');
const Component = require('.././r3-component.js');
/**
GENERATE_INHERITED_START
[Inherited from Event]
Properties:
<no inherited properties>
Methods:
- async(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Async()' passing it the arguments
- emit(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Emit()' passing it the arguments
- subscribe(eventId, callback)
Simply calls 'Subscribe()' passing it the arguments
Static Methods:
- Async(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data, clientCallback and clientErrorCallback as
arguments. If an error occurs during clientCallback it additionally will execute clientErrorCallback with the
error as argument.
- Emit(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data as arg. Calls clientCallback directly after
the event result is obtained, passing it the result. If an exception occurs during execution, the
clientErrorCallback is called with the error as argument.
- Subscribe(eventId, callback)
Subscribes to 'eventName', ex. Event.BEFORE_RENDER and executes 'callback()' when eventName is raised
[Inherited from R3Object]
Properties:
- register (Default value true)
Methods:
<no inherited methods>
Static Methods:
<no inherited static methods>
[Inherited from Component]
Properties:
- x (Default value 0)
- y (Default value 0)
- z (Default value 0)
Methods:
- createInstance()
Creates an instance of this object based on the runtime.
- updateInstance(property)
Updates the instance property, ex. 'x', or specify 'all' to update all properties based on the current object
property(ies)
- updateFromInstance(property)
Updates the object property, ex. 'x', or specify 'all' to update all properties of this object based on the
value of the instance property(ies)
- dispose()
Sends out a notification that this object wants to be deleted. It will first send out a message to delete it's
instance, because an object instance should not exist without an object parent (except maybe for particles)
- disposeInstance()
This will signal all systems that an instance wants to be deleted. Once it has been deleted, another event
will be triggered to notify listeners of the deletion of this instance. This can give 'dispose()' a chance to
dispose the object parent this instance.
- toApiObject()
Transforms the current object into JSON ready to be stored to the back-end.
Static Methods:
<no inherited static methods>
[Belonging to Image]
Properties:
<no static properties>
Methods:
- createInstance()
Creates an instance of this object based on the runtime.
- updateInstance(property)
Updates the instance property, ex. 'x', or specify 'all' to update all properties based on the current object
property(ies)
- updateFromInstance(property)
Updates the object property, ex. 'x', or specify 'all' to update all properties of this object based on the
value of the instance property(ies)
- dispose()
Sends out a notification that this object wants to be deleted. It will first send out a message to delete it's
instance, because an object instance should not exist without an object parent (except maybe for particles)
- disposeInstance()
This will signal all systems that an instance wants to be deleted. Once it has been deleted, another event
will be triggered to notify listeners of the deletion of this instance. This can give 'dispose()' a chance to
dispose the object parent this instance.
- toApiObject()
Transforms the current object into JSON ready to be stored to the back-end.
Static Methods:
<no static methods>
GENERATE_INHERITED_END
Of the form x=<value>
CUSTOM_OPTIONS_START
CUSTOM_OPTIONS_END
Of the form x=<instance.property>
CUSTOM_INSTANCE_OPTIONS_MAPPING_START
CUSTOM_INSTANCE_OPTIONS_MAPPING_END
CUSTOM_LINKED_OBJECTS_START
CUSTOM_LINKED_OBJECTS_END
CUSTOM_EXCLUDED_FROM_INSTANCE_OPTIONS_START
CUSTOM_EXCLUDED_FROM_INSTANCE_OPTIONS_END
CUSTOM_METHODS_START
createInstance() - Creates an instance of this object based on the runtime.
updateInstance(property) - Updates the instance property, ex. 'x', or specify 'all' to update all properties based on the current object property(ies)
updateFromInstance(property) - Updates the object property, ex. 'x', or specify 'all' to update all properties of this object based on the value of the instance property(ies)
dispose() - Sends out a notification that this object wants to be deleted. It will first send out a message to delete it's instance, because an object instance should not exist without an object parent (except maybe for particles)
disposeInstance() - This will signal all systems that an instance wants to be deleted. Once it has been deleted, another event will be triggered to notify listeners of the deletion of this instance. This can give 'dispose()' a chance to dispose the object parent this instance.
toApiObject() - Transforms the current object into JSON ready to be stored to the back-end. @returns JSON
CUSTOM_METHODS_END
CUSTOM_STATIC_METHODS_START
CUSTOM_STATIC_METHODS_END
**/
class Image extends Component {
//GENERATE_CONSTRUCTOR_EXTENDS_START
constructor(options) {
if (Utils.UndefinedOrNull(options)) {
options = {};
}
super(options);
this.emit(Event.OBJECT_CREATED, this);
//GENERATE_OPTIONS_INIT_START
//GENERATE_OPTIONS_INIT_END
//CUSTOM_OPTIONS_INIT_START
//CUSTOM_OPTIONS_INIT_END
Object.assign(this, options);
//CUSTOM_BEFORE_INIT_START
//CUSTOM_BEFORE_INIT_END
this.emit(Event.OBJECT_INITIALIZED, this);
//CUSTOM_AFTER_INIT_START
//CUSTOM_AFTER_INIT_END
}
//GENERATE_CONSTRUCTOR_EXTENDS_END
//GENERATE_METHODS_START
/**
* createInstance()
* - Creates an instance of this object based on the runtime.
*/
createInstance() {
//GENERATE_CREATE_INSTANCE_METHOD_START
this.emit(Event.CREATE_INSTANCE_BEFORE, this);
this[this.runtime].createInstance(
this,
{
//GENERATE_CREATE_INSTANCE_OPTIONS_START
//GENERATE_CREATE_INSTANCE_OPTIONS_END
}
)
this.emit(Event.INSTANCE_CREATED, this);
//GENERATE_CREATE_INSTANCE_METHOD_END
//CUSTOM_CREATE_INSTANCE_METHOD_START
//CUSTOM_CREATE_INSTANCE_METHOD_END
}
/**
* updateInstance()
* - Updates the instance property, ex. 'x', or specify 'all' to update all properties based on the current object
* property(ies)
* @param property
*/
updateInstance(property) {
//GENERATE_UPDATE_INSTANCE_METHOD_START
this.emit(Event.UPDATE_INSTANCE_BEFORE, this);
//GENERATE_UPDATE_INSTANCE_OPTIONS_START
//GENERATE_UPDATE_INSTANCE_OPTIONS_END
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
//GENERATE_UPDATE_INSTANCE_METHOD_END
//CUSTOM_UPDATE_INSTANCE_METHOD_START
//CUSTOM_UPDATE_INSTANCE_METHOD_END
}
/**
* updateFromInstance()
* - Updates the object property, ex. 'x', or specify 'all' to update all properties of this object based on the
* value of the instance property(ies)
* @param property
*/
updateFromInstance(property) {
//GENERATE_UPDATE_FROM_INSTANCE_METHOD_START
this.emit(Event.UPDATE_FROM_INSTANCE_BEFORE, this);
//GENERATE_UPDATE_FROM_INSTANCE_OPTIONS_START
//GENERATE_UPDATE_FROM_INSTANCE_OPTIONS_END
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
//GENERATE_UPDATE_FROM_INSTANCE_METHOD_END
//CUSTOM_UPDATE_FROM_INSTANCE_METHOD_START
//CUSTOM_UPDATE_FROM_INSTANCE_METHOD_END
}
/**
* dispose()
* - Sends out a notification that this object wants to be deleted. It will first send out a message to delete it's
* instance, because an object instance should not exist without an object parent (except maybe for particles)
*/
dispose() {
//GENERATE_DISPOSE_METHOD_START
this.subscribe(
Event.INSTANCE_DISPOSED,
function(object) {
if (object === this) {
this.emit(Event.DISPOSE_OBJECT, this);
}
}
);
this.disposeInstance();
//GENERATE_DISPOSE_METHOD_END
//CUSTOM_DISPOSE_METHOD_START
//CUSTOM_DISPOSE_METHOD_END
}
/**
* disposeInstance()
* - This will signal all systems that an instance wants to be deleted. Once it has been deleted, another event
* will be triggered to notify listeners of the deletion of this instance. This can give 'dispose()' a chance to
* dispose the object parent this instance.
*/
disposeInstance() {
//GENERATE_DISPOSE_INSTANCE_METHOD_START
console.log('Disposing instance of ' + this.name);
this.emit(Event.DISPOSE_INSTANCE, this);
//GENERATE_DISPOSE_INSTANCE_METHOD_END
//CUSTOM_DISPOSE_INSTANCE_METHOD_START
//CUSTOM_DISPOSE_INSTANCE_METHOD_END
}
/**
* toApiObject()
* - Transforms the current object into JSON ready to be stored to the back-end. \n * @returns JSON
*/
toApiObject() {
//GENERATE_TO_API_OBJECT_METHOD_START
//GENERATE_TO_API_OBJECT_METHOD_END
//CUSTOM_TO_API_OBJECT_METHOD_START
//CUSTOM_TO_API_OBJECT_METHOD_END
}
//GENERATE_METHODS_END
//GENERATE_STATIC_METHODS_START
//GENERATE_STATIC_METHODS_END
//CUSTOM_IMPLEMENTATION_START
//CUSTOM_IMPLEMENTATION_END
}
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_START
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_END
module.exports = Image;

View File

@ -2,6 +2,10 @@ const Utils = require('./r3-utils');
/**
GENERATE_INHERITED_START
GENERATE_INHERITED_END
CUSTOM_OPTIONS_START
CUSTOM_OPTIONS_END
@ -58,7 +62,8 @@ class Event {
/**
* async()
* - Simply calls 'Async()' passing it the arguments @param eventId
* - Simply calls 'Async()' passing it the arguments
* @param eventId
* @param data
* @param clientCallback
* @param clientErrorCallback
@ -70,6 +75,9 @@ class Event {
clientErrorCallback
) {
//GENERATE_ASYNC_METHOD_START
//GENERATE_ASYNC_METHOD_END
//CUSTOM_ASYNC_METHOD_START
return Event.Async(
eventId,
@ -83,7 +91,8 @@ class Event {
/**
* emit()
* - Simply calls 'Emit()' passing it the arguments @param eventId
* - Simply calls 'Emit()' passing it the arguments
* @param eventId
* @param data
* @param clientCallback
* @param clientErrorCallback
@ -95,6 +104,9 @@ class Event {
clientErrorCallback
) {
//GENERATE_EMIT_METHOD_START
//GENERATE_EMIT_METHOD_END
//CUSTOM_EMIT_METHOD_START
return Event.Emit(
eventId,
@ -108,7 +120,8 @@ class Event {
/**
* subscribe()
* - Simply calls 'Subscribe()' passing it the arguments @param eventId
* - Simply calls 'Subscribe()' passing it the arguments
* @param eventId
* @param callback
*/
subscribe(
@ -116,6 +129,9 @@ class Event {
callback
) {
//GENERATE_SUBSCRIBE_METHOD_START
//GENERATE_SUBSCRIBE_METHOD_END
//CUSTOM_SUBSCRIBE_METHOD_START
return Event.Subscribe(eventId, callback.bind(this));
//CUSTOM_SUBSCRIBE_METHOD_END
@ -129,7 +145,8 @@ class Event {
* Async()
* - Calls all subscription functions registered to eventId with data, clientCallback and clientErrorCallback as
* arguments. If an error occurs during clientCallback it additionally will execute clientErrorCallback with the
* error as argument. @param eventId
* error as argument.
* @param eventId
* @param data
* @param clientCallback
* @param clientErrorCallback
@ -141,6 +158,9 @@ class Event {
clientErrorCallback
) {
//GENERATE_STATIC_ASYNC_METHOD_START
//GENERATE_STATIC_ASYNC_METHOD_END
//CUSTOM_STATIC_ASYNC_METHOD_START
if (Event.Subscriptions.hasOwnProperty(eventId)) {
@ -169,7 +189,8 @@ class Event {
* Emit()
* - Calls all subscription functions registered to eventId with data as arg. Calls clientCallback directly after
* the event result is obtained, passing it the result. If an exception occurs during execution, the
* clientErrorCallback is called with the error as argument. @param eventId
* clientErrorCallback is called with the error as argument.
* @param eventId
* @param data
* @param clientCallback
* @param clientErrorCallback
@ -181,6 +202,9 @@ class Event {
clientErrorCallback
) {
//GENERATE_STATIC_EMIT_METHOD_START
//GENERATE_STATIC_EMIT_METHOD_END
//CUSTOM_STATIC_EMIT_METHOD_START
if (Event.Subscriptions.hasOwnProperty(eventId)) {
@ -211,7 +235,8 @@ class Event {
/**
* Subscribe()
* - Subscribes to 'eventName', ex. Event.BEFORE_RENDER and executes 'callback()' when eventName is raised @param eventId
* - Subscribes to 'eventName', ex. Event.BEFORE_RENDER and executes 'callback()' when eventName is raised
* @param eventId
* @param callback \n * @returns {Object} - A handle to the subscription which can be removed by calling handle.remove()
*/
static Subscribe(
@ -219,6 +244,9 @@ class Event {
callback
) {
//GENERATE_STATIC_SUBSCRIBE_METHOD_START
//GENERATE_STATIC_SUBSCRIBE_METHOD_END
//CUSTOM_STATIC_SUBSCRIBE_METHOD_START
let subscriptionId = Utils.RandomId(10);

View File

@ -1,12 +1,12 @@
const Event = require('./r3-event');
const Utils = require('./r3-utils');
const R3Object = require('r3-r3-object.js');
const R3Object = require('./r3-r3-object.js');
/**
GENERATE_INHERITED_START
Inherited from Event
[Inherited from Event]
Properties:
@ -17,13 +17,12 @@ const R3Object = require('r3-r3-object.js');
- async(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Async()' passing it the arguments
- emit(eventId, data, clientCallback, clientErrorCallback)
- emit(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Emit()' passing it the arguments
- subscribe(eventId, callback)
- subscribe(eventId, callback)
Simply calls 'Subscribe()' passing it the arguments
Static Methods:
- Async(eventId, data, clientCallback, clientErrorCallback)
@ -31,21 +30,19 @@ const R3Object = require('r3-r3-object.js');
arguments. If an error occurs during clientCallback it additionally will execute clientErrorCallback with the
error as argument.
- Emit(eventId, data, clientCallback, clientErrorCallback)
- Emit(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data as arg. Calls clientCallback directly after
the event result is obtained, passing it the result. If an exception occurs during execution, the
clientErrorCallback is called with the error as argument.
- Subscribe(eventId, callback)
- Subscribe(eventId, callback)
Subscribes to 'eventName', ex. Event.BEFORE_RENDER and executes 'callback()' when eventName is raised
Inherited from R3Object
[Inherited from R3Object]
Properties:
register=true
- register (Default value true)
Methods:
@ -55,6 +52,20 @@ const R3Object = require('r3-r3-object.js');
<no inherited static methods>
[Belonging to Project]
Properties:
<no static properties>
Methods:
<no methods>
Static Methods:
<no static methods>
GENERATE_INHERITED_END
Of the form x=<value>
@ -110,111 +121,6 @@ class Project extends R3Object {
}
//GENERATE_CONSTRUCTOR_EXTENDS_END
//GENERATE_CREATE_INSTANCE_START
createInstance() {
//GENERATE_CREATE_INSTANCE_BEFORE_START
this.emit(Event.CREATE_INSTANCE_BEFORE, this);
//GENERATE_CREATE_INSTANCE_BEFORE_END
//CUSTOM_CREATE_INSTANCE_START
//CUSTOM_CREATE_INSTANCE_END
//GENERATE_CREATE_INSTANCE_AFTER_START
this[this.runtime].createInstance(
this,
{
//GENERATE_CREATE_INSTANCE_OPTIONS_START
//GENERATE_CREATE_INSTANCE_OPTIONS_END
}
)
this.emit(Event.INSTANCE_CREATED, this);
//GENERATE_CREATE_INSTANCE_AFTER_END
}
//GENERATE_CREATE_INSTANCE_END
//GENERATE_UPDATE_INSTANCE_START
updateInstance(property) {
//GENERATE_UPDATE_INSTANCE_BEFORE_START
this.emit(Event.UPDATE_INSTANCE_BEFORE, this);
//GENERATE_UPDATE_INSTANCE_BEFORE_END
//GENERATE_UPDATE_INSTANCE_OPTIONS_START
//GENERATE_UPDATE_INSTANCE_OPTIONS_END
//CUSTOM_UPDATE_INSTANCE_START
//CUSTOM_UPDATE_INSTANCE_END
//GENERATE_UPDATE_INSTANCE_AFTER_START
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
//GENERATE_UPDATE_INSTANCE_AFTER_END
}
//GENERATE_UPDATE_INSTANCE_END
//GENERATE_UPDATE_FROM_INSTANCE_START
updateFromInstance(property) {
//GENERATE_UPDATE_FROM_INSTANCE_BEFORE_START
this.emit(Event.UPDATE_FROM_INSTANCE_BEFORE, this);
//GENERATE_UPDATE_FROM_INSTANCE_BEFORE_END
//GENERATE_UPDATE_FROM_INSTANCE_OPTIONS_START
//GENERATE_UPDATE_FROM_INSTANCE_OPTIONS_END
//CUSTOM_UPDATE_FROM_INSTANCE_START
//CUSTOM_UPDATE_FROM_INSTANCE_END
//GENERATE_UPDATE_FROM_INSTANCE_AFTER_START
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
//GENERATE_UPDATE_FROM_INSTANCE_AFTER_END
}
//GENERATE_UPDATE_FROM_INSTANCE_END
//GENERATE_DISPOSE_START
dispose() {
//GENERATE_DISPOSE_BEFORE_START
this.subscribe(
Event.INSTANCE_DISPOSED,
function(object) {
if (object === this) {
this.emit(Event.DISPOSE_OBJECT, this);
}
}
);
//GENERATE_DISPOSE_BEFORE_END
//CUSTOM_DISPOSE_START
//CUSTOM_DISPOSE_END
//GENERATE_DISPOSE_AFTER_START
this.disposeInstance();
//GENERATE_DISPOSE_AFTER_END
}
//GENERATE_DISPOSE_END
//GENERATE_DISPOSE_INSTANCE_START
disposeInstance() {
//GENERATE_DISPOSE_INSTANCE_BEFORE_START
console.log('Disposing instance of ' + this.name);
//GENERATE_DISPOSE_INSTANCE_BEFORE_END
//CUSTOM_DISPOSE_INSTANCE_START
//CUSTOM_DISPOSE_INSTANCE_END
//GENERATE_DISPOSE_INSTANCE_AFTER_START
this.emit(Event.DISPOSE_INSTANCE, this);
//GENERATE_DISPOSE_INSTANCE_AFTER_END
}
//GENERATE_DISPOSE_INSTANCE_END
//GENERATE_METHODS_START
//GENERATE_METHODS_END

View File

@ -1,11 +1,11 @@
const Utils = require('./r3-utils');
const Event = require('r3-event.js');
const Event = require('./r3-event.js');
/**
GENERATE_INHERITED_START
Inherited from Event
[Inherited from Event]
Properties:
@ -16,13 +16,12 @@ const Event = require('r3-event.js');
- async(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Async()' passing it the arguments
- emit(eventId, data, clientCallback, clientErrorCallback)
- emit(eventId, data, clientCallback, clientErrorCallback)
Simply calls 'Emit()' passing it the arguments
- subscribe(eventId, callback)
- subscribe(eventId, callback)
Simply calls 'Subscribe()' passing it the arguments
Static Methods:
- Async(eventId, data, clientCallback, clientErrorCallback)
@ -30,14 +29,27 @@ const Event = require('r3-event.js');
arguments. If an error occurs during clientCallback it additionally will execute clientErrorCallback with the
error as argument.
- Emit(eventId, data, clientCallback, clientErrorCallback)
- Emit(eventId, data, clientCallback, clientErrorCallback)
Calls all subscription functions registered to eventId with data as arg. Calls clientCallback directly after
the event result is obtained, passing it the result. If an exception occurs during execution, the
clientErrorCallback is called with the error as argument.
- Subscribe(eventId, callback)
- Subscribe(eventId, callback)
Subscribes to 'eventName', ex. Event.BEFORE_RENDER and executes 'callback()' when eventName is raised
[Belonging to R3Object]
Properties:
- register (Default value true)
Methods:
<no methods>
Static Methods:
<no static methods>
GENERATE_INHERITED_END
@ -101,126 +113,6 @@ class R3Object extends Event {
}
//GENERATE_CONSTRUCTOR_EXTENDS_END
//GENERATE_CREATE_INSTANCE_START
createInstance() {
//GENERATE_CREATE_INSTANCE_BEFORE_START
this.emit(Event.CREATE_INSTANCE_BEFORE, this);
//GENERATE_CREATE_INSTANCE_BEFORE_END
//CUSTOM_CREATE_INSTANCE_START
//CUSTOM_CREATE_INSTANCE_END
//GENERATE_CREATE_INSTANCE_AFTER_START
this[this.runtime].createInstance(
this,
{
//GENERATE_CREATE_INSTANCE_OPTIONS_START
'register': this.register
//GENERATE_CREATE_INSTANCE_OPTIONS_END
}
)
this.emit(Event.INSTANCE_CREATED, this);
//GENERATE_CREATE_INSTANCE_AFTER_END
}
//GENERATE_CREATE_INSTANCE_END
//GENERATE_UPDATE_INSTANCE_START
updateInstance(property) {
//GENERATE_UPDATE_INSTANCE_BEFORE_START
this.emit(Event.UPDATE_INSTANCE_BEFORE, this);
//GENERATE_UPDATE_INSTANCE_BEFORE_END
//GENERATE_UPDATE_INSTANCE_OPTIONS_START
if (property === 'register') {
this.instance.register = this.register;
if (property !== 'all') {
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
return;
}
}
//GENERATE_UPDATE_INSTANCE_OPTIONS_END
//CUSTOM_UPDATE_INSTANCE_START
//CUSTOM_UPDATE_INSTANCE_END
//GENERATE_UPDATE_INSTANCE_AFTER_START
this.emit(Event.UPDATE_INSTANCE_AFTER, this);
//GENERATE_UPDATE_INSTANCE_AFTER_END
}
//GENERATE_UPDATE_INSTANCE_END
//GENERATE_UPDATE_FROM_INSTANCE_START
updateFromInstance(property) {
//GENERATE_UPDATE_FROM_INSTANCE_BEFORE_START
this.emit(Event.UPDATE_FROM_INSTANCE_BEFORE, this);
//GENERATE_UPDATE_FROM_INSTANCE_BEFORE_END
//GENERATE_UPDATE_FROM_INSTANCE_OPTIONS_START
if (property === 'register' || property === 'all') {
this.register = this.instance.register;
if (property !== 'all') {
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
return;
}
}
//GENERATE_UPDATE_FROM_INSTANCE_OPTIONS_END
//CUSTOM_UPDATE_FROM_INSTANCE_START
//CUSTOM_UPDATE_FROM_INSTANCE_END
//GENERATE_UPDATE_FROM_INSTANCE_AFTER_START
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);
//GENERATE_UPDATE_FROM_INSTANCE_AFTER_END
}
//GENERATE_UPDATE_FROM_INSTANCE_END
//GENERATE_DISPOSE_START
dispose() {
//GENERATE_DISPOSE_BEFORE_START
this.subscribe(
Event.INSTANCE_DISPOSED,
function(object) {
if (object === this) {
this.emit(Event.DISPOSE_OBJECT, this);
}
}
);
//GENERATE_DISPOSE_BEFORE_END
//CUSTOM_DISPOSE_START
//CUSTOM_DISPOSE_END
//GENERATE_DISPOSE_AFTER_START
this.disposeInstance();
//GENERATE_DISPOSE_AFTER_END
}
//GENERATE_DISPOSE_END
//GENERATE_DISPOSE_INSTANCE_START
disposeInstance() {
//GENERATE_DISPOSE_INSTANCE_BEFORE_START
console.log('Disposing instance of ' + this.name);
//GENERATE_DISPOSE_INSTANCE_BEFORE_END
//CUSTOM_DISPOSE_INSTANCE_START
//CUSTOM_DISPOSE_INSTANCE_END
//GENERATE_DISPOSE_INSTANCE_AFTER_START
this.emit(Event.DISPOSE_INSTANCE, this);
//GENERATE_DISPOSE_INSTANCE_AFTER_END
}
//GENERATE_DISPOSE_INSTANCE_END
//GENERATE_METHODS_START
//GENERATE_METHODS_END

View File

@ -1,9 +1,15 @@
//GENERATE_IMPORTS_START
const System = require('./r3-system.js');
const SystemLinking = require('./r3-system-linking.js');
const SystemSocket = require('./r3-system-socket.js');
const SystemTest = require('./r3-system-test.js');
//GENERATE_IMPORTS_END
module.exports = {
//GENERATE_EXPORTS_START
System,
SystemLinking,
SystemSocket
SystemSocket,
SystemTest
//GENERATE_EXPORTS_END
}

View File

@ -6,29 +6,41 @@ const System = require('./r3-system.js');
GENERATE_INHERITED_START
Inherited from System
[Inherited from System]
Properties:
started=false
- started (Default value false)
Methods:
- start(options)
Just calls System.Start(options)
- stop(options)
- stop(options)
Just calls System.Stop(options)
Static Methods:
- Start(options)
Starts the system by registering subscriptions to events
- Stop(options)
- Stop(options)
Stops the system by removing these subscriptions to events
[Belonging to SystemLinking]
Properties:
<no static properties>
Methods:
<no methods>
Static Methods:
<no static methods>
GENERATE_INHERITED_END

View File

@ -6,29 +6,41 @@ const System = require('./r3-system.js');
GENERATE_INHERITED_START
Inherited from System
[Inherited from System]
Properties:
started=false
- started (Default value false)
Methods:
- start(options)
Just calls System.Start(options)
- stop(options)
- stop(options)
Just calls System.Stop(options)
Static Methods:
- Start(options)
Starts the system by registering subscriptions to events
- Stop(options)
- Stop(options)
Stops the system by removing these subscriptions to events
[Belonging to SystemSocket]
Properties:
<no static properties>
Methods:
<no methods>
Static Methods:
<no static methods>
GENERATE_INHERITED_END

View File

@ -6,29 +6,41 @@ const System = require('./r3-system.js');
GENERATE_INHERITED_START
Inherited from System
[Inherited from System]
Properties:
started=false
- started (Default value false)
Methods:
- start(options)
Just calls System.Start(options)
- stop(options)
- stop(options)
Just calls System.Stop(options)
Static Methods:
- Start(options)
Starts the system by registering subscriptions to events
- Stop(options)
- Stop(options)
Stops the system by removing these subscriptions to events
[Belonging to SystemTest]
Properties:
<no static properties>
Methods:
<no methods>
Static Methods:
<no static methods>
GENERATE_INHERITED_END

View File

@ -62,6 +62,9 @@ class System {
*/
start(options) {
//GENERATE_START_METHOD_START
//GENERATE_START_METHOD_END
//CUSTOM_START_METHOD_START
System.Start(options);
@ -81,6 +84,9 @@ class System {
*/
stop(options) {
//GENERATE_STOP_METHOD_START
//GENERATE_STOP_METHOD_END
//CUSTOM_STOP_METHOD_START
System.Stop(options);
//CUSTOM_STOP_METHOD_END
@ -97,6 +103,9 @@ class System {
*/
static Start(options) {
//GENERATE_STATIC_START_METHOD_START
//GENERATE_STATIC_START_METHOD_END
//CUSTOM_STATIC_START_METHOD_START
console.log('Starting system X');
//CUSTOM_STATIC_START_METHOD_END
@ -110,6 +119,9 @@ class System {
*/
static Stop(options) {
//GENERATE_STATIC_STOP_METHOD_START
//GENERATE_STATIC_STOP_METHOD_END
//CUSTOM_STATIC_STOP_METHOD_START
console.log('Stopping system X');
//CUSTOM_STATIC_STOP_METHOD_END

View File

@ -2,6 +2,10 @@ const Event = require('./r3-event');
/**
GENERATE_INHERITED_START
GENERATE_INHERITED_END
CUSTOM_OPTIONS_START
CUSTOM_OPTIONS_END

View File

@ -1,12 +1,10 @@
createInstance() {
this.emit(Event.CREATE_INSTANCE_BEFORE, this);
//GENERATE_CREATE_INSTANCE_BEFORE_START
//GENERATE_CREATE_INSTANCE_BEFORE_END
//CUSTOM_CREATE_INSTANCE_START
//CUSTOM_CREATE_INSTANCE_END
//GENERATE_CREATE_INSTANCE_AFTER_START
//GENERATE_CREATE_INSTANCE_AFTER_END
}
this[this.runtime].createInstance(
this,
{
//GENERATE_CREATE_INSTANCE_OPTIONS_START
//GENERATE_CREATE_INSTANCE_OPTIONS_END
}
)
this.emit(Event.INSTANCE_CREATED, this);

View File

@ -1,8 +0,0 @@
this[this.runtime].createInstance(
this,
{
//GENERATE_CREATE_INSTANCE_OPTIONS_START
//GENERATE_CREATE_INSTANCE_OPTIONS_END
}
)
this.emit(Event.INSTANCE_CREATED, this);

View File

@ -1 +0,0 @@
this.emit(Event.CREATE_INSTANCE_BEFORE, this);

View File

@ -1,12 +1,10 @@
dispose() {
this.subscribe(
Event.INSTANCE_DISPOSED,
function(object) {
if (object === this) {
this.emit(Event.DISPOSE_OBJECT, this);
}
}
);
//GENERATE_DISPOSE_BEFORE_START
//GENERATE_DISPOSE_BEFORE_END
//CUSTOM_DISPOSE_START
//CUSTOM_DISPOSE_END
//GENERATE_DISPOSE_AFTER_START
//GENERATE_DISPOSE_AFTER_END
}
this.disposeInstance();

View File

@ -1 +0,0 @@
this.disposeInstance();

View File

@ -1,8 +0,0 @@
this.subscribe(
Event.INSTANCE_DISPOSED,
function(object) {
if (object === this) {
this.emit(Event.DISPOSE_OBJECT, this);
}
}
);

View File

@ -1,12 +1,2 @@
disposeInstance() {
//GENERATE_DISPOSE_INSTANCE_BEFORE_START
//GENERATE_DISPOSE_INSTANCE_BEFORE_END
//CUSTOM_DISPOSE_INSTANCE_START
//CUSTOM_DISPOSE_INSTANCE_END
//GENERATE_DISPOSE_INSTANCE_AFTER_START
//GENERATE_DISPOSE_INSTANCE_AFTER_END
}
console.log('Disposing instance of ' + this.name);
this.emit(Event.DISPOSE_INSTANCE, this);

View File

@ -1 +0,0 @@
this.emit(Event.DISPOSE_INSTANCE, this);

View File

@ -1 +0,0 @@
console.log('Disposing instance of ' + this.name);

View File

@ -1,10 +1,11 @@
const Event = require('INCLUDE_PATH/r3-event');
const Utils = require('INCLUDE_PATH/r3-utils');
const EXTEND_CLASS = require('EXTEND_CLASS_FILE_NAME');
const EXTEND_CLASS = require('INCLUDE_PATH/EXTEND_CLASS_FILE_NAME');
/**
GENERATE_INHERITED_START
GENERATE_INHERITED_END
Of the form x=<value>
@ -34,21 +35,6 @@ class CLASS_NAME extends EXTEND_CLASS {
//GENERATE_CONSTRUCTOR_EXTENDS_START
//GENERATE_CONSTRUCTOR_EXTENDS_END
//GENERATE_CREATE_INSTANCE_START
//GENERATE_CREATE_INSTANCE_END
//GENERATE_UPDATE_INSTANCE_START
//GENERATE_UPDATE_INSTANCE_END
//GENERATE_UPDATE_FROM_INSTANCE_START
//GENERATE_UPDATE_FROM_INSTANCE_END
//GENERATE_DISPOSE_START
//GENERATE_DISPOSE_END
//GENERATE_DISPOSE_INSTANCE_START
//GENERATE_DISPOSE_INSTANCE_END
//GENERATE_METHODS_START
//GENERATE_METHODS_END

View File

@ -1,5 +1,5 @@
Inherited from CLASS_NAME
[DESCRIPTION CLASS_NAME]
Properties:

View File

@ -5,6 +5,10 @@
*/
METHOD_NAME(METHOD_ARGS) {
//GENERATE_METHOD_NAME_UPPERCASE_METHOD_START
FUNCTION_TEMPLATE
//GENERATE_METHOD_NAME_UPPERCASE_METHOD_END
//CUSTOM_METHOD_NAME_UPPERCASE_METHOD_START
//CUSTOM_METHOD_NAME_UPPERCASE_METHOD_END

View File

@ -5,6 +5,10 @@
*/
static METHOD_NAME(METHOD_ARGS) {
//GENERATE_STATIC_METHOD_NAME_UPPERCASE_METHOD_START
FUNCTION_TEMPLATE
//GENERATE_STATIC_METHOD_NAME_UPPERCASE_METHOD_END
//CUSTOM_STATIC_METHOD_NAME_UPPERCASE_METHOD_START
//CUSTOM_STATIC_METHOD_NAME_UPPERCASE_METHOD_END

View File

@ -0,0 +1,7 @@
//GENERATE_IMPORTS_START
//GENERATE_IMPORTS_END
module.exports = {
//GENERATE_EXPORTS_START
//GENERATE_EXPORTS_END
}

View File

@ -3,6 +3,10 @@ const Utils = require('INCLUDE_PATH/r3-utils');
/**
GENERATE_INHERITED_START
GENERATE_INHERITED_END
CUSTOM_OPTIONS_START
CUSTOM_OPTIONS_END

View File

@ -1,34 +1,39 @@
GENERATE_ASYNC_METHOD
GENERATE_CONSTRUCTOR
GENERATE_CONSTRUCTOR_EXTENDS
GENERATE_CREATE_INSTANCE
GENERATE_CREATE_INSTANCE_AFTER
GENERATE_CREATE_INSTANCE_BEFORE
GENERATE_CREATE_INSTANCE_METHOD
GENERATE_CREATE_INSTANCE_OPTIONS
GENERATE_DISPOSE
GENERATE_DISPOSE_AFTER
GENERATE_DISPOSE_BEFORE
GENERATE_DISPOSE_INSTANCE
GENERATE_DISPOSE_INSTANCE_AFTER
GENERATE_DISPOSE_INSTANCE_BEFORE
GENERATE_DISPOSE_INSTANCE_METHOD
GENERATE_DISPOSE_METHOD
GENERATE_EMIT_METHOD
GENERATE_EVENT_LISTENERS
GENERATE_EXPORTS
GENERATE_IMPORTS
GENERATE_INHERITED
GENERATE_METHOD_NAME_UPPERCASE_METHOD
GENERATE_METHODS
GENERATE_OPTIONS_INIT
GENERATE_START_METHOD
GENERATE_STATIC_ASYNC_METHOD
GENERATE_STATIC_EMIT_METHOD
GENERATE_STATIC_METHOD_NAME_UPPERCASE_METHOD
GENERATE_STATIC_METHODS
GENERATE_UPDATE_FROM_INSTANCE
GENERATE_UPDATE_FROM_INSTANCE_AFTER
GENERATE_UPDATE_FROM_INSTANCE_BEFORE
GENERATE_STATIC_START_METHOD
GENERATE_STATIC_STOP_METHOD
GENERATE_STATIC_SUBSCRIBE_METHOD
GENERATE_STOP_METHOD
GENERATE_SUBSCRIBE_METHOD
GENERATE_TO_API_OBJECT_METHOD
GENERATE_UPDATE_FROM_INSTANCE_METHOD
GENERATE_UPDATE_FROM_INSTANCE_OPTIONS
GENERATE_UPDATE_INSTANCE
GENERATE_UPDATE_INSTANCE_AFTER
GENERATE_UPDATE_INSTANCE_BEFORE
GENERATE_UPDATE_INSTANCE_METHOD
GENERATE_UPDATE_INSTANCE_OPTIONS
CUSTOM_AFTER_INIT
CUSTOM_ASYNC_METHOD
CUSTOM_BEFORE_INIT
CUSTOM_CREATE_INSTANCE
CUSTOM_DISPOSE
CUSTOM_DISPOSE_INSTANCE
CUSTOM_CREATE_INSTANCE_METHOD
CUSTOM_DISPOSE_INSTANCE_METHOD
CUSTOM_DISPOSE_METHOD
CUSTOM_EMIT_METHOD
CUSTOM_EVENT_LISTENERS
CUSTOM_EXCLUDED_FROM_INSTANCE_OPTIONS
@ -50,5 +55,6 @@ CUSTOM_STATIC_STOP_METHOD
CUSTOM_STATIC_SUBSCRIBE_METHOD
CUSTOM_STOP_METHOD
CUSTOM_SUBSCRIBE_METHOD
CUSTOM_UPDATE_FROM_INSTANCE
CUSTOM_UPDATE_INSTANCE
CUSTOM_TO_API_OBJECT_METHOD
CUSTOM_UPDATE_FROM_INSTANCE_METHOD
CUSTOM_UPDATE_INSTANCE_METHOD

View File

@ -1,15 +1,6 @@
updateFromInstance(property) {
//GENERATE_UPDATE_FROM_INSTANCE_BEFORE_START
//GENERATE_UPDATE_FROM_INSTANCE_BEFORE_END
this.emit(Event.UPDATE_FROM_INSTANCE_BEFORE, this);
//GENERATE_UPDATE_FROM_INSTANCE_OPTIONS_START
//GENERATE_UPDATE_FROM_INSTANCE_OPTIONS_END
//CUSTOM_UPDATE_FROM_INSTANCE_START
//CUSTOM_UPDATE_FROM_INSTANCE_END
//GENERATE_UPDATE_FROM_INSTANCE_AFTER_START
//GENERATE_UPDATE_FROM_INSTANCE_AFTER_END
}
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);

View File

@ -1 +0,0 @@
this.emit(Event.UPDATE_FROM_INSTANCE_AFTER, this);

View File

@ -1 +0,0 @@
this.emit(Event.UPDATE_FROM_INSTANCE_BEFORE, this);

View File

@ -1,15 +1,6 @@
updateInstance(property) {
//GENERATE_UPDATE_INSTANCE_BEFORE_START
//GENERATE_UPDATE_INSTANCE_BEFORE_END
this.emit(Event.UPDATE_INSTANCE_BEFORE, this);
//GENERATE_UPDATE_INSTANCE_OPTIONS_START
//GENERATE_UPDATE_INSTANCE_OPTIONS_END
//CUSTOM_UPDATE_INSTANCE_START
//CUSTOM_UPDATE_INSTANCE_END
//GENERATE_UPDATE_INSTANCE_AFTER_START
//GENERATE_UPDATE_INSTANCE_AFTER_END
}
this.emit(Event.UPDATE_INSTANCE_AFTER, this);

View File

@ -1 +0,0 @@
this.emit(Event.UPDATE_INSTANCE_AFTER, this);

View File

@ -1 +0,0 @@
this.emit(Event.UPDATE_INSTANCE_BEFORE, this);

View File

@ -84,11 +84,8 @@ function loadSaved($file, $tokens) {
return $loadedTokens;
}
function save($file, $tokens) {
echo "saving file " . $file . "\n";
function getFileData($file, &$tokens)
{
$currentTokens = [];
$fn = fopen($file, "r");
@ -120,6 +117,13 @@ function save($file, $tokens) {
}
fclose($fn);
}
function save($file, $tokens) {
echo "saving file " . $file . "\n";
getFileData($file, $tokens);
$saveFile =$file . '.saved';
@ -149,10 +153,10 @@ function save($file, $tokens) {
function deleteSavedFile($saveFile)
{
if ($saveFile) {
if ($saveFile && file_exists($saveFile)) {
unlink($saveFile);
} else {
echo "saved file was null";
echo "Did not unlink file $saveFile because it did not exist.\n";
}
}
@ -224,6 +228,22 @@ function updateSection($file, $token, $updates, $separator = "") {
return true;
}
function getPropertyListItems($store)
{
$propertyListItems = [];
foreach ($store as $item) {
$item = trim($item);
$result = preg_split('/=/', $item);
$propertyListItem = '- ' . $result[0]. ' (Default value ' . $result[1] . ")";
array_push($propertyListItems, $propertyListItem);
}
return $propertyListItems;
}
function getMethodListItems($store)
{
$methodListItems = [];
@ -238,9 +258,15 @@ function getMethodListItems($store)
return $methodListItems;
}
function doGetInheritedTemplateUpdates($node, $restoreTokens)
function doGetInheritedTemplateUpdates($node, $restoreTokens, $inherited = true)
{
try {
$saveFile = $node->file . '.saved';
if (!file_exists($saveFile)) {
$result = save($node->file, $restoreTokens);
}
$tokens = loadSaved($node->file, $restoreTokens);
} catch (ErrorException $e) {
echo $e->getMessage();
@ -250,7 +276,7 @@ function doGetInheritedTemplateUpdates($node, $restoreTokens)
$updates = '';
if ($node->parent !== null && $node->parent->name !== "R3") {
$updates = doGetInheritedTemplateUpdates($node->parent, $restoreTokens);
$updates = rtrim(doGetInheritedTemplateUpdates($node->parent, $restoreTokens)) . "\n";
}
$template = file_get_contents('src/templates/generate_inherited.template');
@ -260,37 +286,55 @@ function doGetInheritedTemplateUpdates($node, $restoreTokens)
$token = 'CUSTOM_OPTIONS';
$store = getTokenStore($token, $tokens);
if (sizeof($store) <= 0) {
$PROPERTY_LIST = '<no inherited properties>';
} else {
$items = [];
foreach ($store as $value) {
array_push($items, trim($value));
if ($inherited) {
$PROPERTY_LIST = '<no inherited properties>';
} else {
$PROPERTY_LIST = '<no static properties>';
}
$PROPERTY_LIST = implode("\n", $items);
} else {
$propertyListItems = getPropertyListItems($store);
$PROPERTY_LIST = implode("\n ", $propertyListItems);
}
$PROPERTY_LIST = trim($PROPERTY_LIST);
$token = 'CUSTOM_METHODS';
$store = getTokenStore($token, $tokens);
if (sizeof($store) <= 0) {
$METHOD_LIST = '<no inherited methods>';
if ($inherited) {
$METHOD_LIST = '<no inherited methods>';
} else {
$METHOD_LIST = '<no methods>';
}
} else {
$methodListItems = getMethodListItems($store);
$METHOD_LIST = implode("\n\t\t", $methodListItems);
$METHOD_LIST = implode("\n ", $methodListItems);
}
$METHOD_LIST = trim($METHOD_LIST);
$token = 'CUSTOM_STATIC_METHODS';
$store = getTokenStore($token, $tokens);
if (sizeof($store) <= 0) {
$STATIC_METHOD_LIST = '<no inherited static methods>';
if ($inherited) {
$STATIC_METHOD_LIST = '<no inherited static methods>';
} else {
$STATIC_METHOD_LIST = '<no static methods>';
}
} else {
$methodListItems = getMethodListItems($store);
$STATIC_METHOD_LIST = implode("\n\t\t", $methodListItems);
$STATIC_METHOD_LIST = implode("\n ", $methodListItems);
}
$STATIC_METHOD_LIST = trim($STATIC_METHOD_LIST);
if ($inherited) {
$description = 'Inherited from';
} else {
$description = 'Belonging to';
}
$updated = str_replace('CLASS_NAME', $CLASS_NAME, $template);
$updated = str_replace('DESCRIPTION', $description, $template);
$updated = str_replace('CLASS_NAME', $CLASS_NAME, $updated);
$updated = str_replace('PROPERTY_LIST', $PROPERTY_LIST, $updated);
$updated = str_replace('STATIC_METHOD_LIST', $STATIC_METHOD_LIST, $updated);
$updated = str_replace('METHOD_LIST', $METHOD_LIST, $updated);
@ -329,7 +373,7 @@ function generateInherited($file, $restoreTokens)
return;
}
$updates = doGetInheritedTemplateUpdates($node->parent, $restoreTokens);
$updates = doGetInheritedTemplateUpdates($node, $restoreTokens, false);
updateSection($file, 'GENERATE_INHERITED' , $updates);
}
@ -515,7 +559,11 @@ function generateUpdateFromInstanceOptions($file, $tokens)
}
}
function getMethodDetails($item): array
/**
* @param $item
* @return array
*/
function getMethodDetails($item)
{
$item = trim($item);
@ -596,7 +644,7 @@ function doMethodUpdate($template, $tokens, $token)
$args = implode(",\n ", $argsArray);
$args = "\n " . $args . "\n ";
$params = implode("\n * @param ", $argsArray);
$params = "@param " . $params;
$params = "\n * @param " . $params;
} else if (sizeof($argsArray) === 1) {
if ($args === '') {
$params = $args;
@ -611,7 +659,17 @@ function doMethodUpdate($template, $tokens, $token)
$comment = wordwrap($comment, 110, "\n * ");
$updated = str_replace('METHOD_ARGS', $args, $template);
$updated = $template;
$potentialTemplate = strtolower('src/templates/' . $methodTokenName . '.template');
if (file_exists($potentialTemplate)) {
$functionTemplate = file_get_contents($potentialTemplate);
$updated = preg_replace('/^\s*FUNCTION_TEMPLATE/m', $functionTemplate, $updated);
} else {
$updated = preg_replace('/^.*?FUNCTION_TEMPLATE.*\n/m', '', $updated);
}
$updated = str_replace('METHOD_ARGS', $args, $updated);
$updated = str_replace('METHOD_NAME_UPPERCASE', $methodTokenName, $updated);
$updated = str_replace('METHOD_NAME', $methodName, $updated);
$updated = str_replace('COMMENT', $comment, $updated);
@ -768,6 +826,23 @@ foreach ($files as $file) {
}
}
/**
* Check if we have no saved custom methods but introduced them
* from a template
*/
if (!in_array('CUSTOM_METHODS', array_keys($tokens))){
$methodTokens = getTokens('CUSTOM_METHODS');
getFileData($file, $methodTokens);
if (sizeof($methodTokens['CUSTOM_METHODS']) > 0) {
$tokens['CUSTOM_METHODS'] = $methodTokens['CUSTOM_METHODS'];
}
}
generateMethods($file, $tokens);
generateStaticMethods($file, $tokens);
generateInitOptions($file, $tokens);
generateCreateInstanceOptions($file, $tokens);
@ -776,12 +851,6 @@ foreach ($files as $file) {
generateUpdateFromInstanceOptions($file, $tokens);
generateMethods($file, $tokens);
generateStaticMethods($file, $tokens);
echo `r3 update-token-db`;
/**
* Try to restore the rest of the old data because now methods were generated.
* If not all data restores now - a method name / token has changed and we need
@ -804,14 +873,67 @@ foreach ($files as $file) {
echo "If you do not do it now - on the next template update code will be overwritten and you could lose code!!!\n";
exit(1);
} else {
// deleteSavedFile($saveFile);
// exit(0);
deleteSavedFile($saveFile);
exit(0);
}
} else if ($argv[2] == 'build-graph') {
buildNodeList($file);
}
}
function generateIndex($types)
{
/**
* Graph $graph
*/
global $graph;
foreach ($types as $type) {
$systemNode = $graph->search('name', $type);
$template = file_get_contents('src/templates/index.template');
$imports = [];
$exports = [];
$nodes = array_merge([$systemNode], $systemNode->children);
foreach ($nodes as $child) {
if ($type === 'System') {
$file = str_replace('src/r3/r3-system', '.', $child->file);
}
if ($type === 'Component') {
$file = str_replace('src/r3/r3-component', '.', $child->file);
}
if ($type === 'R3') {
$file = str_replace('src/r3', '.', $child->file);
}
array_push($imports, "const " . $child->name . ' = require(\'' . $file . "');");
array_push($exports, $child->name);
}
$indexFile = 'src/r3/index.js';
if ($type === 'System') {
$indexFile = 'src/r3/r3-system/index.js';
}
if ($type === 'Component') {
$indexFile = 'src/r3/r3-component/index.js';
}
file_put_contents($indexFile, $template);
updateSection($indexFile, 'GENERATE_IMPORTS', implode("\n", $imports));
updateSection($indexFile, 'GENERATE_EXPORTS', " " . implode(",\n ", $exports));
}
}
if ($argv[2] == 'build-graph') {
global $nodeList;
@ -832,17 +954,24 @@ if ($argv[2] == 'build-graph') {
*/
foreach ($files as $file) {
$saveFile = $file . '.saved';
generateInherited($file, $restoreTokens);
}
generateIndex(
[
'System',
'Component',
'R3'
]
);
foreach ($files as $file) {
$saveFile = $file . '.saved';
deleteSavedFile($saveFile);
}
}

View File

@ -14,6 +14,7 @@ $files = [];
if ($argv[1] == 'all') {
$files = scandir('src/r3/', SCANDIR_SORT_DESCENDING);
$systemFiles = scandir('src/r3/r3-system', SCANDIR_SORT_DESCENDING);
$componentFiles = scandir('src/r3/r3-component', SCANDIR_SORT_DESCENDING);
$newFiles = [];
@ -39,6 +40,17 @@ if ($argv[1] == 'all') {
}
}
for ($i = 0; $i < sizeof($componentFiles); $i++) {
if (preg_match('/index\.js$/', $componentFiles[$i])) {
continue;
}
if (preg_match('/\.js$/', $componentFiles[$i])) {
array_push($newFiles, 'src/r3/r3-component/' . $componentFiles[$i]);
}
}
$files = $newFiles;
} else {