check default arg values on undefined

master
Theunis J. Botha 2021-08-04 10:50:28 +02:00
parent 01196d29ad
commit 3402c7a891
25 changed files with 401 additions and 389 deletions

View File

@ -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);
?>

69
dist/r3.js vendored
View File

@ -1,6 +1,6 @@
class R3 {
static version = '2.0.105';
static compileDate = '2021 Aug 04 - 08:59:53 am';
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);
@ -1640,7 +1644,7 @@ class SystemLinking extends System {
constructor(options) {
if (Utils.UndefinedOrNull(options)) {
if (typeof options === 'undefined') {
options = {};
}
@ -1820,7 +1824,7 @@ class SystemSocket extends System {
constructor(options) {
if (Utils.UndefinedOrNull(options)) {
if (typeof options === 'undefined') {
options = {};
}
@ -1951,7 +1955,7 @@ class SystemTest extends System {
constructor(options) {
if (Utils.UndefinedOrNull(options)) {
if (typeof options === 'undefined') {
options = {};
}
@ -2084,7 +2088,7 @@ class R3Object extends Event {
constructor(options) {
if (Utils.UndefinedOrNull(options)) {
if (typeof options === 'undefined') {
options = {};
}
@ -2092,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;
}
@ -2166,7 +2167,7 @@ class Runtime extends Event {
constructor(options) {
if (Utils.UndefinedOrNull(options)) {
if (typeof options === 'undefined') {
options = {};
}
@ -2182,6 +2183,9 @@ class Runtime extends Event {
}
Runtime.DEFAULT = 0x1;
Runtime.GRAPHICS = 0x2;
/**
Class R3.Event.Object.Component
@ -2235,7 +2239,7 @@ class Runtime extends Event {
Properties:
- runtime (Default value R3.RUNTIME_DEFAULT)
- runtime (Default value R3.Runtime.DEFAULT)
Methods:
@ -2265,7 +2269,7 @@ class Component extends R3Object {
constructor(options) {
if (Utils.UndefinedOrNull(options)) {
if (typeof options === 'undefined') {
options = {};
}
@ -2273,17 +2277,15 @@ class Component extends R3Object {
this.emit(Event.OBJECT_CREATED, this);
if (typeof options === 'undefined') {
options = {};
}
if (Utils.UndefinedOrNull(options.runtime)) {
options.runtime = R3.RUNTIME_DEFAULT;
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);
}
/**
@ -2340,7 +2342,7 @@ class Component extends R3Object {
*/
getRuntime() {
if (this.runtime === R3.RUNTIME_DEFAULT) {
if (this.runtime === R3.Runtime.DEFAULT) {
//TODO: implement runtime base
return null;
}
@ -2425,7 +2427,7 @@ class Project extends R3Object {
constructor(options) {
if (Utils.UndefinedOrNull(options)) {
if (typeof options === 'undefined') {
options = {};
}
@ -2494,7 +2496,7 @@ class Project extends R3Object {
Properties:
- runtime (Default value R3.RUNTIME_DEFAULT)
- runtime (Default value R3.Runtime.DEFAULT)
Methods:
@ -2538,7 +2540,7 @@ class Image extends Component {
constructor(options) {
if (Utils.UndefinedOrNull(options)) {
if (typeof options === 'undefined') {
options = {};
}
@ -2567,6 +2569,7 @@ 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);

View File

@ -1,6 +1,6 @@
{
"name": "r3",
"version" : "2.0.105",
"version" : "2.0.121",
"description": "",
"private": true,
"dependencies": {

501
r3.php
View File

@ -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)
{
@ -436,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);
@ -668,7 +648,6 @@ function generateEventListenersStop($file, $tokens)
updateSection($file, 'GENERATE_EVENT_LISTENERS_STOP' , $updated);
}
/**
* @param $item
* @return array
@ -951,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)
{
/**
@ -1256,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';
@ -1376,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;
@ -1416,7 +1502,6 @@ if ($argv[2] == 'build-dist') {
generateR3($nodes);
generateR3Dist($nodes);
foreach ($files as $file) {
$saveFile = $file . '.saved';
@ -1427,8 +1512,6 @@ if ($argv[2] == 'build-dist') {
}
exit(0);
?>

View File

@ -57,7 +57,7 @@ const R3Object = require('.././r3-r3-object.js');
Properties:
- runtime (Default value R3.RUNTIME_DEFAULT)
- runtime (Default value R3.Runtime.DEFAULT)
Methods:
@ -81,7 +81,7 @@ const R3Object = require('.././r3-r3-object.js');
Of the form x=<value>
CUSTOM_OPTIONS_START
runtime=R3.RUNTIME_DEFAULT
runtime=R3.Runtime.DEFAULT
CUSTOM_OPTIONS_END
Of the form x=<instance.property>
@ -111,7 +111,7 @@ class Component extends R3Object {
//GENERATE_CONSTRUCTOR_EXTENDS_START
constructor(options) {
if (Utils.UndefinedOrNull(options)) {
if (typeof options === 'undefined') {
options = {};
}
@ -120,11 +120,8 @@ class Component extends R3Object {
this.emit(Event.OBJECT_CREATED, this);
//GENERATE_OPTIONS_INIT_START
if (typeof options === 'undefined') {
options = {};
}
if (Utils.UndefinedOrNull(options.runtime)) {
options.runtime = R3.RUNTIME_DEFAULT;
if (typeof options.runtime === 'undefined')) {
options.runtime = R3.Runtime.DEFAULT;
}
//GENERATE_OPTIONS_INIT_END
@ -139,6 +136,7 @@ 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
@ -217,7 +215,7 @@ class Component extends R3Object {
getRuntime() {
//GENERATE_GET_RUNTIME_METHOD_START
if (this.runtime === R3.RUNTIME_DEFAULT) {
if (this.runtime === R3.Runtime.DEFAULT) {
//TODO: implement runtime base
return null;
}

View File

@ -57,7 +57,7 @@ const Component = require('.././r3-component.js');
Properties:
- runtime (Default value R3.RUNTIME_DEFAULT)
- runtime (Default value R3.Runtime.DEFAULT)
Methods:
@ -120,7 +120,7 @@ class Image extends Component {
//GENERATE_CONSTRUCTOR_EXTENDS_START
constructor(options) {
if (Utils.UndefinedOrNull(options)) {
if (typeof options === 'undefined') {
options = {};
}

View File

@ -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

View File

@ -96,7 +96,7 @@ class Project extends R3Object {
//GENERATE_CONSTRUCTOR_EXTENDS_START
constructor(options) {
if (Utils.UndefinedOrNull(options)) {
if (typeof options === 'undefined') {
options = {};
}

View File

@ -82,7 +82,7 @@ class R3Object extends Event {
//GENERATE_CONSTRUCTOR_EXTENDS_START
constructor(options) {
if (Utils.UndefinedOrNull(options)) {
if (typeof options === 'undefined') {
options = {};
}
@ -91,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

View File

@ -1,6 +1,6 @@
class R3 {
static version = '2.0.105';
static compileDate = '2021 Aug 04 - 08:59:53 am';
static version = '2.0.121';
static compileDate = '2021 Aug 04 - 10:49:37 am';
}
//GENERATE_IMPORTS_START
@ -37,6 +37,7 @@ R3.Component = Component;
//GENERATE_CONVENIENT_DEFINES_END
//CUSTOM_CONVENIENT_DEFINES_START
R3.Runtime = Runtime;
//CUSTOM_CONVENIENT_DEFINES_END
module.exports = R3;

View File

@ -81,7 +81,7 @@ class Runtime extends Event {
//GENERATE_CONSTRUCTOR_EXTENDS_START
constructor(options) {
if (Utils.UndefinedOrNull(options)) {
if (typeof options === 'undefined') {
options = {};
}
@ -119,8 +119,8 @@ class Runtime extends Event {
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_START
//GENERATE_RUNTIMES_START
//GENERATE_RUNTIMES_END
Runtime.DEFAULT = 0x1;
Runtime.GRAPHICS = 0x2;
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_END

View File

@ -78,7 +78,7 @@ class SystemLinking extends System {
//GENERATE_CONSTRUCTOR_EXTENDS_START
constructor(options) {
if (Utils.UndefinedOrNull(options)) {
if (typeof options === 'undefined') {
options = {};
}

View File

@ -76,7 +76,7 @@ class SystemSocket extends System {
//GENERATE_CONSTRUCTOR_EXTENDS_START
constructor(options) {
if (Utils.UndefinedOrNull(options)) {
if (typeof options === 'undefined') {
options = {};
}

View File

@ -76,7 +76,7 @@ class SystemTest extends System {
//GENERATE_CONSTRUCTOR_EXTENDS_START
constructor(options) {
if (Utils.UndefinedOrNull(options)) {
if (typeof options === 'undefined') {
options = {};
}

View File

@ -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

View File

@ -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

View File

@ -2,6 +2,10 @@
Event.Emit(Event.OBJECT_CREATED, this);
if (typeof options === 'undefined') {
options = {};
}
//GENERATE_OPTIONS_INIT_START
//GENERATE_OPTIONS_INIT_END

View File

@ -1,6 +1,6 @@
constructor(options) {
if (Utils.UndefinedOrNull(options)) {
if (typeof options === 'undefined') {
options = {};
}

View File

@ -1,3 +1,3 @@
if (Utils.UndefinedOrNull(options.KEY)) {
if (typeof options.KEY === 'undefined')) {
options.KEY = VALUE;
}

View File

@ -1,3 +0,0 @@
if (typeof options === 'undefined') {
options = {};
}

View File

@ -1,4 +1,4 @@
if (this.runtime === R3.RUNTIME_DEFAULT) {
if (this.runtime === R3.Runtime.DEFAULT) {
//TODO: implement runtime base
return null;
}

View File

@ -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
**/

View File

@ -8,9 +8,9 @@ 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
@ -19,7 +19,6 @@ GENERATE_INHERITED
GENERATE_METHOD_NAME_UPPERCASE_METHOD
GENERATE_METHODS
GENERATE_OPTIONS_INIT
GENERATE_RUNTIMES
GENERATE_START_METHOD
GENERATE_STATIC_ASYNC_METHOD
GENERATE_STATIC_EMIT_METHOD

View File

@ -1,5 +1,26 @@
<?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);
}
if (isset($argc)) {
for ($i = 0; $i < $argc; $i++) {
echo "Argument #" . $i . " - " . $argv[$i] . "\n";

View File

@ -1 +1 @@
2.0.105
2.0.121