Compare commits
4 Commits
3711c85887
...
4177e62fe1
Author | SHA1 | Date |
---|---|---|
Theunis J. Botha | 4177e62fe1 | |
Theunis J. Botha | dd10634c4e | |
Theunis J. Botha | 3402c7a891 | |
Theunis J. Botha | 01196d29ad |
|
@ -9,3 +9,5 @@ r3 create SystemLinking system
|
|||
r3 create SystemTest system
|
||||
r3 create Component extends R3Object ./r3-component/
|
||||
r3 create Image extends Component ./r3-component/
|
||||
r3 create Runtime extends Event
|
||||
r3 create SystemInput system
|
||||
|
|
|
@ -1,95 +0,0 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
//$files = array_merge(
|
||||
// scandir('./src/r3', SCANDIR_SORT_DESCENDING),
|
||||
// scandir('./test', SCANDIR_SORT_DESCENDING)
|
||||
//);
|
||||
|
||||
$files = scandir('./src/r3', SCANDIR_SORT_DESCENDING);
|
||||
|
||||
$events = [];
|
||||
|
||||
foreach ($files as $file) {
|
||||
|
||||
$file = './src/r3/' . $file;
|
||||
// echo $file . "\n";
|
||||
// continue;
|
||||
|
||||
if (
|
||||
preg_match('/\.js$/', $file) &&
|
||||
!preg_match('/r3\-event/', $file)
|
||||
) {
|
||||
|
||||
echo "processing file " . $file . "\n";
|
||||
|
||||
$fn = fopen($file, "r");
|
||||
|
||||
while (!feof($fn)) {
|
||||
|
||||
$line = fgets($fn);
|
||||
|
||||
|
||||
if (
|
||||
preg_match('/Event\./', $line) &&
|
||||
!preg_match('/Emit|Subscribe|.call|GetEventName|Async|prototype/', $line)
|
||||
) {
|
||||
$matches = [];
|
||||
preg_match_all('/(Event\..*?)(\s+|,|;|$|\))/', $line, $matches);
|
||||
|
||||
if ($matches[1] && $matches[1][0]) {
|
||||
|
||||
$event = $matches[1][0];
|
||||
|
||||
if (in_array($event, $events)) {
|
||||
// Do nothing
|
||||
} else {
|
||||
array_push($events, $event);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
fclose($fn);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
array_push($events, 'Event.START');
|
||||
array_push($events, 'Event.PAUSE');
|
||||
array_push($events, 'Event.RESTART');
|
||||
|
||||
sort($events);
|
||||
|
||||
$i = 1;
|
||||
|
||||
$eventList = '';
|
||||
|
||||
$eventFunction = "Event.GetEventName = function(eventId) {\n\n\tswitch(eventId) {\n";
|
||||
|
||||
foreach ($events as $event) {
|
||||
$eventList .= $event . " = " . "0x" . dechex($i) . ";\n";
|
||||
|
||||
$eventFunction .= "\t\tcase 0x" . dechex($i). " : return '" . strtolower(str_replace('Event.', '', $event)) . "';\n";
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
$eventList .= "Event.MAX_EVENTS = " . "0x" . dechex($i) . ";\n\n";
|
||||
|
||||
$eventFunction .= "\t\tdefault :\n\t\t\tthrow new Error('Event type not defined : ' + eventId);\n";
|
||||
$eventFunction .= "\t}\n\n";
|
||||
$eventFunction .= "};\n";
|
||||
|
||||
echo $eventList;
|
||||
echo $eventFunction;
|
||||
|
||||
file_put_contents('./src/r3/events-generated', $eventList . $eventFunction);
|
||||
|
||||
?>
|
|
@ -1,6 +1,6 @@
|
|||
class R3 {
|
||||
static version = '2.0.82';
|
||||
static compileDate = '2021 Jul 12 - 12:02:40 pm';
|
||||
static version = '2.0.121';
|
||||
static compileDate = '2021 Aug 04 - 10:49:37 am';
|
||||
}
|
||||
|
||||
class System {
|
||||
|
@ -9,6 +9,10 @@ class System {
|
|||
|
||||
Event.Emit(Event.OBJECT_CREATED, this);
|
||||
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
|
||||
Object.assign(this, options);
|
||||
|
||||
Event.Emit(Event.OBJECT_INITIALIZED, this);
|
||||
|
@ -83,6 +87,10 @@ class Event {
|
|||
|
||||
Event.Emit(Event.OBJECT_CREATED, this);
|
||||
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
|
||||
Object.assign(this, options);
|
||||
|
||||
Event.Emit(Event.OBJECT_INITIALIZED, this);
|
||||
|
@ -298,7 +306,7 @@ class Event {
|
|||
|
||||
}
|
||||
|
||||
Event.COMPONENT_INITIALIZED = 0x1;
|
||||
Event.COMPONENT_CREATED = 0x1;
|
||||
Event.CREATE_INSTANCE_BEFORE = 0x2;
|
||||
Event.DISPOSE_INSTANCE = 0x3;
|
||||
Event.DISPOSE_OBJECT = 0x4;
|
||||
|
@ -311,16 +319,12 @@ Event.OBJECT_INITIALIZED = 0xa;
|
|||
Event.PAUSE = 0xb;
|
||||
Event.RESTART = 0xc;
|
||||
Event.START = 0xd;
|
||||
Event.UPDATE_FROM_INSTANCE_AFTER = 0xe;
|
||||
Event.UPDATE_FROM_INSTANCE_BEFORE = 0xf;
|
||||
Event.UPDATE_INSTANCE_AFTER = 0x10;
|
||||
Event.UPDATE_INSTANCE_BEFORE = 0x11;
|
||||
Event.MAX_EVENTS = 0x12;
|
||||
Event.MAX_EVENTS = 0xe;
|
||||
|
||||
Event.GetEventName = function(eventId) {
|
||||
|
||||
switch(eventId) {
|
||||
case 0x1 : return 'component_initialized';
|
||||
case 0x1 : return 'component_created';
|
||||
case 0x2 : return 'create_instance_before';
|
||||
case 0x3 : return 'dispose_instance';
|
||||
case 0x4 : return 'dispose_object';
|
||||
|
@ -333,10 +337,6 @@ Event.GetEventName = function(eventId) {
|
|||
case 0xb : return 'pause';
|
||||
case 0xc : return 'restart';
|
||||
case 0xd : return 'start';
|
||||
case 0xe : return 'update_from_instance_after';
|
||||
case 0xf : return 'update_from_instance_before';
|
||||
case 0x10 : return 'update_instance_after';
|
||||
case 0x11 : return 'update_instance_before';
|
||||
default :
|
||||
throw new Error('Event type not defined : ' + eventId);
|
||||
}
|
||||
|
@ -349,6 +349,10 @@ class Utils {
|
|||
|
||||
Event.Emit(Event.OBJECT_CREATED, this);
|
||||
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
|
||||
Object.assign(this, options);
|
||||
|
||||
Event.Emit(Event.OBJECT_INITIALIZED, this);
|
||||
|
@ -1589,6 +1593,7 @@ class Utils {
|
|||
|
||||
/**
|
||||
|
||||
Class R3.System.Linking
|
||||
[Inherited from System]
|
||||
|
||||
Properties:
|
||||
|
@ -1620,21 +1625,18 @@ class Utils {
|
|||
Methods:
|
||||
|
||||
- start(options)
|
||||
Just calls System.Start(options)
|
||||
Overrides for R3.System.start()
|
||||
|
||||
- stop(options)
|
||||
Just calls System.Stop(options)
|
||||
Overrides for R3.System.stop()
|
||||
|
||||
Static Methods:
|
||||
|
||||
- Start(options)
|
||||
Starts the system by registering subscriptions to events
|
||||
Overrides for R3.System.Start()
|
||||
|
||||
- Stop(options)
|
||||
Stops the system by removing these subscriptions to events
|
||||
|
||||
Event.OBJECT_CREATED
|
||||
Event.INSTANCE_CREATED
|
||||
Overrides for R3.System.Stop()
|
||||
|
||||
**/
|
||||
|
||||
|
@ -1642,7 +1644,7 @@ class SystemLinking extends System {
|
|||
|
||||
constructor(options) {
|
||||
|
||||
if (Utils.UndefinedOrNull(options)) {
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
|
||||
|
@ -1771,6 +1773,7 @@ class SystemLinking extends System {
|
|||
|
||||
/**
|
||||
|
||||
Class R3.System.Socket
|
||||
[Inherited from System]
|
||||
|
||||
Properties:
|
||||
|
@ -1802,18 +1805,18 @@ class SystemLinking extends System {
|
|||
Methods:
|
||||
|
||||
- start(options)
|
||||
Just calls System.Start(options)
|
||||
Overrides for R3.System.start()
|
||||
|
||||
- stop(options)
|
||||
Just calls System.Stop(options)
|
||||
Overrides for R3.System.stop()
|
||||
|
||||
Static Methods:
|
||||
|
||||
- Start(options)
|
||||
Starts the system by registering subscriptions to events
|
||||
Overrides for R3.System.Start()
|
||||
|
||||
- Stop(options)
|
||||
Stops the system by removing these subscriptions to events
|
||||
Overrides for R3.System.Stop()
|
||||
|
||||
**/
|
||||
|
||||
|
@ -1821,7 +1824,7 @@ class SystemSocket extends System {
|
|||
|
||||
constructor(options) {
|
||||
|
||||
if (Utils.UndefinedOrNull(options)) {
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
|
||||
|
@ -1857,6 +1860,8 @@ class SystemSocket extends System {
|
|||
SystemSocket.Stop(options);
|
||||
this.started = false;
|
||||
|
||||
console.log('system socket stop test');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1874,6 +1879,8 @@ class SystemSocket extends System {
|
|||
|
||||
console.log('Started SystemSocket');
|
||||
|
||||
console.log('CUSTOM Start Test Stuff');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1897,6 +1904,7 @@ class SystemSocket extends System {
|
|||
|
||||
/**
|
||||
|
||||
Class R3.System.Test
|
||||
[Inherited from System]
|
||||
|
||||
Properties:
|
||||
|
@ -1928,18 +1936,18 @@ class SystemSocket extends System {
|
|||
Methods:
|
||||
|
||||
- start(options)
|
||||
Just calls System.Start(options)
|
||||
Overrides for R3.System.start()
|
||||
|
||||
- stop(options)
|
||||
Just calls System.Stop(options)
|
||||
Overrides for R3.System.stop()
|
||||
|
||||
Static Methods:
|
||||
|
||||
- Start(options)
|
||||
Starts the system by registering subscriptions to events
|
||||
Overrides for R3.System.Start()
|
||||
|
||||
- Stop(options)
|
||||
Stops the system by removing these subscriptions to events
|
||||
Overrides for R3.System.Stop()
|
||||
|
||||
**/
|
||||
|
||||
|
@ -1947,7 +1955,7 @@ class SystemTest extends System {
|
|||
|
||||
constructor(options) {
|
||||
|
||||
if (Utils.UndefinedOrNull(options)) {
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
|
||||
|
@ -2023,6 +2031,7 @@ class SystemTest extends System {
|
|||
|
||||
/**
|
||||
|
||||
Class R3.Event.Object
|
||||
[Inherited from Event]
|
||||
|
||||
Properties:
|
||||
|
@ -2079,7 +2088,7 @@ class R3Object extends Event {
|
|||
|
||||
constructor(options) {
|
||||
|
||||
if (Utils.UndefinedOrNull(options)) {
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
|
||||
|
@ -2087,10 +2096,7 @@ class R3Object extends Event {
|
|||
|
||||
this.emit(Event.OBJECT_CREATED, this);
|
||||
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
if (Utils.UndefinedOrNull(options.register)) {
|
||||
if (typeof options.register === 'undefined')) {
|
||||
options.register = true;
|
||||
}
|
||||
|
||||
|
@ -2104,6 +2110,85 @@ class R3Object extends Event {
|
|||
|
||||
/**
|
||||
|
||||
Class R3.Event.Runtime
|
||||
[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
|
||||
|
||||
[Belonging to Runtime]
|
||||
|
||||
Properties:
|
||||
|
||||
<no static properties>
|
||||
|
||||
Methods:
|
||||
|
||||
<no methods>
|
||||
|
||||
Static Methods:
|
||||
|
||||
<no static methods>
|
||||
|
||||
Of the form x=<value>
|
||||
|
||||
Of the form x=<instance.property>
|
||||
|
||||
**/
|
||||
|
||||
class Runtime extends Event {
|
||||
|
||||
constructor(options) {
|
||||
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
|
||||
super(options);
|
||||
|
||||
this.emit(Event.OBJECT_CREATED, this);
|
||||
|
||||
Object.assign(this, options);
|
||||
|
||||
this.emit(Event.OBJECT_INITIALIZED, this);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Runtime.DEFAULT = 0x1;
|
||||
Runtime.GRAPHICS = 0x2;
|
||||
|
||||
/**
|
||||
|
||||
Class R3.Event.Object.Component
|
||||
[Inherited from Event]
|
||||
|
||||
Properties:
|
||||
|
@ -2154,11 +2239,21 @@ class R3Object extends Event {
|
|||
|
||||
Properties:
|
||||
|
||||
<no static properties>
|
||||
- runtime (Default value R3.Runtime.DEFAULT)
|
||||
|
||||
Methods:
|
||||
|
||||
<no methods>
|
||||
- createInstance()
|
||||
No comment
|
||||
|
||||
- dispose()
|
||||
No comment
|
||||
|
||||
- disposeInstance()
|
||||
No comment
|
||||
|
||||
- getRuntime()
|
||||
No comment
|
||||
|
||||
Static Methods:
|
||||
|
||||
|
@ -2174,7 +2269,7 @@ class Component extends R3Object {
|
|||
|
||||
constructor(options) {
|
||||
|
||||
if (Utils.UndefinedOrNull(options)) {
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
|
||||
|
@ -2182,16 +2277,86 @@ class Component extends R3Object {
|
|||
|
||||
this.emit(Event.OBJECT_CREATED, this);
|
||||
|
||||
if (typeof options.runtime === 'undefined')) {
|
||||
options.runtime = R3.Runtime.DEFAULT;
|
||||
}
|
||||
|
||||
Object.assign(this, options);
|
||||
|
||||
this.emit(Event.OBJECT_INITIALIZED, this);
|
||||
|
||||
this.emit(Event.COMPONENT_CREATED, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* createInstance()
|
||||
* - No comment
|
||||
*/
|
||||
createInstance() {
|
||||
|
||||
this.emit(Event.CREATE_INSTANCE_BEFORE, this);
|
||||
|
||||
this.getRuntime().createInstance(
|
||||
this,
|
||||
{
|
||||
'runtime': this.runtime
|
||||
}
|
||||
)
|
||||
this.emit(Event.INSTANCE_CREATED, this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* dispose()
|
||||
* - No comment
|
||||
*/
|
||||
dispose() {
|
||||
|
||||
this.subscribe(
|
||||
Event.INSTANCE_DISPOSED,
|
||||
function(object) {
|
||||
if (object === this) {
|
||||
this.emit(Event.DISPOSE_OBJECT, this);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
this.disposeInstance();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* disposeInstance()
|
||||
* - No comment
|
||||
*/
|
||||
disposeInstance() {
|
||||
|
||||
console.log('Disposing instance of ' + this.name);
|
||||
this.emit(Event.DISPOSE_INSTANCE, this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* getRuntime()
|
||||
* - No comment
|
||||
*/
|
||||
getRuntime() {
|
||||
|
||||
if (this.runtime === R3.Runtime.DEFAULT) {
|
||||
//TODO: implement runtime base
|
||||
return null;
|
||||
}
|
||||
|
||||
//TODO: implement runtime classes
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Class R3.Event.Object.Project
|
||||
[Inherited from Event]
|
||||
|
||||
Properties:
|
||||
|
@ -2262,7 +2427,7 @@ class Project extends R3Object {
|
|||
|
||||
constructor(options) {
|
||||
|
||||
if (Utils.UndefinedOrNull(options)) {
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
|
||||
|
@ -2280,6 +2445,7 @@ class Project extends R3Object {
|
|||
|
||||
/**
|
||||
|
||||
Class R3.Event.Object.Component.Image
|
||||
[Inherited from Event]
|
||||
|
||||
Properties:
|
||||
|
@ -2330,11 +2496,21 @@ class Project extends R3Object {
|
|||
|
||||
Properties:
|
||||
|
||||
<no inherited properties>
|
||||
- runtime (Default value R3.Runtime.DEFAULT)
|
||||
|
||||
Methods:
|
||||
|
||||
<no inherited methods>
|
||||
- createInstance()
|
||||
No comment
|
||||
|
||||
- dispose()
|
||||
No comment
|
||||
|
||||
- disposeInstance()
|
||||
No comment
|
||||
|
||||
- getRuntime()
|
||||
No comment
|
||||
|
||||
Static Methods:
|
||||
|
||||
|
@ -2364,7 +2540,7 @@ class Image extends Component {
|
|||
|
||||
constructor(options) {
|
||||
|
||||
if (Utils.UndefinedOrNull(options)) {
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
|
||||
|
@ -2389,9 +2565,11 @@ R3.System.Linking = SystemLinking;
|
|||
R3.System.Socket = SystemSocket;
|
||||
R3.System.Test = SystemTest;
|
||||
R3.Event.Object = R3Object;
|
||||
R3.Event.Runtime = Runtime;
|
||||
R3.Event.Object.Component = Component;
|
||||
R3.Event.Object.Project = Project;
|
||||
R3.Event.Object.Component.Image = Image;
|
||||
R3.Runtime = Runtime;
|
||||
|
||||
console.log('r3.js - version ' + R3.version + ' compiled ' + R3.compileDate);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "r3",
|
||||
"version" : "2.0.82",
|
||||
"version" : "2.0.121",
|
||||
"description": "",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
|
|
567
r3.php
567
r3.php
|
@ -4,26 +4,7 @@
|
|||
include "utils.php";
|
||||
include "graph.php";
|
||||
|
||||
function to_camel_case_from_uppper_underscore($string, $capitalizeFirstCharacter = true)
|
||||
{
|
||||
|
||||
$str = str_replace(' ', '', ucwords(str_replace('_', ' ', strtolower($string))));
|
||||
|
||||
if (!$capitalizeFirstCharacter) {
|
||||
$str[0] = strtolower($str[0]);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
function from_camel_case($input) {
|
||||
preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $input, $matches);
|
||||
$ret = $matches[0];
|
||||
foreach ($ret as &$match) {
|
||||
$match = $match == strtoupper($match) ? strtolower($match) : lcfirst($match);
|
||||
}
|
||||
return implode('_', $ret);
|
||||
}
|
||||
global $files;
|
||||
|
||||
function getTokens($type)
|
||||
{
|
||||
|
@ -256,30 +237,53 @@ function getPropertyListItems($store)
|
|||
return $propertyListItems;
|
||||
}
|
||||
|
||||
function getMethodListItems($store)
|
||||
function getMethodListItems($store, $parentStore = [], $parent = null)
|
||||
{
|
||||
$methodListItems = [];
|
||||
|
||||
foreach ($store as $item) {
|
||||
|
||||
$overrides = false;
|
||||
|
||||
foreach ($parentStore as $parentItem) {
|
||||
if (trim($parentItem) === trim($item)) {
|
||||
$overrides=true;
|
||||
}
|
||||
}
|
||||
|
||||
$details = getMethodDetails($item);
|
||||
$methodListItem = '- ' . $details['methodName'] . '(' . $details['args'] .")\n";
|
||||
|
||||
if ($overrides === true) {
|
||||
$methodListItem = '- ' . $details['methodName'] . '(' . $details['args'] . ")\n";
|
||||
$methodListItem .= " " . wordwrap('Overrides for ' . $parent->nameSpace . $parent->name . '.' . $details['methodName'] . '()', 110, "\n ") . "\n";
|
||||
} else {
|
||||
$methodListItem = '- ' . $details['methodName'] . '(' . $details['args'] . ")\n";
|
||||
$methodListItem .= " " . wordwrap($details['comment'], 110, "\n ") . "\n";
|
||||
}
|
||||
array_push($methodListItems, $methodListItem);
|
||||
}
|
||||
|
||||
return $methodListItems;
|
||||
}
|
||||
|
||||
function doGetInheritedTemplateUpdates($node, $restoreTokens, $inherited = true)
|
||||
function doGetInheritedTemplateUpdates($node, $restoreTokens, $inherited = true, $for)
|
||||
{
|
||||
try {
|
||||
|
||||
$saveFile = $node->file . '.saved';
|
||||
|
||||
if (!file_exists($saveFile)) {
|
||||
$result = save($node->file, $restoreTokens);
|
||||
save($node->file, $restoreTokens);
|
||||
}
|
||||
|
||||
$tokens = loadSaved($node->file, $restoreTokens);
|
||||
|
||||
if ($node->parent !== null) {
|
||||
$parentSaveFile = $node->parent->file . '.saved';
|
||||
if (!file_exists($parentSaveFile)) {
|
||||
save($node->parent->file, $restoreTokens);
|
||||
}
|
||||
}
|
||||
$parentTokens = loadSaved($node->parent->file, $restoreTokens);
|
||||
|
||||
} catch (ErrorException $e) {
|
||||
echo $e->getMessage();
|
||||
exit(1);
|
||||
|
@ -287,8 +291,12 @@ function doGetInheritedTemplateUpdates($node, $restoreTokens, $inherited = true)
|
|||
|
||||
$updates = '';
|
||||
|
||||
$firstTemplate = false;
|
||||
|
||||
if ($node->parent !== null && $node->parent->name !== "R3") {
|
||||
$updates = rtrim(doGetInheritedTemplateUpdates($node->parent, $restoreTokens)) . "\n";
|
||||
$updates = rtrim(doGetInheritedTemplateUpdates($node->parent, $restoreTokens, true, $for)) . "\n";
|
||||
} else {
|
||||
$firstTemplate = true;
|
||||
}
|
||||
|
||||
$template = file_get_contents('src/templates/generate_inherited.template');
|
||||
|
@ -311,6 +319,7 @@ function doGetInheritedTemplateUpdates($node, $restoreTokens, $inherited = true)
|
|||
|
||||
$token = 'CUSTOM_METHODS';
|
||||
$store = getTokenStore($token, $tokens);
|
||||
$parentStore = getTokenStore($token, $parentTokens);
|
||||
|
||||
if (sizeof($store) <= 0) {
|
||||
if ($inherited) {
|
||||
|
@ -319,13 +328,14 @@ function doGetInheritedTemplateUpdates($node, $restoreTokens, $inherited = true)
|
|||
$METHOD_LIST = '<no methods>';
|
||||
}
|
||||
} else {
|
||||
$methodListItems = getMethodListItems($store);
|
||||
$methodListItems = getMethodListItems($store, $parentStore, $node->parent);
|
||||
$METHOD_LIST = implode("\n ", $methodListItems);
|
||||
}
|
||||
$METHOD_LIST = trim($METHOD_LIST);
|
||||
|
||||
$token = 'CUSTOM_STATIC_METHODS';
|
||||
$store = getTokenStore($token, $tokens);
|
||||
$parentStore = getTokenStore($token, $parentTokens);
|
||||
|
||||
if (sizeof($store) <= 0) {
|
||||
if ($inherited) {
|
||||
|
@ -334,7 +344,7 @@ function doGetInheritedTemplateUpdates($node, $restoreTokens, $inherited = true)
|
|||
$STATIC_METHOD_LIST = '<no static methods>';
|
||||
}
|
||||
} else {
|
||||
$methodListItems = getMethodListItems($store);
|
||||
$methodListItems = getMethodListItems($store, $parentStore, $node->parent);
|
||||
$STATIC_METHOD_LIST = implode("\n ", $methodListItems);
|
||||
}
|
||||
$STATIC_METHOD_LIST = trim($STATIC_METHOD_LIST);
|
||||
|
@ -345,7 +355,13 @@ function doGetInheritedTemplateUpdates($node, $restoreTokens, $inherited = true)
|
|||
$description = 'Belonging to';
|
||||
}
|
||||
|
||||
$updated = str_replace('DESCRIPTION', $description, $template);
|
||||
if ($firstTemplate) {
|
||||
$updated = str_replace("FIRST_TEMPLATE", "Class " . $for, $template);
|
||||
} else {
|
||||
$updated = preg_replace('/^.*?FIRST_TEMPLATE.*\n/m', "", $template);
|
||||
}
|
||||
|
||||
$updated = str_replace('DESCRIPTION', $description, $updated);
|
||||
$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);
|
||||
|
@ -385,7 +401,7 @@ function generateInherited($file, $restoreTokens)
|
|||
return;
|
||||
}
|
||||
|
||||
$updates = doGetInheritedTemplateUpdates($node, $restoreTokens, false);
|
||||
$updates = doGetInheritedTemplateUpdates($node, $restoreTokens, false, $node->nameSpace . $node->nameSpaceClassName);
|
||||
|
||||
updateSection($file, 'GENERATE_INHERITED' , $updates);
|
||||
}
|
||||
|
@ -401,10 +417,9 @@ function generateInitOptions($file, $tokens)
|
|||
|
||||
echo "Will be building options for $token\n";
|
||||
|
||||
$header = file_get_contents('src/templates/generate_custom_options_init_header.template');
|
||||
$template = file_get_contents('src/templates/generate_custom_options_init.template');
|
||||
|
||||
$updates = $header;
|
||||
$updates = '';
|
||||
|
||||
foreach ($store as $item) {
|
||||
$item = trim($item);
|
||||
|
@ -424,7 +439,7 @@ function generateInitOptions($file, $tokens)
|
|||
|
||||
function getTokenStore($tokenName, $tokens)
|
||||
{
|
||||
if (array_key_exists($tokenName, $tokens)) {
|
||||
if (is_array($tokens) && array_key_exists($tokenName, $tokens)) {
|
||||
return $tokens[$tokenName];
|
||||
}
|
||||
return [];
|
||||
|
@ -595,7 +610,7 @@ function generateEventListenersStart($file, $tokens)
|
|||
|
||||
$methodName = 'ON_'.$eventName;
|
||||
|
||||
$methodName = to_camel_case_from_uppper_underscore($methodName);
|
||||
$methodName = to_camel_case_from_upper_underscore($methodName);
|
||||
|
||||
$updates = str_replace('EVENT_NAME', $item, $template);
|
||||
$updates = str_replace('CALL_BACK', $methodName, $updates);
|
||||
|
@ -633,7 +648,6 @@ function generateEventListenersStop($file, $tokens)
|
|||
updateSection($file, 'GENERATE_EVENT_LISTENERS_STOP' , $updated);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $item
|
||||
* @return array
|
||||
|
@ -847,7 +861,7 @@ function getEventListenerUpdates($template, $tokens, $token)
|
|||
|
||||
$methodTokenName = $methodName;
|
||||
|
||||
$methodName = to_camel_case_from_uppper_underscore($methodName);
|
||||
$methodName = to_camel_case_from_upper_underscore($methodName);
|
||||
|
||||
$updated = $template;
|
||||
|
||||
|
@ -916,189 +930,6 @@ function generateMethods($file, $tokens)
|
|||
|
||||
}
|
||||
|
||||
$nodeList = [];
|
||||
|
||||
/**
|
||||
* @throws ErrorException
|
||||
*/
|
||||
function buildNodeList($file)
|
||||
{
|
||||
echo "loading file $file\n";
|
||||
|
||||
global $nodeList;
|
||||
|
||||
$fn = fopen($file, "r");
|
||||
|
||||
$line = '';
|
||||
$found = false;
|
||||
|
||||
while (!feof($fn) && !$found) {
|
||||
$line = fgets($fn);
|
||||
|
||||
if (preg_match('/^class\s+/', $line)) {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($found) {
|
||||
// echo $line . "\n";
|
||||
|
||||
$matches = [];
|
||||
|
||||
$result = preg_match('/^class\s+(.*?)(\s+extends\s+(.*?)\s+|\s+?{)/', $line, $matches);
|
||||
|
||||
if ($result === false) {
|
||||
throw new ErrorException('Could not match');
|
||||
}
|
||||
|
||||
$extends = null;
|
||||
|
||||
if (sizeof($matches) === 4) {
|
||||
$class = $matches[1];
|
||||
$extends = $matches[3];
|
||||
} else if (sizeof($matches) === 3) {
|
||||
$class = $matches[1];
|
||||
} else {
|
||||
throw new ErrorException('Unhandled case');
|
||||
}
|
||||
|
||||
$nameSpace = '';
|
||||
$nameSpaceClassName = $class;
|
||||
|
||||
if ($extends) {
|
||||
$nameSpaceClassName = str_replace($extends, '', $class);
|
||||
$nameSpaceClassName = str_replace('R3', '', $nameSpaceClassName);
|
||||
}
|
||||
|
||||
$node = new Node(
|
||||
$file,
|
||||
$class,
|
||||
$nameSpace,
|
||||
$nameSpaceClassName,
|
||||
$extends
|
||||
);
|
||||
|
||||
array_push($nodeList, $node);
|
||||
|
||||
} else {
|
||||
echo "not found\n";
|
||||
}
|
||||
|
||||
fclose($fn);
|
||||
|
||||
}
|
||||
|
||||
global $files;
|
||||
|
||||
foreach ($files as $file) {
|
||||
|
||||
$saveFile = null;
|
||||
|
||||
if ($argv[2] == 'save') {
|
||||
|
||||
$saveFile = $file . '.saved';
|
||||
|
||||
if (file_exists($saveFile)) {
|
||||
|
||||
echo "A previous restore operation did not complete - please remove the saved file before trying this again\n";
|
||||
echo "The save file is located at $saveFile\n";
|
||||
echo "Remove easily with:\n";
|
||||
echo "rm $saveFile\n";
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$tokens = getTokens('CUSTOM');
|
||||
|
||||
$result = save($file, $tokens);
|
||||
|
||||
exit(0);
|
||||
|
||||
} else if ($argv[2] == 'restore') {
|
||||
|
||||
$saveFile = $file . '.saved';
|
||||
|
||||
$restoreTokens = getTokens('CUSTOM');
|
||||
|
||||
$restoreTokenKeys = array_keys($restoreTokens);
|
||||
|
||||
try {
|
||||
$tokens = loadSaved($file, $restoreTokens);
|
||||
} catch (ErrorException $e) {
|
||||
echo $e->getMessage();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$skipped = [];
|
||||
|
||||
foreach ($tokens as $token => $store) {
|
||||
if (in_array($token, $restoreTokenKeys)) {
|
||||
updateSection($file, $token, $store);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
generateStaticEventListenerMethods($file, $tokens);
|
||||
|
||||
generateInitOptions($file, $tokens);
|
||||
|
||||
generateCreateInstanceOptions($file, $tokens);
|
||||
|
||||
generateUpdateInstanceOptions($file, $tokens);
|
||||
|
||||
generateUpdateFromInstanceOptions($file, $tokens);
|
||||
|
||||
generateEventListenersStart($file, $tokens);
|
||||
|
||||
generateEventListenersStop($file, $tokens);
|
||||
|
||||
/**
|
||||
* 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
|
||||
* to notify the user
|
||||
*/
|
||||
|
||||
foreach ($tokens as $token => $store) {
|
||||
if (in_array($token, $restoreTokenKeys)) {
|
||||
$result = updateSection($file, $token, $store);
|
||||
if ($result !== true && $result !== false) {
|
||||
array_push($skipped, $result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sizeof($skipped) !== 0) {
|
||||
echo "Some tokens could not be restored because they could not be found in the new version\n";
|
||||
print_r($skipped);
|
||||
echo "Please restore them manually from the saved file :$saveFile\n";
|
||||
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);
|
||||
}
|
||||
} else if ($argv[2] == 'build-dist') {
|
||||
buildNodeList($file);
|
||||
}
|
||||
}
|
||||
|
||||
function generateIndex($types)
|
||||
{
|
||||
/**
|
||||
|
@ -1221,6 +1052,96 @@ function generateR3($nodes)
|
|||
|
||||
}
|
||||
|
||||
function generateEvents()
|
||||
{
|
||||
global $files;
|
||||
|
||||
$events = [];
|
||||
|
||||
foreach ($files as $file) {
|
||||
|
||||
// $file = './src/r3/' . $file;
|
||||
// echo $file . "\n";
|
||||
// continue;
|
||||
|
||||
if (
|
||||
preg_match('/\.js$/', $file) &&
|
||||
!preg_match('/r3\-event/', $file)
|
||||
) {
|
||||
|
||||
echo "processing file " . $file . "\n";
|
||||
|
||||
$fn = fopen($file, "r");
|
||||
|
||||
while (!feof($fn)) {
|
||||
|
||||
$line = fgets($fn);
|
||||
|
||||
|
||||
if (
|
||||
preg_match('/Event\./', $line) &&
|
||||
!preg_match('/Emit|Subscribe|.call|GetEventName|Async|prototype/', $line)
|
||||
) {
|
||||
$matches = [];
|
||||
preg_match_all('/(Event\..*?)(\s+|,|;|$|\))/', $line, $matches);
|
||||
|
||||
if ($matches[1] && $matches[1][0]) {
|
||||
|
||||
$event = $matches[1][0];
|
||||
|
||||
if (in_array($event, $events)) {
|
||||
// Do nothing
|
||||
} else {
|
||||
array_push($events, $event);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
fclose($fn);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
array_push($events, 'Event.START');
|
||||
array_push($events, 'Event.PAUSE');
|
||||
array_push($events, 'Event.RESTART');
|
||||
|
||||
sort($events);
|
||||
|
||||
$i = 1;
|
||||
|
||||
$eventList = '';
|
||||
|
||||
$eventFunction = "Event.GetEventName = function(eventId) {\n\n\tswitch(eventId) {\n";
|
||||
|
||||
foreach ($events as $event) {
|
||||
$eventList .= $event . " = " . "0x" . dechex($i) . ";\n";
|
||||
|
||||
$eventFunction .= "\t\tcase 0x" . dechex($i). " : return '" . strtolower(str_replace('Event.', '', $event)) . "';\n";
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
$eventList .= "Event.MAX_EVENTS = " . "0x" . dechex($i) . ";\n\n";
|
||||
|
||||
$eventFunction .= "\t\tdefault :\n\t\t\tthrow new Error('Event type not defined : ' + eventId);\n";
|
||||
$eventFunction .= "\t}\n\n";
|
||||
$eventFunction .= "};\n";
|
||||
|
||||
echo $eventList;
|
||||
echo $eventFunction;
|
||||
|
||||
updateSection('./src/r3/r3-event.js', 'GENERATE_EVENTS' , $eventList . $eventFunction);
|
||||
|
||||
}
|
||||
|
||||
function generateR3Dist($nodes)
|
||||
{
|
||||
$r3jsFile = 'dist/r3.js';
|
||||
|
@ -1286,6 +1207,9 @@ function generateR3Dist($nodes)
|
|||
$contents = preg_replace('/\n^\s+\bCUSTOM_OPTIONS_START\b.*?\bCUSTOM_OPTIONS_END.*?$/sm', '', $contents);
|
||||
$contents = preg_replace('/\n^\s+\bCUSTOM_METHODS_START\b.*?\bCUSTOM_METHODS_END.*?$/sm', '', $contents);
|
||||
$contents = preg_replace('/\n^\s+\bCUSTOM_STATIC_METHODS_START\b.*?\bCUSTOM_STATIC_METHODS_END.*?$/sm', '', $contents);
|
||||
$contents = preg_replace('/\n^\s+\bCUSTOM_EVENT_LISTENERS_START\b.*?\bCUSTOM_EVENT_LISTENERS_END.*?$/sm', '', $contents);
|
||||
// $contents = preg_replace('/^\s+\bCUSTOM_EVENT_LISTENERS_START.*?$/sm', " Listens to the following Events:\n", $contents);
|
||||
|
||||
$contents = preg_replace('/\n^\bmodule\.exports\s+=\s+{.*?}$/sm', '', $contents);
|
||||
$contents = preg_replace('/\n^\bmodule\.exports\s+=.*?$/sm', '', $contents);
|
||||
$contents = preg_replace('/\n^\bconst.*?= require.*?$/sm', '', $contents);
|
||||
|
@ -1338,6 +1262,206 @@ function updateParentSystems($nodes)
|
|||
}
|
||||
}
|
||||
|
||||
function buildNodeList($file)
|
||||
{
|
||||
echo "loading file $file\n";
|
||||
|
||||
global $nodeList;
|
||||
|
||||
$fn = fopen($file, "r");
|
||||
|
||||
$line = '';
|
||||
$found = false;
|
||||
|
||||
while (!feof($fn) && !$found) {
|
||||
$line = fgets($fn);
|
||||
|
||||
if (preg_match('/^class\s+/', $line)) {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($found) {
|
||||
// echo $line . "\n";
|
||||
|
||||
$matches = [];
|
||||
|
||||
$result = preg_match('/^class\s+(.*?)(\s+extends\s+(.*?)\s+|\s+?{)/', $line, $matches);
|
||||
|
||||
if ($result === false) {
|
||||
throw new ErrorException('Could not match');
|
||||
}
|
||||
|
||||
$extends = null;
|
||||
|
||||
if (sizeof($matches) === 4) {
|
||||
$class = $matches[1];
|
||||
$extends = $matches[3];
|
||||
} else if (sizeof($matches) === 3) {
|
||||
$class = $matches[1];
|
||||
} else {
|
||||
throw new ErrorException('Unhandled case');
|
||||
}
|
||||
|
||||
$nameSpace = '';
|
||||
$nameSpaceClassName = $class;
|
||||
|
||||
if ($extends) {
|
||||
$nameSpaceClassName = str_replace($extends, '', $class);
|
||||
$nameSpaceClassName = str_replace('R3', '', $nameSpaceClassName);
|
||||
}
|
||||
|
||||
$node = new Node(
|
||||
$file,
|
||||
$class,
|
||||
$nameSpace,
|
||||
$nameSpaceClassName,
|
||||
$extends
|
||||
);
|
||||
|
||||
array_push($nodeList, $node);
|
||||
|
||||
} else {
|
||||
echo "not found\n";
|
||||
}
|
||||
|
||||
fclose($fn);
|
||||
|
||||
}
|
||||
|
||||
//function generateRuntimes()
|
||||
//{
|
||||
//
|
||||
// updateSection(
|
||||
// 'src/r3/r3-runtime.js',
|
||||
// 'GENERATE_RUNTIMES',
|
||||
// [
|
||||
// 'Runtime.RUNTIME_DEFAULT'
|
||||
// ]
|
||||
// );
|
||||
//
|
||||
//}
|
||||
|
||||
$nodeList = [];
|
||||
|
||||
/**
|
||||
* @throws ErrorException
|
||||
*/
|
||||
|
||||
|
||||
foreach ($files as $file) {
|
||||
|
||||
$saveFile = null;
|
||||
|
||||
if ($argv[2] == 'save') {
|
||||
|
||||
$saveFile = $file . '.saved';
|
||||
|
||||
if (file_exists($saveFile)) {
|
||||
|
||||
echo "A previous restore operation did not complete - please remove the saved file before trying this again\n";
|
||||
echo "The save file is located at $saveFile\n";
|
||||
echo "Remove easily with:\n";
|
||||
echo "rm $saveFile\n";
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$tokens = getTokens('CUSTOM');
|
||||
|
||||
$result = save($file, $tokens);
|
||||
|
||||
exit(0);
|
||||
|
||||
} else if ($argv[2] == 'restore') {
|
||||
|
||||
$saveFile = $file . '.saved';
|
||||
|
||||
$restoreTokens = getTokens('CUSTOM');
|
||||
|
||||
$restoreTokenKeys = array_keys($restoreTokens);
|
||||
|
||||
try {
|
||||
$tokens = loadSaved($file, $restoreTokens);
|
||||
} catch (ErrorException $e) {
|
||||
echo $e->getMessage();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$skipped = [];
|
||||
|
||||
foreach ($tokens as $token => $store) {
|
||||
if (in_array($token, $restoreTokenKeys)) {
|
||||
updateSection($file, $token, $store);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
generateStaticEventListenerMethods($file, $tokens);
|
||||
|
||||
generateInitOptions($file, $tokens);
|
||||
|
||||
generateCreateInstanceOptions($file, $tokens);
|
||||
|
||||
generateUpdateInstanceOptions($file, $tokens);
|
||||
|
||||
generateUpdateFromInstanceOptions($file, $tokens);
|
||||
|
||||
generateEventListenersStart($file, $tokens);
|
||||
|
||||
generateEventListenersStop($file, $tokens);
|
||||
|
||||
/**
|
||||
* 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
|
||||
* to notify the user
|
||||
*/
|
||||
|
||||
foreach ($tokens as $token => $store) {
|
||||
if (in_array($token, $restoreTokenKeys)) {
|
||||
$result = updateSection($file, $token, $store);
|
||||
if ($result !== true && $result !== false) {
|
||||
array_push($skipped, $result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sizeof($skipped) !== 0) {
|
||||
echo "Some tokens could not be restored because they could not be found in the new version\n";
|
||||
print_r($skipped);
|
||||
echo "Please restore them manually from the saved file :$saveFile\n";
|
||||
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);
|
||||
}
|
||||
} else if ($argv[2] == 'build-dist') {
|
||||
buildNodeList($file);
|
||||
}
|
||||
}
|
||||
|
||||
if ($argv[2] == 'generate-events') {
|
||||
generateEvents();
|
||||
}
|
||||
|
||||
if ($argv[2] == 'build-dist') {
|
||||
|
||||
global $nodeList;
|
||||
|
@ -1378,7 +1502,6 @@ if ($argv[2] == 'build-dist') {
|
|||
generateR3($nodes);
|
||||
generateR3Dist($nodes);
|
||||
|
||||
|
||||
foreach ($files as $file) {
|
||||
|
||||
$saveFile = $file . '.saved';
|
||||
|
@ -1389,8 +1512,6 @@ if ($argv[2] == 'build-dist') {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
exit(0);
|
||||
|
||||
?>
|
|
@ -6,6 +6,7 @@ const R3Object = require('.././r3-r3-object.js');
|
|||
|
||||
GENERATE_INHERITED_START
|
||||
|
||||
Class R3.Event.Object.Component
|
||||
[Inherited from Event]
|
||||
|
||||
Properties:
|
||||
|
@ -56,11 +57,21 @@ const R3Object = require('.././r3-r3-object.js');
|
|||
|
||||
Properties:
|
||||
|
||||
<no static properties>
|
||||
- runtime (Default value R3.Runtime.DEFAULT)
|
||||
|
||||
Methods:
|
||||
|
||||
<no methods>
|
||||
- createInstance()
|
||||
No comment
|
||||
|
||||
- dispose()
|
||||
No comment
|
||||
|
||||
- disposeInstance()
|
||||
No comment
|
||||
|
||||
- getRuntime()
|
||||
No comment
|
||||
|
||||
Static Methods:
|
||||
|
||||
|
@ -70,6 +81,7 @@ const R3Object = require('.././r3-r3-object.js');
|
|||
|
||||
Of the form x=<value>
|
||||
CUSTOM_OPTIONS_START
|
||||
runtime=R3.Runtime.DEFAULT
|
||||
CUSTOM_OPTIONS_END
|
||||
|
||||
Of the form x=<instance.property>
|
||||
|
@ -83,6 +95,10 @@ const R3Object = require('.././r3-r3-object.js');
|
|||
CUSTOM_EXCLUDED_FROM_INSTANCE_OPTIONS_END
|
||||
|
||||
CUSTOM_METHODS_START
|
||||
createInstance()
|
||||
dispose()
|
||||
disposeInstance()
|
||||
getRuntime()
|
||||
CUSTOM_METHODS_END
|
||||
|
||||
CUSTOM_STATIC_METHODS_START
|
||||
|
@ -95,7 +111,7 @@ class Component extends R3Object {
|
|||
//GENERATE_CONSTRUCTOR_EXTENDS_START
|
||||
constructor(options) {
|
||||
|
||||
if (Utils.UndefinedOrNull(options)) {
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
|
||||
|
@ -104,6 +120,9 @@ class Component extends R3Object {
|
|||
this.emit(Event.OBJECT_CREATED, this);
|
||||
|
||||
//GENERATE_OPTIONS_INIT_START
|
||||
if (typeof options.runtime === 'undefined')) {
|
||||
options.runtime = R3.Runtime.DEFAULT;
|
||||
}
|
||||
//GENERATE_OPTIONS_INIT_END
|
||||
|
||||
//CUSTOM_OPTIONS_INIT_START
|
||||
|
@ -117,11 +136,98 @@ class Component extends R3Object {
|
|||
this.emit(Event.OBJECT_INITIALIZED, this);
|
||||
|
||||
//CUSTOM_AFTER_INIT_START
|
||||
this.emit(Event.COMPONENT_CREATED, this);
|
||||
//CUSTOM_AFTER_INIT_END
|
||||
}
|
||||
//GENERATE_CONSTRUCTOR_EXTENDS_END
|
||||
|
||||
//GENERATE_METHODS_START
|
||||
|
||||
/**
|
||||
* createInstance()
|
||||
* - No comment
|
||||
*/
|
||||
createInstance() {
|
||||
|
||||
//GENERATE_CREATE_INSTANCE_METHOD_START
|
||||
this.emit(Event.CREATE_INSTANCE_BEFORE, this);
|
||||
|
||||
this.getRuntime().createInstance(
|
||||
this,
|
||||
{
|
||||
//GENERATE_CREATE_INSTANCE_OPTIONS_START
|
||||
'runtime': this.runtime
|
||||
//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
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* dispose()
|
||||
* - No comment
|
||||
*/
|
||||
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()
|
||||
* - No comment
|
||||
*/
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* getRuntime()
|
||||
* - No comment
|
||||
*/
|
||||
getRuntime() {
|
||||
|
||||
//GENERATE_GET_RUNTIME_METHOD_START
|
||||
if (this.runtime === R3.Runtime.DEFAULT) {
|
||||
//TODO: implement runtime base
|
||||
return null;
|
||||
}
|
||||
|
||||
//TODO: implement runtime classes
|
||||
return null;
|
||||
//GENERATE_GET_RUNTIME_METHOD_END
|
||||
|
||||
//CUSTOM_GET_RUNTIME_METHOD_START
|
||||
//CUSTOM_GET_RUNTIME_METHOD_END
|
||||
|
||||
}
|
||||
//GENERATE_METHODS_END
|
||||
|
||||
//GENERATE_STATIC_METHODS_START
|
||||
|
|
|
@ -6,6 +6,7 @@ const Component = require('.././r3-component.js');
|
|||
|
||||
GENERATE_INHERITED_START
|
||||
|
||||
Class R3.Event.Object.Component.Image
|
||||
[Inherited from Event]
|
||||
|
||||
Properties:
|
||||
|
@ -56,11 +57,21 @@ const Component = require('.././r3-component.js');
|
|||
|
||||
Properties:
|
||||
|
||||
<no inherited properties>
|
||||
- runtime (Default value R3.Runtime.DEFAULT)
|
||||
|
||||
Methods:
|
||||
|
||||
<no inherited methods>
|
||||
- createInstance()
|
||||
No comment
|
||||
|
||||
- dispose()
|
||||
No comment
|
||||
|
||||
- disposeInstance()
|
||||
No comment
|
||||
|
||||
- getRuntime()
|
||||
No comment
|
||||
|
||||
Static Methods:
|
||||
|
||||
|
@ -109,7 +120,7 @@ class Image extends Component {
|
|||
//GENERATE_CONSTRUCTOR_EXTENDS_START
|
||||
constructor(options) {
|
||||
|
||||
if (Utils.UndefinedOrNull(options)) {
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,10 @@ class Event {
|
|||
|
||||
Event.Emit(Event.OBJECT_CREATED, this);
|
||||
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
|
||||
//GENERATE_OPTIONS_INIT_START
|
||||
//GENERATE_OPTIONS_INIT_END
|
||||
|
||||
|
@ -299,8 +303,8 @@ class Event {
|
|||
|
||||
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_START
|
||||
|
||||
//GENERATE_EVENT_START
|
||||
Event.COMPONENT_INITIALIZED = 0x1;
|
||||
//GENERATE_EVENTS_START
|
||||
Event.COMPONENT_CREATED = 0x1;
|
||||
Event.CREATE_INSTANCE_BEFORE = 0x2;
|
||||
Event.DISPOSE_INSTANCE = 0x3;
|
||||
Event.DISPOSE_OBJECT = 0x4;
|
||||
|
@ -313,16 +317,12 @@ Event.OBJECT_INITIALIZED = 0xa;
|
|||
Event.PAUSE = 0xb;
|
||||
Event.RESTART = 0xc;
|
||||
Event.START = 0xd;
|
||||
Event.UPDATE_FROM_INSTANCE_AFTER = 0xe;
|
||||
Event.UPDATE_FROM_INSTANCE_BEFORE = 0xf;
|
||||
Event.UPDATE_INSTANCE_AFTER = 0x10;
|
||||
Event.UPDATE_INSTANCE_BEFORE = 0x11;
|
||||
Event.MAX_EVENTS = 0x12;
|
||||
Event.MAX_EVENTS = 0xe;
|
||||
|
||||
Event.GetEventName = function(eventId) {
|
||||
|
||||
switch(eventId) {
|
||||
case 0x1 : return 'component_initialized';
|
||||
case 0x1 : return 'component_created';
|
||||
case 0x2 : return 'create_instance_before';
|
||||
case 0x3 : return 'dispose_instance';
|
||||
case 0x4 : return 'dispose_object';
|
||||
|
@ -335,16 +335,12 @@ Event.GetEventName = function(eventId) {
|
|||
case 0xb : return 'pause';
|
||||
case 0xc : return 'restart';
|
||||
case 0xd : return 'start';
|
||||
case 0xe : return 'update_from_instance_after';
|
||||
case 0xf : return 'update_from_instance_before';
|
||||
case 0x10 : return 'update_instance_after';
|
||||
case 0x11 : return 'update_instance_before';
|
||||
default :
|
||||
throw new Error('Event type not defined : ' + eventId);
|
||||
}
|
||||
|
||||
};
|
||||
//GENERATE_EVENT_END
|
||||
//GENERATE_EVENTS_END
|
||||
|
||||
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_END
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ const R3Object = require('./r3-r3-object.js');
|
|||
|
||||
GENERATE_INHERITED_START
|
||||
|
||||
Class R3.Event.Object.Project
|
||||
[Inherited from Event]
|
||||
|
||||
Properties:
|
||||
|
@ -95,7 +96,7 @@ class Project extends R3Object {
|
|||
//GENERATE_CONSTRUCTOR_EXTENDS_START
|
||||
constructor(options) {
|
||||
|
||||
if (Utils.UndefinedOrNull(options)) {
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ const Event = require('./r3-event.js');
|
|||
|
||||
GENERATE_INHERITED_START
|
||||
|
||||
Class R3.Event.Object
|
||||
[Inherited from Event]
|
||||
|
||||
Properties:
|
||||
|
@ -81,7 +82,7 @@ class R3Object extends Event {
|
|||
//GENERATE_CONSTRUCTOR_EXTENDS_START
|
||||
constructor(options) {
|
||||
|
||||
if (Utils.UndefinedOrNull(options)) {
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
|
||||
|
@ -90,10 +91,7 @@ class R3Object extends Event {
|
|||
this.emit(Event.OBJECT_CREATED, this);
|
||||
|
||||
//GENERATE_OPTIONS_INIT_START
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
if (Utils.UndefinedOrNull(options.register)) {
|
||||
if (typeof options.register === 'undefined')) {
|
||||
options.register = true;
|
||||
}
|
||||
//GENERATE_OPTIONS_INIT_END
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class R3 {
|
||||
static version = '2.0.82';
|
||||
static compileDate = '2021 Jul 12 - 12:02:40 pm';
|
||||
static version = '2.0.121';
|
||||
static compileDate = '2021 Aug 04 - 10:49:37 am';
|
||||
}
|
||||
|
||||
//GENERATE_IMPORTS_START
|
||||
|
@ -11,6 +11,7 @@ const SystemLinking = require('./r3-system/r3-system-linking.js');
|
|||
const SystemSocket = require('./r3-system/r3-system-socket.js');
|
||||
const SystemTest = require('./r3-system/r3-system-test.js');
|
||||
const R3Object = require('./r3-r3-object.js');
|
||||
const Runtime = require('./r3-runtime.js');
|
||||
const Component = require('./r3-component/r3-component.js');
|
||||
const Project = require('./r3-project.js');
|
||||
const Image = require('./r3-component/r3-image.js');
|
||||
|
@ -24,6 +25,7 @@ R3.System.Linking = SystemLinking;
|
|||
R3.System.Socket = SystemSocket;
|
||||
R3.System.Test = SystemTest;
|
||||
R3.Event.Object = R3Object;
|
||||
R3.Event.Runtime = Runtime;
|
||||
R3.Event.Object.Component = Component;
|
||||
R3.Event.Object.Project = Project;
|
||||
R3.Event.Object.Component.Image = Image;
|
||||
|
@ -35,6 +37,7 @@ R3.Component = Component;
|
|||
//GENERATE_CONVENIENT_DEFINES_END
|
||||
|
||||
//CUSTOM_CONVENIENT_DEFINES_START
|
||||
R3.Runtime = Runtime;
|
||||
//CUSTOM_CONVENIENT_DEFINES_END
|
||||
|
||||
module.exports = R3;
|
||||
|
|
|
@ -0,0 +1,127 @@
|
|||
const Utils = require('./r3-utils');
|
||||
const Event = require('./r3-event.js');
|
||||
|
||||
/**
|
||||
|
||||
GENERATE_INHERITED_START
|
||||
|
||||
Class R3.Event.Runtime
|
||||
[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
|
||||
|
||||
[Belonging to Runtime]
|
||||
|
||||
Properties:
|
||||
|
||||
<no static properties>
|
||||
|
||||
Methods:
|
||||
|
||||
<no methods>
|
||||
|
||||
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
|
||||
CUSTOM_METHODS_END
|
||||
|
||||
CUSTOM_STATIC_METHODS_START
|
||||
CUSTOM_STATIC_METHODS_END
|
||||
|
||||
**/
|
||||
|
||||
class Runtime extends Event {
|
||||
|
||||
//GENERATE_CONSTRUCTOR_EXTENDS_START
|
||||
constructor(options) {
|
||||
|
||||
if (typeof options === 'undefined') {
|
||||
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
|
||||
//GENERATE_METHODS_END
|
||||
|
||||
//GENERATE_STATIC_METHODS_START
|
||||
//GENERATE_STATIC_METHODS_END
|
||||
|
||||
//CUSTOM_IMPLEMENTATION_START
|
||||
//CUSTOM_IMPLEMENTATION_END
|
||||
}
|
||||
|
||||
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_START
|
||||
|
||||
Runtime.DEFAULT = 0x1;
|
||||
Runtime.GRAPHICS = 0x2;
|
||||
|
||||
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_END
|
||||
|
||||
module.exports = Runtime;
|
|
@ -0,0 +1,77 @@
|
|||
const Event = require('.././r3-event');
|
||||
const Utils = require('.././r3-utils');
|
||||
const System = require('./r3-system.js');
|
||||
|
||||
/**
|
||||
|
||||
GENERATE_INHERITED_START
|
||||
|
||||
GENERATE_INHERITED_END
|
||||
|
||||
CUSTOM_OPTIONS_START
|
||||
CUSTOM_OPTIONS_END
|
||||
|
||||
CUSTOM_EVENT_LISTENERS_START
|
||||
CUSTOM_EVENT_LISTENERS_END
|
||||
|
||||
CUSTOM_METHODS_START
|
||||
start(options = {}) - Just calls System.Start(options)
|
||||
stop(options = {}) - Just calls System.Stop(options)
|
||||
CUSTOM_METHODS_END
|
||||
|
||||
CUSTOM_STATIC_METHODS_START
|
||||
Start(options = {}) - Starts the system by registering subscriptions to events
|
||||
Stop(options = {}) - Stops the system by removing these subscriptions to events
|
||||
CUSTOM_STATIC_METHODS_END
|
||||
|
||||
**/
|
||||
|
||||
class SystemInput extends System {
|
||||
|
||||
//GENERATE_CONSTRUCTOR_EXTENDS_START
|
||||
constructor(options) {
|
||||
|
||||
if (typeof options === 'undefined') {
|
||||
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
|
||||
//GENERATE_METHODS_END
|
||||
|
||||
//GENERATE_STATIC_METHODS_START
|
||||
//GENERATE_STATIC_METHODS_END
|
||||
|
||||
//GENERATE_STATIC_EVENT_LISTENER_METHODS_START
|
||||
//GENERATE_STATIC_EVENT_LISTENER_METHODS_END
|
||||
|
||||
//CUSTOM_IMPLEMENTATION_START
|
||||
//CUSTOM_IMPLEMENTATION_END
|
||||
|
||||
}
|
||||
|
||||
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_START
|
||||
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_END
|
||||
|
||||
module.exports = SystemInput;
|
|
@ -6,6 +6,7 @@ const System = require('./r3-system.js');
|
|||
|
||||
GENERATE_INHERITED_START
|
||||
|
||||
Class R3.System.Linking
|
||||
[Inherited from System]
|
||||
|
||||
Properties:
|
||||
|
@ -37,18 +38,18 @@ const System = require('./r3-system.js');
|
|||
Methods:
|
||||
|
||||
- start(options)
|
||||
Just calls System.Start(options)
|
||||
Overrides for R3.System.start()
|
||||
|
||||
- stop(options)
|
||||
Just calls System.Stop(options)
|
||||
Overrides for R3.System.stop()
|
||||
|
||||
Static Methods:
|
||||
|
||||
- Start(options)
|
||||
Starts the system by registering subscriptions to events
|
||||
Overrides for R3.System.Start()
|
||||
|
||||
- Stop(options)
|
||||
Stops the system by removing these subscriptions to events
|
||||
Overrides for R3.System.Stop()
|
||||
|
||||
GENERATE_INHERITED_END
|
||||
|
||||
|
@ -77,7 +78,7 @@ class SystemLinking extends System {
|
|||
//GENERATE_CONSTRUCTOR_EXTENDS_START
|
||||
constructor(options) {
|
||||
|
||||
if (Utils.UndefinedOrNull(options)) {
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ const System = require('./r3-system.js');
|
|||
|
||||
GENERATE_INHERITED_START
|
||||
|
||||
Class R3.System.Socket
|
||||
[Inherited from System]
|
||||
|
||||
Properties:
|
||||
|
@ -37,18 +38,18 @@ const System = require('./r3-system.js');
|
|||
Methods:
|
||||
|
||||
- start(options)
|
||||
Just calls System.Start(options)
|
||||
Overrides for R3.System.start()
|
||||
|
||||
- stop(options)
|
||||
Just calls System.Stop(options)
|
||||
Overrides for R3.System.stop()
|
||||
|
||||
Static Methods:
|
||||
|
||||
- Start(options)
|
||||
Starts the system by registering subscriptions to events
|
||||
Overrides for R3.System.Start()
|
||||
|
||||
- Stop(options)
|
||||
Stops the system by removing these subscriptions to events
|
||||
Overrides for R3.System.Stop()
|
||||
|
||||
GENERATE_INHERITED_END
|
||||
|
||||
|
@ -75,7 +76,7 @@ class SystemSocket extends System {
|
|||
//GENERATE_CONSTRUCTOR_EXTENDS_START
|
||||
constructor(options) {
|
||||
|
||||
if (Utils.UndefinedOrNull(options)) {
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
|
||||
|
@ -133,6 +134,7 @@ class SystemSocket extends System {
|
|||
//GENERATE_STOP_METHOD_END
|
||||
|
||||
//CUSTOM_STOP_METHOD_START
|
||||
console.log('system socket stop test');
|
||||
//CUSTOM_STOP_METHOD_END
|
||||
|
||||
}
|
||||
|
@ -163,6 +165,7 @@ class SystemSocket extends System {
|
|||
//GENERATE_STATIC_START_METHOD_END
|
||||
|
||||
//CUSTOM_STATIC_START_METHOD_START
|
||||
console.log('CUSTOM Start Test Stuff');
|
||||
//CUSTOM_STATIC_START_METHOD_END
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ const System = require('./r3-system.js');
|
|||
|
||||
GENERATE_INHERITED_START
|
||||
|
||||
Class R3.System.Test
|
||||
[Inherited from System]
|
||||
|
||||
Properties:
|
||||
|
@ -37,18 +38,18 @@ const System = require('./r3-system.js');
|
|||
Methods:
|
||||
|
||||
- start(options)
|
||||
Just calls System.Start(options)
|
||||
Overrides for R3.System.start()
|
||||
|
||||
- stop(options)
|
||||
Just calls System.Stop(options)
|
||||
Overrides for R3.System.stop()
|
||||
|
||||
Static Methods:
|
||||
|
||||
- Start(options)
|
||||
Starts the system by registering subscriptions to events
|
||||
Overrides for R3.System.Start()
|
||||
|
||||
- Stop(options)
|
||||
Stops the system by removing these subscriptions to events
|
||||
Overrides for R3.System.Stop()
|
||||
|
||||
GENERATE_INHERITED_END
|
||||
|
||||
|
@ -75,7 +76,7 @@ class SystemTest extends System {
|
|||
//GENERATE_CONSTRUCTOR_EXTENDS_START
|
||||
constructor(options) {
|
||||
|
||||
if (Utils.UndefinedOrNull(options)) {
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,10 @@ class System {
|
|||
|
||||
Event.Emit(Event.OBJECT_CREATED, this);
|
||||
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
|
||||
//GENERATE_OPTIONS_INIT_START
|
||||
//GENERATE_OPTIONS_INIT_END
|
||||
|
||||
|
|
|
@ -24,6 +24,10 @@ class Utils {
|
|||
|
||||
Event.Emit(Event.OBJECT_CREATED, this);
|
||||
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
|
||||
//GENERATE_OPTIONS_INIT_START
|
||||
//GENERATE_OPTIONS_INIT_END
|
||||
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
Event.Emit(Event.OBJECT_CREATED, this);
|
||||
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
|
||||
//GENERATE_OPTIONS_INIT_START
|
||||
//GENERATE_OPTIONS_INIT_END
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
constructor(options) {
|
||||
|
||||
if (Utils.UndefinedOrNull(options)) {
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
this.emit(Event.CREATE_INSTANCE_BEFORE, this);
|
||||
|
||||
this[this.runtime].createInstance(
|
||||
this.getRuntime().createInstance(
|
||||
this,
|
||||
{
|
||||
//GENERATE_CREATE_INSTANCE_OPTIONS_START
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
if (Utils.UndefinedOrNull(options.KEY)) {
|
||||
if (typeof options.KEY === 'undefined')) {
|
||||
options.KEY = VALUE;
|
||||
}
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
|
||||
FIRST_TEMPLATE
|
||||
[DESCRIPTION CLASS_NAME]
|
||||
|
||||
Properties:
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
if (this.runtime === R3.Runtime.DEFAULT) {
|
||||
//TODO: implement runtime base
|
||||
return null;
|
||||
}
|
||||
|
||||
//TODO: implement runtime classes
|
||||
return null;
|
|
@ -15,13 +15,13 @@ const EXTEND_CLASS = require('./EXTEND_CLASS_FILE_NAME');
|
|||
CUSTOM_EVENT_LISTENERS_END
|
||||
|
||||
CUSTOM_METHODS_START
|
||||
start(options) - Just calls System.Start(options)
|
||||
stop(options) - Just calls System.Stop(options)
|
||||
start(options = {}) - Just calls System.Start(options)
|
||||
stop(options = {}) - Just calls System.Stop(options)
|
||||
CUSTOM_METHODS_END
|
||||
|
||||
CUSTOM_STATIC_METHODS_START
|
||||
Start(options) - Starts the system by registering subscriptions to events
|
||||
Stop(options) - Stops the system by removing these subscriptions to events
|
||||
Start(options = {}) - Starts the system by registering subscriptions to events
|
||||
Stop(options = {}) - Stops the system by removing these subscriptions to events
|
||||
CUSTOM_STATIC_METHODS_END
|
||||
|
||||
**/
|
||||
|
|
|
@ -2,13 +2,17 @@ GENERATE_ASYNC_METHOD
|
|||
GENERATE_CONSTRUCTOR
|
||||
GENERATE_CONSTRUCTOR_EXTENDS
|
||||
GENERATE_CONVENIENT_DEFINES
|
||||
GENERATE_CREATE_INSTANCE_METHOD
|
||||
GENERATE_CREATE_INSTANCE_OPTIONS
|
||||
GENERATE_DEFINES
|
||||
GENERATE_DISPOSE_INSTANCE_METHOD
|
||||
GENERATE_DISPOSE_METHOD
|
||||
GENERATE_EMIT_METHOD
|
||||
GENERATE_EVENT
|
||||
GENERATE_EVENT_LISTENERS_START
|
||||
GENERATE_EVENT_LISTENERS_STOP
|
||||
GENERATE_EVENTS
|
||||
GENERATE_EXPORTS
|
||||
GENERATE_GET_RUNTIME_METHOD
|
||||
GENERATE_IMPORTS
|
||||
GENERATE_INDEX_BODY
|
||||
GENERATE_INHERITED
|
||||
|
@ -34,9 +38,13 @@ CUSTOM_AFTER_INIT
|
|||
CUSTOM_ASYNC_METHOD
|
||||
CUSTOM_BEFORE_INIT
|
||||
CUSTOM_CONVENIENT_DEFINES
|
||||
CUSTOM_CREATE_INSTANCE_METHOD
|
||||
CUSTOM_DISPOSE_INSTANCE_METHOD
|
||||
CUSTOM_DISPOSE_METHOD
|
||||
CUSTOM_EMIT_METHOD
|
||||
CUSTOM_EVENT_LISTENERS
|
||||
CUSTOM_EXCLUDED_FROM_INSTANCE_OPTIONS
|
||||
CUSTOM_GET_RUNTIME_METHOD
|
||||
CUSTOM_IMPLEMENTATION
|
||||
CUSTOM_INSTANCE_OPTIONS_MAPPING
|
||||
CUSTOM_LINKED_OBJECTS
|
||||
|
|
21
utils.php
21
utils.php
|
@ -1,5 +1,26 @@
|
|||
<?php
|
||||
|
||||
function to_camel_case_from_upper_underscore($string, $capitalizeFirstCharacter = true)
|
||||
{
|
||||
|
||||
$str = str_replace(' ', '', ucwords(str_replace('_', ' ', strtolower($string))));
|
||||
|
||||
if (!$capitalizeFirstCharacter) {
|
||||
$str[0] = strtolower($str[0]);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
function from_camel_case($input) {
|
||||
preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $input, $matches);
|
||||
$ret = $matches[0];
|
||||
foreach ($ret as &$match) {
|
||||
$match = $match == strtoupper($match) ? strtolower($match) : lcfirst($match);
|
||||
}
|
||||
return implode('_', $ret);
|
||||
}
|
||||
|
||||
if (isset($argc)) {
|
||||
for ($i = 0; $i < $argc; $i++) {
|
||||
echo "Argument #" . $i . " - " . $argv[$i] . "\n";
|
||||
|
|
Loading…
Reference in New Issue