build events
parent
fd04d04973
commit
35b14a6550
|
@ -3,7 +3,8 @@ FROM alpine:3.14
|
|||
WORKDIR "/app"
|
||||
|
||||
RUN apk add --no-cache nodejs && \
|
||||
apk add --update npm
|
||||
apk add --update npm && \
|
||||
apk add php
|
||||
|
||||
#COPY gulpfile.js .
|
||||
#COPY webpack.config.js .
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
#!/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);
|
||||
|
||||
?>
|
|
@ -168,7 +168,34 @@ class Event {
|
|||
}
|
||||
|
||||
//EVENT_GENERATED_START
|
||||
Event.OBJECT_CREATED = 0x1;
|
||||
Event.CREATE_INSTANCE = 0x1;
|
||||
Event.GET_RUNTIME = 0x2;
|
||||
Event.GET_WINDOW_SIZE = 0x3;
|
||||
Event.INSTANCE_CREATED = 0x4;
|
||||
Event.OBJECT_CREATED = 0x5;
|
||||
Event.OBJECT_INITIALIZED = 0x6;
|
||||
Event.PAUSE = 0x7;
|
||||
Event.RESTART = 0x8;
|
||||
Event.START = 0x9;
|
||||
Event.MAX_EVENTS = 0xa;
|
||||
|
||||
Event.GetEventName = function(eventId) {
|
||||
|
||||
switch(eventId) {
|
||||
case 0x1 : return 'create_instance';
|
||||
case 0x2 : return 'get_runtime';
|
||||
case 0x3 : return 'get_window_size';
|
||||
case 0x4 : return 'instance_created';
|
||||
case 0x5 : return 'object_created';
|
||||
case 0x6 : return 'object_initialized';
|
||||
case 0x7 : return 'pause';
|
||||
case 0x8 : return 'restart';
|
||||
case 0x9 : return 'start';
|
||||
default :
|
||||
throw new Error('Event type not defined : ' + eventId);
|
||||
}
|
||||
|
||||
};
|
||||
//EVENT_GENERATED_END
|
||||
|
||||
module.exports = Event;
|
||||
|
|
|
@ -7,7 +7,7 @@ class R3 {
|
|||
}
|
||||
|
||||
static version() {
|
||||
return 'Fri Jun 18 2021 11:52:07 GMT+0000 (Coordinated Universal Time)';
|
||||
return 'Fri Jun 18 2021 12:28:24 GMT+0000 (Coordinated Universal Time)';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -168,7 +168,34 @@ class Event {
|
|||
}
|
||||
|
||||
//EVENT_GENERATED_START
|
||||
Event.OBJECT_CREATED = 0x1;
|
||||
Event.CREATE_INSTANCE = 0x1;
|
||||
Event.GET_RUNTIME = 0x2;
|
||||
Event.GET_WINDOW_SIZE = 0x3;
|
||||
Event.INSTANCE_CREATED = 0x4;
|
||||
Event.OBJECT_CREATED = 0x5;
|
||||
Event.OBJECT_INITIALIZED = 0x6;
|
||||
Event.PAUSE = 0x7;
|
||||
Event.RESTART = 0x8;
|
||||
Event.START = 0x9;
|
||||
Event.MAX_EVENTS = 0xa;
|
||||
|
||||
Event.GetEventName = function(eventId) {
|
||||
|
||||
switch(eventId) {
|
||||
case 0x1 : return 'create_instance';
|
||||
case 0x2 : return 'get_runtime';
|
||||
case 0x3 : return 'get_window_size';
|
||||
case 0x4 : return 'instance_created';
|
||||
case 0x5 : return 'object_created';
|
||||
case 0x6 : return 'object_initialized';
|
||||
case 0x7 : return 'pause';
|
||||
case 0x8 : return 'restart';
|
||||
case 0x9 : return 'start';
|
||||
default :
|
||||
throw new Error('Event type not defined : ' + eventId);
|
||||
}
|
||||
|
||||
};
|
||||
//EVENT_GENERATED_END
|
||||
|
||||
module.exports = Event;
|
||||
|
|
Loading…
Reference in New Issue