diff --git a/.gitignore b/.gitignore index 0b6684f..1e49baa 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,6 @@ /outputs /godot-rj-nuget-package /godot/modules/rokojori_action_library +/rokojori-cpp-generator/node_modules diff --git a/copy-cpp-source.js b/_old-js/copy-cpp-source.js similarity index 100% rename from copy-cpp-source.js rename to _old-js/copy-cpp-source.js diff --git a/cpp-class-member.js b/_old-js/cpp-class-member.js similarity index 98% rename from cpp-class-member.js rename to _old-js/cpp-class-member.js index b736e3c..24bfac6 100644 --- a/cpp-class-member.js +++ b/_old-js/cpp-class-member.js @@ -14,9 +14,12 @@ class CppClassMember type = "void"; initialValue = null; parameters = []; + accessModifier; - constructor( nameDefinition, body ) + constructor( accessModifier, nameDefinition, body ) { + this.accessModifier = accessModifier; + if ( nameDefinition.indexOf( "()" ) != -1) { this.isMethod = true; diff --git a/create-cpp.js b/_old-js/create-cpp.js similarity index 88% rename from create-cpp.js rename to _old-js/create-cpp.js index ebaab3b..fc1e086 100644 --- a/create-cpp.js +++ b/_old-js/create-cpp.js @@ -156,7 +156,7 @@ async function main() -function grabMembers( membersData ) +function grabMembers( membersData, accessModifier ) { let members = []; @@ -187,13 +187,14 @@ function grabMembers( membersData ) let actionGetter = `virtual get_${actionName}():Ref`; let actionSetter = `virtual set_${actionName}()`; - members.push( new CppClassMember( signal, {} ) ); - members.push( new CppClassMember( actionGetter, {} ) ); - members.push( new CppClassMember( actionSetter, { "action":"Ref"} ) ); + members.push( new CppClassMember( accessModifier, signal, {} ) ); + members.push( new CppClassMember( "protected", "m_" + name, {} ) ); + members.push( new CppClassMember( accessModifier, actionGetter, {} ) ); + members.push( new CppClassMember( accessModifier, actionSetter, { "action":"Ref"} ) ); } else { - let classMember = new CppClassMember( nameDefinition, memberData ); + let classMember = new CppClassMember( accessModifier, nameDefinition, memberData ); members.push( classMember ); } @@ -278,8 +279,21 @@ async function createCppFiles( definitionPath, types, missingTypes ) let headerDefine = getHeaderDefine( className ); - let protectedMembers = grabMembers( data.protected ); - let publicMembers = grabMembers( data.public ); + let fromProtectedMembers = grabMembers( data.protected, "protected" ); + let fromPublicMembers = grabMembers( data.public, "public" ); + + let protectedMembers = []; + let publicMembers = []; + + let insertMember = m => + { + let container = m.accessModifier === "public" ? publicMembers : protectedMembers; + container.push( m ); + }; + + fromProtectedMembers.forEach( m => insertMember( m ) ); + fromPublicMembers.forEach( m => insertMember( m ) ); + let allMembers = [].concat( protectedMembers ).concat( publicMembers ); diff --git a/create-output.js b/_old-js/create-output.js similarity index 100% rename from create-output.js rename to _old-js/create-output.js diff --git a/library.js b/_old-js/library.js similarity index 100% rename from library.js rename to _old-js/library.js diff --git a/build-steps/build-steps-windows.txt b/build-steps/build-steps-windows.txt index e80acaa..712b5ff 100644 --- a/build-steps/build-steps-windows.txt +++ b/build-steps/build-steps-windows.txt @@ -5,8 +5,9 @@ ================================================ [ Copy C++] -cd {ROOT-PATH} -node copy-cpp-source.js +cd {CPP-GEN-PATH} +npm run create-cpp +npm run copy-cpp-source [ Build C++ ] cd {GODOT-EDITOR-PATH} diff --git a/rokojori-action-library b/rokojori-action-library index 650c341..29c6666 160000 --- a/rokojori-action-library +++ b/rokojori-action-library @@ -1 +1 @@ -Subproject commit 650c34164ae6a39bdce2d748888092c660a1ebd6 +Subproject commit 29c6666c18a64e93fb302ee49538b8881d54d30f diff --git a/rokojori-action-library-definitions/RJTimeLine.json b/rokojori-action-library-definitions/RJTimeLine.json index 602233a..b97bdf9 100644 --- a/rokojori-action-library-definitions/RJTimeLine.json +++ b/rokojori-action-library-definitions/RJTimeLine.json @@ -1,6 +1,7 @@ { "class":"RJTimeLine:Resource", + "public": { "isLooping": false, diff --git a/rokojori-action-library-definitions/RJTimeLineManager.json b/rokojori-action-library-definitions/RJTimeLineManager.json index 826b95b..c4c489c 100644 --- a/rokojori-action-library-definitions/RJTimeLineManager.json +++ b/rokojori-action-library-definitions/RJTimeLineManager.json @@ -5,23 +5,23 @@ "public": { - "virtual getTimeLineIndex():int" : { "timeLine":"Ref" }, - "virtual getTimeLineSize():int" : {}, + "getTimeLineIndex():int" : { "timeLine":"Ref" }, + "getTimeLineSize():int" : {}, - "virtual createID():int" : {}, + "createID():int" : {}, - "virtual getLastPosition():double" : { "timeLineIndex":"int" }, + "getLastPosition():double" : { "timeLineIndex":"int" }, - "virtual getPosition():double" : { "timeLineIndex":"int" }, - "virtual setPosition()" : { "timeLineIndex":"int", "position":"double" }, + "getPosition():double" : { "timeLineIndex":"int" }, + "setPosition()" : { "timeLineIndex":"int", "position":"double" }, - "virtual getSpeed():double" : { "timeLineIndex":"int" }, - "virtual setSpeed()" : { "timeLineIndex":"int", "speed":"double" }, + "getSpeed():double" : { "timeLineIndex":"int" }, + "setSpeed()" : { "timeLineIndex":"int", "speed":"double" }, - "virtual getPlayState():bool" : { "timeLineIndex":"int" }, - "virtual setPlayState()" : { "timeLineIndex":"int", "playState":"bool" }, + "getPlayState():bool" : { "timeLineIndex":"int" }, + "setPlayState()" : { "timeLineIndex":"int", "playState":"bool" }, - "virtual scheduleEvent()" : + "scheduleEvent()" : { "timeLineIndex": "int", "position": "double", @@ -29,7 +29,7 @@ "isPersistent": "bool" }, - "virtual scheduleSpan()" : + "scheduleSpan()" : { "timeLineIndex": "int", "startPosition": "double", diff --git a/rokojori-action-library-definitions/RJUpdatable.json b/rokojori-action-library-definitions/RJUpdatable.json index 01ce60d..55bde24 100644 --- a/rokojori-action-library-definitions/RJUpdatable.json +++ b/rokojori-action-library-definitions/RJUpdatable.json @@ -3,6 +3,6 @@ "public": { - "virtual update()":{ "delta":"double" } + "update()":{ "delta":"double" } } } \ No newline at end of file diff --git a/rokojori-action-library-definitions/RJVirtualCamera3D.json b/rokojori-action-library-definitions/RJVirtualCamera3D.json index 9a4e75e..7472fbd 100644 --- a/rokojori-action-library-definitions/RJVirtualCamera3D.json +++ b/rokojori-action-library-definitions/RJVirtualCamera3D.json @@ -3,8 +3,8 @@ "public": { - "virtual getCameraPosition()": "Vector3", - "virtual getCameraRotation()": "Quaternion", - "virtual getCameraFOV()":"float" + "getCameraPosition()": "Vector3", + "getCameraRotation()": "Quaternion", + "getCameraFOV()":"float" } } \ No newline at end of file diff --git a/rokojori-action-library-definitions/RJVirtualCamera3DManager.json b/rokojori-action-library-definitions/RJVirtualCamera3DManager.json index 10d9ea3..23ebdd6 100644 --- a/rokojori-action-library-definitions/RJVirtualCamera3DManager.json +++ b/rokojori-action-library-definitions/RJVirtualCamera3DManager.json @@ -5,12 +5,12 @@ "public": { - "virtual getCamera():Ref" : { "cameraIndex": "int" }, - "virtual getCameraIndex():int" : { "timeLine":"Ref" }, - "virtual getCameraSize():int" : {}, + "getCamera():Ref" : { "cameraIndex": "int" }, + "getCameraIndex():int" : { "timeLine":"Ref" }, + "getCameraSize():int" : {}, - "virtual getCameraPriority():float" : { "cameraIndex":"int" }, - "virtual setCameraPriority()" : { "cameraIndex":"int", "priority":"float" }, + "getCameraPriority():float" : { "cameraIndex":"int" }, + "setCameraPriority()" : { "cameraIndex":"int", "priority":"float" }, "cameraPrioritySmoothingCoefficient": 0.5, "cameraPrioritySmoothingStepFPS": 120 diff --git a/rokojori-action-library-definitions/_RJSequenceAction.json b/rokojori-action-library-definitions/_RJSequenceAction.json index c456e5c..92265a8 100644 --- a/rokojori-action-library-definitions/_RJSequenceAction.json +++ b/rokojori-action-library-definitions/_RJSequenceAction.json @@ -3,9 +3,9 @@ "public": { - "virtual dispatchStart():int" : {}, - "virtual dispatchCancel()": { "id":"int" }, - "virtual dispatchEnd()" : { "id":"int" }, + "dispatchStart():int" : {}, + "dispatchCancel()": { "id":"int" }, + "dispatchEnd()" : { "id":"int" }, "signal onSequenceDone()" : { "id":"int" } } } \ No newline at end of file diff --git a/rokojori-action-library-definitions/__Example.json b/rokojori-action-library-definitions/__Example.json new file mode 100644 index 0000000..e6e93b7 --- /dev/null +++ b/rokojori-action-library-definitions/__Example.json @@ -0,0 +1,99 @@ +{ + // Define ClassName and BaseClass, + // .. => Node, Resource and RJ classes will be included automatically + + "class":"ClassName:BaseClass", + + // Includes needed for members + "includes":[ "./RJAction.h" ], + + + // Protected member definitions + "protected": + { + // same as public, see below + }, + + // Public member definitions + "public": + { + // -------------------------------------------------------------------- + // [ V A R I A B L E S ] + // -------------------------------------------------------------------- + + // float + "number": 0, + + // int + "counter": "int", + + // bool + "isOn": false, + + // string + "name": "String", + + // Vector3 + "position": "Vector3", + + // Quaternion + "rotation": "Quaternion", + + + + // -------------------------------------------------------------------- + // [ M E T H O D S ] + // -------------------------------------------------------------------- + + // methods can be overwritten and are virtual by default + "doStuff()" : {}, + // this is the same as the above + "virtual doStuff()" : {}, + + // method that is not virtual + "final doStuff()" : {}, + + + // Static methods are available without instance + "static doStuff()" : {}, + + + // Without return or parameters + "doStuff()" : {}, + + + // With value return but without parameters + "doStuff():int" : {}, + + // With reference return but without parameters, + // "Ref" is important + "doStuff():Ref" : {}, + "doStuff():Ref" : {}, + + + // Parameters + "somethingWithParameters():Ref" : { "id":"int", "reference":"Ref" }, + + + // -------------------------------------------------------------------- + // [ S I G N A L S ] + // -------------------------------------------------------------------- + + // Signals are return-less callbacks, which can have input parameters + "signal onEvent()" : { "callbackID": "int" }, + + + // -------------------------------------------------------------------- + // [ A C T I O N ] (RJAction) + // -------------------------------------------------------------------- + + // RJActions are signals without input parameters and can be assigned in the editor + // This function will create a reference for the action and create + // setters/getters for it and additionally creates a signal. + // Should not have a "on" before the name, since this will be added. + + // The class will have a signal 'changed' and an RJAction 'onChanged' + "action changed" : {}, + + } +} \ No newline at end of file diff --git a/rokojori-action-library-definitions/_raw/RJAction.cpp b/rokojori-action-library-definitions/_raw/RJAction.cpp new file mode 100644 index 0000000..18779df --- /dev/null +++ b/rokojori-action-library-definitions/_raw/RJAction.cpp @@ -0,0 +1,32 @@ +/* RJAction.cpp */ + +#include "RJAction.h" + + +void RJAction::_bind_methods() +{ + GDVIRTUAL_BIND( _onTrigger ); + + ClassDB::bind_method( D_METHOD( "trigger" ) , &RJAction::trigger ); + + /* + ClassDB::bind_method(D_METHOD("add", "value"), &RokojoriAction::add); + ClassDB::bind_method(D_METHOD("reset"), &RokojoriAction::reset); + ClassDB::bind_method(D_METHOD("get_total"), &RokojoriAction::get_total); + */ +} + +void RJAction::trigger() +{ + GDVIRTUAL_CALL( _onTrigger ); +} + +RJAction::RJAction() +{ + +} + +RJAction::~RJAction() +{ + +} diff --git a/rokojori-action-library-definitions/_raw/RJAction.h b/rokojori-action-library-definitions/_raw/RJAction.h new file mode 100644 index 0000000..5cad7a5 --- /dev/null +++ b/rokojori-action-library-definitions/_raw/RJAction.h @@ -0,0 +1,28 @@ +/* RJAction.h */ + +#ifndef ROKOJORI__ACTION_H +#define ROKOJORI__ACTION_H + +#include "./RJNetworkNode.h" + +class RJAction : public RJNetworkNode +{ + GDCLASS(RJAction, RJNetworkNode); + + +protected: + static void _bind_methods(); + + GDVIRTUAL0( _onTrigger ) + +public: + + void trigger(); + + RJAction(); + ~RJAction(); + +}; + + +#endif // ROKOJORI__ACTION_H \ No newline at end of file diff --git a/rokojori-action-library-definitions/_raw/RJGodotHeaders.h b/rokojori-action-library-definitions/_raw/RJGodotHeaders.h new file mode 100644 index 0000000..07b288c --- /dev/null +++ b/rokojori-action-library-definitions/_raw/RJGodotHeaders.h @@ -0,0 +1,21 @@ +/* RJGodotHeaders.h */ + +#ifndef ROKOJORI_GODOT_HEADERS_H +#define ROKOJORI_GODOT_HEADERS_H + +#include "scene/main/node.h" +#include "scene/2d/node_2d.h" +#include "scene/3d/node_3d.h" + +#include "core/io/resource.h" + +#include "core/math/vector3.h" +#include "core/math/vector3.h" +#include "core/math/quaternion.h" +#include "core/math/color.h" + +#include "./RJNetworkNode.h" +#include "./RJAction.h" +#include "./RJSequenceAction.h" + +#endif // ROKOJORI_GODOT_HEADERS_H \ No newline at end of file diff --git a/rokojori-action-library-definitions/_raw/RJNetworkNode.cpp b/rokojori-action-library-definitions/_raw/RJNetworkNode.cpp new file mode 100644 index 0000000..b4ee4dc --- /dev/null +++ b/rokojori-action-library-definitions/_raw/RJNetworkNode.cpp @@ -0,0 +1,26 @@ + +/* RJNetworkNode.cpp */ + +#include "RJNetworkNode.h" + +// Registers fields, signals and methods for Godot +void RJNetworkNode::_bind_methods() +{ + +} + +// Constructor +RJNetworkNode::RJNetworkNode() +{ + +} + +// Destructor +RJNetworkNode::~RJNetworkNode() +{ + +} + + + + diff --git a/rokojori-action-library-definitions/_raw/RJNetworkNode.h b/rokojori-action-library-definitions/_raw/RJNetworkNode.h new file mode 100644 index 0000000..48881de --- /dev/null +++ b/rokojori-action-library-definitions/_raw/RJNetworkNode.h @@ -0,0 +1,31 @@ + +/* RJNetworkNode.h */ + +#ifndef ROKOJORI__NETWORK_NODE_H +#define ROKOJORI__NETWORK_NODE_H + +#include "scene/main/node.h" + +class RJNetworkNode : public Node +{ + GDCLASS( RJNetworkNode, Node ); + +protected: + static void _bind_methods(); + + + + +public: + + + + // Constructor + RJNetworkNode(); + + // Destructor + ~RJNetworkNode(); +}; + + +#endif // ROKOJORI__NETWORK_NODE_H diff --git a/rokojori-action-library-definitions/_raw/RJSequenceAction.cpp b/rokojori-action-library-definitions/_raw/RJSequenceAction.cpp new file mode 100644 index 0000000..d1b9826 --- /dev/null +++ b/rokojori-action-library-definitions/_raw/RJSequenceAction.cpp @@ -0,0 +1,55 @@ + +/* RJSequenceAction.cpp */ + +#include "RJSequenceAction.h" + + +void RJSequenceAction::_bind_methods() +{ + GDVIRTUAL_BIND( cancelAction, "id" ); + + ClassDB::bind_method( D_METHOD( "dispatchStart" ) , &RJSequenceAction::dispatchStart ); + ClassDB::bind_method( D_METHOD( "dispatchCancelled" ) , &RJSequenceAction::dispatchCancelled ); + ClassDB::bind_method( D_METHOD( "dispatchEnd" ) , &RJSequenceAction::dispatchEnd ); + ClassDB::bind_method( D_METHOD( "getLastSequenceActionID" ) , &RJSequenceAction::getLastSequenceActionID ); + + ADD_SIGNAL (MethodInfo( "onSequenceDone" , PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::BOOL, "success") ) ); +} + +int RJSequenceAction::dispatchStart() +{ + if ( idCounter > 1000000 ) + { + idCounter = 0; + } + + idCounter++; + + return idCounter; +} + +int RJSequenceAction::getLastSequenceActionID() +{ + return idCounter; +} + +void RJSequenceAction::dispatchCancelled( int id ) +{ + emit_signal( SNAME( "onSequenceDone" ), id, false ); +} + +void RJSequenceAction::dispatchEnd( int id ) +{ + emit_signal( SNAME( "onSequenceDone" ), id, true ); +} + +RJSequenceAction::RJSequenceAction() +{ +} + + +RJSequenceAction::~RJSequenceAction() +{ + +} + diff --git a/rokojori-action-library-definitions/_raw/RJSequenceAction.h b/rokojori-action-library-definitions/_raw/RJSequenceAction.h new file mode 100644 index 0000000..47e7ebf --- /dev/null +++ b/rokojori-action-library-definitions/_raw/RJSequenceAction.h @@ -0,0 +1,37 @@ + +/* RJSequenceAction.h */ + +#ifndef ROKOJORI__SEQUENCE_ACTION_H +#define ROKOJORI__SEQUENCE_ACTION_H + + +#include "./RJAction.h" + + +class RJSequenceAction : public RJAction +{ + GDCLASS(RJSequenceAction, RJAction); + +protected: + static void _bind_methods(); + + int idCounter = 0; + +public: + + int dispatchStart(); + void dispatchCancelled( int id ); + void dispatchEnd( int id ); + + int getLastSequenceActionID(); + GDVIRTUAL1( cancelAction, int ); + + /* signal onSequenceDone */ + + RJSequenceAction(); + + ~RJSequenceAction(); +}; + + +#endif // ROKOJORI__SEQUENCE_ACTION_H diff --git a/rokojori-action-library-definitions/_raw/register_types.cpp b/rokojori-action-library-definitions/_raw/register_types.cpp new file mode 100644 index 0000000..f1dcaae --- /dev/null +++ b/rokojori-action-library-definitions/_raw/register_types.cpp @@ -0,0 +1,28 @@ +/* register_types.cpp */ + +#include "register_types.h" + +#include "core/object/class_db.h" + +/*INCLUDES*/ + +void initialize_rokojori_action_library_module( ModuleInitializationLevel p_level ) +{ + if ( p_level != MODULE_INITIALIZATION_LEVEL_SCENE ) + { + return; + } + + /*CLASS-DB-REGISTRATIONS*/ +} + +void uninitialize_rokojori_action_library_module( ModuleInitializationLevel p_level ) +{ + if ( p_level != MODULE_INITIALIZATION_LEVEL_SCENE ) + { + return; + } + +} + + diff --git a/rokojori-action-library-definitions/_raw/register_types.h b/rokojori-action-library-definitions/_raw/register_types.h new file mode 100644 index 0000000..8220b67 --- /dev/null +++ b/rokojori-action-library-definitions/_raw/register_types.h @@ -0,0 +1,13 @@ +/* register_types.h */ + +#ifndef ROKOJORI_ACTION_LIBRARY_REGISTER_TYPES_H +#define ROKOJORI_ACTION_LIBRARY_REGISTER_TYPES_H + +#include "modules/register_module_types.h" + + +void initialize_rokojori_action_library_module( ModuleInitializationLevel p_level ); +void uninitialize_rokojori_action_library_module( ModuleInitializationLevel p_level ); + + +#endif // ROKOJORI_ACTION_LIBRARY_REGISTER_TYPES_H \ No newline at end of file diff --git a/rokojori-action-library-definitions/core/RJNetworkNode.json b/rokojori-action-library-definitions/core/RJNetworkNode.json new file mode 100644 index 0000000..dd718e9 --- /dev/null +++ b/rokojori-action-library-definitions/core/RJNetworkNode.json @@ -0,0 +1,8 @@ +{ + "class":"RJNetworkNode:Node", + + "public": + { + + } +} \ No newline at end of file diff --git a/rokojori-action-library-definitions/core/RJSelector.json b/rokojori-action-library-definitions/core/RJSelector.json new file mode 100644 index 0000000..56acf39 --- /dev/null +++ b/rokojori-action-library-definitions/core/RJSelector.json @@ -0,0 +1,14 @@ +{ + "class":"RJSelector:Resource", + + "includes": + [ + "scene/main/node.h" + ], + + + "public": + { + "selects():bool":{ "node":"Ref"} + } +} \ No newline at end of file diff --git a/rokojori-action-library-definitions/core/RJSensor.json b/rokojori-action-library-definitions/core/RJSensor.json new file mode 100644 index 0000000..37e8e46 --- /dev/null +++ b/rokojori-action-library-definitions/core/RJSensor.json @@ -0,0 +1,11 @@ +{ + "class":"RJSensor:RJNetworkNode", + + "public": + { + "getValue():float":{}, + "isActive():bool":{}, + "wasActive():bool":{}, + "updateValue()":{ "value":"float"} + } +} \ No newline at end of file diff --git a/rokojori-action-library-definitions/generic/RJ-X-Property.json b/rokojori-action-library-definitions/generic/RJ-X-Property.json new file mode 100644 index 0000000..0aa0cc6 --- /dev/null +++ b/rokojori-action-library-definitions/generic/RJ-X-Property.json @@ -0,0 +1,10 @@ +{ + "variations": "genericOnlyIntNode", + + "class":"RJ{Extension}{DataTypeName}Property:{ParentClass}", + + "public": + { + "property value":"{DataType}" + } +} \ No newline at end of file diff --git a/rokojori-action-library-definitions/generic/_RJGet-X-FromNode-Y.json b/rokojori-action-library-definitions/generic/_RJGet-X-FromNode-Y.json new file mode 100644 index 0000000..f79cf67 --- /dev/null +++ b/rokojori-action-library-definitions/generic/_RJGet-X-FromNode-Y.json @@ -0,0 +1,10 @@ +{ + "variations": "generic", + + "class":"RJGet{DataTypeName}FromNode{Extension}:{ParentClass}", + + "public": + { + "get():{DataType}" : { "node":"Ref" } + } +} \ No newline at end of file diff --git a/rokojori-action-library-definitions/generic/_RJSet-X-OnNode-Y.json b/rokojori-action-library-definitions/generic/_RJSet-X-OnNode-Y.json new file mode 100644 index 0000000..67a1ba4 --- /dev/null +++ b/rokojori-action-library-definitions/generic/_RJSet-X-OnNode-Y.json @@ -0,0 +1,10 @@ +{ + "variations": "generic", + + "class":"RJSet{DataTypeName}OnNode{Extension}:{ParentClass}", + + "public": + { + "set()" : { "node":"Ref", "value":"{DataType}" } + } +} \ No newline at end of file diff --git a/rokojori-action-library-definitions/interactions/RJCaster.json b/rokojori-action-library-definitions/interactions/RJCaster.json new file mode 100644 index 0000000..716f03a --- /dev/null +++ b/rokojori-action-library-definitions/interactions/RJCaster.json @@ -0,0 +1,25 @@ +{ + "class":"RJCaster:Node3D", + + "includes": + [ + "./RJAction.h", + "./RJSelector.h", + "core/math/vector3.h", + "scene/resources/3d/shape_3d.h" + ], + + "public": + { + "beforeProcess":"Node", + "afterProcess":"Node", + "includeSelector":"Resource", + "excludeSelector":"Resource", + + "numColliders():int":{}, + "getCollider():Ref":{ "index":"int" }, + "getCollisionPosition():Vector3":{ "index":"int" }, + "getCollisionNormal():Vector3":{ "index":"int" }, + "getCollisionShape():Ref":{ "index":"int" } + } +} \ No newline at end of file diff --git a/rokojori-action-library-definitions/interactions/RJPointable.json b/rokojori-action-library-definitions/interactions/RJPointable.json new file mode 100644 index 0000000..4847bfb --- /dev/null +++ b/rokojori-action-library-definitions/interactions/RJPointable.json @@ -0,0 +1,29 @@ +{ + "class":"RJPointable:Node3D", + + "includes": + [ + "./RJAction.h", + "./RJPointer.h" + ], + + "forwards": + [ + "template class Ref;", + "class RJPointer;" + ], + + "public": + { + "pointingPriority":"int = 0", + + "onPointed":"Node", + "onUnpointed":"Node", + "onPointerAdded":"Node", + "onPointerRemoved":"Node", + + "updatePointerState()":{ "pointer":"Ref", "pointed":"bool" }, + "getPointer():Ref":{ "index":"int" }, + "numPointing():int":{} + } +} \ No newline at end of file diff --git a/rokojori-action-library-definitions/interactions/RJPointer.json b/rokojori-action-library-definitions/interactions/RJPointer.json new file mode 100644 index 0000000..29bf369 --- /dev/null +++ b/rokojori-action-library-definitions/interactions/RJPointer.json @@ -0,0 +1,21 @@ +{ + "class":"RJPointer:Node3D", + + "includes": + [ + "./RJCaster.h", + "./RJPointable.h" + ], + + "forwards": + [ + "template class Ref;", + "class RJPointable;" + ], + + "public": + { + "caster":"Node", + "getPointable():Ref":{ "index":"int" } + } +} \ No newline at end of file diff --git a/rokojori-action-library-definitions/interactions/_RJInteractable.json b/rokojori-action-library-definitions/interactions/_RJInteractable.json new file mode 100644 index 0000000..f0ef370 --- /dev/null +++ b/rokojori-action-library-definitions/interactions/_RJInteractable.json @@ -0,0 +1,13 @@ +{ + "class":"RJInteractable:Node3D", + + "includes": + [ + "./RJAction.h" + ], + + "public": + { + "onInteraction":"Node" + } +} \ No newline at end of file diff --git a/rokojori-action-library-definitions/interactions/_RJInteractor.json b/rokojori-action-library-definitions/interactions/_RJInteractor.json new file mode 100644 index 0000000..04b62fa --- /dev/null +++ b/rokojori-action-library-definitions/interactions/_RJInteractor.json @@ -0,0 +1,15 @@ +{ + "class":"RJInteractor:Node3D", + + "includes": + [ + "./RJSensor.h", + "./RJPointer.h" + ], + + "public": + { + "input":"Node", + "pointer":"Node" + } +} \ No newline at end of file diff --git a/rokojori-action-library-definitions/properties/RJBoolProperty.json b/rokojori-action-library-definitions/properties/RJBoolProperty.json deleted file mode 100644 index e5cacdb..0000000 --- a/rokojori-action-library-definitions/properties/RJBoolProperty.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "class":"RJBoolProperty:RJNetworkNode", - - "public": - { - "virtual set()" : { "value":"bool" }, - "virtual get():bool": {}, - "signal onChange()" : {} - } -} \ No newline at end of file diff --git a/rokojori-action-library-definitions/properties/RJNodeProperty.json b/rokojori-action-library-definitions/properties/RJNodeProperty.json deleted file mode 100644 index 0987148..0000000 --- a/rokojori-action-library-definitions/properties/RJNodeProperty.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "class":"RJNodeProperty:RJNetworkNode", - - "public": - { - "virtual set()" : { "value":"Ref" }, - "virtual get():Ref": {}, - "signal onChange()" : {} - } -} \ No newline at end of file diff --git a/rokojori-action-library-definitions/properties/RJNumberProperty.json b/rokojori-action-library-definitions/properties/RJNumberProperty.json deleted file mode 100644 index 60eb4de..0000000 --- a/rokojori-action-library-definitions/properties/RJNumberProperty.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "class":"RJNumberProperty:RJNetworkNode", - - "includes":[ "./RJAction.h" ], - - "public": - { - "virtual set()" : { "value":"double" }, - "virtual get():double": {}, - "action changed" : {} - } -} \ No newline at end of file diff --git a/rokojori-action-library-definitions/properties/RJStringProperty.json b/rokojori-action-library-definitions/properties/RJStringProperty.json deleted file mode 100644 index adbdd69..0000000 --- a/rokojori-action-library-definitions/properties/RJStringProperty.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "class":"RJStringProperty:RJNetworkNode", - - "public": - { - "virtual set()" : { "value":"String" }, - "virtual get():String": {}, - "signal onChange()" : {} - } -} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/CppClassMember.js b/rokojori-cpp-generator/builds/CppClassMember.js new file mode 100644 index 0000000..63c47ee --- /dev/null +++ b/rokojori-cpp-generator/builds/CppClassMember.js @@ -0,0 +1,174 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CppClassMember = exports.CppParameter = void 0; +const GodotTypes_1 = require("./GodotTypes"); +class CppParameter { + constructor() { + this.name = ""; + this.type = ""; + } +} +exports.CppParameter = CppParameter; +class CppClassMember { + constructor(accessModifier, nameDefinition, body) { + this.name = ""; + this.isMethod = false; + this.isVirtual = false; + this.isStatic = false; + this.isSignal = false; + this.type = "void"; + this.initialValue = null; + this.parameters = []; + this.accessModifier = ""; + this.parametersDefinition = ""; + this.accessModifier = accessModifier; + if (nameDefinition.indexOf("()") != -1) { + this.isMethod = true; + let typeRegex = /\(\)\s*(?:\:\s*(.+)\s*)?$/; + let result = typeRegex.exec(nameDefinition); + if (result[1]) { + this.type = result[1]; + } + nameDefinition = nameDefinition.replace(typeRegex, ""); + } + let names = nameDefinition.split(/\s+/); + this.name = names[names.length - 1]; + for (let i = 0; i < names.length - 1; i++) { + if ("virtual" === names[i]) { + this.isVirtual = true; + } + if ("static" === names[i]) { + this.isStatic = true; + } + if ("signal" === names[i]) { + this.isSignal = true; + } + } + if (this.isMethod) { + this.parseMethodBody(body); + } + else { + this.parseVariableBody(body); + } + } + get isMemberWithInitialValue() { + return !this.isMethod && this.initialValue !== null; + } + getMemberInitializer() { + return `${this.name} = ${this.initialValue};`; + } + parseVariableBody(body) { + if (typeof body === "boolean") { + this.type = "bool"; + this.initialValue = body + ""; + return; + } + if (typeof body === "number") { + this.type = "float"; + this.initialValue = body + ""; + return; + } + let regex = /((?:\w|\<|\>)+)(?:\s*\=\s*(.+))?/; + let result = regex.exec(body); + this.type = result[1]; + this.initialValue = result[2] || null; + } + parseMethodBody(body) { + if (!body) { + return; + } + if (typeof body === "string") { + this.type = body; + return; + } + for (let it in body) { + if (!body.hasOwnProperty(it)) { + continue; + } + let cppParameter = new CppParameter(); + cppParameter.name = it; + cppParameter.type = body[it]; + this.parameters.push(cppParameter); + } + } + getMethodBinding(className) { + if (!this.isMethod) { + let type = GodotTypes_1.GodotTypes.stringToVariantType(this.type); + let bindings = []; + bindings.push(`/* ${this.name}: ${this.type} */`); + bindings.push(`ClassDB::bind_method(D_METHOD("get_${this.name}"), &${className}::get_${this.name});`); + bindings.push(`ClassDB::bind_method(D_METHOD("set_${this.name}"), &${className}::set_${this.name});`); + bindings.push(`ADD_PROPERTY(PropertyInfo(Variant::${type}, "${this.name}"), "set_${this.name}", "get_${this.name}");`); + bindings.push(` `); + //ClassDB::bind_method(D_METHOD("set_color", "color"), &GLTFLight::set_color); + //ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color"); // Color + return bindings.join("\n "); + } + if (this.isSignal) { + //ADD_SIGNAL(MethodInfo("session_supported", PropertyInfo(Variant::STRING, "session_mode"), PropertyInfo(Variant::BOOL, "supported"))); + let parameterInfos = ""; + for (let i = 0; i < this.parameters.length; i++) { + let type = GodotTypes_1.GodotTypes.stringToVariantType(this.parameters[i].type); + let name = this.parameters[i].name; + let pi = `, PropertyInfo(Variant::${type}, "${name}")`; + parameterInfos += pi; + } + return `ADD_SIGNAL (MethodInfo( "${this.name}" ${parameterInfos}) );`; + } + else if (this.isVirtual) { + let parameterInfos = ""; + for (let i = 0; i < this.parameters.length; i++) { + let name = `, "${this.parameters[i].name}"`; + parameterInfos += name; + } + return `GDVIRTUAL_BIND( ${this.name}${parameterInfos} );`; + } + else { + return `ClassDB::bind_method( D_METHOD( "${this.name}" ) , &${className}::${this.name} );`; + } + } + getHeaderDefinition() { + if (this.isSignal) { + return `/* signal ${this.name} */`; + } + else if (this.isMethod) { + return this.getMethodHeaderDefinition(); + } + else { + return this.getVariableHeaderDefinition(); + } + } + getParametersDefinition() { + return this.parameters.map(p => p.type + " " + p.name).join(", "); + } + getMethodHeaderDefinition() { + if (this.isVirtual) { + let numParameters = this.parameters.length; + let methodReturnType = this.type === "void" ? "" : "R"; + let returnTypeDefinition = this.type === "void" ? "" : (this.type + ", "); + let parametersDefinition = ""; + if (numParameters > 0) { + parametersDefinition = ", " + this.parameters.map(p => p.type).join(", "); + } + return `GDVIRTUAL${numParameters}${methodReturnType}( ${returnTypeDefinition}${this.name}${parametersDefinition} );`; + } + return `${this.type} ${this.name}(${this.parametersDefinition});`; + } + getVariableHeaderDefinition() { + return `${this.type} get_${this.name}(); void set_${this.name}( ${this.type} p_${this.name} );`; + //return `${this.type} ${this.name};` + } + getPropertyHeaderDefinition() { + return `${this.type} ${this.name};`; + } + getPropertyImplementation(className) { + let bindings = []; + bindings.push(`/* ${this.name}: ${this.type} */`); + bindings.push(`${this.type} ${className}::get_${this.name}() { return ${this.name}; }`); + bindings.push(`void ${className}::set_${this.name}( ${this.type} p_${this.name} ) { ${this.name} = p_${this.name}; }`); + bindings.push(` `); + return bindings.join("\n"); + } +} +exports.CppClassMember = CppClassMember; +//# sourceMappingURL=CppClassMember.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/CppClassMember.js.map b/rokojori-cpp-generator/builds/CppClassMember.js.map new file mode 100644 index 0000000..0184d0d --- /dev/null +++ b/rokojori-cpp-generator/builds/CppClassMember.js.map @@ -0,0 +1 @@ +{"version":3,"file":"CppClassMember.js","sourceRoot":"","sources":["../source/CppClassMember.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AAE1C,MAAa,YAAY;IAAzB;QAEE,SAAI,GAAG,EAAE,CAAC;QACV,SAAI,GAAG,EAAE,CAAC;IACZ,CAAC;CAAA;AAJD,oCAIC;AAED,MAAa,cAAc;IAazB,YAAa,cAAqB,EAAE,cAAqB,EAAE,IAAQ;QAXnE,SAAI,GAAG,EAAE,CAAC;QACV,aAAQ,GAAI,KAAK,CAAC;QAClB,cAAS,GAAG,KAAK,CAAC;QAClB,aAAQ,GAAI,KAAK,CAAC;QAClB,aAAQ,GAAI,KAAK,CAAC;QAClB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AC,IAAI,KAAK,IAAI,CAAC,IAAI,MAAM,IAAI,CAAC,IAAI,KAAK,CAAA;QAC/F,qCAAqC;IACvC,CAAC;IAED,2BAA2B;QAEzB,OAAO,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,GAAG,CAAA;IACrC,CAAC;IAED,yBAAyB,CAAE,SAAgB;QAEzC,IAAI,QAAQ,GAAG,EAAE,CAAC;QAElB,QAAQ,CAAC,IAAI,CAAE,MAAM,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,CAAE,CAAC;QACpD,QAAQ,CAAC,IAAI,CAAE,GAAG,IAAI,CAAC,IAAI,IAAI,SAAS,SAAS,IAAI,CAAC,IAAI,eAAe,IAAI,CAAC,IAAI,KAAK,CAAE,CAAC;QAC1F,QAAQ,CAAC,IAAI,CAAE,QAAQ,SAAS,SAAS,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,MAAM,IAAI,CAAC,IAAI,QAAQ,IAAI,CAAC,IAAI,QAAQ,IAAI,CAAC,IAAI,KAAK,CAAE,CAAC;QACzH,QAAQ,CAAC,IAAI,CAAE,GAAG,CAAE,CAAC;QAErB,OAAO,QAAQ,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IAC/B,CAAC;CAEF;AA7PD,wCA6PC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/CppCreator.js b/rokojori-cpp-generator/builds/CppCreator.js new file mode 100644 index 0000000..432adff --- /dev/null +++ b/rokojori-cpp-generator/builds/CppCreator.js @@ -0,0 +1,156 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CppCreator = void 0; +const CppClassMember_1 = require("./CppClassMember"); +const CppHeaderCreator_1 = require("./CppHeaderCreator"); +const CppImplementationCreator_1 = require("./CppImplementationCreator"); +const Files_1 = require("./library/Files"); +const Texts_1 = require("./library/Texts"); +class CppCreator { + static createTypeRegistration(className) { + return `ClassDB::register_class<${className}>();`; + } + static createIncludes(className) { + console.log("Create include", className); + let godotClasses = { + "Node": "scene/main/node.h", + "Node2D": "scene/2d/node_2d.h", + "Node3D": "scene/3d/node_3d.h", + "Resource": "core/io/resource.h" + }; + if (godotClasses[className]) { + return `#include "${godotClasses[className]}"`; + } + return `#include "./${className}.h"`; + } + static grabMembers(membersData, accessModifier) { + let members = []; + if (!membersData) { + return members; + } + for (let it in membersData) { + if (!membersData.hasOwnProperty(it)) { + continue; + } + let nameDefinition = it; + let memberData = membersData[it]; + let actionRegex = /^\s*action\s+(\w+)\s*$/; + if (actionRegex.test(nameDefinition)) { + let name = actionRegex.exec(nameDefinition)[1]; + let upperCaseName = name[0].toUpperCase() + name.substring(1); + let actionName = `on${upperCaseName}`; + let signal = `signal ${name}()`; + let actionGetter = `virtual get_${actionName}():Ref`; + let actionSetter = `virtual set_${actionName}()`; + members.push(new CppClassMember_1.CppClassMember(accessModifier, signal, {})); + members.push(new CppClassMember_1.CppClassMember("protected", "m_" + name, {})); + members.push(new CppClassMember_1.CppClassMember(accessModifier, actionGetter, {})); + members.push(new CppClassMember_1.CppClassMember(accessModifier, actionSetter, { "action": "Ref" })); + } + else { + let classMember = new CppClassMember_1.CppClassMember(accessModifier, nameDefinition, memberData); + members.push(classMember); + } + } + return members; + } + static getHeaderDefine(className) { + className = className.replace(/^RJ/, ""); + let output = [className[0]]; + for (let i = 1; i < className.length; i++) { + let character = className[i]; + let upperCaseCharacter = character.toUpperCase(); + if (character === upperCaseCharacter) { + output.push("_"); + } + output.push(upperCaseCharacter); + } + className = output.join(""); + return "ROKOJORI__" + className + "_H"; + } + static getRegistratedTypes(text) { + let matches = Texts_1.Texts.getMatches(text, CppCreator.classRegistrationRegex); + let types = matches.map(m => { + return { match: m.match, index: m.index, type: CppCreator.classRegistrationRegex.exec(m.match)[1] }; + }); + return types; + } + static createCppFiles(definitionPath, types, missingTypes) { + return __awaiter(this, void 0, void 0, function* () { + console.log("Creating: ", definitionPath); + let jsonPath = definitionPath; + // path.join( definitionsPath, definitionPath ); + let isDir = yield Files_1.Files.isDirectory(jsonPath); + if (isDir) { + let files = yield Files_1.Files.getFiles(jsonPath); + for (let file of files) { + yield CppCreator.createCppFiles(Texts_1.Texts.joinPaths(jsonPath, file), types, missingTypes); + } + return Promise.resolve(); + } + let data = yield Files_1.Files.loadJSON(jsonPath); + //console.log( "data:", jsonPath, data ); + let classNameResult = /(\w+)(?:\:(\w+))?/.exec(data.class); + let className = classNameResult[1]; + let extendingClass = classNameResult[2]; + let headerDefine = CppCreator.getHeaderDefine(className); + let fromProtectedMembers = CppCreator.grabMembers(data.protected, "protected"); + let fromPublicMembers = CppCreator.grabMembers(data.public, "public"); + let protectedMembers = []; + let publicMembers = []; + let insertMember = (m) => { + let container = m.accessModifier === "public" ? publicMembers : protectedMembers; + container.push(m); + }; + fromProtectedMembers.forEach(m => insertMember(m)); + fromPublicMembers.forEach(m => insertMember(m)); + let allMembers = [].concat(protectedMembers).concat(publicMembers); + let protectedHeader = protectedMembers.map(m => m.getHeaderDefinition()).join("\n "); + let publicHeader = publicMembers.map(m => m.getHeaderDefinition()).join("\n "); + let properties = publicMembers.filter(m => !m.isMethod); + let propertyDefinitions = properties.map(p => p.getPropertyHeaderDefinition()).join("\n "); + protectedHeader += "\n\n " + propertyDefinitions; + let methodBindings = allMembers.map(m => m.getMethodBinding(className)).join("\n "); + let initializers = allMembers.filter(m => m.isMemberWithInitialValue).map(m => m.getMemberInitializer()).join("\n "); + let includes = ""; + if (data.includes) { + let mappedIncludes = data.includes.map((inc) => `#include "${inc}"`); + includes = mappedIncludes.join("\n"); + } + let extendingClassInclude = CppCreator.createIncludes(extendingClass); + includes += "\n" + extendingClassInclude; + let header = CppHeaderCreator_1.CppHeaderCreator.create(className, extendingClass, headerDefine, protectedHeader, publicHeader, includes); + let constructorExpressions = initializers; + let destructorExpressions = ""; + let methodImplementations = ""; + let propertyImplementations = properties.map(p => p.getPropertyImplementation(className)).join("\n"); + methodImplementations += propertyImplementations; + let implementation = CppImplementationCreator_1.CppImplementationCreator.craete(className, methodBindings, constructorExpressions, destructorExpressions, methodImplementations); + //console.log( header ); + //console.log( implementation ); + let hasType = types.find(t => t.type === className); + if (!hasType) { + missingTypes.push(className); + } + let rawFilePath = Texts_1.Texts.joinPaths(CppCreator.outputPath, className); + yield Files_1.Files.saveUTF8(rawFilePath + ".h", header); + yield Files_1.Files.saveUTF8(rawFilePath + ".cpp", implementation); + return Promise.resolve(); + }); + } +} +exports.CppCreator = CppCreator; +CppCreator.definitionsPath = __dirname + "/../../rokojori-action-library-definitions"; +CppCreator.outputPath = __dirname + "/../../rokojori-action-library"; +CppCreator.registerTypesPath = CppCreator.outputPath + "/register_types.cpp"; +CppCreator.classRegistrationRegex = /ClassDB\:\:register_class\<(\w+)\>\(\)\;/; +//# sourceMappingURL=CppCreator.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/CppCreator.js.map b/rokojori-cpp-generator/builds/CppCreator.js.map new file mode 100644 index 0000000..18ee936 --- /dev/null +++ b/rokojori-cpp-generator/builds/CppCreator.js.map @@ -0,0 +1 @@ +{"version":3,"file":"CppCreator.js","sourceRoot":"","sources":["../source/CppCreator.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAkD;AAClD,yDAAsD;AACtD,yEAAsE;AACtE,2CAAwC;AAExC,2CAAwC;AAExC,MAAa,UAAU;IAOrB,MAAM,CAAC,sBAAsB,CAAE,SAAgB;QAE7C,OAAO,2BAA2B,SAAS,MAAM,CAAC;IACpD,CAAC;IAED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iB,GAAG,UAAU,CAAC,UAAU,GAAG,qBAAqB,CAAC;AAClE,iCAAsB,GAAG,0CAA0C,CAAC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/CppHeaderCreator.js b/rokojori-cpp-generator/builds/CppHeaderCreator.js new file mode 100644 index 0000000..bc5b0da --- /dev/null +++ b/rokojori-cpp-generator/builds/CppHeaderCreator.js @@ -0,0 +1,39 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CppHeaderCreator = void 0; +class CppHeaderCreator { + static create(className, extendingClassName, headerDefine, protectedMembers, publicMembers, includes) { + let cppHeader = ` +/* ${className}.h */ + +#ifndef ${headerDefine} +#define ${headerDefine} + +${includes} + + +class ${className} : public ${extendingClassName} +{ + GDCLASS(${className}, ${extendingClassName}); + +protected: + static void _bind_methods(); + ${protectedMembers} + +public: + + ${publicMembers} + + ${className}(); + + ~${className}(); +}; + + +#endif // ${headerDefine} +`; + return cppHeader; + } +} +exports.CppHeaderCreator = CppHeaderCreator; +//# sourceMappingURL=CppHeaderCreator.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/CppHeaderCreator.js.map b/rokojori-cpp-generator/builds/CppHeaderCreator.js.map new file mode 100644 index 0000000..c8661ba --- /dev/null +++ b/rokojori-cpp-generator/builds/CppHeaderCreator.js.map @@ -0,0 +1 @@ +{"version":3,"file":"CppHeaderCreator.js","sourceRoot":"","sources":["../source/CppHeaderCreator.ts"],"names":[],"mappings":";;;AAAA,MAAa,gBAAgB;IAE3B,MAAM,CAAC,MAAM,CAAE,SAAgB,EAAE,kBAAyB,EACzC,YAAmB,EAAE,gBAAuB,EAC5C,aAAoB,EAAE,QAAe;QAGpD,IAAI,SAAS,GAEjB;KACK,SAAS;;UAEJ,YAAY;UACZ,YAAY;;EAEpB,QAAQ;;;QAGF,SAAS,aAAa,kBAAkB;;YAEpC,SAAS,KAAK,kBAAkB;;;;IAIxC,gBAAgB;;;;IAIhB,aAAa;;IAEb,SAAS;;KAER,SAAS;;;;YAIF,YAAY;CACvB,CAAA;QAEG,OAAO,SAAS,CAAC;IAGnB,CAAC;CAEF;AA5CD,4CA4CC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/CppImplementationCreator.js b/rokojori-cpp-generator/builds/CppImplementationCreator.js new file mode 100644 index 0000000..92ed6a6 --- /dev/null +++ b/rokojori-cpp-generator/builds/CppImplementationCreator.js @@ -0,0 +1,34 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CppImplementationCreator = void 0; +class CppImplementationCreator { + static craete(className, boundMethods, constructorExpressions, destructorExpressions, methodImplementations) { + let cppImplementation = ` +/* ${className}.cpp */ + +#include "${className}.h" + + +void ${className}::_bind_methods() +{ + ${boundMethods} +} + +${className}::${className}() +{ + ${constructorExpressions} +} + +${className}::~${className}() +{ + ${destructorExpressions} +} + +${methodImplementations} + +`; + return cppImplementation; + } +} +exports.CppImplementationCreator = CppImplementationCreator; +//# sourceMappingURL=CppImplementationCreator.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/CppImplementationCreator.js.map b/rokojori-cpp-generator/builds/CppImplementationCreator.js.map new file mode 100644 index 0000000..1065fcc --- /dev/null +++ b/rokojori-cpp-generator/builds/CppImplementationCreator.js.map @@ -0,0 +1 @@ +{"version":3,"file":"CppImplementationCreator.js","sourceRoot":"","sources":["../source/CppImplementationCreator.ts"],"names":[],"mappings":";;;AACA,MAAa,wBAAwB;IAGnC,MAAM,CAAC,MAAM,CAAE,SAAgB,EAAE,YAAmB,EACrC,sBAA6B,EAAE,qBAA4B,EAC3D,qBAA4B;QAGzC,IAAI,iBAAiB,GACzB;KACK,SAAS;;YAEF,SAAS;;;OAGd,SAAS;;IAEZ,YAAY;;;EAGd,SAAS,KAAK,SAAS;;IAErB,sBAAsB;;;EAGxB,SAAS,MAAM,SAAS;;IAEtB,qBAAqB;;;EAGvB,qBAAqB;;CAEtB,CAAA;QAEG,OAAO,iBAAiB,CAAC;IAE3B,CAAC;CAEF;AAtCD,4DAsCC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/GodotTypes.js b/rokojori-cpp-generator/builds/GodotTypes.js new file mode 100644 index 0000000..de2446b --- /dev/null +++ b/rokojori-cpp-generator/builds/GodotTypes.js @@ -0,0 +1,56 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.GodotTypes = void 0; +class GodotTypes { + static stringToVariantType(stringType) { + if (/^TypedArray\<.+\>$/.test(stringType)) { + return "ARRAY"; + } + switch (stringType) { + case "bool": return "BOOL"; + case "int": return "INT"; + case "float": return "FLOAT"; + case "String": return "STRING"; + // Math + case "Vector2": return "VECTOR2"; + case "Vector2i": return "VECTOR2I"; + case "Rect2": return "RECT2"; + case "Rect2i": return "RECT2I"; + case "Transform2D": return "TRANSFORM2D"; + case "Vector3": return "VECTOR3"; + case "Vector3i": return "VECTOR3I"; + case "Vector4": return "VECTOR4"; + case "Vector4i": return "VECTOR4I"; + case "Plane": return "PLANE"; + case "AABB": return "AABB"; + case "Quaternion": return "QUATERNION"; + case "Basis": return "BASIS"; + case "Transform3D": return "TRANSFORM3D"; + case "Projection": return "PROJECTION"; + // Miscellaneous + case "Color": return "COLOR"; + case "RID": return "RID"; + case "Object": return "OBJECT"; + case "Callable": return "CALLABLE"; + case "Signal": return "SIGNAL"; + case "StringName": return "STRING_NAME"; + case "NodePath": return "NODE_PATH"; + case "Dictionary": return "DICTIONARY"; + case "Array": return "ARRAY"; + // Arrays + case "PackedByteArray": return "PACKED_BYTE_ARRAY"; + case "PackedInt32Array": return "PACKED_INT32_ARRAY"; + case "PackedInt64Array": return "PACKED_INT64_ARRAY"; + case "PackedFloat32Array": return "PACKED_FLOAT32_ARRAY"; + case "PackedFloat64Array": return "PACKED_FLOAT64_ARRAY"; + case "PackedStringArray": return "PACKED_STRING_ARRAY"; + case "PackedVector2Array": return "PACKED_VECTOR2_ARRAY"; + case "PackedVector3Array": return "PACKED_VECTOR3_ARRAY"; + case "PackedColorArray": return "PACKED_COLOR_ARRAY"; + } + console.error("Type could not be mapped: ", stringType); + return "OBJECT"; + } +} +exports.GodotTypes = GodotTypes; +//# sourceMappingURL=GodotTypes.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/GodotTypes.js.map b/rokojori-cpp-generator/builds/GodotTypes.js.map new file mode 100644 index 0000000..25c9e2f --- /dev/null +++ b/rokojori-cpp-generator/builds/GodotTypes.js.map @@ -0,0 +1 @@ +{"version":3,"file":"GodotTypes.js","sourceRoot":"","sources":["../source/GodotTypes.ts"],"names":[],"mappings":";;;AACA,MAAa,UAAU;IAErB,MAAM,CAAC,mBAAmB,CAAE,UAAiB;QAE3C,IAAK,oBAAoB,CAAC,IAAI,CAAE,UAAU,CAAE,EAC5C,CAAC;YACC,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,QAAQ,UAAU,EAClB,CAAC;YACC,KAAK,MAAM,CAAC,CAAC,OAAO,MAAM,CAAC;YAC3B,KAAK,KAAK,CAAC,CAAC,OAAO,KAAK,CAAC;YACzB,KAAK,OAAO,CAAC,CAAC,OAAO,OAAO,CAAC;YAC7B,KAAK,QAAQ,CAAC,CAAC,OAAO,QAAQ,CAAC;YAE/B,OAAO;YACP,KAAK,SAAS,CAAC,CAAC,OAAO,SAAS,CAAC;YACjC,KAAK,UAAU,CAAC,CAAC,OAAO,UAAU,CAAC;YACnC,KAAK,OAAO,CAAC,CAAC,OAAO,OAAO,CAAC;YAC7B,KAAK,QAAQ,CAAC,CAAC,OAAO,QAAQ,CAAC;YAC/B,KAAK,aAAa,CAAC,CAAC,OAAO,aAAa,CAAC;YACzC,KAAK,SAAS,CAAC,CAAC,OAAO,SAAS,CAAC;YACjC,KAAK,UAAU,CAAC,CAAC,OAAO,UAAU,CAAC;YACnC,KAAK,SAAS,CAAC,CAAC,OAAO,SAAS,CAAC;YACjC,KAAK,UAAU,CAAC,CAAC,OAAO,UAAU,CAAC;YACnC,KAAK,OAAO,CAAC,CAAC,OAAO,OAAO,CAAC;Y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AA4B,EAAE,UAAU,CAAE,CAAC;QAE1D,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AA5DD,gCA4DC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/copy-cpp-source.js b/rokojori-cpp-generator/builds/copy-cpp-source.js new file mode 100644 index 0000000..88510d6 --- /dev/null +++ b/rokojori-cpp-generator/builds/copy-cpp-source.js @@ -0,0 +1,43 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const RJLog_1 = require("./library/RJLog"); +const fs = require("node:fs/promises"); +let from = __dirname + "/../../rokojori-action-library"; +let to = __dirname + "/../../godot/modules/rokojori_action_library"; +function main() { + return __awaiter(this, void 0, void 0, function* () { + RJLog_1.RJLog.log("Copying C++ source"); + yield deleteOldDirectory(); + yield copyToModules(); + // await runBuild(); + RJLog_1.RJLog.log("Copying C++ source"); + }); +} +function deleteOldDirectory() { + return __awaiter(this, void 0, void 0, function* () { + let stats = yield fs.stat(to); + if (stats) { + RJLog_1.RJLog.log(`deleting previous directory: "${to}"`); + yield fs.rm(to, { recursive: true }); + } + return Promise.resolve(); + }); +} +function copyToModules() { + return __awaiter(this, void 0, void 0, function* () { + RJLog_1.RJLog.log("copying:", `"${from}" >> "${to}"`); + yield fs.cp(from, to, { recursive: true }); + return Promise.resolve(); + }); +} +main(); +//# sourceMappingURL=copy-cpp-source.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/copy-cpp-source.js.map b/rokojori-cpp-generator/builds/copy-cpp-source.js.map new file mode 100644 index 0000000..dbadc52 --- /dev/null +++ b/rokojori-cpp-generator/builds/copy-cpp-source.js.map @@ -0,0 +1 @@ +{"version":3,"file":"copy-cpp-source.js","sourceRoot":"","sources":["../source/copy-cpp-source.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,2CAAwC;AAExC,MAAM,EAAE,GAAG,OAAO,CAAE,kBAAkB,CAAE,CAAC;AAEzC,IAAI,IAAI,GAAG,SAAS,GAAG,gCAAgC,CAAC;AACxD,IAAI,EAAE,GAAK,SAAS,GAAG,8CAA8C,CAAA;AAErE,SAAe,IAAI;;QAEjB,aAAK,CAAC,GAAG,CAAE,oBAAoB,CAAE,CAAC;QAElC,MAAM,kBAAkB,EAAE,CAAC;QAC3B,MAAM,aAAa,EAAE,CAAC;QACtB,oBAAoB;QAEpB,aAAK,CAAC,GAAG,CAAE,oBAAoB,CAAE,CAAC;IACpC,CAAC;CAAA;AAED,SAAe,kBAAkB;;QAE/B,IAAI,KAAK,GAAG,MAAM,EAAE,CAAC,IAAI,CAAE,EAAE,CAAE,CAAC;QAEhC,IAAK,KAAK,EACV,CAAC;YACC,aAAK,CAAC,GAAG,CAAE,iCAAiC,EAAE,GAAG,CAAE,CAAC;YACpD,MAAM,EAAE,CAAC,EAAE,CAAE,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAE,CAAC;QACzC,CAAC;QAED,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CAAA;AAED,SAAe,aAAa;;QAE1B,aAAK,CAAC,GAAG,CAAE,UAAU,EAAE,IAAI,IAAI,SAAS,EAAE,GAAG,CAAE,CAAC;QAChD,MAAM,EAAE,CAAC,EAAE,CAAE,IAAI,EAAE,EAAE,EAAE,EAAE,SAAS,EAAG,IAAI,EAAE,CAAE,CAAC;QAE9C,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CAAA;AAID,IAAI,EAAE,CAAC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/CppCreator.js b/rokojori-cpp-generator/builds/cpp-creation/CppCreator.js new file mode 100644 index 0000000..3df64aa --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/CppCreator.js @@ -0,0 +1,149 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CppCreator = void 0; +const Header_1 = require("./Header"); +const Implementation_1 = require("./Implementation"); +const Files_1 = require("../library/Files"); +const Texts_1 = require("../library/Texts"); +const MemberType_1 = require("./MemberType"); +const CppDefinition_1 = require("./CppDefinition"); +const Variations_1 = require("./Variations"); +const VariationTemplates_1 = require("./VariationTemplates"); +const MemberFactory_1 = require("./factories/MemberFactory"); +class CppCreator { + static createIncludes(className) { + // RJLog.log( "Create include", className ); + let godotClasses = { + "Node": "scene/main/node.h", + "Node2D": "scene/2d/node_2d.h", + "Node3D": "scene/3d/node_3d.h", + "Resource": "core/io/resource.h" + }; + if (godotClasses[className]) { + return `#include "${godotClasses[className]}"`; + } + return `#include "./${className}.h"`; + } + static getHeaderDefine(className) { + className = className.replace(/^RJ/, ""); + let output = [className[0]]; + for (let i = 1; i < className.length; i++) { + let character = className[i]; + let upperCaseCharacter = character.toUpperCase(); + if (character === upperCaseCharacter) { + output.push("_"); + } + output.push(upperCaseCharacter); + } + className = output.join(""); + return "ROKOJORI__" + className + "_H"; + } + static createCppFiles(definitionPath) { + return __awaiter(this, void 0, void 0, function* () { + let jsonPath = definitionPath; + // path.join( definitionsPath, definitionPath ); + let isDir = yield Files_1.Files.isDirectory(jsonPath); + if (isDir) { + let files = yield Files_1.Files.getFiles(jsonPath); + for (let file of files) { + if (file.startsWith("_")) { + continue; + } + yield CppCreator.createCppFiles(Texts_1.Texts.joinPaths(jsonPath, file)); + } + return Promise.resolve(); + } + return this.createCppFile(jsonPath); + }); + } + static createCppFile(jsonPath) { + return __awaiter(this, void 0, void 0, function* () { + let data = yield Files_1.Files.loadJSON(jsonPath); + if (data.variations) { + let variationsData = data.variations; + if (typeof variationsData == "string") { + variationsData = VariationTemplates_1.VariationTemplates[variationsData]; + } + let variations = new Variations_1.Variations(variationsData); + console.log(variations.items, variations.counter, variations.hasItems); + while (variations.hasItems) { + let newData = CppDefinition_1.CppDefinition.createVariation(data, variations.currentMap); + yield this.createCppFileWith(newData); + variations.nextItem(); + } + } + else { + yield CppCreator.createCppFileWith(data); + } + return Promise.resolve(); + }); + } + static createCppFileWith(data) { + return __awaiter(this, void 0, void 0, function* () { + let classNameResult = /(\w+)(?:\:(\w+))?/.exec(data.class); + let className = classNameResult[1]; + let extendingClass = classNameResult[2]; + let headerDefine = CppCreator.getHeaderDefine(className); + let fromProtectedMembers = MemberFactory_1.MemberFactory.grabMembers(data.protected, "protected"); + let fromPublicMembers = MemberFactory_1.MemberFactory.grabMembers(data.public, "public"); + let protectedMembers = []; + let publicMembers = []; + let insertMember = (m) => { + let container = m.accessModifier === "public" ? publicMembers : protectedMembers; + container.push(m); + }; + fromProtectedMembers.forEach(m => insertMember(m)); + fromPublicMembers.forEach(m => insertMember(m)); + let allMembers = [].concat(protectedMembers).concat(publicMembers); + let protectedHeader = protectedMembers.map(m => m.getHeaderDefinition()).join("\n "); + let publicHeader = publicMembers.map(m => m.getHeaderDefinition()).join("\n "); + let fields = allMembers.filter(m => m.memberType === MemberType_1.MemberType.Field); + let methods = allMembers.filter(m => m.memberType === MemberType_1.MemberType.Method); + let fieldDeclarations = fields.map(f => f.getFieldDeclaration()).join("\n "); + protectedHeader += "\n\n " + fieldDeclarations; + let methodBindings = allMembers.map(m => m.getBindings(className)).join("\n "); + let initializers = fields.filter(m => m.hasInitializer).map(m => m.getInitializer()).join("\n "); + let includes = `#include "./RJGodotHeaders.h"`; + if (data.includes) { + let mappedIncludes = data.includes.map((inc) => `#include "${inc}"`); + includes += "\n" + mappedIncludes.join("\n"); + } + let extendingClassInclude = CppCreator.createIncludes(extendingClass); + includes += "\n" + extendingClassInclude; + let forwards = ""; + if (data.forwards) { + let forwardDeclarations = data.forwards; + forwards = forwardDeclarations.join("\n"); + } + let header = Header_1.Header.create(className, extendingClass, headerDefine, protectedHeader, publicHeader, includes, forwards); + let constructorExpressions = initializers; + let destructorExpressions = ""; + let implementations = ""; + let fieldImplementations = fields.map(f => f.getFieldImplementation(className)); + implementations += fieldImplementations.join("\n") + "\n"; + let methodsWithImplementation = methods.filter(m => m.hasMethodImplementation); + let methodImplementations = methodsWithImplementation.map(m => m.getMethodImplementation(className)); + implementations += methodImplementations.join("\n"); + let implementation = Implementation_1.Implementation.craete(className, methodBindings, constructorExpressions, destructorExpressions, implementations); + let rawFilePath = Texts_1.Texts.joinPaths(CppCreator.outputPath, className); + yield Files_1.Files.saveUTF8(rawFilePath + ".h", header); + yield Files_1.Files.saveUTF8(rawFilePath + ".cpp", implementation); + }); + } +} +exports.CppCreator = CppCreator; +CppCreator.definitionsPath = __dirname + "/../../../rokojori-action-library-definitions"; +CppCreator.outputPath = __dirname + "/../../../rokojori-action-library"; +CppCreator.rawPath = CppCreator.definitionsPath + "/_raw"; +CppCreator.registerTypesPath = CppCreator.rawPath + "/register_types.cpp"; +CppCreator.registerTypesPathOutput = CppCreator.outputPath + "/register_types.cpp"; +//# sourceMappingURL=CppCreator.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/CppCreator.js.map b/rokojori-cpp-generator/builds/cpp-creation/CppCreator.js.map new file mode 100644 index 0000000..ff05a18 --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/CppCreator.js.map @@ -0,0 +1 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AC,CAAC,uBAAuB,CAAE,CAAC;YACjF,IAAI,qBAAqB,GAAG,yBAAyB,CAAC,GAAG,CAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,uBAAuB,CAAE,SAAS,CAAE,CAAE,CAAC;YAEzG,eAAe,IAAI,qBAAqB,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;YAEtD,IAAI,cAAc,GAAG,+BAAc,CAAC,MAAM,CAAE,SAAS,EAAE,cAAc,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,eAAe,CAAE,CAAC;YAExI,IAAI,WAAW,GAAG,aAAK,CAAC,SAAS,CAAE,UAAU,CAAC,UAAU,EAAE,SAAS,CAAE,CAAC;YAEtE,MAAM,aAAK,CAAC,QAAQ,CAAE,WAAW,GAAG,IAAI,EAAE,MAAM,CAAE,CAAC;YACnD,MAAM,aAAK,CAAC,QAAQ,CAAE,WAAW,GAAG,MAAM,EAAE,cAAc,CAAE,CAAC;QAC/D,CAAC;KAAA;;AA3MH,gCA6MC;AA3MQ,0BAAe,GAAG,SAAS,GAAG,+CAA+C,CAAC;AAC9E,qBAAU,GAAG,SAAS,GAAG,mCAAmC,CAAC;AAC7D,kBAAO,GAAG,UAAU,CAAC,eAAe,GAAG,OAAO,CAAC;AAC/C,4BAAiB,GAAG,UAAU,CAAC,OAAO,GAAG,qBAAqB,CAAC;AAC/D,kCAAuB,GAAG,UAAU,CAAC,UAAU,GAAG,qBAAqB,CAAC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/CppDefinition.js b/rokojori-cpp-generator/builds/cpp-creation/CppDefinition.js new file mode 100644 index 0000000..3c6e09e --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/CppDefinition.js @@ -0,0 +1,25 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CppDefinition = void 0; +const Texts_1 = require("../library/Texts"); +class CppDefinition { + static createVariation(cppDefinition, map) { + let variation = new CppDefinition(); + variation.class = Texts_1.Texts.replaceAll(cppDefinition.class, map); + variation.includes = Texts_1.Texts.replaceAllIn(cppDefinition.includes, map); + variation.forwards = Texts_1.Texts.replaceAllIn(cppDefinition.forwards, map); + variation.public = CppDefinition.applyVariationOnAll(cppDefinition.public, map); + variation.protected = CppDefinition.applyVariationOnAll(cppDefinition.protected, map); + return variation; + } + static applyVariationOnAll(obj, map) { + if (obj === null || obj === undefined) { + return obj; + } + let jsonValue = JSON.stringify(obj); + jsonValue = Texts_1.Texts.replaceAll(jsonValue, map); + return JSON.parse(jsonValue); + } +} +exports.CppDefinition = CppDefinition; +//# sourceMappingURL=CppDefinition.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/CppDefinition.js.map b/rokojori-cpp-generator/builds/cpp-creation/CppDefinition.js.map new file mode 100644 index 0000000..c36d0f1 --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/CppDefinition.js.map @@ -0,0 +1 @@ +{"version":3,"file":"CppDefinition.js","sourceRoot":"","sources":["../../source/cpp-creation/CppDefinition.ts"],"names":[],"mappings":";;;AAAA,4CAAyC;AAIzC,MAAa,aAAa;IAYxB,MAAM,CAAC,eAAe,CAAE,aAA2B,EAAE,GAAsB;QAEzE,IAAI,SAAS,GAAG,IAAI,aAAa,EAAE,CAAC;QAEpC,SAAS,CAAC,KAAK,GAAG,aAAK,CAAC,UAAU,CAAE,aAAa,CAAC,KAAK,EAAE,GAAG,CAAE,CAAC;QAE/D,SAAS,CAAC,QAAQ,GAAG,aAAK,CAAC,YAAY,CAAE,aAAa,CAAC,QAAQ,EAAE,GAAG,CAAE,CAAC;QACvE,SAAS,CAAC,QAAQ,GAAG,aAAK,CAAC,YAAY,CAAE,aAAa,CAAC,QAAQ,EAAE,GAAG,CAAE,CAAC;QAEvE,SAAS,CAAC,MAAM,GAAG,aAAa,CAAC,mBAAmB,CAAE,aAAa,CAAC,MAAM,EAAE,GAAG,CAAE,CAAC;QAClF,SAAS,CAAC,SAAS,GAAG,aAAa,CAAC,mBAAmB,CAAE,aAAa,CAAC,SAAS,EAAE,GAAG,CAAE,CAAC;QAExF,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,mBAAmB,CAAK,GAAK,EAAE,GAAsB;QAE1D,IAAK,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EACtC,CAAC;YACC,OAAO,GAAG,CAAC;QACb,CAAC;QAED,IAAI,SAAS,GAAG,IAAI,CAAC,SAAS,CAAE,GAAG,CAAE,CAAC;QACtC,SAAS,GAAG,aAAK,CAAC,UAAU,CAAE,SAAS,EAAE,GAAG,CAAE,CAAC;QAC/C,OAAO,IAAI,CAAC,KAAK,CAAE,SAAS,CAAO,CAAC;IACtC,CAAC;CACF;AAtCD,sCAsCC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/GodotTypes.js b/rokojori-cpp-generator/builds/cpp-creation/GodotTypes.js new file mode 100644 index 0000000..27390df --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/GodotTypes.js @@ -0,0 +1,68 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.GodotTypes = void 0; +const RJLog_1 = require("../library/RJLog"); +class GodotTypes { + static stringToPropertyHint(stringType) { + switch (stringType) { + case "Node": + case "Ref": + return "PROPERTY_HINT_NODE_TYPE"; + case "Resource": + case "Ref": + return "PROPERTY_HINT_RESOURCE_TYPE"; + } + RJLog_1.RJLog.error("No property hint found for", `"${stringType}"`); + } + static stringToVariantType(stringType) { + if (/^TypedArray\<.+\>$/.test(stringType)) { + return "ARRAY"; + } + switch (stringType) { + case "bool": return "BOOL"; + case "int": return "INT"; + case "float": return "FLOAT"; + case "String": return "STRING"; + // Math + case "Vector2": return "VECTOR2"; + case "Vector2i": return "VECTOR2I"; + case "Rect2": return "RECT2"; + case "Rect2i": return "RECT2I"; + case "Transform2D": return "TRANSFORM2D"; + case "Vector3": return "VECTOR3"; + case "Vector3i": return "VECTOR3I"; + case "Vector4": return "VECTOR4"; + case "Vector4i": return "VECTOR4I"; + case "Plane": return "PLANE"; + case "AABB": return "AABB"; + case "Quaternion": return "QUATERNION"; + case "Basis": return "BASIS"; + case "Transform3D": return "TRANSFORM3D"; + case "Projection": return "PROJECTION"; + // Miscellaneous + case "Color": return "COLOR"; + case "RID": return "RID"; + case "Object": return "OBJECT"; + case "Callable": return "CALLABLE"; + case "Signal": return "SIGNAL"; + case "StringName": return "STRING_NAME"; + case "NodePath": return "NODE_PATH"; + case "Dictionary": return "DICTIONARY"; + case "Array": return "ARRAY"; + // Arrays + case "PackedByteArray": return "PACKED_BYTE_ARRAY"; + case "PackedInt32Array": return "PACKED_INT32_ARRAY"; + case "PackedInt64Array": return "PACKED_INT64_ARRAY"; + case "PackedFloat32Array": return "PACKED_FLOAT32_ARRAY"; + case "PackedFloat64Array": return "PACKED_FLOAT64_ARRAY"; + case "PackedStringArray": return "PACKED_STRING_ARRAY"; + case "PackedVector2Array": return "PACKED_VECTOR2_ARRAY"; + case "PackedVector3Array": return "PACKED_VECTOR3_ARRAY"; + case "PackedColorArray": return "PACKED_COLOR_ARRAY"; + } + RJLog_1.RJLog.error("Type could not be mapped: ", stringType); + return "OBJECT"; + } +} +exports.GodotTypes = GodotTypes; +//# sourceMappingURL=GodotTypes.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/GodotTypes.js.map b/rokojori-cpp-generator/builds/cpp-creation/GodotTypes.js.map new file mode 100644 index 0000000..8221f1e --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/GodotTypes.js.map @@ -0,0 +1 @@ +{"version":3,"file":"GodotTypes.js","sourceRoot":"","sources":["../../source/cpp-creation/GodotTypes.ts"],"names":[],"mappings":";;;AAAA,4CAAyC;AAEzC,MAAa,UAAU;IAErB,MAAM,CAAC,oBAAoB,CAAE,UAAiB;QAE5C,QAAS,UAAU,EACnB,CAAC;YACC,KAAK,MAAM,CAAC;YAAC,KAAK,WAAW;gBAC7B,OAAO,yBAAy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AC;YACzC,KAAK,YAAY,CAAC,CAAC,OAAO,YAAY,CAAC;YAEvC,gBAAgB;YAChB,KAAK,OAAO,CAAC,CAAC,OAAO,OAAO,CAAC;YAC7B,KAAK,KAAK,CAAC,CAAC,OAAO,KAAK,CAAC;YACzB,KAAK,QAAQ,CAAC,CAAC,OAAO,QAAQ,CAAC;YAC/B,KAAK,UAAU,CAAC,CAAC,OAAO,UAAU,CAAC;YACnC,KAAK,QAAQ,CAAC,CAAC,OAAO,QAAQ,CAAC;YAC/B,KAAK,YAAY,CAAC,CAAC,OAAO,aAAa,CAAC;YACxC,KAAK,UAAU,CAAC,CAAC,OAAO,WAAW,CAAC;YACpC,KAAK,YAAY,CAAC,CAAC,OAAO,YAAY,CAAC;YACvC,KAAK,OAAO,CAAC,CAAC,OAAO,OAAO,CAAC;YAE7B,SAAS;YACT,KAAK,iBAAiB,CAAC,CAAC,OAAO,mBAAmB,CAAC;YACnD,KAAK,kBAAkB,CAAC,CAAC,OAAO,oBAAoB,CAAC;YACrD,KAAK,kBAAkB,CAAC,CAAC,OAAO,oBAAoB,CAAC;YACrD,KAAK,oBAAoB,CAAC,CAAC,OAAO,sBAAsB,CAAC;YACzD,KAAK,oBAAoB,CAAC,CAAC,OAAO,sBAAsB,CAAC;YACzD,KAAK,mBAAmB,CAAC,CAAC,OAAO,qBAAqB,CAAC;YACvD,KAAK,oBAAoB,CAAC,CAAC,OAAO,sBAAsB,CAAC;YACzD,KAAK,oBAAoB,CAAC,CAAC,OAAO,sBAAsB,CAAC;YACzD,KAAK,kBAAkB,CAAC,CAAC,OAAO,oBAAoB,CAAC;QACvD,CAAC;QAED,aAAK,CAAC,KAAK,CAAE,4BAA4B,EAAE,UAAU,CAAE,CAAC;QAExD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AA1ED,gCA0EC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/Header.js b/rokojori-cpp-generator/builds/cpp-creation/Header.js new file mode 100644 index 0000000..72f9b9d --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/Header.js @@ -0,0 +1,43 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Header = void 0; +class Header { + static create(className, extendingClassName, headerDefine, protectedMembers, publicMembers, includes, forwardDeclarations) { + let cppHeader = ` +/* ${className}.h */ + +#ifndef ${headerDefine} +#define ${headerDefine} + +${includes} + +${forwardDeclarations} + + +class ${className} : public ${extendingClassName} +{ + GDCLASS( ${className}, ${extendingClassName} ); + +protected: + static void _bind_methods(); + ${protectedMembers} + +public: + + ${publicMembers} + + // Constructor + ${className}(); + + // Destructor + ~${className}(); +}; + + +#endif // ${headerDefine} +`; + return cppHeader; + } +} +exports.Header = Header; +//# sourceMappingURL=Header.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/Header.js.map b/rokojori-cpp-generator/builds/cpp-creation/Header.js.map new file mode 100644 index 0000000..6e7f243 --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/Header.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Header.js","sourceRoot":"","sources":["../../source/cpp-creation/Header.ts"],"names":[],"mappings":";;;AAAA,MAAa,MAAM;IAEjB,MAAM,CAAC,MAAM,CAAE,SAAgB,EAAE,kBAAyB,EACzC,YAAmB,EAAE,gBAAuB,EAC5C,aAAoB,EAAE,QAAe,EACrC,mBAA0B;QAGzC,IAAI,SAAS,GAEjB;KACK,SAAS;;UAEJ,YAAY;UACZ,YAAY;;EAEpB,QAAQ;;EAER,mBAAmB;;;QAGb,SAAS,aAAa,kBAAkB;;aAEnC,SAAS,KAAK,kBAAkB;;;;IAIzC,gBAAgB;;;;IAIhB,aAAa;;;IAGb,SAAS;;;KAGR,SAAS;;;;YAIF,YAAY;CACvB,CAAA;QAEG,OAAO,SAAS,CAAC;IAGnB,CAAC;CAEF;AAjDD,wBAiDC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/Implementation.js b/rokojori-cpp-generator/builds/cpp-creation/Implementation.js new file mode 100644 index 0000000..fba62c3 --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/Implementation.js @@ -0,0 +1,36 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Implementation = void 0; +class Implementation { + static craete(className, boundMethods, constructorExpressions, destructorExpressions, methodImplementations) { + let cppImplementation = ` +/* ${className}.cpp */ + +#include "${className}.h" + +// Registers fields, signals and methods for Godot +void ${className}::_bind_methods() +{ + ${boundMethods} +} + +// Constructor +${className}::${className}() +{ + ${constructorExpressions} +} + +// Destructor +${className}::~${className}() +{ + ${destructorExpressions} +} + +${methodImplementations} + +`; + return cppImplementation; + } +} +exports.Implementation = Implementation; +//# sourceMappingURL=Implementation.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/Implementation.js.map b/rokojori-cpp-generator/builds/cpp-creation/Implementation.js.map new file mode 100644 index 0000000..f776d80 --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/Implementation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Implementation.js","sourceRoot":"","sources":["../../source/cpp-creation/Implementation.ts"],"names":[],"mappings":";;;AACA,MAAa,cAAc;IAGzB,MAAM,CAAC,MAAM,CAAE,SAAgB,EAAE,YAAmB,EACrC,sBAA6B,EAAE,qBAA4B,EAC3D,qBAA4B;QAGzC,IAAI,iBAAiB,GACzB;KACK,SAAS;;YAEF,SAAS;;;OAGd,SAAS;;IAEZ,YAAY;;;;EAId,SAAS,KAAK,SAAS;;IAErB,sBAAsB;;;;EAIxB,SAAS,MAAM,SAAS;;IAEtB,qBAAqB;;;EAGvB,qBAAqB;;CAEtB,CAAA;QAEG,OAAO,iBAAiB,CAAC;IAE3B,CAAC;CAEF;AAxCD,wCAwCC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/MemberFactory.js b/rokojori-cpp-generator/builds/cpp-creation/MemberFactory.js new file mode 100644 index 0000000..20b93ae --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/MemberFactory.js @@ -0,0 +1,98 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.MemberFactory = void 0; +const MemberInitializer_1 = require("./MemberInitializer"); +const Method_1 = require("./members/Method"); +const Field_1 = require("./members/Field"); +const Signal_1 = require("./members/Signal"); +class MemberFactory { + static grabMembers(membersData, accessModifier) { + let members = []; + if (!membersData) { + return members; + } + for (let it in membersData) { + if (!membersData.hasOwnProperty(it)) { + continue; + } + let nameDefinition = it; + let memberData = membersData[it]; + if (MemberFactory.actionRegex.test(nameDefinition)) { + let name = MemberFactory.actionRegex.exec(nameDefinition)[1]; + let upperCaseName = name[0].toUpperCase() + name.substring(1); + let actionName = `on${upperCaseName}`; + let signal = `signal ${name}()`; + members.push(MemberFactory.create(accessModifier, signal, {})); + members.push(MemberFactory.create(accessModifier, actionName, "Node")); + } + else if (MemberFactory.propertyRegex.test(nameDefinition)) { + let result = MemberFactory.propertyRegex.exec(nameDefinition); + let signalName = result[1]; + let fieldName = result[2]; + signalName = signalName || `${fieldName}Changed`; + let upperCaseName = signalName[0].toUpperCase() + signalName.substring(1); + let actionName = `on${upperCaseName}`; + let signal = `signal ${signalName}()`; + if (!result[1]) { + members.push(MemberFactory.create(accessModifier, signal, {})); + members.push(MemberFactory.create(accessModifier, actionName, "Node")); + } + let field = MemberFactory.create(accessModifier, fieldName, memberData); + field.isProperty = true; + field.propertySignalName = signalName; + field.propertyActionName = actionName; + members.push(field); + } + else { + let classMember = MemberFactory.create(accessModifier, nameDefinition, memberData); + members.push(classMember); + } + } + return members; + } + static create(accessModifier, nameDefinition, body) { + let memberInitializer = new MemberInitializer_1.MemberInitializer(); + if (nameDefinition.indexOf("()") != -1) { + memberInitializer.isMethod = true; + memberInitializer.isVirtual = true; + let typeRegex = /\(\)\s*(?:\:\s*(.+)\s*)?$/; + let result = typeRegex.exec(nameDefinition); + if (result[1]) { + memberInitializer.type = result[1]; + } + nameDefinition = nameDefinition.replace(typeRegex, ""); + } + let names = nameDefinition.split(/\s+/); + memberInitializer.name = names[names.length - 1]; + for (let i = 0; i < names.length - 1; i++) { + if ("final" === names[i]) { + memberInitializer.isVirtual = false; + } + if ("static" === names[i]) { + memberInitializer.isStatic = true; + } + if ("signal" === names[i]) { + memberInitializer.isSignal = true; + } + } + let member = null; + if (memberInitializer.isMethod) { + if (memberInitializer.isSignal) { + member = new Signal_1.Signal(memberInitializer); + } + else { + member = new Method_1.Method(memberInitializer); + } + } + else { + member = new Field_1.Field(memberInitializer); + } + member.accessModifier = accessModifier; + member.parseBody(body); + return member; + } +} +exports.MemberFactory = MemberFactory; +MemberFactory.actionRegex = /^\s*action\s+(\w+)\s*$/; +MemberFactory.propertyRegex = /^\s*property(?:\s*\@\s*(\w+))?\s+(\w+)\s*$/; +//# sourceMappingURL=MemberFactory.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/MemberFactory.js.map b/rokojori-cpp-generator/builds/cpp-creation/MemberFactory.js.map new file mode 100644 index 0000000..bdfe13d --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/MemberFactory.js.map @@ -0,0 +1 @@ +{"version":3,"file":"MemberFactory.js","sourceRoot":"","sources":["../../source/cpp-creation/MemberFactory.ts"],"names":[],"mappings":";;;AACA,2DAAwD;AACxD,6CAA0C;AAC1C,2CAAwC;AACxC,6CAA0C;AAG1C,MAAa,aAAa;IAKxB,MAAM,CAAC,WAAW,CAAE,WAAe,EAAE,cAAqB;QAExD,IAAI,OAAO,GAAY,EAAE,CAAC;QAE1B,IAAK,CAAE,WAAW,EAClB,CAAC;YACC,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,KAAM,IAAI,EAAE,IAAI,WAAW,EAC3B,CAAC;YACC,IAAK,CAAE,WAAW,CAAC,cAAc,CAAE,EAAE,CAAE,EACvC,CAAC;gBACC,SAAS;YACX,CAAC;YAED,IAAI,cAAc,GAAG,EAAE,CAAC;YACxB,IAAI,UAAU,GAAG,W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sCAgJC;AA9IiB,yBAAW,GAAG,wBAAwB,CAAC;AACvC,2BAAa,GAAG,4CAA4C,CAAC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/MemberInitializer.js b/rokojori-cpp-generator/builds/cpp-creation/MemberInitializer.js new file mode 100644 index 0000000..6f05330 --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/MemberInitializer.js @@ -0,0 +1,16 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.MemberInitializer = void 0; +class MemberInitializer { + constructor() { + this.accessModifier = ""; + this.type = "void"; + this.name = ""; + this.isVirtual = true; + this.isSignal = false; + this.isMethod = false; + this.isStatic = false; + } +} +exports.MemberInitializer = MemberInitializer; +//# sourceMappingURL=MemberInitializer.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/MemberInitializer.js.map b/rokojori-cpp-generator/builds/cpp-creation/MemberInitializer.js.map new file mode 100644 index 0000000..8b8918e --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/MemberInitializer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"MemberInitializer.js","sourceRoot":"","sources":["../../source/cpp-creation/MemberInitializer.ts"],"names":[],"mappings":";;;AACA,MAAa,iBAAiB;IAA9B;QAEE,mBAAc,GAAG,EAAE,CAAC;QACpB,SAAI,GAAG,MAAM,CAAC;QACd,SAAI,GAAG,EAAE,CAAC;QAEV,cAAS,GAAG,IAAI,CAAC;QACjB,aAAQ,GAAI,KAAK,CAAC;QAClB,aAAQ,GAAI,KAAK,CAAC;QAClB,aAAQ,GAAI,KAAK,CAAC;IACpB,CAAC;CAAA;AAVD,8CAUC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/MemberType.js b/rokojori-cpp-generator/builds/cpp-creation/MemberType.js new file mode 100644 index 0000000..37d7d16 --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/MemberType.js @@ -0,0 +1,10 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.MemberType = void 0; +var MemberType; +(function (MemberType) { + MemberType[MemberType["Field"] = 0] = "Field"; + MemberType[MemberType["Method"] = 1] = "Method"; + MemberType[MemberType["Signal"] = 2] = "Signal"; +})(MemberType || (exports.MemberType = MemberType = {})); +//# sourceMappingURL=MemberType.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/MemberType.js.map b/rokojori-cpp-generator/builds/cpp-creation/MemberType.js.map new file mode 100644 index 0000000..aaf7cf9 --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/MemberType.js.map @@ -0,0 +1 @@ +{"version":3,"file":"MemberType.js","sourceRoot":"","sources":["../../source/cpp-creation/MemberType.ts"],"names":[],"mappings":";;;AAAA,IAAY,UAKX;AALD,WAAY,UAAU;IAEpB,6CAAK,CAAA;IACL,+CAAM,CAAA;IACN,+CAAM,CAAA;AACR,CAAC,EALW,UAAU,0BAAV,UAAU,QAKrB"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/Parameter.js b/rokojori-cpp-generator/builds/cpp-creation/Parameter.js new file mode 100644 index 0000000..2c618b1 --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/Parameter.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Parameter = void 0; +class Parameter { + constructor() { + this.name = ""; + this.type = ""; + } + get() { + return `${this.type} ${this.name}`; + } +} +exports.Parameter = Parameter; +//# sourceMappingURL=Parameter.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/Parameter.js.map b/rokojori-cpp-generator/builds/cpp-creation/Parameter.js.map new file mode 100644 index 0000000..49b9e00 --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/Parameter.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Parameter.js","sourceRoot":"","sources":["../../source/cpp-creation/Parameter.ts"],"names":[],"mappings":";;;AAAA,MAAa,SAAS;IAAtB;QAEE,SAAI,GAAG,EAAE,CAAC;QACV,SAAI,GAAG,EAAE,CAAC;IAMZ,CAAC;IAJC,GAAG;QAED,OAAO,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;IACrC,CAAC;CACF;AATD,8BASC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/TypeRegistration.js b/rokojori-cpp-generator/builds/cpp-creation/TypeRegistration.js new file mode 100644 index 0000000..51498c9 --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/TypeRegistration.js @@ -0,0 +1,46 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.TypeRegistration = void 0; +const Files_1 = require("../library/Files"); +const CppCreator_1 = require("./CppCreator"); +class TypeRegistration { + static createRegistrations() { + return __awaiter(this, void 0, void 0, function* () { + let registrationImplementation = yield Files_1.Files.loadUTF8(CppCreator_1.CppCreator.registerTypesPath); + let allFiles = yield Files_1.Files.getFiles(CppCreator_1.CppCreator.outputPath); + let filter = (file) => { + if (TypeRegistration.exceptions.indexOf(file) !== -1) { + return false; + } + return file.endsWith(".h") && file != "register_types.h"; + }; + let headers = allFiles.filter(file => filter(file)); + let includeStatements = headers.map(h => `#include "./${h}"`); + let includes = includeStatements.join("\n"); + registrationImplementation = + registrationImplementation.replace(TypeRegistration.includesRegex, includes); + let classNames = headers.map(h => h.replace(/\.h$/, "")); + let registrators = classNames.map(cn => `ClassDB::register_class<${cn}>();`); + let registrations = registrators.join("\n "); + registrationImplementation = + registrationImplementation.replace(TypeRegistration.classDBRegistrationsRegex, registrations); + yield Files_1.Files.saveUTF8(CppCreator_1.CppCreator.registerTypesPathOutput, registrationImplementation); + }); + } +} +exports.TypeRegistration = TypeRegistration; +TypeRegistration.includesRegex = /\/\*INCLUDES\*\//; +TypeRegistration.classDBRegistrationsRegex = /\/\*CLASS-DB-REGISTRATIONS\*\//; +TypeRegistration.exceptions = [ + "RJGodotHeaders.h" +]; +//# sourceMappingURL=TypeRegistration.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/TypeRegistration.js.map b/rokojori-cpp-generator/builds/cpp-creation/TypeRegistration.js.map new file mode 100644 index 0000000..e0890f7 --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/TypeRegistration.js.map @@ -0,0 +1 @@ +{"version":3,"file":"TypeRegistration.js","sourceRoot":"","sources":["../../source/cpp-creation/TypeRegistration.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAAyC;AACzC,6CAA0C;AAE1C,MAAa,gBAAgB;IAU3B,MAAM,CAAO,mBAAmB;;YAE9B,IAAI,0BAA0B,GAAG,MAAM,aAAK,CAAC,QAAQ,CAAE,uBAAU,CAAC,iBAAiB,CAAE,CAAC;YACtF,IAAI,QAAQ,GAAG,MAAM,aAAK,CAAC,QAAQ,CAAE,uBAAU,CAAC,UAAU,CAAE,CAAC;YAC7D,IAAI,MAAM,GAAG,CAAE,IAAW,EAAG,EAAE;gBAE7B,IAAK,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAE,IAAI,CAAE,KAAK,CAAC,CAAC,EACvD,CAAC;oBACC,OAAO,KAAK,CAAC;gBACf,CAAC;gBAED,OAAO,IAAI,CAAC,QAAQ,CAAE,IAAI,CAAE,IAAI,IAAI,IAAI,kBAAkB,CAAC;YAC7D,CAAC,CAAC;YAEF,IAAI,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAE,IAAI,CAAC,EAAE,CAAC,MAAM,CAAE,IAAI,CAAE,CAAE,CAAC;YAExD,IAAI,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAE,CAAC,CAAC,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;YAC/D,IAAI,QAAQ,GAAG,iBAAiB,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;YAE9C,0BAA0B;gBACxB,0BAA0B,CAAC,OAAO,CAAE,gBAAgB,CAAC,aAAa,EAAE,QAAQ,CAAE,CAAC;YAEjF,IAAI,UAAU,GAAG,OAAO,CAAC,GAAG,CAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAE,MAAM,EAAE,EAAE,CAAE,CAAE,CAAC;YAC7D,IAAI,YAAY,GAAG,UAAU,CAAC,GAAG,CAAE,EAAE,CAAC,EAAE,CAAC,2BAA2B,EAAE,MAAM,CAAC,CAAA;YAE7E,IAAI,aAAa,GAAG,YAAY,CAAC,IAAI,CAAE,MAAM,CAAE,CAAC;YAChD,0BAA0B;gBACxB,0BAA0B,CAAC,OAAO,CAAE,gBAAgB,CAAC,yBAAyB,EAAE,aAAa,CAAE,CAAC;YAElG,MAAM,aAAK,CAAC,QAAQ,CAAE,uBAAU,CAAC,uBAAuB,EAAE,0BAA0B,CAAE,CAAC;QAEzF,CAAC;KAAA;;AAzCH,4CA0CC;AAxCQ,8BAAa,GAAG,kBAAkB,CAAC;AACnC,0CAAyB,GAAG,gCAAgC,CAAC;AAE7D,2BAAU,GACjB;IACE,kBAAkB;CACnB,CAAC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/VariationTemplates.js b/rokojori-cpp-generator/builds/cpp-creation/VariationTemplates.js new file mode 100644 index 0000000..5d8f1f2 --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/VariationTemplates.js @@ -0,0 +1,25 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.VariationTemplates = void 0; +class VariationTemplates { +} +exports.VariationTemplates = VariationTemplates; +VariationTemplates.genericOnlyIntNode = [ + { + "{DataTypeName}": ["Int"], + "{DataType}": ["int"], + "{Extension}": [""], + "{ParentClass}": ["Node"] + } +]; +VariationTemplates.generic = [ + { + "{DataTypeName}": ["Bool", "Float", "Int", "Color", "Vector2", "Vector3", "Quaternion", "String", "Node", "Resource"], + "{DataType}": ["bool", "float", "int", "Color", "Vector2", "Vector3", "Quaternion", "String", "Ref", "Ref"] + }, + { + "{Extension}": ["", "Global"], + "{ParentClass}": ["Node", "Resource"] + } +]; +//# sourceMappingURL=VariationTemplates.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/VariationTemplates.js.map b/rokojori-cpp-generator/builds/cpp-creation/VariationTemplates.js.map new file mode 100644 index 0000000..ce69dae --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/VariationTemplates.js.map @@ -0,0 +1 @@ +{"version":3,"file":"VariationTemplates.js","sourceRoot":"","sources":["../../source/cpp-creation/VariationTemplates.ts"],"names":[],"mappings":";;;AAKA,MAAa,kBAAkB;;AAA/B,gDAyBC;AAvBiB,qCAAkB,GAClC;IACE;QACE,gBAAgB,EAAC,CAAE,KAAK,CAAE;QAC1B,YAAY,EAAK,CAAE,KAAK,CAAE;QAC1B,aAAa,EAAI,CAAE,EAAE,CAAE;QACvB,eAAe,EAAI,CAAE,MAAM,CAAE;KAE9B;CACF,CAAC;AAEc,0BAAO,GACvB;IACE;QACE,gBAAgB,EAAC,CAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAE;QACtH,YAAY,EAAK,CAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,CAAE;KACjI;IAED;QACE,aAAa,EAAI,CAAM,EAAE,EAAE,QAAQ,CAAE;QACrC,eAAe,EAAE,CAAE,MAAM,EAAE,UAAU,CAAE;KACxC;CACF,CAAC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/Variations.js b/rokojori-cpp-generator/builds/cpp-creation/Variations.js new file mode 100644 index 0000000..0849e52 --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/Variations.js @@ -0,0 +1,77 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Variations = void 0; +class Variations { + constructor(vds) { + this._indicies = []; + this._lengths = []; + this._items = 1; + this._counter = 0; + this._map = new Map(); + this._variationDefinitions = vds; + this._items = 1; + vds.forEach(vd => { + this._indicies.push(0); + let length = -1; + for (let it in vd) { + if (length != -1 || !vd.hasOwnProperty(it)) { + continue; + } + length = vd[it].length; + } + this._lengths.push(length); + this._items *= length; + }); + console.log("Found items:", this._items); + this._grabCurrentMap(); + } + _grabCurrentMap() { + this._map.clear(); + for (let i = 0; i < this._indicies.length; i++) { + this._grabItems(i); + } + } + get hasItems() { + return this._counter <= this._items; + } + get items() { + return this._items; + } + get counter() { + return this._counter; + } + nextItem() { + this._counter++; + this._incrementCounter(0); + this._grabCurrentMap(); + // RJLog.log( this._counter, this._indicies, this.currentMap ); + } + _incrementCounter(position) { + let value = this._indicies[position]; + if (value == (this._lengths[position] - 1)) { + this._indicies[position] = 0; + this._incrementCounter(position + 1); + } + else { + this._indicies[position]++; + } + } + _grabItems(index) { + let counter = this._indicies[index]; + let vd = this._variationDefinitions[index]; + let map = this._map; + for (let it in vd) { + if (!vd.hasOwnProperty(it)) { + continue; + } + let key = it; + let values = vd[it]; + map.set(key, values[counter]); + } + } + get currentMap() { + return this._map; + } +} +exports.Variations = Variations; +//# sourceMappingURL=Variations.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/Variations.js.map b/rokojori-cpp-generator/builds/cpp-creation/Variations.js.map new file mode 100644 index 0000000..63c7028 --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/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AC;YACb,IAAI,MAAM,GAAG,EAAE,CAAE,EAAE,CAAE,CAAC;YAEtB,GAAG,CAAC,GAAG,CAAE,GAAG,EAAE,MAAM,CAAE,OAAO,CAAE,CAAE,CAAC;QACpC,CAAC;IACH,CAAC;IAED,IAAI,UAAU;QAEZ,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;CACF;AAvHD,gCAuHC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/factories/ActionFactory.js b/rokojori-cpp-generator/builds/cpp-creation/factories/ActionFactory.js new file mode 100644 index 0000000..1dd48fe --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/factories/ActionFactory.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ActionFactory = void 0; +const BaseFactory_1 = require("./BaseFactory"); +class ActionFactory extends BaseFactory_1.BaseFactory { + constructor() { super(ActionFactory.regex); } + create(accessModifier, nameDefinition, memberData, members) { + let name = ActionFactory.regex.exec(nameDefinition)[1]; + let upperCaseName = name[0].toUpperCase() + name.substring(1); + let actionName = `on${upperCaseName}`; + let signal = `signal ${name}()`; + members.push(this.createMember(accessModifier, signal, {})); + members.push(this.createMember(accessModifier, actionName, "Node")); + } +} +exports.ActionFactory = ActionFactory; +ActionFactory.regex = /^\s*action\s+(\w+)\s*$/; +//# sourceMappingURL=ActionFactory.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/factories/ActionFactory.js.map b/rokojori-cpp-generator/builds/cpp-creation/factories/ActionFactory.js.map new file mode 100644 index 0000000..46af0fe --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/factories/ActionFactory.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ActionFactory.js","sourceRoot":"","sources":["../../../source/cpp-creation/factories/ActionFactory.ts"],"names":[],"mappings":";;;AACA,+CAA4C;AAE5C,MAAa,aAAc,SAAQ,yBAAW;IAI5C,gBAAe,KAAK,CAAE,aAAa,CAAC,KAAK,CAAE,CAAC,CAAC,CAAC;IAE9C,MAAM,CAAE,cAAqB,EAAE,cAAqB,EAAE,UAAc,EAAE,OAAgB;QAEpF,IAAI,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,IAAI,CAAE,cAAc,CAAE,CAAE,CAAC,CAAE,CAAC;QAC3D,IAAI,aAAa,GAAG,IAAI,CAAE,CAAC,CAAE,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,SAAS,CAAE,CAAC,CAAE,CAAC;QAClE,IAAI,UAAU,GAAG,KAAK,aAAa,EAAE,CAAC;QAEtC,IAAI,MAAM,GAAG,UAAU,IAAI,IAAI,CAAC;QAEhC,OAAO,CAAC,IAAI,CAAE,IAAI,CAAC,YAAY,CAAE,cAAc,EAAE,MAAM,EAAE,EAAE,CAAE,CAAE,CAAC;QAChE,OAAO,CAAC,IAAI,CAAE,IAAI,CAAC,YAAY,CAAE,cAAc,EAAE,UAAU,EAAE,gBAAgB,CAAE,CAAE,CAAC;IACpF,CAAC;;AAhBH,sCAiBC;AAfiB,mBAAK,GAAG,wBAAwB,CAAC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/factories/BaseFactory.js b/rokojori-cpp-generator/builds/cpp-creation/factories/BaseFactory.js new file mode 100644 index 0000000..7751c78 --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/factories/BaseFactory.js @@ -0,0 +1,61 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.BaseFactory = void 0; +const MemberInitializer_1 = require("../MemberInitializer"); +const Field_1 = require("../members/Field"); +const Method_1 = require("../members/Method"); +const Signal_1 = require("../members/Signal"); +class BaseFactory { + constructor(regex) { + this._regex = regex; + } + handles(nameDefinition) { + return this._regex.test(nameDefinition); + } + createMember(accessModifier, nameDefinition, body) { + return BaseFactory.createMemberFrom(accessModifier, nameDefinition, body); + } + static createMemberFrom(accessModifier, nameDefinition, body) { + let memberInitializer = new MemberInitializer_1.MemberInitializer(); + if (nameDefinition.indexOf("()") != -1) { + memberInitializer.isMethod = true; + memberInitializer.isVirtual = true; + let typeRegex = /\(\)\s*(?:\:\s*(.+)\s*)?$/; + let result = typeRegex.exec(nameDefinition); + if (result[1]) { + memberInitializer.type = result[1]; + } + nameDefinition = nameDefinition.replace(typeRegex, ""); + } + let names = nameDefinition.split(/\s+/); + memberInitializer.name = names[names.length - 1]; + for (let i = 0; i < names.length - 1; i++) { + if ("final" === names[i]) { + memberInitializer.isVirtual = false; + } + if ("static" === names[i]) { + memberInitializer.isStatic = true; + } + if ("signal" === names[i]) { + memberInitializer.isSignal = true; + } + } + let member = null; + if (memberInitializer.isMethod) { + if (memberInitializer.isSignal) { + member = new Signal_1.Signal(memberInitializer); + } + else { + member = new Method_1.Method(memberInitializer); + } + } + else { + member = new Field_1.Field(memberInitializer); + } + member.accessModifier = accessModifier; + member.parseBody(body); + return member; + } +} +exports.BaseFactory = BaseFactory; +//# sourceMappingURL=BaseFactory.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/factories/BaseFactory.js.map b/rokojori-cpp-generator/builds/cpp-creation/factories/BaseFactory.js.map new file mode 100644 index 0000000..dba8fb0 --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/factories/BaseFactory.js.map @@ -0,0 +1 @@ +{"version":3,"file":"BaseFactory.js","sourceRoot":"","sources":["../../../source/cpp-creation/factories/BaseFactory.ts"],"names":[],"mappings":";;;AAAA,4DAAyD;AACzD,4CAAyC;AAEzC,8CAA2C;AAC3C,8CAA2C;AAE3C,MAAsB,WAAW;IAI/B,YAAa,KAAY;QAEvB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,OAAO,CAAE,cAAqB;QAE5B,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAE,cAAc,CAAE,CAAC;IAC5C,CAAC;IAID,YAAY,CAAoB,cAAqB,EAAE,cAAqB,EAAE,IAAQ;QAEpF,OAAO,WAAW,CA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B,CAAC;gBACC,iBAAiB,CAAC,QAAQ,GAAG,IAAI,CAAC;YACpC,CAAC;QAEH,CAAC;QAED,IAAI,MAAM,GAAU,IAAI,CAAC;QAEzB,IAAK,iBAAiB,CAAC,QAAQ,EAC/B,CAAC;YACC,IAAK,iBAAiB,CAAC,QAAQ,EAC/B,CAAC;gBACC,MAAM,GAAG,IAAI,eAAM,CAAE,iBAAiB,CAAE,CAAC;YAC3C,CAAC;iBAED,CAAC;gBACC,MAAM,GAAG,IAAI,eAAM,CAAE,iBAAiB,CAAE,CAAC;YAC3C,CAAC;QAEH,CAAC;aAED,CAAC;YACC,MAAM,GAAG,IAAI,aAAK,CAAE,iBAAiB,CAAE,CAAC;QAC1C,CAAC;QAED,MAAM,CAAC,cAAc,GAAG,cAAc,CAAC;QACvC,MAAM,CAAC,SAAS,CAAE,IAAI,CAAE,CAAC;QAEzB,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAzFD,kCAyFC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/factories/MemberFactory.js b/rokojori-cpp-generator/builds/cpp-creation/factories/MemberFactory.js new file mode 100644 index 0000000..f5ee381 --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/factories/MemberFactory.js @@ -0,0 +1,84 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.MemberFactory = void 0; +const ActionFactory_1 = require("./ActionFactory"); +const PropertyFactory_1 = require("./PropertyFactory"); +const BaseFactory_1 = require("./BaseFactory"); +class MemberFactory { + static grabMembers(membersData, accessModifier) { + let members = []; + if (!membersData) { + return members; + } + for (let it in membersData) { + if (!membersData.hasOwnProperty(it)) { + continue; + } + let nameDefinition = it; + let memberData = membersData[it]; + let factory = this.factories.find(f => f.handles(nameDefinition)); + if (factory) { + factory.create(accessModifier, nameDefinition, memberData, members); + } + else { + members.push(BaseFactory_1.BaseFactory.createMemberFrom(accessModifier, nameDefinition, memberData)); + } + /* + if ( MemberFactory.actionRegex.test( nameDefinition ) ) + { + let name = MemberFactory.actionRegex.exec( nameDefinition )[ 1 ]; + let upperCaseName = name[ 0 ].toUpperCase() + name.substring( 1 ); + let actionName = `on${upperCaseName}`; + + let signal = `signal ${name}()`; + + members.push( MemberFactory.create( accessModifier, signal, {} ) ); + members.push( MemberFactory.create( accessModifier, actionName, "Node" ) ); + } + else if ( MemberFactory.propertyRegex.test( nameDefinition ) ) + { + let result = MemberFactory.propertyRegex.exec( nameDefinition ); + + let signalName = result[ 1 ]; + let fieldName = result[ 2 ]; + + signalName = signalName || `${fieldName}Changed`; + + let upperCaseName = signalName[ 0 ].toUpperCase() + signalName.substring( 1 ); + let actionName = `on${upperCaseName}`; + + let signal = `signal ${signalName}()`; + + if ( ! result[ 1 ] ) + { + members.push( MemberFactory.create( accessModifier, signal, {} ) ); + members.push( MemberFactory.create( accessModifier, actionName, "Node" ) ); + } + + let field = MemberFactory.create( accessModifier, fieldName, memberData ) as Field; + + field.isProperty = true; + field.propertySignalName = signalName; + field.propertyActionName = actionName; + + members.push( field ); + } + else + { + let classMember = MemberFactory.create( accessModifier, nameDefinition, memberData ); + members.push( classMember ); + } + + */ + } + return members; + } +} +exports.MemberFactory = MemberFactory; +MemberFactory.actionRegex = /^\s*action\s+(\w+)\s*$/; +MemberFactory.propertyRegex = /^\s*property(?:\s*\@\s*(\w+))?\s+(\w+)\s*$/; +MemberFactory.factories = [ + new ActionFactory_1.ActionFactory(), + new PropertyFactory_1.PropertyFactory() +]; +//# sourceMappingURL=MemberFactory.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/factories/MemberFactory.js.map b/rokojori-cpp-generator/builds/cpp-creation/factories/MemberFactory.js.map new file mode 100644 index 0000000..6f06916 --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/factories/MemberFactory.js.map @@ -0,0 +1 @@ +{"version":3,"file":"MemberFactory.js","sourceRoot":"","sources":["../../../source/cpp-creation/factories/MemberFactory.ts"],"names":[],"mappings":";;;AAKA,mDAAgD;AAChD,uDAAoD;AACpD,+CAA4C;AAG5C,MAAa,aAAa;IAWxB,MAAM,CAAC,WAAW,CAAE,WAAe,EAAE,cAAqB;QAExD,IAAI,OAAO,GAAY,EAAE,CAAC;QAE1B,IAAK,CAAE,WAAW,EAClB,CAAC;YACC,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,KAAM,IAAI,EAAE,IAAI,WAAW,EAC3B,CAAC;YACC,IAAK,CAAE,WAAW,CAAC,cAAc,CAAE,EAAE,CAAE,EACvC,CAAC;gBACC,SAAS;YACX,CAAC;YAED,IAAI,cAAc,GAAG,EAAE,CAAC;YACxB,IAAI,UAAU,GAAG,WAAW,CAAE,EAAE,CAAE,CAAC;YAEnC,IAAI,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAE,cAAc,CAAE,CAAE,CAAC;YAEtE,IAAK,OAAO,EACZ,CAAC;gBACC,OAAO,CAAC,MAAM,CAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,OAAO,CAAE,CAAC;YACxE,CAAC;iBAED,CAAC;gBACC,OAAO,CAAC,IAAI,CAAE,yBAAW,CAAC,gBAAgB,CAAG,cAAc,EAAE,cAAc,EAAE,UAAU,CAAE,CAAE,CAAC;YAC9F,CAAC;YAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA8CE;QAEJ,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;;AA5FH,sCAoKC;AAlKiB,yBAAW,GAAG,wBAAwB,CAAC;AACvC,2BAAa,GAAG,4CAA4C,CAAC;AAEtE,uBAAS,GAChB;IACE,IAAI,6BAAa,EAAE;IACnB,IAAI,iCAAe,EAAE;CACtB,CAAA"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/factories/PropertyFactory.js b/rokojori-cpp-generator/builds/cpp-creation/factories/PropertyFactory.js new file mode 100644 index 0000000..6345051 --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/factories/PropertyFactory.js @@ -0,0 +1,43 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PropertyFactory = void 0; +const BaseFactory_1 = require("./BaseFactory"); +class PropertyFactory extends BaseFactory_1.BaseFactory { + constructor() { super(PropertyFactory.regex); } + create(accessModifier, nameDefinition, memberData, members) { + let result = PropertyFactory.regex.exec(nameDefinition); + let fieldName = result[1]; + let upperCaseName = fieldName[0].toUpperCase() + fieldName.substring(1); + let signalName = `${fieldName}Changed`; + let upperCaseSignalName = signalName[0].toUpperCase() + signalName.substring(1); + let actionName = `on${upperCaseSignalName}`; + let signalMethodDefinition = `signal ${signalName}()`; + let field = this.createMember(accessModifier, fieldName, memberData); + field.isProperty = true; + field.propertySignalName = signalName; + field.propertyActionName = actionName; + members.push(field); + members.push(this.createMember(accessModifier, signalMethodDefinition, {})); + members.push(this.createMember(accessModifier, actionName, "Node")); + let dispatchChanged = this.createMember(accessModifier, `final dispatch${upperCaseName}Changed()`, [{}, + [ + `emit_signal( SNAME( "${signalName}" ) );`, + "", + `if ( ${actionName} != NULL )`, + "{", + ` ${actionName}->trigger();`, + "}" + ] + ]); + members.push(dispatchChanged); + let setSilent = this.createMember(accessModifier, `final set${upperCaseName}Silent()`, [{ "p_value": memberData }, + [ + "value = p_value;" + ] + ]); + members.push(setSilent); + } +} +exports.PropertyFactory = PropertyFactory; +PropertyFactory.regex = /^\s*property\s+(\w+)\s*$/; +//# sourceMappingURL=PropertyFactory.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/factories/PropertyFactory.js.map b/rokojori-cpp-generator/builds/cpp-creation/factories/PropertyFactory.js.map new file mode 100644 index 0000000..7c77309 --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/factories/PropertyFactory.js.map @@ -0,0 +1 @@ +{"version":3,"file":"PropertyFactory.js","sourceRoot":"","sources":["../../../source/cpp-creation/factories/P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,GAAG,IAAI,CAAC,YAAY,CAAE,cAAc,EAErD,iBAAiB,aAAa,WAAW,EAAE,CAAE,EAAE;YAC7C;gBACE,wBAAwB,UAAU,QAAQ;gBAC1C,EAAE;gBACF,QAAQ,UAAU,YAAY;gBAC9B,GAAG;gBACH,KAAK,UAAU,cAAc;gBAC7B,GAAG;aACJ;SACF,CACF,CAAC;QAGF,OAAO,CAAC,IAAI,CAAE,eAAe,CAAE,CAAC;QAIhC,IAAI,SAAS,GAAG,IAAI,CAAC,YAAY,CAAE,cAAc,EAE/C,YAAY,aAAa,UAAU,EAAE,CAAE,EAAE,SAAS,EAAE,UAAU,EAAC;YAC7D;gBACA,kBAAkB;aACjB;SACH,CACD,CAAC;QAEF,OAAO,CAAC,IAAI,CAAE,SAAS,CAAE,CAAC;IAE5B,CAAC;;AAnEH,0CAoEC;AAlEiB,qBAAK,GAAG,0BAA0B,CAAC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/members/Field.js b/rokojori-cpp-generator/builds/cpp-creation/members/Field.js new file mode 100644 index 0000000..0963543 --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/members/Field.js @@ -0,0 +1,129 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Field = void 0; +const GodotTypes_1 = require("../GodotTypes"); +const MemberType_1 = require("../MemberType"); +const Member_1 = require("./Member"); +class Field extends Member_1.Member { + constructor(memberInitializer) { + super(MemberType_1.MemberType.Field, memberInitializer); + this.isReference = false; + this.referenceType = ""; + this.isProperty = false; + this.propertySignalName = ""; + this.propertyActionName = ""; + } + parseBody(body) { + if (typeof body === "boolean") { + this.type = "bool"; + this.initialValue = body + ""; + return; + } + if (typeof body === "number") { + this.type = "float"; + this.initialValue = body + ""; + return; + } + let regex = /((?:\w|\<|\>)+)(?:\s*\=\s*(.+))?/; + let result = regex.exec(body); + let typeOrRefRegex = /^(Ref|Resource|Node)/; + let typeResult = result[1]; + this.isReference = typeOrRefRegex.test(typeResult); + // RJLog.log( "Is Reference", this.name, this.isReference, typeResult ); + if (this.isReference) { + this.referenceType = refRegex.test(typeResult) ? refRegex.exec(typeResult)[1] : + typeOrRefRegex.exec(typeResult)[1]; + // RJLog.log( "referenceType", body, `"${this.referenceType}"`, typeResult ); + if (Field.Node === this.referenceType) { + typeResult = typeResult.replace(typeOrRefRegex, "").replace(/>$/, ""); + typeResult = typeResult + "*"; + } + else { + typeResult = typeResult.replace(typeOrRefRegex, "Ref<"); + if (result.length >= 2) { + this.initialValue = result[2]; + } + } + } + this.type = typeResult; + this.initialValue = result[2] || null; + } + getFieldDeclaration() { + let fieldInfo = "\n " + this.info() + "\n "; + if (Field.Node === this.referenceType) { + return `${fieldInfo}${this.type} ${this.name} = nullptr;`; + } + return `${fieldInfo}${this.type} ${this.name};`; + } + getHeaderDefinition() { + let fieldInfo = "\n " + this.info() + "\n "; + if (Field.Node === this.referenceType) { + return `${fieldInfo}${this.type} get_${this.name}() const; void set_${this.name}( ${this.type} p_${this.name} );`; + } + if (Field.Resource === this.referenceType) { + return `${fieldInfo}${this.type} get_${this.name}() const; void set_${this.name}( const ${this.type} &p_${this.name} );`; + } + return `${fieldInfo}${this.type} get_${this.name}(); void set_${this.name}( ${this.type} p_${this.name} );`; + } + getBindings(className) { + let bindings = []; + bindings.push(`// ${this.name}: ${this.type}`); + bindings.push(`ClassDB::bind_method( D_METHOD( "set_${this.name}", "${this.name}" ), &${className}::set_${this.name} );`); + bindings.push(`ClassDB::bind_method( D_METHOD( "get_${this.name}"), &${className}::get_${this.name});`); + if (this.isReference) { + // ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "reference_property", PROPERTY_HINT_NODE_TYPE), "set_reference_property", "get_reference_property"); + // RJLog.log( "Searching propertyHint:", this.name, this.type, this.referenceType ); + let propertyHint = GodotTypes_1.GodotTypes.stringToPropertyHint(this.referenceType); + bindings.push(`ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "${this.name}", ${propertyHint} ), "set_${this.name}", "get_${this.name}" );`); + } + else { + let type = GodotTypes_1.GodotTypes.stringToVariantType(this.type); + bindings.push(`ADD_PROPERTY(PropertyInfo( Variant::${type}, "${this.name}" ), "set_${this.name}", "get_${this.name}" );`); + } + bindings.push(` `); + //ClassDB::bind_method(D_METHOD("set_color", "color"), &GLTFLight::set_color); + //ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color"); // Color + return bindings.join("\n "); + } + getFieldImplementation(className) { + let implementations = []; + implementations.push(`// ${this.name}: ${this.type}`); + let eventCallbacks = ""; + if (this.isProperty) { + eventCallbacks += `\n`; + eventCallbacks += `\n emit_signal( SNAME( "${this.propertySignalName}" ) );`; + eventCallbacks += `\n`; + eventCallbacks += `\n if ( ${this.propertyActionName} != NULL )`; + eventCallbacks += `\n {`; + eventCallbacks += `\n ${this.propertyActionName}->trigger();`; + eventCallbacks += `\n }`; + } + let n = this.isProperty ? "\n" : ""; + let n2 = this.isProperty ? "\n " : ""; + if (Field.Node === this.referenceType) { + implementations.push(`${this.type} ${className}::get_${this.name}() const { return ${this.name}; }`); + implementations.push(`void ${className}::set_${this.name}( ${this.type} p_${this.name} ) ${n}{${n2} ${this.name} = p_${this.name};${eventCallbacks} ${n}}`); + } + else if (Field.Resource === this.referenceType) { + implementations.push(`${this.type} ${className}::get_${this.name}() const { return ${this.name}; }`); + implementations.push(`void ${className}::set_${this.name}( const ${this.type} &p_${this.name} ) ${n}{${n2} ${this.name} = p_${this.name};${eventCallbacks} ${n}}`); + } + else { + implementations.push(`${this.type} ${className}::get_${this.name}() { return ${this.name}; }`); + implementations.push(`void ${className}::set_${this.name}( ${this.type} p_${this.name} ) ${n}{${n2} ${this.name} = p_${this.name};${eventCallbacks} ${n}}`); + } + implementations.push(` `); + return implementations.join("\n"); + } + get hasInitializer() { + return this.initialValue !== null; + } + getInitializer() { + return `${this.name} = ${this.initialValue};`; + } +} +exports.Field = Field; +Field.Node = "Node"; +Field.Resource = "Resource"; +//# sourceMappingURL=Field.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/members/Field.js.map b/rokojori-cpp-generator/builds/cpp-creation/members/Field.js.map new file mode 100644 index 0000000..2604021 --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/members/Field.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Field.js","sourceRoot":"","sources":["../../../source/cpp-creation/members/Field.ts"],"names":[],"mappings":";;;AACA,8CAA2C;AAE3C,8CAA2C;AAC3C,qCAAkC;AAElC,MAAa,KAAM,SAAQ,eAAM;IAK/B,YAAa,iBAAmC;QAE9C,KAAK,CAAE,uBAAU,CAAC,KAAK,EAAE,iBAAiB,CAAE,CAAC;QAG/C,gBAAW,GAAG,KAAK,CAAC;QACpB,kBAAa,GAAG,EAAE,CAAC;QACnB,eAAU,GAAG,KAAK,CAAC;QACnB,uBAAkB,GAAG,EAAE,CAAC;QACxB,uBAAkB,GAAG,EAAE,CAAC;IANxB,CAAC;IAQD,SAAS,CAAE,IAAQ;QAEjB,IAAK,OAAO,IAAI,KAAK,SAAS,EAC9B,CAAC;YACC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC;YACnB,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,EAAE,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,IAAK,OAAO,IAAI,KAAK,QAAQ,EAC7B,CAAC;YACC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC;YACpB,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,EAAE,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,IAAI,KAAK,GAAG,kCAAkC,CAAC;QAC/C,IAAI,MAAM,GAAG,KAAK,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;QAChC,IAAI,cAAc,GAAG,uBAAuB,CAAC;QAC7C,IAAI,QAAQ,GAAG,aAAa,CAAC;QAE7B,IAAI,UAAU,GAAG,MAAM,CAAE,CAAC,CAAE,CAAA;QAE5B,IAAI,CAAC,WAAW,GAAG,cAAc,CA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Q,SAAS,SAAS,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,MAAM,IAAI,CAAC,IAAI,MAAM,CAAC,IAAI,EAAE,IAAI,IAAI,CAAC,IAAI,QAAQ,IAAI,CAAC,IAAI,IAAI,cAAc,IAAI,CAAC,GAAG,CAAE,CAAC;QAChK,CAAC;QAED,eAAe,CAAC,IAAI,CAAE,GAAG,CAAE,CAAC;QAE5B,OAAO,eAAe,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IACtC,CAAC;IAED,IAAI,cAAc;QAEhB,OAAO,IAAI,CAAC,YAAY,KAAK,IAAI,CAAC;IACpC,CAAC;IAED,cAAc;QAEZ,OAAO,GAAG,IAAI,CAAC,IAAI,MAAM,IAAI,CAAC,YAAY,GAAG,CAAC;IAChD,CAAC;;AA7LH,sBA8LC;AA5LiB,UAAI,GAAG,MAAM,AAAT,CAAU;AACd,cAAQ,GAAG,UAAU,AAAb,CAAc"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/members/Member.js b/rokojori-cpp-generator/builds/cpp-creation/members/Member.js new file mode 100644 index 0000000..736de5b --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/members/Member.js @@ -0,0 +1,67 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Member = void 0; +const Parameter_1 = require("../Parameter"); +class Member { + constructor(memberType, memberInitializer) { + this.name = ""; + this.isMethod = false; + this.isVirtual = true; + this.isStatic = false; + this.isSignal = false; + this.type = "void"; + this.initialValue = null; + this.parameters = []; + this.accessModifier = ""; + this.parametersDefinition = ""; + this.memberType = memberType; + this.accessModifier = memberInitializer.accessModifier; + this.name = memberInitializer.name; + this.type = memberInitializer.type || this.type; + this.isMethod = memberInitializer.isMethod; + this.isSignal = memberInitializer.isSignal; + this.isStatic = memberInitializer.isStatic; + this.isVirtual = memberInitializer.isVirtual; + } + info() { + let methodBrackets = this.isMethod ? "()" : ""; + if (methodBrackets === "()" && this.parameters.length > 0) { + methodBrackets = "( " + this.parametersDefinition + " )"; + } + if (this.isSignal) { + } + return `// ${this.isSignal ? "[signal] " : ""}${this.name}${methodBrackets} : ${this.type}`; + } + setPublic() { + this.accessModifier = "public"; + return this; + } + setProtected() { + this.accessModifier = "protected"; + return this; + } + parseMethodParameters(body) { + if (!body) { + return; + } + if (typeof body === "string") { + this.type = body; + return; + } + for (let it in body) { + if (!body.hasOwnProperty(it)) { + continue; + } + let cppParameter = new Parameter_1.Parameter(); + cppParameter.name = it; + cppParameter.type = body[it]; + this.parameters.push(cppParameter); + } + this.parametersDefinition = this.parameters.map(p => p.get()).join(", "); + } + getParametersDefinition() { + return this.parameters.map(p => p.type + " " + p.name).join(", "); + } +} +exports.Member = Member; +//# sourceMappingURL=Member.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/members/Member.js.map b/rokojori-cpp-generator/builds/cpp-creation/members/Member.js.map new file mode 100644 index 0000000..94cacdb --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/members/Member.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Member.js","sourceRoot":"","sources":["../../../source/cpp-creation/members/Member.ts"],"names":[],"mappings":";;;AAGA,4CAAyC;AAGzC,MAAsB,MAAM;IAc1B,YAAa,UAAqB,EAAE,iBAAmC;QAXvE,SAAI,GAAG,EAAE,CAAC;QACV,aAAQ,GAAI,KAAK,CAAC;QAClB,cAAS,GAAG,IAAI,CAAC;QACjB,aAAQ,GAAI,KAAK,CAAC;QAClB,aAAQ,GAAI,KAAK,CAAC;QAClB,SAAI,GAAG,MAAM,CAAC;QACd,iBAAY,GAAU,IAAI,CAAC;QAC3B,eAAU,GAAe,EAAE,CAAC;QAC5B,mBAAc,GAAG,EAAE,CAAC;QACpB,yBAAoB,GAAG,EAAE,CAAC;QAIxB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAE7B,IAAI,CAAC,cAAc,GAAG,iBAAiB,CAAC,cAAc,CAAC;QACvD,IAAI,CA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YAEjB,OAAO;QACT,CAAC;QAED,KAAM,IAAI,EAAE,IAAI,IAAI,EACpB,CAAC;YACC,IAAK,CAAE,IAAI,CAAC,cAAc,CAAE,EAAE,CAAE,EAChC,CAAC;gBACC,SAAS;YACX,CAAC;YAED,IAAI,YAAY,GAAG,IAAI,qBAAS,EAAE,CAAC;YACnC,YAAY,CAAC,IAAI,GAAG,EAAE,CAAC;YACvB,YAAY,CAAC,IAAI,GAAG,IAAI,CAAE,EAAE,CAAE,CAAC;YAE/B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAE,YAAY,CAAE,CAAC;QACvC,CAAC;QAED,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAE,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IAE/E,CAAC;IAMD,uBAAuB;QAErB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,GAAG,GAAG,CAAC,CAAC,IAAI,CAAE,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IACxE,CAAC;CAsBF;AA3HD,wBA2HC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/members/Method.js b/rokojori-cpp-generator/builds/cpp-creation/members/Method.js new file mode 100644 index 0000000..a2a1351 --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/members/Method.js @@ -0,0 +1,69 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Method = void 0; +const MemberType_1 = require("../MemberType"); +const Member_1 = require("./Member"); +class Method extends Member_1.Member { + constructor(memberInitializer) { + super(MemberType_1.MemberType.Method, memberInitializer); + this.implementation = null; + } + get hasMethodImplementation() { + return this.implementation != null; + } + getMethodImplementation(className) { + let lines = []; + lines.push(this.info()); + lines.push(`${this.type} ${className}::${this.name}${this.parameterWithBrackets}`); + lines.push("{"); + this.implementation.forEach(l => lines.push(" " + l)); + lines.push("}"); + return lines.join("\n") + "\n"; + } + parseBody(body) { + if (Array.isArray(body)) { + let parameters = body[0]; + let lines = body[1]; + this.parseMethodParameters(parameters); + this.implementation = lines; + } + else { + return this.parseMethodParameters(body); + } + } + get parameterWithBrackets() { + let parameters = this.parametersDefinition === "" ? "()" : + `( ${this.parametersDefinition} )`; + return parameters; + } + getHeaderDefinition() { + let methodInfo = "\n " + this.info() + "\n "; + if (this.isVirtual) { + let numParameters = this.parameters.length; + let methodReturnType = this.type === "void" ? "" : "R"; + let returnTypeDefinition = this.type === "void" ? "" : (this.type + ", "); + let parametersDefinition = ""; + if (numParameters > 0) { + parametersDefinition = ", " + this.parameters.map(p => p.type).join(", "); + } + return `${methodInfo}GDVIRTUAL${numParameters}${methodReturnType}( ${returnTypeDefinition}${this.name}${parametersDefinition} );`; + } + let parameters = this.parameterWithBrackets; + return `${methodInfo}${this.type} ${this.name}${parameters};`; + } + getBindings(className) { + if (this.isVirtual) { + let parameterInfos = ""; + for (let i = 0; i < this.parameters.length; i++) { + let name = `, "${this.parameters[i].name}"`; + parameterInfos += name; + } + return `GDVIRTUAL_BIND( ${this.name}${parameterInfos} );`; + } + else { + return `ClassDB::bind_method( D_METHOD( "${this.name}" ) , &${className}::${this.name} );`; + } + } +} +exports.Method = Method; +//# sourceMappingURL=Method.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/members/Method.js.map b/rokojori-cpp-generator/builds/cpp-creation/members/Method.js.map new file mode 100644 index 0000000..51095ba --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/members/Method.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Method.js","sourceRoot":"","sources":["../../../source/cpp-creation/members/Method.ts"],"names":[],"mappings":";;;AAEA,8CAA2C;AAC3C,qCAAkC;AAElC,MAAa,MAAO,SAAQ,eAAM;IAEhC,YAAa,iBAAmC;QAE9C,KAAK,CAAE,uBAAU,CAAC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AAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAChD,CAAC;gBACC,IAAI,IAAI,GAAG,MAAM,IAAI,CAAC,UAAU,CAAE,CAAC,CAAE,CAAC,IAAI,GAAG,CAAC;gBAE9C,cAAc,IAAI,IAAI,CAAC;YACzB,CAAC;YAED,OAAO,mBAAmB,IAAI,CAAC,IAAI,GAAG,cAAc,KAAK,CAAC;QAC5D,CAAC;aAED,CAAC;YACC,OAAO,oCAAoC,IAAI,CAAC,IAAI,UAAU,SAAS,KAAK,IAAI,CAAC,IAAI,KAAK,CAAA;QAC5F,CAAC;IACH,CAAC;CACF;AArGD,wBAqGC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/members/Signal.js b/rokojori-cpp-generator/builds/cpp-creation/members/Signal.js new file mode 100644 index 0000000..40c3d16 --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/members/Signal.js @@ -0,0 +1,30 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Signal = void 0; +const GodotTypes_1 = require("../GodotTypes"); +const MemberType_1 = require("../MemberType"); +const Member_1 = require("./Member"); +class Signal extends Member_1.Member { + constructor(memberInitializer) { + super(MemberType_1.MemberType.Signal, memberInitializer); + } + parseBody(body) { + return this.parseMethodParameters(body); + } + getHeaderDefinition() { + return "\n " + this.info(); + } + getBindings(className) { + //ADD_SIGNAL(MethodInfo("session_supported", PropertyInfo(Variant::STRING, "session_mode"), PropertyInfo(Variant::BOOL, "supported"))); + let parameterInfos = ""; + for (let i = 0; i < this.parameters.length; i++) { + let type = GodotTypes_1.GodotTypes.stringToVariantType(this.parameters[i].type); + let name = this.parameters[i].name; + let pi = `, PropertyInfo(Variant::${type}, "${name}")`; + parameterInfos += pi; + } + return `ADD_SIGNAL (MethodInfo( "${this.name}" ${parameterInfos}) );`; + } +} +exports.Signal = Signal; +//# sourceMappingURL=Signal.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/cpp-creation/members/Signal.js.map b/rokojori-cpp-generator/builds/cpp-creation/members/Signal.js.map new file mode 100644 index 0000000..54efea8 --- /dev/null +++ b/rokojori-cpp-generator/builds/cpp-creation/members/Signal.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Signal.js","sourceRoot":"","sources":["../../../source/cpp-creation/members/Signal.ts"],"names":[],"mappings":";;;AACA,8CAA2C;AAE3C,8CAA2C;AAC3C,qCAAkC;AAElC,MAAa,MAAO,SAAQ,eAAM;IAEhC,YAAa,iBAAmC;QAE9C,KAAK,CAAE,uBAAU,CAAC,MAAM,EAAE,iBAAiB,CAAE,CAAC;IAChD,CAAC;IAED,SAAS,CAAE,IAAQ;QAEjB,OAAO,IAAI,CAAC,qBAAqB,CAAE,IAAI,CAAE,CAAC;IAC5C,CAAC;IAGD,mBAAmB;QAEjB,OAAO,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAC9B,CAAC;IAED,WAAW,CAAE,SAAgB;QAE3B,uIAAuI;QACvI,IAAI,cAAc,GAAG,EAAE,CAAC;QAExB,KAAM,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAChD,CAAC;YACC,IAAI,IAAI,GAAG,uBAAU,CAAC,mBAAmB,CAAE,IAAI,CAAC,UAAU,CAAE,CAAC,CAAE,CAAC,IAAI,CAAE,CAAC;YACvE,IAAI,IAAI,GAAG,IAAI,CAAC,UAAU,CAAE,CAAC,CAAE,CAAC,IAAI,CAAC;YAErC,IAAI,EAAE,GAAG,2BAA2B,IAAI,MAAM,IAAI,IAAI,CAAC;YAEvD,cAAc,IAAI,EAAE,CAAC;QACvB,CAAC;QAED,OAAO,4BAA4B,IAAI,CAAC,IAAI,KAAK,cAAc,MAAM,CAAC;IACxE,CAAC;CACF;AAnCD,wBAmCC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/create-cpp.js b/rokojori-cpp-generator/builds/create-cpp.js new file mode 100644 index 0000000..b3a0984 --- /dev/null +++ b/rokojori-cpp-generator/builds/create-cpp.js @@ -0,0 +1,75 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const CppCreator_1 = require("./cpp-creation/CppCreator"); +const TypeRegistration_1 = require("./cpp-creation/TypeRegistration"); +const Files_1 = require("./library/Files"); +const RJLog_1 = require("./library/RJLog"); +const Texts_1 = require("./library/Texts"); +class CreateCpp { + static main() { + return __awaiter(this, void 0, void 0, function* () { + RJLog_1.RJLog.log("Clear old cpp files"); + yield this.clearCppFiles(); + RJLog_1.RJLog.log("Generate cpp files from definitions"); + let files = yield this.getCppFiles(); + for (let file of files) { + var cppFilePath = Texts_1.Texts.joinPaths(CppCreator_1.CppCreator.definitionsPath, file); + yield CppCreator_1.CppCreator.createCppFiles(cppFilePath); + } + RJLog_1.RJLog.log("Copy raw cpp files"); + yield this.copyRaw(); + RJLog_1.RJLog.log("Register types"); + yield TypeRegistration_1.TypeRegistration.createRegistrations(); + }); + } + ; + static clearCppFiles() { + return __awaiter(this, void 0, void 0, function* () { + let allFiles = yield Files_1.Files.getFiles(CppCreator_1.CppCreator.outputPath); + let cppFiles = allFiles.filter(file => CreateCpp.cppExtensionRegex.test(file)); + for (let cppFile of cppFiles) { + let fullPath = Texts_1.Texts.joinPaths(CppCreator_1.CppCreator.outputPath, cppFile); + //RJLog.log( "deleting", fullPath ); + yield Files_1.Files.delete(fullPath); + } + }); + } + static getCppFiles() { + return __awaiter(this, void 0, void 0, function* () { + let files = yield Files_1.Files.getFiles(CppCreator_1.CppCreator.definitionsPath); + files = files.filter(f => !f.startsWith("_")); + return Promise.resolve(files); + }); + } + static copyRaw() { + return __awaiter(this, void 0, void 0, function* () { + let files = yield Files_1.Files.getFilesRecursive(CppCreator_1.CppCreator.rawPath); + for (let i = 0; i < files.length; i++) { + let fileName = Texts_1.Texts.fileName(files[i]); + if (fileName.startsWith("_") || !CreateCpp.cppExtensionRegex.test(fileName)) { + continue; + } + let fullPath = Texts_1.Texts.joinPaths(CppCreator_1.CppCreator.rawPath, files[i]); + let isDirectory = yield Files_1.Files.isDirectory(fullPath); + if (isDirectory) { + continue; + } + let outputFullPath = Texts_1.Texts.joinPaths(CppCreator_1.CppCreator.outputPath, fileName); + // RJLog.log( "copying:", fileName, "\n" + fullPath, "\n", outputFullPath ); + yield Files_1.Files.copy(fullPath, outputFullPath); + } + }); + } +} +CreateCpp.cppExtensionRegex = /\.(h|cpp)$/; +CreateCpp.main(); +//# sourceMappingURL=create-cpp.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/create-cpp.js.map b/rokojori-cpp-generator/builds/create-cpp.js.map new file mode 100644 index 0000000..ae52752 --- /dev/null +++ b/rokojori-cpp-generator/builds/create-cpp.js.map @@ -0,0 +1 @@ +{"version":3,"file":"create-cpp.js","sourceRoot":"","sources":["../source/create-cpp.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,0DAAuD;AACvD,sEAAmE;AACnE,2CAAwC;AAExC,2CAAwC;AACxC,2CAAwC;AAExC,MAAM,SAAS;IAEb,MAAM,CAAO,IAAI;;YAEf,aAAK,CAAC,GAAG,CAAE,qBAAqB,CAAE,CAAC;YACnC,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;YAE3B,aAAK,CAAC,GAAG,CAAE,qCAAqC,CAAE,CAAC;YACnD,IAAI,KAAK,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;YAErC,KAAM,IAAI,IAAI,IAAI,KAAK,EACvB,CAA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,GAAG,MAAM,aAAK,CAAC,iBAAiB,CAAE,uBAAU,CAAC,OAAO,CAAE,CAAC;YAEhE,KAAM,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EACtC,CAAC;gBACC,IAAI,QAAQ,GAAG,aAAK,CAAC,QAAQ,CAAE,KAAK,CAAE,CAAC,CAAE,CAAE,CAAC;gBAE5C,IAAK,QAAQ,CAAC,UAAU,CAAE,GAAG,CAAE,IAAI,CAAE,SAAS,CAAC,iBAAiB,CAAC,IAAI,CAAE,QAAQ,CAAE,EACjF,CAAC;oBACC,SAAS;gBACX,CAAC;gBAED,IAAI,QAAQ,GAAG,aAAK,CAAC,SAAS,CAAE,uBAAU,CAAC,OAAO,EAAE,KAAK,CAAE,CAAC,CAAE,CAAE,CAAC;gBACjE,IAAI,WAAW,GAAG,MAAM,aAAK,CAAC,WAAW,CAAE,QAAQ,CAAE,CAAC;gBAEtD,IAAK,WAAW,EAChB,CAAC;oBACC,SAAS;gBACX,CAAC;gBAED,IAAI,cAAc,GAAG,aAAK,CAAC,SAAS,CAAE,uBAAU,CAAC,UAAU,EAAE,QAAQ,CAAE,CAAC;gBAExE,4EAA4E;gBAE5E,MAAM,aAAK,CAAC,IAAI,CAAE,QAAQ,EAAE,cAAc,CAAE,CAAC;YAE/C,CAAC;QACH,CAAC;KAAA;;AArDM,2BAAiB,GAAG,YAAY,CAAC;AAwD1C,SAAS,CAAC,IAAI,EAAE,CAAC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/create-output.js b/rokojori-cpp-generator/builds/create-output.js new file mode 100644 index 0000000..da6abad --- /dev/null +++ b/rokojori-cpp-generator/builds/create-output.js @@ -0,0 +1,77 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const RJLog_1 = require("./library/RJLog"); +const { argv } = require("process"); +const path = require("path"); +const fs = require("node:fs/promises"); +const { exists } = require("./library.js"); +let targetDirectory = "outputs"; +let godotName = "godot-4.3-dev-rokojori"; +let platform = "argv[ 2 ]"; +let godotPlatformName = godotName + "-" + "argv[ 2 ]"; +let platformTargetDirectory = path.join(targetDirectory, godotPlatformName); +function main() { + return __awaiter(this, void 0, void 0, function* () { + if (argv.length !== 3) { + let platforms = ["windows"]; + console.error("Platform missing in the command. Add one of these to the command line:", platforms.join(", ")); + return; + } + platform = argv[2]; + godotPlatformName = godotName + "-" + argv[2]; + platformTargetDirectory = path.join(targetDirectory, godotPlatformName); + RJLog_1.RJLog.log("Creating output"); + yield deleteOldDirectory(); + yield createDirectory(); + RJLog_1.RJLog.log("Output done"); + }); +} +function deleteOldDirectory() { + return __awaiter(this, void 0, void 0, function* () { + let directoryExists = yield exists(platformTargetDirectory); + RJLog_1.RJLog.log("checking if old directory exists", directoryExists); + if (directoryExists) { + RJLog_1.RJLog.log(`deleting previous directory: "${platformTargetDirectory}"`); + yield fs.rm(platformTargetDirectory, { recursive: true }); + } + return Promise.resolve(); + }); +} +function createDirectory() { + return __awaiter(this, void 0, void 0, function* () { + RJLog_1.RJLog.log(`creating directory: "${platformTargetDirectory}"`); + yield fs.mkdir(platformTargetDirectory, { recursive: true }); + let godotFrom = "godot/bin"; + let godotTo = path.join(platformTargetDirectory, "godot"); + RJLog_1.RJLog.log(`copying godot: "${godotFrom}" >> "${godotTo}"`); + yield fs.cp(godotFrom, godotTo, { recursive: true }); + let npFrom = "godot-rj-nuget-package"; + let npTo = path.join(platformTargetDirectory, npFrom); + RJLog_1.RJLog.log(`copying nupkg: "${npFrom}" >> "${npTo}"`); + yield fs.cp(npFrom, npTo, { recursive: true }); + let installerFiles = { + "windows": [ + "install-godot-windows.bat", + "install-godot-windows-readme.txt" + ] + }; + let installers = installerFiles[platform]; + for (let installer of installers) { + let installFrom = "install-scripts/" + installer; + let installTo = path.join(platformTargetDirectory, installer); + RJLog_1.RJLog.log(`copying installer: "${installFrom}" >> "${installTo}"`); + yield fs.cp(installFrom, installTo, { recursive: true }); + } + }); +} +main(); +//# sourceMappingURL=create-output.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/create-output.js.map b/rokojori-cpp-generator/builds/create-output.js.map new file mode 100644 index 0000000..057f106 --- /dev/null +++ b/rokojori-cpp-generator/builds/create-output.js.map @@ -0,0 +1 @@ +{"version":3,"file":"create-output.js","sourceRoot":"","sources":["../source/create-output.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2CAAwC;AAExC,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACpC,MAAM,IAAI,GAAG,OAAO,CAAE,MAAM,CAAE,CAAC;AAC/B,MAAM,EAAE,GAAG,OAAO,CAAE,kBAAkB,CAAE,CAAC;AACzC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAE,cAAc,CAAE,CAAC;AAG7C,IAAI,eAAe,GAAG,SAAS,CAAC;AAChC,IAAI,SAAS,GAAG,wBAAwB,CAAC;AACzC,IAAI,QAAQ,GAAG,WAAW,CAAC;AAC3B,IAAI,iBAAiB,GAAG,SAAS,GAAG,GAAG,GAAG,WAAW,CAAC;AACtD,IAAI,uBAAuB,GAAG,IAAI,CAAC,IAAI,CAAE,eAAe,EAAE,iBAAiB,CAAE,CAAC;AAE9E,SAAe,IAAI;;QAGjB,IAAK,IAAI,CAAC,MAAM,KAAK,CAAC,EACtB,CAAC;YACC,IAAI,SAAS,GAAG,CAAE,SAAS,CAAE,CAAC;YAE9B,OAAO,CAAC,KAAK,CAAE,wEAAwE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,CAAE,CAAC;QAE7D,MAAM,EAAE,CAAC,EAAE,CAAE,SAAS,EAAE,OAAO,EAAE,EAAE,SAAS,EAAG,IAAI,EAAE,CAAE,CAAC;QAIxD,IAAI,MAAM,GAAG,wBAAwB,CAAC;QACtC,IAAI,IAAI,GAAK,IAAI,CAAC,IAAI,CAAE,uBAAuB,EAAE,MAAM,CAAE,CAAC;QAE1D,aAAK,CAAC,GAAG,CAAE,mBAAmB,MAAM,SAAS,IAAI,GAAG,CAAE,CAAC;QAEvD,MAAM,EAAE,CAAC,EAAE,CAAE,MAAM,EAAE,IAAI,EAAE,EAAE,SAAS,EAAG,IAAI,EAAE,CAAE,CAAC;QAGlD,IAAI,cAAc,GAClB;YACE,SAAS,EACT;gBACE,2BAA2B;gBAC3B,kCAAkC;aACnC;SACF,CAAC;QAEF,IAAI,UAAU,GAAK,cAAc,CAAE,QAAQ,CAAE,CAAC;QAE9C,KAAM,IAAI,SAAS,IAAI,UAAU,EACjC,CAAC;YACC,IAAI,WAAW,GAAG,kBAAkB,GAAG,SAAS,CAAC;YAEjD,IAAI,SAAS,GAAK,IAAI,CAAC,IAAI,CAAE,uBAAuB,EAAE,SAAS,CAAE,CAAC;YAElE,aAAK,CAAC,GAAG,CAAE,uBAAuB,WAAW,SAAS,SAAS,GAAG,CAAE,CAAC;YAErE,MAAM,EAAE,CAAC,EAAE,CAAE,WAAW,EAAE,SAAS,EAAE,EAAE,SAAS,EAAG,IAAI,EAAE,CAAE,CAAC;QAC9D,CAAC;IAEH,CAAC;CAAA;AAGD,IAAI,EAAE,CAAC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/library/Files.js b/rokojori-cpp-generator/builds/library/Files.js new file mode 100644 index 0000000..8068c17 --- /dev/null +++ b/rokojori-cpp-generator/builds/library/Files.js @@ -0,0 +1,102 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Files = void 0; +const fs_1 = require("fs"); +const RJLog_1 = require("./RJLog"); +class Files { + static getFiles(filePath) { + return __awaiter(this, void 0, void 0, function* () { + return yield fs_1.promises.readdir(filePath); + }); + } + static copy(from, to) { + return __awaiter(this, void 0, void 0, function* () { + return yield fs_1.promises.copyFile(from, to); + }); + } + static getFilesRecursive(filePath) { + return __awaiter(this, void 0, void 0, function* () { + let files = yield fs_1.promises.readdir(filePath, { recursive: true }); + return files; + }); + } + static delete(filePath) { + return __awaiter(this, void 0, void 0, function* () { + yield fs_1.promises.unlink(filePath); + return Promise.resolve(); + }); + } + static isDirectory(filePath) { + return __awaiter(this, void 0, void 0, function* () { + let stats = yield fs_1.promises.stat(filePath); + return stats.isDirectory(); + }); + } + static exists(filePath) { + return __awaiter(this, void 0, void 0, function* () { + try { + let stats = yield fs_1.promises.stat(filePath); + let exists = stats !== undefined && stats !== null; + return Promise.resolve(exists); + } + catch (e) { + } + return Promise.resolve(false); + }); + } + static loadUTF8(filePath) { + return __awaiter(this, void 0, void 0, function* () { + try { + let data = yield fs_1.promises.readFile(filePath); + let stringData = data.toString(); + return Promise.resolve(stringData); + } + catch (exception) { + RJLog_1.RJLog.warn("loadUTF8: ", filePath); + RJLog_1.RJLog.warn(exception); + } + return Promise.resolve(null); + }); + } + static saveUTF8(filePath, data) { + return __awaiter(this, void 0, void 0, function* () { + try { + yield fs_1.promises.writeFile(filePath, data); + return Promise.resolve(true); + } + catch (exception) { + RJLog_1.RJLog.warn("saveUTF8: ", filePath); + RJLog_1.RJLog.warn(exception); + } + return Promise.resolve(false); + }); + } + static loadJSON(filePath) { + return __awaiter(this, void 0, void 0, function* () { + let text = yield this.loadUTF8(filePath); + if (text === null) { + return Promise.resolve(null); + } + try { + let jsonObject = JSON.parse(text); + return Promise.resolve(jsonObject); + } + catch (exception) { + RJLog_1.RJLog.warn("LoadJSON: ", filePath); + RJLog_1.RJLog.warn(exception); + } + return Promise.resolve(null); + }); + } +} +exports.Files = Files; +//# sourceMappingURL=Files.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/library/Files.js.map b/rokojori-cpp-generator/builds/library/Files.js.map new file mode 100644 index 0000000..82986ec --- /dev/null +++ b/rokojori-cpp-generator/builds/library/Files.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Files.js","sourceRoot":"","sources":["../../source/library/Files.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2BAAoC;AACpC,mCAAgC;AAEhC,MAAa,KAAK;IAEhB,MAAM,CAAO,QAAQ,CAAE,QAAe;;YAEpC,OAAO,MAAM,aAAE,CAAC,OAAO,CAAE,QAAQ,CAAE,CAAC;QACtC,CAAC;KAAA;IAED,MAAM,CAAO,IAAI,CAAE,IAAW,EAAE,EAAS;;YAEvC,OAAO,MAAM,aAAE,CAAC,QAAQ,CAAE,IAAI,EAAE,EAAE,CAAE,CAAC;QACvC,CAAC;KAAA;IAGD,MAAM,CAAO,iBAAiB,CAAE,QAAe;;YAE7C,IAAI,KAAK,GAAG,MAAM,aAAE,CAAC,OAAO,CAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAE,CAAC;YAC9D,OAAO,KAAK,CAAC;QACf,CAAC;KAAA;IAGD,MAAM,CAAO,MAAM,CAAE,QAAe;;YAElC,MAAM,aAAE,CAAC,MAAM,CAAE,QAAQ,CAAE,CAAC;YAC5B,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;QAC3B,CAAC;KAAA;IAED,MAAM,CAAO,WAAW,CAAE,QAAe;;YAEvC,IAAI,KAAK,GAAG,MAAM,aAAE,CAAC,IAAI,CAAE,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gBACrC,aAAK,CAAC,IAAI,CAAE,SAAS,CAAE,CAAC;YAC1B,CAAC;YAED,OAAO,OAAO,CAAC,OAAO,CAAE,KAAK,CAAE,CAAC;QAElC,CAAC;KAAA;IAID,MAAM,CAAO,QAAQ,CAAK,QAAe;;YAEvC,IAAI,IAAI,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAE,QAAQ,CAAE,CAAC;YAE3C,IAAK,IAAI,KAAK,IAAI,EAClB,CAAC;gBACC,OAAO,OAAO,CAAC,OAAO,CAAE,IAAI,CAAO,CAAC;YACtC,CAAC;YAED,IACA,CAAC;gBACC,IAAI,UAAU,GAAG,IAAI,CAAC,KAAK,CAAE,IAAI,CAAE,CAAC;gBAEpC,OAAO,OAAO,CAAC,OAAO,CAAE,UAAU,CAAE,CAAC;YACvC,CAAC;YACD,OAAQ,SAAS,EACjB,CAAC;gBACC,aAAK,CAAC,IAAI,CAAE,YAAY,EAAE,QAAQ,CAAE,CAAC;gBACrC,aAAK,CAAC,IAAI,CAAE,SAAS,CAAE,CAAC;YAC1B,CAAC;YAED,OAAO,OAAO,CAAC,OAAO,CAAE,IAAI,CAAE,CAAC;QACjC,CAAC;KAAA;CAGF;AA/GD,sBA+GC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/library/LogColors.js b/rokojori-cpp-generator/builds/library/LogColors.js new file mode 100644 index 0000000..48cc766 --- /dev/null +++ b/rokojori-cpp-generator/builds/library/LogColors.js @@ -0,0 +1,32 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.LogColors = void 0; +class LogColors { +} +exports.LogColors = LogColors; +LogColors.reset = "\x1b[0m"; +LogColors.bright = "\x1b[1m"; +LogColors.dim = "\x1b[2m"; +LogColors.underscore = "\x1b[4m"; +LogColors.blink = "\x1b[5m"; +LogColors.reverse = "\x1b[7m"; +LogColors.hidden = "\x1b[8m"; +LogColors.black_Foreground = "\x1b[30m"; +LogColors.red_Foreground = "\x1b[31m"; +LogColors.green_Foreground = "\x1b[32m"; +LogColors.yellow_Foreground = "\x1b[33m"; +LogColors.blue_Foreground = "\x1b[34m"; +LogColors.magenta_Foreground = "\x1b[35m"; +LogColors.cyan_Foreground = "\x1b[36m"; +LogColors.white_Foreground = "\x1b[37m"; +LogColors.gray_Foreground = "\x1b[90m"; +LogColors.black_Background = "\x1b[40m"; +LogColors.red_Background = "\x1b[41m"; +LogColors.green_Background = "\x1b[42m"; +LogColors.yellow_Background = "\x1b[43m"; +LogColors.blue_Background = "\x1b[44m"; +LogColors.magenta_Background = "\x1b[45m"; +LogColors.cyan_Background = "\x1b[46m"; +LogColors.white_Background = "\x1b[47m"; +LogColors.gray_Background = "\x1b[100m"; +//# sourceMappingURL=LogColors.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/library/LogColors.js.map b/rokojori-cpp-generator/builds/library/LogColors.js.map new file mode 100644 index 0000000..69c7eaf --- /dev/null +++ b/rokojori-cpp-generator/builds/library/LogColors.js.map @@ -0,0 +1 @@ +{"version":3,"file":"LogColors.js","sourceRoot":"","sources":["../../source/library/LogColors.ts"],"names":[],"mappings":";;;AAAA,MAAa,SAAS;;AAAtB,8BA8BC;AA5BiB,eAAK,GAAG,SAAS,CAAC;AAClB,gBAAM,GAAG,SAAS,CAAC;AACnB,aAAG,GAAG,SAAS,CAAC;AAChB,oBAAU,GAAG,SAAS,CAAC;AACvB,eAAK,GAAG,SAAS,CAAC;AAClB,iBAAO,GAAG,SAAS,CAAC;AACpB,gBAAM,GAAG,SAAS,CAAC;AAEnB,0BAAgB,GAAG,UAAU,CAAC;AAC9B,wBAAc,GAAG,UAAU,CAAC;AAC5B,0BAAgB,GAAG,UAAU,CAAC;AAC9B,2BAAiB,GAAG,UAAU,CAAC;AAC/B,yBAAe,GAAG,UAAU,CAAC;AAC7B,4BAAkB,GAAG,UAAU,CAAC;AAChC,yBAAe,GAAG,UAAU,CAAC;AAC7B,0BAAgB,GAAG,UAAU,CAAC;AAC9B,yBAAe,GAAG,UAAU,CAAC;AAE7B,0BAAgB,GAAG,UAAU,CAAC;AAC9B,wBAAc,GAAG,UAAU,CAAC;AAC5B,0BAAgB,GAAG,UAAU,CAAC;AAC9B,2BAAiB,GAAG,UAAU,CAAC;AAC/B,yBAAe,GAAG,UAAU,CAAC;AAC7B,4BAAkB,GAAG,UAAU,CAAC;AAChC,yBAAe,GAAG,UAAU,CAAC;AAC7B,0BAAgB,GAAG,UAAU,CAAC;AAC9B,yBAAe,GAAG,WAAW,CAAC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/library/MatchResult.js b/rokojori-cpp-generator/builds/library/MatchResult.js new file mode 100644 index 0000000..83cd097 --- /dev/null +++ b/rokojori-cpp-generator/builds/library/MatchResult.js @@ -0,0 +1,7 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.MatchResult = void 0; +class MatchResult { +} +exports.MatchResult = MatchResult; +//# sourceMappingURL=MatchResult.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/library/MatchResult.js.map b/rokojori-cpp-generator/builds/library/MatchResult.js.map new file mode 100644 index 0000000..ff8b97e --- /dev/null +++ b/rokojori-cpp-generator/builds/library/MatchResult.js.map @@ -0,0 +1 @@ +{"version":3,"file":"MatchResult.js","sourceRoot":"","sources":["../../source/library/MatchResult.ts"],"names":[],"mappings":";;;AAAA,MAAa,WAAW;CAKvB;AALD,kCAKC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/library/Objects.js b/rokojori-cpp-generator/builds/library/Objects.js new file mode 100644 index 0000000..4b28911 --- /dev/null +++ b/rokojori-cpp-generator/builds/library/Objects.js @@ -0,0 +1,11 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Objects = void 0; +class Objects { + static jsonClone(obj) { + let jsonData = JSON.stringify(obj); + return JSON.parse(jsonData); + } +} +exports.Objects = Objects; +//# sourceMappingURL=Objects.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/library/Objects.js.map b/rokojori-cpp-generator/builds/library/Objects.js.map new file mode 100644 index 0000000..1f2dfce --- /dev/null +++ b/rokojori-cpp-generator/builds/library/Objects.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Objects.js","sourceRoot":"","sources":["../../source/library/Objects.ts"],"names":[],"mappings":";;;AAAA,MAAa,OAAO;IAElB,MAAM,CAAC,SAAS,CAAK,GAAK;QAExB,IAAI,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAE,GAAG,CAAE,CAAC;QACrC,OAAO,IAAI,CAAC,KAAK,CAAE,QAAQ,CAAO,CAAC;IACrC,CAAC;CACF;AAPD,0BAOC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/library/RJLog.js b/rokojori-cpp-generator/builds/library/RJLog.js new file mode 100644 index 0000000..f9d059b --- /dev/null +++ b/rokojori-cpp-generator/builds/library/RJLog.js @@ -0,0 +1,83 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.RJLog = void 0; +const LogColors_1 = require("./LogColors"); +const Texts_1 = require("./Texts"); +class RJLog { + static _parseLineResult(line) { + let result = RJLog.matcherWithFunction.exec(line) || + RJLog.matcherFile.exec(line) || + RJLog.matcherAnonymous.exec(line); + return result; + } + static _parseLine(line) { + let result = RJLog._parseLineResult(line); + if (result) { + return " " + result[1] + "(" + result[2] + ") "; + } + return line; + } + static logError(e) { + console.log("\n" + RJLog._formatErrorMessage(e.stack)); + } + static _formatErrorMessage(stackTrace, color = RJLog.errorMessageColor) { + let lines = Texts_1.Texts.splitLines(stackTrace); + let output = [color]; + lines.forEach((line, index) => { + let lineInfo = RJLog._parseLine(line); + output.push(lineInfo); + if (index !== lines.length - 1) { + output.push("\n"); + } + }); + output.push(RJLog.resetColor); + return output.join(""); + } + static getLineInfo(color = RJLog.logColor, stackTrace, lineIndex = 3) { + stackTrace = stackTrace || (new Error().stack + ""); + let lines = Texts_1.Texts.splitLines(stackTrace); + let result = null; + while (!result && lineIndex < lines.length) { + let line = lines[lineIndex]; + result = RJLog._parseLineResult(line); + lineIndex++; + } + if (!result) { + console.log(stackTrace); + return color + " " + RJLog.resetColor; + } + return color + " " + result[1] + "(" + result[2] + ") " + RJLog.resetColor; + } + static error(...params) { + if (RJLog.logAlwaysLineInfo || typeof process === "object") { + let lineInfo = RJLog.getLineInfo(RJLog.errorColor); + console.log("\n" + lineInfo); + } + console.error.apply(console, params); + } + static warn(...params) { + if (RJLog.logAlwaysLineInfo || typeof process === "object") { + let lineInfo = RJLog.getLineInfo(RJLog.warnColor); + console.log("\n" + lineInfo); + } + console.warn.apply(console, params); + } + static log(...params) { + if (RJLog.logAlwaysLineInfo || typeof process === "object") { + let lineInfo = RJLog.getLineInfo(); + console.log("\n" + lineInfo); + } + console.log.apply(console, params); + } +} +exports.RJLog = RJLog; +RJLog.errorColor = LogColors_1.LogColors.red_Background; +RJLog.errorMessageColor = LogColors_1.LogColors.red_Foreground; +RJLog.warnColor = LogColors_1.LogColors.yellow_Background; +RJLog.logColor = LogColors_1.LogColors.gray_Background; +RJLog.resetColor = LogColors_1.LogColors.reset; +RJLog.matcherWithFunction = /^\s+at\s(.+)\s\(.+?:(\d+:\d+)\)/; +RJLog.matcherFile = /\(.+?\\(\w+)\.js:(\d+:\d+)\)/; +RJLog.matcherAnonymous = /^\s+at\s(.+)\s\((.+)\)/; +RJLog.logAlwaysLineInfo = true; +//# sourceMappingURL=RJLog.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/library/RJLog.js.map b/rokojori-cpp-generator/builds/library/RJLog.js.map new file mode 100644 index 0000000..42e91e2 --- /dev/null +++ b/rokojori-cpp-generator/builds/library/RJLog.js.map @@ -0,0 +1 @@ +{"version":3,"file":"RJLog.js","sourceRoot":"","sources":["../../source/library/RJLog.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AACxC,mCAAgC;AAEhC,MAAa,KAAK;IAehB,MAAM,CAAC,gBAAgB,CAAE,IAAW;QAElC,IAAI,MAAM,GAAG,KAAK,CAAC,mBAAmB,CAAC,IAAI,CAAE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AE,GAAG,MAAY;QAE1B,IAAK,KAAK,CAAC,iBAAiB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAC3D,CAAC;YACC,IAAI,QAAQ,GAAG,KAAK,CAAC,WAAW,CAAE,KAAK,CAAC,SAAS,CAAE,CAAC;YACpD,OAAO,CAAC,GAAG,CAAE,IAAI,GAAG,QAAQ,CAAE,CAAC;QACjC,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,KAAK,CAAE,OAAO,EAAE,MAAM,CAAE,CAAC;IACxC,CAAC;IAGD,MAAM,CAAC,GAAG,CAAE,GAAG,MAAY;QAEzB,IAAK,KAAK,CAAC,iBAAiB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAC3D,CAAC;YACC,IAAI,QAAQ,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;YACnC,OAAO,CAAC,GAAG,CAAE,IAAI,GAAG,QAAQ,CAAE,CAAC;QACjC,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,KAAK,CAAE,OAAO,EAAE,MAAM,CAAE,CAAC;IACvC,CAAC;;AA/HH,sBAgIC;AA9HiB,gBAAU,GAAG,qBAAS,CAAC,cAAc,CAAC;AACtC,uBAAiB,GAAG,qBAAS,CAAC,cAAc,CAAC;AAC7C,eAAS,GAAI,qBAAS,CAAC,iBAAiB,CAAC;AACzC,cAAQ,GAAK,qBAAS,CAAC,eAAe,CAAA;AACtC,gBAAU,GAAG,qBAAS,CAAC,KAAK,CAAC;AAE7B,yBAAmB,GAAG,iCAAiC,CAAC;AACxD,iBAAW,GAAW,8BAA8B,CAAC;AACrD,sBAAgB,GAAM,wBAAwB,CAAC;AAE/C,uBAAiB,GAAG,IAAI,CAAC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/library/Text.js b/rokojori-cpp-generator/builds/library/Text.js new file mode 100644 index 0000000..c50e552 --- /dev/null +++ b/rokojori-cpp-generator/builds/library/Text.js @@ -0,0 +1,50 @@ +export class MatchResult { +} +export class Text { + static makeSticky(regexp) { + if (regexp.sticky) { + return regexp; + } + var source = regexp.source; + var flags = regexp.flags; + if (flags.indexOf("y") === -1) { + flags += "y"; + } + return new RegExp(source, flags); + } + static makeGlobal(regexp) { + if (regexp.global) { + return regexp; + } + var source = regexp.source; + var flags = regexp.flags; + if (flags.indexOf("g") === -1) { + flags += "g"; + } + return new RegExp(source, flags); + } + static getMatches(source, regex) { + regex = this.makeGlobal(regex); + let offset = 0; + let matches = []; + while (offset < source.length) { + regex.lastIndex = offset; + let result = regex.exec(source); + let match = result ? result[0] : null; + if (result && result.index != offset && match.length > 0) { + offset = result.index + match.length; + matches.push({ match: match, index: result.index }); + } + else { + return matches; + } + } + return matches; + } + static insertText(sourceText, insertText, insertPosition) { + let before = sourceText.substring(0, insertPosition); + let after = sourceText.substring(insertPosition, sourceText.length); + return before + insertText + after; + } +} +//# sourceMappingURL=Text.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/library/Text.js.map b/rokojori-cpp-generator/builds/library/Text.js.map new file mode 100644 index 0000000..57e4f15 --- /dev/null +++ b/rokojori-cpp-generator/builds/library/Text.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Text.js","sourceRoot":"","sources":["../../source/library/Text.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,WAAW;CAIvB;AAED,MAAM,OAAO,IAAI;IAEf,MAAM,CAAC,UAAU,CAAE,MAAa;QAE9B,IAAK,MAAM,CAAC,MAAM,EAClB,CAAC;YACC,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,IAAI,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC3B,IAAI,KAAK,GAAI,MAAM,CAAC,KAAK,CAAC;QAE1B,IAAK,KAAK,CAAC,OAAO,CAAE,GAAG,CAAE,KAAK,CAAC,CAAC,EAChC,CAAC;YACC,KAAK,IAAI,GAAG,CAAC;QACf,CAAC;QAED,OAAO,IAAI,MAAM,CAAE,MAAM,EAAE,KAAK,CAAE,CAAC;IACrC,CAAC;IAED,MAAM,CAAC,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,UAAU,CAAE,UAAiB,EAAE,UAAiB,EAAE,cAAqB;QAE5E,IAAI,MAAM,GAAG,UAAU,CAAC,SAAS,CAAE,CAAC,EAAE,cAAc,CAAE,CAAC;QACvD,IAAI,KAAK,GAAI,UAAU,CAAC,SAAS,CAAE,cAAc,EAAE,UAAU,CAAC,MAAM,CAAE,CAAC;QAEvE,OAAO,MAAM,GAAG,UAAU,GAAG,KAAK,CAAC;IACrC,CAAC;CACF"} \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/library/Texts.js b/rokojori-cpp-generator/builds/library/Texts.js new file mode 100644 index 0000000..1fb5ff9 --- /dev/null +++ b/rokojori-cpp-generator/builds/library/Texts.js @@ -0,0 +1,105 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Texts = void 0; +const path_1 = __importDefault(require("path")); +class Texts { + static joinPaths(...paths) { + return path_1.default.join.apply(null, paths); + } + static makeSticky(regexp) { + if (regexp.sticky) { + return regexp; + } + var source = regexp.source; + var flags = regexp.flags; + if (flags.indexOf("y") === -1) { + flags += "y"; + } + return new RegExp(source, flags); + } + static splitLines(text) { + return text.split(/(?:\r\n)|\n|\r/g); + } + static fileName(fullPath) { + return path_1.default.basename(fullPath); + } + static splitLinesCaptureBreaks(text) { + return text.split(/((?:\r\n)|\n|\r)/g); + } + static makeGlobal(regexp) { + if (regexp.global) { + return regexp; + } + var source = regexp.source; + var flags = regexp.flags; + if (flags.indexOf("g") === -1) { + flags += "g"; + } + return new RegExp(source, flags); + } + static replaceAllIn(texts, replacements) { + if (texts === undefined || texts === null) { + return texts; + } + let outputTexts = []; + for (let i = 0; i < texts.length; i++) { + outputTexts.push(Texts.replaceAll(texts[i], replacements)); + } + return outputTexts; + } + static replaceAll(text, replacements) { + if (text === undefined || text === null) { + return text; + } + for (let [variable, replacement] of replacements) { + let replacementRegexSource = Texts.toRegexSource(variable); + let regex = new RegExp(replacementRegexSource, "g"); + text = text.replace(regex, replacement); + } + return text; + } + static toRegexSource(source) { + source = source.replace(/\./g, "\\."); + source = source.replace(/\(/g, "\\("); + source = source.replace(/\)/g, "\\)"); + source = source.replace(/\[/g, "\\["); + source = source.replace(/\]/g, "\\]"); + source = source.replace(/\^/g, "\\^"); + source = source.replace(/\$/g, "\\$"); + source = source.replace(/\*/g, "\\*"); + source = source.replace(/\+/g, "\\+"); + source = source.replace(/\-/g, "\\-"); + source = source.replace(/\?/g, "\\?"); + source = source.replace(/\//g, "\\/"); + source = source.replace(/\|/g, "\\|"); + return source; + } + static getMatches(source, regex, type = null) { + regex = this.makeGlobal(regex); + let offset = 0; + let matches = []; + while (offset < source.length) { + regex.lastIndex = offset; + let result = regex.exec(source); + let match = result ? result[0] : null; + if (result && result.index != offset && match.length > 0) { + offset = result.index + match.length; + matches.push({ match: match, index: result.index, type: type }); + } + else { + return matches; + } + } + return matches; + } + static insertText(sourceText, insertText, insertPosition) { + let before = sourceText.substring(0, insertPosition); + let after = sourceText.substring(insertPosition, sourceText.length); + return before + insertText + after; + } +} +exports.Texts = Texts; +//# sourceMappingURL=Texts.js.map \ No newline at end of file diff --git a/rokojori-cpp-generator/builds/library/Texts.js.map b/rokojori-cpp-generator/builds/library/Texts.js.map new file mode 100644 index 0000000..58c9828 --- /dev/null +++ b/rokojori-cpp-generator/builds/library/Texts.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Texts.js","sourceRoot":"","sources":["../../source/library/Texts.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAMxB,MAAa,KAAK;IAEhB,MAAM,CAAC,SAAS,CAAE,GAAG,KAAc;QAEjC,OAAO,cAAI,CAAC,IAAI,CAAC,KAAK,CAAE,IAAI,EAAE,KAAK,CAAE,CAAC;IACxC,CAAC;IAED,MAAM,CAAC,UAAU,CAAE,MAAa;QAE9B,IAAK,MAAM,CAAC,MAAM,EAClB,CAAC;YACC,OAAO,MAAM,CAAC;QA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IAAI,EAAE,CAAE,CAAC;YAClE,CAAC;iBAED,CAAC;gBACC,OAAO,OAAO,CAAC;YACjB,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,CAAC,UAAU,CAAE,UAAiB,EAAE,UAAiB,EAAE,cAAqB;QAE5E,IAAI,MAAM,GAAG,UAAU,CAAC,SAAS,CAAE,CAAC,EAAE,cAAc,CAAE,CAAC;QACvD,IAAI,KAAK,GAAI,UAAU,CAAC,SAAS,CAAE,cAAc,EAAE,UAAU,CAAC,MAAM,CAAE,CAAC;QAEvE,OAAO,MAAM,GAAG,UAAU,GAAG,KAAK,CAAC;IACrC,CAAC;CACF;AAnJD,sBAmJC"} \ No newline at end of file diff --git a/rokojori-cpp-generator/package-lock.json b/rokojori-cpp-generator/package-lock.json new file mode 100644 index 0000000..dc22c18 --- /dev/null +++ b/rokojori-cpp-generator/package-lock.json @@ -0,0 +1,39 @@ +{ + "name": "rokojori-cpp-generator", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "rokojori-cpp-generator", + "dependencies": { + "@types/node": "^20.14.12", + "typescript": "^5.5.4" + } + }, + "node_modules/@types/node": { + "version": "20.14.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.12.tgz", + "integrity": "sha512-r7wNXakLeSsGT0H1AU863vS2wa5wBOK4bWMjZz2wj+8nBx+m5PeIn0k8AloSLpRuiwdRQZwarZqHE4FNArPuJQ==", + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/typescript": { + "version": "5.5.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", + "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" + } + } +} diff --git a/rokojori-cpp-generator/package.json b/rokojori-cpp-generator/package.json new file mode 100644 index 0000000..fa3d429 --- /dev/null +++ b/rokojori-cpp-generator/package.json @@ -0,0 +1,16 @@ +{ + "name": "rokojori-cpp-generator", + + "scripts": + { + "build": "tsc -p source/tsconfig.json", + "create-cpp": "npm run build && node builds/create-cpp.js", + "copy-cpp-source": "npm run build && node builds/copy-cpp-source.js" + }, + + "dependencies": + { + "@types/node": "^20.14.12", + "typescript": "^5.5.4" + } +} diff --git a/rokojori-cpp-generator/source/copy-cpp-source.ts b/rokojori-cpp-generator/source/copy-cpp-source.ts new file mode 100644 index 0000000..2e25dfc --- /dev/null +++ b/rokojori-cpp-generator/source/copy-cpp-source.ts @@ -0,0 +1,43 @@ +import { Files } from "./library/Files"; +import { RJLog } from "./library/RJLog"; + +const fs = require( "node:fs/promises" ); + +let from = __dirname + "/../../rokojori-action-library"; +let to = __dirname + "/../../godot/modules/rokojori_action_library" + +async function main() +{ + RJLog.log( "Copying C++ source" ); + + await deleteOldDirectory(); + await copyToModules(); + // await runBuild(); + + RJLog.log( "Copying C++ source" ); +} + +async function deleteOldDirectory() +{ + let stats = await fs.stat( to ); + + if ( stats ) + { + RJLog.log( `deleting previous directory: "${to}"` ); + await fs.rm( to, { recursive: true } ); + } + + return Promise.resolve(); +} + +async function copyToModules() +{ + RJLog.log( "copying:", `"${from}" >> "${to}"` ); + await fs.cp( from, to, { recursive : true } ); + + return Promise.resolve(); +} + + + +main(); \ No newline at end of file diff --git a/rokojori-cpp-generator/source/cpp-creation/CppCreator.ts b/rokojori-cpp-generator/source/cpp-creation/CppCreator.ts new file mode 100644 index 0000000..ed8a487 --- /dev/null +++ b/rokojori-cpp-generator/source/cpp-creation/CppCreator.ts @@ -0,0 +1,222 @@ +import { Member } from "./members/Member"; +import { Header } from "./Header"; +import { Implementation } from "./Implementation"; +import { Files } from "../library/Files"; +import { MatchResult } from "../library/MatchResult"; +import { Texts } from "../library/Texts"; +import { MemberType } from "./MemberType"; +import { Field } from "./members/Field"; +import { RJLog } from "../library/RJLog"; +import { CppDefinition } from "./CppDefinition"; +import { Objects } from "../library/Objects"; +import { Variations } from "./Variations"; +import { VariationDefinitions, VariationTemplates } from "./VariationTemplates"; +import { Method } from "./members/Method"; +import { MemberFactory } from "./factories/MemberFactory"; + +export class CppCreator +{ + static definitionsPath = __dirname + "/../../../rokojori-action-library-definitions"; + static outputPath = __dirname + "/../../../rokojori-action-library"; + static rawPath = CppCreator.definitionsPath + "/_raw"; + static registerTypesPath = CppCreator.rawPath + "/register_types.cpp"; + static registerTypesPathOutput = CppCreator.outputPath + "/register_types.cpp"; + + static createIncludes( className:string ) + { + // RJLog.log( "Create include", className ); + + let godotClasses:any = + { + "Node" : "scene/main/node.h", + "Node2D" : "scene/2d/node_2d.h", + "Node3D" : "scene/3d/node_3d.h", + "Resource" : "core/io/resource.h" + } + + if ( godotClasses[ className ] ) + { + return `#include "${godotClasses[ className ]}"`; + } + + + return `#include "./${className}.h"`; + } + + static getHeaderDefine( className:string ) + { + className = className.replace( /^RJ/, "" ); + + let output = [ className[ 0 ] ]; + + for ( let i = 1; i < className.length; i++ ) + { + let character = className[ i ]; + let upperCaseCharacter = character.toUpperCase(); + + if ( character === upperCaseCharacter ) + { + output.push( "_" ); + + } + + output.push( upperCaseCharacter ); + + } + + className = output.join( "" ); + + return "ROKOJORI__" + className + "_H"; + } + + static async createCppFiles( definitionPath:string ) + { + let jsonPath = definitionPath; + // path.join( definitionsPath, definitionPath ); + + let isDir = await Files.isDirectory( jsonPath ); + + if ( isDir ) + { + let files = await Files.getFiles( jsonPath ); + + for ( let file of files ) + { + if ( file.startsWith( "_" ) ) + { + continue; + } + + await CppCreator.createCppFiles( Texts.joinPaths( jsonPath, file ) ); + } + + return Promise.resolve(); + } + + return this.createCppFile( jsonPath ); + + } + + static async createCppFile( jsonPath:string ) + { + let data = await Files.loadJSON( jsonPath ); + + if ( data.variations ) + { + let variationsData = data.variations; + + if ( typeof variationsData == "string" ) + { + variationsData = (VariationTemplates as any as {[index:string]:VariationDefinitions})[ variationsData ]; + } + + let variations = new Variations( variationsData ); + + console.log( variations.items, variations.counter, variations.hasItems ); + + while ( variations.hasItems ) + { + let newData = CppDefinition.createVariation( data, variations.currentMap ); + + await this.createCppFileWith( newData ); + + variations.nextItem(); + } + } + else + { + await CppCreator.createCppFileWith( data ); + } + + + + return Promise.resolve(); + } + + static async createCppFileWith( data:CppDefinition ) + { + let classNameResult = /(\w+)(?:\:(\w+))?/.exec( data.class ); + + let className = classNameResult[ 1 ]; + let extendingClass = classNameResult[ 2 ]; + + let headerDefine = CppCreator.getHeaderDefine( className ); + + let fromProtectedMembers = MemberFactory.grabMembers( data.protected, "protected" ); + let fromPublicMembers = MemberFactory.grabMembers( data.public, "public" ); + + let protectedMembers:Member[] = []; + let publicMembers:Member[] = []; + + let insertMember = ( m:Member ) => + { + let container = m.accessModifier === "public" ? publicMembers : protectedMembers; + container.push( m ); + }; + + fromProtectedMembers.forEach( m => insertMember( m ) ); + fromPublicMembers.forEach( m => insertMember( m ) ); + + + let allMembers:Member[] = [].concat( protectedMembers ).concat( publicMembers ); + + + let protectedHeader = protectedMembers.map( m => m.getHeaderDefinition() ).join( "\n " ); + let publicHeader = publicMembers.map( m => m.getHeaderDefinition() ).join( "\n " ); + + let fields:Field[] = allMembers.filter( m => m.memberType === MemberType.Field ) as Field[]; + let methods:Method[] = allMembers.filter( m => m.memberType === MemberType.Method ) as Method[]; + + let fieldDeclarations = fields.map( f => f.getFieldDeclaration() ).join( "\n " ); + + protectedHeader += "\n\n " + fieldDeclarations; + + let methodBindings = allMembers.map( m => m.getBindings( className ) ).join( "\n " ); + + let initializers = fields.filter( m => m.hasInitializer ).map( m => m.getInitializer() ).join( "\n "); + + let includes = `#include "./RJGodotHeaders.h"`; + + if ( data.includes ) + { + let mappedIncludes = data.includes.map( ( inc:string ) => `#include "${inc}"` ); + includes += "\n" + mappedIncludes.join( "\n" ); + } + + let extendingClassInclude = CppCreator.createIncludes( extendingClass ); + + includes += "\n" + extendingClassInclude; + + let forwards = ""; + + if ( data.forwards ) + { + let forwardDeclarations = data.forwards as string[]; + forwards = forwardDeclarations.join( "\n" ); + } + + let header = Header.create( className, extendingClass, headerDefine, + protectedHeader, publicHeader, includes, + forwards ); + + let constructorExpressions = initializers; + let destructorExpressions = ""; + let implementations = ""; + + let fieldImplementations = fields.map( f => f.getFieldImplementation( className ) ); + implementations += fieldImplementations.join( "\n" ) + "\n"; + + let methodsWithImplementation = methods.filter( m => m.hasMethodImplementation ); + let methodImplementations = methodsWithImplementation.map( m => m.getMethodImplementation( className ) ); + + implementations += methodImplementations.join( "\n" ); + + let implementation = Implementation.craete( className, methodBindings, constructorExpressions, destructorExpressions, implementations ); + + let rawFilePath = Texts.joinPaths( CppCreator.outputPath, className ); + + await Files.saveUTF8( rawFilePath + ".h", header ); + await Files.saveUTF8( rawFilePath + ".cpp", implementation ); + } + +} \ No newline at end of file diff --git a/rokojori-cpp-generator/source/cpp-creation/CppDefinition.ts b/rokojori-cpp-generator/source/cpp-creation/CppDefinition.ts new file mode 100644 index 0000000..23816bb --- /dev/null +++ b/rokojori-cpp-generator/source/cpp-creation/CppDefinition.ts @@ -0,0 +1,43 @@ +import { Texts } from "../library/Texts"; +import { VariationDefinitions } from "./VariationTemplates"; + +export type MemberDefinitions = { [index:string]:any }; +export class CppDefinition +{ + variations:string|VariationDefinitions; + + class:string; + + includes:string[]; + forwards:string[]; + + public:MemberDefinitions; + protected:MemberDefinitions; + + static createVariation( cppDefinition:CppDefinition, map:Map ):CppDefinition + { + let variation = new CppDefinition(); + + variation.class = Texts.replaceAll( cppDefinition.class, map ); + + variation.includes = Texts.replaceAllIn( cppDefinition.includes, map ); + variation.forwards = Texts.replaceAllIn( cppDefinition.forwards, map ); + + variation.public = CppDefinition.applyVariationOnAll( cppDefinition.public, map ); + variation.protected = CppDefinition.applyVariationOnAll( cppDefinition.protected, map ); + + return variation; + } + + static applyVariationOnAll( obj:T, map:Map ):T + { + if ( obj === null || obj === undefined ) + { + return obj; + } + + let jsonValue = JSON.stringify( obj ); + jsonValue = Texts.replaceAll( jsonValue, map ); + return JSON.parse( jsonValue ) as T; + } +} \ No newline at end of file diff --git a/rokojori-cpp-generator/source/cpp-creation/GodotTypes.ts b/rokojori-cpp-generator/source/cpp-creation/GodotTypes.ts new file mode 100644 index 0000000..64fbb20 --- /dev/null +++ b/rokojori-cpp-generator/source/cpp-creation/GodotTypes.ts @@ -0,0 +1,77 @@ +import { RJLog } from "../library/RJLog"; + +export class GodotTypes +{ + static stringToPropertyHint( stringType:string ) + { + switch ( stringType ) + { + case "Node": case "Ref": + return "PROPERTY_HINT_NODE_TYPE"; + + case "Resource": case "Ref": + return "PROPERTY_HINT_RESOURCE_TYPE"; + } + + RJLog.error( "No property hint found for", `"${stringType}"` ); + } + + static stringToVariantType( stringType:string ) + { + if ( /^TypedArray\<.+\>$/.test( stringType ) ) + { + return "ARRAY"; + } + + switch( stringType ) + { + case "bool": return "BOOL"; + case "int": return "INT"; + case "float": return "FLOAT"; + case "String": return "STRING"; + + // Math + case "Vector2": return "VECTOR2"; + case "Vector2i": return "VECTOR2I"; + case "Rect2": return "RECT2"; + case "Rect2i": return "RECT2I"; + case "Transform2D": return "TRANSFORM2D"; + case "Vector3": return "VECTOR3"; + case "Vector3i": return "VECTOR3I"; + case "Vector4": return "VECTOR4"; + case "Vector4i": return "VECTOR4I"; + case "Plane": return "PLANE"; + case "AABB": return "AABB"; + case "Quaternion": return "QUATERNION"; + case "Basis": return "BASIS"; + case "Transform3D": return "TRANSFORM3D"; + case "Projection": return "PROJECTION"; + + // Miscellaneous + case "Color": return "COLOR"; + case "RID": return "RID"; + case "Object": return "OBJECT"; + case "Callable": return "CALLABLE"; + case "Signal": return "SIGNAL"; + case "StringName": return "STRING_NAME"; + case "NodePath": return "NODE_PATH"; + case "Dictionary": return "DICTIONARY"; + case "Array": return "ARRAY"; + + // Arrays + case "PackedByteArray": return "PACKED_BYTE_ARRAY"; + case "PackedInt32Array": return "PACKED_INT32_ARRAY"; + case "PackedInt64Array": return "PACKED_INT64_ARRAY"; + case "PackedFloat32Array": return "PACKED_FLOAT32_ARRAY"; + case "PackedFloat64Array": return "PACKED_FLOAT64_ARRAY"; + case "PackedStringArray": return "PACKED_STRING_ARRAY"; + case "PackedVector2Array": return "PACKED_VECTOR2_ARRAY"; + case "PackedVector3Array": return "PACKED_VECTOR3_ARRAY"; + case "PackedColorArray": return "PACKED_COLOR_ARRAY"; + } + + RJLog.error( "Type could not be mapped: ", stringType ); + + return "OBJECT"; + } +} \ No newline at end of file diff --git a/rokojori-cpp-generator/source/cpp-creation/Header.ts b/rokojori-cpp-generator/source/cpp-creation/Header.ts new file mode 100644 index 0000000..aa5b004 --- /dev/null +++ b/rokojori-cpp-generator/source/cpp-creation/Header.ts @@ -0,0 +1,50 @@ +export class Header +{ + static create( className:string, extendingClassName:string, + headerDefine:string, protectedMembers:string, + publicMembers:string, includes:string, + forwardDeclarations:string ) + { + + let cppHeader = + +` +/* ${className}.h */ + +#ifndef ${headerDefine} +#define ${headerDefine} + +${includes} + +${forwardDeclarations} + + +class ${className} : public ${extendingClassName} +{ + GDCLASS( ${className}, ${extendingClassName} ); + +protected: + static void _bind_methods(); + ${protectedMembers} + +public: + + ${publicMembers} + + // Constructor + ${className}(); + + // Destructor + ~${className}(); +}; + + +#endif // ${headerDefine} +` + + return cppHeader; + + + } + +} \ No newline at end of file diff --git a/rokojori-cpp-generator/source/cpp-creation/Implementation.ts b/rokojori-cpp-generator/source/cpp-creation/Implementation.ts new file mode 100644 index 0000000..e1f755e --- /dev/null +++ b/rokojori-cpp-generator/source/cpp-creation/Implementation.ts @@ -0,0 +1,42 @@ + +export class Implementation +{ + + static craete( className:string, boundMethods:string, + constructorExpressions:string, destructorExpressions:string, + methodImplementations:string ) + { + + let cppImplementation = +` +/* ${className}.cpp */ + +#include "${className}.h" + +// Registers fields, signals and methods for Godot +void ${className}::_bind_methods() +{ + ${boundMethods} +} + +// Constructor +${className}::${className}() +{ + ${constructorExpressions} +} + +// Destructor +${className}::~${className}() +{ + ${destructorExpressions} +} + +${methodImplementations} + +` + + return cppImplementation; + + } + +} \ No newline at end of file diff --git a/rokojori-cpp-generator/source/cpp-creation/MemberInitializer.ts b/rokojori-cpp-generator/source/cpp-creation/MemberInitializer.ts new file mode 100644 index 0000000..1b9e108 --- /dev/null +++ b/rokojori-cpp-generator/source/cpp-creation/MemberInitializer.ts @@ -0,0 +1,12 @@ + +export class MemberInitializer +{ + accessModifier = ""; + type = "void"; + name = ""; + + isVirtual = true; + isSignal = false; + isMethod = false; + isStatic = false; +} \ No newline at end of file diff --git a/rokojori-cpp-generator/source/cpp-creation/MemberType.ts b/rokojori-cpp-generator/source/cpp-creation/MemberType.ts new file mode 100644 index 0000000..611215e --- /dev/null +++ b/rokojori-cpp-generator/source/cpp-creation/MemberType.ts @@ -0,0 +1,6 @@ +export enum MemberType +{ + Field, + Method, + Signal +} diff --git a/rokojori-cpp-generator/source/cpp-creation/Parameter.ts b/rokojori-cpp-generator/source/cpp-creation/Parameter.ts new file mode 100644 index 0000000..2f17a24 --- /dev/null +++ b/rokojori-cpp-generator/source/cpp-creation/Parameter.ts @@ -0,0 +1,10 @@ +export class Parameter +{ + name = ""; + type = ""; + + get() + { + return `${this.type} ${this.name}`; + } +} \ No newline at end of file diff --git a/rokojori-cpp-generator/source/cpp-creation/TypeRegistration.ts b/rokojori-cpp-generator/source/cpp-creation/TypeRegistration.ts new file mode 100644 index 0000000..73d610b --- /dev/null +++ b/rokojori-cpp-generator/source/cpp-creation/TypeRegistration.ts @@ -0,0 +1,46 @@ +import { Files } from "../library/Files"; +import { CppCreator } from "./CppCreator"; + +export class TypeRegistration +{ + static includesRegex = /\/\*INCLUDES\*\//; + static classDBRegistrationsRegex = /\/\*CLASS-DB-REGISTRATIONS\*\//; + + static exceptions = + [ + "RJGodotHeaders.h" + ]; + + static async createRegistrations() + { + let registrationImplementation = await Files.loadUTF8( CppCreator.registerTypesPath ); + let allFiles = await Files.getFiles( CppCreator.outputPath ); + let filter = ( file:string ) => + { + if ( TypeRegistration.exceptions.indexOf( file ) !== -1 ) + { + return false; + } + + return file.endsWith( ".h" ) && file != "register_types.h"; + }; + + let headers = allFiles.filter( file => filter( file ) ); + + let includeStatements = headers.map( h => `#include "./${h}"`); + let includes = includeStatements.join( "\n" ); + + registrationImplementation = + registrationImplementation.replace( TypeRegistration.includesRegex, includes ); + + let classNames = headers.map( h => h.replace( /\.h$/, "" ) ); + let registrators = classNames.map( cn => `ClassDB::register_class<${cn}>();`) + + let registrations = registrators.join( "\n " ); + registrationImplementation = + registrationImplementation.replace( TypeRegistration.classDBRegistrationsRegex, registrations ); + + await Files.saveUTF8( CppCreator.registerTypesPathOutput, registrationImplementation ); + + } +} \ No newline at end of file diff --git a/rokojori-cpp-generator/source/cpp-creation/VariationTemplates.ts b/rokojori-cpp-generator/source/cpp-creation/VariationTemplates.ts new file mode 100644 index 0000000..01511bf --- /dev/null +++ b/rokojori-cpp-generator/source/cpp-creation/VariationTemplates.ts @@ -0,0 +1,31 @@ +import { RJLog } from "../library/RJLog"; + +export type VariationDefinition = { [index:string]:string[] }; +export type VariationDefinitions = VariationDefinition[]; + +export class VariationTemplates +{ + static readonly genericOnlyIntNode:VariationDefinitions = + [ + { + "{DataTypeName}":[ "Int" ], + "{DataType}": [ "int" ], + "{Extension}": [ "" ], + "{ParentClass}": [ "Node" ] + + } + ]; + + static readonly generic:VariationDefinitions = + [ + { + "{DataTypeName}":[ "Bool", "Float", "Int", "Color", "Vector2", "Vector3", "Quaternion", "String", "Node", "Resource" ], + "{DataType}": [ "bool", "float", "int", "Color", "Vector2", "Vector3", "Quaternion", "String", "Ref", "Ref" ] + }, + + { + "{Extension}": [ "", "Global" ], + "{ParentClass}": [ "Node", "Resource" ] + } + ]; +} \ No newline at end of file diff --git a/rokojori-cpp-generator/source/cpp-creation/Variations.ts b/rokojori-cpp-generator/source/cpp-creation/Variations.ts new file mode 100644 index 0000000..4fb1aac --- /dev/null +++ b/rokojori-cpp-generator/source/cpp-creation/Variations.ts @@ -0,0 +1,124 @@ +import { RJLog } from "../library/RJLog"; +import { VariationDefinitions } from "./VariationTemplates"; + + +export class Variations +{ + _variationDefinitions:VariationDefinitions; + _indicies:number[] = []; + _lengths:number[] = []; + _items = 1; + _counter = 0; + _map = new Map(); + + constructor( vds:VariationDefinitions ) + { + this._variationDefinitions = vds; + + this._items = 1; + + vds.forEach( + vd => + { + this._indicies.push( 0 ); + + let length = -1; + + for ( let it in vd ) + { + if ( length !=-1 || ! vd.hasOwnProperty( it ) ) + { + continue; + } + + length = vd[ it ].length; + } + + this._lengths.push( length ); + + this._items *= length; + } + + ); + + console.log( "Found items:", this._items ); + + this._grabCurrentMap(); + } + + _grabCurrentMap() + { + this._map.clear(); + + for ( let i = 0; i < this._indicies.length; i++ ) + { + this._grabItems( i ); + } + } + + get hasItems() + { + return this._counter <= this._items; + } + + get items() + { + return this._items; + } + + get counter() + { + return this._counter; + } + + nextItem() + { + this._counter ++; + this._incrementCounter( 0 ); + + this._grabCurrentMap(); + + // RJLog.log( this._counter, this._indicies, this.currentMap ); + } + + _incrementCounter( position:number ) + { + let value = this._indicies[ position ]; + + if ( value == ( this._lengths[ position ] - 1 ) ) + { + this._indicies[ position ] = 0; + this._incrementCounter( position + 1 ); + } + else + { + this._indicies[ position ] ++; + } + + } + + _grabItems( index:number ) + { + let counter = this._indicies[ index ]; + let vd = this._variationDefinitions[ index ]; + let map = this._map; + + for ( let it in vd ) + { + if ( ! vd.hasOwnProperty( it ) ) + { + continue; + } + + let key = it; + let values = vd[ it ]; + + map.set( key, values[ counter ] ); + } + } + + get currentMap():Map + { + return this._map; + } +} \ No newline at end of file diff --git a/rokojori-cpp-generator/source/cpp-creation/factories/ActionFactory.ts b/rokojori-cpp-generator/source/cpp-creation/factories/ActionFactory.ts new file mode 100644 index 0000000..ecd32a8 --- /dev/null +++ b/rokojori-cpp-generator/source/cpp-creation/factories/ActionFactory.ts @@ -0,0 +1,21 @@ +import { Member } from "../members/Member"; +import { BaseFactory } from "./BaseFactory"; + +export class ActionFactory extends BaseFactory +{ + static readonly regex = /^\s*action\s+(\w+)\s*$/; + + constructor(){ super( ActionFactory.regex ); } + + create( accessModifier:string, nameDefinition:string, memberData:any, members:Member[] ) + { + let name = ActionFactory.regex.exec( nameDefinition )[ 1 ]; + let upperCaseName = name[ 0 ].toUpperCase() + name.substring( 1 ); + let actionName = `on${upperCaseName}`; + + let signal = `signal ${name}()`; + + members.push( this.createMember( accessModifier, signal, {} ) ); + members.push( this.createMember( accessModifier, actionName, "Node" ) ); + } +} diff --git a/rokojori-cpp-generator/source/cpp-creation/factories/BaseFactory.ts b/rokojori-cpp-generator/source/cpp-creation/factories/BaseFactory.ts new file mode 100644 index 0000000..af20f57 --- /dev/null +++ b/rokojori-cpp-generator/source/cpp-creation/factories/BaseFactory.ts @@ -0,0 +1,96 @@ +import { MemberInitializer } from "../MemberInitializer"; +import { Field } from "../members/Field"; +import { Member } from "../members/Member"; +import { Method } from "../members/Method"; +import { Signal } from "../members/Signal"; + +export abstract class BaseFactory +{ + _regex:RegExp; + + constructor( regex:RegExp ) + { + this._regex = regex; + } + + handles( nameDefinition:string ) + { + return this._regex.test( nameDefinition ); + } + + abstract create( accessModifier:string, nameDefinition:string, memberData:any, members:Member[] ):void; + + createMember( accessModifier:string, nameDefinition:string, body:any ) + { + return BaseFactory.createMemberFrom( accessModifier, nameDefinition, body ) as T; + } + + static createMemberFrom( accessModifier:string, nameDefinition:string, body:any ) + { + + let memberInitializer = new MemberInitializer(); + + + if ( nameDefinition.indexOf( "()" ) != -1) + { + memberInitializer.isMethod = true; + memberInitializer.isVirtual = true; + + let typeRegex = /\(\)\s*(?:\:\s*(.+)\s*)?$/; + let result = typeRegex.exec( nameDefinition ); + + if ( result[ 1 ] ) + { + memberInitializer.type = result[ 1 ]; + } + + nameDefinition = nameDefinition.replace( typeRegex, "" ); + } + + let names = nameDefinition.split( /\s+/ ); + memberInitializer.name = names[ names.length -1 ]; + + for ( let i = 0; i < names.length - 1; i++ ) + { + if ( "final" === names[ i ] ) + { + memberInitializer.isVirtual = false; + } + + if ( "static" === names[ i ] ) + { + memberInitializer.isStatic = true; + } + + if ( "signal" === names[ i ] ) + { + memberInitializer.isSignal = true; + } + + } + + let member:Member = null; + + if ( memberInitializer.isMethod ) + { + if ( memberInitializer.isSignal ) + { + member = new Signal( memberInitializer ); + } + else + { + member = new Method( memberInitializer ); + } + + } + else + { + member = new Field( memberInitializer ); + } + + member.accessModifier = accessModifier; + member.parseBody( body ); + + return member; + } +} \ No newline at end of file diff --git a/rokojori-cpp-generator/source/cpp-creation/factories/MemberFactory.ts b/rokojori-cpp-generator/source/cpp-creation/factories/MemberFactory.ts new file mode 100644 index 0000000..84fc8d3 --- /dev/null +++ b/rokojori-cpp-generator/source/cpp-creation/factories/MemberFactory.ts @@ -0,0 +1,175 @@ +import { Member } from "../members/Member"; +import { MemberInitializer } from "../MemberInitializer"; +import { Method } from "../members/Method"; +import { Field } from "../members/Field"; +import { Signal } from "../members/Signal"; +import { ActionFactory } from "./ActionFactory"; +import { PropertyFactory } from "./PropertyFactory"; +import { BaseFactory } from "./BaseFactory"; + + +export class MemberFactory +{ + static readonly actionRegex = /^\s*action\s+(\w+)\s*$/; + static readonly propertyRegex = /^\s*property(?:\s*\@\s*(\w+))?\s+(\w+)\s*$/; + + static factories:BaseFactory[] = + [ + new ActionFactory(), + new PropertyFactory() + ] + + static grabMembers( membersData:any, accessModifier:string ) + { + let members:Member[] = []; + + if ( ! membersData ) + { + return members; + } + + for ( let it in membersData ) + { + if ( ! membersData.hasOwnProperty( it ) ) + { + continue; + } + + let nameDefinition = it; + let memberData = membersData[ it ]; + + let factory = this.factories.find( f => f.handles( nameDefinition ) ); + + if ( factory ) + { + factory.create( accessModifier, nameDefinition, memberData, members ); + } + else + { + members.push( BaseFactory.createMemberFrom( accessModifier, nameDefinition, memberData ) ); + } + + /* + if ( MemberFactory.actionRegex.test( nameDefinition ) ) + { + let name = MemberFactory.actionRegex.exec( nameDefinition )[ 1 ]; + let upperCaseName = name[ 0 ].toUpperCase() + name.substring( 1 ); + let actionName = `on${upperCaseName}`; + + let signal = `signal ${name}()`; + + members.push( MemberFactory.create( accessModifier, signal, {} ) ); + members.push( MemberFactory.create( accessModifier, actionName, "Node" ) ); + } + else if ( MemberFactory.propertyRegex.test( nameDefinition ) ) + { + let result = MemberFactory.propertyRegex.exec( nameDefinition ); + + let signalName = result[ 1 ]; + let fieldName = result[ 2 ]; + + signalName = signalName || `${fieldName}Changed`; + + let upperCaseName = signalName[ 0 ].toUpperCase() + signalName.substring( 1 ); + let actionName = `on${upperCaseName}`; + + let signal = `signal ${signalName}()`; + + if ( ! result[ 1 ] ) + { + members.push( MemberFactory.create( accessModifier, signal, {} ) ); + members.push( MemberFactory.create( accessModifier, actionName, "Node" ) ); + } + + let field = MemberFactory.create( accessModifier, fieldName, memberData ) as Field; + + field.isProperty = true; + field.propertySignalName = signalName; + field.propertyActionName = actionName; + + members.push( field ); + } + else + { + let classMember = MemberFactory.create( accessModifier, nameDefinition, memberData ); + members.push( classMember ); + } + + */ + + } + + return members; + } + + /*static create( accessModifier:string, nameDefinition:string, body:any ) + { + + let memberInitializer = new MemberInitializer(); + + + if ( nameDefinition.indexOf( "()" ) != -1) + { + memberInitializer.isMethod = true; + memberInitializer.isVirtual = true; + + let typeRegex = /\(\)\s*(?:\:\s*(.+)\s*)?$/; + let result = typeRegex.exec( nameDefinition ); + + if ( result[ 1 ] ) + { + memberInitializer.type = result[ 1 ]; + } + + nameDefinition = nameDefinition.replace( typeRegex, "" ); + } + + let names = nameDefinition.split( /\s+/ ); + memberInitializer.name = names[ names.length -1 ]; + + for ( let i = 0; i < names.length - 1; i++ ) + { + if ( "final" === names[ i ] ) + { + memberInitializer.isVirtual = false; + } + + if ( "static" === names[ i ] ) + { + memberInitializer.isStatic = true; + } + + if ( "signal" === names[ i ] ) + { + memberInitializer.isSignal = true; + } + + } + + let member:Member = null; + + if ( memberInitializer.isMethod ) + { + if ( memberInitializer.isSignal ) + { + member = new Signal( memberInitializer ); + } + else + { + member = new Method( memberInitializer ); + } + + } + else + { + member = new Field( memberInitializer ); + } + + member.accessModifier = accessModifier; + member.parseBody( body ); + + return member; + } + + */ +} \ No newline at end of file diff --git a/rokojori-cpp-generator/source/cpp-creation/factories/PropertyFactory.ts b/rokojori-cpp-generator/source/cpp-creation/factories/PropertyFactory.ts new file mode 100644 index 0000000..b1bbdf8 --- /dev/null +++ b/rokojori-cpp-generator/source/cpp-creation/factories/PropertyFactory.ts @@ -0,0 +1,73 @@ +import { Field } from "../members/Field"; +import { Member } from "../members/Member"; +import { BaseFactory } from "./BaseFactory"; + +export class PropertyFactory extends BaseFactory +{ + static readonly regex = /^\s*property\s+(\w+)\s*$/; + + constructor(){ super( PropertyFactory.regex ); } + + create( accessModifier:string, nameDefinition:string, memberData:any, members:Member[] ) + { + let result = PropertyFactory.regex.exec( nameDefinition ); + + let fieldName = result[ 1 ]; + + let upperCaseName = fieldName[ 0 ].toUpperCase() + fieldName.substring( 1 ) + + let signalName = `${fieldName}Changed`; + + let upperCaseSignalName = signalName[ 0 ].toUpperCase() + signalName.substring( 1 ); + let actionName = `on${upperCaseSignalName}`; + + let signalMethodDefinition = `signal ${signalName}()`; + + + + let field = this.createMember( accessModifier, fieldName, memberData ); + + field.isProperty = true; + field.propertySignalName = signalName; + field.propertyActionName = actionName; + + + members.push( field ); + + + members.push( this.createMember( accessModifier, signalMethodDefinition, {} ) ); + members.push( this.createMember( accessModifier, actionName, "Node" ) ); + + + let dispatchChanged = this.createMember( accessModifier, + + `final dispatch${upperCaseName}Changed()`, [ {}, + [ + `emit_signal( SNAME( "${signalName}" ) );`, + "", + `if ( ${actionName} != NULL )`, + "{", + ` ${actionName}->trigger();`, + "}" + ] + ] + ); + + + members.push( dispatchChanged ); + + + + let setSilent = this.createMember( accessModifier, + + `final set${upperCaseName}Silent()`, [ { "p_value": memberData}, + [ + "value = p_value;" + ] + ] + ); + + members.push( setSilent ); + + } +} \ No newline at end of file diff --git a/rokojori-cpp-generator/source/cpp-creation/members/Field.ts b/rokojori-cpp-generator/source/cpp-creation/members/Field.ts new file mode 100644 index 0000000..997af90 --- /dev/null +++ b/rokojori-cpp-generator/source/cpp-creation/members/Field.ts @@ -0,0 +1,197 @@ +import { RJLog } from "../../library/RJLog"; +import { GodotTypes } from "../GodotTypes"; +import { MemberInitializer } from "../MemberInitializer"; +import { MemberType } from "../MemberType"; +import { Member } from "./Member"; + +export class Field extends Member +{ + static readonly Node = "Node"; + static readonly Resource = "Resource"; + + constructor( memberInitializer:MemberInitializer ) + { + super( MemberType.Field, memberInitializer ); + } + + isReference = false; + referenceType = ""; + isProperty = false; + propertySignalName = ""; + propertyActionName = ""; + + parseBody( body:any ) + { + if ( typeof body === "boolean" ) + { + this.type = "bool"; + this.initialValue = body + ""; + return; + } + + if ( typeof body === "number" ) + { + this.type = "float"; + this.initialValue = body + ""; + return; + } + + let regex = /((?:\w|\<|\>)+)(?:\s*\=\s*(.+))?/; + let result = regex.exec( body ); + let typeOrRefRegex = /^(Ref|Resource|Node)/; + + let typeResult = result[ 1 ] + + this.isReference = typeOrRefRegex.test( typeResult ); + + // RJLog.log( "Is Reference", this.name, this.isReference, typeResult ); + + if ( this.isReference ) + { + this.referenceType = refRegex.test( typeResult ) ? refRegex.exec( typeResult )[ 1 ] : + typeOrRefRegex.exec( typeResult )[ 1 ]; + + // RJLog.log( "referenceType", body, `"${this.referenceType}"`, typeResult ); + + if ( Field.Node === this.referenceType ) + { + typeResult = typeResult.replace( typeOrRefRegex, "" ).replace( />$/, ""); + typeResult = typeResult + "*"; + } + else + { + typeResult = typeResult.replace( typeOrRefRegex, "Ref<" ); + + if ( result.length >= 2 ) + { + this.initialValue = result[ 2 ]; + } + } + + } + + this.type = typeResult; + this.initialValue = result[ 2 ] || null; + + } + + getFieldDeclaration() + { + let fieldInfo = "\n " + this.info() + "\n "; + + if ( Field.Node === this.referenceType ) + { + return `${fieldInfo}${this.type} ${this.name} = nullptr;`; + } + + return `${fieldInfo}${this.type} ${this.name};` + } + + getHeaderDefinition():string + { + let fieldInfo = "\n " + this.info() + "\n "; + + if ( Field.Node === this.referenceType ) + { + return `${fieldInfo}${this.type} get_${this.name}() const; void set_${this.name}( ${this.type} p_${this.name} );`; + } + + if ( Field.Resource === this.referenceType ) + { + return `${fieldInfo}${this.type} get_${this.name}() const; void set_${this.name}( const ${this.type} &p_${this.name} );`; + } + + return `${fieldInfo}${this.type} get_${this.name}(); void set_${this.name}( ${this.type} p_${this.name} );` + } + + getBindings( className:string ):string + { + + + let bindings = []; + + bindings.push( `// ${this.name}: ${this.type}` ); + + bindings.push( `ClassDB::bind_method( D_METHOD( "set_${this.name}", "${this.name}" ), &${className}::set_${this.name} );` ); + bindings.push( `ClassDB::bind_method( D_METHOD( "get_${this.name}"), &${className}::get_${this.name});` ); + + + if ( this.isReference ) + { + // ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "reference_property", PROPERTY_HINT_NODE_TYPE), "set_reference_property", "get_reference_property"); + // RJLog.log( "Searching propertyHint:", this.name, this.type, this.referenceType ); + let propertyHint = GodotTypes.stringToPropertyHint( this.referenceType ); + + bindings.push( `ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "${this.name}", ${propertyHint} ), "set_${this.name}", "get_${this.name}" );` ); + + } + else + { + let type = GodotTypes.stringToVariantType( this.type ); + bindings.push( `ADD_PROPERTY(PropertyInfo( Variant::${type}, "${this.name}" ), "set_${this.name}", "get_${this.name}" );` ); + } + + bindings.push( ` ` ); + + //ClassDB::bind_method(D_METHOD("set_color", "color"), &GLTFLight::set_color); + //ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color"); // Color + + return bindings.join( "\n " ); + + } + + + getFieldImplementation( className:string ) + { + let implementations = []; + + implementations.push( `// ${this.name}: ${this.type}` ); + + let eventCallbacks = ""; + + if ( this.isProperty ) + { + eventCallbacks += `\n`; + eventCallbacks += `\n emit_signal( SNAME( "${this.propertySignalName}" ) );`; + eventCallbacks += `\n`; + eventCallbacks += `\n if ( ${this.propertyActionName} != NULL )`; + eventCallbacks += `\n {`; + eventCallbacks += `\n ${this.propertyActionName}->trigger();`; + eventCallbacks += `\n }`; + } + + let n = this.isProperty ? "\n" : ""; + let n2 = this.isProperty ? "\n " : ""; + + if ( Field.Node === this.referenceType ) + { + implementations.push( `${this.type} ${className}::get_${this.name}() const { return ${this.name}; }` ); + implementations.push( `void ${className}::set_${this.name}( ${this.type} p_${this.name} ) ${n}{${n2} ${this.name} = p_${this.name};${eventCallbacks} ${n}}` ); + } + else if ( Field.Resource === this.referenceType ) + { + implementations.push( `${this.type} ${className}::get_${this.name}() const { return ${this.name}; }` ); + implementations.push( `void ${className}::set_${this.name}( const ${this.type} &p_${this.name} ) ${n}{${n2} ${this.name} = p_${this.name};${eventCallbacks} ${n}}` ); + } + else + { + implementations.push( `${this.type} ${className}::get_${this.name}() { return ${this.name}; }` ); + implementations.push( `void ${className}::set_${this.name}( ${this.type} p_${this.name} ) ${n}{${n2} ${this.name} = p_${this.name};${eventCallbacks} ${n}}` ); + } + + implementations.push( ` ` ); + + return implementations.join( "\n" ); + } + + get hasInitializer() + { + return this.initialValue !== null; + } + + getInitializer() + { + return `${this.name} = ${this.initialValue};`; + } +} \ No newline at end of file diff --git a/rokojori-cpp-generator/source/cpp-creation/members/Member.ts b/rokojori-cpp-generator/source/cpp-creation/members/Member.ts new file mode 100644 index 0000000..8e53794 --- /dev/null +++ b/rokojori-cpp-generator/source/cpp-creation/members/Member.ts @@ -0,0 +1,132 @@ +import { GodotTypes } from "../GodotTypes"; +import { MemberInitializer } from "../MemberInitializer"; +import { MemberType } from "../MemberType"; +import { Parameter } from "../Parameter"; + + +export abstract class Member +{ + memberType:MemberType; + name = ""; + isMethod = false; + isVirtual = true; + isStatic = false; + isSignal = false; + type = "void"; + initialValue:string = null; + parameters:Parameter[] = []; + accessModifier = ""; + parametersDefinition = ""; + + constructor( memberType:MemberType, memberInitializer:MemberInitializer ) + { + this.memberType = memberType; + + this.accessModifier = memberInitializer.accessModifier; + this.name = memberInitializer.name; + this.type = memberInitializer.type || this.type; + + this.isMethod = memberInitializer.isMethod; + this.isSignal = memberInitializer.isSignal; + this.isStatic = memberInitializer.isStatic; + this.isVirtual = memberInitializer.isVirtual; + } + + info() + { + let methodBrackets = this.isMethod ? "()" : ""; + + if ( methodBrackets === "()" && this.parameters.length > 0 ) + { + methodBrackets = "( " + this.parametersDefinition + " )"; + } + + if ( this.isSignal ) + { + + } + + return `// ${this.isSignal? "[signal] ": "" }${this.name}${methodBrackets} : ${this.type}`; + } + + setPublic() + { + this.accessModifier = "public"; + return this; + } + + setProtected() + { + this.accessModifier = "protected"; + return this; + } + + abstract parseBody( body:any ):void + + + + + parseMethodParameters( body:any ) + { + if ( ! body ) + { + return; + } + + if ( typeof body === "string" ) + { + this.type = body; + + return; + } + + for ( let it in body ) + { + if ( ! body.hasOwnProperty( it ) ) + { + continue; + } + + let cppParameter = new Parameter(); + cppParameter.name = it; + cppParameter.type = body[ it ]; + + this.parameters.push( cppParameter ); + } + + this.parametersDefinition = this.parameters.map( p => p.get() ).join( ", " ); + + } + + abstract getBindings( className:string ):string + + abstract getHeaderDefinition():string; + + getParametersDefinition() + { + return this.parameters.map( p => p.type + " " + p.name ).join( ", " ); + } + + /* + getFieldDeclaration() + { + return `${this.type} ${this.name};` + } + + getFieldImplementation( className:string ) + { + let bindings = []; + + bindings.push( `// ${this.name}: ${this.type}` ); + bindings.push( `${this.type} ${className}::get_${this.name}() { return ${this.name}; }` ); + bindings.push( `void ${className}::set_${this.name}( ${this.type} p_${this.name} ) { ${this.name} = p_${this.name}; }` ); + bindings.push( ` ` ); + + return bindings.join( "\n" ); + } + + */ + +} + + diff --git a/rokojori-cpp-generator/source/cpp-creation/members/Method.ts b/rokojori-cpp-generator/source/cpp-creation/members/Method.ts new file mode 100644 index 0000000..7dc6efc --- /dev/null +++ b/rokojori-cpp-generator/source/cpp-creation/members/Method.ts @@ -0,0 +1,107 @@ + +import { MemberInitializer } from "../MemberInitializer"; +import { MemberType } from "../MemberType"; +import { Member } from "./Member"; + +export class Method extends Member +{ + constructor( memberInitializer:MemberInitializer ) + { + super( MemberType.Method, memberInitializer ); + } + + implementation:string[] = null; + + get hasMethodImplementation() + { + return this.implementation != null; + } + + getMethodImplementation( className:string ) + { + let lines = []; + + lines.push( this.info() ); + lines.push( `${this.type} ${className}::${this.name}${this.parameterWithBrackets}`); + lines.push( "{" ); + + this.implementation.forEach( l => lines.push( " " + l ) ); + lines.push( "}" ); + + return lines.join( "\n" ) + "\n"; + } + + parseBody( body:any ) + { + if ( Array.isArray( body ) ) + { + let parameters = body[ 0 ]; + let lines = body[ 1 ]; + + this.parseMethodParameters( parameters ); + this.implementation = lines; + } + else + { + return this.parseMethodParameters( body ); + } + + } + + get parameterWithBrackets() + { + let parameters = this.parametersDefinition === "" ? "()" : + `( ${this.parametersDefinition} )`; + + return parameters; + } + + getHeaderDefinition():string + { + let methodInfo = "\n " + this.info() + "\n "; + + if ( this.isVirtual ) + { + let numParameters = this.parameters.length; + let methodReturnType = this.type === "void" ? "" : "R"; + let returnTypeDefinition = this.type === "void" ? "" : ( this.type + ", " ) ; + + let parametersDefinition = ""; + + if ( numParameters > 0 ) + { + parametersDefinition = ", " + this.parameters.map( p => p.type ).join( ", " ); + } + + + return `${methodInfo}GDVIRTUAL${numParameters}${methodReturnType}( ${returnTypeDefinition}${this.name}${parametersDefinition} );` + } + + let parameters = this.parameterWithBrackets; + + return `${methodInfo}${this.type} ${this.name}${parameters};` + } + + + + getBindings( className:string ) + { + if ( this.isVirtual ) + { + let parameterInfos = ""; + + for ( let i = 0; i < this.parameters.length; i++ ) + { + let name = `, "${this.parameters[ i ].name}"`; + + parameterInfos += name; + } + + return `GDVIRTUAL_BIND( ${this.name}${parameterInfos} );`; + } + else + { + return `ClassDB::bind_method( D_METHOD( "${this.name}" ) , &${className}::${this.name} );` + } + } +} \ No newline at end of file diff --git a/rokojori-cpp-generator/source/cpp-creation/members/Signal.ts b/rokojori-cpp-generator/source/cpp-creation/members/Signal.ts new file mode 100644 index 0000000..a32a9e5 --- /dev/null +++ b/rokojori-cpp-generator/source/cpp-creation/members/Signal.ts @@ -0,0 +1,42 @@ + +import { GodotTypes } from "../GodotTypes"; +import { MemberInitializer } from "../MemberInitializer"; +import { MemberType } from "../MemberType"; +import { Member } from "./Member"; + +export class Signal extends Member +{ + constructor( memberInitializer:MemberInitializer ) + { + super( MemberType.Signal, memberInitializer ); + } + + parseBody( body:any ) + { + return this.parseMethodParameters( body ); + } + + + getHeaderDefinition():string + { + return "\n " + this.info(); + } + + getBindings( className:string ) + { + //ADD_SIGNAL(MethodInfo("session_supported", PropertyInfo(Variant::STRING, "session_mode"), PropertyInfo(Variant::BOOL, "supported"))); + let parameterInfos = ""; + + for ( let i = 0; i < this.parameters.length; i++ ) + { + let type = GodotTypes.stringToVariantType( this.parameters[ i ].type ); + let name = this.parameters[ i ].name; + + let pi = `, PropertyInfo(Variant::${type}, "${name}")`; + + parameterInfos += pi; + } + + return `ADD_SIGNAL (MethodInfo( "${this.name}" ${parameterInfos}) );`; + } +} \ No newline at end of file diff --git a/rokojori-cpp-generator/source/create-cpp.ts b/rokojori-cpp-generator/source/create-cpp.ts new file mode 100644 index 0000000..0d37b93 --- /dev/null +++ b/rokojori-cpp-generator/source/create-cpp.ts @@ -0,0 +1,88 @@ +import { CppCreator } from "./cpp-creation/CppCreator"; +import { TypeRegistration } from "./cpp-creation/TypeRegistration"; +import { Files } from "./library/Files"; +import { MatchResult } from "./library/MatchResult"; +import { RJLog } from "./library/RJLog"; +import { Texts } from "./library/Texts"; + +class CreateCpp +{ + static async main() + { + RJLog.log( "Clear old cpp files" ); + await this.clearCppFiles(); + + RJLog.log( "Generate cpp files from definitions" ); + let files = await this.getCppFiles(); + + for ( let file of files ) + { + var cppFilePath = Texts.joinPaths( CppCreator.definitionsPath, file ); + await CppCreator.createCppFiles( cppFilePath); + } + + RJLog.log( "Copy raw cpp files" ); + await this.copyRaw(); + + RJLog.log( "Register types" ); + await TypeRegistration.createRegistrations(); + + } + + static cppExtensionRegex = /\.(h|cpp)$/;; + + static async clearCppFiles() + { + let allFiles = await Files.getFiles( CppCreator.outputPath ); + + let cppFiles = allFiles.filter( file => CreateCpp.cppExtensionRegex.test( file ) ); + + for ( let cppFile of cppFiles ) + { + let fullPath = Texts.joinPaths( CppCreator.outputPath, cppFile ); + + //RJLog.log( "deleting", fullPath ); + await Files.delete( fullPath ); + } + } + + static async getCppFiles() + { + let files = await Files.getFiles( CppCreator.definitionsPath ); + files = files.filter( f => ! f.startsWith( "_" ) ); + + return Promise.resolve( files ); + } + + static async copyRaw() + { + let files = await Files.getFilesRecursive( CppCreator.rawPath ); + + for ( let i = 0; i < files.length; i++ ) + { + let fileName = Texts.fileName( files[ i ] ); + + if ( fileName.startsWith( "_" ) || ! CreateCpp.cppExtensionRegex.test( fileName ) ) + { + continue; + } + + let fullPath = Texts.joinPaths( CppCreator.rawPath, files[ i ] ); + let isDirectory = await Files.isDirectory( fullPath ); + + if ( isDirectory ) + { + continue; + } + + let outputFullPath = Texts.joinPaths( CppCreator.outputPath, fileName ); + + // RJLog.log( "copying:", fileName, "\n" + fullPath, "\n", outputFullPath ); + + await Files.copy( fullPath, outputFullPath ); + + } + } +} + +CreateCpp.main(); diff --git a/rokojori-cpp-generator/source/create-output.ts b/rokojori-cpp-generator/source/create-output.ts new file mode 100644 index 0000000..df5dac6 --- /dev/null +++ b/rokojori-cpp-generator/source/create-output.ts @@ -0,0 +1,106 @@ +import { RJLog } from "./library/RJLog"; + +const { argv } = require("process"); +const path = require( "path" ); +const fs = require( "node:fs/promises" ); +const { exists } = require( "./library.js" ); + + +let targetDirectory = "outputs"; +let godotName = "godot-4.3-dev-rokojori"; +let platform = "argv[ 2 ]"; +let godotPlatformName = godotName + "-" + "argv[ 2 ]"; +let platformTargetDirectory = path.join( targetDirectory, godotPlatformName ); + +async function main() +{ + + if ( argv.length !== 3 ) + { + let platforms = [ "windows" ]; + + console.error( "Platform missing in the command. Add one of these to the command line:", platforms.join( ", " ) ); + + return; + } + + platform = argv[ 2 ]; + godotPlatformName = godotName + "-" + argv[ 2 ]; + platformTargetDirectory = path.join( targetDirectory, godotPlatformName ); + + RJLog.log( "Creating output" ); + + await deleteOldDirectory(); + await createDirectory(); + + + RJLog.log( "Output done" ); +} + + +async function deleteOldDirectory() +{ + + let directoryExists = await exists( platformTargetDirectory ); + + RJLog.log( "checking if old directory exists", directoryExists ); + + if ( directoryExists ) + { + RJLog.log( `deleting previous directory: "${platformTargetDirectory}"` ); + await fs.rm( platformTargetDirectory, { recursive: true } ); + } + + return Promise.resolve(); +} + +async function createDirectory() +{ + RJLog.log( `creating directory: "${platformTargetDirectory}"` ); + await fs.mkdir( platformTargetDirectory, { recursive: true } ); + + + + let godotFrom = "godot/bin"; + let godotTo = path.join( platformTargetDirectory, "godot" ); + + RJLog.log( `copying godot: "${godotFrom}" >> "${godotTo}"` ); + + await fs.cp( godotFrom, godotTo, { recursive : true } ); + + + + let npFrom = "godot-rj-nuget-package"; + let npTo = path.join( platformTargetDirectory, npFrom ); + + RJLog.log( `copying nupkg: "${npFrom}" >> "${npTo}"` ); + + await fs.cp( npFrom, npTo, { recursive : true } ); + + + let installerFiles:{[index:string]:string[]} = + { + "windows" : + [ + "install-godot-windows.bat", + "install-godot-windows-readme.txt" + ] + }; + + let installers = installerFiles[ platform ]; + + for ( let installer of installers ) + { + let installFrom = "install-scripts/" + installer; + + let installTo = path.join( platformTargetDirectory, installer ); + + RJLog.log( `copying installer: "${installFrom}" >> "${installTo}"` ); + + await fs.cp( installFrom, installTo, { recursive : true } ); + } + +} + + +main(); diff --git a/rokojori-cpp-generator/source/library/Files.ts b/rokojori-cpp-generator/source/library/Files.ts new file mode 100644 index 0000000..96c1da4 --- /dev/null +++ b/rokojori-cpp-generator/source/library/Files.ts @@ -0,0 +1,115 @@ +import { promises as fs } from "fs"; +import { RJLog } from "./RJLog"; + +export class Files +{ + static async getFiles( filePath:string ) + { + return await fs.readdir( filePath ); + } + + static async copy( from:string, to:string ) + { + return await fs.copyFile( from, to ); + } + + + static async getFilesRecursive( filePath:string ) + { + let files = await fs.readdir( filePath, { recursive: true } ); + return files; + } + + + static async delete( filePath:string ) + { + await fs.unlink( filePath ); + return Promise.resolve(); + } + + static async isDirectory( filePath:string ) + { + let stats = await fs.stat( filePath ); + + return stats.isDirectory(); + } + + static async exists( filePath:string ) + { + try + { + let stats = await fs.stat( filePath ); + let exists = stats !== undefined && stats !== null; + return Promise.resolve( exists ); + } + catch( e ) + { + + } + + return Promise.resolve( false ); + } + + static async loadUTF8( filePath:string ):Promise + { + try + { + let data = await fs.readFile( filePath ); + let stringData = data.toString(); + return Promise.resolve( stringData ); + } + catch ( exception ) + { + RJLog.warn( "loadUTF8: ", filePath ); + RJLog.warn( exception ); + } + + return Promise.resolve( null ); + + } + + static async saveUTF8( filePath:string, data:string ) + { + try + { + await fs.writeFile( filePath, data ); + return Promise.resolve( true ); + } + catch ( exception ) + { + RJLog.warn( "saveUTF8: ", filePath ); + RJLog.warn( exception ); + } + + return Promise.resolve( false ); + + } + + + + static async loadJSON( filePath:string ):Promise + { + let text = await this.loadUTF8( filePath ); + + if ( text === null ) + { + return Promise.resolve( null ) as T; + } + + try + { + let jsonObject = JSON.parse( text ); + + return Promise.resolve( jsonObject ); + } + catch ( exception ) + { + RJLog.warn( "LoadJSON: ", filePath ); + RJLog.warn( exception ); + } + + return Promise.resolve( null ); + } + + +} \ No newline at end of file diff --git a/rokojori-cpp-generator/source/library/LogColors.ts b/rokojori-cpp-generator/source/library/LogColors.ts new file mode 100644 index 0000000..1d58ca5 --- /dev/null +++ b/rokojori-cpp-generator/source/library/LogColors.ts @@ -0,0 +1,31 @@ +export class LogColors +{ + static readonly reset = "\x1b[0m"; + static readonly bright = "\x1b[1m"; + static readonly dim = "\x1b[2m"; + static readonly underscore = "\x1b[4m"; + static readonly blink = "\x1b[5m"; + static readonly reverse = "\x1b[7m"; + static readonly hidden = "\x1b[8m"; + + static readonly black_Foreground = "\x1b[30m"; + static readonly red_Foreground = "\x1b[31m"; + static readonly green_Foreground = "\x1b[32m"; + static readonly yellow_Foreground = "\x1b[33m"; + static readonly blue_Foreground = "\x1b[34m"; + static readonly magenta_Foreground = "\x1b[35m"; + static readonly cyan_Foreground = "\x1b[36m"; + static readonly white_Foreground = "\x1b[37m"; + static readonly gray_Foreground = "\x1b[90m"; + + static readonly black_Background = "\x1b[40m"; + static readonly red_Background = "\x1b[41m"; + static readonly green_Background = "\x1b[42m"; + static readonly yellow_Background = "\x1b[43m"; + static readonly blue_Background = "\x1b[44m"; + static readonly magenta_Background = "\x1b[45m"; + static readonly cyan_Background = "\x1b[46m"; + static readonly white_Background = "\x1b[47m"; + static readonly gray_Background = "\x1b[100m"; + +} \ No newline at end of file diff --git a/rokojori-cpp-generator/source/library/MatchResult.ts b/rokojori-cpp-generator/source/library/MatchResult.ts new file mode 100644 index 0000000..483f57f --- /dev/null +++ b/rokojori-cpp-generator/source/library/MatchResult.ts @@ -0,0 +1,6 @@ +export class MatchResult +{ + match:string; + index:number + type:string; +} \ No newline at end of file diff --git a/rokojori-cpp-generator/source/library/Objects.ts b/rokojori-cpp-generator/source/library/Objects.ts new file mode 100644 index 0000000..bca31f0 --- /dev/null +++ b/rokojori-cpp-generator/source/library/Objects.ts @@ -0,0 +1,8 @@ +export class Objects +{ + static jsonClone( obj:T ):T + { + let jsonData = JSON.stringify( obj ); + return JSON.parse( jsonData ) as T; + } +} \ No newline at end of file diff --git a/rokojori-cpp-generator/source/library/RJLog.ts b/rokojori-cpp-generator/source/library/RJLog.ts new file mode 100644 index 0000000..15d731d --- /dev/null +++ b/rokojori-cpp-generator/source/library/RJLog.ts @@ -0,0 +1,132 @@ +import { LogColors } from "./LogColors"; +import { Texts } from "./Texts"; + +export class RJLog +{ + static readonly errorColor = LogColors.red_Background; + static readonly errorMessageColor = LogColors.red_Foreground; + static readonly warnColor = LogColors.yellow_Background; + static readonly logColor = LogColors.gray_Background + static readonly resetColor = LogColors.reset; + + static readonly matcherWithFunction = /^\s+at\s(.+)\s\(.+?:(\d+:\d+)\)/; + static readonly matcherFile = /\(.+?\\(\w+)\.js:(\d+:\d+)\)/; + static readonly matcherAnonymous = /^\s+at\s(.+)\s\((.+)\)/; + + static readonly logAlwaysLineInfo = true; + + + static _parseLineResult( line:string ):RegExpExecArray + { + let result = RJLog.matcherWithFunction.exec( line ) || + RJLog.matcherFile.exec( line ) || + RJLog.matcherAnonymous.exec( line ); + + return result; + } + + static _parseLine( line:string ):string + { + let result = RJLog._parseLineResult( line ); + + if ( result ) + { + return " " + result[ 1 ] + "(" + result[ 2 ] + ") "; + } + + return line; + } + + static logError( e:Error ) + { + console.log( "\n" + RJLog._formatErrorMessage( e.stack ) ); + } + + static _formatErrorMessage( stackTrace:string, color:string = RJLog.errorMessageColor ) + { + let lines = Texts.splitLines( stackTrace ); + let output:string[] = [ color ]; + + lines.forEach( + ( line, index ) => + { + let lineInfo = RJLog._parseLine( line ); + + output.push( lineInfo ); + + if ( index !== lines.length - 1 ) + { + output.push( "\n" ); + } + + } + ) + + output.push( RJLog.resetColor ); + + return output.join( "" ); + } + + static getLineInfo( color:string = RJLog.logColor, stackTrace?:string, lineIndex:number = 3 ) + { + stackTrace = stackTrace || ( new Error().stack + "" ); + + let lines = Texts.splitLines( stackTrace ); + + let result:RegExpExecArray = null; + + while ( ! result && lineIndex < lines.length ) + { + let line = lines[ lineIndex ]; + + result = RJLog._parseLineResult( line ) ; + + lineIndex ++; + } + + + if ( ! result ) + { + console.log( stackTrace ); + return color + " " + RJLog.resetColor ; + } + + return color + " " + result[ 1 ] + "(" + result[ 2 ] + ") " + RJLog.resetColor; + } + + + static error( ...params:any[] ) + { + if ( RJLog.logAlwaysLineInfo || typeof process === "object" ) + { + let lineInfo = RJLog.getLineInfo( RJLog.errorColor ); + console.log( "\n" + lineInfo ); + } + + console.error.apply( console, params ); + + } + + static warn( ...params:any[] ) + { + if ( RJLog.logAlwaysLineInfo || typeof process === "object" ) + { + let lineInfo = RJLog.getLineInfo( RJLog.warnColor ); + console.log( "\n" + lineInfo ); + } + + console.warn.apply( console, params ); + } + + + static log( ...params:any[] ) + { + if ( RJLog.logAlwaysLineInfo || typeof process === "object" ) + { + let lineInfo = RJLog.getLineInfo(); + console.log( "\n" + lineInfo ); + } + + console.log.apply( console, params ); + } +} \ No newline at end of file diff --git a/rokojori-cpp-generator/source/library/Texts.ts b/rokojori-cpp-generator/source/library/Texts.ts new file mode 100644 index 0000000..086c55d --- /dev/null +++ b/rokojori-cpp-generator/source/library/Texts.ts @@ -0,0 +1,154 @@ +import path from "path"; +import { text } from "stream/consumers"; +import { MatchResult } from "./MatchResult"; + + + +export class Texts +{ + static joinPaths( ...paths:string[] ) + { + return path.join.apply( null, paths ); + } + + static makeSticky( regexp:RegExp ) + { + if ( regexp.sticky ) + { + return regexp; + } + + var source = regexp.source; + var flags = regexp.flags; + + if ( flags.indexOf( "y" ) === -1 ) + { + flags += "y"; + } + + return new RegExp( source, flags ); + } + + static splitLines( text:string ) + { + return text.split( /(?:\r\n)|\n|\r/g ); + } + + static fileName( fullPath:string ) + { + return path.basename( fullPath ); + } + + static splitLinesCaptureBreaks( text:string ) + { + return text.split( /((?:\r\n)|\n|\r)/g ); + } + + static makeGlobal( regexp:RegExp ) + { + if ( regexp.global ) + { + return regexp; + } + + var source = regexp.source; + var flags = regexp.flags; + + if ( flags.indexOf( "g" ) === -1 ) + { + flags += "g"; + } + + return new RegExp( source, flags ); + } + + static replaceAllIn( texts:string[], replacements:Map ) + { + if ( texts === undefined || texts === null ) + { + return texts; + } + + let outputTexts = []; + + for ( let i = 0; i < texts.length; i++ ) + { + outputTexts.push( Texts.replaceAll( texts[ i ], replacements ) ); + } + + return outputTexts; + } + + static replaceAll( text:string, replacements:Map ) + { + if ( text === undefined || text === null ) + { + return text; + } + + for ( let [ variable, replacement ] of replacements ) + { + let replacementRegexSource = Texts.toRegexSource( variable ); + let regex = new RegExp( replacementRegexSource, "g" ); + text = text.replace( regex, replacement ); + } + + return text; + } + + static toRegexSource( source:string ) + { + source = source.replace( /\./g, "\\." ); + source = source.replace( /\(/g, "\\(" ); + source = source.replace( /\)/g, "\\)" ); + source = source.replace( /\[/g, "\\[" ); + source = source.replace( /\]/g, "\\]" ); + source = source.replace( /\^/g, "\\^" ); + source = source.replace( /\$/g, "\\$" ); + source = source.replace( /\*/g, "\\*" ); + source = source.replace( /\+/g, "\\+" ); + source = source.replace( /\-/g, "\\-" ); + source = source.replace( /\?/g, "\\?" ); + source = source.replace( /\//g, "\\/" ); + source = source.replace( /\|/g, "\\|" ); + + return source; + } + + static getMatches( source:string, regex:RegExp, type:string = null ) + { + regex = this.makeGlobal( regex ); + + let offset = 0; + + let matches:MatchResult[] = []; + + while ( offset < source.length ) + { + regex.lastIndex = offset; + let result = regex.exec( source ); + + let match = result ? result[ 0 ] : null; + + if ( result && result.index != offset && match.length > 0) + { + offset = result.index + match.length; + matches.push( { match:match, index: result.index, type:type } ); + } + else + { + return matches; + } + } + + return matches; + } + + static insertText( sourceText:string, insertText:string, insertPosition:number ) + { + let before = sourceText.substring( 0, insertPosition ); + let after = sourceText.substring( insertPosition, sourceText.length ); + + return before + insertText + after; + } +} \ No newline at end of file diff --git a/rokojori-cpp-generator/source/tsconfig.json b/rokojori-cpp-generator/source/tsconfig.json new file mode 100644 index 0000000..6920d60 --- /dev/null +++ b/rokojori-cpp-generator/source/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": + { + "outDir": "../builds", + "sourceMap": true, + "noImplicitAny": true, + "esModuleInterop": true, + "module": "node16", + "target": "es2015", + "baseUrl": ".", + "paths": { } + } +} \ No newline at end of file