test systems start
parent
f6adda0a7b
commit
0d8242a0ec
|
@ -3,4 +3,7 @@ r3 create R3Object extends Event
|
|||
r3 create Utils normal
|
||||
r3 create Component extends R3Object
|
||||
r3 create Project extends R3Object
|
||||
r3 create System normal ./r3-system/
|
||||
r3 create System system-base
|
||||
r3 create Test system
|
||||
r3 create Linking system
|
||||
r3 create Socket system
|
||||
|
|
174
graph.php
174
graph.php
|
@ -7,32 +7,34 @@ class Graph
|
|||
protected $open;
|
||||
protected $closed;
|
||||
public $nodes;
|
||||
public $tempNodes;
|
||||
|
||||
/**
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function __construct(
|
||||
$__initialList
|
||||
$__initialList,
|
||||
$__build = true
|
||||
)
|
||||
{
|
||||
$this->initialList = $__initialList;
|
||||
$this->open = [];
|
||||
/**
|
||||
* Step 2. Create a list called CLOSED initially empty
|
||||
*/
|
||||
$this->closed = [];
|
||||
$this->open = null;
|
||||
$this->closed = null;
|
||||
$this->nodes = [];
|
||||
$this->tempNodes = [];
|
||||
|
||||
/**
|
||||
* Step 1. Create a Search graph
|
||||
*/
|
||||
$this->build();
|
||||
if ($__build) {
|
||||
$this->build();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Node
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
protected function popFirst(&$__list)
|
||||
{
|
||||
/**
|
||||
|
@ -45,6 +47,9 @@ class Graph
|
|||
return array_splice($__list, 0, 1)[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ErrorException
|
||||
*/
|
||||
protected function remove($__name, &$__list)
|
||||
{
|
||||
for ($i = 0; $i < sizeof($__list); $i++) {
|
||||
|
@ -69,15 +74,17 @@ class Graph
|
|||
return $nodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 6. Expand $node by generating a set M of successors that are not already ancestors of
|
||||
* $node in G. Install them into G.
|
||||
*/
|
||||
protected function expand($node)
|
||||
{
|
||||
|
||||
if ($node->name === 'R3') {
|
||||
$children = $this->removeAll(null, $this->initialList);
|
||||
} else {
|
||||
$children = $this->removeAll($node->name, $this->initialList);
|
||||
}
|
||||
|
||||
return $children;
|
||||
}
|
||||
|
||||
|
@ -98,7 +105,7 @@ class Graph
|
|||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function processOpen()
|
||||
protected function processOpen($searchMode = false, $property = null, $value = null)
|
||||
{
|
||||
/**
|
||||
* Step 3. If OPEN is empty - throw Exception (we are actually done)
|
||||
|
@ -114,24 +121,39 @@ class Graph
|
|||
* Step 5. If $node is a GOAL node - we are done - we skip this step because we are done
|
||||
* only when $this->initialList / $this->open is empty
|
||||
*/
|
||||
if ($searchMode) {
|
||||
|
||||
if ($property === null) {
|
||||
throw new ErrorException('Search mode cannot be true without a property specified');
|
||||
}
|
||||
|
||||
if ($node->$property === $value) {
|
||||
return $node;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 6. Expand $node by generating a set M of successors that are not already ancestors of
|
||||
* $node in G. Install them into G.
|
||||
*
|
||||
* We skip 6. and 7. a) when in search mode, because we already have children linked to parents
|
||||
*/
|
||||
$successors = $this->expand($node);
|
||||
if (!$searchMode) {
|
||||
|
||||
$node->children = $successors;
|
||||
$successors = $this->expand($node);
|
||||
|
||||
/**
|
||||
* Step 7. a) Establish a link from each successor to its parent
|
||||
*/
|
||||
$this->linkToParent($node);
|
||||
$node->children = $successors;
|
||||
|
||||
/**
|
||||
* Step 7. a) Establish a link from each successor to its parent
|
||||
*/
|
||||
$this->linkToParent($node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 7. b) Add all successors to OPEN
|
||||
*/
|
||||
$this->pushToList($this->open, $successors);
|
||||
$this->pushToList($this->open, $node->children);
|
||||
|
||||
/**
|
||||
* Step 8. We skip this because we do not do any re-ordering on the graph
|
||||
|
@ -140,10 +162,48 @@ class Graph
|
|||
/**
|
||||
* Step 9. Go back to Step 3
|
||||
*/
|
||||
$this->processOpen();
|
||||
return $this->processOpen($searchMode, $property, $value);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $property
|
||||
* @param $value
|
||||
* @return Node | null
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function search($property, $value)
|
||||
{
|
||||
if (sizeof($this->nodes) <= 0) {
|
||||
throw new ErrorException('This graph is not built yet');
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 1. Create a Search graph containing only the start node - put it on a list called OPEN
|
||||
*/
|
||||
$startNode = $this->nodes[0];
|
||||
|
||||
array_push($this->tempNodes, $startNode);
|
||||
|
||||
$this->open = [];
|
||||
|
||||
array_push($this->open, $startNode);
|
||||
|
||||
/**
|
||||
* Step 2. Create a list called CLOSED initially empty
|
||||
*/
|
||||
$this->closed = [];
|
||||
|
||||
try {
|
||||
/**
|
||||
* Step 3. If OPEN is empty - we could not find the node
|
||||
*/
|
||||
return $this->processOpen(true, $property, $value);
|
||||
} catch (Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ErrorException
|
||||
*/
|
||||
|
@ -160,8 +220,15 @@ class Graph
|
|||
|
||||
array_push($this->nodes, $startNode);
|
||||
|
||||
$this->open = [];
|
||||
|
||||
array_push($this->open, $startNode);
|
||||
|
||||
/**
|
||||
* Step 2. Create a list called CLOSED initially empty
|
||||
*/
|
||||
$this->closed = [];
|
||||
|
||||
try {
|
||||
/**
|
||||
* Step 3. If OPEN is empty - throw Exception (we are actually done)
|
||||
|
@ -171,75 +238,6 @@ class Graph
|
|||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
// public function createNode($file, $className, $extendClass = null) {
|
||||
//
|
||||
// $node = new Node($file, $className);
|
||||
//
|
||||
// if ($extendClass) {
|
||||
// $parent = new Node('', $extendClass);
|
||||
// array_push($node['parents'], $parent);
|
||||
// }
|
||||
//
|
||||
// return $node;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @throws ErrorException
|
||||
// */
|
||||
// public function addNode($file, $className, $extendClassName)
|
||||
// {
|
||||
// if ($className === null) {
|
||||
// throw new ErrorException("classname cannot be null");
|
||||
// }
|
||||
//
|
||||
// echo "size of graph is " . sizeof($this->nodes) . "\n";
|
||||
//
|
||||
// $node = $this->createNode($file, $className, $extendClassName);
|
||||
//
|
||||
// array_push($this->nodes, $node);
|
||||
// }
|
||||
//
|
||||
// public function sort()
|
||||
// {
|
||||
//
|
||||
// echo "sorting graph";
|
||||
//
|
||||
// $baseClasses = [];
|
||||
//
|
||||
// $extendClasses = [];
|
||||
//
|
||||
// foreach ($this->nodes as $node) {
|
||||
//
|
||||
// if ($node['name'] === 'R3') {
|
||||
//
|
||||
// // skip R3 - it is the main parent of everything
|
||||
//
|
||||
// array_push($newGraph, $node);
|
||||
//
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// if (sizeof($node['parents']) === 0) {
|
||||
// array_push($baseClasses, $node);
|
||||
// } else {
|
||||
// array_push($extendClasses, $node);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// foreach ($baseClasses as $baseClass) {
|
||||
// array_push($baseClass['parents'], $newGraph[0]);
|
||||
// array_push($newGraph[0]['children'], $baseClass);
|
||||
// }
|
||||
//
|
||||
// foreach ($extendClasses as $extendClass) {
|
||||
//
|
||||
// findRecursive($extendClass['name'], $newGraph);
|
||||
//
|
||||
//
|
||||
//
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
class Node
|
||||
|
|
|
@ -5,6 +5,36 @@ const R3Object = require('r3-r3-object.js');
|
|||
/**
|
||||
|
||||
GENERATE_INHERITED_START
|
||||
|
||||
Inherited from Event
|
||||
|
||||
Properties:
|
||||
|
||||
test
|
||||
|
||||
Methods:
|
||||
|
||||
test
|
||||
|
||||
Static Methods:
|
||||
|
||||
test
|
||||
|
||||
|
||||
Inherited from R3Object
|
||||
|
||||
Properties:
|
||||
|
||||
test
|
||||
|
||||
Methods:
|
||||
|
||||
test
|
||||
|
||||
Static Methods:
|
||||
|
||||
test
|
||||
|
||||
GENERATE_INHERITED_END
|
||||
|
||||
Of the form x=<value>
|
||||
|
|
|
@ -5,6 +5,36 @@ const R3Object = require('r3-r3-object.js');
|
|||
/**
|
||||
|
||||
GENERATE_INHERITED_START
|
||||
|
||||
Inherited from Event
|
||||
|
||||
Properties:
|
||||
|
||||
test
|
||||
|
||||
Methods:
|
||||
|
||||
test
|
||||
|
||||
Static Methods:
|
||||
|
||||
test
|
||||
|
||||
|
||||
Inherited from R3Object
|
||||
|
||||
Properties:
|
||||
|
||||
test
|
||||
|
||||
Methods:
|
||||
|
||||
test
|
||||
|
||||
Static Methods:
|
||||
|
||||
test
|
||||
|
||||
GENERATE_INHERITED_END
|
||||
|
||||
Of the form x=<value>
|
||||
|
|
|
@ -4,6 +4,21 @@ const Event = require('r3-event.js');
|
|||
/**
|
||||
|
||||
GENERATE_INHERITED_START
|
||||
|
||||
Inherited from Event
|
||||
|
||||
Properties:
|
||||
|
||||
test
|
||||
|
||||
Methods:
|
||||
|
||||
test
|
||||
|
||||
Static Methods:
|
||||
|
||||
test
|
||||
|
||||
GENERATE_INHERITED_END
|
||||
|
||||
Of the form x=<value>
|
||||
|
|
|
@ -1,28 +1,60 @@
|
|||
const System = require('./r3-system');
|
||||
const R3Object = require('../r3-r3-object');
|
||||
const Event = require('../r3-event');
|
||||
const Event = require('.././r3-event');
|
||||
const Utils = require('.././r3-utils');
|
||||
const System = require('./r3-system.js');
|
||||
|
||||
class LinkingSystem extends System {
|
||||
/**
|
||||
|
||||
static start() {
|
||||
GENERATE_INHERITED_START
|
||||
GENERATE_INHERITED_END
|
||||
|
||||
super.start();
|
||||
|
||||
console.log('starting linking system');
|
||||
CUSTOM_OPTIONS_START
|
||||
CUSTOM_OPTIONS_END
|
||||
|
||||
Event.Subscribe(
|
||||
Event.OBJECT_CREATED,
|
||||
() => {
|
||||
console.log('linking system discovered an object');
|
||||
}
|
||||
);
|
||||
CUSTOM_EVENT_LISTENERS_START
|
||||
CUSTOM_EVENT_LISTENERS_END
|
||||
|
||||
let object = new R3Object();
|
||||
**/
|
||||
|
||||
return true;
|
||||
class SystemLinking extends System {
|
||||
|
||||
}
|
||||
//GENERATE_CONSTRUCTOR_EXTENDS_START
|
||||
constructor(options) {
|
||||
|
||||
if (Utils.UndefinedOrNull(options)) {
|
||||
options = {};
|
||||
}
|
||||
|
||||
super(options);
|
||||
|
||||
this.emit(Event.OBJECT_CREATED, this);
|
||||
|
||||
//GENERATE_OPTIONS_INIT_START
|
||||
//GENERATE_OPTIONS_INIT_END
|
||||
|
||||
//CUSTOM_OPTIONS_INIT_START
|
||||
//CUSTOM_OPTIONS_INIT_END
|
||||
|
||||
Object.assign(this, options);
|
||||
|
||||
//CUSTOM_BEFORE_INIT_START
|
||||
//CUSTOM_BEFORE_INIT_END
|
||||
|
||||
this.emit(Event.OBJECT_INITIALIZED, this);
|
||||
|
||||
//CUSTOM_AFTER_INIT_START
|
||||
//CUSTOM_AFTER_INIT_END
|
||||
}
|
||||
//GENERATE_CONSTRUCTOR_EXTENDS_END
|
||||
|
||||
//GENERATE_EVENT_LISTENERS_START
|
||||
//GENERATE_EVENT_LISTENERS_END
|
||||
|
||||
//CUSTOM_IMPLEMENTATION_START
|
||||
//CUSTOM_IMPLEMENTATION_END
|
||||
|
||||
}
|
||||
|
||||
module.exports = LinkingSystem;
|
||||
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_START
|
||||
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_END
|
||||
|
||||
module.exports = SystemLinking;
|
|
@ -1,17 +1,60 @@
|
|||
const Event = require('.././r3-event');
|
||||
const Utils = require('.././r3-utils');
|
||||
const System = require('./r3-system.js');
|
||||
|
||||
class SocketSystem extends System {
|
||||
/**
|
||||
|
||||
static start() {
|
||||
GENERATE_INHERITED_START
|
||||
GENERATE_INHERITED_END
|
||||
|
||||
super.start();
|
||||
|
||||
console.log('starting socket system');
|
||||
CUSTOM_OPTIONS_START
|
||||
CUSTOM_OPTIONS_END
|
||||
|
||||
return true;
|
||||
CUSTOM_EVENT_LISTENERS_START
|
||||
CUSTOM_EVENT_LISTENERS_END
|
||||
|
||||
}
|
||||
**/
|
||||
|
||||
class SystemSocket extends System {
|
||||
|
||||
//GENERATE_CONSTRUCTOR_EXTENDS_START
|
||||
constructor(options) {
|
||||
|
||||
if (Utils.UndefinedOrNull(options)) {
|
||||
options = {};
|
||||
}
|
||||
|
||||
super(options);
|
||||
|
||||
this.emit(Event.OBJECT_CREATED, this);
|
||||
|
||||
//GENERATE_OPTIONS_INIT_START
|
||||
//GENERATE_OPTIONS_INIT_END
|
||||
|
||||
//CUSTOM_OPTIONS_INIT_START
|
||||
//CUSTOM_OPTIONS_INIT_END
|
||||
|
||||
Object.assign(this, options);
|
||||
|
||||
//CUSTOM_BEFORE_INIT_START
|
||||
//CUSTOM_BEFORE_INIT_END
|
||||
|
||||
this.emit(Event.OBJECT_INITIALIZED, this);
|
||||
|
||||
//CUSTOM_AFTER_INIT_START
|
||||
//CUSTOM_AFTER_INIT_END
|
||||
}
|
||||
//GENERATE_CONSTRUCTOR_EXTENDS_END
|
||||
|
||||
//GENERATE_EVENT_LISTENERS_START
|
||||
//GENERATE_EVENT_LISTENERS_END
|
||||
|
||||
//CUSTOM_IMPLEMENTATION_START
|
||||
//CUSTOM_IMPLEMENTATION_END
|
||||
|
||||
}
|
||||
|
||||
module.exports = SocketSystem;
|
||||
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_START
|
||||
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_END
|
||||
|
||||
module.exports = SystemSocket;
|
|
@ -0,0 +1,60 @@
|
|||
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
|
||||
|
||||
**/
|
||||
|
||||
class SystemTest extends System {
|
||||
|
||||
//GENERATE_CONSTRUCTOR_EXTENDS_START
|
||||
constructor(options) {
|
||||
|
||||
if (Utils.UndefinedOrNull(options)) {
|
||||
options = {};
|
||||
}
|
||||
|
||||
super(options);
|
||||
|
||||
this.emit(Event.OBJECT_CREATED, this);
|
||||
|
||||
//GENERATE_OPTIONS_INIT_START
|
||||
//GENERATE_OPTIONS_INIT_END
|
||||
|
||||
//CUSTOM_OPTIONS_INIT_START
|
||||
//CUSTOM_OPTIONS_INIT_END
|
||||
|
||||
Object.assign(this, options);
|
||||
|
||||
//CUSTOM_BEFORE_INIT_START
|
||||
//CUSTOM_BEFORE_INIT_END
|
||||
|
||||
this.emit(Event.OBJECT_INITIALIZED, this);
|
||||
|
||||
//CUSTOM_AFTER_INIT_START
|
||||
//CUSTOM_AFTER_INIT_END
|
||||
}
|
||||
//GENERATE_CONSTRUCTOR_EXTENDS_END
|
||||
|
||||
//GENERATE_EVENT_LISTENERS_START
|
||||
//GENERATE_EVENT_LISTENERS_END
|
||||
|
||||
//CUSTOM_IMPLEMENTATION_START
|
||||
//CUSTOM_IMPLEMENTATION_END
|
||||
|
||||
}
|
||||
|
||||
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_START
|
||||
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_END
|
||||
|
||||
module.exports = SystemTest;
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
Inherited from CLASS_NAME
|
||||
|
||||
Properties:
|
||||
|
||||
PROPERTY_LIST
|
||||
|
||||
Methods:
|
||||
|
||||
METHOD_LIST
|
||||
|
||||
Static Methods:
|
||||
|
||||
STATIC_METHOD_LIST
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
const Event = require('INCLUDE_PATH/r3-event');
|
||||
const Utils = require('INCLUDE_PATH/r3-utils');
|
||||
|
||||
/**
|
||||
|
||||
CUSTOM_OPTIONS_START
|
||||
CUSTOM_OPTIONS_END
|
||||
|
||||
CUSTOM_METHODS_START
|
||||
CUSTOM_METHODS_END
|
||||
|
||||
CUSTOM_STATIC_METHODS_START
|
||||
CUSTOM_STATIC_METHODS_END
|
||||
|
||||
**/
|
||||
|
||||
class CLASS_NAME {
|
||||
|
||||
//GENERATE_CONSTRUCTOR_START
|
||||
//GENERATE_CONSTRUCTOR_END
|
||||
|
||||
//CUSTOM_IMPLEMENTATION_START
|
||||
//CUSTOM_IMPLEMENTATION_END
|
||||
|
||||
//GENERATE_METHODS_START
|
||||
//GENERATE_METHODS_END
|
||||
|
||||
//GENERATE_STATIC_METHODS_START
|
||||
//GENERATE_STATIC_METHODS_END
|
||||
|
||||
}
|
||||
|
||||
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_START
|
||||
//CUSTOM_OUT_OF_CLASS_IMPLEMENTATION_END
|
||||
|
||||
module.exports = CLASS_NAME;
|
|
@ -1,6 +1,6 @@
|
|||
const Event = require('INCLUDE_PATH/r3-event');
|
||||
const Utils = require('INCLUDE_PATH/r3-utils');
|
||||
const EXTEND_CLASS = require('EXTEND_CLASS_FILE_NAME');
|
||||
const EXTEND_CLASS = require('./EXTEND_CLASS_FILE_NAME');
|
||||
|
||||
/**
|
||||
|
||||
|
|
|
@ -224,6 +224,72 @@ function updateSection($file, $token, $updates, $separator = "") {
|
|||
return true;
|
||||
}
|
||||
|
||||
function doGetInheritedTemplateUpdates($node, $restoreTokens)
|
||||
{
|
||||
try {
|
||||
$tokens = loadSaved($node->file, $restoreTokens);
|
||||
} catch (ErrorException $e) {
|
||||
echo $e->getMessage();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$updates = '';
|
||||
|
||||
if ($node->parent !== null && $node->parent->name !== "R3") {
|
||||
$updates = doGetInheritedTemplateUpdates($node->parent, $restoreTokens);
|
||||
}
|
||||
|
||||
$template = file_get_contents('src/templates/generate_inherited.template');
|
||||
|
||||
$CLASS_NAME = $node->name;
|
||||
$PROPERTY_LIST = 'test';
|
||||
$METHOD_LIST = 'test';
|
||||
$STATIC_METHOD_LIST = 'test';
|
||||
|
||||
$updated = str_replace('CLASS_NAME', $CLASS_NAME, $template);
|
||||
$updated = str_replace('PROPERTY_LIST', $PROPERTY_LIST, $updated);
|
||||
$updated = str_replace('STATIC_METHOD_LIST', $STATIC_METHOD_LIST, $updated);
|
||||
$updated = str_replace('METHOD_LIST', $METHOD_LIST, $updated);
|
||||
$updates .= $updated;
|
||||
|
||||
return $updates;
|
||||
}
|
||||
|
||||
function generateInherited($file, $restoreTokens)
|
||||
{
|
||||
|
||||
echo "Generating inherited fields for $file\n";
|
||||
|
||||
global $graph;
|
||||
|
||||
$node = $graph->search('file', $file);
|
||||
|
||||
if ($node === null) {
|
||||
/**
|
||||
* This node is not part of R3
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
if ($node->parent === null) {
|
||||
/**
|
||||
* This node has no inherited properties
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
if ($node->parent->name === 'R3') {
|
||||
/**
|
||||
* This is a base class
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
$updates = doGetInheritedTemplateUpdates($node->parent, $restoreTokens);
|
||||
|
||||
updateSection($file, 'GENERATE_INHERITED' , $updates);
|
||||
}
|
||||
|
||||
function generateInitOptions($file, $tokens)
|
||||
{
|
||||
$token = 'CUSTOM_OPTIONS';
|
||||
|
@ -445,6 +511,8 @@ function doMethodUpdate($template, $tokens, $token)
|
|||
$args = "\n\t\t" . $args . "\n\t";
|
||||
$params = implode("\n\t * @param ", $argsArray);
|
||||
$params = "@param " . $params;
|
||||
} else {
|
||||
$params = "\n\t * @param " . $params;
|
||||
}
|
||||
|
||||
$result = preg_match('/.*?\).*?(\w.*$)/', $item, $matches);
|
||||
|
@ -526,7 +594,7 @@ $nodeList = [];
|
|||
/**
|
||||
* @throws ErrorException
|
||||
*/
|
||||
function buildGraph($file)
|
||||
function buildNodeList($file)
|
||||
{
|
||||
echo "loading file $file\n";
|
||||
|
||||
|
@ -618,7 +686,12 @@ foreach ($files as $file) {
|
|||
|
||||
$restoreTokenKeys = array_keys($restoreTokens);
|
||||
|
||||
$tokens = loadSaved($file, $restoreTokens);
|
||||
try {
|
||||
$tokens = loadSaved($file, $restoreTokens);
|
||||
} catch (ErrorException $e) {
|
||||
echo $e->getMessage();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$skipped = [];
|
||||
|
||||
|
@ -664,20 +737,51 @@ foreach ($files as $file) {
|
|||
echo "If you do not do it now - on the next template update code will be overwritten and you could lose code!!!\n";
|
||||
exit(1);
|
||||
} else {
|
||||
deleteSavedFile($saveFile);
|
||||
// deleteSavedFile($saveFile);
|
||||
exit(0);
|
||||
}
|
||||
} else if ($argv[2] == 'build-graph') {
|
||||
buildGraph($file);
|
||||
buildNodeList($file);
|
||||
}
|
||||
}
|
||||
|
||||
if ($argv[2] == 'build-graph') {
|
||||
|
||||
global $nodeList;
|
||||
|
||||
/**
|
||||
* Now generate the graph based on the new classes
|
||||
*/
|
||||
$graph = new Graph(
|
||||
$nodeList
|
||||
);
|
||||
|
||||
$restoreTokens = getTokens('CUSTOM');
|
||||
|
||||
$restoreTokenKeys = array_keys($restoreTokens);
|
||||
|
||||
/**
|
||||
* Now start processing the files again - this time generating linked objects / inherited properties / methods
|
||||
*/
|
||||
foreach ($files as $file) {
|
||||
|
||||
$saveFile = $file . '.saved';
|
||||
|
||||
generateInherited($file, $restoreTokens);
|
||||
|
||||
}
|
||||
|
||||
foreach ($files as $file) {
|
||||
|
||||
$saveFile = $file . '.saved';
|
||||
|
||||
deleteSavedFile($saveFile);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
exit(0);
|
||||
|
||||
?>
|
44
utils.php
44
utils.php
|
@ -1,36 +1,46 @@
|
|||
<?php
|
||||
|
||||
if (isset($argc)) {
|
||||
for ($i = 0; $i < $argc; $i++) {
|
||||
echo "Argument #" . $i . " - " . $argv[$i] . "\n";
|
||||
}
|
||||
for ($i = 0; $i < $argc; $i++) {
|
||||
echo "Argument #" . $i . " - " . $argv[$i] . "\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo "argc and argv disabled\n";
|
||||
echo "argc and argv disabled\n";
|
||||
}
|
||||
|
||||
$files = [];
|
||||
|
||||
if ($argv[1] == 'all') {
|
||||
$files = scandir('src/r3/', SCANDIR_SORT_DESCENDING);
|
||||
$systemFiles = scandir('src/r3/r3-system', SCANDIR_SORT_DESCENDING);
|
||||
$files = scandir('src/r3/', SCANDIR_SORT_DESCENDING);
|
||||
$systemFiles = scandir('src/r3/r3-system', SCANDIR_SORT_DESCENDING);
|
||||
|
||||
$newFiles = [];
|
||||
$newFiles = [];
|
||||
|
||||
for ($i = 0; $i < sizeof($files); $i++) {
|
||||
if (preg_match('/\.js$/', $files[$i])) {
|
||||
array_push($newFiles, 'src/r3/' . $files[$i]);
|
||||
}
|
||||
for ($i = 0; $i < sizeof($files); $i++) {
|
||||
|
||||
if (preg_match('/index\.js$/', $files[$i])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for ($i = 0; $i < sizeof($systemFiles); $i++) {
|
||||
if (preg_match('/\.js$/', $systemFiles[$i])) {
|
||||
array_push($newFiles, 'src/r3/r3-system/' . $systemFiles[$i]);
|
||||
}
|
||||
if (preg_match('/\.js$/', $files[$i])) {
|
||||
array_push($newFiles, 'src/r3/' . $files[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = 0; $i < sizeof($systemFiles); $i++) {
|
||||
|
||||
if (preg_match('/index\.js$/', $files[$i])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$files = $newFiles;
|
||||
if (preg_match('/\.js$/', $systemFiles[$i])) {
|
||||
array_push($newFiles, 'src/r3/r3-system/' . $systemFiles[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
$files = $newFiles;
|
||||
|
||||
} else {
|
||||
$files = [$argv[1]];
|
||||
$files = [$argv[1]];
|
||||
}
|
Loading…
Reference in New Issue