new entities

master
Theunis J. Botha 2021-09-10 07:18:08 +02:00
parent 48068f057d
commit b384d331ac
14 changed files with 443 additions and 84 deletions

View File

@ -28,3 +28,5 @@ r3 create Canvas extends DOM ./r3-component/
r3 create SystemDOM system
r3 create Document extends Default ./r3-runtime/
r3 create SystemRuntime system
r3 create Entity normal ./r3-entity/
r3 create Slider extends Entity ./r3-entity/

158
dist/r3.js vendored
View File

@ -1,8 +1,56 @@
class R3 {
static version = '2.0.454';
static compileDate = '2021 Sep 09 - 18:08:03 pm';
static version = '2.0.464';
static compileDate = '2021 Sep 10 - 07:16:56 am';
}
class Entity {
constructor(options) {
Event.Emit(Event.OBJECT_CREATED, this);
if (typeof options === 'undefined') {
options = {};
}
if (typeof options.callDepth === 'undefined') {
options.callDepth = 0;
} else {
options.callDepth++;
}
Object.assign(this, options);
if (options.callDepth === 0) {
this.initialized();
} else {
options.callDepth--;
}
}
/**
* initialized()
* - Should raise an event(s) which indicates that this object initialized
*/
initialized() {
if (this.hasOwnProperty('callDepth')) {
delete this.callDepth;
} else {
console.warn('Multiple calls to initialized() - check your callstack');
}
Event.Emit(Event.OBJECT_INITIALIZED, this);
Event.Emit(Event.ENTITY_INITIALIZED, this);
}
}
Entity.SLIDER = 0x0;
Entity.MAX_ENTITY = 0x1;
class System {
constructor(options) {
@ -22,7 +70,7 @@ System.SYSTEM_INPUT = 0x1;
System.SYSTEM_LINKING = 0x2;
System.SYSTEM_RUNTIME = 0x3;
System.SYSTEM_SOCKET = 0x4;
System.MAX_SYSTEMS = 0x5;
System.MAX_SYSTEM = 0x5;
class Event {
@ -278,13 +326,13 @@ class Event {
}
Event.BEFORE_RENDER = 0x1;
Event.COMPONENT_CREATED = 0x2;
Event.COMPONENT_INITIALIZED = 0x3;
Event.CREATE_INSTANCE_BEFORE = 0x4;
Event.DISPOSE_INSTANCE = 0x5;
Event.DISPOSE_OBJECT = 0x6;
Event.DOM_COMPONENT_INITIALIZED = 0x7;
Event.COMPONENT_CREATED = 0x1;
Event.COMPONENT_INITIALIZED = 0x2;
Event.CREATE_INSTANCE_BEFORE = 0x3;
Event.DISPOSE_INSTANCE = 0x4;
Event.DISPOSE_OBJECT = 0x5;
Event.DOM_COMPONENT_INITIALIZED = 0x6;
Event.ENTITY_INITIALIZED = 0x7;
Event.GET_RUNTIME = 0x8;
Event.GET_WINDOW_SIZE = 0x9;
Event.INPUT_COMPONENT_INITIALIZED = 0xa;
@ -313,13 +361,13 @@ Event.MAX_EVENTS = 0x1f;
Event.GetEventName = function(eventId) {
switch(eventId) {
case 0x1 : return 'before_render';
case 0x2 : return 'component_created';
case 0x3 : return 'component_initialized';
case 0x4 : return 'create_instance_before';
case 0x5 : return 'dispose_instance';
case 0x6 : return 'dispose_object';
case 0x7 : return 'dom_component_initialized';
case 0x1 : return 'component_created';
case 0x2 : return 'component_initialized';
case 0x3 : return 'create_instance_before';
case 0x4 : return 'dispose_instance';
case 0x5 : return 'dispose_object';
case 0x6 : return 'dom_component_initialized';
case 0x7 : return 'entity_initialized';
case 0x8 : return 'get_runtime';
case 0x9 : return 'get_window_size';
case 0xa : return 'input_component_initialized';
@ -1621,6 +1669,76 @@ class Utils {
}
/**
Class R3.Entity.Slider
[Inherited from Entity]
Inherited Properties:
<no inherited properties>
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
- initialized()
Should raise an event(s) which indicates that this object initialized
Inherited Static Methods:
<no inherited static methods>
[Belonging to Slider]
Properties:
<no properties>
Static Properties:
<no static properties>
Methods:
<no methods>
Static Methods:
<no static methods>
**/
class Slider extends Entity {
constructor(options) {
if (typeof options === 'undefined') {
options = {};
}
if (typeof options.callDepth === 'undefined') {
options.callDepth = 0;
} else {
options.callDepth++;
}
super(options);
Object.assign(this, options);
if (options.callDepth === 0) {
this.initialized();
} else {
options.callDepth--;
}
}
}
/**
Class R3.System.DOM
@ -2450,7 +2568,7 @@ Runtime.BULLET = 0x9;
Runtime.SOCKET = 0xa;
Runtime.STATISTICS = 0xb;
Runtime.STATS = 0xc;
Runtime.MAX_RUNTIMES = 0xd;
Runtime.MAX_RUNTIME = 0xd;
/**
@ -3553,7 +3671,7 @@ Component.DOM = 0x0;
Component.CANVAS = 0x1;
Component.INPUT = 0x2;
Component.TOUCH = 0x3;
Component.MAX_COMPONENTS = 0x4;
Component.MAX_COMPONENT = 0x4;
/**
@ -5101,6 +5219,7 @@ class Touch extends Input {
}
R3.Entity = Entity;
R3.System = System;
R3.Event = Event;
R3.Utils = Utils;
@ -5134,6 +5253,7 @@ Runtime.Physics.Bullet = Bullet;
Runtime.Socket = Socket;
Runtime.Statistics = Statistics;
Runtime.Statistics.Stats = Stats;
Entity.Slider = Slider;
console.log('r3.js - version ' + R3.version + ' compiled ' + R3.compileDate);
R3.System.DOM.Start();
R3.System.Input.Start();

View File

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

26
r3.php
View File

@ -286,7 +286,7 @@ function doGetInheritedTemplateUpdates($node, $restoreTokens, $inherited = true,
} catch (ErrorException $e) {
echo $e->getMessage();
exit(1);
exit(0);
}
$updates = '';
@ -454,7 +454,8 @@ function generateConstructors($file, $command)
}
if (!$constructor) {
throw new Exception('Constructor not found for file : ' . $file);
console.log('No constructor found for : ' . $file);
return;
}
updateSection($file, $token , $constructor);
@ -1378,6 +1379,7 @@ function generateR3Dist($nodes)
'src/r3/r3-system/index.js',
'src/r3/r3-component/index.js',
'src/r3/r3-runtime/index.js',
'src/r3/r3-entity/index.js',
];
foreach ($indexFiles as $indexFile) {
@ -1561,7 +1563,7 @@ function generateOutOfClassImplementationDefines($graph, $types)
$i++;
}
array_push($updateList, $parent->name . '.MAX_' . strtoupper($parent->name) . 'S = 0x' . dechex($i) . ";\n");
array_push($updateList, $parent->name . '.MAX_' . strtoupper($parent->name) . ' = 0x' . dechex($i) . ";\n");
updateSection($parent->file, 'GENERATED_OUT_OF_CLASS_IMPLEMENTATION' , $updateList);
}
@ -1603,14 +1605,14 @@ foreach ($files as $file) {
echo "Remove easily with:\n";
echo "rm $saveFile\n";
exit(1);
exit(0);
}
$tokens = getTokens('CUSTOM');
$result = save($file, $tokens);
exit(0);
exit(1);
} else if ($argv[2] == 'restore') {
@ -1624,7 +1626,7 @@ foreach ($files as $file) {
$tokens = loadSaved($file, $restoreTokens);
} catch (ErrorException $e) {
echo $e->getMessage();
exit(1);
exit(0);
}
$skipped = [];
@ -1696,10 +1698,10 @@ foreach ($files as $file) {
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);
exit(0);
} else {
deleteSavedFile($saveFile);
exit(0);
exit(1);
}
} else if ($argv[2] == 'build-dist') {
buildNodeList($file);
@ -1738,7 +1740,8 @@ if ($argv[2] == 'build-dist') {
[
'System',
'Component',
'Runtime'
'Runtime',
'Entity'
]
);
@ -1753,7 +1756,8 @@ if ($argv[2] == 'build-dist') {
[
'System',
'Component',
'Runtime'
'Runtime',
'Entity'
]
);
@ -1770,6 +1774,6 @@ if ($argv[2] == 'build-dist') {
}
exit(0);
exit(1);
?>

View File

@ -312,7 +312,7 @@ Component.DOM = 0x0;
Component.CANVAS = 0x1;
Component.INPUT = 0x2;
Component.TOUCH = 0x3;
Component.MAX_COMPONENTS = 0x4;
Component.MAX_COMPONENT = 0x4;
//GENERATED_OUT_OF_CLASS_IMPLEMENTATION_END
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_START

12
src/r3/r3-entity/index.js Normal file
View File

@ -0,0 +1,12 @@
//GENERATED_IMPORTS_START
const Entity = require('./r3-entity.js');
const Slider = require('./r3-slider.js');
//GENERATED_IMPORTS_END
//GENERATED_INDEX_BODY_START
Entity.Slider = Slider;
//GENERATED_INDEX_BODY_END
//GENERATED_EXPORTS_START
module.exports = Entity;
//GENERATED_EXPORTS_END

View File

@ -0,0 +1,101 @@
const Event = require('.././r3-event');
const Utils = require('.././r3-utils');
/**
GENERATED_INHERITED_START
GENERATED_INHERITED_END
CUSTOM_OPTIONS_START
CUSTOM_OPTIONS_END
CUSTOM_METHODS_START
initialized() - Should raise an event(s) which indicates that this object initialized
CUSTOM_METHODS_END
CUSTOM_STATIC_METHODS_START
CUSTOM_STATIC_METHODS_END
**/
class Entity {
//GENERATED_CONSTRUCTOR_START
constructor(options) {
Event.Emit(Event.OBJECT_CREATED, this);
if (typeof options === 'undefined') {
options = {};
}
if (typeof options.callDepth === 'undefined') {
options.callDepth = 0;
} else {
options.callDepth++;
}
//GENERATED_OPTIONS_INIT_START
//GENERATED_OPTIONS_INIT_END
//CUSTOM_OPTIONS_INIT_START
//CUSTOM_OPTIONS_INIT_END
Object.assign(this, options);
//CUSTOM_BEFORE_INIT_START
//CUSTOM_BEFORE_INIT_END
if (options.callDepth === 0) {
this.initialized();
} else {
options.callDepth--;
}
//CUSTOM_AFTER_INIT_START
//CUSTOM_AFTER_INIT_END
}
//GENERATED_CONSTRUCTOR_END
//CUSTOM_IMPLEMENTATION_START
//CUSTOM_IMPLEMENTATION_END
//GENERATED_METHODS_START
/**
* initialized()
* - Should raise an event(s) which indicates that this object initialized
*/
initialized() {
//GENERATED_INITIALIZED_METHOD_START
if (this.hasOwnProperty('callDepth')) {
delete this.callDepth;
} else {
console.warn('Multiple calls to initialized() - check your callstack');
}
//GENERATED_INITIALIZED_METHOD_END
//CUSTOM_INITIALIZED_METHOD_START
Event.Emit(Event.OBJECT_INITIALIZED, this);
Event.Emit(Event.ENTITY_INITIALIZED, this);
//CUSTOM_INITIALIZED_METHOD_END
}
//GENERATED_METHODS_END
//GENERATED_STATIC_METHODS_START
//GENERATED_STATIC_METHODS_END
}
//GENERATED_OUT_OF_CLASS_IMPLEMENTATION_START
Entity.SLIDER = 0x0;
Entity.MAX_ENTITY = 0x1;
//GENERATED_OUT_OF_CLASS_IMPLEMENTATION_END
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_START
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_END
module.exports = Entity;

View File

@ -0,0 +1,124 @@
const Event = require('.././r3-event');
const Utils = require('.././r3-utils');
const Entity = require('.././r3-entity.js');
/**
GENERATED_INHERITED_START
Class R3.Entity.Slider
[Inherited from Entity]
Inherited Properties:
<no inherited properties>
Inherited Static Properties:
<no inherited static properties>
Inherited Methods:
- initialized()
Should raise an event(s) which indicates that this object initialized
Inherited Static Methods:
<no inherited static methods>
[Belonging to Slider]
Properties:
<no properties>
Static Properties:
<no static properties>
Methods:
<no methods>
Static Methods:
<no static methods>
GENERATED_INHERITED_END
CUSTOM_OPTIONS_START
CUSTOM_OPTIONS_END
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 Slider extends Entity {
//GENERATED_CONSTRUCTOR_EXTENDS_START
constructor(options) {
if (typeof options === 'undefined') {
options = {};
}
if (typeof options.callDepth === 'undefined') {
options.callDepth = 0;
} else {
options.callDepth++;
}
super(options);
//GENERATED_OPTIONS_INIT_START
//GENERATED_OPTIONS_INIT_END
//CUSTOM_OPTIONS_INIT_START
//CUSTOM_OPTIONS_INIT_END
Object.assign(this, options);
//CUSTOM_BEFORE_INIT_START
//CUSTOM_BEFORE_INIT_END
if (options.callDepth === 0) {
this.initialized();
} else {
options.callDepth--;
}
//CUSTOM_AFTER_INIT_START
//CUSTOM_AFTER_INIT_END
}
//GENERATED_CONSTRUCTOR_EXTENDS_END
//GENERATED_METHODS_START
//GENERATED_METHODS_END
//GENERATED_STATIC_METHODS_START
//GENERATED_STATIC_METHODS_END
//CUSTOM_IMPLEMENTATION_START
//CUSTOM_IMPLEMENTATION_END
}
//GENERATED_OUT_OF_CLASS_IMPLEMENTATION_START
//GENERATED_OUT_OF_CLASS_IMPLEMENTATION_END
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_START
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_END
module.exports = Slider;

View File

@ -341,13 +341,13 @@ class Event {
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_START
//GENERATED_EVENTS_START
Event.BEFORE_RENDER = 0x1;
Event.COMPONENT_CREATED = 0x2;
Event.COMPONENT_INITIALIZED = 0x3;
Event.CREATE_INSTANCE_BEFORE = 0x4;
Event.DISPOSE_INSTANCE = 0x5;
Event.DISPOSE_OBJECT = 0x6;
Event.DOM_COMPONENT_INITIALIZED = 0x7;
Event.COMPONENT_CREATED = 0x1;
Event.COMPONENT_INITIALIZED = 0x2;
Event.CREATE_INSTANCE_BEFORE = 0x3;
Event.DISPOSE_INSTANCE = 0x4;
Event.DISPOSE_OBJECT = 0x5;
Event.DOM_COMPONENT_INITIALIZED = 0x6;
Event.ENTITY_INITIALIZED = 0x7;
Event.GET_RUNTIME = 0x8;
Event.GET_WINDOW_SIZE = 0x9;
Event.INPUT_COMPONENT_INITIALIZED = 0xa;
@ -376,13 +376,13 @@ Event.MAX_EVENTS = 0x1f;
Event.GetEventName = function(eventId) {
switch(eventId) {
case 0x1 : return 'before_render';
case 0x2 : return 'component_created';
case 0x3 : return 'component_initialized';
case 0x4 : return 'create_instance_before';
case 0x5 : return 'dispose_instance';
case 0x6 : return 'dispose_object';
case 0x7 : return 'dom_component_initialized';
case 0x1 : return 'component_created';
case 0x2 : return 'component_initialized';
case 0x3 : return 'create_instance_before';
case 0x4 : return 'dispose_instance';
case 0x5 : return 'dispose_object';
case 0x6 : return 'dom_component_initialized';
case 0x7 : return 'entity_initialized';
case 0x8 : return 'get_runtime';
case 0x9 : return 'get_window_size';
case 0xa : return 'input_component_initialized';

View File

@ -1,9 +1,10 @@
class R3 {
static version = '2.0.454';
static compileDate = '2021 Sep 09 - 18:08:03 pm';
static version = '2.0.464';
static compileDate = '2021 Sep 10 - 07:16:56 am';
}
//GENERATED_IMPORTS_START
const Entity = require('./r3-entity/r3-entity.js');
const System = require('./r3-system/r3-system.js');
const Event = require('./r3-event.js');
const Utils = require('./r3-utils.js');
@ -14,6 +15,7 @@ const Project = require('./r3-project.js');
//GENERATED_IMPORTS_END
//GENERATED_DEFINES_START
R3.Entity = Entity;
R3.System = System;
R3.Event = Event;
R3.Utils = Utils;

View File

@ -148,7 +148,7 @@ Runtime.BULLET = 0x9;
Runtime.SOCKET = 0xa;
Runtime.STATISTICS = 0xb;
Runtime.STATS = 0xc;
Runtime.MAX_RUNTIMES = 0xd;
Runtime.MAX_RUNTIME = 0xd;
//GENERATED_OUT_OF_CLASS_IMPLEMENTATION_END
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_START

View File

@ -74,7 +74,7 @@ System.SYSTEM_INPUT = 0x1;
System.SYSTEM_LINKING = 0x2;
System.SYSTEM_RUNTIME = 0x3;
System.SYSTEM_SOCKET = 0x4;
System.MAX_SYSTEMS = 0x5;
System.MAX_SYSTEM = 0x5;
//GENERATED_OUT_OF_CLASS_IMPLEMENTATION_END
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_START

View File

@ -32,11 +32,27 @@ else {
$files = [];
function addFiles($folder, &$newFiles)
{
$files = scandir($folder, SCANDIR_SORT_DESCENDING);
for ($i = 0; $i < sizeof($files); $i++) {
if (preg_match('/index\.js$/', $files[$i])) {
continue;
}
if (preg_match('/\.js$/', $files[$i])) {
array_push($newFiles, $folder . $files[$i]);
}
}
}
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);
$runtimeFiles = scandir('src/r3/r3-runtime', SCANDIR_SORT_DESCENDING);
$newFiles = [];
@ -51,37 +67,15 @@ if ($argv[1] == 'all') {
}
}
for ($i = 0; $i < sizeof($systemFiles); $i++) {
$folders = [
'src/r3/r3-system/',
'src/r3/r3-component/',
'src/r3/r3-runtime/',
'src/r3/r3-entity/'
];
if (preg_match('/index\.js$/', $systemFiles[$i])) {
continue;
}
if (preg_match('/\.js$/', $systemFiles[$i])) {
array_push($newFiles, 'src/r3/r3-system/' . $systemFiles[$i]);
}
}
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]);
}
}
for ($i = 0; $i < sizeof($runtimeFiles); $i++) {
if (preg_match('/index\.js$/', $runtimeFiles[$i])) {
continue;
}
if (preg_match('/\.js$/', $runtimeFiles[$i])) {
array_push($newFiles, 'src/r3/r3-runtime/' . $runtimeFiles[$i]);
}
foreach ($folders as $folder) {
addFiles($folder, $newFiles);
}
$files = $newFiles;

View File

@ -1 +1 @@
2.0.454
2.0.464