From 8a9949d94705caa91f6e494325c6b796d51bd963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9renger=20Dalle-Cort?= Date: Wed, 22 May 2024 19:42:18 -0400 Subject: [PATCH] refactor: fw => tools, nodable => ndbl, async (class => functions) --- CMakeLists.txt | 410 +++++++++--------- HOW-TO-BUILD.md | 6 +- src/README.md | 4 +- src/fw/core/CMakeLists.txt | 0 src/fw/core/assertions.h | 27 -- src/fw/core/async.h | 24 - src/fw/gui/EventManager.cpp | 68 --- src/fw/gui/gui.cpp | 20 - src/fw/gui/gui.h | 9 - src/ndbl/README.md | 19 + src/{nodable => ndbl}/app/main.cpp | 6 +- src/{nodable => ndbl}/cli/CLI.cpp | 25 +- src/{nodable => ndbl}/cli/CLI.h | 15 +- src/ndbl/cli/main.cpp | 21 + src/{nodable/gui => ndbl/cli}/tests.cpp | 6 +- src/{nodable => ndbl}/core/Component.cpp | 2 +- src/{nodable => ndbl}/core/Component.h | 10 +- src/{nodable => ndbl}/core/ComponentBag.cpp | 4 +- src/{nodable => ndbl}/core/ComponentBag.h | 14 +- src/{nodable => ndbl}/core/DataAccess.cpp | 8 +- src/{nodable => ndbl}/core/DataAccess.h | 4 +- src/{nodable => ndbl}/core/DirectedEdge.cpp | 4 +- src/{nodable => ndbl}/core/DirectedEdge.h | 0 src/{nodable => ndbl}/core/ForLoopNode.cpp | 2 +- src/{nodable => ndbl}/core/ForLoopNode.h | 0 src/{nodable => ndbl}/core/Graph.cpp | 54 +-- src/{nodable => ndbl}/core/Graph.h | 32 +- src/{nodable => ndbl}/core/Graph.specs.cpp | 4 +- src/{nodable => ndbl}/core/GraphUtil.cpp | 0 src/{nodable => ndbl}/core/GraphUtil.h | 0 src/{nodable => ndbl}/core/IConditional.h | 4 +- src/{nodable => ndbl}/core/IScope.h | 8 +- src/{nodable => ndbl}/core/IfNode.cpp | 2 +- src/{nodable => ndbl}/core/IfNode.h | 0 src/{nodable => ndbl}/core/InstructionNode.h | 2 +- .../core/InvokableComponent.cpp | 16 +- .../core/InvokableComponent.h | 14 +- src/{nodable => ndbl}/core/LiteralNode.cpp | 2 +- src/{nodable => ndbl}/core/LiteralNode.h | 8 +- src/{nodable => ndbl}/core/Node.cpp | 4 +- src/{nodable => ndbl}/core/Node.h | 18 +- src/{nodable => ndbl}/core/Node.specs.cpp | 2 +- src/{nodable => ndbl}/core/NodeFactory.cpp | 10 +- src/{nodable => ndbl}/core/NodeFactory.h | 14 +- src/{nodable => ndbl}/core/NodeUtils.h | 2 +- src/{nodable => ndbl}/core/Property.cpp | 4 +- src/{nodable => ndbl}/core/Property.h | 30 +- src/{nodable => ndbl}/core/Property.specs.cpp | 4 +- src/{nodable => ndbl}/core/PropertyBag.cpp | 6 +- src/{nodable => ndbl}/core/PropertyBag.h | 26 +- src/{nodable => ndbl}/core/Scope.cpp | 18 +- src/{nodable => ndbl}/core/Scope.h | 0 .../core/SimpleKeyValueSerializer.h | 0 src/{nodable => ndbl}/core/Slot.cpp | 14 +- src/{nodable => ndbl}/core/Slot.h | 12 +- src/{nodable => ndbl}/core/Slot.specs.cpp | 0 src/{nodable => ndbl}/core/SlotFlag.h | 2 +- src/{nodable => ndbl}/core/SlotRef.cpp | 0 src/{nodable => ndbl}/core/SlotRef.h | 6 +- src/{nodable => ndbl}/core/TConditionalNode.h | 8 +- src/{nodable => ndbl}/core/Token.cpp | 0 src/{nodable => ndbl}/core/Token.h | 6 +- src/{nodable => ndbl}/core/Token.specs.cpp | 2 +- src/{nodable => ndbl}/core/TokenRibbon.cpp | 6 +- src/{nodable => ndbl}/core/TokenRibbon.h | 0 src/{nodable => ndbl}/core/Token_t.h | 2 +- src/{nodable => ndbl}/core/VariableNode.cpp | 8 +- src/{nodable => ndbl}/core/VariableNode.h | 20 +- src/{nodable => ndbl}/core/Vertex.h | 2 +- src/{nodable => ndbl}/core/VirtualMachine.cpp | 14 +- src/{nodable => ndbl}/core/VirtualMachine.h | 14 +- .../core/VirtualMachine.specs.cpp | 0 src/{nodable => ndbl}/core/WhileLoopNode.cpp | 2 +- src/{nodable => ndbl}/core/WhileLoopNode.h | 2 +- src/{nodable => ndbl}/core/assembly/Code.cpp | 4 +- src/{nodable => ndbl}/core/assembly/Code.h | 2 +- .../core/assembly/Compiler.cpp | 46 +- .../core/assembly/Compiler.h | 4 +- .../core/assembly/Instruction.cpp | 4 +- .../core/assembly/Instruction.h | 24 +- .../core/assembly/Register.h | 2 +- src/{nodable => ndbl}/core/constants.h | 0 src/ndbl/core/core.cpp | 17 + src/ndbl/core/core.h | 7 + src/{nodable => ndbl}/core/fixtures/core.h | 31 +- .../core/language/Nodlang.bench.cpp | 14 +- .../core/language/Nodlang.cpp | 78 ++-- src/{nodable => ndbl}/core/language/Nodlang.h | 66 +-- .../language/Nodlang.parse_and_eval.specs.cpp | 4 +- .../Nodlang.parse_function_call.specs.cpp | 4 +- .../language/Nodlang.parse_token.specs.cpp | 2 +- .../core/language/Nodlang.specs.cpp | 6 +- .../core/language/Nodlang.tokenize.specs.cpp | 2 +- .../core/language/Nodlang_biology.cpp | 4 +- .../core/language/Nodlang_biology.h | 0 .../core/language/Nodlang_math.cpp | 8 +- .../core/language/Nodlang_math.h | 0 src/{nodable/cli => ndbl/core}/tests.cpp | 6 +- src/{nodable => ndbl}/gui/Action.h | 10 +- src/{nodable => ndbl}/gui/Command.h | 0 src/{nodable => ndbl}/gui/Condition.h | 0 src/{nodable => ndbl}/gui/Config.cpp | 26 +- src/{nodable => ndbl}/gui/Config.h | 67 +-- src/{nodable => ndbl}/gui/Event.h | 44 +- src/{nodable => ndbl}/gui/File.cpp | 10 +- src/{nodable => ndbl}/gui/File.h | 14 +- src/{nodable => ndbl}/gui/FileView.cpp | 14 +- src/{nodable => ndbl}/gui/FileView.h | 8 +- src/{nodable => ndbl}/gui/FrameMode.h | 0 src/{nodable => ndbl}/gui/GraphView.cpp | 34 +- src/{nodable => ndbl}/gui/GraphView.h | 27 +- src/{nodable => ndbl}/gui/History.cpp | 0 src/{nodable => ndbl}/gui/History.h | 16 +- src/{nodable => ndbl}/gui/Isolation.h | 0 src/{nodable => ndbl}/gui/Nodable.cpp | 44 +- src/{nodable => ndbl}/gui/Nodable.h | 14 +- src/{nodable => ndbl}/gui/Nodable.specs.cpp | 4 +- src/{nodable => ndbl}/gui/NodableView.cpp | 48 +- src/{nodable => ndbl}/gui/NodableView.h | 10 +- src/{nodable => ndbl}/gui/NodeView.cpp | 20 +- src/{nodable => ndbl}/gui/NodeView.h | 52 +-- .../gui/NodeViewConstraint.cpp | 22 +- .../gui/NodeViewConstraint.h | 10 +- src/{nodable => ndbl}/gui/Physics.cpp | 16 +- src/{nodable => ndbl}/gui/Physics.h | 18 +- src/{nodable => ndbl}/gui/PropertyView.cpp | 6 +- src/{nodable => ndbl}/gui/PropertyView.h | 14 +- src/{nodable => ndbl}/gui/SlotView.cpp | 2 +- src/{nodable => ndbl}/gui/SlotView.h | 22 +- src/{nodable => ndbl}/gui/benchmark.cpp | 14 +- src/{nodable => ndbl}/gui/build_info.h.in | 0 .../gui/commands/Cmd_ConnectEdge.h | 6 +- .../gui/commands/Cmd_DisconnectEdge.h | 8 +- .../gui/commands/Cmd_Group.h | 2 +- .../gui/commands/Cmd_ReplaceText.h | 4 +- .../Cmd_WrappedTextEditorUndoRecord.h | 4 +- src/{nodable => ndbl}/gui/fixtures/gui.h | 5 +- src/ndbl/gui/gui.cpp | 23 + src/ndbl/gui/gui.h | 9 + src/{nodable => ndbl}/gui/scripts/nodable.bat | 0 src/{nodable => ndbl}/gui/scripts/nodable.sh | 0 src/{nodable/core => ndbl/gui}/tests.cpp | 6 +- src/ndbl/gui/types.h | 2 + src/nodable/README.md | 19 - src/nodable/cli/main.cpp | 7 - src/nodable/gui/gui.cpp | 20 - src/nodable/gui/gui.h | 9 - src/nodable/gui/types.h | 2 - src/{fw => tools}/README.md | 0 src/{fw => tools}/core/Color.h | 2 +- src/{fw => tools}/core/TIdentifier.h | 4 +- src/tools/core/assertions.h | 27 ++ src/{fw => tools}/core/async.cpp | 22 +- src/tools/core/async.h | 17 + src/tools/core/core.cpp | 16 + src/tools/core/core.h | 7 + src/{fw => tools}/core/format.cpp | 2 +- src/{fw => tools}/core/format.h | 6 +- src/{fw => tools}/core/geometry/Box2D.h | 2 +- src/{fw => tools}/core/geometry/Rect.h | 4 +- src/{fw => tools}/core/geometry/Space.h | 2 +- src/{fw => tools}/core/geometry/Vec2.h | 4 +- src/{fw => tools}/core/geometry/Vec4.h | 2 +- src/{fw => tools}/core/geometry/XForm2D.h | 2 +- src/{fw => tools}/core/hash.h | 2 +- src/{fw => tools}/core/log.cpp | 2 +- src/{fw => tools}/core/log.h | 23 +- src/{fw => tools}/core/math.h | 2 +- src/{fw => tools}/core/memory/Pool.bench.cpp | 2 +- src/{fw => tools}/core/memory/Pool.cpp | 2 +- src/{fw => tools}/core/memory/Pool.h | 16 +- src/{fw => tools}/core/memory/Pool.inl | 44 +- src/{fw => tools}/core/memory/Pool.specs.cpp | 4 +- src/{fw => tools}/core/reflection/Operator.h | 2 +- .../core/reflection/Operator_t.h | 2 +- src/{fw => tools}/core/reflection/class.h | 4 +- src/{fw => tools}/core/reflection/enum.h | 0 .../core/reflection/func_type.cpp | 2 +- src/{fw => tools}/core/reflection/func_type.h | 4 +- src/{fw => tools}/core/reflection/invokable.h | 15 +- src/{fw => tools}/core/reflection/qword.cpp | 4 +- src/{fw => tools}/core/reflection/qword.h | 6 +- src/{fw => tools}/core/reflection/reflection | 0 .../core/reflection/reflection.specs.cpp | 2 +- .../core/reflection/registration.h | 2 +- src/{fw => tools}/core/reflection/type.cpp | 2 +- src/{fw => tools}/core/reflection/type.h | 22 +- .../core/reflection/type_register.cpp | 8 +- .../core/reflection/type_register.h | 2 +- src/{fw => tools}/core/reflection/union.h | 0 src/{fw => tools}/core/reflection/variant.cpp | 54 +-- src/{fw => tools}/core/reflection/variant.h | 8 +- src/{fw => tools}/core/string.bench.cpp | 2 +- src/{fw => tools}/core/string.h | 2 +- src/{fw => tools}/core/string.spec.cpp | 4 +- src/{fw => tools}/core/system.cpp | 16 +- src/{fw => tools}/core/system.h | 2 +- src/{fw => tools}/core/tests.cpp | 2 +- src/{fw => tools}/core/types.h | 0 src/{fw => tools}/gui-example/AppExample.h | 10 +- .../gui-example/AppExampleView.h | 12 +- src/{fw => tools}/gui-example/main.cpp | 4 +- src/{fw => tools}/gui/Action.cpp | 2 +- src/{fw => tools}/gui/Action.h | 4 +- src/{fw => tools}/gui/ActionManager.cpp | 24 +- src/{fw => tools}/gui/ActionManager.h | 6 +- src/{fw => tools}/gui/ActionManagerView.cpp | 2 +- src/{fw => tools}/gui/ActionManagerView.h | 2 +- src/{fw => tools}/gui/App.cpp | 70 +-- src/{fw => tools}/gui/App.h | 4 +- src/{fw => tools}/gui/AppView.cpp | 14 +- src/{fw => tools}/gui/AppView.h | 4 +- src/{fw => tools}/gui/Config.h | 8 +- src/{fw => tools}/gui/Event.h | 6 +- src/tools/gui/EventManager.cpp | 59 +++ src/{fw => tools}/gui/EventManager.h | 6 +- src/{fw => tools}/gui/FontManager.cpp | 6 +- src/{fw => tools}/gui/FontManager.h | 2 +- src/{fw => tools}/gui/FontManagerConfig.h | 4 +- src/{fw => tools}/gui/ImGuiEx.cpp | 20 +- src/{fw => tools}/gui/ImGuiEx.h | 14 +- src/{fw => tools}/gui/ImGuiExConfig.h | 14 +- src/{fw => tools}/gui/Texture.h | 6 +- src/{fw => tools}/gui/TextureManager.cpp | 4 +- src/{fw => tools}/gui/TextureManager.h | 2 +- src/{fw => tools}/gui/View.cpp | 2 +- src/{fw => tools}/gui/View.h | 10 +- src/tools/gui/gui.cpp | 25 ++ src/tools/gui/gui.h | 9 + 229 files changed, 1479 insertions(+), 1418 deletions(-) delete mode 100644 src/fw/core/CMakeLists.txt delete mode 100644 src/fw/core/assertions.h delete mode 100644 src/fw/core/async.h delete mode 100644 src/fw/gui/EventManager.cpp delete mode 100644 src/fw/gui/gui.cpp delete mode 100644 src/fw/gui/gui.h create mode 100644 src/ndbl/README.md rename src/{nodable => ndbl}/app/main.cpp (77%) rename src/{nodable => ndbl}/cli/CLI.cpp (94%) rename src/{nodable => ndbl}/cli/CLI.h (77%) create mode 100644 src/ndbl/cli/main.cpp rename src/{nodable/gui => ndbl/cli}/tests.cpp (70%) rename src/{nodable => ndbl}/core/Component.cpp (90%) rename src/{nodable => ndbl}/core/Component.h (63%) rename src/{nodable => ndbl}/core/ComponentBag.cpp (87%) rename src/{nodable => ndbl}/core/ComponentBag.h (78%) rename src/{nodable => ndbl}/core/DataAccess.cpp (93%) rename src/{nodable => ndbl}/core/DataAccess.h (81%) rename src/{nodable => ndbl}/core/DirectedEdge.cpp (95%) rename src/{nodable => ndbl}/core/DirectedEdge.h (100%) rename src/{nodable => ndbl}/core/ForLoopNode.cpp (97%) rename src/{nodable => ndbl}/core/ForLoopNode.h (100%) rename src/{nodable => ndbl}/core/Graph.cpp (91%) rename src/{nodable => ndbl}/core/Graph.h (77%) rename src/{nodable => ndbl}/core/Graph.specs.cpp (98%) rename src/{nodable => ndbl}/core/GraphUtil.cpp (100%) rename src/{nodable => ndbl}/core/GraphUtil.h (100%) rename src/{nodable => ndbl}/core/IConditional.h (93%) rename src/{nodable => ndbl}/core/IScope.h (90%) rename src/{nodable => ndbl}/core/IfNode.cpp (91%) rename src/{nodable => ndbl}/core/IfNode.h (100%) rename src/{nodable => ndbl}/core/InstructionNode.h (96%) rename src/{nodable => ndbl}/core/InvokableComponent.cpp (88%) rename src/{nodable => ndbl}/core/InvokableComponent.h (78%) rename src/{nodable => ndbl}/core/LiteralNode.cpp (96%) rename src/{nodable => ndbl}/core/LiteralNode.h (77%) rename src/{nodable => ndbl}/core/Node.cpp (99%) rename src/{nodable => ndbl}/core/Node.h (91%) rename src/{nodable => ndbl}/core/Node.specs.cpp (96%) rename src/{nodable => ndbl}/core/NodeFactory.cpp (95%) rename src/{nodable => ndbl}/core/NodeFactory.h (71%) rename src/{nodable => ndbl}/core/NodeUtils.h (98%) rename src/{nodable => ndbl}/core/Property.cpp (97%) rename src/{nodable => ndbl}/core/Property.h (71%) rename src/{nodable => ndbl}/core/Property.specs.cpp (96%) rename src/{nodable => ndbl}/core/PropertyBag.cpp (96%) rename src/{nodable => ndbl}/core/PropertyBag.h (76%) rename src/{nodable => ndbl}/core/Scope.cpp (90%) rename src/{nodable => ndbl}/core/Scope.h (100%) rename src/{nodable => ndbl}/core/SimpleKeyValueSerializer.h (100%) rename src/{nodable => ndbl}/core/Slot.cpp (86%) rename src/{nodable => ndbl}/core/Slot.h (90%) rename src/{nodable => ndbl}/core/Slot.specs.cpp (100%) rename src/{nodable => ndbl}/core/SlotFlag.h (98%) rename src/{nodable => ndbl}/core/SlotRef.cpp (100%) rename src/{nodable => ndbl}/core/SlotRef.h (91%) rename src/{nodable => ndbl}/core/TConditionalNode.h (94%) rename src/{nodable => ndbl}/core/Token.cpp (100%) rename src/{nodable => ndbl}/core/Token.h (98%) rename src/{nodable => ndbl}/core/Token.specs.cpp (98%) rename src/{nodable => ndbl}/core/TokenRibbon.cpp (97%) rename src/{nodable => ndbl}/core/TokenRibbon.h (100%) rename src/{nodable => ndbl}/core/Token_t.h (97%) rename src/{nodable => ndbl}/core/VariableNode.cpp (92%) rename src/{nodable => ndbl}/core/VariableNode.h (73%) rename src/{nodable => ndbl}/core/Vertex.h (95%) rename src/{nodable => ndbl}/core/VirtualMachine.cpp (95%) rename src/{nodable => ndbl}/core/VirtualMachine.h (90%) rename src/{nodable => ndbl}/core/VirtualMachine.specs.cpp (100%) rename src/{nodable => ndbl}/core/WhileLoopNode.cpp (91%) rename src/{nodable => ndbl}/core/WhileLoopNode.h (91%) rename src/{nodable => ndbl}/core/assembly/Code.cpp (91%) rename src/{nodable => ndbl}/core/assembly/Code.h (98%) rename src/{nodable => ndbl}/core/assembly/Compiler.cpp (93%) rename src/{nodable => ndbl}/core/assembly/Compiler.h (97%) rename src/{nodable => ndbl}/core/assembly/Instruction.cpp (97%) rename src/{nodable => ndbl}/core/assembly/Instruction.h (87%) rename src/{nodable => ndbl}/core/assembly/Register.h (93%) rename src/{nodable => ndbl}/core/constants.h (100%) create mode 100644 src/ndbl/core/core.cpp create mode 100644 src/ndbl/core/core.h rename src/{nodable => ndbl}/core/fixtures/core.h (85%) rename src/{nodable => ndbl}/core/language/Nodlang.bench.cpp (94%) rename src/{nodable => ndbl}/core/language/Nodlang.cpp (97%) rename src/{nodable => ndbl}/core/language/Nodlang.h (74%) rename src/{nodable => ndbl}/core/language/Nodlang.parse_and_eval.specs.cpp (99%) rename src/{nodable => ndbl}/core/language/Nodlang.parse_function_call.specs.cpp (96%) rename src/{nodable => ndbl}/core/language/Nodlang.parse_token.specs.cpp (98%) rename src/{nodable => ndbl}/core/language/Nodlang.specs.cpp (98%) rename src/{nodable => ndbl}/core/language/Nodlang.tokenize.specs.cpp (98%) rename src/{nodable => ndbl}/core/language/Nodlang_biology.cpp (96%) rename src/{nodable => ndbl}/core/language/Nodlang_biology.h (100%) rename src/{nodable => ndbl}/core/language/Nodlang_math.cpp (98%) rename src/{nodable => ndbl}/core/language/Nodlang_math.h (100%) rename src/{nodable/cli => ndbl/core}/tests.cpp (70%) rename src/{nodable => ndbl}/gui/Action.h (83%) rename src/{nodable => ndbl}/gui/Command.h (100%) rename src/{nodable => ndbl}/gui/Condition.h (100%) rename src/{nodable => ndbl}/gui/Config.cpp (87%) rename src/{nodable => ndbl}/gui/Config.h (56%) rename src/{nodable => ndbl}/gui/Event.h (54%) rename src/{nodable => ndbl}/gui/File.cpp (96%) rename src/{nodable => ndbl}/gui/File.h (88%) rename src/{nodable => ndbl}/gui/FileView.cpp (98%) rename src/{nodable => ndbl}/gui/FileView.h (93%) rename src/{nodable => ndbl}/gui/FrameMode.h (100%) rename src/{nodable => ndbl}/gui/GraphView.cpp (97%) rename src/{nodable => ndbl}/gui/GraphView.h (72%) rename src/{nodable => ndbl}/gui/History.cpp (100%) rename src/{nodable => ndbl}/gui/History.h (90%) rename src/{nodable => ndbl}/gui/Isolation.h (100%) rename src/{nodable => ndbl}/gui/Nodable.cpp (95%) rename src/{nodable => ndbl}/gui/Nodable.h (86%) rename src/{nodable => ndbl}/gui/Nodable.specs.cpp (98%) rename src/{nodable => ndbl}/gui/NodableView.cpp (96%) rename src/{nodable => ndbl}/gui/NodableView.h (87%) rename src/{nodable => ndbl}/gui/NodeView.cpp (99%) rename src/{nodable => ndbl}/gui/NodeView.h (72%) rename src/{nodable => ndbl}/gui/NodeViewConstraint.cpp (96%) rename src/{nodable => ndbl}/gui/NodeViewConstraint.h (92%) rename src/{nodable => ndbl}/gui/Physics.cpp (93%) rename src/{nodable => ndbl}/gui/Physics.h (66%) rename src/{nodable => ndbl}/gui/PropertyView.cpp (93%) rename src/{nodable => ndbl}/gui/PropertyView.h (77%) rename src/{nodable => ndbl}/gui/SlotView.cpp (99%) rename src/{nodable => ndbl}/gui/SlotView.h (75%) rename src/{nodable => ndbl}/gui/benchmark.cpp (96%) rename src/{nodable => ndbl}/gui/build_info.h.in (100%) rename src/{nodable => ndbl}/gui/commands/Cmd_ConnectEdge.h (92%) rename src/{nodable => ndbl}/gui/commands/Cmd_DisconnectEdge.h (88%) rename src/{nodable => ndbl}/gui/commands/Cmd_Group.h (96%) rename src/{nodable => ndbl}/gui/commands/Cmd_ReplaceText.h (95%) rename src/{nodable => ndbl}/gui/commands/Cmd_WrappedTextEditorUndoRecord.h (95%) rename src/{nodable => ndbl}/gui/fixtures/gui.h (91%) create mode 100644 src/ndbl/gui/gui.cpp create mode 100644 src/ndbl/gui/gui.h rename src/{nodable => ndbl}/gui/scripts/nodable.bat (100%) rename src/{nodable => ndbl}/gui/scripts/nodable.sh (100%) rename src/{nodable/core => ndbl/gui}/tests.cpp (70%) create mode 100644 src/ndbl/gui/types.h delete mode 100644 src/nodable/README.md delete mode 100644 src/nodable/cli/main.cpp delete mode 100644 src/nodable/gui/gui.cpp delete mode 100644 src/nodable/gui/gui.h delete mode 100644 src/nodable/gui/types.h rename src/{fw => tools}/README.md (100%) rename src/{fw => tools}/core/Color.h (96%) rename src/{fw => tools}/core/TIdentifier.h (99%) create mode 100644 src/tools/core/assertions.h rename src/{fw => tools}/core/async.cpp (72%) create mode 100644 src/tools/core/async.h create mode 100644 src/tools/core/core.cpp create mode 100644 src/tools/core/core.h rename src/{fw => tools}/core/format.cpp (98%) rename src/{fw => tools}/core/format.h (92%) rename src/{fw => tools}/core/geometry/Box2D.h (98%) rename src/{fw => tools}/core/geometry/Rect.h (96%) rename src/{fw => tools}/core/geometry/Space.h (89%) rename src/{fw => tools}/core/geometry/Vec2.h (98%) rename src/{fw => tools}/core/geometry/Vec4.h (97%) rename src/{fw => tools}/core/geometry/XForm2D.h (98%) rename src/{fw => tools}/core/hash.h (96%) rename src/{fw => tools}/core/log.cpp (98%) rename src/{fw => tools}/core/log.h (87%) rename src/{fw => tools}/core/math.h (97%) rename src/{fw => tools}/core/memory/Pool.bench.cpp (99%) rename src/{fw => tools}/core/memory/Pool.cpp (71%) rename src/{fw => tools}/core/memory/Pool.h (96%) rename src/{fw => tools}/core/memory/Pool.inl (90%) rename src/{fw => tools}/core/memory/Pool.specs.cpp (98%) rename src/{fw => tools}/core/reflection/Operator.h (97%) rename src/{fw => tools}/core/reflection/Operator_t.h (96%) rename src/{fw => tools}/core/reflection/class.h (63%) rename src/{fw => tools}/core/reflection/enum.h (100%) rename src/{fw => tools}/core/reflection/func_type.cpp (98%) rename src/{fw => tools}/core/reflection/func_type.h (98%) rename src/{fw => tools}/core/reflection/invokable.h (95%) rename src/{fw => tools}/core/reflection/qword.cpp (91%) rename src/{fw => tools}/core/reflection/qword.h (94%) rename src/{fw => tools}/core/reflection/reflection (100%) rename src/{fw => tools}/core/reflection/reflection.specs.cpp (99%) rename src/{fw => tools}/core/reflection/registration.h (99%) rename src/{fw => tools}/core/reflection/type.cpp (99%) rename src/{fw => tools}/core/reflection/type.h (92%) rename src/{fw => tools}/core/reflection/type_register.cpp (92%) rename src/{fw => tools}/core/reflection/type_register.h (97%) rename src/{fw => tools}/core/reflection/union.h (100%) rename src/{fw => tools}/core/reflection/variant.cpp (85%) rename src/{fw => tools}/core/reflection/variant.h (96%) rename src/{fw => tools}/core/string.bench.cpp (99%) rename src/{fw => tools}/core/string.h (99%) rename src/{fw => tools}/core/string.spec.cpp (98%) rename src/{fw => tools}/core/system.cpp (73%) rename src/{fw => tools}/core/system.h (96%) rename src/{fw => tools}/core/tests.cpp (92%) rename src/{fw => tools}/core/types.h (100%) rename src/{fw => tools}/gui-example/AppExample.h (92%) rename src/{fw => tools}/gui-example/AppExampleView.h (73%) rename src/{fw => tools}/gui-example/main.cpp (70%) rename src/{fw => tools}/gui/Action.cpp (91%) rename src/{fw => tools}/gui/Action.h (98%) rename src/{fw => tools}/gui/ActionManager.cpp (71%) rename src/{fw => tools}/gui/ActionManager.h (94%) rename src/{fw => tools}/gui/ActionManagerView.cpp (97%) rename src/{fw => tools}/gui/ActionManagerView.h (91%) rename src/{fw => tools}/gui/App.cpp (88%) rename src/{fw => tools}/gui/App.h (98%) rename src/{fw => tools}/gui/AppView.cpp (95%) rename src/{fw => tools}/gui/AppView.h (98%) rename src/{fw => tools}/gui/Config.h (95%) rename src/{fw => tools}/gui/Event.h (96%) create mode 100644 src/tools/gui/EventManager.cpp rename src/{fw => tools}/gui/EventManager.h (95%) rename src/{fw => tools}/gui/FontManager.cpp (93%) rename src/{fw => tools}/gui/FontManager.h (97%) rename src/{fw => tools}/gui/FontManagerConfig.h (94%) rename src/{fw => tools}/gui/ImGuiEx.cpp (93%) rename src/{fw => tools}/gui/ImGuiEx.h (94%) rename src/{fw => tools}/gui/ImGuiExConfig.h (62%) rename src/{fw => tools}/gui/Texture.h (90%) rename src/{fw => tools}/gui/TextureManager.cpp (98%) rename src/{fw => tools}/gui/TextureManager.h (98%) rename src/{fw => tools}/gui/View.cpp (98%) rename src/{fw => tools}/gui/View.h (77%) create mode 100644 src/tools/gui/gui.cpp create mode 100644 src/tools/gui/gui.h diff --git a/CMakeLists.txt b/CMakeLists.txt index e8788e465..7139c1d3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ set(NDBL_APP_NAME "Nodable") set(NDBL_PACKAGE_DIR "${CMAKE_CURRENT_LIST_DIR}/out/package") # // set(NDBL_CONFIGURED_DIR "${PROJECT_BINARY_DIR}/configured/ndbl") set(NDBL_SKIP_TESTS OFF) -option(FW_NO_POOL "Disable Pool (for benchmark only)" OFF) +option(TOOLS_NO_POOL "Disable Pool (for benchmark only)" OFF) # set a build type to Release by default if not set: if ( NOT DEFINED CMAKE_BUILD_TYPE ) @@ -48,15 +48,15 @@ set(CMAKE_CXX_EXTENSIONS ON) # enable threads (we have some std::async in ndbl_app) set(THREADS_PREFER_PTHREAD_FLAG ON) -# Defines FW_DEBUG/NDBL_DEBUG when in Debug -set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DFW_DEBUG -DNDBL_DEBUG") +# Defines TOOLS_DEBUG/NDBL_DEBUG when in Debug +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DTOOLS_DEBUG -DNDBL_DEBUG") if(WIN32) add_compile_definitions(NOMINMAX) # avoid min/max macros causing conflicts with min/max functions endif() -if (FW_NO_POOL) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DFW_NO_POOL") +if (TOOLS_NO_POOL) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTOOLS_NO_POOL") endif () # add subdirectories @@ -103,7 +103,7 @@ endif () ndbl_log("Threads found: ${Threads_FOUND}") ndbl_log("OpenGL found: ${OpenGL_FOUND}") -# Includes for all (fw and nodable) targets +# Includes for all (tools and nodable) targets include_directories( src libs @@ -121,110 +121,113 @@ include_directories( #-------------------- add_library( - framework-core + tools-core STATIC libs/whereami/src/whereami.c - src/fw/core/Color.h - src/fw/core/TIdentifier.h - src/fw/core/assertions.h - src/fw/core/async.cpp - src/fw/core/async.h - src/fw/core/format.cpp - src/fw/core/format.h - src/fw/core/geometry/Box2D.h - src/fw/core/geometry/Rect.h - src/fw/core/geometry/Space.h - src/fw/core/geometry/Vec2.h - src/fw/core/geometry/Vec4.h - src/fw/core/geometry/XForm2D.h - src/fw/core/hash.h - src/fw/core/log.cpp - src/fw/core/log.h - src/fw/core/math.h - src/fw/core/memory/Pool.cpp - src/fw/core/memory/Pool.h - src/fw/core/reflection/Operator.h - src/fw/core/reflection/Operator_t.h - src/fw/core/reflection/class.h - src/fw/core/reflection/enum.h - src/fw/core/reflection/func_type.cpp - src/fw/core/reflection/func_type.h - src/fw/core/reflection/invokable.h - src/fw/core/reflection/qword.cpp - src/fw/core/reflection/qword.h - src/fw/core/reflection/reflection - src/fw/core/reflection/registration.h - src/fw/core/reflection/type.cpp - src/fw/core/reflection/type.h - src/fw/core/reflection/type_register.cpp - src/fw/core/reflection/type_register.h - src/fw/core/reflection/union.h - src/fw/core/reflection/variant.cpp - src/fw/core/reflection/variant.h - src/fw/core/string.h - src/fw/core/system.cpp - src/fw/core/system.h - src/fw/core/types.h + src/tools/core/core.cpp + src/tools/core/core.h + src/tools/core/Color.h + src/tools/core/TIdentifier.h + src/tools/core/assertions.h + src/tools/core/async.cpp + src/tools/core/async.h + src/tools/core/format.cpp + src/tools/core/format.h + src/tools/core/geometry/Box2D.h + src/tools/core/geometry/Rect.h + src/tools/core/geometry/Space.h + src/tools/core/geometry/Vec2.h + src/tools/core/geometry/Vec4.h + src/tools/core/geometry/XForm2D.h + src/tools/core/hash.h + src/tools/core/log.cpp + src/tools/core/log.h + src/tools/core/math.h + src/tools/core/memory/Pool.cpp + src/tools/core/memory/Pool.h + src/tools/core/reflection/Operator.h + src/tools/core/reflection/Operator_t.h + src/tools/core/reflection/class.h + src/tools/core/reflection/enum.h + src/tools/core/reflection/func_type.cpp + src/tools/core/reflection/func_type.h + src/tools/core/reflection/invokable.h + src/tools/core/reflection/qword.cpp + src/tools/core/reflection/qword.h + src/tools/core/reflection/reflection + src/tools/core/reflection/registration.h + src/tools/core/reflection/type.cpp + src/tools/core/reflection/type.h + src/tools/core/reflection/type_register.cpp + src/tools/core/reflection/type_register.h + src/tools/core/reflection/union.h + src/tools/core/reflection/variant.cpp + src/tools/core/reflection/variant.h + src/tools/core/string.h + src/tools/core/system.cpp + src/tools/core/system.h + src/tools/core/types.h # libraries libs/whereami/src/whereami.c libs/whereami/src/whereami.h ) target_link_libraries( - framework-core + tools-core PUBLIC - Observe # event system using observer/observable pattern. - glm # math - Threads::Threads + Observe # event system using observer/observable pattern. + glm # math + Threads::Threads ) add_executable( - test-framework-core - src/fw/core/reflection/reflection.specs.cpp - src/fw/core/memory/Pool.specs.cpp + test-tools-core + src/tools/core/reflection/reflection.specs.cpp + src/tools/core/memory/Pool.specs.cpp ) -target_link_libraries(test-framework-core PUBLIC gtest_main gtest framework-core) -add_test(NAME test_framework_core COMMAND test-framework-core) +target_link_libraries(test-tools-core PUBLIC gtest_main gtest tools-core) +add_test(NAME test_framework_core COMMAND test-tools-core) -add_executable(bench-fw-core-string src/fw/core/string.bench.cpp) -target_link_libraries(bench-fw-core-string PUBLIC benchmark::benchmark framework-core) +add_executable(bench-fw-core-string src/tools/core/string.bench.cpp) +target_link_libraries(bench-fw-core-string PUBLIC benchmark::benchmark tools-core) -add_executable(bench-fw-core-Pool src/fw/core/memory/Pool.bench.cpp) -target_link_libraries(bench-fw-core-Pool PUBLIC benchmark::benchmark framework-core) +add_executable(bench-fw-core-Pool src/tools/core/memory/Pool.bench.cpp) +target_link_libraries(bench-fw-core-Pool PUBLIC benchmark::benchmark tools-core) # 1.2) Framework GUI #------------------- add_library( - framework-gui + tools-gui STATIC - src/fw/gui/Action.cpp - src/fw/gui/Action.h - src/fw/gui/ActionManager.cpp - src/fw/gui/ActionManager.h - src/fw/gui/ActionManagerView.cpp - src/fw/gui/ActionManagerView.h - src/fw/gui/App.cpp - src/fw/gui/App.h - src/fw/gui/AppView.cpp - src/fw/gui/AppView.h - src/fw/gui/gui.cpp - src/fw/gui/Config.h - src/fw/gui/Event.h - src/fw/gui/EventManager.cpp - src/fw/gui/EventManager.h - src/fw/gui/FontManager.cpp - src/fw/gui/FontManager.h - src/fw/gui/FontManagerConfig.h - src/fw/gui/ImGuiEx.cpp - src/fw/gui/ImGuiEx.h - src/fw/gui/ImGuiExConfig.h - src/fw/gui/Texture.h - src/fw/gui/TextureManager.cpp - src/fw/gui/TextureManager.h - src/fw/gui/View.cpp - src/fw/gui/View.h + src/tools/gui/Action.cpp + src/tools/gui/Action.h + src/tools/gui/ActionManager.cpp + src/tools/gui/ActionManager.h + src/tools/gui/ActionManagerView.cpp + src/tools/gui/ActionManagerView.h + src/tools/gui/App.cpp + src/tools/gui/App.h + src/tools/gui/AppView.cpp + src/tools/gui/AppView.h + src/tools/gui/gui.h + src/tools/gui/gui.cpp + src/tools/gui/Config.h + src/tools/gui/Event.h + src/tools/gui/EventManager.cpp + src/tools/gui/EventManager.h + src/tools/gui/FontManager.cpp + src/tools/gui/FontManager.h + src/tools/gui/FontManagerConfig.h + src/tools/gui/ImGuiEx.cpp + src/tools/gui/ImGuiEx.h + src/tools/gui/ImGuiExConfig.h + src/tools/gui/Texture.h + src/tools/gui/TextureManager.cpp + src/tools/gui/TextureManager.h + src/tools/gui/View.cpp + src/tools/gui/View.h libs/imgui/imgui.cpp libs/imgui/imgui_demo.cpp libs/imgui/imgui_draw.cpp @@ -242,14 +245,14 @@ add_library( ) target_link_libraries( - framework-gui + tools-gui PUBLIC - ${CMAKE_DL_LIBS} - OpenGL::GL - SDL2-static SDL2main - nfd # native file dialog - extended - freetype # because: https://github.com/ocornut/imgui/tree/master/misc/freetype - framework-core + ${CMAKE_DL_LIBS} + OpenGL::GL + SDL2-static SDL2main + nfd # native file dialog - extended + freetype # because: https://github.com/ocornut/imgui/tree/master/misc/freetype + tools-core ) # link APPLE specific libraries @@ -258,36 +261,37 @@ IF (APPLE) find_library(CORE_FOUNDATION_FRAMEWORK CoreFoundation) if (NOT CORE_FOUNDATION_FRAMEWORK) -ndbl_err("CoreFoundation not found") + ndbl_err("CoreFoundation not found") endif () find_library(COCOA_FRAMEWORK Cocoa) if (NOT COCOA_FRAMEWORK) -ndbl_err("Cocoa not found") + ndbl_err("Cocoa not found") endif () ndbl_log("CORE_FOUNDATION_FRAMEWORK: ${CORE_FOUNDATION_FRAMEWORK}") ndbl_log("COCOA_FRAMEWORK: ${COCOA_FRAMEWORK}") target_link_libraries( - framework-gui - PUBLIC - ${CORE_FOUNDATION_FRAMEWORK} - ${COCOA_FRAMEWORK}) + tools-gui + PUBLIC + ${CORE_FOUNDATION_FRAMEWORK} + ${COCOA_FRAMEWORK} + ) ENDIF () -target_compile_definitions(framework-gui PUBLIC IMGUI_USER_CONFIG="${CMAKE_CURRENT_LIST_DIR}/src/fw/gui/ImGuiExConfig.h") # Override imconfig.h -set_target_properties(framework-gui PROPERTIES POSITION_INDEPENDENT_CODE FALSE) # required to run well on recent os (ex: ubuntu) -set_target_properties(framework-gui PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${BUILD_PATH}") # fix working directory for visual studio +target_compile_definitions(tools-gui PUBLIC IMGUI_USER_CONFIG="${CMAKE_CURRENT_LIST_DIR}/src/tools/gui/ImGuiExConfig.h") # Override imconfig.h +set_target_properties(tools-gui PROPERTIES POSITION_INDEPENDENT_CODE FALSE) # required to run well on recent os (ex: ubuntu) +set_target_properties(tools-gui PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${BUILD_PATH}") # fix working directory for visual studio # define assets -set(FW_ASSETS -"assets/fonts/CenturyGothic.ttf" -"assets/fonts/fa-solid-900.ttf" +set(TOOLS_ASSETS + "assets/fonts/CenturyGothic.ttf" + "assets/fonts/fa-solid-900.ttf" ) # copy each file (will dirty the build when file changes) -foreach (ASSET ${FW_ASSETS}) +foreach (ASSET ${TOOLS_ASSETS}) configure_file("${ASSET}" "${CMAKE_BINARY_DIR}/${ASSET}" COPYONLY) endforeach () @@ -295,58 +299,60 @@ endforeach () #--------------------------------------- # add executable -add_executable(framework-gui-example WIN32 src/fw/gui-example/main.cpp) -target_link_libraries(framework-gui-example PUBLIC framework-gui) -set_target_properties(framework-gui-example PROPERTIES POSITION_INDEPENDENT_CODE FALSE) # required to run well on recent os (ex: ubuntu) -set_target_properties(framework-gui-example PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${BUILD_PATH}") # fix working directory for visual studio +add_executable(tools-gui-example WIN32 src/tools/gui-example/main.cpp) +target_link_libraries(tools-gui-example PUBLIC tools-gui) +set_target_properties(tools-gui-example PROPERTIES POSITION_INDEPENDENT_CODE FALSE) # required to run well on recent os (ex: ubuntu) +set_target_properties(tools-gui-example PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${BUILD_PATH}") # fix working directory for visual studio # Installation : -# install( TARGETS framework-gui-example RUNTIME PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE DESTINATION .) +# install( TARGETS tools-gui-example RUNTIME PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE DESTINATION .) # 2.1) Nodable Core #------------------ add_library( - nodable-core + ndbl-core STATIC - src/nodable/core/Component.cpp - src/nodable/core/ComponentBag.cpp - src/nodable/core/IfNode.cpp - src/nodable/core/DataAccess.cpp - src/nodable/core/DirectedEdge.cpp - src/nodable/core/ForLoopNode.cpp - src/nodable/core/Graph.cpp - src/nodable/core/GraphUtil.cpp - src/nodable/core/InvokableComponent.cpp - src/nodable/core/LiteralNode.cpp - src/nodable/core/Node.cpp - src/nodable/core/NodeFactory.cpp - src/nodable/core/Property.cpp - src/nodable/core/PropertyBag.cpp - src/nodable/core/Scope.cpp - src/nodable/core/Slot.cpp - src/nodable/core/SlotRef.cpp - src/nodable/core/Token.cpp - src/nodable/core/TokenRibbon.cpp - src/nodable/core/VariableNode.cpp - src/nodable/core/VirtualMachine.cpp - src/nodable/core/WhileLoopNode.cpp - src/nodable/core/assembly/Code.cpp - src/nodable/core/assembly/Compiler.cpp - src/nodable/core/assembly/Instruction.cpp - src/nodable/core/language/Nodlang.cpp - src/nodable/core/language/Nodlang_biology.cpp - src/nodable/core/language/Nodlang_math.cpp + src/ndbl/core/core.cpp + src/ndbl/core/core.h + src/ndbl/core/Component.cpp + src/ndbl/core/ComponentBag.cpp + src/ndbl/core/IfNode.cpp + src/ndbl/core/DataAccess.cpp + src/ndbl/core/DirectedEdge.cpp + src/ndbl/core/ForLoopNode.cpp + src/ndbl/core/Graph.cpp + src/ndbl/core/GraphUtil.cpp + src/ndbl/core/InvokableComponent.cpp + src/ndbl/core/LiteralNode.cpp + src/ndbl/core/Node.cpp + src/ndbl/core/NodeFactory.cpp + src/ndbl/core/Property.cpp + src/ndbl/core/PropertyBag.cpp + src/ndbl/core/Scope.cpp + src/ndbl/core/Slot.cpp + src/ndbl/core/SlotRef.cpp + src/ndbl/core/Token.cpp + src/ndbl/core/TokenRibbon.cpp + src/ndbl/core/VariableNode.cpp + src/ndbl/core/VirtualMachine.cpp + src/ndbl/core/WhileLoopNode.cpp + src/ndbl/core/assembly/Code.cpp + src/ndbl/core/assembly/Compiler.cpp + src/ndbl/core/assembly/Instruction.cpp + src/ndbl/core/language/Nodlang.cpp + src/ndbl/core/language/Nodlang_biology.cpp + src/ndbl/core/language/Nodlang_math.cpp ) target_link_libraries( - nodable-core + ndbl-core PUBLIC - framework-core + tools-core ) ndbl_log("Defining install ...") -set_target_properties(nodable-core PROPERTIES OUTPUT_NAME "core") +set_target_properties(ndbl-core PROPERTIES OUTPUT_NAME "core") ndbl_log("NDBL_SKIP_TESTS: ${NDBL_SKIP_TESTS}") @@ -355,25 +361,25 @@ if (NDBL_SKIP_TESTS) endif () add_executable( - test-nodable-core - src/nodable/core/Graph.specs.cpp - src/nodable/core/Node.specs.cpp - src/nodable/core/Property.specs.cpp - src/nodable/core/Slot.specs.cpp - src/nodable/core/Token.specs.cpp - src/nodable/core/language/Nodlang.specs.cpp - src/nodable/core/language/Nodlang.tokenize.specs.cpp - src/nodable/core/language/Nodlang.parse_function_call.specs.cpp - src/nodable/core/language/Nodlang.parse_token.specs.cpp - src/nodable/core/VirtualMachine.specs.cpp - src/nodable/core/language/Nodlang.parse_and_eval.specs.cpp + test-ndbl-core + src/ndbl/core/Graph.specs.cpp + src/ndbl/core/Node.specs.cpp + src/ndbl/core/Property.specs.cpp + src/ndbl/core/Slot.specs.cpp + src/ndbl/core/Token.specs.cpp + src/ndbl/core/language/Nodlang.specs.cpp + src/ndbl/core/language/Nodlang.tokenize.specs.cpp + src/ndbl/core/language/Nodlang.parse_function_call.specs.cpp + src/ndbl/core/language/Nodlang.parse_token.specs.cpp + src/ndbl/core/VirtualMachine.specs.cpp + src/ndbl/core/language/Nodlang.parse_and_eval.specs.cpp ) -target_link_libraries(test-nodable-core PUBLIC gtest_main gtest nodable-core) -add_test(NAME test_nodable_core COMMAND test-nodable-core) +target_link_libraries(test-ndbl-core PUBLIC gtest_main gtest ndbl-core) +add_test(NAME test_ndbl_core COMMAND test-ndbl-core) # Benchmarks -add_executable(bench-nodable-core-Nodlang src/nodable/core/language/Nodlang.bench.cpp) -target_link_libraries(bench-nodable-core-Nodlang PUBLIC benchmark::benchmark nodable-core) +add_executable(bench-ndbl-core-Nodlang src/ndbl/core/language/Nodlang.bench.cpp) +target_link_libraries(bench-ndbl-core-Nodlang PUBLIC benchmark::benchmark ndbl-core) # 2.1) Nodable CLI #----------------- @@ -384,18 +390,18 @@ if (NOT NDBL_CONFIGURED_DIR) endif () add_executable( - nodable-cli - src/nodable/cli/main.cpp - src/nodable/cli/CLI.cpp + ndbl-cli + src/ndbl/cli/main.cpp + src/ndbl/cli/CLI.cpp ) -target_link_libraries(nodable-cli PUBLIC nodable-core) -set_target_properties(nodable-cli PROPERTIES POSITION_INDEPENDENT_CODE FALSE) # required to run well on recent os (ex: ubuntu) -set_target_properties(nodable-cli PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${BUILD_PATH}") # fix working directory for visual studio -set_target_properties(nodable-cli PROPERTIES OUTPUT_NAME "cli") +target_link_libraries(ndbl-cli PUBLIC ndbl-core) +set_target_properties(ndbl-cli PROPERTIES POSITION_INDEPENDENT_CODE FALSE) # required to run well on recent os (ex: ubuntu) +set_target_properties(ndbl-cli PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${BUILD_PATH}") # fix working directory for visual studio +set_target_properties(ndbl-cli PROPERTIES OUTPUT_NAME "cli") # Installation : -install(TARGETS nodable-cli DESTINATION . RUNTIME PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE) +install(TARGETS ndbl-cli DESTINATION . RUNTIME PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE) # 2.1) Nodable GUI #------------------ @@ -417,42 +423,42 @@ ndbl_log(" - NDBL_APP_ASSETS_ABSOLUTE_DIR: ${NDBL_APP_ASSETS_ABSOLUTE_DIR}") # Configure files configure_file( - src/nodable/gui/build_info.h.in + src/ndbl/gui/build_info.h.in ${NDBL_CONFIGURED_DIR}/gui/build_info.h ) add_library( - nodable-gui + ndbl-gui STATIC - src/nodable/gui/gui.cpp - src/nodable/gui/gui.h - src/nodable/gui/Config.cpp - src/nodable/gui/Config.h - src/nodable/gui/GraphView.cpp - src/nodable/gui/History.cpp - src/nodable/gui/File.cpp - src/nodable/gui/FileView.cpp - src/nodable/gui/Nodable.cpp - src/nodable/gui/NodableView.cpp - src/nodable/gui/NodeView.cpp - src/nodable/gui/NodeViewConstraint.cpp - src/nodable/gui/Physics.cpp - src/nodable/gui/PropertyView.cpp - src/nodable/gui/SlotView.cpp - src/nodable/gui/Isolation.h + src/ndbl/gui/gui.cpp + src/ndbl/gui/gui.h + src/ndbl/gui/Config.cpp + src/ndbl/gui/Config.h + src/ndbl/gui/GraphView.cpp + src/ndbl/gui/History.cpp + src/ndbl/gui/File.cpp + src/ndbl/gui/FileView.cpp + src/ndbl/gui/Nodable.cpp + src/ndbl/gui/NodableView.cpp + src/ndbl/gui/NodeView.cpp + src/ndbl/gui/NodeViewConstraint.cpp + src/ndbl/gui/Physics.cpp + src/ndbl/gui/PropertyView.cpp + src/ndbl/gui/SlotView.cpp + src/ndbl/gui/Isolation.h ) target_link_libraries( - nodable-gui + ndbl-gui PUBLIC - nodable-core - framework-gui + ndbl-core + tools-gui ) target_include_directories( - nodable-gui + ndbl-gui PUBLIC - ${PROJECT_BINARY_DIR}/configured/ndbl/gui/ + ${PROJECT_BINARY_DIR}/configured/ndbl/gui/ ) # define assets @@ -479,19 +485,19 @@ if (NDBL_SKIP_TESTS) return() endif () -add_executable(test-nodable-gui src/nodable/gui/Nodable.specs.cpp) -target_link_libraries(test-nodable-gui PUBLIC gtest_main gtest nodable-gui) +add_executable(test-ndbl-gui src/ndbl/gui/Nodable.specs.cpp) +target_link_libraries(test-ndbl-gui PUBLIC gtest_main gtest ndbl-gui) # GUI tests does not work on every machine (only MacOS in software on GitHub Actions) if ($ENV{JETBRAINS_IDE}) ndbl_log("JETBRAINS_IDE is defined: Enable Nodable GUI tests (hardware rendering)") - add_test(NAME test_nodable_gui COMMAND test-nodable-gui) + add_test(NAME test_ndbl_gui COMMAND test-ndbl-gui) add_definitions(-D NDBL_GUI_TEST_HUMAN_SPEED) elseif (WIN32) ndbl_log("Windows detected: Skip Nodable GUI tests") elseif (APPLE) ndbl_log("Apple detected: Enable Nodable GUI tests (software rendering)") - add_test(NAME test_nodable_gui COMMAND test-nodable-gui) + add_test(NAME test_ndbl_gui COMMAND test-ndbl-gui) elseif (UNIX) # Should be tested after APPLE ndbl_log("Linux detected: Skip Nodable GUI tests") endif () @@ -499,11 +505,11 @@ endif () # 2.1) Nodable App #----------------- -add_executable(nodable-app WIN32 src/nodable/app/main.cpp) -target_link_libraries(nodable-app PUBLIC nodable-gui) -set_target_properties(nodable-app PROPERTIES POSITION_INDEPENDENT_CODE FALSE) # required to run well on recent os (ex: ubuntu) -set_target_properties(nodable-app PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${BUILD_PATH}") # fix working directory for visual studio -set_target_properties(nodable-app PROPERTIES OUTPUT_NAME "nodable") +add_executable(ndbl-app WIN32 src/ndbl/app/main.cpp) +target_link_libraries(ndbl-app PUBLIC ndbl-gui) +set_target_properties(ndbl-app PROPERTIES POSITION_INDEPENDENT_CODE FALSE) # required to run well on recent os (ex: ubuntu) +set_target_properties(ndbl-app PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${BUILD_PATH}") # fix working directory for visual studio +set_target_properties(ndbl-app PROPERTIES OUTPUT_NAME "nodable") set(README README.md) set(LICENSE LICENSE) @@ -511,7 +517,7 @@ configure_file("${README}" . COPYONLY) configure_file("${LICENSE}" . COPYONLY) # Installation : -install(TARGETS nodable-app DESTINATION . RUNTIME PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE) +install(TARGETS ndbl-app DESTINATION . RUNTIME PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE) install(DIRECTORY assets DESTINATION .) install(FILES ${LICENSE} ${README} DESTINATION .) diff --git a/HOW-TO-BUILD.md b/HOW-TO-BUILD.md index a6a65f2c7..3a79299d5 100644 --- a/HOW-TO-BUILD.md +++ b/HOW-TO-BUILD.md @@ -4,9 +4,9 @@ ## Architecture -Nodable is split in two [src](./src/README.md): -- the [nodable](./src/nodable/README.md) project. -- the [framework](./src/fw/README.md) project. +Nodable sources are split in two folders under [./src](./src/README.md): +- [./src/ndbl](src/ndbl/README.md) project. +- [./src/tool](src/tools/README.md) project. They both rely on external [libraries](./libs/README.md). diff --git a/src/README.md b/src/README.md index cf8d249ec..2c9a6b49c 100644 --- a/src/README.md +++ b/src/README.md @@ -2,11 +2,11 @@ # Projects -### [`./framework`](./fw/README.md) +### [`./framework`](tools/README.md) Framework libraries to develop applications (headless or gui) including an example. -### [`./nodable`](./nodable/README.md) +### [`./nodable`](ndbl/README.md) Nodable application and libraries. diff --git a/src/fw/core/CMakeLists.txt b/src/fw/core/CMakeLists.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/fw/core/assertions.h b/src/fw/core/assertions.h deleted file mode 100644 index 1d3efbd02..000000000 --- a/src/fw/core/assertions.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -#include "log.h" // to flush before to assert/throw - -// Assertion is stopping the program when expression is false -#ifndef FW_ASSERT_ -#define FW_ASSERT_(expression) \ - LOG_FLUSH(); \ - assert((expression)); -#endif - -// Expect is throwing an exception when expression is false -#ifndef FW_EXPECT_ -#define FW_EXPECT_(expression, message_if_fails )\ - if(!(expression)) { LOG_FLUSH(); throw std::runtime_error(message_if_fails); } -#endif - -#if NOEXCEPT -# include -# define FW_ASSERT(expression) FW_ASSERT_( expression ) -# define FW_EXPECT(expression, message) FW_ASSERT_( expression ) -#else -# include -# include -# define FW_ASSERT(expression) FW_EXPECT_( (expression), "Assertion failed: " #expression" is false" ) -# define FW_EXPECT(expression, message) FW_EXPECT_( (expression), message ) -#endif diff --git a/src/fw/core/async.h b/src/fw/core/async.h deleted file mode 100644 index 4af080331..000000000 --- a/src/fw/core/async.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once -#include -#include - -namespace fw -{ - /** - * Handle asynchronous tasks - * @example @code - * async::get_instance() - * .add_task(std::async(std::launch::async, []()-> void {...})) - */ - class async - { - public: - async(); - void clean_tasks(); // remove finished tasks - void add_task(std::future&&); - static async& get_instance(); - private: - static constexpr size_t tasks_reserved_size = 16; - std::vector> tasks; - }; -} \ No newline at end of file diff --git a/src/fw/gui/EventManager.cpp b/src/fw/gui/EventManager.cpp deleted file mode 100644 index 3afa37e8f..000000000 --- a/src/fw/gui/EventManager.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "EventManager.h" - -#include -#include -#include - -#include "fw/core/assertions.h" -#include "fw/core/async.h" -#include "fw/core/log.h" -#include "fw/core/reflection/type.h" - -using namespace fw; - -EventManager* EventManager::s_instance = nullptr; - -EventManager::~EventManager() -{ - LOG_VERBOSE("fw::EventManager", "Destructor ...\n"); - s_instance = nullptr; - LOG_VERBOSE("fw::EventManager", "Destructor " OK "\n"); -} -EventManager::EventManager() -{ - LOG_VERBOSE("fw::EventManager", "Constructor ...\n"); - FW_EXPECT(!s_instance, "cannot have two instances at a time"); - s_instance = this; - LOG_VERBOSE("fw::EventManager", "Constructor " OK "\n"); -} - -EventManager& EventManager::get_instance() -{ - FW_EXPECT(s_instance, "No instance found."); - return *s_instance; -} - -void EventManager::dispatch(IEvent* _event) -{ - m_events.push(_event); -} - -IEvent* EventManager::poll_event() -{ - if ( m_events.empty() ) - { - return nullptr; - } - - IEvent* next_event = m_events.front(); - m_events.pop(); - return next_event; -} - -IEvent* EventManager::dispatch( EventID _event_id ) -{ - auto new_event = new IEvent{ _event_id }; - dispatch(new_event ); - return new_event; -} - -void EventManager::dispatch_delayed(u64_t delay, IEvent* event) -{ - async::get_instance().add_task( - std::async(std::launch::async, [this, event, delay]() -> void { - std::this_thread::sleep_for(std::chrono::milliseconds{delay}); - dispatch(event); - }) - ); -} \ No newline at end of file diff --git a/src/fw/gui/gui.cpp b/src/fw/gui/gui.cpp deleted file mode 100644 index 3978efa76..000000000 --- a/src/fw/gui/gui.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "gui.h" - -fw::Config* fw::g_conf{nullptr}; - -void fw::init() -{ - FW_EXPECT(fw::g_conf == nullptr, "fw::g_conf is already initialized\n") - fw::g_conf = new Config(); - - Pool::init(); -}; - -void fw::shutdown() -{ - FW_EXPECT(fw::g_conf != nullptr, "fw::g_conf was not initialized, did you call fw::shutdown() twice?\n") - delete fw::g_conf; - fw::g_conf = nullptr; - - Pool::shutdown(); -}; \ No newline at end of file diff --git a/src/fw/gui/gui.h b/src/fw/gui/gui.h deleted file mode 100644 index 3108b17af..000000000 --- a/src/fw/gui/gui.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -#include "Config.h" - -namespace fw -{ - extern Config* g_conf; // Globally accessible configuration. Must be initialized with fw::init() before use; - void init(); // create a new g_conf - void shutdown(); // delete current g_conf -} \ No newline at end of file diff --git a/src/ndbl/README.md b/src/ndbl/README.md new file mode 100644 index 000000000..2ef5196a0 --- /dev/null +++ b/src/ndbl/README.md @@ -0,0 +1,19 @@ +# Nodable + +Contains the nodable app and its libraries. + +### `./core` + +Nodable core library based on [tools-core](../tools/core). + +### `./gui` + +Nodable graphic user interface library based on [tools-gui](../tools/gui). + +### `./app` + +Nodable application based on [ndbl-gui](./gui). + +### `./cli` + +Nodable experimental command line interface based on [ndbl-core](./core). diff --git a/src/nodable/app/main.cpp b/src/ndbl/app/main.cpp similarity index 77% rename from src/nodable/app/main.cpp rename to src/ndbl/app/main.cpp index c93934349..fbf874fb2 100644 --- a/src/nodable/app/main.cpp +++ b/src/ndbl/app/main.cpp @@ -1,7 +1,7 @@ -#include "nodable/gui/Config.h" -#include "nodable/gui/Nodable.h" +#include "ndbl/gui/Config.h" +#include "ndbl/gui/Nodable.h" -using namespace fw; +using namespace tools; using namespace ndbl; int main(int argc, char *argv[]) diff --git a/src/nodable/cli/CLI.cpp b/src/ndbl/cli/CLI.cpp similarity index 94% rename from src/nodable/cli/CLI.cpp rename to src/ndbl/cli/CLI.cpp index 032ea8728..f1ffffe25 100644 --- a/src/nodable/cli/CLI.cpp +++ b/src/ndbl/cli/CLI.cpp @@ -2,11 +2,12 @@ #include -#include "fw/core/reflection/reflection" -#include "nodable/core/language/Nodlang.h" +#include "ndbl/core/core.h" +#include "ndbl/core/language/Nodlang.h" +#include "tools/core/reflection/reflection" using namespace ndbl; -using namespace fw; +using namespace tools; REGISTER { @@ -42,24 +43,6 @@ CLI::~CLI() delete m_asm_code; } - - -int CLI::main(int argc, char* argv[]) -{ - log::set_verbosity(log::Verbosity_Warning); - Pool::init(); - - while (!should_stop()) - { - update(); - } - - m_graph.clear(); - Pool::shutdown(); - LOG_FLUSH() - return 0; -} - bool CLI::should_stop() const { return m_should_stop; diff --git a/src/nodable/cli/CLI.h b/src/ndbl/cli/CLI.h similarity index 77% rename from src/nodable/cli/CLI.h rename to src/ndbl/cli/CLI.h index 8d1e7a29f..735bc1d20 100644 --- a/src/nodable/cli/CLI.h +++ b/src/ndbl/cli/CLI.h @@ -2,13 +2,13 @@ #include -#include "fw/core/reflection/reflection" +#include "tools/core/reflection/reflection" -#include "nodable/core/language/Nodlang.h" -#include "nodable/core/NodeFactory.h" -#include "nodable/core/Graph.h" -#include "nodable/core/VirtualMachine.h" -#include "nodable/core/assembly/Compiler.h" +#include "ndbl/core/language/Nodlang.h" +#include "ndbl/core/NodeFactory.h" +#include "ndbl/core/Graph.h" +#include "ndbl/core/VirtualMachine.h" +#include "ndbl/core/assembly/Compiler.h" namespace ndbl { @@ -20,7 +20,6 @@ namespace ndbl public: CLI(); ~CLI(); - int main(int argc, char* argv[]); bool should_stop() const; // api @@ -52,7 +51,7 @@ namespace ndbl const assembly::Code* m_asm_code; VirtualMachine m_virtual_machine; bool m_auto_completion = false; - void log_function_call(const fw::variant &result, const fw::func_type *type) const; + void log_function_call(const tools::variant &result, const tools::func_type *type) const; }; } diff --git a/src/ndbl/cli/main.cpp b/src/ndbl/cli/main.cpp new file mode 100644 index 000000000..0d314456d --- /dev/null +++ b/src/ndbl/cli/main.cpp @@ -0,0 +1,21 @@ +#include "CLI.h" +#include "ndbl/core/core.h" + +using tools::log; + +int main(int argc, char *argv[]) +{ + ndbl::core_init(); + log::set_verbosity(log::Verbosity_Warning ); + { + ndbl::CLI cli; + + while ( !cli.should_stop() ) + { + cli.update(); + } + } + ndbl::core_shutdown(); + LOG_FLUSH() + return 0; +} diff --git a/src/nodable/gui/tests.cpp b/src/ndbl/cli/tests.cpp similarity index 70% rename from src/nodable/gui/tests.cpp rename to src/ndbl/cli/tests.cpp index daab4900c..79fc57ee0 100644 --- a/src/nodable/gui/tests.cpp +++ b/src/ndbl/cli/tests.cpp @@ -1,8 +1,8 @@ #include -#include "fw/core/log.h" -#include +#include "tools/core/log.h" +#include "tools/core/reflection/reflection" -using namespace fw; +using namespace tools; int main(int argc, char **argv) { diff --git a/src/nodable/core/Component.cpp b/src/ndbl/core/Component.cpp similarity index 90% rename from src/nodable/core/Component.cpp rename to src/ndbl/core/Component.cpp index 52232c2ee..56c2ce517 100644 --- a/src/nodable/core/Component.cpp +++ b/src/ndbl/core/Component.cpp @@ -2,7 +2,7 @@ #include "Node.h" using namespace ndbl; -using namespace fw; +using namespace tools; REGISTER { diff --git a/src/nodable/core/Component.h b/src/ndbl/core/Component.h similarity index 63% rename from src/nodable/core/Component.h rename to src/ndbl/core/Component.h index 24c51983a..cc5d9c547 100644 --- a/src/nodable/core/Component.h +++ b/src/ndbl/core/Component.h @@ -1,7 +1,7 @@ #pragma once -#include "fw/core/reflection/reflection" -#include "fw/core/memory/Pool.h" +#include "tools/core/reflection/reflection" +#include "tools/core/memory/Pool.h" namespace ndbl { @@ -20,9 +20,9 @@ namespace ndbl Component(Component&&) = default; Component& operator=(Component&&) = default; virtual ~Component() = default; - ::fw::PoolID get_owner()const { return m_owner; } - virtual void set_owner(::fw::PoolID node); + ::tools::PoolID get_owner()const { return m_owner; } + virtual void set_owner(::tools::PoolID node); protected: - ::fw::PoolID m_owner; + ::tools::PoolID m_owner; }; } \ No newline at end of file diff --git a/src/nodable/core/ComponentBag.cpp b/src/ndbl/core/ComponentBag.cpp similarity index 87% rename from src/nodable/core/ComponentBag.cpp rename to src/ndbl/core/ComponentBag.cpp index cc0a1e414..eefbb5884 100644 --- a/src/nodable/core/ComponentBag.cpp +++ b/src/ndbl/core/ComponentBag.cpp @@ -2,7 +2,7 @@ #include "Component.h" using namespace ndbl; -using namespace fw; +using namespace tools; void ComponentBag::add(PoolID id) @@ -20,7 +20,7 @@ void ComponentBag::remove(PoolID component) { auto found = std::find(m_components.begin(), m_components.end(), component ); - FW_EXPECT(found != m_components.end(), "Component can't be found it those components"); + EXPECT(found != m_components.end(), "Component can't be found it those components"); m_components_by_type.erase(component->get_type()->id()); m_components.erase(found); component->set_owner({}); diff --git a/src/nodable/core/ComponentBag.h b/src/ndbl/core/ComponentBag.h similarity index 78% rename from src/nodable/core/ComponentBag.h rename to src/ndbl/core/ComponentBag.h index d81a51909..2f35bb864 100644 --- a/src/nodable/core/ComponentBag.h +++ b/src/ndbl/core/ComponentBag.h @@ -1,6 +1,6 @@ #pragma once -#include "fw/core/memory/Pool.h" -#include "fw/core/reflection/reflection" +#include "tools/core/memory/Pool.h" +#include "tools/core/reflection/reflection" #include namespace ndbl { @@ -8,7 +8,7 @@ namespace ndbl { // forward declarations class Node; class Component; - using fw::PoolID; + using tools::PoolID; /** * Store a list of Components* owned by a single owner. @@ -38,10 +38,10 @@ namespace ndbl { template PoolID get()const; - inline std::unordered_map>::const_iterator + inline std::unordered_map>::const_iterator begin() const { return m_components_by_type.cbegin(); } - inline std::unordered_map>::const_iterator + inline std::unordered_map>::const_iterator end() const { return m_components_by_type.cend(); } const std::vector>& get_all() @@ -50,14 +50,14 @@ namespace ndbl { private: PoolID m_owner; std::vector> m_components; - std::unordered_map> m_components_by_type; + std::unordered_map> m_components_by_type; }; template PoolID ComponentBag::get() const { - static_assert(fw::is_base_of::value, "ComponentT must inherit from Component"); + static_assert( tools::is_base_of::value, "ComponentT must inherit from Component"); if ( m_components_by_type.empty() ) return {}; auto desired_typeid = std::type_index(typeid(T)); diff --git a/src/nodable/core/DataAccess.cpp b/src/ndbl/core/DataAccess.cpp similarity index 93% rename from src/nodable/core/DataAccess.cpp rename to src/ndbl/core/DataAccess.cpp index 5722cdb86..516422fbd 100644 --- a/src/nodable/core/DataAccess.cpp +++ b/src/ndbl/core/DataAccess.cpp @@ -6,13 +6,13 @@ #include #include -#include "fw/core/assertions.h" -#include "fw/core/memory/Pool.h" +#include "tools/core/assertions.h" +#include "tools/core/memory/Pool.h" #include "Node.h" using namespace ndbl; -using namespace fw; +using namespace tools; REGISTER { @@ -41,7 +41,7 @@ bool DataAccess::update() }; Node* owner = m_owner.get(); - FW_ASSERT( owner != nullptr ); + ASSERT( owner != nullptr ); writer.StartObject(); { // Write Properties diff --git a/src/nodable/core/DataAccess.h b/src/ndbl/core/DataAccess.h similarity index 81% rename from src/nodable/core/DataAccess.h rename to src/ndbl/core/DataAccess.h index 883d852d2..1380245a5 100644 --- a/src/nodable/core/DataAccess.h +++ b/src/ndbl/core/DataAccess.h @@ -1,7 +1,7 @@ #pragma once -#include "fw/core/types.h" -#include "fw/core/reflection/reflection" +#include "tools/core/types.h" +#include "tools/core/reflection/reflection" #include "Component.h" namespace ndbl diff --git a/src/nodable/core/DirectedEdge.cpp b/src/ndbl/core/DirectedEdge.cpp similarity index 95% rename from src/nodable/core/DirectedEdge.cpp rename to src/ndbl/core/DirectedEdge.cpp index 046de453f..877e1c6a7 100644 --- a/src/nodable/core/DirectedEdge.cpp +++ b/src/ndbl/core/DirectedEdge.cpp @@ -19,8 +19,8 @@ DirectedEdge::DirectedEdge( SlotRef _tail, SlotRef _head ) : tail(_tail) , head(_head) { - FW_ASSERT(_tail.flags & SlotFlag_ORDER_FIRST ) - FW_ASSERT(_head.flags & SlotFlag_ORDER_SECOND ) + ASSERT(_tail.flags & SlotFlag_ORDER_FIRST ) + ASSERT(_head.flags & SlotFlag_ORDER_SECOND ) } bool DirectedEdge::operator!=( const DirectedEdge &other ) const diff --git a/src/nodable/core/DirectedEdge.h b/src/ndbl/core/DirectedEdge.h similarity index 100% rename from src/nodable/core/DirectedEdge.h rename to src/ndbl/core/DirectedEdge.h diff --git a/src/nodable/core/ForLoopNode.cpp b/src/ndbl/core/ForLoopNode.cpp similarity index 97% rename from src/nodable/core/ForLoopNode.cpp rename to src/ndbl/core/ForLoopNode.cpp index f181a6a3f..83a4a84b0 100644 --- a/src/nodable/core/ForLoopNode.cpp +++ b/src/ndbl/core/ForLoopNode.cpp @@ -3,7 +3,7 @@ #include "GraphUtil.h" using namespace ndbl; -using namespace fw; +using namespace tools; REGISTER { diff --git a/src/nodable/core/ForLoopNode.h b/src/ndbl/core/ForLoopNode.h similarity index 100% rename from src/nodable/core/ForLoopNode.h rename to src/ndbl/core/ForLoopNode.h diff --git a/src/nodable/core/Graph.cpp b/src/ndbl/core/Graph.cpp similarity index 91% rename from src/nodable/core/Graph.cpp rename to src/ndbl/core/Graph.cpp index ce63f040f..af63b0eb6 100644 --- a/src/nodable/core/Graph.cpp +++ b/src/ndbl/core/Graph.cpp @@ -13,7 +13,7 @@ #include "language/Nodlang.h" using namespace ndbl; -using namespace fw; +using namespace tools; Graph::Graph( const NodeFactory* _factory @@ -91,7 +91,7 @@ UpdateResult Graph::update() void Graph::add(PoolID _node) { - FW_ASSERT(std::find(m_node_registry.begin(), m_node_registry.end(), _node->poolid()) == m_node_registry.end()) + ASSERT(std::find(m_node_registry.begin(), m_node_registry.end(), _node->poolid()) == m_node_registry.end()) m_node_registry.push_back(_node->poolid()); _node->parent_graph = this; set_dirty(); // To express this graph changed @@ -101,7 +101,7 @@ void Graph::add(PoolID _node) void Graph::remove(PoolID _node) { auto found = std::find(m_node_registry.begin(), m_node_registry.end(), _node); - FW_ASSERT(found != m_node_registry.end()); + ASSERT(found != m_node_registry.end()); m_node_registry.erase(found); set_dirty(); // To express this graph changed } @@ -201,20 +201,20 @@ bool Graph::is_empty() const DirectedEdge* Graph::connect_or_merge(Slot&_out, Slot& _in ) { // Guards - FW_ASSERT( _in ) - FW_ASSERT( _out ) - FW_ASSERT( _in.has_flags( SlotFlag_INPUT ) ) - FW_ASSERT( _in.has_flags( SlotFlag_NOT_FULL ) ) - FW_ASSERT( _out.has_flags( SlotFlag_OUTPUT ) ) - FW_ASSERT( _out.has_flags( SlotFlag_NOT_FULL ) ) + ASSERT( _in ) + ASSERT( _out ) + ASSERT( _in.has_flags( SlotFlag_INPUT ) ) + ASSERT( _in.has_flags( SlotFlag_NOT_FULL ) ) + ASSERT( _out.has_flags( SlotFlag_OUTPUT ) ) + ASSERT( _out.has_flags( SlotFlag_NOT_FULL ) ) Property* in_prop = _in.get_property(); Property* out_prop = _out.get_property(); - FW_EXPECT( in_prop, "tail property must be defined" ) - FW_EXPECT( out_prop, "head property must be defined" ) - FW_EXPECT( in_prop != out_prop, "Can't connect same properties!" ) + EXPECT( in_prop, "tail property must be defined" ) + EXPECT( out_prop, "head property must be defined" ) + EXPECT( in_prop != out_prop, "Can't connect same properties!" ) const type* out_type = out_prop->get_type(); const type* in_type = in_prop->get_type(); - FW_EXPECT( type::is_implicitly_convertible( out_type, in_type ), "dependency type should be implicitly convertible to dependent type"); + EXPECT( type::is_implicitly_convertible( out_type, in_type ), "dependency type should be implicitly convertible to dependent type"); // case 1: merge orphan slot if ( _out.get_node() == nullptr ) // if dependent is orphan @@ -261,15 +261,15 @@ void Graph::remove(DirectedEdge edge) DirectedEdge* Graph::connect_to_variable(Slot& _out, VariableNode& _variable ) { // Guards - FW_ASSERT( _out.has_flags( SlotFlag_OUTPUT | SlotFlag_NOT_FULL )) + ASSERT( _out.has_flags( SlotFlag_OUTPUT | SlotFlag_NOT_FULL )) return connect_or_merge( _out, _variable.input_slot() ); } DirectedEdge* Graph::connect(Slot& _first, Slot& _second, ConnectFlags _flags) { - FW_ASSERT( _first.has_flags( SlotFlag_ORDER_FIRST ) ) - FW_ASSERT( _second.has_flags( SlotFlag_ORDER_SECOND ) ) - FW_ASSERT( _first.node != _second.node ) + ASSERT( _first.has_flags( SlotFlag_ORDER_FIRST ) ) + ASSERT( _second.has_flags( SlotFlag_ORDER_SECOND ) ) + ASSERT( _first.node != _second.node ) // Insert edge SlotFlags type = _first.type(); @@ -292,10 +292,10 @@ DirectedEdge* Graph::connect(Slot& _first, Slot& _second, ConnectFlags _flags) // - child node has a PARENT slot Node* parent = _first.get_node(); static_assert(SlotFlag_CHILD & SlotFlag_ORDER_FIRST); Node* new_child = _second.get_node(); static_assert(SlotFlag_PARENT & SlotFlag_ORDER_SECOND); - FW_ASSERT( parent->has_component()) + ASSERT( parent->has_component()) Slot* parent_next_slot = parent->find_slot_at( SlotFlag_NEXT, _first.position() ); - FW_ASSERT(parent_next_slot) + ASSERT(parent_next_slot) Slot& new_child_prev_slot = *new_child->find_slot( SlotFlag_PREV ); // Case 1: Parent has only 1 child (the newly connected), we connect it as "next". @@ -311,7 +311,7 @@ DirectedEdge* Graph::connect(Slot& _first, Slot& _second, ConnectFlags _flags) else { PoolID previous_child = parent->rchildren().at(1); - FW_ASSERT( previous_child ) + ASSERT( previous_child ) // Case 2.a: Connects to all last instructions' "next" slot (in last child's previous_child_scope). // parent @@ -332,7 +332,7 @@ DirectedEdge* Graph::connect(Slot& _first, Slot& _second, ConnectFlags _flags) for (Node* each_instr : previous_child_scope->get_last_instructions_rec() ) { Slot* each_instr_next_slot = each_instr->find_slot( SlotFlag_NEXT | SlotFlag_NOT_FULL ); - FW_ASSERT(each_instr_next_slot); + ASSERT(each_instr_next_slot); connect( *each_instr_next_slot, new_child_prev_slot ); } } @@ -345,7 +345,7 @@ DirectedEdge* Graph::connect(Slot& _first, Slot& _second, ConnectFlags _flags) else { Slot* last_sibling_next_slot = previous_child->find_slot( SlotFlag_NEXT | SlotFlag_NOT_FULL ); - FW_ASSERT(last_sibling_next_slot) + ASSERT(last_sibling_next_slot) connect( *last_sibling_next_slot, new_child_prev_slot ); } } @@ -411,7 +411,7 @@ DirectedEdge* Graph::connect(Slot& _first, Slot& _second, ConnectFlags _flags) break; } default: - FW_ASSERT(false);// This connection type is not yet implemented + ASSERT(false);// This connection type is not yet implemented } } set_dirty(); // To express this graph changed @@ -424,7 +424,7 @@ void Graph::disconnect( const DirectedEdge& _edge, ConnectFlags flags) SlotFlags type = _edge.tail.flags & SlotFlag_TYPE_MASK; auto [range_begin, range_end] = m_edge_registry.equal_range(type); auto it = std::find_if( range_begin, range_end, [&](const auto& _pair) -> bool { return _edge == _pair.second; }); - FW_EXPECT( it != m_edge_registry.end(), "Unable to find edge" ); + EXPECT( it != m_edge_registry.end(), "Unable to find edge" ); // erase it from the registry m_edge_registry.erase(it); @@ -457,7 +457,7 @@ void Graph::disconnect( const DirectedEdge& _edge, ConnectFlags flags) // None break; default: - FW_EXPECT(!type, "Not yet implemented yet"); + EXPECT(!type, "Not yet implemented yet"); } set_dirty(); // To express this graph changed @@ -539,7 +539,7 @@ PoolID Graph::create_node( NodeType _type, const func_type* _signature ) case NodeType_INVOKABLE: { - FW_EXPECT(_signature != nullptr, "_signature is expected when dealing with functions or operators") + EXPECT(_signature != nullptr, "_signature is expected when dealing with functions or operators") auto& language = Nodlang::get_instance(); // Currently, we handle operators and functions the exact same way const auto invokable = language.find_function(_signature); @@ -547,7 +547,7 @@ PoolID Graph::create_node( NodeType _type, const func_type* _signature ) return create_function(invokable.get(), is_operator); } default: - FW_EXPECT( false, "Unhandled NodeType."); + EXPECT( false, "Unhandled NodeType."); } } diff --git a/src/nodable/core/Graph.h b/src/ndbl/core/Graph.h similarity index 77% rename from src/nodable/core/Graph.h rename to src/ndbl/core/Graph.h index 98d1157c6..c9e3a15fe 100644 --- a/src/nodable/core/Graph.h +++ b/src/ndbl/core/Graph.h @@ -5,12 +5,12 @@ #include #include // std::shared_ptr -#include "nodable/core/Node.h" -#include "nodable/core/NodeFactory.h" -#include "nodable/core/WhileLoopNode.h" -#include "fw/core/reflection/class.h" -#include "fw/core/reflection/reflection" -#include "fw/core/types.h" +#include "ndbl/core/Node.h" +#include "ndbl/core/NodeFactory.h" +#include "ndbl/core/WhileLoopNode.h" +#include "tools/core/reflection/class.h" +#include "tools/core/reflection/reflection" +#include "tools/core/types.h" #include "IScope.h" @@ -58,21 +58,21 @@ namespace ndbl // node related PoolID create_node(); // Create a raw node. - PoolID create_node(NodeType, const fw::func_type* _signature = nullptr); // Create a given node type in a simple way. + PoolID create_node(NodeType, const tools::func_type* _signature = nullptr); // Create a given node type in a simple way. PoolID create_root(); - PoolID create_variable(const fw::type *_type, const std::string &_name, PoolID _scope); - PoolID create_variable_decl(const fw::type* _type, const char* _name, PoolID _scope); + PoolID create_variable(const tools::type *_type, const std::string &_name, PoolID _scope); + PoolID create_variable_decl(const tools::type* _type, const char* _name, PoolID _scope); template PoolID create_variable_decl(const char* _name = "var", PoolID _scope = {}) - { return create_variable_decl( fw::type::get(), _name, _scope); } + { return create_variable_decl( tools::type::get(), _name, _scope); } - PoolID create_literal(const fw::type *_type); + PoolID create_literal(const tools::type *_type); template - PoolID create_literal() { return create_literal(fw::type::get()); } - PoolID create_abstract_function(const fw::func_type *_invokable, bool _is_operator = false); // Create and append a new abstract (without known implementation) function of a given type. - PoolID create_function(const fw::iinvokable *_invokable, bool _is_operator = false); - PoolID create_abstract_operator(const fw::func_type *_invokable); // Create a new abstract (without known implementation) operator. - PoolID create_operator(const fw::iinvokable *_invokable); + PoolID create_literal() { return create_literal( tools::type::get()); } + PoolID create_abstract_function(const tools::func_type *_invokable, bool _is_operator = false); // Create and append a new abstract (without known implementation) function of a given type. + PoolID create_function(const tools::iinvokable *_invokable, bool _is_operator = false); + PoolID create_abstract_operator(const tools::func_type *_invokable); // Create a new abstract (without known implementation) operator. + PoolID create_operator(const tools::iinvokable *_invokable); PoolID create_scope(); PoolID create_cond_struct(); PoolID create_for_loop(); diff --git a/src/nodable/core/Graph.specs.cpp b/src/ndbl/core/Graph.specs.cpp similarity index 98% rename from src/nodable/core/Graph.specs.cpp rename to src/ndbl/core/Graph.specs.cpp index bd0c35c3d..759915134 100644 --- a/src/nodable/core/Graph.specs.cpp +++ b/src/ndbl/core/Graph.specs.cpp @@ -1,6 +1,6 @@ #include -#include "fw/core/reflection/func_type.h" +#include "tools/core/reflection/func_type.h" #include "Graph.h" #include "InvokableComponent.h" @@ -11,7 +11,7 @@ #include "fixtures/core.h" using namespace ndbl; -using namespace fw; +using namespace tools; typedef ::testing::Core Graph_; TEST_F(Graph_, connect) diff --git a/src/nodable/core/GraphUtil.cpp b/src/ndbl/core/GraphUtil.cpp similarity index 100% rename from src/nodable/core/GraphUtil.cpp rename to src/ndbl/core/GraphUtil.cpp diff --git a/src/nodable/core/GraphUtil.h b/src/ndbl/core/GraphUtil.h similarity index 100% rename from src/nodable/core/GraphUtil.h rename to src/ndbl/core/GraphUtil.h diff --git a/src/nodable/core/IConditional.h b/src/ndbl/core/IConditional.h similarity index 93% rename from src/nodable/core/IConditional.h rename to src/ndbl/core/IConditional.h index 7eea39150..8b59cc14d 100644 --- a/src/nodable/core/IConditional.h +++ b/src/ndbl/core/IConditional.h @@ -1,6 +1,6 @@ #pragma once -#include "fw/core/reflection/reflection" +#include "tools/core/reflection/reflection" namespace ndbl { @@ -10,7 +10,7 @@ namespace ndbl class Slot; class Property; class InstructionNode; - using fw::PoolID; + using tools::PoolID; typedef size_t Branch; enum Branch_ : size_t diff --git a/src/nodable/core/IScope.h b/src/ndbl/core/IScope.h similarity index 90% rename from src/nodable/core/IScope.h rename to src/ndbl/core/IScope.h index 9642e9789..2fb60ed09 100644 --- a/src/nodable/core/IScope.h +++ b/src/ndbl/core/IScope.h @@ -1,9 +1,9 @@ #pragma once #include -#include "fw/core/memory/Pool.h" -#include "fw/core/reflection/reflection" -#include "fw/core/types.h" +#include "tools/core/memory/Pool.h" +#include "tools/core/reflection/reflection" +#include "tools/core/types.h" namespace ndbl { @@ -11,7 +11,7 @@ namespace ndbl class InstructionNode; class VariableNode; class Node; - using fw::PoolID; + using tools::PoolID; /** * @class Interface for a scope node diff --git a/src/nodable/core/IfNode.cpp b/src/ndbl/core/IfNode.cpp similarity index 91% rename from src/nodable/core/IfNode.cpp rename to src/ndbl/core/IfNode.cpp index 267c701d6..39065bbb5 100644 --- a/src/nodable/core/IfNode.cpp +++ b/src/ndbl/core/IfNode.cpp @@ -2,7 +2,7 @@ #include "IfNode.h" using namespace ndbl; -using namespace fw; +using namespace tools; REGISTER { diff --git a/src/nodable/core/IfNode.h b/src/ndbl/core/IfNode.h similarity index 100% rename from src/nodable/core/IfNode.h rename to src/ndbl/core/IfNode.h diff --git a/src/nodable/core/InstructionNode.h b/src/ndbl/core/InstructionNode.h similarity index 96% rename from src/nodable/core/InstructionNode.h rename to src/ndbl/core/InstructionNode.h index d50bced1e..41d7fbd23 100644 --- a/src/nodable/core/InstructionNode.h +++ b/src/ndbl/core/InstructionNode.h @@ -3,7 +3,7 @@ #include #include -#include "fw/core/types.h" +#include "tools/core/types.h" #include "Node.h" // base class #include "Property.h" diff --git a/src/nodable/core/InvokableComponent.cpp b/src/ndbl/core/InvokableComponent.cpp similarity index 88% rename from src/nodable/core/InvokableComponent.cpp rename to src/ndbl/core/InvokableComponent.cpp index 83ebe04d9..e2c8c1ae5 100644 --- a/src/nodable/core/InvokableComponent.cpp +++ b/src/ndbl/core/InvokableComponent.cpp @@ -1,13 +1,13 @@ #include "InvokableComponent.h" -#include "fw/core/log.h" -#include "fw/core/memory/Pool.h" -#include "fw/core/reflection/func_type.h" +#include "tools/core/log.h" +#include "tools/core/memory/Pool.h" +#include "tools/core/reflection/func_type.h" #include "VariableNode.h" using namespace ndbl; -using namespace fw; +using namespace tools; REGISTER { @@ -28,7 +28,7 @@ InvokableComponent::InvokableComponent(const func_type* _signature, bool _is_ope , m_is_operator( _is_operator ) , token( Token_t::identifier, _signature->get_identifier().c_str() ) { - FW_EXPECT(_signature != nullptr, "Signature must be defined!") + EXPECT(_signature != nullptr, "Signature must be defined!") m_invokable = _invokable; m_argument_slot.resize(_signature->get_arg_count()); } @@ -59,7 +59,7 @@ bool InvokableComponent::update() variants.push_back( adjacent->get_property()->value() ); } } - FW_ASSERT( m_argument_slot.size() == variants.size()) + ASSERT( m_argument_slot.size() == variants.size()) variant result = m_invokable->invoke( variants ); m_result_slot->get_property()->set( result); for( auto* variant : variants ) variant->flag_defined(true); @@ -80,13 +80,13 @@ bool InvokableComponent::update() void InvokableComponent::bind_result(SlotRef slot) { - FW_ASSERT(slot.flags & SlotFlag_OUTPUT); + ASSERT(slot.flags & SlotFlag_OUTPUT); m_result_slot = slot; } void InvokableComponent::bind_arg(size_t arg_id, SlotRef slot) { - FW_ASSERT(slot.flags & SlotFlag_INPUT) + ASSERT(slot.flags & SlotFlag_INPUT) m_argument_slot[arg_id] = slot; } diff --git a/src/nodable/core/InvokableComponent.h b/src/ndbl/core/InvokableComponent.h similarity index 78% rename from src/nodable/core/InvokableComponent.h rename to src/ndbl/core/InvokableComponent.h index d0f74e121..26c5866eb 100644 --- a/src/nodable/core/InvokableComponent.h +++ b/src/ndbl/core/InvokableComponent.h @@ -1,8 +1,8 @@ #pragma once #include -#include "fw/core/types.h" -#include "fw/core/reflection/reflection" +#include "tools/core/types.h" +#include "tools/core/reflection/reflection" #include "DirectedEdge.h" #include "Component.h" @@ -19,7 +19,7 @@ namespace ndbl { public: InvokableComponent(); - InvokableComponent(const fw::func_type*, bool _is_operator, const fw::iinvokable*); + InvokableComponent(const tools::func_type*, bool _is_operator, const tools::iinvokable*); ~InvokableComponent() = default; InvokableComponent(InvokableComponent&&) = default; InvokableComponent& operator=(InvokableComponent&&) = default; @@ -28,8 +28,8 @@ namespace ndbl bool update(); void bind_arg(size_t _index, SlotRef); const std::vector& get_arguments() const; - const fw::func_type* get_func_type()const { return m_signature; } - const fw::iinvokable* get_function()const { return m_invokable; } + const tools::func_type* get_func_type()const { return m_signature; } + const tools::iinvokable* get_function()const { return m_invokable; } void bind_result(SlotRef); bool has_function() const { return m_invokable; }; bool is_operator()const { return m_is_operator; }; @@ -37,8 +37,8 @@ namespace ndbl protected: SlotRef m_result_slot; std::vector m_argument_slot; - const fw::func_type* m_signature; - const fw::iinvokable* m_invokable; + const tools::func_type* m_signature; + const tools::iinvokable* m_invokable; bool m_is_operator; REFLECT_DERIVED_CLASS() diff --git a/src/nodable/core/LiteralNode.cpp b/src/ndbl/core/LiteralNode.cpp similarity index 96% rename from src/nodable/core/LiteralNode.cpp rename to src/ndbl/core/LiteralNode.cpp index 0ceb108b1..57e7b0c69 100644 --- a/src/nodable/core/LiteralNode.cpp +++ b/src/ndbl/core/LiteralNode.cpp @@ -1,7 +1,7 @@ #include "LiteralNode.h" using namespace ndbl; -using namespace fw; +using namespace tools; REGISTER { diff --git a/src/nodable/core/LiteralNode.h b/src/ndbl/core/LiteralNode.h similarity index 77% rename from src/nodable/core/LiteralNode.h rename to src/ndbl/core/LiteralNode.h index 9e4189134..f92fe8253 100644 --- a/src/nodable/core/LiteralNode.h +++ b/src/ndbl/core/LiteralNode.h @@ -1,6 +1,6 @@ #pragma once #include // std::shared_ptr -#include "fw/core/reflection/reflection" +#include "tools/core/reflection/reflection" #include "Node.h" // Base class namespace ndbl @@ -10,7 +10,7 @@ namespace ndbl public: LiteralNode() = default; - explicit LiteralNode(const fw::type*); + explicit LiteralNode(const tools::type*); LiteralNode(LiteralNode&&) = default; LiteralNode& operator=(LiteralNode&&) = default; ~LiteralNode() override = default; @@ -19,8 +19,8 @@ namespace ndbl Property* value() { return get_prop_at( m_value_property_id ); } const Property* value() const { return get_prop_at( m_value_property_id ); } private: - ID m_value_property_id; - const fw::type* m_type; + ID m_value_property_id; + const tools::type* m_type; REFLECT_DERIVED_CLASS() }; } diff --git a/src/nodable/core/Node.cpp b/src/ndbl/core/Node.cpp similarity index 99% rename from src/nodable/core/Node.cpp rename to src/ndbl/core/Node.cpp index efd65e180..fcd848a49 100644 --- a/src/nodable/core/Node.cpp +++ b/src/ndbl/core/Node.cpp @@ -10,7 +10,7 @@ #include "InvokableComponent.h" using namespace ndbl; -using namespace fw; +using namespace tools; REGISTER { @@ -228,7 +228,7 @@ Slot & Node::get_nth_slot( u8_t _n, SlotFlags _flags ) count++; } } - FW_EXPECT(false, "Not found") + EXPECT(false, "Not found") } ID Node::add_prop(const type *_type, const char *_name, PropertyFlags _flags) diff --git a/src/nodable/core/Node.h b/src/ndbl/core/Node.h similarity index 91% rename from src/nodable/core/Node.h rename to src/ndbl/core/Node.h index e3c29293c..2f9f5d10e 100644 --- a/src/nodable/core/Node.h +++ b/src/ndbl/core/Node.h @@ -5,10 +5,10 @@ #include #include -#include "fw/core/assertions.h" -#include "fw/core/memory/Pool.h" -#include "fw/core/reflection/reflection" -#include "fw/core/types.h" +#include "tools/core/assertions.h" +#include "tools/core/memory/Pool.h" +#include "tools/core/reflection/reflection" +#include "tools/core/types.h" #include "ComponentBag.h" #include "DirectedEdge.h" @@ -16,8 +16,8 @@ #include "PropertyBag.h" #include "constants.h" -namespace ndbl { - +namespace ndbl +{ // forward declarations class Graph; @@ -85,7 +85,7 @@ namespace ndbl { const Slot* find_slot_at( SlotFlags, size_t _position ) const; // implicitly THIS_PROPERTY's slot Slot* find_slot_by_property_name(const char* _property_name, SlotFlags ); const Slot* find_slot_by_property_name(const char* property_name, SlotFlags ) const; - Slot* find_slot_by_property_type(SlotFlags _way, const fw::type *_type); + Slot* find_slot_by_property_type(SlotFlags _way, const tools::type *_type); Slot* find_slot_by_property_id( ID, SlotFlags ); const Slot* find_slot_by_property_id( ID, SlotFlags ) const; Slot* find_adjacent_at(SlotFlags, u8_t _index ) const; @@ -104,12 +104,12 @@ namespace ndbl { // Property related //----------------- - ID add_prop(const fw::type*, const char* /* name */, PropertyFlags = PropertyFlag_DEFAULT); + ID add_prop(const tools::type*, const char* /* name */, PropertyFlags = PropertyFlag_DEFAULT); Property* get_prop_at(ID); const Property* get_prop_at(ID) const; Property* get_prop(const char* _name); const Property* get_prop(const char* _name) const; - const fw::iinvokable*get_connected_invokable(const char *property_name) const; // TODO: can't remember to understand why I needed this... + const tools::iinvokable*get_connected_invokable(const char *property_name) const; // TODO: can't remember to understand why I needed this... bool has_input_connected( const ID& ) const; template diff --git a/src/nodable/core/Node.specs.cpp b/src/ndbl/core/Node.specs.cpp similarity index 96% rename from src/nodable/core/Node.specs.cpp rename to src/ndbl/core/Node.specs.cpp index 4c800e1c0..5a81bf5e3 100644 --- a/src/nodable/core/Node.specs.cpp +++ b/src/ndbl/core/Node.specs.cpp @@ -1,4 +1,4 @@ -#include "nodable/core/Scope.h" +#include "ndbl/core/Scope.h" #include "fixtures/core.h" #include diff --git a/src/nodable/core/NodeFactory.cpp b/src/ndbl/core/NodeFactory.cpp similarity index 95% rename from src/nodable/core/NodeFactory.cpp rename to src/ndbl/core/NodeFactory.cpp index 65a95295b..420a543b5 100644 --- a/src/nodable/core/NodeFactory.cpp +++ b/src/ndbl/core/NodeFactory.cpp @@ -2,7 +2,7 @@ #include -#include "fw/core/reflection/reflection" +#include "tools/core/reflection/reflection" #include "ForLoopNode.h" #include "IfNode.h" @@ -15,7 +15,7 @@ #include "WhileLoopNode.h" using namespace ndbl; -using namespace fw; +using namespace tools; NodeFactory::NodeFactory() : m_post_process([](PoolID _node){}) @@ -79,8 +79,8 @@ PoolID NodeFactory::_create_abstract_func(const func_type* _func_type, boo { size_t count = _func_type->get_arg_count(); - FW_EXPECT( count != 0 , "An operator cannot have zero argument" ); - FW_EXPECT( count < 3 , "An operator cannot have more than 2 arguments" ); + EXPECT( count != 0 , "An operator cannot have zero argument" ); + EXPECT( count < 3 , "An operator cannot have more than 2 arguments" ); switch ( count ) { @@ -238,7 +238,7 @@ void NodeFactory::destroy_node(PoolID node) const void NodeFactory::override_post_process_fct( NodeFactory::PostProcessFct f) { - FW_EXPECT( m_post_process_is_overrided == false, "Cannot override post process function more than once." ); + EXPECT( m_post_process_is_overrided == false, "Cannot override post process function more than once." ); m_post_process_is_overrided = true; m_post_process = f; } diff --git a/src/nodable/core/NodeFactory.h b/src/ndbl/core/NodeFactory.h similarity index 71% rename from src/nodable/core/NodeFactory.h rename to src/ndbl/core/NodeFactory.h index d0074755c..928dd36ad 100644 --- a/src/nodable/core/NodeFactory.h +++ b/src/ndbl/core/NodeFactory.h @@ -2,7 +2,7 @@ #include // std::shared_ptr #include // std::function -#include "fw/core/reflection/reflection" +#include "tools/core/reflection/reflection" #include "ForLoopNode.h" #include "IfNode.h" @@ -32,10 +32,10 @@ namespace ndbl ~NodeFactory(){} PoolID create_program()const; - PoolID create_variable(const fw::type *_type, const std::string &_name, PoolID _scope)const; - PoolID create_literal(const fw::type *_type)const; - PoolID create_abstract_func(const fw::func_type *_signature, bool _is_operator)const; - PoolID create_func(const fw::iinvokable *_function, bool _is_operator)const; + PoolID create_variable(const tools::type *_type, const std::string &_name, PoolID _scope)const; + PoolID create_literal(const tools::type *_type)const; + PoolID create_abstract_func(const tools::func_type *_signature, bool _is_operator)const; + PoolID create_func(const tools::iinvokable *_function, bool _is_operator)const; PoolID create_scope()const; PoolID create_cond_struct()const; PoolID create_for_loop()const; @@ -44,8 +44,8 @@ namespace ndbl void destroy_node(PoolID node)const; void override_post_process_fct( NodeFactory::PostProcessFct f ); private: - PoolID _create_abstract_func(const fw::func_type *_func_type, bool _is_operator) const; // this do not invoke post_process - void add_invokable_component(PoolID _node, const fw::func_type *_func_type, const fw::iinvokable *_invokable, bool _is_operator) const; + PoolID _create_abstract_func(const tools::func_type *_func_type, bool _is_operator) const; // this do not invoke post_process + void add_invokable_component(PoolID _node, const tools::func_type *_func_type, const tools::iinvokable *_invokable, bool _is_operator) const; bool m_post_process_is_overrided; std::function)> m_post_process; // invoked after each node creation, just before to return. diff --git a/src/nodable/core/NodeUtils.h b/src/ndbl/core/NodeUtils.h similarity index 98% rename from src/nodable/core/NodeUtils.h rename to src/ndbl/core/NodeUtils.h index 4faf68d40..092509c6d 100644 --- a/src/nodable/core/NodeUtils.h +++ b/src/ndbl/core/NodeUtils.h @@ -1,6 +1,6 @@ #pragma once #include "Node.h" -#include "fw/core/memory/Pool.h" +#include "tools/core/memory/Pool.h" #include #include diff --git a/src/nodable/core/Property.cpp b/src/ndbl/core/Property.cpp similarity index 97% rename from src/nodable/core/Property.cpp rename to src/ndbl/core/Property.cpp index 3b80539b7..24dd66991 100644 --- a/src/nodable/core/Property.cpp +++ b/src/ndbl/core/Property.cpp @@ -2,10 +2,10 @@ #include "PropertyBag.h" #include "VariableNode.h" -#include "fw/core/memory/Pool.h" +#include "tools/core/memory/Pool.h" using namespace ndbl; -using namespace fw; +using namespace tools; Property::Property() : m_name("Unknown") diff --git a/src/nodable/core/Property.h b/src/ndbl/core/Property.h similarity index 71% rename from src/nodable/core/Property.h rename to src/ndbl/core/Property.h index 63f31c51f..af7adb3f7 100644 --- a/src/nodable/core/Property.h +++ b/src/ndbl/core/Property.h @@ -1,9 +1,9 @@ #pragma once -#include "nodable/core/Token.h" -#include "fw/core/memory/Pool.h" -#include "fw/core/reflection/variant.h" -#include "fw/core/types.h"// for constants and forward declarations +#include "ndbl/core/Token.h" +#include "tools/core/memory/Pool.h" +#include "tools/core/reflection/variant.h" +#include "tools/core/types.h"// for constants and forward declarations #include #include @@ -32,7 +32,7 @@ namespace ndbl class Property { public: - fw::ID id; + tools::ID id; Token token; explicit Property(); @@ -41,13 +41,13 @@ namespace ndbl explicit Property(bool); explicit Property(double); explicit Property(const char *); - explicit Property(const fw::type *_type, PropertyFlags _flags); + explicit Property(const tools::type *_type, PropertyFlags _flags); ~Property() = default; - fw::variant* operator->() { return value(); } - const fw::variant* operator->() const { return value(); } - fw::variant& operator*() { return *value(); } - const fw::variant& operator*() const { return *value(); } + tools::variant* operator->() { return value(); } + const tools::variant* operator->() const { return value(); } + tools::variant& operator*() { return *value(); } + const tools::variant& operator*() const { return *value(); } template T to()const { return value()->to(); } void digest(Property *_property); @@ -59,16 +59,16 @@ namespace ndbl void set_visibility(PropertyFlags); const std::string& get_name()const { return m_name; } - const fw::type* get_type()const { return value()->get_type(); } + const tools::type* get_type()const { return value()->get_type(); } PropertyFlags get_visibility()const { return m_flags & PropertyFlag_VISIBILITY_MASK; } PropertyFlags flags()const { return m_flags; } void ensure_is_initialized(bool b); void flag_as_reference(); bool is_ref() const; - fw::variant* value() { return &m_variant; } - const fw::variant* value()const{ return &m_variant; } + tools::variant* value() { return &m_variant; } + const tools::variant* value()const{ return &m_variant; } - static std::vector get(std::vector _in_properties); + static std::vector get(std::vector _in_properties); template T& as() { return value()->as(); } @@ -83,7 +83,7 @@ namespace ndbl private: PropertyFlags m_flags; std::string m_name; - fw::variant m_variant; + tools::variant m_variant; }; template diff --git a/src/nodable/core/Property.specs.cpp b/src/ndbl/core/Property.specs.cpp similarity index 96% rename from src/nodable/core/Property.specs.cpp rename to src/ndbl/core/Property.specs.cpp index 5dc99a1ec..5ac8e9ed1 100644 --- a/src/nodable/core/Property.specs.cpp +++ b/src/ndbl/core/Property.specs.cpp @@ -1,9 +1,9 @@ #include "Property.h" -#include "fw/core/memory/Pool.h" +#include "tools/core/memory/Pool.h" #include using namespace ndbl; -using namespace fw; +using namespace tools; TEST(Property, Type_Boolean) { diff --git a/src/nodable/core/PropertyBag.cpp b/src/ndbl/core/PropertyBag.cpp similarity index 96% rename from src/nodable/core/PropertyBag.cpp rename to src/ndbl/core/PropertyBag.cpp index 75a628140..26524de54 100644 --- a/src/nodable/core/PropertyBag.cpp +++ b/src/ndbl/core/PropertyBag.cpp @@ -2,7 +2,7 @@ #include "Node.h" using namespace ndbl; -using namespace fw; +using namespace tools; bool PropertyBag::has(const char* _name) const { @@ -11,7 +11,7 @@ bool PropertyBag::has(const char* _name) const ID PropertyBag::add(const type* _type, const char* _name, PropertyFlags _flags ) { - FW_ASSERT(!has(_name)); + ASSERT(!has(_name)); auto id = (ID)m_properties.size(); // we cannot delete a property, so we can count on size() to get a unique id @@ -86,7 +86,7 @@ ID PropertyBag::find_id_from_name(const char *_name) const return id; } } - FW_EXPECT( false, "No property found with this name") + EXPECT( false, "No property found with this name") } Property* PropertyBag::get_this() diff --git a/src/nodable/core/PropertyBag.h b/src/ndbl/core/PropertyBag.h similarity index 76% rename from src/nodable/core/PropertyBag.h rename to src/ndbl/core/PropertyBag.h index ff5a21de3..0bd14b4eb 100644 --- a/src/nodable/core/PropertyBag.h +++ b/src/ndbl/core/PropertyBag.h @@ -3,9 +3,9 @@ #include #include // std::shared_ptr -#include "fw/core/memory/Pool.h" -#include "fw/core/reflection/reflection" -#include "fw/core/types.h" +#include "tools/core/memory/Pool.h" +#include "tools/core/reflection/reflection" +#include "tools/core/types.h" #include "constants.h" #include "Property.h" @@ -34,31 +34,31 @@ namespace ndbl const_iterator end() const { return m_properties.end(); } size_t size() const; bool has(const char*) const; - Property* at(fw::ID); - const Property* at(fw::ID) const; + Property* at( tools::ID); + const Property* at( tools::ID) const; Property* find_by_name(const char* _name); const Property* find_by_name(const char* _name) const; - Property* find_first( PropertyFlags, const fw::type* ); - const Property* find_first( PropertyFlags, const fw::type* ) const; - fw::ID find_id_from_name(const char*) const; + Property* find_first( PropertyFlags, const tools::type* ); + const Property* find_first( PropertyFlags, const tools::type* ) const; + tools::ID find_id_from_name(const char*) const; Property* get_this(); const Property* get_this() const; - fw::ID add( const fw::type* _type, + tools::ID add( const tools::type* _type, const char *_name, PropertyFlags = PropertyFlag_DEFAULT ); template - fw::ID add( + tools::ID add( const char* _name, PropertyFlags _flags = PropertyFlag_DEFAULT ) { - return add(fw::type::get(), _name, _flags); + return add( tools::type::get(), _name, _flags); } private: - const Property* _find_first( PropertyFlags _flags, const fw::type *_type) const; + const Property* _find_first( PropertyFlags _flags, const tools::type *_type) const; const Property* _find_nth_write_only( u8_t _n ) const; std::vector m_properties; - std::map> m_properties_by_name; + std::map> m_properties_by_name; }; } \ No newline at end of file diff --git a/src/nodable/core/Scope.cpp b/src/ndbl/core/Scope.cpp similarity index 90% rename from src/nodable/core/Scope.cpp rename to src/ndbl/core/Scope.cpp index 57908284a..dd9d74e87 100644 --- a/src/nodable/core/Scope.cpp +++ b/src/ndbl/core/Scope.cpp @@ -3,8 +3,8 @@ #include #include // for std::find_if -#include "fw/core/log.h" -#include "fw/core/memory/Pool.h" +#include "tools/core/log.h" +#include "tools/core/memory/Pool.h" #include "ForLoopNode.h" #include "IScope.h" @@ -12,7 +12,7 @@ #include "VariableNode.h" using namespace ndbl; -using namespace fw; +using namespace tools; REGISTER { @@ -46,7 +46,7 @@ PoolID Scope::find_variable(const std::string &_name) * In case not found, find recursively */ PoolID parent = m_owner->find_parent(); - FW_ASSERT(parent != m_owner); + ASSERT(parent != m_owner); if ( !parent ) { return {}; @@ -56,7 +56,7 @@ PoolID Scope::find_variable(const std::string &_name) { return {}; } - FW_ASSERT(scope != m_id); + ASSERT(scope != m_id); return scope->find_variable( _name ); } @@ -90,7 +90,7 @@ std::vector& Scope::get_last_instructions_rec( std::vector& _out) // Recursive call for nested scopes for( size_t i = 0; i < children.size(); ++i ) { - FW_ASSERT(children[i]) + ASSERT(children[i]) if ( PoolID scope = children[i]->get_component() ) { scope->get_last_instructions_rec(_out); // Recursive call on nested scopes @@ -106,10 +106,10 @@ std::vector& Scope::get_last_instructions_rec( std::vector& _out) void Scope::remove_variable(VariableNode* _variable) { - FW_ASSERT(_variable != nullptr) - FW_ASSERT(_variable->get_scope() == m_id) + ASSERT(_variable != nullptr) + ASSERT(_variable->get_scope() == m_id) auto found = std::find(m_variables.begin(), m_variables.end(), _variable->poolid() ); - FW_ASSERT(found->get() != nullptr); + ASSERT(found->get() != nullptr); _variable->reset_scope(); m_variables.erase( found ); } diff --git a/src/nodable/core/Scope.h b/src/ndbl/core/Scope.h similarity index 100% rename from src/nodable/core/Scope.h rename to src/ndbl/core/Scope.h diff --git a/src/nodable/core/SimpleKeyValueSerializer.h b/src/ndbl/core/SimpleKeyValueSerializer.h similarity index 100% rename from src/nodable/core/SimpleKeyValueSerializer.h rename to src/ndbl/core/SimpleKeyValueSerializer.h diff --git a/src/nodable/core/Slot.cpp b/src/ndbl/core/Slot.cpp similarity index 86% rename from src/nodable/core/Slot.cpp rename to src/ndbl/core/Slot.cpp index 770e35150..d046b7da5 100644 --- a/src/nodable/core/Slot.cpp +++ b/src/ndbl/core/Slot.cpp @@ -27,8 +27,8 @@ Slot::Slot( , m_adjacent() , m_position(_position) { - FW_ASSERT( (_flags & SlotFlag_NOT_FULL) == SlotFlag_NONE ) // cannot be set manually - FW_ASSERT( _capacity > 0 ) + ASSERT( (_flags & SlotFlag_NOT_FULL) == SlotFlag_NONE ) // cannot be set manually + ASSERT( _capacity > 0 ) m_adjacent.reserve(_capacity); flags |= SlotFlag_NOT_FULL; } @@ -113,9 +113,9 @@ Node* Slot::get_node() const void Slot::add_adjacent( const SlotRef& _ref) { - FW_EXPECT( _ref != *this, "Reflexive edge not handled" ); - FW_EXPECT( type() == _ref.slot_type() , "Slot must have common type" ); - FW_EXPECT( m_adjacent.size() < m_adjacent.capacity(), "Slot is full" ); + EXPECT( _ref != *this, "Reflexive edge not handled" ); + EXPECT( type() == _ref.slot_type() , "Slot must have common type" ); + EXPECT( m_adjacent.size() < m_adjacent.capacity(), "Slot is full" ); m_adjacent.emplace_back(_ref); if ( m_adjacent.size() == m_adjacent.capacity() ) { @@ -126,7 +126,7 @@ void Slot::add_adjacent( const SlotRef& _ref) void Slot::remove_adjacent( const SlotRef& _ref ) { auto it = std::find( m_adjacent.begin(), m_adjacent.end(), _ref); - FW_EXPECT( it != m_adjacent.end(), "SlotRef not found") + EXPECT( it != m_adjacent.end(), "SlotRef not found") m_adjacent.erase( it ); flags |= SlotFlag_NOT_FULL; } @@ -163,7 +163,7 @@ size_t Slot::capacity() const void Slot::expand_capacity( size_t _capacity ) { - FW_EXPECT( m_adjacent.capacity() <= _capacity, "New capacity must be strictly greater than current" ); + EXPECT( m_adjacent.capacity() <= _capacity, "New capacity must be strictly greater than current" ); m_adjacent.reserve(_capacity); flags |= SlotFlag_NOT_FULL; } diff --git a/src/nodable/core/Slot.h b/src/ndbl/core/Slot.h similarity index 90% rename from src/nodable/core/Slot.h rename to src/ndbl/core/Slot.h index 01c037e7b..28b5acabe 100644 --- a/src/nodable/core/Slot.h +++ b/src/ndbl/core/Slot.h @@ -1,7 +1,7 @@ #pragma once #include "SlotFlag.h" -#include "fw/core/memory/Pool.h" -#include "fw/core/types.h" +#include "tools/core/memory/Pool.h" +#include "tools/core/types.h" #include namespace ndbl @@ -10,9 +10,9 @@ namespace ndbl class Node; class Property; class SlotRef; - using fw::PoolID; - using fw::ID; - using fw::ID8; + using tools::PoolID; + using tools::ID; + using tools::ID8; constexpr u8_t SLOT_MAX_CAPACITY = std::numeric_limits::max(); @@ -22,7 +22,7 @@ namespace ndbl static const Slot null; ID8 id; // slot index (in node's SlotBag) - PoolID node; // node id (in fw::Pool) + PoolID node; // node id (in tools::Pool) ID property; // property index (in node's PropertyBag) SlotFlags flags; diff --git a/src/nodable/core/Slot.specs.cpp b/src/ndbl/core/Slot.specs.cpp similarity index 100% rename from src/nodable/core/Slot.specs.cpp rename to src/ndbl/core/Slot.specs.cpp diff --git a/src/nodable/core/SlotFlag.h b/src/ndbl/core/SlotFlag.h similarity index 98% rename from src/nodable/core/SlotFlag.h rename to src/ndbl/core/SlotFlag.h index 195c65c96..40eb123f0 100644 --- a/src/nodable/core/SlotFlag.h +++ b/src/ndbl/core/SlotFlag.h @@ -1,5 +1,5 @@ #pragma once -#include "fw/core/types.h" +#include "tools/core/types.h" namespace ndbl { diff --git a/src/nodable/core/SlotRef.cpp b/src/ndbl/core/SlotRef.cpp similarity index 100% rename from src/nodable/core/SlotRef.cpp rename to src/ndbl/core/SlotRef.cpp diff --git a/src/nodable/core/SlotRef.h b/src/ndbl/core/SlotRef.h similarity index 91% rename from src/nodable/core/SlotRef.h rename to src/ndbl/core/SlotRef.h index dbf4193ad..de6472f04 100644 --- a/src/nodable/core/SlotRef.h +++ b/src/ndbl/core/SlotRef.h @@ -1,12 +1,12 @@ #pragma once #include "SlotFlag.h" -#include "fw/core/memory/Pool.h" +#include "tools/core/memory/Pool.h" namespace ndbl { // Forward declarations - using fw::PoolID; - using fw::ID8; + using tools::PoolID; + using tools::ID8; class Node; class Slot; diff --git a/src/nodable/core/TConditionalNode.h b/src/ndbl/core/TConditionalNode.h similarity index 94% rename from src/nodable/core/TConditionalNode.h rename to src/ndbl/core/TConditionalNode.h index 5e50c8246..b7cf9249f 100644 --- a/src/nodable/core/TConditionalNode.h +++ b/src/ndbl/core/TConditionalNode.h @@ -37,7 +37,7 @@ namespace ndbl template const Slot& TConditionalNode::get_condition_slot( Branch _branch ) const { - FW_ASSERT( _branch > 0 && _branch < BRANCH_COUNT ) // branch_FALSE has no condition + ASSERT( _branch > 0 && _branch < BRANCH_COUNT ) // branch_FALSE has no condition return get_slot_at( m_condition_slot_id.at(_branch - 1) ); } @@ -72,16 +72,16 @@ namespace ndbl template const Slot& TConditionalNode::get_child_slot_at( Branch _branch ) const { - FW_ASSERT(_branch < BRANCH_COUNT ) + ASSERT(_branch < BRANCH_COUNT ) return m_slots[ (u8_t)m_child_slot_id[_branch] ]; } template PoolID TConditionalNode::get_scope_at( Branch _branch ) const { - FW_ASSERT(_branch < BRANCH_COUNT ) + ASSERT(_branch < BRANCH_COUNT ) const Slot& slot = m_slots[ (u8_t)m_child_slot_id[_branch] ]; - FW_ASSERT(slot); + ASSERT(slot); if ( SlotRef adjacent_slot = slot.first_adjacent() ) { return adjacent_slot.node->get_component(); diff --git a/src/nodable/core/Token.cpp b/src/ndbl/core/Token.cpp similarity index 100% rename from src/nodable/core/Token.cpp rename to src/ndbl/core/Token.cpp diff --git a/src/nodable/core/Token.h b/src/ndbl/core/Token.h similarity index 98% rename from src/nodable/core/Token.h rename to src/ndbl/core/Token.h index 84b037f82..c786e847b 100644 --- a/src/nodable/core/Token.h +++ b/src/ndbl/core/Token.h @@ -6,9 +6,9 @@ #include #include -#include "fw/core/string.h" -#include "fw/core/reflection/reflection" -#include "fw/core/assertions.h" +#include "tools/core/string.h" +#include "tools/core/reflection/reflection" +#include "tools/core/assertions.h" #include "Token_t.h" namespace ndbl diff --git a/src/nodable/core/Token.specs.cpp b/src/ndbl/core/Token.specs.cpp similarity index 98% rename from src/nodable/core/Token.specs.cpp rename to src/ndbl/core/Token.specs.cpp index 0704b13e3..7a338d29b 100644 --- a/src/nodable/core/Token.specs.cpp +++ b/src/ndbl/core/Token.specs.cpp @@ -1,5 +1,5 @@ #include -#include "nodable/core/Property.h" +#include "ndbl/core/Property.h" using namespace ndbl; diff --git a/src/nodable/core/TokenRibbon.cpp b/src/ndbl/core/TokenRibbon.cpp similarity index 97% rename from src/nodable/core/TokenRibbon.cpp rename to src/ndbl/core/TokenRibbon.cpp index 7fd0e69f8..708a38996 100644 --- a/src/nodable/core/TokenRibbon.cpp +++ b/src/ndbl/core/TokenRibbon.cpp @@ -1,7 +1,7 @@ #include "TokenRibbon.h" -#include "fw/core/log.h" -#include "fw/core/assertions.h" +#include "tools/core/log.h" +#include "tools/core/assertions.h" #include "Token_t.h" #include "Token.h" @@ -114,7 +114,7 @@ void TokenRibbon::set_source_buffer(char* _buffer) bool TokenRibbon::can_eat(size_t count) const { - FW_ASSERT(count > 0); + ASSERT(count > 0); return m_cursor + count <= m_tokens.size() ; } diff --git a/src/nodable/core/TokenRibbon.h b/src/ndbl/core/TokenRibbon.h similarity index 100% rename from src/nodable/core/TokenRibbon.h rename to src/ndbl/core/TokenRibbon.h diff --git a/src/nodable/core/Token_t.h b/src/ndbl/core/Token_t.h similarity index 97% rename from src/nodable/core/Token_t.h rename to src/ndbl/core/Token_t.h index 006bf11a6..967e05e09 100644 --- a/src/nodable/core/Token_t.h +++ b/src/ndbl/core/Token_t.h @@ -1,5 +1,5 @@ #pragma once -#include "fw/core/types.h" +#include "tools/core/types.h" namespace ndbl { diff --git a/src/nodable/core/VariableNode.cpp b/src/ndbl/core/VariableNode.cpp similarity index 92% rename from src/nodable/core/VariableNode.cpp rename to src/ndbl/core/VariableNode.cpp index 9c01ea9b9..798aab557 100644 --- a/src/nodable/core/VariableNode.cpp +++ b/src/ndbl/core/VariableNode.cpp @@ -3,7 +3,7 @@ #include "Scope.h" using namespace ndbl; -using namespace fw; +using namespace tools; REGISTER { @@ -18,7 +18,7 @@ VariableNode::VariableNode() { } -VariableNode::VariableNode(const fw::type *_type, const char* identifier) +VariableNode::VariableNode(const tools::type *_type, const char* identifier) : Node("Variable") , identifier_token( Token_t::identifier ) , m_is_declared( false ) @@ -63,14 +63,14 @@ void VariableNode::reset_scope(Scope* _scope) Property *VariableNode::property() { Property* p = get_prop_at( m_value_property_id ); - FW_ASSERT(p != nullptr) + ASSERT(p != nullptr) return p; } const Property* VariableNode::property() const { const Property* p = get_prop_at( m_value_property_id ); - FW_ASSERT(p != nullptr) + ASSERT(p != nullptr) return p; } diff --git a/src/nodable/core/VariableNode.h b/src/ndbl/core/VariableNode.h similarity index 73% rename from src/nodable/core/VariableNode.h rename to src/ndbl/core/VariableNode.h index a29abbbd9..ca4e456ad 100644 --- a/src/nodable/core/VariableNode.h +++ b/src/ndbl/core/VariableNode.h @@ -3,8 +3,8 @@ #include #include // std::shared_ptr -#include "fw/core/reflection/reflection" -#include "fw/core/types.h" +#include "tools/core/reflection/reflection" +#include "tools/core/types.h" #include "Scope.h" #include "Node.h" @@ -21,7 +21,7 @@ namespace ndbl public: VariableNode(); VariableNode(VariableNode&&) = default; - explicit VariableNode(const fw::type *, const char* identifier); + explicit VariableNode(const tools::type *, const char* identifier); ~VariableNode() override = default; VariableNode& operator=(VariableNode&&) = default; @@ -32,12 +32,12 @@ namespace ndbl PoolID get_scope(); void set_declared(bool b = true) { m_is_declared = b; } void reset_scope(Scope* _scope = nullptr); - const fw::type* type() const; - fw::variant* value(); - fw::variant& operator * () { return *property()->value(); } - fw::variant* operator -> () { return property()->value(); } - const fw::variant& operator * () const { return *property()->value(); } - const fw::variant* operator -> () const { return property()->value(); } + const tools::type* type() const; + tools::variant* value(); + tools::variant& operator * () { return *property()->value(); } + tools::variant* operator -> () { return property()->value(); } + const tools::variant& operator * () const { return *property()->value(); } + const tools::variant* operator -> () const { return property()->value(); } Slot &input_slot(); const Slot &input_slot() const; @@ -51,7 +51,7 @@ namespace ndbl private: ID m_value_property_id; bool m_is_declared; - const fw::type* m_type; + const tools::type* m_type; PoolID m_scope; REFLECT_DERIVED_CLASS() diff --git a/src/nodable/core/Vertex.h b/src/ndbl/core/Vertex.h similarity index 95% rename from src/nodable/core/Vertex.h rename to src/ndbl/core/Vertex.h index a00f697a7..02998fecb 100644 --- a/src/nodable/core/Vertex.h +++ b/src/ndbl/core/Vertex.h @@ -24,5 +24,5 @@ namespace ndbl } }; -}// namespace fw +}// namespace tools diff --git a/src/nodable/core/VirtualMachine.cpp b/src/ndbl/core/VirtualMachine.cpp similarity index 95% rename from src/nodable/core/VirtualMachine.cpp rename to src/ndbl/core/VirtualMachine.cpp index f4b12d1a2..41e379cfe 100644 --- a/src/nodable/core/VirtualMachine.cpp +++ b/src/ndbl/core/VirtualMachine.cpp @@ -5,7 +5,7 @@ #include "VariableNode.h" using namespace ndbl; -using namespace fw; +using namespace tools; using opcode = ndbl::assembly::Instruction_t; CPU::CPU() @@ -58,7 +58,7 @@ void VirtualMachine::advance_cursor(i64_t _amount) void VirtualMachine::run_program() { - FW_ASSERT(m_program_asm_code); + ASSERT(m_program_asm_code); LOG_MESSAGE("VM", "Running program ...\n") m_is_program_running = true; @@ -165,7 +165,7 @@ bool VirtualMachine::_stepOver() } else { - FW_EXPECT(false, "This type is not handled!") + EXPECT(false, "This type is not handled!") } advance_cursor(); @@ -196,7 +196,7 @@ bool VirtualMachine::_stepOver() { advance_cursor(); VariableNode* variable = next_instr->push.var.get(); - FW_EXPECT(variable->value()->is_initialized(), "Variable should be initialized since it should have been pushed earlier!"); + EXPECT(variable->value()->is_initialized(), "Variable should be initialized since it should have been pushed earlier!"); variable->value()->reset_value(); variable->value()->ensure_is_initialized(false); success = true; @@ -343,7 +343,7 @@ bool VirtualMachine::step_over() void VirtualMachine::debug_program() { - FW_ASSERT(m_program_asm_code); + ASSERT(m_program_asm_code); m_is_debugging = true; m_is_program_running = true; m_cpu.clear_registers(); @@ -373,8 +373,8 @@ Instruction* VirtualMachine::get_next_instr() const bool VirtualMachine::load_program(const Code *_code) { - FW_ASSERT(!m_is_program_running) // dev must stop before to load program. - FW_ASSERT(!m_program_asm_code) // dev must unload before to load. + ASSERT(!m_is_program_running) // dev must stop before to load program. + ASSERT(!m_program_asm_code) // dev must unload before to load. m_program_asm_code = _code; diff --git a/src/nodable/core/VirtualMachine.h b/src/ndbl/core/VirtualMachine.h similarity index 90% rename from src/nodable/core/VirtualMachine.h rename to src/ndbl/core/VirtualMachine.h index eb7db0328..65ed2474e 100644 --- a/src/nodable/core/VirtualMachine.h +++ b/src/ndbl/core/VirtualMachine.h @@ -1,6 +1,6 @@ #pragma once -#include "fw/core/types.h" +#include "tools/core/types.h" #include "assembly/Compiler.h" #include "assembly/Register.h" @@ -23,17 +23,17 @@ namespace ndbl CPU(); ~CPU() = default; // Read a given register - fw::qword read(Register)const; + tools::qword read(Register)const; // Write a word into a given register - void write(Register, fw::qword); + void write(Register, tools::qword); // Clear all registers void clear_registers(); private: // Read a given register by reference with write mode - fw::qword& read_write(Register); + tools::qword& read_write(Register); // Store all registers - fw::qword m_register[Register::COUNT]; + tools::qword m_register[Register::COUNT]; }; /** @@ -68,13 +68,13 @@ namespace ndbl // Get the next node to be executed. Works in debug mode only. inline const Node* get_next_node() const {return m_next_node.get(); } // Get the last instruction's result - fw::qword get_last_result() const; + tools::qword get_last_result() const; // Check if there is a next instruction (internally check instruction pointer's position) bool is_there_a_next_instr() const; // Get the next instruction to execute Instruction* get_next_instr() const; // Read a given CPU register - fw::qword read_cpu_register(Register _register) const; + tools::qword read_cpu_register(Register _register) const; // Get current program ptr*/ const Code * get_program_asm_code(); // Check if a given Node is the next to be executed diff --git a/src/nodable/core/VirtualMachine.specs.cpp b/src/ndbl/core/VirtualMachine.specs.cpp similarity index 100% rename from src/nodable/core/VirtualMachine.specs.cpp rename to src/ndbl/core/VirtualMachine.specs.cpp diff --git a/src/nodable/core/WhileLoopNode.cpp b/src/ndbl/core/WhileLoopNode.cpp similarity index 91% rename from src/nodable/core/WhileLoopNode.cpp rename to src/ndbl/core/WhileLoopNode.cpp index a7c9a3ee3..0edcad459 100644 --- a/src/nodable/core/WhileLoopNode.cpp +++ b/src/ndbl/core/WhileLoopNode.cpp @@ -1,7 +1,7 @@ #include "WhileLoopNode.h" using namespace ndbl; -using namespace fw; +using namespace tools; REGISTER { diff --git a/src/nodable/core/WhileLoopNode.h b/src/ndbl/core/WhileLoopNode.h similarity index 91% rename from src/nodable/core/WhileLoopNode.h rename to src/ndbl/core/WhileLoopNode.h index e87e43897..8b203d872 100644 --- a/src/nodable/core/WhileLoopNode.h +++ b/src/ndbl/core/WhileLoopNode.h @@ -1,7 +1,7 @@ #pragma once #include -#include "fw/core/reflection/reflection" +#include "tools/core/reflection/reflection" #include "TConditionalNode.h"// base class #include "Token.h" diff --git a/src/nodable/core/assembly/Code.cpp b/src/ndbl/core/assembly/Code.cpp similarity index 91% rename from src/nodable/core/assembly/Code.cpp rename to src/ndbl/core/assembly/Code.cpp index 26facd08f..4933ccaea 100644 --- a/src/nodable/core/assembly/Code.cpp +++ b/src/ndbl/core/assembly/Code.cpp @@ -1,9 +1,9 @@ #include "Code.h" #include -#include "fw/core/format.h" +#include "tools/core/format.h" using namespace ndbl; -using namespace fw; +using namespace tools; assembly::Code::~Code() { diff --git a/src/nodable/core/assembly/Code.h b/src/ndbl/core/assembly/Code.h similarity index 98% rename from src/nodable/core/assembly/Code.h rename to src/ndbl/core/assembly/Code.h index ad8fe264b..b4796fa46 100644 --- a/src/nodable/core/assembly/Code.h +++ b/src/ndbl/core/assembly/Code.h @@ -1,7 +1,7 @@ #pragma once #include -#include "fw/core/types.h" +#include "tools/core/types.h" #include "Instruction.h" namespace ndbl diff --git a/src/nodable/core/assembly/Compiler.cpp b/src/ndbl/core/assembly/Compiler.cpp similarity index 93% rename from src/nodable/core/assembly/Compiler.cpp rename to src/ndbl/core/assembly/Compiler.cpp index 9a01851d0..cc87daa06 100644 --- a/src/nodable/core/assembly/Compiler.cpp +++ b/src/ndbl/core/assembly/Compiler.cpp @@ -3,28 +3,28 @@ #include #include -#include "fw/core/assertions.h" -#include "fw/core/log.h" -#include "fw/core/math.h" -#include "fw/core/string.h" -#include "fw/core/memory/Pool.h" - -#include "nodable/core/ForLoopNode.h" -#include "nodable/core/Graph.h" -#include "nodable/core/IConditional.h" -#include "nodable/core/IfNode.h" -#include "nodable/core/InvokableComponent.h" -#include "nodable/core/LiteralNode.h" -#include "nodable/core/Scope.h" -#include "nodable/core/VariableNode.h" -#include "nodable/core/WhileLoopNode.h" +#include "tools/core/assertions.h" +#include "tools/core/log.h" +#include "tools/core/math.h" +#include "tools/core/string.h" +#include "tools/core/memory/Pool.h" + +#include "ndbl/core/ForLoopNode.h" +#include "ndbl/core/Graph.h" +#include "ndbl/core/IConditional.h" +#include "ndbl/core/IfNode.h" +#include "ndbl/core/InvokableComponent.h" +#include "ndbl/core/LiteralNode.h" +#include "ndbl/core/Scope.h" +#include "ndbl/core/VariableNode.h" +#include "ndbl/core/WhileLoopNode.h" #include "Instruction.h" #include "Register.h" using namespace ndbl; using namespace ndbl::assembly; -using namespace fw; +using namespace tools; Code::Code( PoolID root ) : m_meta_data({root}) @@ -79,23 +79,23 @@ void Compiler::compile_input_slot( const Slot& slot) { return; } - FW_ASSERT( slot.adjacent_count() == 1 ) + ASSERT( slot.adjacent_count() == 1 ) compile_output_slot( *slot.first_adjacent() ); } void Compiler::compile_output_slot( const Slot& slot) { - FW_ASSERT(slot.has_flags(SlotFlag_OUTPUT) ) + ASSERT(slot.has_flags(SlotFlag_OUTPUT) ) Property* property = slot.get_property(); - FW_EXPECT(property != nullptr, "Vertex should contain a valid property id" ) + EXPECT(property != nullptr, "Vertex should contain a valid property id" ) compile_node( slot.get_node() ); } void assembly::Compiler::compile_scope(const Scope* _scope, bool _insert_fake_return) { - FW_ASSERT(_scope) + ASSERT(_scope) const Node* scope_owner = _scope->get_owner().get(); - FW_ASSERT(scope_owner) + ASSERT(scope_owner) // call push_stack_frame { @@ -143,7 +143,7 @@ void assembly::Compiler::compile_scope(const Scope* _scope, bool _insert_fake_re void assembly::Compiler::compile_node( const Node* _node ) { - FW_ASSERT( _node ) + ASSERT( _node ) if ( _node->get_type()->is_child_of()) { @@ -332,7 +332,7 @@ const Code* assembly::Compiler::compile_syntax_tree(const Graph* _graph) try { Scope* scope = _graph->get_root()->get_component().get(); - FW_ASSERT(scope) + ASSERT(scope) compile_scope(scope, true); // <--- true here is a hack, TODO: implement a real ReturnNode LOG_MESSAGE("Compiler", "Program compiled.\n"); } diff --git a/src/nodable/core/assembly/Compiler.h b/src/ndbl/core/assembly/Compiler.h similarity index 97% rename from src/nodable/core/assembly/Compiler.h rename to src/ndbl/core/assembly/Compiler.h index bc9e02167..ba727dd13 100644 --- a/src/nodable/core/assembly/Compiler.h +++ b/src/ndbl/core/assembly/Compiler.h @@ -1,6 +1,6 @@ #pragma once -#include "fw/core/types.h" -#include "nodable/core/Graph.h" +#include "tools/core/types.h" +#include "ndbl/core/Graph.h" #include "Code.h" namespace ndbl diff --git a/src/nodable/core/assembly/Instruction.cpp b/src/ndbl/core/assembly/Instruction.cpp similarity index 97% rename from src/nodable/core/assembly/Instruction.cpp rename to src/ndbl/core/assembly/Instruction.cpp index d3680700d..fb1ebef41 100644 --- a/src/nodable/core/assembly/Instruction.cpp +++ b/src/ndbl/core/assembly/Instruction.cpp @@ -1,10 +1,10 @@ #include "Instruction.h" #include -#include "fw/core/format.h" +#include "tools/core/format.h" #include "Register.h" using namespace ndbl; -using namespace fw; +using namespace tools; std::string assembly::Instruction::to_string(const Instruction& _instr) { diff --git a/src/nodable/core/assembly/Instruction.h b/src/ndbl/core/assembly/Instruction.h similarity index 87% rename from src/nodable/core/assembly/Instruction.h rename to src/ndbl/core/assembly/Instruction.h index 95f90e5f7..472a43722 100644 --- a/src/nodable/core/assembly/Instruction.h +++ b/src/ndbl/core/assembly/Instruction.h @@ -1,8 +1,8 @@ #pragma once -#include "fw/core/memory/Pool.h" -#include "fw/core/reflection/reflection" -#include "fw/core/types.h" +#include "tools/core/memory/Pool.h" +#include "tools/core/reflection/reflection" +#include "tools/core/types.h" namespace ndbl { @@ -10,7 +10,7 @@ namespace ndbl class Scope; class VariableNode; class Node; - using fw::PoolID; + using tools::PoolID; namespace assembly { @@ -54,24 +54,26 @@ namespace assembly struct Instruction_mov { Instruction_t opcode; - fw::qword dst; // source memory - fw::qword src; // destination memory + tools::qword dst; // source memory + tools::qword src; // destination memory }; // Un-reference a pointer to a given type struct Instruction_uref { - Instruction_t opcode; - fw::qword* ptr; - const fw::type* type; // pointed data's type. + Instruction_t opcode; + tools::qword* ptr; + const tools::type* type; // pointed data's type. }; // Compare two operands (test if equals) struct Instruction_cmp { + using qword = tools::qword; + Instruction_t opcode; - fw::qword left; // the left operand. - fw::qword right; // the right operand. + qword left; // the left operand. + qword right; // the right operand. }; // Push or pop to/from the stack. diff --git a/src/nodable/core/assembly/Register.h b/src/ndbl/core/assembly/Register.h similarity index 93% rename from src/nodable/core/assembly/Register.h rename to src/ndbl/core/assembly/Register.h index 84825138b..e0b1e618c 100644 --- a/src/nodable/core/assembly/Register.h +++ b/src/ndbl/core/assembly/Register.h @@ -1,6 +1,6 @@ #pragma once -#include "fw/core/reflection/reflection" +#include "tools/core/reflection/reflection" namespace ndbl { diff --git a/src/nodable/core/constants.h b/src/ndbl/core/constants.h similarity index 100% rename from src/nodable/core/constants.h rename to src/ndbl/core/constants.h diff --git a/src/ndbl/core/core.cpp b/src/ndbl/core/core.cpp new file mode 100644 index 000000000..fde4b010d --- /dev/null +++ b/src/ndbl/core/core.cpp @@ -0,0 +1,17 @@ +#include "core.h" +#include "tools/core/core.h" +#include "tools/core/log.h" + +void ndbl::core_init() +{ + LOG_MESSAGE("ndbl", "core_init() ...\n"); + tools::core_init(); + LOG_MESSAGE("ndbl", "core_init() OK\n"); +}; + +void ndbl::core_shutdown() +{ + LOG_MESSAGE("ndbl", "core_shutdown() ...\n"); + tools::core_shutdown(); + LOG_MESSAGE("ndbl", "core_shutdown() OK\n"); +}; \ No newline at end of file diff --git a/src/ndbl/core/core.h b/src/ndbl/core/core.h new file mode 100644 index 000000000..32c17cd6e --- /dev/null +++ b/src/ndbl/core/core.h @@ -0,0 +1,7 @@ +#pragma once + +namespace ndbl +{ + void core_init(); // Call before to use tools::core + void core_shutdown(); // Undo init() +} \ No newline at end of file diff --git a/src/nodable/core/fixtures/core.h b/src/ndbl/core/fixtures/core.h similarity index 85% rename from src/nodable/core/fixtures/core.h rename to src/ndbl/core/fixtures/core.h index 1a85d62f3..b0116e249 100644 --- a/src/nodable/core/fixtures/core.h +++ b/src/ndbl/core/fixtures/core.h @@ -4,16 +4,19 @@ #include #include -#include "fw/core/string.h" -#include "fw/core/types.h" -#include "nodable/core/Graph.h" -#include "nodable/core/Node.h" -#include "nodable/core/NodeFactory.h" -#include "nodable/core/Property.h" -#include "nodable/core/Scope.h" -#include "nodable/core/VariableNode.h" -#include "nodable/core/VirtualMachine.h" -#include "nodable/core/language/Nodlang.h" +#include "ndbl/core/Graph.h" +#include "ndbl/core/Node.h" +#include "ndbl/core/NodeFactory.h" +#include "ndbl/core/Property.h" +#include "ndbl/core/Scope.h" +#include "ndbl/core/VariableNode.h" +#include "ndbl/core/VirtualMachine.h" +#include "ndbl/core/core.h" +#include "ndbl/core/language/Nodlang.h" +#include "tools/core/core.h" +#include "tools/core/string.h" +#include "tools/core/types.h" +#include "tools/gui/gui.h" using namespace ndbl; @@ -31,12 +34,12 @@ class Core : public Test Core() : graph(&factory) { - //fw::log::set_verbosity( fw::log::Verbosity_Verbose ); + //tools::log::set_verbosity( tools::log::Verbosity_Verbose ); } void SetUp() { - fw::Pool::init(); + ndbl::core_init(); } void TearDown() @@ -50,7 +53,7 @@ class Core : public Test { LOG_ERROR(__FILE__, "Exception during graph.clear(): %s\n", error.what() ); } - fw::Pool::shutdown(); + ndbl::core_shutdown(); } ~Core() @@ -83,7 +86,7 @@ class Core : public Test virtual_machine.run_program(); // get result - fw::qword mem_space = virtual_machine.get_last_result(); + tools::qword mem_space = virtual_machine.get_last_result(); auto result = return_t(mem_space); virtual_machine.release_program(); diff --git a/src/nodable/core/language/Nodlang.bench.cpp b/src/ndbl/core/language/Nodlang.bench.cpp similarity index 94% rename from src/nodable/core/language/Nodlang.bench.cpp rename to src/ndbl/core/language/Nodlang.bench.cpp index 6ba3ff4e4..783cb4432 100644 --- a/src/nodable/core/language/Nodlang.bench.cpp +++ b/src/ndbl/core/language/Nodlang.bench.cpp @@ -1,10 +1,10 @@ #include #include -#include "nodable/core/language/Nodlang.h" -#include "nodable/core/Graph.h" -#include "nodable/core/NodeFactory.h" -#include "fw/core/reflection/reflection" -#include "fw/core/string.h" +#include "ndbl/core/language/Nodlang.h" +#include "ndbl/core/Graph.h" +#include "ndbl/core/NodeFactory.h" +#include "tools/core/reflection/reflection" +#include "tools/core/string.h" /* * @@ -28,7 +28,7 @@ */ using namespace ndbl; -using namespace fw; +using namespace tools; class NodlangFixture : public benchmark::Fixture { public: @@ -119,7 +119,7 @@ BENCHMARK_DEFINE_F(NodlangFixture, tokenize__some_code_to_graph)(benchmark::Stat for (auto _ : state) { - FW_EXPECT(language->tokenize(code), "parse failed"); + EXPECT(language->tokenize(code), "parse failed"); } } diff --git a/src/nodable/core/language/Nodlang.cpp b/src/ndbl/core/language/Nodlang.cpp similarity index 97% rename from src/nodable/core/language/Nodlang.cpp rename to src/ndbl/core/language/Nodlang.cpp index 0fb333cf4..2173c020b 100644 --- a/src/nodable/core/language/Nodlang.cpp +++ b/src/ndbl/core/language/Nodlang.cpp @@ -16,27 +16,27 @@ #include #include // isdigit, isalpha, and isalnum. -#include "fw/core/reflection/reflection" -#include "fw/core/format.h" -#include "fw/core/log.h" -#include "fw/core/hash.h" -#include "fw/core/memory/Pool.h" - -#include "nodable/core/DirectedEdge.h" -#include "nodable/core/ForLoopNode.h" -#include "nodable/core/Graph.h" -#include "nodable/core/IfNode.h" -#include "nodable/core/InvokableComponent.h" -#include "nodable/core/LiteralNode.h" -#include "nodable/core/Property.h" -#include "nodable/core/Scope.h" -#include "nodable/core/VariableNode.h" -#include "nodable/core/WhileLoopNode.h" -#include "nodable/core/language/Nodlang_biology.h" -#include "nodable/core/language/Nodlang_math.h" +#include "tools/core/reflection/reflection" +#include "tools/core/format.h" +#include "tools/core/log.h" +#include "tools/core/hash.h" +#include "tools/core/memory/Pool.h" + +#include "ndbl/core/DirectedEdge.h" +#include "ndbl/core/ForLoopNode.h" +#include "ndbl/core/Graph.h" +#include "ndbl/core/IfNode.h" +#include "ndbl/core/InvokableComponent.h" +#include "ndbl/core/LiteralNode.h" +#include "ndbl/core/Property.h" +#include "ndbl/core/Scope.h" +#include "ndbl/core/VariableNode.h" +#include "ndbl/core/WhileLoopNode.h" +#include "ndbl/core/language/Nodlang_biology.h" +#include "ndbl/core/language/Nodlang_math.h" using namespace ndbl; -using namespace fw; +using namespace tools; //--------------------------------------------------------------------------------------------------------------------------- // [SECTION] A. Declaration ------------------------------------------------------------------------------------------------- @@ -132,7 +132,7 @@ Nodlang::Nodlang(bool _strict) for( auto [keyword, operator_t, precedence] : m_definition.operators) { const Operator *op = new Operator(keyword, operator_t, precedence); - FW_ASSERT(std::find(m_operators.begin(), m_operators.end(), op) == m_operators.end()) + ASSERT(std::find(m_operators.begin(), m_operators.end(), op) == m_operators.end()) m_operators.push_back(op); } @@ -241,9 +241,9 @@ bool Nodlang::to_bool(const std::string &_str) std::string Nodlang::to_unquoted_string(const std::string &_quoted_str) { - FW_ASSERT(_quoted_str.size() >= 2); - FW_ASSERT(_quoted_str.front() == '\"'); - FW_ASSERT(_quoted_str.back() == '\"'); + ASSERT(_quoted_str.size() >= 2); + ASSERT(_quoted_str.front() == '\"'); + ASSERT(_quoted_str.back() == '\"'); return std::string(++_quoted_str.cbegin(), --_quoted_str.cend()); } @@ -607,8 +607,8 @@ PoolID Nodlang::parse_program() parse_code_block();// we do not check if we parsed something empty or not, a program can be empty. // Add ignored chars pre/post token to the main scope begin/end token prefix/suffix. - FW_ASSERT(program_scope->token_begin.is_null()) - FW_ASSERT(program_scope->token_end.is_null()) + ASSERT(program_scope->token_begin.is_null()) + ASSERT(program_scope->token_end.is_null()) program_scope->token_begin = parser_state.ribbon.prefix(); program_scope->token_end = parser_state.ribbon.suffix(); @@ -667,7 +667,7 @@ void Nodlang::parse_code_block() if ( auto instruction = parse_instr() ) { Slot* child_slot = get_current_scope_node()->find_slot( SlotFlag_CHILD | SlotFlag_NOT_FULL ); - FW_ASSERT(child_slot) + ASSERT(child_slot) // Create parent/child connection parser_state.graph->connect( *child_slot, @@ -1136,13 +1136,13 @@ Slot* Nodlang::parse_function_call() PoolID Nodlang::get_current_scope() { - FW_ASSERT( parser_state.scope.top() ); + ASSERT( parser_state.scope.top() ); return parser_state.scope.top(); } PoolID Nodlang::get_current_scope_node() { - FW_ASSERT( parser_state.scope.top() ); + ASSERT( parser_state.scope.top() ); return parser_state.scope.top()->get_owner(); } @@ -1538,7 +1538,7 @@ std::string &Nodlang::serialize_func_call(std::string &_out, const func_type *_s for (const SlotRef& input_slot : inputs) { - FW_ASSERT( input_slot->has_flags(SlotFlag_INPUT) ) + ASSERT( input_slot->has_flags(SlotFlag_INPUT) ) if ( input_slot != inputs.front()) { serialize_token_t(_out, Token_t::list_separator); @@ -1633,7 +1633,7 @@ std::string &Nodlang::serialize_variant(std::string &_out, const variant *varian std::string &Nodlang::serialize_input(std::string& _out, const Slot& _slot, SerializeFlags _flags ) const { - FW_ASSERT( _slot.has_flags( SlotFlag_INPUT ) ); + ASSERT( _slot.has_flags( SlotFlag_INPUT ) ); const Property* property = _slot.get_property(); const Slot* adjacent_slot = _slot.first_adjacent().get(); @@ -1643,7 +1643,7 @@ std::string &Nodlang::serialize_input(std::string& _out, const Slot& _slot, Seri } const Property* adjacent_property = adjacent_slot->get_property(); - FW_ASSERT(adjacent_property != nullptr) + ASSERT(adjacent_property != nullptr) // specific case of a Node* if ( adjacent_property->is_this() && adjacent_property->value()->is_initialized() ) @@ -1685,16 +1685,16 @@ std::string &Nodlang::serialize_output(std::string& _out, const Slot& _slot, Ser /** This method is work in progress * It works only if the given slot is an output of a VALUE_PROPERTY. * This means we need to serialize the node itself */ - FW_ASSERT( _slot.has_flags( SlotFlag_OUTPUT ) ) - FW_ASSERT( _slot.get_property() == _slot.node->get_prop(VALUE_PROPERTY) ) + ASSERT( _slot.has_flags( SlotFlag_OUTPUT ) ) + ASSERT( _slot.get_property() == _slot.node->get_prop(VALUE_PROPERTY) ) return serialize_node( _out, _slot.node, _flags ); } std::string & Nodlang::serialize_node( std::string &_out, const PoolID &node_id, SerializeFlags _flags ) const { const Node* node = node_id.get(); - FW_ASSERT( node ) - FW_ASSERT( _flags == SerializeFlag_RECURSE ); // The only flag configuration handled for now + ASSERT( node ) + ASSERT( _flags == SerializeFlag_RECURSE ); // The only flag configuration handled for now if ( auto* cond_struct = cast(node ) ) { @@ -2017,7 +2017,7 @@ void Nodlang::add_function(std::shared_ptr _invokable) // Register the invokable as an operator implementation auto found = std::find(m_operators_impl.begin(), m_operators_impl.end(), _invokable); - FW_ASSERT(found == m_operators_impl.end()) + ASSERT(found == m_operators_impl.end()) m_operators_impl.push_back(_invokable); LOG_VERBOSE("Nodlang", "add operator: %s (in m_functions and m_operator_implems)\n", type_as_string.c_str()); } @@ -2103,7 +2103,7 @@ int Nodlang::get_precedence(const iinvokable* _invokable) const const type * Nodlang::get_type(Token_t _token) const { - FW_EXPECT(is_a_type_keyword(_token), "_token_t is not a type keyword!"); + EXPECT(is_a_type_keyword(_token), "_token_t is not a type keyword!"); return m_type_by_token_t.find(_token)->second; return m_type_by_token_t.find(_token)->second; } @@ -2139,8 +2139,8 @@ Nodlang::ParserState::~ParserState() void Nodlang::ParserState::set_source_buffer(const char *str, size_t size) { - FW_ASSERT(source_buffer == nullptr); // should call clear() before - FW_ASSERT(str != nullptr); + ASSERT(source_buffer == nullptr); // should call clear() before + ASSERT(str != nullptr); if( size != 0 ) { diff --git a/src/nodable/core/language/Nodlang.h b/src/ndbl/core/language/Nodlang.h similarity index 74% rename from src/nodable/core/language/Nodlang.h rename to src/ndbl/core/language/Nodlang.h index 0addb1c3c..f84bfbb06 100644 --- a/src/nodable/core/language/Nodlang.h +++ b/src/ndbl/core/language/Nodlang.h @@ -6,13 +6,13 @@ #include #include -#include "fw/core/reflection/reflection" -#include "fw/core/system.h" -#include "fw/core/hash.h" +#include "tools/core/reflection/reflection" +#include "tools/core/system.h" +#include "tools/core/hash.h" -#include "nodable/core/VariableNode.h" -#include "nodable/core/Token.h" -#include "nodable/core/TokenRibbon.h" +#include "ndbl/core/VariableNode.h" +#include "ndbl/core/Token.h" +#include "ndbl/core/TokenRibbon.h" namespace ndbl{ @@ -36,9 +36,9 @@ namespace ndbl{ class Nodlang { public: - using operators_vec = std::vector; - using invokable_ptr = std::shared_ptr; - using Invokable_vec = std::vector>; + using operators_vec = std::vector; + using invokable_ptr = std::shared_ptr; + using Invokable_vec = std::vector>; explicit Nodlang(bool _strict = false); ~Nodlang(); @@ -105,11 +105,11 @@ namespace ndbl{ }; std::string& serialize_invokable(std::string&_out, const InvokableComponent &_component) const; - std::string& serialize_func_call(std::string& _out, const fw::func_type *_signature, const std::vector &inputs)const; - std::string& serialize_func_sig(std::string& _out, const fw::func_type*)const; + std::string& serialize_func_call(std::string& _out, const tools::func_type *_signature, const std::vector &inputs)const; + std::string& serialize_func_sig(std::string& _out, const tools::func_type*)const; std::string& serialize_token_t(std::string& _out, const Token_t&)const; std::string& serialize_token(std::string& _out, const Token &) const; - std::string& serialize_type(std::string& _out, const fw::type*) const; + std::string& serialize_type(std::string& _out, const tools::type*) const; std::string& serialize_input(std::string& _out, const Slot &_slot, SerializeFlags _flags = SerializeFlag_RECURSE )const; std::string& serialize_output(std::string& _out, const Slot &_slot, SerializeFlags flags = SerializeFlag_RECURSE )const; std::string& serialize_node( std::string &_out, const PoolID &_node, SerializeFlags _flags = SerializeFlag_RECURSE ) const; @@ -117,7 +117,7 @@ namespace ndbl{ std::string& serialize_for_loop(std::string& _out, const ForLoopNode *_for_loop)const; std::string& serialize_while_loop(std::string& _out, const WhileLoopNode *_while_loop_node)const; std::string& serialize_cond_struct(std::string& _out, const IfNode*_condition_struct ) const; - std::string& serialize_variant(std::string& _out, const fw::variant*) const; + std::string& serialize_variant(std::string& _out, const tools::variant*) const; std::string& serialize_variable(std::string& _out, const VariableNode*) const; std::string& serialize_property(std::string &_out, const Property*) const; @@ -125,44 +125,44 @@ namespace ndbl{ public: invokable_ptr find_function( const char* _signature ) const; // Find a function by signature as string (ex: "int multiply(int,int)" ) - invokable_ptr find_function(const fw::func_type*) const; // Find a function by signature (strict first, then cast allowed) - invokable_ptr find_function_exact(const fw::func_type*) const; // Find a function by signature (no cast allowed). - invokable_ptr find_function_fallback(const fw::func_type*) const; // Find a function by signature (casts allowed). - invokable_ptr find_operator_fct(const fw::func_type*) const; // Find an operator's function by signature (strict first, then cast allowed) - invokable_ptr find_operator_fct_exact(const fw::func_type*) const; // Find an operator's function by signature (no cast allowed). - invokable_ptr find_operator_fct_fallback(const fw::func_type*) const; // Find an operator's function by signature (casts allowed). - const fw::Operator* find_operator(const std::string& , fw::Operator_t) const;// Find an operator by symbol and type (unary, binary or ternary). + invokable_ptr find_function(const tools::func_type*) const; // Find a function by signature (strict first, then cast allowed) + invokable_ptr find_function_exact(const tools::func_type*) const; // Find a function by signature (no cast allowed). + invokable_ptr find_function_fallback(const tools::func_type*) const; // Find a function by signature (casts allowed). + invokable_ptr find_operator_fct(const tools::func_type*) const; // Find an operator's function by signature (strict first, then cast allowed) + invokable_ptr find_operator_fct_exact(const tools::func_type*) const; // Find an operator's function by signature (no cast allowed). + invokable_ptr find_operator_fct_fallback(const tools::func_type*) const; // Find an operator's function by signature (casts allowed). + const tools::Operator* find_operator(const std::string& , tools::Operator_t) const;// Find an operator by symbol and type (unary, binary or ternary). const Invokable_vec& get_api()const { return m_functions; } // Get all the functions registered in the language. (TODO: why do we store the declared functions here? can't we load them in the VirtualMachine instead?). - std::string& to_string(std::string& /*out*/, const fw::type*)const; // Convert a type to string (by ref). + std::string& to_string(std::string& /*out*/, const tools::type*)const; // Convert a type to string (by ref). std::string& to_string(std::string& /*out*/, Token_t)const; // Convert a type to a token_t (by ref). - std::string to_string(const fw::type *) const; // Convert a type to string. + std::string to_string(const tools::type *) const; // Convert a type to string. std::string to_string(Token_t)const; // Convert a type to a token_t. - const fw::type* get_type(Token_t _token)const; // Get the type corresponding to a given token_t (must be a type keyword) - void add_function(std::shared_ptr); // Adds a new function (regular or operator's implementation). - int get_precedence(const fw::iinvokable*)const; // Get the precedence of a given function (precedence may vary because function could be an operator implementation). + const tools::type* get_type(Token_t _token)const; // Get the type corresponding to a given token_t (must be a type keyword) + void add_function(std::shared_ptr); // Adds a new function (regular or operator's implementation). + int get_precedence(const tools::iinvokable*)const; // Get the precedence of a given function (precedence may vary because function could be an operator implementation). template void load_library(); // Instantiate a library from its type (uses reflection to get all its static methods). private: - invokable_ptr find_function(fw::hash::hash_t _hash) const; + invokable_ptr find_function( tools::hash::hash_t _hash) const; private: struct { std::vector> keywords; - std::vector> types; - std::vector> operators; + std::vector> types; + std::vector> operators; std::vector> chars; } m_definition; // language definition operators_vec m_operators; // the allowed operators (!= implementations). Invokable_vec m_operators_impl; // operators' implementations. Invokable_vec m_functions; // all the functions (including operator's). - std::unordered_map> m_functions_by_signature; // Functions indexed by signature hash + std::unordered_map> m_functions_by_signature; // Functions indexed by signature hash std::unordered_map m_single_char_by_keyword; std::unordered_map m_keyword_by_token_t; // token_t to string (ex: Token_t::keyword_double => "double"). - std::unordered_map m_keyword_by_type_id; + std::unordered_map m_keyword_by_type_id; std::unordered_map m_token_t_by_single_char; std::unordered_map m_token_t_by_keyword; // keyword reserved by the language (ex: int, string, operator, if, for, etc.) - std::unordered_map m_token_t_by_type_id; - std::unordered_map m_type_by_token_t; // token_t to type. Works only if token_t refers to a type keyword. + std::unordered_map m_token_t_by_type_id; + std::unordered_map m_type_by_token_t; // token_t to type. Works only if token_t refers to a type keyword. }; @@ -171,7 +171,7 @@ namespace ndbl{ { T library; // Libraries are static and this will force static code to run. TODO: add load/release methods - auto type = fw::type::get(); + auto type = tools::type::get(); for(auto& each_static : type->get_static_methods()) { add_function(each_static); diff --git a/src/nodable/core/language/Nodlang.parse_and_eval.specs.cpp b/src/ndbl/core/language/Nodlang.parse_and_eval.specs.cpp similarity index 99% rename from src/nodable/core/language/Nodlang.parse_and_eval.specs.cpp rename to src/ndbl/core/language/Nodlang.parse_and_eval.specs.cpp index 0d98da78d..15da92b24 100644 --- a/src/nodable/core/language/Nodlang.parse_and_eval.specs.cpp +++ b/src/ndbl/core/language/Nodlang.parse_and_eval.specs.cpp @@ -1,9 +1,9 @@ #include "../fixtures/core.h" #include -#include "fw/core/log.h" +#include "tools/core/log.h" using namespace ndbl; -using namespace fw; +using namespace tools; typedef ::testing::Core Parse_and_eval; diff --git a/src/nodable/core/language/Nodlang.parse_function_call.specs.cpp b/src/ndbl/core/language/Nodlang.parse_function_call.specs.cpp similarity index 96% rename from src/nodable/core/language/Nodlang.parse_function_call.specs.cpp rename to src/ndbl/core/language/Nodlang.parse_function_call.specs.cpp index ecd54c52f..bb663b9e2 100644 --- a/src/nodable/core/language/Nodlang.parse_function_call.specs.cpp +++ b/src/ndbl/core/language/Nodlang.parse_function_call.specs.cpp @@ -1,7 +1,7 @@ #include "../fixtures/core.h" #include -#include "fw/core/log.h" -#include "nodable/core/InvokableComponent.h" +#include "tools/core/log.h" +#include "ndbl/core/InvokableComponent.h" using namespace ndbl; diff --git a/src/nodable/core/language/Nodlang.parse_token.specs.cpp b/src/ndbl/core/language/Nodlang.parse_token.specs.cpp similarity index 98% rename from src/nodable/core/language/Nodlang.parse_token.specs.cpp rename to src/ndbl/core/language/Nodlang.parse_token.specs.cpp index caf0fbed4..210e9427d 100644 --- a/src/nodable/core/language/Nodlang.parse_token.specs.cpp +++ b/src/ndbl/core/language/Nodlang.parse_token.specs.cpp @@ -1,6 +1,6 @@ #include "../fixtures/core.h" #include -#include "fw/core/log.h" +#include "tools/core/log.h" using namespace ndbl; diff --git a/src/nodable/core/language/Nodlang.specs.cpp b/src/ndbl/core/language/Nodlang.specs.cpp similarity index 98% rename from src/nodable/core/language/Nodlang.specs.cpp rename to src/ndbl/core/language/Nodlang.specs.cpp index 8d768d054..8164e0549 100644 --- a/src/nodable/core/language/Nodlang.specs.cpp +++ b/src/ndbl/core/language/Nodlang.specs.cpp @@ -1,10 +1,10 @@ #include -#include -#include "../fixtures/core.h" +#include "tools/core/reflection/invokable.h" +#include "ndbl/core/fixtures/core.h" using namespace ndbl; -using namespace fw; +using namespace tools; typedef testing::Core Language; diff --git a/src/nodable/core/language/Nodlang.tokenize.specs.cpp b/src/ndbl/core/language/Nodlang.tokenize.specs.cpp similarity index 98% rename from src/nodable/core/language/Nodlang.tokenize.specs.cpp rename to src/ndbl/core/language/Nodlang.tokenize.specs.cpp index 8979699ec..890a7e01a 100644 --- a/src/nodable/core/language/Nodlang.tokenize.specs.cpp +++ b/src/ndbl/core/language/Nodlang.tokenize.specs.cpp @@ -1,6 +1,6 @@ #include "../fixtures/core.h" #include -#include "fw/core/log.h" +#include "tools/core/log.h" #include using namespace ndbl; diff --git a/src/nodable/core/language/Nodlang_biology.cpp b/src/ndbl/core/language/Nodlang_biology.cpp similarity index 96% rename from src/nodable/core/language/Nodlang_biology.cpp rename to src/ndbl/core/language/Nodlang_biology.cpp index fbca6989a..ee614bbfb 100644 --- a/src/nodable/core/language/Nodlang_biology.cpp +++ b/src/ndbl/core/language/Nodlang_biology.cpp @@ -1,8 +1,8 @@ #include "Nodlang_biology.h" -#include "fw/core/reflection/reflection" +#include "tools/core/reflection/reflection" using namespace ndbl; -using namespace fw; +using namespace tools; namespace // anonymous, only accessible from this file { diff --git a/src/nodable/core/language/Nodlang_biology.h b/src/ndbl/core/language/Nodlang_biology.h similarity index 100% rename from src/nodable/core/language/Nodlang_biology.h rename to src/ndbl/core/language/Nodlang_biology.h diff --git a/src/nodable/core/language/Nodlang_math.cpp b/src/ndbl/core/language/Nodlang_math.cpp similarity index 98% rename from src/nodable/core/language/Nodlang_math.cpp rename to src/ndbl/core/language/Nodlang_math.cpp index 37797caaa..3419bee25 100644 --- a/src/nodable/core/language/Nodlang_math.cpp +++ b/src/ndbl/core/language/Nodlang_math.cpp @@ -3,12 +3,12 @@ #include #include -#include "fw/core/format.h" -#include "fw/core/reflection/registration.h" -#include "fw/core/types.h" +#include "tools/core/format.h" +#include "tools/core/reflection/registration.h" +#include "tools/core/types.h" using namespace ndbl; -using namespace fw; +using namespace tools; namespace // anonymous, accessible only in that file { diff --git a/src/nodable/core/language/Nodlang_math.h b/src/ndbl/core/language/Nodlang_math.h similarity index 100% rename from src/nodable/core/language/Nodlang_math.h rename to src/ndbl/core/language/Nodlang_math.h diff --git a/src/nodable/cli/tests.cpp b/src/ndbl/core/tests.cpp similarity index 70% rename from src/nodable/cli/tests.cpp rename to src/ndbl/core/tests.cpp index daab4900c..79fc57ee0 100644 --- a/src/nodable/cli/tests.cpp +++ b/src/ndbl/core/tests.cpp @@ -1,8 +1,8 @@ #include -#include "fw/core/log.h" -#include +#include "tools/core/log.h" +#include "tools/core/reflection/reflection" -using namespace fw; +using namespace tools; int main(int argc, char **argv) { diff --git a/src/nodable/gui/Action.h b/src/ndbl/gui/Action.h similarity index 83% rename from src/nodable/gui/Action.h rename to src/ndbl/gui/Action.h index 2f155c60c..fa23d028b 100644 --- a/src/nodable/gui/Action.h +++ b/src/ndbl/gui/Action.h @@ -1,14 +1,14 @@ #pragma once -#include "fw/core/reflection/func_type.h" -#include "fw/gui/Action.h" -#include "nodable/core/Graph.h" +#include "tools/core/reflection/func_type.h" +#include "tools/gui/Action.h" +#include "ndbl/core/Graph.h" #include "Event.h" namespace ndbl { - using fw::Action; - using fw::Event; + using tools::Action; + using tools::Event; // Actions specific to Nodable, more actions defined in framework's Action.h diff --git a/src/nodable/gui/Command.h b/src/ndbl/gui/Command.h similarity index 100% rename from src/nodable/gui/Command.h rename to src/ndbl/gui/Command.h diff --git a/src/nodable/gui/Condition.h b/src/ndbl/gui/Condition.h similarity index 100% rename from src/nodable/gui/Condition.h rename to src/ndbl/gui/Condition.h diff --git a/src/nodable/gui/Config.cpp b/src/ndbl/gui/Config.cpp similarity index 87% rename from src/nodable/gui/Config.cpp rename to src/ndbl/gui/Config.cpp index 94012c807..abb9bc387 100644 --- a/src/nodable/gui/Config.cpp +++ b/src/ndbl/gui/Config.cpp @@ -1,8 +1,8 @@ #include "Config.h" #include "build_info.h" -#include "fw/gui/gui.h" +#include "tools/gui/gui.h" -using namespace fw; +using namespace tools; ndbl::Config::Config() { @@ -109,16 +109,16 @@ ndbl::Config::Config() graph_unfold_iterations = 100; // NodableView - fw::g_conf->dockspace_right_ratio = 0.25f; - fw::g_conf->dockspace_top_size = 36.f; - fw::g_conf->dockspace_bottom_size = 100.f; + tools::g_conf->dockspace_right_ratio = 0.25f; + tools::g_conf->dockspace_top_size = 36.f; + tools::g_conf->dockspace_bottom_size = 100.f; const char *k_paragraph = "Paragraph"; const char *k_heading = "Heading 1"; const char *k_code = "Code"; const char *k_tool = "Tool Button"; - fw::g_conf->font_manager.text = { + tools::g_conf->font_manager.text = { // id , font_path , size , icons? , icons size { k_paragraph , "fonts/JetBrainsMono-Regular.ttf" , 16.0f, true , 16.0f }, { k_heading , "fonts/JetBrainsMono-Bold.ttf" , 20.0f, true , 20.0f }, @@ -126,13 +126,13 @@ ndbl::Config::Config() { k_tool , "fonts/JetBrainsMono-Medium.ttf" , 16.0f, true , 16.0f } }; - fw::g_conf->font_manager.defaults[FontSlot_Paragraph] = k_paragraph; - fw::g_conf->font_manager.defaults[FontSlot_Heading] = k_heading; - fw::g_conf->font_manager.defaults[FontSlot_Code] = k_code; - fw::g_conf->font_manager.defaults[FontSlot_ToolBtn] = k_tool; - fw::g_conf->font_manager.subsamples = 1.0f; - fw::g_conf->font_manager.icon = {"Icons", "fonts/fa-solid-900.ttf" }; - fw::g_conf->app_window_label = BuildInfo::version_extended; + tools::g_conf->font_manager.defaults[FontSlot_Paragraph] = k_paragraph; + tools::g_conf->font_manager.defaults[FontSlot_Heading] = k_heading; + tools::g_conf->font_manager.defaults[FontSlot_Code] = k_code; + tools::g_conf->font_manager.defaults[FontSlot_ToolBtn] = k_tool; + tools::g_conf->font_manager.subsamples = 1.0f; + tools::g_conf->font_manager.icon = {"Icons", "fonts/fa-solid-900.ttf" }; + tools::g_conf->app_window_label = BuildInfo::version_extended; } int ndbl::Config::ui_grid_subdiv_size() const diff --git a/src/nodable/gui/Config.h b/src/ndbl/gui/Config.h similarity index 56% rename from src/nodable/gui/Config.h rename to src/ndbl/gui/Config.h index 09bb847ff..a2496ff43 100644 --- a/src/nodable/gui/Config.h +++ b/src/ndbl/gui/Config.h @@ -4,55 +4,58 @@ #include #include -#include "fw/core/reflection/reflection" -#include "fw/core/types.h" -#include "fw/gui/AppView.h" -#include "fw/gui/FontManager.h" -#include "fw/gui/ImGuiEx.h" +#include "tools/core/reflection/reflection" +#include "tools/core/types.h" +#include "tools/gui/AppView.h" +#include "tools/gui/FontManager.h" +#include "tools/gui/ImGuiEx.h" #include "Isolation.h" #include "types.h" namespace ndbl { + using tools::Vec2; + using tools::Vec4; + struct Config { Config(); void reset(); TextEditor::Palette ui_text_textEditorPalette{}; - fw::Vec2 ui_wire_bezier_roundness; // {min, max} + Vec2 ui_wire_bezier_roundness; // {min, max} float ui_wire_bezier_thickness; - fw::Vec2 ui_wire_bezier_fade_length_minmax; - fw::Vec4 ui_wire_color; - fw::Vec4 ui_wire_shadowColor; + Vec2 ui_wire_bezier_fade_length_minmax; + Vec4 ui_wire_color; + Vec4 ui_wire_shadowColor; float ui_slot_radius; - fw::Vec4 ui_slot_border_color; - fw::Vec4 ui_slot_color; - fw::Vec4 ui_slot_hovered_color; - fw::Vec2 ui_slot_size; + Vec4 ui_slot_border_color; + Vec4 ui_slot_color; + Vec4 ui_slot_hovered_color; + Vec2 ui_slot_size; float ui_slot_gap; float ui_slot_border_radius; float ui_slot_invisible_ratio; float ui_node_spacing; - fw::Vec4 ui_node_padding; // left, top, right, bottom + Vec4 ui_node_padding; // left, top, right, bottom float ui_node_borderWidth; float ui_node_instructionBorderRatio; // ratio to apply to borderWidth - fw::Vec4 ui_node_variableColor; - fw::Vec4 ui_node_invokableColor; - fw::Vec4 ui_node_instructionColor; - fw::Vec4 ui_node_literalColor; - fw::Vec4 ui_node_condStructColor; - fw::Vec4 ui_node_shadowColor; - fw::Vec4 ui_node_borderColor; - fw::Vec4 ui_node_borderHighlightedColor; - fw::Vec4 ui_node_highlightedColor; - fw::Vec4 ui_node_fillColor; + Vec4 ui_node_variableColor; + Vec4 ui_node_invokableColor; + Vec4 ui_node_instructionColor; + Vec4 ui_node_literalColor; + Vec4 ui_node_condStructColor; + Vec4 ui_node_shadowColor; + Vec4 ui_node_borderColor; + Vec4 ui_node_borderHighlightedColor; + Vec4 ui_node_highlightedColor; + Vec4 ui_node_fillColor; float ui_node_speed; u8_t ui_node_animation_subsample_count; - fw::Vec4 ui_codeflow_color; - fw::Vec4 ui_codeflow_shadowColor; + Vec4 ui_codeflow_color; + Vec4 ui_codeflow_shadowColor; float ui_codeflow_thickness_ratio; - fw::Vec2 ui_toolButton_size; + Vec2 ui_toolButton_size; u64_t ui_history_size_max{}; float ui_history_btn_spacing; float ui_history_btn_height; @@ -60,11 +63,11 @@ namespace ndbl const char* ui_splashscreen_imagePath; float ui_overlay_margin; float ui_overlay_indent; - fw::Vec4 ui_overlay_window_bg_golor; - fw::Vec4 ui_overlay_border_color; - fw::Vec4 ui_overlay_text_color; - fw::Vec4 ui_graph_grid_color_major; - fw::Vec4 ui_graph_grid_color_minor; + Vec4 ui_overlay_window_bg_golor; + Vec4 ui_overlay_border_color; + Vec4 ui_overlay_text_color; + Vec4 ui_graph_grid_color_major; + Vec4 ui_graph_grid_color_minor; i32_t ui_grid_subdiv_count; i32_t ui_grid_size; const char* ui_file_info_window_label; diff --git a/src/nodable/gui/Event.h b/src/ndbl/gui/Event.h similarity index 54% rename from src/nodable/gui/Event.h rename to src/ndbl/gui/Event.h index 6c7eb22e0..cfe74354b 100644 --- a/src/nodable/gui/Event.h +++ b/src/ndbl/gui/Event.h @@ -1,11 +1,11 @@ #pragma once #include -#include "fw/core/memory/Pool.h" -#include "fw/gui/EventManager.h" +#include "tools/core/memory/Pool.h" +#include "tools/gui/EventManager.h" -#include "nodable/core/Graph.h" -#include "nodable/core/SlotRef.h" +#include "ndbl/core/Graph.h" +#include "ndbl/core/SlotRef.h" #include "Event.h" #include "FrameMode.h" @@ -15,11 +15,13 @@ namespace ndbl { // forward declaration class NodeView; - using fw::PoolID; + using tools::PoolID; + using tools::Vec2; + using tools::func_type; - enum EventID_ : fw::EventID + enum EventID_ : tools::EventID { - EventID_DELETE_NODE = fw::EventID_USER_DEFINED, // operation on nodes + EventID_DELETE_NODE = tools::EventID_USER_DEFINED, // operation on nodes EventID_ARRANGE_NODE, EventID_SELECT_NEXT, EventID_TOGGLE_FOLDING, @@ -33,8 +35,8 @@ namespace ndbl EventID_SELECTION_CHANGE, }; - using Event_ToggleIsolationFlags = fw::Event; - using Event_MoveSelection = fw::Event; + using Event_ToggleIsolationFlags = tools::Event; + using Event_MoveSelection = tools::Event; class GraphView; struct EventPayload_FrameNodeViews @@ -44,7 +46,7 @@ namespace ndbl : mode(mode) {} }; - using Event_FrameSelection = fw::Event; + using Event_FrameSelection = tools::Event; struct EventPayload_SlotPair { SlotRef first; @@ -54,16 +56,16 @@ namespace ndbl , second(second) {} }; - using Event_SlotDisconnected = fw::Event; - using Event_SlotDropped = fw::Event; + using Event_SlotDisconnected = tools::Event; + using Event_SlotDropped = tools::Event; struct EventPayload_Node { PoolID node; }; - using Event_DeleteNode = fw::Event; - using Event_ArrangeNode = fw::Event; - using Event_SelectNext = fw::Event; + using Event_DeleteNode = tools::Event; + using Event_ArrangeNode = tools::Event; + using Event_SelectNext = tools::Event; enum ToggleFoldingMode { @@ -74,33 +76,33 @@ namespace ndbl { ToggleFoldingMode mode; }; - using Event_ToggleFolding = fw::Event; + using Event_ToggleFolding = tools::Event; struct EventPayload_NodeViewSelectionChange { PoolID new_selection; PoolID old_selection; }; - using Event_SelectionChange = fw::Event; + using Event_SelectionChange = tools::Event; struct EventPayload_CreateNode { NodeType node_type; // The note type to create - const fw::func_type* node_signature; // The signature of the node that must be created + const func_type* node_signature; // The signature of the node that must be created SlotView* dragged_slot = nullptr; // The slot view being dragged. Graph* graph = nullptr; // The graph to create the node into - fw::Vec2 node_view_local_pos; // The desired position for the new node view + Vec2 node_view_local_pos; // The desired position for the new node view explicit EventPayload_CreateNode(NodeType node_type ) : node_type(node_type) , node_signature(nullptr) {} - EventPayload_CreateNode(NodeType node_type, const fw::func_type* signature ) + EventPayload_CreateNode(NodeType node_type, const tools::func_type* signature ) : node_type(node_type) , node_signature(signature) {} }; - using Event_CreateNode = fw::Event; + using Event_CreateNode = tools::Event; }// namespace ndbl diff --git a/src/nodable/gui/File.cpp b/src/ndbl/gui/File.cpp similarity index 96% rename from src/nodable/gui/File.cpp rename to src/ndbl/gui/File.cpp index a1c27b106..7effc7263 100644 --- a/src/nodable/gui/File.cpp +++ b/src/ndbl/gui/File.cpp @@ -3,9 +3,9 @@ #include #include -#include "nodable/core/NodeUtils.h" -#include "nodable/core/InvokableComponent.h" -#include "nodable/core/LiteralNode.h" +#include "ndbl/core/NodeUtils.h" +#include "ndbl/core/InvokableComponent.h" +#include "ndbl/core/LiteralNode.h" #include "GraphView.h" #include "History.h" #include "Nodable.h" @@ -13,7 +13,7 @@ #include "Physics.h" using namespace ndbl; -using namespace fw; +using namespace tools; File::File() : path() @@ -103,7 +103,7 @@ UpdateResult File::update( Isolation flags ) { // TODO: The case where both focused_text and graph changed is not handled yet // This is not supposed to happens, that's why there is an assert to be aware of is - FW_ASSERT(false); + ASSERT(false); } view.set_dirty( false ); } diff --git a/src/nodable/gui/File.h b/src/ndbl/gui/File.h similarity index 88% rename from src/nodable/gui/File.h rename to src/ndbl/gui/File.h index 7ec03c846..34fe459c5 100644 --- a/src/nodable/gui/File.h +++ b/src/ndbl/gui/File.h @@ -6,15 +6,15 @@ #include #include -#include "fw/core/reflection/reflection" -#include "fw/core/log.h" +#include "tools/core/reflection/reflection" +#include "tools/core/log.h" #include "Isolation.h" -#include "nodable/core/NodeFactory.h" -#include "nodable/gui/FileView.h" -#include "nodable/gui/History.h" -#include "nodable/gui/Nodable.h" -#include "nodable/gui/types.h" +#include "ndbl/core/NodeFactory.h" +#include "ndbl/gui/FileView.h" +#include "ndbl/gui/History.h" +#include "ndbl/gui/Nodable.h" +#include "ndbl/gui/types.h" namespace ndbl { diff --git a/src/nodable/gui/FileView.cpp b/src/ndbl/gui/FileView.cpp similarity index 98% rename from src/nodable/gui/FileView.cpp rename to src/ndbl/gui/FileView.cpp index 36bb19ef0..8806c3b33 100644 --- a/src/nodable/gui/FileView.cpp +++ b/src/ndbl/gui/FileView.cpp @@ -1,10 +1,10 @@ #include "FileView.h" -#include "nodable/core/Graph.h" -#include "nodable/core/Node.h" -#include "nodable/core/VirtualMachine.h" -#include "nodable/core/language/Nodlang.h" -#include "nodable/core/NodeUtils.h" +#include "ndbl/core/Graph.h" +#include "ndbl/core/Node.h" +#include "ndbl/core/VirtualMachine.h" +#include "ndbl/core/language/Nodlang.h" +#include "ndbl/core/NodeUtils.h" #include "Config.h" @@ -17,7 +17,7 @@ #include "gui.h" using namespace ndbl; -using namespace fw; +using namespace tools; FileView::FileView() : View() @@ -168,7 +168,7 @@ bool FileView::onDraw() Graph* graph = m_file->graph; GraphView* graph_view = m_file->graph_view; - FW_ASSERT(graph); + ASSERT(graph); ImGui::SameLine(); if ( graph_view ) diff --git a/src/nodable/gui/FileView.h b/src/ndbl/gui/FileView.h similarity index 93% rename from src/nodable/gui/FileView.h rename to src/ndbl/gui/FileView.h index f37819e8c..9c2785aaf 100644 --- a/src/nodable/gui/FileView.h +++ b/src/ndbl/gui/FileView.h @@ -2,8 +2,8 @@ #include -#include "fw/core/reflection/reflection" -#include "fw/gui/View.h" +#include "tools/core/reflection/reflection" +#include "tools/gui/View.h" #include "Condition.h" #include "Isolation.h" @@ -36,7 +36,7 @@ namespace ndbl OverlayPos position; } OverlayData; - class FileView : public fw::View + class FileView : public tools::View { public: explicit FileView(); @@ -61,7 +61,7 @@ namespace ndbl void clear_overlay(); void push_overlay(OverlayData, OverlayType) ; void refresh_overlay(Condition condition); - void draw_overlay(const char* title, const std::vector& overlay_data, fw::Rect rect, fw::Vec2 position); + void draw_overlay(const char* title, const std::vector& overlay_data, tools::Rect rect, tools::Vec2 position); size_t size() const; private: diff --git a/src/nodable/gui/FrameMode.h b/src/ndbl/gui/FrameMode.h similarity index 100% rename from src/nodable/gui/FrameMode.h rename to src/ndbl/gui/FrameMode.h diff --git a/src/nodable/gui/GraphView.cpp b/src/ndbl/gui/GraphView.cpp similarity index 97% rename from src/nodable/gui/GraphView.cpp rename to src/ndbl/gui/GraphView.cpp index 30c3704af..0649a7520 100644 --- a/src/nodable/gui/GraphView.cpp +++ b/src/ndbl/gui/GraphView.cpp @@ -4,21 +4,21 @@ #include // std::shared_ptr #include #include -#include "fw/core/types.h" -#include "fw/core/log.h" -#include "fw/core/system.h" -#include "fw/gui/ImGuiEx.h" -#include "fw/core/math.h" - -#include "nodable/core/ForLoopNode.h" -#include "nodable/core/Graph.h" -#include "nodable/core/IfNode.h" -#include "nodable/core/LiteralNode.h" -#include "nodable/core/NodeUtils.h" -#include "nodable/core/Scope.h" -#include "nodable/core/Slot.h" -#include "nodable/core/VariableNode.h" -#include "nodable/core/language/Nodlang.h" +#include "tools/core/types.h" +#include "tools/core/log.h" +#include "tools/core/system.h" +#include "tools/gui/ImGuiEx.h" +#include "tools/core/math.h" + +#include "ndbl/core/ForLoopNode.h" +#include "ndbl/core/Graph.h" +#include "ndbl/core/IfNode.h" +#include "ndbl/core/LiteralNode.h" +#include "ndbl/core/NodeUtils.h" +#include "ndbl/core/Scope.h" +#include "ndbl/core/Slot.h" +#include "ndbl/core/VariableNode.h" +#include "ndbl/core/language/Nodlang.h" #include "Action.h" #include "Condition.h" @@ -30,12 +30,12 @@ #include "Physics.h" #include "PropertyView.h" #include "SlotView.h" -#include "fw/core/Color.h" +#include "tools/core/Color.h" #include "gui.h" using namespace ndbl; using namespace ndbl::assembly; -using namespace fw; +using namespace tools; const char* k_context_menu_popup = "GraphView.CreateNodeContextMenu"; diff --git a/src/nodable/gui/GraphView.h b/src/ndbl/gui/GraphView.h similarity index 72% rename from src/nodable/gui/GraphView.h rename to src/ndbl/gui/GraphView.h index b2686b5f1..6758eea2e 100644 --- a/src/nodable/gui/GraphView.h +++ b/src/ndbl/gui/GraphView.h @@ -4,12 +4,12 @@ #include #include -#include "fw/gui/View.h" // base class -#include "fw/core/reflection/reflection" +#include "tools/gui/View.h" // base class +#include "tools/core/reflection/reflection" -#include "nodable/core/Component.h" // base class -#include "nodable/core/IScope.h" -#include "nodable/core/Scope.h" +#include "ndbl/core/Component.h" // base class +#include "ndbl/core/IScope.h" +#include "ndbl/core/Scope.h" #include "Action.h" @@ -23,14 +23,15 @@ namespace ndbl // forward declarations class Nodable; class Graph; + using tools::Vec2; struct CreateNodeContextMenu { - bool must_be_reset_flag = false; - fw::Vec2 opened_at_pos = fw::Vec2(-1,-1); // relative - fw::Vec2 opened_at_screen_pos = fw::Vec2(-1,-1); // absolute (screen space) - SlotView* dragged_slot = nullptr; // The slot being dragged when the context menu opened. - char search_input[255] = "\0"; // The search input entered by the user. + bool must_be_reset_flag = false; + Vec2 opened_at_pos {-1,-1}; // relative + Vec2 opened_at_screen_pos {-1,-1}; // absolute (screen space) + SlotView* dragged_slot = nullptr; // The slot being dragged when the context menu opened. + char search_input[255] = "\0"; // The search input entered by the user. std::vector items; // All the available items std::vector items_with_compatible_signature; // Only the items having a compatible signature (with the slot dragged) std::vector items_matching_search; // Only the items having a compatible signature AND matching the search_input. @@ -41,7 +42,7 @@ namespace ndbl void update_cache_based_on_user_input( size_t _limit ); }; - class GraphView: public fw::View + class GraphView: public tools::View { public: GraphView(Graph* graph); @@ -53,7 +54,7 @@ namespace ndbl bool update(float /* delta_time */, i16_t /* subsample_count */); void frame_all_node_views(); void frame_selected_node_views(); - void translate_all(const std::vector&, fw::Vec2 delta, NodeViewFlags); + void translate_all(const std::vector&, Vec2 delta, NodeViewFlags); void unfold(); // unfold the graph until it is stabilized void add_action_to_context_menu( Action_CreateNode* _action); void frame( FrameMode mode ); @@ -61,7 +62,7 @@ namespace ndbl private: void draw_grid( ImDrawList* ) const; void frame_views(const std::vector &_views, bool _align_top_left_corner); - void pan(fw::Vec2); // translate content + void pan(Vec2); // translate content Graph* m_graph; CreateNodeContextMenu m_create_node_context_menu; diff --git a/src/nodable/gui/History.cpp b/src/ndbl/gui/History.cpp similarity index 100% rename from src/nodable/gui/History.cpp rename to src/ndbl/gui/History.cpp diff --git a/src/nodable/gui/History.h b/src/ndbl/gui/History.h similarity index 90% rename from src/nodable/gui/History.h rename to src/ndbl/gui/History.h index efd746577..4750d34b7 100644 --- a/src/nodable/gui/History.h +++ b/src/ndbl/gui/History.h @@ -4,17 +4,17 @@ #include #include #include -#include "fw/gui/ImGuiEx.h" -#include "fw/core/log.h" -#include "fw/core/reflection/reflection" +#include "tools/gui/ImGuiEx.h" +#include "tools/core/log.h" +#include "tools/core/reflection/reflection" -#include "nodable/core/Component.h" -#include "nodable/core/Graph.h" -#include "nodable/core/Property.h" +#include "ndbl/core/Component.h" +#include "ndbl/core/Graph.h" +#include "ndbl/core/Property.h" -#include "nodable/gui/Command.h" -#include "nodable/gui/types.h" +#include "ndbl/gui/Command.h" +#include "ndbl/gui/types.h" namespace ndbl { diff --git a/src/nodable/gui/Isolation.h b/src/ndbl/gui/Isolation.h similarity index 100% rename from src/nodable/gui/Isolation.h rename to src/ndbl/gui/Isolation.h diff --git a/src/nodable/gui/Nodable.cpp b/src/ndbl/gui/Nodable.cpp similarity index 95% rename from src/nodable/gui/Nodable.cpp rename to src/ndbl/gui/Nodable.cpp index ee2738074..69555f007 100644 --- a/src/nodable/gui/Nodable.cpp +++ b/src/ndbl/gui/Nodable.cpp @@ -2,15 +2,15 @@ #include -#include "fw/core/assertions.h" -#include "fw/core/system.h" -#include "fw/gui/EventManager.h" -#include "nodable/core/DataAccess.h" -#include "nodable/core/InvokableComponent.h" -#include "nodable/core/LiteralNode.h" -#include "nodable/core/NodeUtils.h" -#include "nodable/core/Slot.h" -#include "nodable/core/VariableNode.h" +#include "tools/core/assertions.h" +#include "tools/core/system.h" +#include "tools/gui/EventManager.h" +#include "ndbl/core/DataAccess.h" +#include "ndbl/core/InvokableComponent.h" +#include "ndbl/core/LiteralNode.h" +#include "ndbl/core/NodeUtils.h" +#include "ndbl/core/Slot.h" +#include "ndbl/core/VariableNode.h" #include "commands/Cmd_ConnectEdge.h" #include "commands/Cmd_DisconnectEdge.h" @@ -27,12 +27,12 @@ #include "NodeView.h" #include "Physics.h" #include "SlotView.h" -#include "fw/gui/Config.h" -#include "fw/gui/gui.h" +#include "tools/gui/Config.h" +#include "tools/gui/gui.h" #include "gui.h" using namespace ndbl; -using namespace fw; +using namespace tools; Nodable *Nodable::s_instance = nullptr; @@ -55,7 +55,7 @@ Nodable::Nodable() type_register::log_statistics(); // set this instance as s_instance to access it via App::get_instance() - FW_EXPECT(s_instance == nullptr, "Can't create two concurrent App. Delete first instance."); + EXPECT(s_instance == nullptr, "Can't create two concurrent App. Delete first instance."); s_instance = this; LOG_VERBOSE("ndbl::App", "Constructor " OK "\n"); @@ -70,7 +70,7 @@ Nodable::~Nodable() void Nodable::before_init() { - ndbl::init(); + ndbl::gui_init(); } bool Nodable::on_init() @@ -289,7 +289,7 @@ void Nodable::on_update() auto _event = reinterpret_cast(event); if ( _event->data.window_id == "splashscreen" ) { - fw::g_conf->splashscreen = _event->data.visible; + tools::g_conf->splashscreen = _event->data.visible; } break; } @@ -297,7 +297,7 @@ void Nodable::on_update() case Event_FrameSelection::id: { auto _event = reinterpret_cast( event ); - FW_EXPECT(graph_view, "a graph_view is required"); + EXPECT(graph_view, "a graph_view is required"); graph_view->frame(_event->data.mode); break; } @@ -496,7 +496,7 @@ bool Nodable::on_shutdown() } LOG_VERBOSE("ndbl::App", "on_shutdown " OK "\n"); - ndbl::shutdown(); + ndbl::gui_shutdown(); return true; } @@ -524,7 +524,7 @@ File* Nodable::open_file(const std::filesystem::path& _path) File*Nodable::add_file( File* _file) { - FW_EXPECT(_file, "File is nullptr"); + EXPECT(_file, "File is nullptr"); m_loaded_files.push_back( _file ); current_file = _file; event_manager.dispatch( EventID_FILE_OPENED ); @@ -533,7 +533,7 @@ File*Nodable::add_file( File* _file) void Nodable::save_file( File* _file) const { - FW_EXPECT(_file,"file must be defined"); + EXPECT(_file,"file must be defined"); if ( !File::write(*_file, _file->path) ) { @@ -556,9 +556,9 @@ void Nodable::save_file_as(const std::filesystem::path& _path) const void Nodable::close_file( File* _file) { // Find and delete the file - FW_EXPECT(_file, "Cannot close a nullptr File!"); + EXPECT(_file, "Cannot close a nullptr File!"); auto it = std::find(m_loaded_files.begin(), m_loaded_files.end(), _file); - FW_EXPECT(it != m_loaded_files.end(), "Unable to find the file in the loaded_files"); + EXPECT(it != m_loaded_files.end(), "Unable to find the file in the loaded_files"); it = m_loaded_files.erase(it); delete _file; @@ -657,6 +657,6 @@ File*Nodable::new_file() Nodable &Nodable::get_instance() { - FW_EXPECT(s_instance, "No App instance available. Did you forget App app(...) or App* app = new App(...)"); + EXPECT(s_instance, "No App instance available. Did you forget App app(...) or App* app = new App(...)"); return *s_instance; } \ No newline at end of file diff --git a/src/nodable/gui/Nodable.h b/src/ndbl/gui/Nodable.h similarity index 86% rename from src/nodable/gui/Nodable.h rename to src/ndbl/gui/Nodable.h index 82fd52c44..e69b65136 100644 --- a/src/nodable/gui/Nodable.h +++ b/src/ndbl/gui/Nodable.h @@ -4,12 +4,12 @@ #include #include -#include "fw/core/reflection/reflection" -#include "fw/gui/App.h" +#include "tools/core/reflection/reflection" +#include "tools/gui/App.h" -#include "nodable/core/VirtualMachine.h" -#include "nodable/core/NodeFactory.h" -#include "nodable/core/language/Nodlang.h" +#include "ndbl/core/VirtualMachine.h" +#include "ndbl/core/NodeFactory.h" +#include "ndbl/core/language/Nodlang.h" #include "NodableView.h" #include "types.h" @@ -23,8 +23,8 @@ namespace ndbl // - Only a single instance can exist at the same time // - Instantiate it as you want (stack or heap) // - The instance will be available statically via: App* App::get_instance() - // - Is based on fw::App, but extends it using composition instead of inheritance - class Nodable : public fw::App + // - Is based on tools::App, but extends it using composition instead of inheritance + class Nodable : public tools::App { public: Nodable(); diff --git a/src/nodable/gui/Nodable.specs.cpp b/src/ndbl/gui/Nodable.specs.cpp similarity index 98% rename from src/nodable/gui/Nodable.specs.cpp rename to src/ndbl/gui/Nodable.specs.cpp index 2a2d5b505..1f35264d4 100644 --- a/src/nodable/gui/Nodable.specs.cpp +++ b/src/ndbl/gui/Nodable.specs.cpp @@ -1,8 +1,8 @@ #include "Config.h" #include "fixtures/gui.h" -#include "fw/gui/Config.h" -#include "fw/gui/gui.h" +#include "tools/gui/Config.h" +#include "tools/gui/gui.h" typedef ::testing::Gui Gui_App; using namespace ndbl; diff --git a/src/nodable/gui/NodableView.cpp b/src/ndbl/gui/NodableView.cpp similarity index 96% rename from src/nodable/gui/NodableView.cpp rename to src/ndbl/gui/NodableView.cpp index dda005b98..ea503e1cb 100644 --- a/src/nodable/gui/NodableView.cpp +++ b/src/ndbl/gui/NodableView.cpp @@ -2,11 +2,11 @@ #include -#include "fw/core/log.h" -#include "fw/core/system.h" -#include "fw/gui/Texture.h" -#include "fw/gui/ActionManagerView.h" -#include "nodable/core/NodeUtils.h" +#include "tools/core/log.h" +#include "tools/core/system.h" +#include "tools/gui/Texture.h" +#include "tools/gui/ActionManagerView.h" +#include "ndbl/core/NodeUtils.h" #include "Config.h" @@ -19,13 +19,13 @@ #include "Physics.h" #include "PropertyView.h" #include "build_info.h" -#include "fw/gui/Config.h" -#include "fw/gui/gui.h" +#include "tools/gui/Config.h" +#include "tools/gui/gui.h" #include "gui.h" using namespace ndbl; using namespace ndbl::assembly; -using namespace fw; +using namespace tools; NodableView::NodableView(Nodable * _app) : AppView(_app) @@ -37,7 +37,7 @@ NodableView::NodableView(Nodable * _app) , m_scroll_to_curr_instr(true) , m_app(_app) { - FW_EXPECT(m_app, "should be defined"); + EXPECT(m_app, "should be defined"); } NodableView::~NodableView() @@ -185,18 +185,18 @@ void NodableView::on_draw() if (ImGui::BeginMenu("Developer")) { - if ( ImGui::MenuItem("Show debug info", "", fw::g_conf->debug ) ) + if ( ImGui::MenuItem("Show debug info", "", tools::g_conf->debug ) ) { - fw::g_conf->debug = !fw::g_conf->debug; - ImGuiEx::debug = fw::g_conf->debug; + tools::g_conf->debug = !tools::g_conf->debug; + ImGuiEx::debug = tools::g_conf->debug; } - if ( ImGui::MenuItem("Show FPS", "", fw::g_conf->show_fps ) ) + if ( ImGui::MenuItem("Show FPS", "", tools::g_conf->show_fps ) ) { - fw::g_conf->show_fps = !fw::g_conf->show_fps; + tools::g_conf->show_fps = !tools::g_conf->show_fps; } - if ( ImGui::MenuItem("Limit FPS", "", fw::g_conf->delta_time_limit ) ) + if ( ImGui::MenuItem("Limit FPS", "", tools::g_conf->delta_time_limit ) ) { - fw::g_conf->delta_time_limit = !fw::g_conf->delta_time_limit; + tools::g_conf->delta_time_limit = !tools::g_conf->delta_time_limit; } ImGui::Separator(); @@ -240,7 +240,7 @@ void NodableView::on_draw() if (ImGui::BeginMenu("Help")) { if (ImGui::MenuItem("Show Splash Screen", "F1")) { - fw::g_conf->splashscreen = true; + tools::g_conf->splashscreen = true; } if (ImGui::MenuItem("Browse source code")) { @@ -264,7 +264,7 @@ void NodableView::on_draw() if(!m_app->has_files()) { - if( !fw::g_conf->splashscreen ) + if( !tools::g_conf->splashscreen ) { draw_startup_window( get_dockspace(AppView::Dockspace_ROOT)); } @@ -327,7 +327,7 @@ void NodableView::draw_help_window() const { void NodableView::draw_imgui_config_window() const { - if( !fw::g_conf->debug ) + if( !tools::g_conf->debug ) { return; } @@ -681,7 +681,7 @@ void NodableView::draw_config_window() { ActionManagerView::draw(&m_app->action_manager); } - if ( fw::g_conf->debug && ImGui::CollapsingHeader("Pool")) + if ( tools::g_conf->debug && ImGui::CollapsingHeader("Pool")) { ImGui::Text("Pool stats:"); auto pool = Pool::get_pool(); @@ -724,7 +724,7 @@ void NodableView::draw_splashscreen() // close on left/rightmouse btn click if (ImGui::IsMouseClicked(0) || ImGui::IsMouseClicked(1)) { - fw::g_conf->splashscreen = false; + tools::g_conf->splashscreen = false; } ImGui::PopStyleVar(); // ImGuiStyleVar_FramePadding AppView::end_splashscreen(); @@ -803,7 +803,7 @@ void NodableView::draw_toolbar_window() { bool running = vm.is_program_running(); bool debugging = vm.is_debugging(); bool stopped = vm.is_program_stopped(); - auto button_size = g_conf->ui_toolButton_size; + auto button_size = g_conf->ui_toolButton_size; ImGui::PushFont(m_app->font_manager.get_font(FontSlot_ToolBtn)); ImGui::BeginGroup(); @@ -815,7 +815,7 @@ void NodableView::draw_toolbar_window() { ImGui::SameLine(); // run - if (running) ImGui::PushStyleColor(ImGuiCol_Button, fw::g_conf->button_activeColor); + if (running) ImGui::PushStyleColor(ImGuiCol_Button, tools::g_conf->button_activeColor); if (ImGui::Button(ICON_FA_PLAY " run", button_size) && stopped) { m_app->run_program(); @@ -825,7 +825,7 @@ void NodableView::draw_toolbar_window() { ImGui::SameLine(); // debug - if (debugging) ImGui::PushStyleColor(ImGuiCol_Button, fw::g_conf->button_activeColor); + if (debugging) ImGui::PushStyleColor(ImGuiCol_Button, tools::g_conf->button_activeColor); if (ImGui::Button(ICON_FA_BUG " debug", button_size) && stopped) { m_app->debug_program(); } diff --git a/src/nodable/gui/NodableView.h b/src/ndbl/gui/NodableView.h similarity index 87% rename from src/nodable/gui/NodableView.h rename to src/ndbl/gui/NodableView.h index d9e865a33..e219e05a4 100644 --- a/src/nodable/gui/NodableView.h +++ b/src/ndbl/gui/NodableView.h @@ -4,9 +4,9 @@ #include #include -#include "fw/core/reflection/reflection" -#include "fw/core/types.h" -#include "fw/gui/AppView.h" +#include "tools/core/reflection/reflection" +#include "tools/core/types.h" +#include "tools/gui/AppView.h" namespace ndbl { @@ -19,7 +19,7 @@ namespace ndbl /* This class contain the basic setup for and OpenGL/SDL basic window. */ - class NodableView : public fw::AppView + class NodableView : public tools::AppView { public: NodableView(Nodable*); @@ -47,7 +47,7 @@ namespace ndbl void draw_toolbar_window(); void draw_virtual_machine_window(); - fw::Texture* m_logo; + tools::Texture* m_logo; bool m_is_history_dragged; bool m_show_properties_editor; bool m_show_imgui_demo; diff --git a/src/nodable/gui/NodeView.cpp b/src/ndbl/gui/NodeView.cpp similarity index 99% rename from src/nodable/gui/NodeView.cpp rename to src/ndbl/gui/NodeView.cpp index 94d21ccfd..ed004bf19 100644 --- a/src/nodable/gui/NodeView.cpp +++ b/src/ndbl/gui/NodeView.cpp @@ -4,10 +4,10 @@ #include // for sinus #include -#include "fw/core/math.h" -#include "nodable/core/GraphUtil.h" -#include "nodable/core/InvokableComponent.h" -#include "nodable/core/LiteralNode.h" +#include "tools/core/math.h" +#include "ndbl/core/GraphUtil.h" +#include "ndbl/core/InvokableComponent.h" +#include "ndbl/core/LiteralNode.h" #include "Config.h" @@ -17,12 +17,12 @@ #include "Physics.h" #include "PropertyView.h" #include "SlotView.h" -#include "fw/gui/Config.h" -#include "fw/gui/gui.h" +#include "tools/gui/Config.h" +#include "tools/gui/gui.h" #include "gui.h" using namespace ndbl; -using namespace fw; +using namespace tools; REGISTER { @@ -124,7 +124,7 @@ void NodeView::set_owner(PoolID node) case SlotFlag_CHILD: case SlotFlag_PARENT: break; // won't be displayed, let's keep default alignment (0,0) default: - FW_EXPECT(false, "unhandled slot flags") + EXPECT(false, "unhandled slot flags") } m_slot_views.emplace_back( slot, alignment ); @@ -254,7 +254,7 @@ bool NodeView::onDraw() Node* node = m_owner.get(); ImDrawList* draw_list = ImGui::GetWindowDrawList(); - FW_ASSERT(node != nullptr); + ASSERT(node != nullptr); // Draw Node slots (in background) bool is_slot_hovered = false; @@ -739,7 +739,7 @@ void NodeView::draw_as_properties_panel(NodeView *_view, bool *_show_advanced) } ImGui::Unindent(); - if ( fw::g_conf->debug ) + if ( tools::g_conf->debug ) { ImGui::Text("Debug info:" ); // Draw exposed output properties diff --git a/src/nodable/gui/NodeView.h b/src/ndbl/gui/NodeView.h similarity index 72% rename from src/nodable/gui/NodeView.h rename to src/ndbl/gui/NodeView.h index 4c02e899d..9d160d07d 100644 --- a/src/nodable/gui/NodeView.h +++ b/src/ndbl/gui/NodeView.h @@ -9,11 +9,11 @@ #include "PropertyView.h" #include "SlotView.h" -#include "nodable/core/Component.h"// base class -#include "nodable/core/Property.h" -#include "fw/core/geometry/Box2D.h" -#include "fw/gui/ImGuiEx.h" -#include "fw/gui/View.h" +#include "ndbl/core/Component.h"// base class +#include "ndbl/core/Property.h" +#include "tools/core/geometry/Box2D.h" +#include "tools/gui/ImGuiEx.h" +#include "tools/gui/View.h" #include "types.h" namespace ndbl @@ -58,7 +58,7 @@ namespace ndbl /** * This class implement a view for Nodes using ImGui. */ - class NodeView : public Component, public fw::View + class NodeView : public Component, public tools::View { public: NodeView(); @@ -72,12 +72,12 @@ namespace ndbl bool onDraw()override; void set_owner(PoolID)override; bool update(float); - void translate(fw::Vec2, NodeViewFlags flags ); + void translate( tools::Vec2, NodeViewFlags flags ); void arrange_recursively(bool _smoothly = true); std::string get_label(); - fw::Rect get_rect(fw::Space, NodeViewFlags = NodeViewFlag_IGNORE_PINNED | NodeViewFlag_IGNORE_MULTICONSTRAINED) const; + tools::Rect get_rect( tools::Space, NodeViewFlags = NodeViewFlag_IGNORE_PINNED | NodeViewFlag_IGNORE_MULTICONSTRAINED) const; const PropertyView* get_property_view( ID _id )const; - inline fw::Vec2 get_size() const { return box.size(); } + inline tools::Vec2 get_size() const { return box.size(); } bool is_dragged()const; bool is_expanded()const { return m_expanded; } void set_expanded_rec(bool _expanded); @@ -87,15 +87,15 @@ namespace ndbl void expand_toggle(); void expand_toggle_rec(); void enable_edition(bool _enable = true) { m_edition_enable = _enable; } - static fw::Rect get_rect(const std::vector &_views, fw::Space, NodeViewFlags = NodeViewFlag_NONE ); - static std::vector get_rects( const std::vector& _in_views, fw::Space space, NodeViewFlags flags = NodeViewFlag_NONE ); + static tools::Rect get_rect(const std::vector &_views, tools::Space, NodeViewFlags = NodeViewFlag_NONE ); + static std::vector get_rects( const std::vector& _in_views, tools::Space space, NodeViewFlags flags = NodeViewFlag_NONE ); static void set_selected(PoolID); static PoolID get_selected(); static bool is_selected(PoolID); static bool is_any_dragged(); static bool is_any_selected(); - static bool is_inside(NodeView*, fw::Rect, fw::Space); - static void constraint_to_rect(NodeView*, fw::Rect ); + static bool is_inside(NodeView*, tools::Rect, tools::Space); + static void constraint_to_rect(NodeView*, tools::Rect ); static PoolID get_dragged(); static bool draw_property_view(PropertyView*, const char* _override_label); static void draw_as_properties_panel(NodeView* _view, bool *_nodes ); @@ -103,12 +103,12 @@ namespace ndbl static NodeViewDetail get_view_detail() { return s_view_detail; } static NodeView* substitute_with_parent_if_not_visible(NodeView* _view, bool _recursive = true); static std::vector substitute_with_parent_if_not_visible(const std::vector& _in, bool _recurse = true ); - fw::Vec2 get_slot_pos( const Slot& ); - fw::Rect get_slot_rect( const Slot& _slot, i8_t _count ) const; - fw::Rect get_slot_rect( const SlotView &_slot_view, i8_t _pos ) const; - fw::Vec2 get_slot_normal( const Slot& slot) const; - void set_color( const fw::Vec4* _color, ColorType _type = Color_FILL ); - fw::Vec4 get_color(ColorType _type) const; + tools::Vec2 get_slot_pos( const Slot& ); + tools::Rect get_slot_rect( const Slot& _slot, i8_t _count ) const; + tools::Rect get_slot_rect( const SlotView &_slot_view, i8_t _pos ) const; + tools::Vec2 get_slot_normal( const Slot& slot) const; + void set_color( const tools::Vec4* _color, ColorType _type = Color_FILL ); + tools::Vec4 get_color(ColorType _type) const; static bool none_is_visible( std::vector vector1 ); @@ -118,11 +118,11 @@ namespace ndbl void update_labels_from_name(const Node *_node); static void DrawNodeRect( - fw::Rect rect, - fw::Vec4 color, - fw::Vec4 border_highlight_col, - fw::Vec4 shadow_col, - fw::Vec4 border_col, + tools::Rect rect, + tools::Vec4 color, + tools::Vec4 border_highlight_col, + tools::Vec4 shadow_col, + tools::Vec4 border_col, bool selected, float border_radius, float border_width @@ -133,7 +133,7 @@ namespace ndbl bool m_expanded; bool m_pinned; float m_opacity; - std::array m_colors; + std::array m_colors; std::vector m_slot_views; std::vector m_property_views; PropertyView* m_property_view_this; @@ -142,7 +142,7 @@ namespace ndbl static PoolID s_selected; static PoolID s_dragged; static const float s_property_input_size_min; - static const fw::Vec2 s_property_input_toggle_button_size; + static const tools::Vec2 s_property_input_toggle_button_size; static NodeViewDetail s_view_detail; REFLECT_DERIVED_CLASS() diff --git a/src/nodable/gui/NodeViewConstraint.cpp b/src/ndbl/gui/NodeViewConstraint.cpp similarity index 96% rename from src/nodable/gui/NodeViewConstraint.cpp rename to src/ndbl/gui/NodeViewConstraint.cpp index f32713486..01b5ad26a 100644 --- a/src/nodable/gui/NodeViewConstraint.cpp +++ b/src/ndbl/gui/NodeViewConstraint.cpp @@ -1,16 +1,16 @@ #include "NodeViewConstraint.h" #include "Config.h" -#include "fw/gui/Config.h" -#include "fw/gui/gui.h" +#include "tools/gui/Config.h" +#include "tools/gui/gui.h" #include "gui.h" -#include "nodable/core/ForLoopNode.h" -#include "nodable/gui/Nodable.h" -#include "nodable/gui/NodeView.h" -#include "nodable/gui/Physics.h" +#include "ndbl/core/ForLoopNode.h" +#include "ndbl/gui/Nodable.h" +#include "ndbl/gui/NodeView.h" +#include "ndbl/gui/Physics.h" #include using namespace ndbl; -using namespace fw; +using namespace tools; NodeViewConstraint::NodeViewConstraint(const char* _name, ConstrainFlags _flags) : m_flags(_flags) @@ -53,7 +53,7 @@ void NodeViewConstraint::apply(float _dt) auto target_rects = NodeView::get_rects( clean_targets, WORLD_SPACE, flags ); #ifdef NDBL_DEBUG - if( fw::g_conf->debug ) + if( tools::g_conf->debug ) { for(Rect r : target_rects) { @@ -81,7 +81,7 @@ void NodeViewConstraint::apply(float _dt) { case Align_START: { - FW_EXPECT(false, "not implemented") + EXPECT(false, "not implemented") } case Align_END: @@ -209,13 +209,13 @@ void NodeViewConstraint::draw_debug_lines(const std::vector& _drivers void NodeViewConstraint::add_target(PoolID _target) { - FW_ASSERT( _target ); + ASSERT( _target ); m_targets.push_back(_target); } void NodeViewConstraint::add_driver(PoolID _driver) { - FW_ASSERT( _driver ); + ASSERT( _driver ); m_drivers.push_back(_driver); } diff --git a/src/nodable/gui/NodeViewConstraint.h b/src/ndbl/gui/NodeViewConstraint.h similarity index 92% rename from src/nodable/gui/NodeViewConstraint.h rename to src/ndbl/gui/NodeViewConstraint.h index 01962d655..71a2bf7d2 100644 --- a/src/nodable/gui/NodeViewConstraint.h +++ b/src/ndbl/gui/NodeViewConstraint.h @@ -1,15 +1,15 @@ #pragma once -#include "fw/core/geometry/Vec2.h" -#include "fw/core/memory/Pool.h" -#include "fw/core/reflection/reflection" +#include "tools/core/geometry/Vec2.h" +#include "tools/core/memory/Pool.h" +#include "tools/core/reflection/reflection" #include namespace ndbl { // forward declarations class NodeView; - using fw::PoolID; + using tools::PoolID; enum Align { Align_START, @@ -64,7 +64,7 @@ namespace ndbl { void add_drivers(const std::vector>&); void draw_view(); - fw::Vec2 m_offset; // offset applied to the constraint + tools::Vec2 m_offset; // offset applied to the constraint static const Filter no_target_expanded; static const Filter drivers_are_expanded; diff --git a/src/nodable/gui/Physics.cpp b/src/ndbl/gui/Physics.cpp similarity index 93% rename from src/nodable/gui/Physics.cpp rename to src/ndbl/gui/Physics.cpp index 3f391381d..5a46f09c2 100644 --- a/src/nodable/gui/Physics.cpp +++ b/src/ndbl/gui/Physics.cpp @@ -1,16 +1,16 @@ #include "Physics.h" -#include "fw/core/math.h" -#include "nodable/core/ForLoopNode.h" -#include "nodable/core/GraphUtil.h" -#include "nodable/core/IConditional.h" -#include "nodable/core/Node.h" -#include "nodable/core/NodeUtils.h" +#include "tools/core/math.h" +#include "ndbl/core/ForLoopNode.h" +#include "ndbl/core/GraphUtil.h" +#include "ndbl/core/IConditional.h" +#include "ndbl/core/Node.h" +#include "ndbl/core/NodeUtils.h" #include "NodeView.h" using namespace ndbl; -using namespace fw; +using namespace tools; REGISTER { @@ -49,7 +49,7 @@ void Physics::apply_constraints(float _dt) } } -void Physics::translate_to( fw::Space space, fw::Vec2 target_pos, float _factor, bool _recurse) +void Physics::translate_to( tools::Space space, tools::Vec2 target_pos, float _factor, bool _recurse) { Vec2 delta( target_pos - m_view->position(space)); auto factor = std::max(0.0f, _factor); diff --git a/src/nodable/gui/Physics.h b/src/ndbl/gui/Physics.h similarity index 66% rename from src/nodable/gui/Physics.h rename to src/ndbl/gui/Physics.h index 99984887e..80929a240 100644 --- a/src/nodable/gui/Physics.h +++ b/src/ndbl/gui/Physics.h @@ -1,16 +1,16 @@ #pragma once -#include "fw/core/geometry/Space.h" -#include "fw/core/geometry/XForm2D.h" -#include "nodable/core/Component.h" -#include "nodable/gui/NodeViewConstraint.h" +#include "tools/core/geometry/Space.h" +#include "tools/core/geometry/XForm2D.h" +#include "ndbl/core/Component.h" +#include "ndbl/gui/NodeViewConstraint.h" namespace ndbl { // forward declarations class Node; class NodeView; - using fw::PoolID; + using tools::PoolID; class Physics : public Component { public: @@ -24,15 +24,15 @@ namespace ndbl void add_constraint(NodeViewConstraint&); void apply_constraints(float _dt); void clear_constraints(); - void translate_to(fw::Space, fw::Vec2 target_pos, float _factor, bool _recurse = false ); - void add_force(fw::Vec2 force, bool _recurse = false); + void translate_to( tools::Space, tools::Vec2 target_pos, float _factor, bool _recurse = false ); + void add_force( tools::Vec2 force, bool _recurse = false); void apply_forces(float _dt, bool _recurse); static void create_constraints(const std::vector>&); static void destroy_constraints(std::vector &physics_components); private: PoolID m_view; - fw::Vec2 m_forces_sum; - fw::Vec2 m_last_frame_forces_sum; + tools::Vec2 m_forces_sum; + tools::Vec2 m_last_frame_forces_sum; REFLECT_DERIVED_CLASS() }; diff --git a/src/nodable/gui/PropertyView.cpp b/src/ndbl/gui/PropertyView.cpp similarity index 93% rename from src/nodable/gui/PropertyView.cpp rename to src/ndbl/gui/PropertyView.cpp index 2a702ef9a..8533b9913 100644 --- a/src/nodable/gui/PropertyView.cpp +++ b/src/ndbl/gui/PropertyView.cpp @@ -1,12 +1,12 @@ #include "PropertyView.h" -#include "nodable/core/language/Nodlang.h" -#include "nodable/core/Node.h" +#include "ndbl/core/language/Nodlang.h" +#include "ndbl/core/Node.h" #include "NodeView.h" #include "SlotView.h" using namespace ndbl; -using namespace fw; +using namespace tools; PropertyView::PropertyView() { diff --git a/src/nodable/gui/PropertyView.h b/src/ndbl/gui/PropertyView.h similarity index 77% rename from src/nodable/gui/PropertyView.h rename to src/ndbl/gui/PropertyView.h index 1d33b1a74..e9bd96993 100644 --- a/src/nodable/gui/PropertyView.h +++ b/src/ndbl/gui/PropertyView.h @@ -2,19 +2,19 @@ #include -#include "fw/core/geometry/Rect.h" -#include "fw/core/memory/Pool.h" +#include "tools/core/geometry/Rect.h" +#include "tools/core/memory/Pool.h" -#include "nodable/core/Node.h" -#include "nodable/core/VariableNode.h" +#include "ndbl/core/Node.h" +#include "ndbl/core/VariableNode.h" namespace ndbl { // forward declarations class Property; class NodeView; - using fw::ID; - using fw::PoolID; + using tools::ID; + using tools::PoolID; /** * Simple struct to store a property view state @@ -24,7 +24,7 @@ namespace ndbl public: ID property_id; PoolID node_view; - fw::Rect screen_rect; + tools::Rect screen_rect; bool show_input; bool touched; diff --git a/src/nodable/gui/SlotView.cpp b/src/ndbl/gui/SlotView.cpp similarity index 99% rename from src/nodable/gui/SlotView.cpp rename to src/ndbl/gui/SlotView.cpp index 47e958b78..9ad2e4b4d 100644 --- a/src/nodable/gui/SlotView.cpp +++ b/src/ndbl/gui/SlotView.cpp @@ -6,7 +6,7 @@ #include "gui.h" using namespace ndbl; -using namespace fw; +using namespace tools; SlotView *SlotView::s_focused = nullptr; SlotView *SlotView::s_dragged = nullptr; diff --git a/src/nodable/gui/SlotView.h b/src/ndbl/gui/SlotView.h similarity index 75% rename from src/nodable/gui/SlotView.h rename to src/ndbl/gui/SlotView.h index d49635290..e6f15fbcf 100644 --- a/src/nodable/gui/SlotView.h +++ b/src/ndbl/gui/SlotView.h @@ -2,10 +2,10 @@ #include -#include "fw/core/reflection/type.h" -#include "fw/gui/ImGuiEx.h" +#include "tools/core/reflection/type.h" +#include "tools/gui/ImGuiEx.h" -#include "nodable/core/Slot.h" +#include "ndbl/core/Slot.h" #include "types.h" @@ -23,16 +23,16 @@ namespace ndbl class SlotView { public: - SlotView( Slot& _slot, fw::Vec2 _alignment ); + SlotView( Slot& _slot, tools::Vec2 _alignment ); Property* get_property()const; - const fw::type* get_property_type()const; + const tools::type* get_property_type()const; bool has_node_connected() const; - fw::Vec2 alignment() const; + tools::Vec2 alignment() const; Slot& slot()const; PoolID get_node()const; - fw::Vec2 position()const; - fw::Rect get_rect()const; + tools::Vec2 position()const; + tools::Rect get_rect()const; PoolID adjacent_node() const; bool is_this() const; bool allows(SlotFlag) const; @@ -45,12 +45,12 @@ namespace ndbl static void reset_focused(SlotView * slot = nullptr) { s_focused = slot; } static void reset_hovered(SlotView * slot = nullptr) { s_hovered = slot; } static void behavior(SlotView&, bool _readonly); - static void draw_slot_circle( ImDrawList* _draw_list, SlotView& _view, fw::Vec2 _position, bool _readonly ); - static void draw_slot_rectangle(ImDrawList* _draw_list, SlotView& _view, fw::Rect _rect, bool _readonly); + static void draw_slot_circle( ImDrawList* _draw_list, SlotView& _view, tools::Vec2 _position, bool _readonly ); + static void draw_slot_rectangle(ImDrawList* _draw_list, SlotView& _view, tools::Rect _rect, bool _readonly); private: Slot& m_slot; - fw::Vec2 m_alignment; + tools::Vec2 m_alignment; static SlotView* s_focused; static SlotView* s_dragged; static SlotView* s_hovered; diff --git a/src/nodable/gui/benchmark.cpp b/src/ndbl/gui/benchmark.cpp similarity index 96% rename from src/nodable/gui/benchmark.cpp rename to src/ndbl/gui/benchmark.cpp index f21e7b48d..7a5662029 100644 --- a/src/nodable/gui/benchmark.cpp +++ b/src/ndbl/gui/benchmark.cpp @@ -1,10 +1,10 @@ #include #include -#include "nodable/core/language/Nodlang.h" -#include "nodable/core/Graph.h" -#include "nodable/core/NodeFactory.h" -#include "fw/core/reflection/reflection" -#include "fw/core/string.h" +#include "ndbl/core/language/Nodlang.h" +#include "ndbl/core/Graph.h" +#include "ndbl/core/NodeFactory.h" +#include "tools/core/reflection/reflection" +#include "tools/core/string.h" /* * @@ -28,7 +28,7 @@ */ using namespace ndbl; -using namespace fw; +using namespace tools; class NodlangFixture : public benchmark::Fixture { public: @@ -199,7 +199,7 @@ BENCHMARK_DEFINE_F(NodlangFixture, tokenize__some_code_to_graph)(benchmark::Stat for (auto _ : state) { - FW_EXPECT(language->tokenize(code), "parse failed"); + EXPECT(language->tokenize(code), "parse failed"); } } diff --git a/src/nodable/gui/build_info.h.in b/src/ndbl/gui/build_info.h.in similarity index 100% rename from src/nodable/gui/build_info.h.in rename to src/ndbl/gui/build_info.h.in diff --git a/src/nodable/gui/commands/Cmd_ConnectEdge.h b/src/ndbl/gui/commands/Cmd_ConnectEdge.h similarity index 92% rename from src/nodable/gui/commands/Cmd_ConnectEdge.h rename to src/ndbl/gui/commands/Cmd_ConnectEdge.h index bd9b3d21d..03fa0c777 100644 --- a/src/nodable/gui/commands/Cmd_ConnectEdge.h +++ b/src/ndbl/gui/commands/Cmd_ConnectEdge.h @@ -1,7 +1,7 @@ #pragma once -#include "nodable/gui/Command.h" -#include "nodable/core/Node.h" -#include "nodable/core/Graph.h" +#include "ndbl/gui/Command.h" +#include "ndbl/core/Node.h" +#include "ndbl/core/Graph.h" namespace ndbl { diff --git a/src/nodable/gui/commands/Cmd_DisconnectEdge.h b/src/ndbl/gui/commands/Cmd_DisconnectEdge.h similarity index 88% rename from src/nodable/gui/commands/Cmd_DisconnectEdge.h rename to src/ndbl/gui/commands/Cmd_DisconnectEdge.h index 9f4448361..360ef64d9 100644 --- a/src/nodable/gui/commands/Cmd_DisconnectEdge.h +++ b/src/ndbl/gui/commands/Cmd_DisconnectEdge.h @@ -1,8 +1,8 @@ #pragma once -#include "nodable/core/DirectedEdge.h" -#include "nodable/core/Graph.h" -#include "nodable/core/Property.h" -#include "nodable/gui/Command.h" +#include "ndbl/core/DirectedEdge.h" +#include "ndbl/core/Graph.h" +#include "ndbl/core/Property.h" +#include "ndbl/gui/Command.h" namespace ndbl { diff --git a/src/nodable/gui/commands/Cmd_Group.h b/src/ndbl/gui/commands/Cmd_Group.h similarity index 96% rename from src/nodable/gui/commands/Cmd_Group.h rename to src/ndbl/gui/commands/Cmd_Group.h index 07a19afcd..340e3d745 100644 --- a/src/nodable/gui/commands/Cmd_Group.h +++ b/src/ndbl/gui/commands/Cmd_Group.h @@ -1,5 +1,5 @@ #pragma once -#include "nodable/gui/Command.h" +#include "ndbl/gui/Command.h" #include #include diff --git a/src/nodable/gui/commands/Cmd_ReplaceText.h b/src/ndbl/gui/commands/Cmd_ReplaceText.h similarity index 95% rename from src/nodable/gui/commands/Cmd_ReplaceText.h rename to src/ndbl/gui/commands/Cmd_ReplaceText.h index 2cdcef469..acfc84b14 100644 --- a/src/nodable/gui/commands/Cmd_ReplaceText.h +++ b/src/ndbl/gui/commands/Cmd_ReplaceText.h @@ -1,7 +1,7 @@ #pragma once #include -#include "fw/gui/ImGuiEx.h" -#include "nodable/gui/Command.h" +#include "tools/gui/ImGuiEx.h" +#include "ndbl/gui/Command.h" namespace ndbl { diff --git a/src/nodable/gui/commands/Cmd_WrappedTextEditorUndoRecord.h b/src/ndbl/gui/commands/Cmd_WrappedTextEditorUndoRecord.h similarity index 95% rename from src/nodable/gui/commands/Cmd_WrappedTextEditorUndoRecord.h rename to src/ndbl/gui/commands/Cmd_WrappedTextEditorUndoRecord.h index ab4bcc80b..e508ba465 100644 --- a/src/nodable/gui/commands/Cmd_WrappedTextEditorUndoRecord.h +++ b/src/ndbl/gui/commands/Cmd_WrappedTextEditorUndoRecord.h @@ -1,6 +1,6 @@ #pragma once -#include "fw/gui/ImGuiEx.h" -#include "nodable/gui/Command.h" +#include "tools/gui/ImGuiEx.h" +#include "ndbl/gui/Command.h" namespace ndbl { diff --git a/src/nodable/gui/fixtures/gui.h b/src/ndbl/gui/fixtures/gui.h similarity index 91% rename from src/nodable/gui/fixtures/gui.h rename to src/ndbl/gui/fixtures/gui.h index b8c2b5432..95fbbb3de 100644 --- a/src/nodable/gui/fixtures/gui.h +++ b/src/ndbl/gui/fixtures/gui.h @@ -1,6 +1,6 @@ #include -#include "nodable/gui/Nodable.h" +#include "ndbl/gui/Nodable.h" #include #ifdef NDBL_GUI_TEST_HUMAN_SPEED @@ -21,7 +21,6 @@ namespace testing label += test_info->test_suite_name(); label += " - "; label += test_info->name(); - // ndbl::Settings::get_instance().fw_app_view.app_window_label = label; } /** @@ -64,7 +63,7 @@ namespace testing std::filesystem::path path {relative_path}; if( path.is_relative() ) { - path = std::filesystem::path(fw::system::get_executable_directory()) / "screenshots" / path; + path = tools::system::get_executable_directory() / "screenshots" / path; } if (!std::filesystem::exists(path.parent_path())) { diff --git a/src/ndbl/gui/gui.cpp b/src/ndbl/gui/gui.cpp new file mode 100644 index 000000000..00d75d90e --- /dev/null +++ b/src/ndbl/gui/gui.cpp @@ -0,0 +1,23 @@ +#include "gui.h" +#include "tools/gui/gui.h" + +ndbl::Config* ndbl::g_conf{nullptr}; + +void ndbl::gui_init() +{ + LOG_MESSAGE("ndbl", "gui_init() ..\n"); + EXPECT(ndbl::g_conf == nullptr, "ndbl::g_cong is already initialized") + tools::gui_init(); + ndbl::g_conf = new ndbl::Config(); + LOG_MESSAGE("ndbl", "gui_init() OK\n"); +}; + +void ndbl::gui_shutdown() +{ + LOG_MESSAGE("ndbl", "gui_shutdown() ..\n"); + EXPECT(ndbl::g_conf != nullptr, "No g_conf is initialized, did you call tools::shutdown() twice?\n") + tools::gui_shutdown(); + delete ndbl::g_conf; + ndbl::g_conf = nullptr; + LOG_MESSAGE("ndbl", "gui_shutdown() OK\n"); +}; \ No newline at end of file diff --git a/src/ndbl/gui/gui.h b/src/ndbl/gui/gui.h new file mode 100644 index 000000000..ac6637609 --- /dev/null +++ b/src/ndbl/gui/gui.h @@ -0,0 +1,9 @@ +#pragma once +#include "Config.h" + +namespace ndbl +{ + extern Config* g_conf; // Globally accessible configuration. Must be initialized with tools::init() before use; + void gui_init(); // create a new g_conf + void gui_shutdown(); // delete current g_conf +} \ No newline at end of file diff --git a/src/nodable/gui/scripts/nodable.bat b/src/ndbl/gui/scripts/nodable.bat similarity index 100% rename from src/nodable/gui/scripts/nodable.bat rename to src/ndbl/gui/scripts/nodable.bat diff --git a/src/nodable/gui/scripts/nodable.sh b/src/ndbl/gui/scripts/nodable.sh similarity index 100% rename from src/nodable/gui/scripts/nodable.sh rename to src/ndbl/gui/scripts/nodable.sh diff --git a/src/nodable/core/tests.cpp b/src/ndbl/gui/tests.cpp similarity index 70% rename from src/nodable/core/tests.cpp rename to src/ndbl/gui/tests.cpp index daab4900c..79fc57ee0 100644 --- a/src/nodable/core/tests.cpp +++ b/src/ndbl/gui/tests.cpp @@ -1,8 +1,8 @@ #include -#include "fw/core/log.h" -#include +#include "tools/core/log.h" +#include "tools/core/reflection/reflection" -using namespace fw; +using namespace tools; int main(int argc, char **argv) { diff --git a/src/ndbl/gui/types.h b/src/ndbl/gui/types.h new file mode 100644 index 000000000..4a9d06f73 --- /dev/null +++ b/src/ndbl/gui/types.h @@ -0,0 +1,2 @@ +#pragma once +#include "tools/core/types.h" \ No newline at end of file diff --git a/src/nodable/README.md b/src/nodable/README.md deleted file mode 100644 index 7dcc699ad..000000000 --- a/src/nodable/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# Nodable - -Contains the nodable app and its libraries. - -### `./core` - -Nodable core library based on [framework-core](fw/core). - -### `./gui` - -Nodable graphic user interface library based on [framework-gui](fw/gui). - -### `./app` - -Nodable application based on [nodable-gui](./gui). - -### `./cli` - -Nodable experimental command line interface based on [nodable-core](./core). diff --git a/src/nodable/cli/main.cpp b/src/nodable/cli/main.cpp deleted file mode 100644 index e98069457..000000000 --- a/src/nodable/cli/main.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "CLI.h" - -int main(int argc, char *argv[]) -{ - ndbl::CLI cli; - return cli.main(argc, argv); -} diff --git a/src/nodable/gui/gui.cpp b/src/nodable/gui/gui.cpp deleted file mode 100644 index 97d42eac6..000000000 --- a/src/nodable/gui/gui.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "gui.h" -#include "fw/gui/gui.h" - -ndbl::Config* ndbl::g_conf{nullptr}; - -void ndbl::init() -{ - FW_EXPECT(ndbl::g_conf == nullptr, "ndbl::g_cong is already initialized") - - fw::init(); - ndbl::g_conf = new ndbl::Config(); -}; - -void ndbl::shutdown() -{ - FW_EXPECT(ndbl::g_conf != nullptr, "No g_conf is initialized, did you call fw::shutdown() twice?\n") - fw::shutdown(); - delete ndbl::g_conf; - ndbl::g_conf = nullptr; -}; \ No newline at end of file diff --git a/src/nodable/gui/gui.h b/src/nodable/gui/gui.h deleted file mode 100644 index dabd95e5d..000000000 --- a/src/nodable/gui/gui.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -#include "Config.h" - -namespace ndbl -{ - extern Config* g_conf; // Globally accessible configuration. Must be initialized with fw::init() before use; - void init(); // create a new g_conf - void shutdown(); // delete current g_conf -} \ No newline at end of file diff --git a/src/nodable/gui/types.h b/src/nodable/gui/types.h deleted file mode 100644 index cfc84a707..000000000 --- a/src/nodable/gui/types.h +++ /dev/null @@ -1,2 +0,0 @@ -#pragma once -#include "fw/core/types.h" \ No newline at end of file diff --git a/src/fw/README.md b/src/tools/README.md similarity index 100% rename from src/fw/README.md rename to src/tools/README.md diff --git a/src/fw/core/Color.h b/src/tools/core/Color.h similarity index 96% rename from src/fw/core/Color.h rename to src/tools/core/Color.h index 16cf08f85..9406a1722 100644 --- a/src/fw/core/Color.h +++ b/src/tools/core/Color.h @@ -2,7 +2,7 @@ #include "geometry/Vec4.h" #include "types.h" -namespace fw +namespace tools { class Color { diff --git a/src/fw/core/TIdentifier.h b/src/tools/core/TIdentifier.h similarity index 99% rename from src/fw/core/TIdentifier.h rename to src/tools/core/TIdentifier.h index 57abf9890..80e56576a 100644 --- a/src/fw/core/TIdentifier.h +++ b/src/tools/core/TIdentifier.h @@ -2,13 +2,13 @@ #include "types.h" #include -namespace fw +namespace tools { template struct _invalid_id { static_assert( std::is_unsigned_v, "UnsignedT should be unsigned" ); -#if FW_NO_POOL +#if TOOLS_NO_POOL static constexpr UnsignedT value = 0; // Is an address #else static constexpr UnsignedT value = ~UnsignedT(0); diff --git a/src/tools/core/assertions.h b/src/tools/core/assertions.h new file mode 100644 index 000000000..5e106b434 --- /dev/null +++ b/src/tools/core/assertions.h @@ -0,0 +1,27 @@ +#pragma once + +#include "log.h" // to flush before to assert/throw + +// Assertion is stopping the program when expression is false +#ifndef ASSERT_ +#define ASSERT_(expression) \ + LOG_FLUSH(); \ + assert((expression)); +#endif + +#if NOEXCEPT +# include +# define ASSERT(expression) ASSERT_( expression ) +# define EXPECT(expression, message) ASSERT_( expression ) +#else +# include +# include + +// Expect is throwing an exception when expression is false +# ifndef EXPECT_ +# define EXPECT_(expression, message_if_fails )\ + if(!(expression)) { LOG_FLUSH(); throw std::runtime_error(message_if_fails); } +# endif +# define ASSERT(expression) EXPECT_( (expression), "Assertion failed: " #expression" is false" ) +# define EXPECT(expression, message) EXPECT_( (expression), message ) +#endif diff --git a/src/fw/core/async.cpp b/src/tools/core/async.cpp similarity index 72% rename from src/fw/core/async.cpp rename to src/tools/core/async.cpp index 342a6d96c..02828daba 100644 --- a/src/fw/core/async.cpp +++ b/src/tools/core/async.cpp @@ -1,21 +1,21 @@ #include "async.h" #include "log.h" +#include +#include -using namespace fw; +using namespace tools; -async::async() -{ - tasks.reserve(tasks_reserved_size); -} +static constexpr size_t tasks_reserved_size = 16; +std::vector> tasks(tasks_reserved_size); -async& async::get_instance() +void async::delay(const std::function& function, u64_t delay_in_ms ) { - static async instance; - return instance; -} + auto task = std::async(std::launch::async, [=]() -> void { + std::chrono::milliseconds delay{ delay_in_ms }; + std::this_thread::sleep_for(delay); + function(); + }); -void async::add_task(std::future&& task) -{ // try to reuse a memory space by finding the first future ready (aka done) auto task_iterator = tasks.cbegin(); while(task_iterator != tasks.cend()) diff --git a/src/tools/core/async.h b/src/tools/core/async.h new file mode 100644 index 000000000..e1141ee2c --- /dev/null +++ b/src/tools/core/async.h @@ -0,0 +1,17 @@ +#pragma once +#include "types.h" +#include + +namespace tools +{ + /** + * Handle asynchronous tasks + * @example @code + * async::delay([]()-> void {...}), 60) + */ + namespace async + { + void clean_tasks(); // remove finished tasks + void delay(const std::function& function, u64_t delay_in_ms ); + }; +} \ No newline at end of file diff --git a/src/tools/core/core.cpp b/src/tools/core/core.cpp new file mode 100644 index 000000000..3a1dfdbb1 --- /dev/null +++ b/src/tools/core/core.cpp @@ -0,0 +1,16 @@ +#include "core.h" +#include "tools/core/memory/Pool.h" + +void tools::core_init() +{ + LOG_MESSAGE("tools", "core_init() ...\n"); + Pool::init(); + LOG_MESSAGE("tools", "core_init() OK\n"); +}; + +void tools::core_shutdown() +{ + LOG_MESSAGE("tools", "core_shutdown() ...\n"); + Pool::shutdown(); + LOG_MESSAGE("tools", "core_shutdown() OK\n"); +}; \ No newline at end of file diff --git a/src/tools/core/core.h b/src/tools/core/core.h new file mode 100644 index 000000000..36a5aaa58 --- /dev/null +++ b/src/tools/core/core.h @@ -0,0 +1,7 @@ +#pragma once + +namespace tools +{ + void core_init(); // Call before to use tools::core + void core_shutdown(); // Undo init() +} \ No newline at end of file diff --git a/src/fw/core/format.cpp b/src/tools/core/format.cpp similarity index 98% rename from src/fw/core/format.cpp rename to src/tools/core/format.cpp index 26ba0787b..133688925 100644 --- a/src/fw/core/format.cpp +++ b/src/tools/core/format.cpp @@ -1,6 +1,6 @@ #include "format.h" -using namespace fw; +using namespace tools; std::string format::number(double d) { diff --git a/src/fw/core/format.h b/src/tools/core/format.h similarity index 92% rename from src/fw/core/format.h rename to src/tools/core/format.h index 18b3f9dbd..ff82ae079 100644 --- a/src/fw/core/format.h +++ b/src/tools/core/format.h @@ -9,10 +9,12 @@ #include "./string.h" #include "types.h" -namespace fw +namespace tools { namespace format { + using tools::string32; + std::string number(double); // Format a double to a string (without trailing zeros). std::string hexadecimal(u64_t _addr); // Format a quad-word as a hexadecimal string. std::string address(const void* _addr); // Format an address as a hexadecimal string. @@ -40,6 +42,6 @@ namespace fw return result; } void limit_trailing_zeros(std::string& str, int _trailing_max); - fw::string32 time_point_to_string(const std::chrono::system_clock::time_point&); + string32 time_point_to_string(const std::chrono::system_clock::time_point&); }; } \ No newline at end of file diff --git a/src/fw/core/geometry/Box2D.h b/src/tools/core/geometry/Box2D.h similarity index 98% rename from src/fw/core/geometry/Box2D.h rename to src/tools/core/geometry/Box2D.h index 7c1f955e2..d525a0b9a 100644 --- a/src/fw/core/geometry/Box2D.h +++ b/src/tools/core/geometry/Box2D.h @@ -1,7 +1,7 @@ #pragma once #include "XForm2D.h" -namespace fw +namespace tools { class Box2D { diff --git a/src/fw/core/geometry/Rect.h b/src/tools/core/geometry/Rect.h similarity index 96% rename from src/fw/core/geometry/Rect.h rename to src/tools/core/geometry/Rect.h index 7069702f1..3467b11ab 100644 --- a/src/fw/core/geometry/Rect.h +++ b/src/tools/core/geometry/Rect.h @@ -2,7 +2,7 @@ #include "Vec2.h" #include -namespace fw +namespace tools { class Rect { @@ -29,7 +29,7 @@ namespace fw template Rect(const RectT& _rect) - : Rect(fw::Vec2{_rect.Min}, fw::Vec2{_rect.Max} ) + : Rect( tools::Vec2{_rect.Min}, tools::Vec2{_rect.Max} ) {} template diff --git a/src/fw/core/geometry/Space.h b/src/tools/core/geometry/Space.h similarity index 89% rename from src/fw/core/geometry/Space.h rename to src/tools/core/geometry/Space.h index 8d9b3d01f..35b7c8318 100644 --- a/src/fw/core/geometry/Space.h +++ b/src/tools/core/geometry/Space.h @@ -1,6 +1,6 @@ #pragma once -namespace fw +namespace tools { // to distinguish the referential of a position enum Space { diff --git a/src/fw/core/geometry/Vec2.h b/src/tools/core/geometry/Vec2.h similarity index 98% rename from src/fw/core/geometry/Vec2.h rename to src/tools/core/geometry/Vec2.h index 9c56ab82c..a73ef6955 100644 --- a/src/fw/core/geometry/Vec2.h +++ b/src/tools/core/geometry/Vec2.h @@ -5,9 +5,9 @@ #include #include -#include "fw/core/types.h" +#include "tools/core/types.h" -namespace fw +namespace tools { class Vec2 { diff --git a/src/fw/core/geometry/Vec4.h b/src/tools/core/geometry/Vec4.h similarity index 97% rename from src/fw/core/geometry/Vec4.h rename to src/tools/core/geometry/Vec4.h index 7b68346c7..f8a33f2d4 100644 --- a/src/fw/core/geometry/Vec4.h +++ b/src/tools/core/geometry/Vec4.h @@ -2,7 +2,7 @@ #include #include -namespace fw +namespace tools { class Vec4 { diff --git a/src/fw/core/geometry/XForm2D.h b/src/tools/core/geometry/XForm2D.h similarity index 98% rename from src/fw/core/geometry/XForm2D.h rename to src/tools/core/geometry/XForm2D.h index 49db96844..8082524a5 100644 --- a/src/fw/core/geometry/XForm2D.h +++ b/src/tools/core/geometry/XForm2D.h @@ -6,7 +6,7 @@ #include #undef GLM_ENABLE_EXPERIMENTAL -namespace fw +namespace tools { class XForm2D { diff --git a/src/fw/core/hash.h b/src/tools/core/hash.h similarity index 96% rename from src/fw/core/hash.h rename to src/tools/core/hash.h index 8dbf30f49..30de9785a 100644 --- a/src/fw/core/hash.h +++ b/src/tools/core/hash.h @@ -3,7 +3,7 @@ #include #include -namespace fw +namespace tools { namespace hash { diff --git a/src/fw/core/log.cpp b/src/tools/core/log.cpp similarity index 98% rename from src/fw/core/log.cpp rename to src/tools/core/log.cpp index 3276ac5ab..e24189c90 100644 --- a/src/fw/core/log.cpp +++ b/src/tools/core/log.cpp @@ -2,7 +2,7 @@ #include -using namespace fw; +using namespace tools; std::deque log::s_logs; log::Verbosity log::s_verbosity = Verbosity_DEFAULT; diff --git a/src/fw/core/log.h b/src/tools/core/log.h similarity index 87% rename from src/fw/core/log.h rename to src/tools/core/log.h index ea32a183d..c0cafae42 100644 --- a/src/fw/core/log.h +++ b/src/tools/core/log.h @@ -30,19 +30,22 @@ #define KO RED "[KO]" RESET // red colored "[KO]" string. #define OK GREEN "[OK]" RESET // green colored "[OK]" string. -# define LOG_ERROR(...) fw::log::push_message( fw::log::Verbosity_Error , ##__VA_ARGS__ ); fw::log::flush(); -# define LOG_WARNING(...) fw::log::push_message( fw::log::Verbosity_Warning, ##__VA_ARGS__ ); -# define LOG_MESSAGE(...) fw::log::push_message( fw::log::Verbosity_Message, ##__VA_ARGS__ ); -# define LOG_FLUSH() fw::log::flush(); - -#ifdef FW_DEBUG -# define LOG_VERBOSE(...) fw::log::push_message( fw::log::Verbosity_Verbose, ##__VA_ARGS__ ); +# define LOG_ERROR(...) \ + tools::log::push_message( tools::log::Verbosity_Error , ##__VA_ARGS__ ); \ + tools::log::flush(); +# define LOG_WARNING(...) tools::log::push_message( tools::log::Verbosity_Warning, ##__VA_ARGS__ ); +# define LOG_MESSAGE(...) tools::log::push_message( tools::log::Verbosity_Message, ##__VA_ARGS__ ); +# define LOG_FLUSH() tools::log::flush(); + +#ifdef TOOLS_DEBUG +# define LOG_VERBOSE(...) tools::log::push_message( tools::log::Verbosity_Verbose, ##__VA_ARGS__ ); #else # define LOG_VERBOSE(...) #endif -namespace fw { +namespace tools +{ class log { @@ -62,8 +65,8 @@ namespace fw { struct Message { - fw::string256 text{}; - fw::string32 category{}; // short category name (ex: "Game", "App", etc.) + tools::string256 text{}; + tools::string32 category{}; // short category name (ex: "Game", "App", etc.) std::chrono::time_point date = std::chrono::system_clock::now(); Verbosity verbosity=Verbosity_DEFAULT; // verbosity level diff --git a/src/fw/core/math.h b/src/tools/core/math.h similarity index 97% rename from src/fw/core/math.h rename to src/tools/core/math.h index 6dea6dcfe..162b9195d 100644 --- a/src/fw/core/math.h +++ b/src/tools/core/math.h @@ -1,7 +1,7 @@ #pragma once #include -namespace fw +namespace tools { static float normalize(float _value, float _min, float _max) { return glm::clamp(_value, _min, _max) / (_max - _min); } diff --git a/src/fw/core/memory/Pool.bench.cpp b/src/tools/core/memory/Pool.bench.cpp similarity index 99% rename from src/fw/core/memory/Pool.bench.cpp rename to src/tools/core/memory/Pool.bench.cpp index bbaa76e87..bca6ba200 100644 --- a/src/fw/core/memory/Pool.bench.cpp +++ b/src/tools/core/memory/Pool.bench.cpp @@ -1,7 +1,7 @@ #include #include "Pool.h" -using namespace fw; +using namespace tools; template class Data { diff --git a/src/fw/core/memory/Pool.cpp b/src/tools/core/memory/Pool.cpp similarity index 71% rename from src/fw/core/memory/Pool.cpp rename to src/tools/core/memory/Pool.cpp index 4b0ae7bce..62091f43a 100644 --- a/src/fw/core/memory/Pool.cpp +++ b/src/tools/core/memory/Pool.cpp @@ -1,5 +1,5 @@ #include "Pool.h" -using namespace fw; +using namespace tools; Pool* Pool::s_current_pool = nullptr; \ No newline at end of file diff --git a/src/fw/core/memory/Pool.h b/src/tools/core/memory/Pool.h similarity index 96% rename from src/fw/core/memory/Pool.h rename to src/tools/core/memory/Pool.h index e0c000155..3f47fce4c 100644 --- a/src/fw/core/memory/Pool.h +++ b/src/tools/core/memory/Pool.h @@ -9,17 +9,17 @@ #include #include -#include "fw/core/TIdentifier.h" -#include "fw/core/assertions.h" +#include "tools/core/TIdentifier.h" +#include "tools/core/assertions.h" -#ifdef FW_DEBUG -#include "fw/core/reflection/type.h" +#ifdef TOOLS_DEBUG +#include "tools/core/reflection/type.h" #endif #define POOL_REGISTRABLE( Class ) \ protected: \ - template using ID = ::fw::ID; \ - template using PoolID = ::fw::PoolID; \ + template using ID = ::tools::ID; \ + template using PoolID = ::tools::PoolID; \ PoolID m_id; \ public: \ using is_pool_registrable = std::true_type; \ @@ -29,7 +29,7 @@ public: \ #define STATIC_ASSERT__IS_POOL_REGISTRABLE(T) \ static_assert( std::is_same_v, "This type is not pool registrable, use POOL_REGISTRABLE macros." ); -namespace fw +namespace tools { /** * PoolID is the equivalent of a pointer, but it points to a Pool item. @@ -197,6 +197,6 @@ namespace fw std::unordered_map m_pool_vector_by_type; static Pool* s_current_pool; }; -} // namespace fw +} // namespace tools #include "Pool.inl" \ No newline at end of file diff --git a/src/fw/core/memory/Pool.inl b/src/tools/core/memory/Pool.inl similarity index 90% rename from src/fw/core/memory/Pool.inl rename to src/tools/core/memory/Pool.inl index 3b0e948ff..f154d1502 100644 --- a/src/fw/core/memory/Pool.inl +++ b/src/tools/core/memory/Pool.inl @@ -1,6 +1,6 @@ #pragma once -namespace fw +namespace tools { //////////////////////////// PoolID //////////////////////////////////////////// @@ -42,19 +42,23 @@ namespace fw template inline T* PoolID::operator -> () - { FW_ASSERT(*this) return get(); } + { + ASSERT(*this) return get(); } template inline T* PoolID::operator -> () const - { FW_ASSERT(*this) return get(); } + { + ASSERT(*this) return get(); } template inline T& PoolID::operator * () - { FW_ASSERT(*this) return *get(); } + { + ASSERT(*this) return *get(); } template inline T& PoolID::operator * () const - { FW_ASSERT(*this) return *get(); } + { + ASSERT(*this) return *get(); } template PoolID PoolID::null{}; @@ -114,22 +118,22 @@ namespace fw inline Pool* Pool::init(size_t _capacity, bool _reuse_ids) { - FW_EXPECT( s_current_pool == nullptr, "Should initialize Pool once" ) + EXPECT( s_current_pool == nullptr, "Should initialize Pool once" ) s_current_pool = new Pool( _capacity, _reuse_ids); return s_current_pool; } inline void Pool::shutdown() { - FW_EXPECT(s_current_pool != nullptr, "No current pool. Did you called shutdown more than once?") + EXPECT(s_current_pool != nullptr, "No current pool. Did you called shutdown more than once?") delete s_current_pool; s_current_pool = nullptr; } inline Pool* Pool::get_pool() { -#ifdef FW_DEBUG - FW_EXPECT(s_current_pool != nullptr, "No pool. Did you called Pool::init() ?") +#ifdef TOOLS_DEBUG + EXPECT(s_current_pool != nullptr, "No pool. Did you called Pool::init() ?") #endif return s_current_pool; } @@ -153,7 +157,7 @@ namespace fw template inline T* Pool::get(PoolID _id) { -#if FW_NO_POOL +#if TOOLS_NO_POOL return (T*)(u64_t)_id; #else return get( (u64_t)_id ); @@ -168,14 +172,14 @@ namespace fw m_first_free_id = m_record_by_id[id].next_id; // update linked-list return id; } - FW_ASSERT( m_record_by_id.size() != invalid_id ) + ASSERT( m_record_by_id.size() != invalid_id ) return (u64_t)m_record_by_id.size(); } template inline Type* PoolID::get() const // Return a pointer to the data from the Pool having an id == this->id { -#ifdef FW_NO_POOL +#ifdef TOOLS_NO_POOL return (Type*)(u64_t)id; #else if( id ) return Pool::get_pool()->get( id.m_value ); @@ -199,7 +203,7 @@ namespace fw inline void Pool::get(std::vector& _out, const std::vector>& ids) { STATIC_ASSERT__IS_POOL_REGISTRABLE(T) - FW_ASSERT( ids.size() <= _out.size() ); + ASSERT( ids.size() <= _out.size() ); for(size_t i = 0; i < ids.size(); ++i ) { _out[i] = get(ids[i]); @@ -213,7 +217,7 @@ namespace fw template inline PoolID Pool::create(Args... args) { -#ifdef FW_NO_POOL +#ifdef TOOLS_NO_POOL T* instance = new T(args...); PoolID id{(u64_t)instance}; instance->poolid( id ); @@ -231,7 +235,7 @@ namespace fw template inline PoolID Pool::create() { -#ifdef FW_NO_POOL +#ifdef TOOLS_NO_POOL T* instance = new T(); PoolID id{(u64_t)instance}; instance->poolid( id ); @@ -250,7 +254,7 @@ namespace fw { STATIC_ASSERT__IS_POOL_REGISTRABLE(T) auto type_id = std::type_index(typeid(T)); - FW_ASSERT( m_pool_vector_by_type.find(type_id) == m_pool_vector_by_type.end() ); + ASSERT( m_pool_vector_by_type.find(type_id) == m_pool_vector_by_type.end() ); IPoolVector* new_pool_vector = new TPoolVector( m_initial_capacity ); m_pool_vector_by_type.emplace(type_id, new_pool_vector ); return new_pool_vector; @@ -272,7 +276,7 @@ namespace fw auto it = m_pool_vector_by_type.find( type_id ); if ( it == m_pool_vector_by_type.end() ) { - LOG_VERBOSE("Pool", "No vector found for '%s'\n", fw::type::get()->get_name() ); + LOG_VERBOSE("Pool", "No vector found for '%s'\n", tools::type::get()->get_name() ); // Not great to do the init here, but required when a type is not handled yet return init_for(); } @@ -283,7 +287,7 @@ namespace fw inline PoolID Pool::make_record(T* data, IPoolVector * vec, size_t pos ) { u32_t next_id = generate_id(); - FW_ASSERT(next_id < invalid_id) // Last id is reserved for "null" or "invalid" + ASSERT(next_id < invalid_id) // Last id is reserved for "null" or "invalid" PoolID poolid{next_id}; data->poolid(poolid); bool is_new_id = next_id == m_record_by_id.size(); @@ -304,7 +308,7 @@ namespace fw template inline void Pool::destroy(PoolID _id ) { -#ifdef FW_NO_POOL +#ifdef TOOLS_NO_POOL delete _id.get(); #else STATIC_ASSERT__IS_POOL_REGISTRABLE(T) @@ -343,4 +347,4 @@ namespace fw destroy( each_id ); } } -} // namespace fw \ No newline at end of file +} // namespace tools \ No newline at end of file diff --git a/src/fw/core/memory/Pool.specs.cpp b/src/tools/core/memory/Pool.specs.cpp similarity index 98% rename from src/fw/core/memory/Pool.specs.cpp rename to src/tools/core/memory/Pool.specs.cpp index 71da65b2a..8fb324e1f 100644 --- a/src/fw/core/memory/Pool.specs.cpp +++ b/src/tools/core/memory/Pool.specs.cpp @@ -1,8 +1,8 @@ #include "Pool.h" -#include "fw/core/log.h" +#include "tools/core/log.h" #include -using namespace fw; +using namespace tools; class Data { public: diff --git a/src/fw/core/reflection/Operator.h b/src/tools/core/reflection/Operator.h similarity index 97% rename from src/fw/core/reflection/Operator.h rename to src/tools/core/reflection/Operator.h index 0acdddd95..76e9247f0 100644 --- a/src/fw/core/reflection/Operator.h +++ b/src/tools/core/reflection/Operator.h @@ -2,7 +2,7 @@ #include -namespace fw +namespace tools { // forward declaration enum class Operator_t; diff --git a/src/fw/core/reflection/Operator_t.h b/src/tools/core/reflection/Operator_t.h similarity index 96% rename from src/fw/core/reflection/Operator_t.h rename to src/tools/core/reflection/Operator_t.h index b8c741229..7b2108312 100644 --- a/src/fw/core/reflection/Operator_t.h +++ b/src/tools/core/reflection/Operator_t.h @@ -1,7 +1,7 @@ #pragma once #include "enum.h" -namespace fw +namespace tools { enum class Operator_t: int // To distinguish operator types diff --git a/src/fw/core/reflection/class.h b/src/tools/core/reflection/class.h similarity index 63% rename from src/fw/core/reflection/class.h rename to src/tools/core/reflection/class.h index b470db9c5..fb2fd2196 100644 --- a/src/fw/core/reflection/class.h +++ b/src/tools/core/reflection/class.h @@ -3,12 +3,12 @@ /** REFLECT_BASE_CLASS is replaced by a get_type() function if inserted in a class body */ #define REFLECT_BASE_CLASS() \ public:\ - virtual const fw::type* get_type() const { return fw::type::get(); }\ + virtual const tools::type* get_type() const { return tools::type::get(); }\ private: /** REFLECT_DERIVED_CLASS is replaced by a get_type() function if inserted in a class body. Must have a parent class with REFLECT_BASE_CLASS */ #define REFLECT_DERIVED_CLASS() \ public:\ - virtual const fw::type* get_type() const override { return fw::type::get(); }\ + virtual const tools::type* get_type() const override { return tools::type::get(); }\ private: diff --git a/src/fw/core/reflection/enum.h b/src/tools/core/reflection/enum.h similarity index 100% rename from src/fw/core/reflection/enum.h rename to src/tools/core/reflection/enum.h diff --git a/src/fw/core/reflection/func_type.cpp b/src/tools/core/reflection/func_type.cpp similarity index 98% rename from src/fw/core/reflection/func_type.cpp rename to src/tools/core/reflection/func_type.cpp index e69bf1c42..863ba7ff0 100644 --- a/src/fw/core/reflection/func_type.cpp +++ b/src/tools/core/reflection/func_type.cpp @@ -2,7 +2,7 @@ #include // find_if #include "Operator.h" -using namespace fw; +using namespace tools; func_type::func_type(std::string _id) : m_identifier(_id) diff --git a/src/fw/core/reflection/func_type.h b/src/tools/core/reflection/func_type.h similarity index 98% rename from src/fw/core/reflection/func_type.h rename to src/tools/core/reflection/func_type.h index 163cc21ea..8fea5da21 100644 --- a/src/fw/core/reflection/func_type.h +++ b/src/tools/core/reflection/func_type.h @@ -6,7 +6,7 @@ #include #include "type.h" -namespace fw +namespace tools { // forward declarations class Operator; @@ -119,7 +119,7 @@ namespace fw func_type* construct() { - FW_EXPECT( !m_id.empty(), "No identifier specified! use with_id()" ); + EXPECT( !m_id.empty(), "No identifier specified! use with_id()" ); func_type* signature = new func_type(m_id); diff --git a/src/fw/core/reflection/invokable.h b/src/tools/core/reflection/invokable.h similarity index 95% rename from src/fw/core/reflection/invokable.h rename to src/tools/core/reflection/invokable.h index 8206d8111..b99a2a49c 100644 --- a/src/fw/core/reflection/invokable.h +++ b/src/tools/core/reflection/invokable.h @@ -4,12 +4,13 @@ #include #include /* va_list, va_start, va_arg, va_end */ #include -#include "fw/core/types.h" +#include "tools/core/types.h" #include "variant.h" #include "type.h" #include "func_type.h" -namespace fw { +namespace tools +{ class iinvokable { @@ -218,7 +219,7 @@ namespace fw { : m_function_impl(_implem) , m_function_type(func_type_builder::with_id(_name)) { - FW_ASSERT(m_function_impl) + ASSERT(m_function_impl) } ~invokable_static() override @@ -228,8 +229,8 @@ namespace fw { variant invoke(const std::vector &_args = {}) const override { - FW_EXPECT(_args.size() == std::tuple_size(), "Wrong argument count!"); - return fw::invoke(m_function_impl, _args); + EXPECT(_args.size() == std::tuple_size(), "Wrong argument count!"); + return tools::invoke(m_function_impl, _args); } const func_type* get_type() const override { return m_function_type; } @@ -266,8 +267,8 @@ namespace fw { virtual variant invoke(void* _instance, const std::vector &_args = {}) const override { - FW_EXPECT(_args.size() == std::tuple_size(), "Wrong argument count!"); - return fw::invoke_property(reinterpret_cast(_instance), m_method, _args); + EXPECT(_args.size() == std::tuple_size(), "Wrong argument count!"); + return tools::invoke_property(reinterpret_cast(_instance), m_method, _args); }; }; diff --git a/src/fw/core/reflection/qword.cpp b/src/tools/core/reflection/qword.cpp similarity index 91% rename from src/fw/core/reflection/qword.cpp rename to src/tools/core/reflection/qword.cpp index 3a4379a1e..db9b86c14 100644 --- a/src/fw/core/reflection/qword.cpp +++ b/src/tools/core/reflection/qword.cpp @@ -1,8 +1,8 @@ #include "qword.h" #include -#include "fw/core/format.h" +#include "tools/core/format.h" -using namespace fw; +using namespace tools; R_UNION_MEMBER_DEFINITION(qword, b) R_UNION_MEMBER_DEFINITION(qword, u8) diff --git a/src/fw/core/reflection/qword.h b/src/tools/core/reflection/qword.h similarity index 94% rename from src/fw/core/reflection/qword.h rename to src/tools/core/reflection/qword.h index 9881ccbe3..d481dea52 100644 --- a/src/fw/core/reflection/qword.h +++ b/src/tools/core/reflection/qword.h @@ -3,11 +3,11 @@ #include #include // for memset -#include "fw/core/assertions.h" -#include "fw/core/types.h" +#include "tools/core/assertions.h" +#include "tools/core/types.h" #include "union.h" -namespace fw +namespace tools { /** diff --git a/src/fw/core/reflection/reflection b/src/tools/core/reflection/reflection similarity index 100% rename from src/fw/core/reflection/reflection rename to src/tools/core/reflection/reflection diff --git a/src/fw/core/reflection/reflection.specs.cpp b/src/tools/core/reflection/reflection.specs.cpp similarity index 99% rename from src/fw/core/reflection/reflection.specs.cpp rename to src/tools/core/reflection/reflection.specs.cpp index dda20c1ce..4f5aa5a18 100644 --- a/src/fw/core/reflection/reflection.specs.cpp +++ b/src/tools/core/reflection/reflection.specs.cpp @@ -7,7 +7,7 @@ #include "reflection" #include "../log.h" -using namespace fw; +using namespace tools; TEST(Reflection, is_convertible__type_to_ptr) { diff --git a/src/fw/core/reflection/registration.h b/src/tools/core/reflection/registration.h similarity index 99% rename from src/fw/core/reflection/registration.h rename to src/tools/core/reflection/registration.h index 145051ba8..419fe8581 100644 --- a/src/fw/core/reflection/registration.h +++ b/src/tools/core/reflection/registration.h @@ -5,7 +5,7 @@ #include "func_type.h" #include "invokable.h" -namespace fw +namespace tools { template class invokable_static; diff --git a/src/fw/core/reflection/type.cpp b/src/tools/core/reflection/type.cpp similarity index 99% rename from src/fw/core/reflection/type.cpp rename to src/tools/core/reflection/type.cpp index 447cbb291..a24754cfa 100644 --- a/src/fw/core/reflection/type.cpp +++ b/src/tools/core/reflection/type.cpp @@ -3,7 +3,7 @@ #include "type.h" #include "invokable.h" -using namespace fw; +using namespace tools; REGISTER { diff --git a/src/fw/core/reflection/type.h b/src/tools/core/reflection/type.h similarity index 92% rename from src/fw/core/reflection/type.h rename to src/tools/core/reflection/type.h index 087fba22c..45ca1eb08 100644 --- a/src/fw/core/reflection/type.h +++ b/src/tools/core/reflection/type.h @@ -8,23 +8,23 @@ #include #include "type_register.h" -#include "fw/core/assertions.h" +#include "tools/core/assertions.h" -namespace fw +namespace tools { // forward declarations class iinvokable; class iinvokable_nonstatic; - /** Empty structure to act like any type, @related fw::variant class */ + /** Empty structure to act like any type, @related tools::variant class */ struct any_t{}; - /** Empty structure to act like a null type, @related fw::variant class */ + /** Empty structure to act like a null type, @related tools::variant class */ struct null_t{}; /** * @struct Removes a pointer from a given type PointerT * @example @code - * using _Class = fw::remove_pointer::type; // _Class == Class + * using _Class = tools::remove_pointer::type; // _Class == Class */ template struct remove_pointer @@ -126,7 +126,7 @@ namespace fw { using tuple = std::tuple; static constexpr size_t size = std::tuple_size_v; - using result_t = std::array; + using result_t = std::array; static result_t types() { @@ -139,7 +139,7 @@ namespace fw static result_t& extract_type_at(result_t& output) { using element_t = std::tuple_element_t; - output[N] = fw::type::get(); + output[N] = tools::type::get(); return extract_type_at(output); } @@ -147,7 +147,7 @@ namespace fw static result_t& extract_type_at(result_t& output) { using element_t = std::tuple_element_t<0, tuple>; - output[0] = fw::type::get(); + output[0] = tools::type::get(); return output; } }; @@ -211,7 +211,7 @@ namespace fw Flags flags = Flags_NONE; if(std::is_pointer::value) flags += Flags_IS_POINTER; if(std::is_const::value) flags += Flags_IS_CONST; - if(fw::is_class::value) flags += Flags_IS_CLASS; + if( tools::is_class::value) flags += Flags_IS_CLASS; return new type( get_type_id(), @@ -260,8 +260,8 @@ namespace fw template struct is_base_of { - static_assert(fw::has_get_type, "BaseT must have polymorphic reflection"); - static_assert(fw::has_get_type, "DerivedT must have polymorphic reflection"); + static_assert( tools::has_get_type, "BaseT must have polymorphic reflection"); + static_assert( tools::has_get_type, "DerivedT must have polymorphic reflection"); static constexpr bool value = std::is_same_v || std::is_base_of_v; }; } \ No newline at end of file diff --git a/src/fw/core/reflection/type_register.cpp b/src/tools/core/reflection/type_register.cpp similarity index 92% rename from src/fw/core/reflection/type_register.cpp rename to src/tools/core/reflection/type_register.cpp index 0c7068f6b..a695d5508 100644 --- a/src/fw/core/reflection/type_register.cpp +++ b/src/tools/core/reflection/type_register.cpp @@ -1,14 +1,14 @@ #include "type_register.h" #include "type.h" -#include "fw/core/log.h" -#include "fw/core/assertions.h" +#include "tools/core/log.h" +#include "tools/core/assertions.h" -using namespace fw; +using namespace tools; type* type_register::get(std::type_index index) { auto found = by_index().find(index); - FW_EXPECT(found != by_index().end(), "reflection: type not found!") + EXPECT(found != by_index().end(), "reflection: type not found!") return found->second; } diff --git a/src/fw/core/reflection/type_register.h b/src/tools/core/reflection/type_register.h similarity index 97% rename from src/fw/core/reflection/type_register.h rename to src/tools/core/reflection/type_register.h index 98f9f390a..22c5e6c02 100644 --- a/src/fw/core/reflection/type_register.h +++ b/src/tools/core/reflection/type_register.h @@ -6,7 +6,7 @@ #include "../log.h" -namespace fw +namespace tools { // forward declaration class type; diff --git a/src/fw/core/reflection/union.h b/src/tools/core/reflection/union.h similarity index 100% rename from src/fw/core/reflection/union.h rename to src/tools/core/reflection/union.h diff --git a/src/fw/core/reflection/variant.cpp b/src/tools/core/reflection/variant.cpp similarity index 85% rename from src/fw/core/reflection/variant.cpp rename to src/tools/core/reflection/variant.cpp index 2401d7152..7fd542cc9 100644 --- a/src/fw/core/reflection/variant.cpp +++ b/src/tools/core/reflection/variant.cpp @@ -1,7 +1,7 @@ #include "variant.h" -#include "fw/core/format.h" +#include "tools/core/format.h" -using namespace fw; +using namespace tools; variant::~variant() { @@ -48,7 +48,7 @@ double variant::to()const if(m_type->is() ) return double(m_data.i32); if(m_type->is() ) return double(m_data.b); - FW_ASSERT(false) // this case is not handled + ASSERT(false) // this case is not handled } @@ -66,7 +66,7 @@ i16_t variant::to()const if(m_type->is() ) return (i16_t)m_data.i32; if(m_type->is() ) return i16_t(m_data.b); - FW_ASSERT(false) // this case is not handled + ASSERT(false) // this case is not handled } template<> @@ -83,7 +83,7 @@ i32_t variant::to()const if(m_type->is() ) return m_data.i32; if(m_type->is() ) return i16_t(m_data.b); - FW_ASSERT(false) // this case is not handled + ASSERT(false) // this case is not handled } template<> @@ -100,7 +100,7 @@ bool variant::to()const if(m_type->is() ) return m_data.i32 != 0; if(m_type->is() ) return m_data.b; if(m_type->is() ) return m_data.ptr; - FW_EXPECT(false,"Case not handled!") + EXPECT(false,"Case not handled!") } template<> @@ -179,7 +179,7 @@ bool variant::is_initialized()const void variant::reset_value() { - FW_EXPECT(m_is_initialized, "Variant: cannot reset value, variant not intialized!"); + EXPECT(m_is_initialized, "Variant: cannot reset value, variant not intialized!"); if(m_type->is() ) { @@ -225,15 +225,15 @@ void variant::ensure_is_type(const type* _type) } else if( !m_type_change_allowed ) { - FW_EXPECT( m_type->any_of({type::null(), type::any()}), "variant's type should not change (or be null or any)" ); + EXPECT( m_type->any_of({type::null(), type::any()}), "variant's type should not change (or be null or any)" ); } m_type = new_type; } void variant::flag_defined(bool _value ) { - FW_EXPECT(m_type != type::null(), "Variant: Unable to ensure variant is defined because its type is null!"); - FW_EXPECT(m_is_initialized, "Variant: Unable to ensure variant is defined because it is not initialized!"); + EXPECT(m_type != type::null(), "Variant: Unable to ensure variant is defined because its type is null!"); + EXPECT(m_is_initialized, "Variant: Unable to ensure variant is defined because it is not initialized!"); /* * Like in c/cpp, a memory space can be initialized (ex: int i;) but not defined by the user. @@ -259,7 +259,7 @@ void variant::set(const variant& _other) { return; } - FW_ASSERT(type::is_implicitly_convertible(_other.m_type, m_type)); + ASSERT(type::is_implicitly_convertible(_other.m_type, m_type)); if( m_type->is() ) { @@ -289,7 +289,7 @@ void variant::set(const variant& _other) } else { - FW_EXPECT(false, "Variant: missing type case for operator="); + EXPECT(false, "Variant: missing type case for operator="); } } @@ -330,90 +330,90 @@ void variant::set(null_t) variant::operator std::string& () { - FW_ASSERT(m_is_initialized) + ASSERT(m_is_initialized) return *((std::string*)m_data.ptr); } variant::operator bool& () { - FW_ASSERT(m_is_initialized) + ASSERT(m_is_initialized) return m_data.b; } variant::operator i16_t& () { - FW_ASSERT(m_is_initialized) + ASSERT(m_is_initialized) return m_data.i16; } variant::operator i32_t& () { - FW_ASSERT(m_is_initialized) + ASSERT(m_is_initialized) return m_data.i32; } variant::operator u32_t& () { - FW_ASSERT(m_is_initialized) + ASSERT(m_is_initialized) return m_data.u32; } variant::operator u64_t& () { - FW_ASSERT(m_is_initialized) + ASSERT(m_is_initialized) return m_data.u64; } variant::operator double& () { - FW_ASSERT(m_is_initialized) + ASSERT(m_is_initialized) return m_data.d; } variant::operator std::string() const { - FW_ASSERT(m_is_initialized) + ASSERT(m_is_initialized) return *((std::string*)m_data.ptr); } variant::operator bool () const { - FW_ASSERT(m_is_initialized) + ASSERT(m_is_initialized) return m_data.b; } variant::operator i16_t () const { - FW_ASSERT(m_is_initialized) + ASSERT(m_is_initialized) return m_data.i16; } variant::operator i32_t () const { - FW_ASSERT(m_is_initialized) + ASSERT(m_is_initialized) return m_data.i32; } variant::operator u32_t () const { - FW_ASSERT(m_is_initialized) + ASSERT(m_is_initialized) return m_data.u32; } variant::operator u64_t () const { - FW_ASSERT(m_is_initialized) + ASSERT(m_is_initialized) return m_data.u64; } variant::operator double () const { - FW_ASSERT(m_is_initialized) + ASSERT(m_is_initialized) return m_data.d; } variant::operator const char*() const { - FW_ASSERT(m_is_initialized) + ASSERT(m_is_initialized) return ((std::string*)m_data.ptr)->c_str(); } diff --git a/src/fw/core/reflection/variant.h b/src/tools/core/reflection/variant.h similarity index 96% rename from src/fw/core/reflection/variant.h rename to src/tools/core/reflection/variant.h index e9b21d98e..62e15d949 100644 --- a/src/fw/core/reflection/variant.h +++ b/src/tools/core/reflection/variant.h @@ -4,13 +4,13 @@ #include #include // std::shared_ptr -#include "fw/core/assertions.h" -#include "fw/core/types.h" -#include "fw/core/memory/Pool.h" +#include "tools/core/assertions.h" +#include "tools/core/types.h" +#include "tools/core/memory/Pool.h" #include "qword.h" #include "type.h" -namespace fw +namespace tools { /** * @brief This class can hold several types such as: bool, double, std::string, etc.. (see m_data property) diff --git a/src/fw/core/string.bench.cpp b/src/tools/core/string.bench.cpp similarity index 99% rename from src/fw/core/string.bench.cpp rename to src/tools/core/string.bench.cpp index 5926b53f1..2cd022fc3 100644 --- a/src/fw/core/string.bench.cpp +++ b/src/tools/core/string.bench.cpp @@ -2,7 +2,7 @@ #include #include "string.h" -using namespace fw; +using namespace tools; template static void BM_empty_constructor(benchmark::State& state) diff --git a/src/fw/core/string.h b/src/tools/core/string.h similarity index 99% rename from src/fw/core/string.h rename to src/tools/core/string.h index f4b44b36b..1706f58f3 100644 --- a/src/fw/core/string.h +++ b/src/tools/core/string.h @@ -7,7 +7,7 @@ #include #include "types.h" -namespace fw +namespace tools { enum class alloc_strategy { NEXT_ALLOC_USE_HEAP, // Currently allocated on stack, next alloc will be on the heap diff --git a/src/fw/core/string.spec.cpp b/src/tools/core/string.spec.cpp similarity index 98% rename from src/fw/core/string.spec.cpp rename to src/tools/core/string.spec.cpp index 5659ff243..07b9d123f 100644 --- a/src/fw/core/string.spec.cpp +++ b/src/tools/core/string.spec.cpp @@ -1,7 +1,7 @@ #include -#include +#include "tools/core/string.h" -using namespace fw; +using namespace tools; TEST(string, constructor_no_args) { diff --git a/src/fw/core/system.cpp b/src/tools/core/system.cpp similarity index 73% rename from src/fw/core/system.cpp rename to src/tools/core/system.cpp index 886e0f2fc..24023b191 100644 --- a/src/fw/core/system.cpp +++ b/src/tools/core/system.cpp @@ -6,7 +6,7 @@ #include "log.h" -using namespace fw; +using namespace tools; using fs_path = std::filesystem::path; void system::open_url_async(std::string _URL) @@ -28,7 +28,7 @@ void system::open_url_async(std::string _URL) if (result != 0) { - LOG_ERROR( "fw::system", "Unable to open %s. Because the command %s is not available on your system.", + LOG_ERROR( "tools::system", "Unable to open %s. Because the command %s is not available on your system.", _URL.c_str(), command.c_str()) } @@ -51,21 +51,21 @@ fs_path system::get_executable_directory() if ( wai_getExecutablePath(path, length, &dirname_length) ) { path[length] = '\0'; - LOG_MESSAGE("fw::system", "executable path: %s\n", path); + LOG_MESSAGE("tools::system", "executable path: %s\n", path); path[dirname_length] = '\0'; - LOG_MESSAGE("fw::system", " dirname: %s\n", path); - LOG_MESSAGE("fw::system", " basename: %s\n", path + dirname_length + 1); + LOG_MESSAGE("tools::system", " dirname: %s\n", path); + LOG_MESSAGE("tools::system", " basename: %s\n", path + dirname_length + 1); result = path; } else { - LOG_ERROR("fw::system", "Unable to get executable path\n"); + LOG_ERROR("tools::system", "Unable to get executable path\n"); } delete[] path; } else { - LOG_WARNING("fw::system", "Unable to get executable directory!\n"); + LOG_WARNING("tools::system", "Unable to get executable directory!\n"); } return result; } @@ -77,5 +77,5 @@ void system::clear_console() /* cf: https://stackoverflow.com/questions/6486289/ #elif defined (__LINUX__) || defined(__gnu_linux__) || defined(__linux__) || defined (__APPLE__) const char* command = "clear"; #endif - if(std::system(command)) LOG_ERROR("fw::system::console", "Unable to clear console"); + if(std::system(command)) LOG_ERROR("tools::system::console", "Unable to clear console"); } diff --git a/src/fw/core/system.h b/src/tools/core/system.h similarity index 96% rename from src/fw/core/system.h rename to src/tools/core/system.h index c04c1dcdc..3a90700f7 100644 --- a/src/fw/core/system.h +++ b/src/tools/core/system.h @@ -2,7 +2,7 @@ #include #include -namespace fw +namespace tools { namespace system // multi-platform static functions { diff --git a/src/fw/core/tests.cpp b/src/tools/core/tests.cpp similarity index 92% rename from src/fw/core/tests.cpp rename to src/tools/core/tests.cpp index fecf43bc7..d3e24741f 100644 --- a/src/fw/core/tests.cpp +++ b/src/tools/core/tests.cpp @@ -2,7 +2,7 @@ #include "log.h" #include "reflection/reflection" -using namespace fw; +using namespace tools; int main(int argc, char **argv) { diff --git a/src/fw/core/types.h b/src/tools/core/types.h similarity index 100% rename from src/fw/core/types.h rename to src/tools/core/types.h diff --git a/src/fw/gui-example/AppExample.h b/src/tools/gui-example/AppExample.h similarity index 92% rename from src/fw/gui-example/AppExample.h rename to src/tools/gui-example/AppExample.h index 18c0cc054..d37b5d6b6 100644 --- a/src/fw/gui-example/AppExample.h +++ b/src/tools/gui-example/AppExample.h @@ -1,12 +1,12 @@ #pragma once #include "AppExampleView.h" -#include "fw/gui/App.h" -#include "fw/gui/Config.h" -#include "fw/gui/gui.h" +#include "tools/gui/App.h" +#include "tools/gui/Config.h" +#include "tools/gui/gui.h" -namespace fw +namespace tools { - class AppExample : public fw::App + class AppExample : public tools::App { public: AppExample() diff --git a/src/fw/gui-example/AppExampleView.h b/src/tools/gui-example/AppExampleView.h similarity index 73% rename from src/fw/gui-example/AppExampleView.h rename to src/tools/gui-example/AppExampleView.h index 6b40d1b1a..921b43197 100644 --- a/src/fw/gui-example/AppExampleView.h +++ b/src/tools/gui-example/AppExampleView.h @@ -1,9 +1,9 @@ #pragma once -#include "fw/gui/App.h" +#include "tools/gui/App.h" -namespace fw +namespace tools { - class AppExampleView : public fw::AppView + class AppExampleView : public tools::AppView { public: AppExampleView(App* _app) @@ -13,9 +13,9 @@ namespace fw void on_reset_layout() override { // Bind each window to a dockspace - dock_window( "center", fw::AppView::Dockspace_CENTER ); - dock_window( "right", fw::AppView::Dockspace_RIGHT ); - dock_window( "top", fw::AppView::Dockspace_TOP ); + dock_window( "center", tools::AppView::Dockspace_CENTER ); + dock_window( "right", tools::AppView::Dockspace_RIGHT ); + dock_window( "top", tools::AppView::Dockspace_TOP ); } void draw_splashscreen() override diff --git a/src/fw/gui-example/main.cpp b/src/tools/gui-example/main.cpp similarity index 70% rename from src/fw/gui-example/main.cpp rename to src/tools/gui-example/main.cpp index 5233ebf97..3912c1f72 100644 --- a/src/fw/gui-example/main.cpp +++ b/src/tools/gui-example/main.cpp @@ -1,11 +1,11 @@ #include "AppExample.h" -using namespace fw; +using namespace tools; int main(int argc, char *argv[]) { // Override config - fw::g_conf->app_window_label = "framework-example - (based on framework-gui library)"; + tools::g_conf->app_window_label = "framework-example - (based on framework-gui library)"; // Instantiate the application using the predefined configuration AppExample app; diff --git a/src/fw/gui/Action.cpp b/src/tools/gui/Action.cpp similarity index 91% rename from src/fw/gui/Action.cpp rename to src/tools/gui/Action.cpp index d6734f0fa..10f8cc693 100644 --- a/src/fw/gui/Action.cpp +++ b/src/tools/gui/Action.cpp @@ -1,7 +1,7 @@ #include "Action.h" #include "EventManager.h" -using namespace fw; +using namespace tools; void IAction::trigger() const { diff --git a/src/fw/gui/Action.h b/src/tools/gui/Action.h similarity index 98% rename from src/fw/gui/Action.h rename to src/tools/gui/Action.h index 1fe1f30f3..f735ebf59 100644 --- a/src/fw/gui/Action.h +++ b/src/tools/gui/Action.h @@ -3,10 +3,10 @@ #include #include -#include "fw/core/types.h" +#include "tools/core/types.h" #include "Event.h" -namespace fw +namespace tools { /** Data describing a shortcut (ex: "Reset": Ctrl + Alt + R) */ struct Shortcut diff --git a/src/fw/gui/ActionManager.cpp b/src/tools/gui/ActionManager.cpp similarity index 71% rename from src/fw/gui/ActionManager.cpp rename to src/tools/gui/ActionManager.cpp index ff60237b4..4d2ec3e8c 100644 --- a/src/fw/gui/ActionManager.cpp +++ b/src/tools/gui/ActionManager.cpp @@ -4,37 +4,37 @@ #include #include -#include "fw/core/assertions.h" -#include "fw/core/async.h" -#include "fw/core/log.h" -#include "fw/core/reflection/type.h" +#include "tools/core/assertions.h" +#include "tools/core/async.h" +#include "tools/core/log.h" +#include "tools/core/reflection/type.h" -using namespace fw; +using namespace tools; ActionManager* ActionManager::s_instance = nullptr; ActionManager::ActionManager() { - LOG_VERBOSE("fw::ActionManager", "Constructor ...\n"); - FW_EXPECT(!s_instance, "cannot have two instances at a time"); + LOG_VERBOSE("tools::ActionManager", "Constructor ...\n"); + EXPECT(!s_instance, "cannot have two instances at a time"); s_instance = this; - LOG_VERBOSE("fw::ActionManager", "Constructor " OK "\n"); + LOG_VERBOSE("tools::ActionManager", "Constructor " OK "\n"); } ActionManager::~ActionManager() { - LOG_VERBOSE("fw::ActionManager", "Destructor ...\n"); + LOG_VERBOSE("tools::ActionManager", "Destructor ...\n"); s_instance = nullptr; for( auto action : m_actions ) { delete action; } - LOG_VERBOSE("fw::ActionManager", "Destructor " OK "\n"); + LOG_VERBOSE("tools::ActionManager", "Destructor " OK "\n"); } ActionManager& ActionManager::get_instance() { - FW_EXPECT(s_instance, "No instance found."); + EXPECT(s_instance, "No instance found."); return *s_instance; } @@ -45,7 +45,7 @@ const IAction* ActionManager::get_action_with_id(EventID id) { string128 str; str.append_fmt("Unable to find an action bound to EventId %i\n", id); - FW_EXPECT(false, str.c_str() ); + EXPECT(false, str.c_str() ); } return found->second; } diff --git a/src/fw/gui/ActionManager.h b/src/tools/gui/ActionManager.h similarity index 94% rename from src/fw/gui/ActionManager.h rename to src/tools/gui/ActionManager.h index fbf76d92e..68aa07757 100644 --- a/src/fw/gui/ActionManager.h +++ b/src/tools/gui/ActionManager.h @@ -6,13 +6,13 @@ #include #include -#include "fw/core/reflection/func_type.h" -#include "fw/core/types.h" +#include "tools/core/reflection/func_type.h" +#include "tools/core/types.h" #include "Action.h" #include "Event.h" -namespace fw +namespace tools { class ActionManager { diff --git a/src/fw/gui/ActionManagerView.cpp b/src/tools/gui/ActionManagerView.cpp similarity index 97% rename from src/fw/gui/ActionManagerView.cpp rename to src/tools/gui/ActionManagerView.cpp index 045d82c23..917e631c8 100644 --- a/src/fw/gui/ActionManagerView.cpp +++ b/src/tools/gui/ActionManagerView.cpp @@ -2,7 +2,7 @@ #include "ActionManager.h" #include "ImGuiEx.h" -using namespace fw; +using namespace tools; void ActionManagerView::draw(ActionManager* manager) { diff --git a/src/fw/gui/ActionManagerView.h b/src/tools/gui/ActionManagerView.h similarity index 91% rename from src/fw/gui/ActionManagerView.h rename to src/tools/gui/ActionManagerView.h index d0e0a792b..c662f62bc 100644 --- a/src/fw/gui/ActionManagerView.h +++ b/src/tools/gui/ActionManagerView.h @@ -1,6 +1,6 @@ #pragma once -namespace fw +namespace tools { // Forward declaration class ActionManager; diff --git a/src/fw/gui/App.cpp b/src/tools/gui/App.cpp similarity index 88% rename from src/fw/gui/App.cpp rename to src/tools/gui/App.cpp index d7c18c409..5781da316 100644 --- a/src/fw/gui/App.cpp +++ b/src/tools/gui/App.cpp @@ -6,12 +6,12 @@ #include #include -#include "fw/core/system.h" +#include "tools/core/system.h" #include "AppView.h" #include "ImGuiEx.h" #include "gui.h" -using namespace fw; +using namespace tools; App *App::s_instance = nullptr; @@ -25,34 +25,34 @@ App::App(AppView* _view) , m_sdl_gl_context() , m_view(_view) { - LOG_VERBOSE("fw::App", "Constructor ...\n"); - FW_EXPECT( m_view, "View cannot be null"); - FW_EXPECT(s_instance == nullptr, "Only a single fw::App at a time allowed"); + LOG_VERBOSE("tools::App", "Constructor ...\n"); + EXPECT( m_view, "View cannot be null"); + EXPECT(s_instance == nullptr, "Only a single tools::App at a time allowed"); s_instance = this; - LOG_VERBOSE("fw::App", "Constructor " OK "\n"); + LOG_VERBOSE("tools::App", "Constructor " OK "\n"); } App::~App() { - LOG_VERBOSE("fw::App", "Destructor ...\n"); + LOG_VERBOSE("tools::App", "Destructor ...\n"); s_instance = nullptr; - LOG_VERBOSE("fw::App", "Destructor " OK "\n"); + LOG_VERBOSE("tools::App", "Destructor " OK "\n"); } bool App::init() { before_init(); - LOG_VERBOSE("fw::App", "init ...\n"); + LOG_VERBOSE("tools::App", "init ...\n"); // Setup SDL if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER) != 0) { - LOG_ERROR( "fw::App", "SDL Error: %s\n", SDL_GetError()) + LOG_ERROR( "tools::App", "SDL Error: %s\n", SDL_GetError()) return false; } // Setup window - LOG_VERBOSE("fw::App", "setup SDL ...\n"); + LOG_VERBOSE("tools::App", "setup SDL ...\n"); SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); @@ -76,11 +76,11 @@ bool App::init() m_sdl_gl_context = SDL_GL_CreateContext(m_sdl_window); SDL_GL_SetSwapInterval( g_conf->vsync ? 1 : 0); - LOG_VERBOSE("fw::App", "gl3w init ...\n"); + LOG_VERBOSE("tools::App", "gl3w init ...\n"); gl3wInit(); // Setup Dear ImGui binding - LOG_VERBOSE("fw::App", "ImGui init ...\n"); + LOG_VERBOSE("tools::App", "ImGui init ...\n"); IMGUI_CHECKVERSION(); ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); (void)io; @@ -97,7 +97,7 @@ bool App::init() // Override ImGui's default Style // TODO: consider declaring new members in Config rather than modifying values from there. // see colors[ImGuiCol_Button] - LOG_VERBOSE("fw::App", "patch ImGui's style ...\n"); + LOG_VERBOSE("tools::App", "patch ImGui's style ...\n"); ImGuiStyle& style = ImGui::GetStyle(); ImVec4 * colors = style.Colors; colors[ImGuiCol_Text] = Vec4(0.20f, 0.20f, 0.20f, 1.00f); @@ -185,62 +185,62 @@ bool App::init() if (NFD_Init() != NFD_OKAY) { - LOG_ERROR("fw::App", "Unable to init NFD\n"); + LOG_ERROR("tools::App", "Unable to init NFD\n"); } - LOG_VERBOSE("fw::App", "state_changes.emit(ON_INIT) ...\n"); + LOG_VERBOSE("tools::App", "state_changes.emit(ON_INIT) ...\n"); on_init(); m_view->on_init(); - LOG_VERBOSE("fw::App", "init " OK "\n"); + LOG_VERBOSE("tools::App", "init " OK "\n"); return true; } void App::update() { - LOG_VERBOSE("fw::App", "update ...\n"); + LOG_VERBOSE("tools::App", "update ...\n"); handle_events(); - LOG_VERBOSE("fw::App", "state_changes.emit(ON_UPDATE) ...\n"); + LOG_VERBOSE("tools::App", "state_changes.emit(ON_UPDATE) ...\n"); on_update(); - LOG_VERBOSE("fw::App", "update " OK "\n"); + LOG_VERBOSE("tools::App", "update " OK "\n"); } bool App::shutdown() { bool success = true; - LOG_MESSAGE("fw::App", "Shutting down ...\n"); + LOG_MESSAGE("tools::App", "Shutting down ...\n"); success &= texture_manager.release_all(); - LOG_MESSAGE("fw::App", "Shutting down OpenGL3 ...\n"); + LOG_MESSAGE("tools::App", "Shutting down OpenGL3 ...\n"); ImGui_ImplOpenGL3_Shutdown(); - LOG_MESSAGE("fw::App", "Shutting down SDL2 ...\n"); + LOG_MESSAGE("tools::App", "Shutting down SDL2 ...\n"); ImGui_ImplSDL2_Shutdown(); - LOG_MESSAGE("fw::App", "Destroying ImGui context ...\n"); + LOG_MESSAGE("tools::App", "Destroying ImGui context ...\n"); ImGui::DestroyContext (); - LOG_MESSAGE("fw::App", "Shutdown SDL ...\n"); + LOG_MESSAGE("tools::App", "Shutdown SDL ...\n"); SDL_GL_DeleteContext (m_sdl_gl_context); SDL_DestroyWindow (m_sdl_window); SDL_Quit (); - LOG_MESSAGE("fw::App", "Quitting NFD (Native File Dialog) ...\n"); + LOG_MESSAGE("tools::App", "Quitting NFD (Native File Dialog) ...\n"); NFD_Quit(); - LOG_VERBOSE("fw::App", "state_changes.emit(App::ON_SHUTDOWN) ...\n"); + LOG_VERBOSE("tools::App", "state_changes.emit(App::ON_SHUTDOWN) ...\n"); on_shutdown(); - LOG_MESSAGE("fw::App", "Shutdown %s\n", success ? OK : KO) + LOG_MESSAGE("tools::App", "Shutdown %s\n", success ? OK : KO) return success; } void App::draw() { - LOG_VERBOSE("fw::App", "_draw_property_view ...\n"); + LOG_VERBOSE("tools::App", "_draw_property_view ...\n"); ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplSDL2_NewFrame(m_sdl_window); ImGui::NewFrame(); ImGuiEx::BeginFrame(); - LOG_VERBOSE("fw::App", "state_changes.emit(App::ON_DRAW) ...\n"); + LOG_VERBOSE("tools::App", "state_changes.emit(App::ON_DRAW) ...\n"); m_view->draw(); on_draw(); @@ -271,7 +271,7 @@ void App::draw() } SDL_GL_SwapWindow(m_sdl_window); - LOG_VERBOSE("fw::App", "_draw_property_view " OK "\n"); + LOG_VERBOSE("tools::App", "_draw_property_view " OK "\n"); } double App::elapsed_time() const @@ -281,8 +281,8 @@ double App::elapsed_time() const std::filesystem::path App::asset_path(const std::filesystem::path& _path) { - FW_EXPECT(!_path.is_absolute(), "_path is not relative, this can't be an asset") - auto executable_dir = fw::system::get_executable_directory(); + EXPECT(!_path.is_absolute(), "_path is not relative, this can't be an asset") + auto executable_dir = tools::system::get_executable_directory(); return executable_dir / "assets" / _path; } @@ -346,7 +346,7 @@ void App::handle_events() void App::save_screenshot(const char*_path) { - LOG_MESSAGE("fw::App", "Taking screenshot ...\n"); + LOG_MESSAGE("tools::App", "Taking screenshot ...\n"); int width, height; SDL_GetWindowSize(m_sdl_window, &width, &height); GLsizei stride = 4 * width; @@ -369,7 +369,7 @@ void App::save_screenshot(const char*_path) auto absolute_path = asset_path(_path); lodepng::save_file(out, absolute_path.string()); - LOG_MESSAGE("fw::App", "Taking screenshot OK (%s)\n", _path); + LOG_MESSAGE("tools::App", "Taking screenshot OK (%s)\n", _path); } bool App::is_fullscreen() const diff --git a/src/fw/gui/App.h b/src/tools/gui/App.h similarity index 98% rename from src/fw/gui/App.h rename to src/tools/gui/App.h index 5b9f7207c..841ed489c 100644 --- a/src/fw/gui/App.h +++ b/src/tools/gui/App.h @@ -7,7 +7,7 @@ #include -#include "fw/core/types.h" +#include "tools/core/types.h" #include "FontManager.h" #include "AppView.h" @@ -15,7 +15,7 @@ #include "EventManager.h" #include "ActionManager.h" -namespace fw +namespace tools { /* * Application Framework diff --git a/src/fw/gui/AppView.cpp b/src/tools/gui/AppView.cpp similarity index 95% rename from src/fw/gui/AppView.cpp rename to src/tools/gui/AppView.cpp index 5b98db73b..2f3bd7c05 100644 --- a/src/fw/gui/AppView.cpp +++ b/src/tools/gui/AppView.cpp @@ -2,8 +2,8 @@ #include -#include "fw/core/log.h" -#include "fw/core/system.h" +#include "tools/core/log.h" +#include "tools/core/system.h" #include "App.h" #include "Config.h" @@ -11,7 +11,7 @@ #include "TextureManager.h" #include "gui.h" -using namespace fw; +using namespace tools; constexpr const char* k_status_window_name = "Messages"; @@ -19,12 +19,12 @@ AppView::AppView(App * _app) : m_app(_app) , m_is_layout_initialized(false) { - LOG_VERBOSE("fw::AppView", "Constructor " OK "\n"); + LOG_VERBOSE("tools::AppView", "Constructor " OK "\n"); } AppView::~AppView() { - LOG_VERBOSE("fw::AppView", "Destructor " OK "\n"); + LOG_VERBOSE("tools::AppView", "Destructor " OK "\n"); } bool AppView::draw() @@ -163,10 +163,10 @@ bool AppView::pick_file_path(std::string& _out_path, DialogType _dialog_type) co NFD_FreePath(out_path); return true; case NFD_CANCEL: - LOG_MESSAGE("fw::AppView", "User pressed cancel."); + LOG_MESSAGE("tools::AppView", "User pressed cancel."); return false; default: - LOG_ERROR("fw::AppView", "%s\n", NFD_GetError()); + LOG_ERROR("tools::AppView", "%s\n", NFD_GetError()); return false; } } diff --git a/src/fw/gui/AppView.h b/src/tools/gui/AppView.h similarity index 98% rename from src/fw/gui/AppView.h rename to src/tools/gui/AppView.h index 8757d40da..db81d48ce 100644 --- a/src/fw/gui/AppView.h +++ b/src/tools/gui/AppView.h @@ -6,12 +6,12 @@ #include #include -#include "fw/core/types.h" +#include "tools/core/types.h" #include "ImGuiEx.h" #include "EventManager.h" #include "View.h" -namespace fw +namespace tools { // forward declarations class App; diff --git a/src/fw/gui/Config.h b/src/tools/gui/Config.h similarity index 95% rename from src/fw/gui/Config.h rename to src/tools/gui/Config.h index 7e23714f8..c9a21ff80 100644 --- a/src/fw/gui/Config.h +++ b/src/tools/gui/Config.h @@ -2,13 +2,13 @@ #include -#include "fw/core/Color.h" -#include "fw/core/geometry/Vec2.h" -#include "fw/core/geometry/Vec4.h" +#include "tools/core/Color.h" +#include "tools/core/geometry/Vec2.h" +#include "tools/core/geometry/Vec4.h" #include "FontManagerConfig.h" -namespace fw +namespace tools { // Framework configuration struct Config diff --git a/src/fw/gui/Event.h b/src/tools/gui/Event.h similarity index 96% rename from src/fw/gui/Event.h rename to src/tools/gui/Event.h index 1952d934a..811e08b36 100644 --- a/src/fw/gui/Event.h +++ b/src/tools/gui/Event.h @@ -1,8 +1,8 @@ #pragma once -#include "fw/core/types.h" +#include "tools/core/types.h" #include -namespace fw +namespace tools { typedef u16_t EventID; /** @@ -43,7 +43,7 @@ namespace fw /** Template to extend IEvent with a specific payload */ template - class Event : public fw::IEvent + class Event : public IEvent { public: constexpr static EventID id = id_value; diff --git a/src/tools/gui/EventManager.cpp b/src/tools/gui/EventManager.cpp new file mode 100644 index 000000000..4c8854fed --- /dev/null +++ b/src/tools/gui/EventManager.cpp @@ -0,0 +1,59 @@ +#include "EventManager.h" + +#include "tools/core/assertions.h" +#include "tools/core/async.h" +#include "tools/core/log.h" +#include "tools/core/reflection/type.h" + +using namespace tools; + +EventManager* EventManager::s_instance = nullptr; + +EventManager::~EventManager() +{ + LOG_VERBOSE("tools::EventManager", "Destructor ...\n"); + s_instance = nullptr; + LOG_VERBOSE("tools::EventManager", "Destructor " OK "\n"); +} +EventManager::EventManager() +{ + LOG_VERBOSE("tools::EventManager", "Constructor ...\n"); + EXPECT(!s_instance, "cannot have two instances at a time"); + s_instance = this; + LOG_VERBOSE("tools::EventManager", "Constructor " OK "\n"); +} + +EventManager& EventManager::get_instance() +{ + EXPECT(s_instance, "No instance found."); + return *s_instance; +} + +void EventManager::dispatch(IEvent* _event) +{ + m_events.push(_event); +} + +IEvent* EventManager::poll_event() +{ + if ( m_events.empty() ) + { + return nullptr; + } + + IEvent* next_event = m_events.front(); + m_events.pop(); + return next_event; +} + +IEvent* EventManager::dispatch( EventID _event_id ) +{ + auto new_event = new IEvent{ _event_id }; + dispatch(new_event ); + return new_event; +} + +void EventManager::dispatch_delayed(u64_t delay, IEvent* event) +{ + async::delay( [this, event, delay]() -> void { dispatch( event ); }, delay ); +} \ No newline at end of file diff --git a/src/fw/gui/EventManager.h b/src/tools/gui/EventManager.h similarity index 95% rename from src/fw/gui/EventManager.h rename to src/tools/gui/EventManager.h index ecb8984a7..9414518e9 100644 --- a/src/fw/gui/EventManager.h +++ b/src/tools/gui/EventManager.h @@ -6,13 +6,13 @@ #include #include -#include "fw/core/reflection/func_type.h" -#include "fw/core/types.h" +#include "tools/core/reflection/func_type.h" +#include "tools/core/types.h" #include "Action.h" #include "Event.h" -namespace fw +namespace tools { class EventManager { diff --git a/src/fw/gui/FontManager.cpp b/src/tools/gui/FontManager.cpp similarity index 93% rename from src/fw/gui/FontManager.cpp rename to src/tools/gui/FontManager.cpp index 2bc7117bc..48fcfe8e7 100644 --- a/src/fw/gui/FontManager.cpp +++ b/src/tools/gui/FontManager.cpp @@ -3,10 +3,10 @@ #include "Config.h" #include "gui.h" -using namespace fw; +using namespace tools; FontManager::~FontManager() -{ LOG_VERBOSE("fw::FontManager", "Destructor " OK "\n"); } +{ LOG_VERBOSE("tools::FontManager", "Destructor " OK "\n"); } void FontManager::init() { @@ -32,7 +32,7 @@ void FontManager::init() ImFont* FontManager::load_font(const FontConfig& text_font) { - FW_EXPECT(m_loaded_fonts.find(text_font.id) == m_loaded_fonts.end(), "use of same key for different fonts is not allowed"); + EXPECT(m_loaded_fonts.find(text_font.id) == m_loaded_fonts.end(), "use of same key for different fonts is not allowed"); ImFont* font = nullptr; auto& io = ImGui::GetIO(); diff --git a/src/fw/gui/FontManager.h b/src/tools/gui/FontManager.h similarity index 97% rename from src/fw/gui/FontManager.h rename to src/tools/gui/FontManager.h index dc68bee70..34ff8f41d 100644 --- a/src/fw/gui/FontManager.h +++ b/src/tools/gui/FontManager.h @@ -8,7 +8,7 @@ #include "FontManagerConfig.h" #include "ImGuiEx.h" -namespace fw +namespace tools { class FontManager { diff --git a/src/fw/gui/FontManagerConfig.h b/src/tools/gui/FontManagerConfig.h similarity index 94% rename from src/fw/gui/FontManagerConfig.h rename to src/tools/gui/FontManagerConfig.h index 899362ee0..573064556 100644 --- a/src/fw/gui/FontManagerConfig.h +++ b/src/tools/gui/FontManagerConfig.h @@ -1,7 +1,7 @@ #pragma once -#include "fw/core/reflection/reflection" +#include "tools/core/reflection/reflection" -namespace fw +namespace tools { struct FontConfig // Struct to store text_font configuration { diff --git a/src/fw/gui/ImGuiEx.cpp b/src/tools/gui/ImGuiEx.cpp similarity index 93% rename from src/fw/gui/ImGuiEx.cpp rename to src/tools/gui/ImGuiEx.cpp index fe184b9fd..13a505701 100644 --- a/src/fw/gui/ImGuiEx.cpp +++ b/src/tools/gui/ImGuiEx.cpp @@ -3,13 +3,13 @@ #include #include -#include "fw/core/log.h" -#include "fw/core/assertions.h" +#include "tools/core/log.h" +#include "tools/core/assertions.h" #include "Texture.h" #include "EventManager.h" -using namespace fw; +using namespace tools; Rect ImGuiEx::GetContentRegion(Space origin) { @@ -23,7 +23,7 @@ Rect ImGuiEx::GetContentRegion(Space origin) return region; } default: - FW_EXPECT(false,"OriginRef_ case not handled. Cannot compute GetContentRegion(..)") + EXPECT(false,"OriginRef_ case not handled. Cannot compute GetContentRegion(..)") } } @@ -164,7 +164,7 @@ bool ImGuiEx::BeginTooltip(float _delay, float _duration) { if ( !ImGui::IsItemHovered() ) return false; - FW_EXPECT( is_in_a_frame, "Did you forgot to call ImGuiEx::BeginFrame/EndFrame ?"); + EXPECT( is_in_a_frame, "Did you forgot to call ImGuiEx::BeginFrame/EndFrame ?"); is_any_tooltip_open = true; tooltip_delay_elapsed += ImGui::GetIO().DeltaTime; @@ -189,7 +189,7 @@ void ImGuiEx::EndTooltip() void ImGuiEx::EndFrame() { - FW_EXPECT( is_in_a_frame, "ImGuiEx::BeginFrame/EndFrame mismatch"); + EXPECT( is_in_a_frame, "ImGuiEx::BeginFrame/EndFrame mismatch"); if( !is_any_tooltip_open ) { tooltip_delay_elapsed = 0.f; @@ -199,7 +199,7 @@ void ImGuiEx::EndFrame() void ImGuiEx::BeginFrame() { - FW_EXPECT(!is_in_a_frame, "ImGuiEx::BeginFrame/EndFrame mismatch"); + EXPECT(!is_in_a_frame, "ImGuiEx::BeginFrame/EndFrame mismatch"); is_in_a_frame = true; is_any_tooltip_open = false; } @@ -212,7 +212,7 @@ void ImGuiEx::BulletTextWrapped(const char* str) void ImGuiEx::DebugRect(const Vec2& p_min, const Vec2& p_max, ImU32 col, float rounding, ImDrawFlags flags, float thickness) { -#ifdef FW_DEBUG +#ifdef TOOLS_DEBUG if(!debug) return; ImDrawList* list = ImGui::GetForegroundDrawList(); list->AddRect(p_min, p_max, col, rounding, flags, thickness); @@ -221,7 +221,7 @@ void ImGuiEx::DebugRect(const Vec2& p_min, const Vec2& p_max, ImU32 col, float r void ImGuiEx::DebugCircle(const Vec2& center, float radius, ImU32 col, int num_segments, float thickness) { -#ifdef FW_DEBUG +#ifdef TOOLS_DEBUG if(!debug) return; ImDrawList* list = ImGui::GetForegroundDrawList(); list->AddCircle(center, radius, col, num_segments, thickness); @@ -230,7 +230,7 @@ void ImGuiEx::DebugCircle(const Vec2& center, float radius, ImU32 col, int num_s void ImGuiEx::DebugLine(const Vec2& p1, const Vec2& p2, ImU32 col, float thickness) { -#ifdef FW_DEBUG +#ifdef TOOLS_DEBUG if(!debug) return; ImDrawList* list = ImGui::GetForegroundDrawList(); list->AddLine(p1, p2, col, thickness); diff --git a/src/fw/gui/ImGuiEx.h b/src/tools/gui/ImGuiEx.h similarity index 94% rename from src/fw/gui/ImGuiEx.h rename to src/tools/gui/ImGuiEx.h index 227bb4124..e7a9a2266 100644 --- a/src/fw/gui/ImGuiEx.h +++ b/src/tools/gui/ImGuiEx.h @@ -5,16 +5,16 @@ #include #include -#include "fw/core/geometry/Rect.h" -#include "fw/core/geometry/Vec2.h" -#include "fw/core/geometry/Vec4.h" -#include "fw/core/geometry/Space.h" -#include "fw/core/types.h" +#include "tools/core/geometry/Rect.h" +#include "tools/core/geometry/Vec2.h" +#include "tools/core/geometry/Vec4.h" +#include "tools/core/geometry/Space.h" +#include "tools/core/types.h" #include "ActionManager.h" #include "EventManager.h" -namespace fw +namespace tools { // forward declarations struct Texture; @@ -93,7 +93,7 @@ namespace fw extern void DebugRect(const Vec2& p_min, const Vec2& p_max, ImU32 col, float rounding = 0.f, ImDrawFlags flags = 0, float thickness = 1.f); extern void DebugCircle(const Vec2& center, float radius, ImU32 col, int num_segments = 0, float thickness = 1.0f); extern void DebugLine(const Vec2& p1, const Vec2& p2, ImU32 col, float thickness = 1.0f); - extern void Image(fw::Texture* ); + extern void Image(Texture*); template static void MenuItem(bool selected = false, bool enable = true) // Shorthand to get a given action from the manager and draw a MenuItem from it. diff --git a/src/fw/gui/ImGuiExConfig.h b/src/tools/gui/ImGuiExConfig.h similarity index 62% rename from src/fw/gui/ImGuiExConfig.h rename to src/tools/gui/ImGuiExConfig.h index 24a1b8bac..0afcf97bf 100644 --- a/src/fw/gui/ImGuiExConfig.h +++ b/src/tools/gui/ImGuiExConfig.h @@ -1,8 +1,8 @@ #pragma once -#include "fw/core/geometry/Vec2.h" -#include "fw/core/geometry/Vec4.h" -#include "fw/core/geometry/Box2D.h" +#include "tools/core/geometry/Vec2.h" +#include "tools/core/geometry/Vec4.h" +#include "tools/core/geometry/Box2D.h" //---- Use stb_truetype to build and rasterize the font atlas (default) // The only purpose of this define is if you want force compilation of the stb_truetype backend ALONG with the FreeType backend. @@ -12,12 +12,12 @@ // This will be inlined as part of ImVec2 and ImVec4 class declarations. #define IM_VEC2_CLASS_EXTRA \ - ImVec2( const fw::Vec2& v ): ImVec2(v.x, v.y) {} \ + ImVec2( const tools::Vec2& v ): ImVec2(v.x, v.y) {} \ ImVec2( const float f): ImVec2(f, f) {} \ - operator fw::Vec2() const { return {x,y}; } + operator tools::Vec2() const { return {x,y}; } #define IM_VEC4_CLASS_EXTRA \ - ImVec4(const fw::Vec4& v): ImVec4(v.x, v.y, v.z, v.w) {} \ - operator fw::Vec4() const { return {x,y,z,w}; } + ImVec4(const tools::Vec4& v): ImVec4(v.x, v.y, v.z, v.w) {} \ + operator tools::Vec4() const { return {x,y,z,w}; } #define IMGUI_DEFINE_MATH_OPERATORS \ No newline at end of file diff --git a/src/fw/gui/Texture.h b/src/tools/gui/Texture.h similarity index 90% rename from src/fw/gui/Texture.h rename to src/tools/gui/Texture.h index 499f97dcd..c46f05e96 100644 --- a/src/fw/gui/Texture.h +++ b/src/tools/gui/Texture.h @@ -2,10 +2,10 @@ #include "gl3w/GL/gl3w.h" -#include "fw/core/geometry/Vec2.h" -#include "fw/core/types.h" +#include "tools/core/geometry/Vec2.h" +#include "tools/core/types.h" -namespace fw +namespace tools { struct Texture // Simple data structure to store OpenGL texture information { diff --git a/src/fw/gui/TextureManager.cpp b/src/tools/gui/TextureManager.cpp similarity index 98% rename from src/fw/gui/TextureManager.cpp rename to src/tools/gui/TextureManager.cpp index bdf399d26..a104f3b19 100644 --- a/src/fw/gui/TextureManager.cpp +++ b/src/tools/gui/TextureManager.cpp @@ -7,10 +7,10 @@ #include #include -#include "fw/core/log.h" +#include "tools/core/log.h" #include "Texture.h" -using namespace fw; +using namespace tools; Texture* TextureManager::load(const std::string& path) { diff --git a/src/fw/gui/TextureManager.h b/src/tools/gui/TextureManager.h similarity index 98% rename from src/fw/gui/TextureManager.h rename to src/tools/gui/TextureManager.h index 4dfc925fd..26bc4d17f 100644 --- a/src/fw/gui/TextureManager.h +++ b/src/tools/gui/TextureManager.h @@ -4,7 +4,7 @@ #include #include -namespace fw +namespace tools { // forward declarations struct Texture; diff --git a/src/fw/gui/View.cpp b/src/tools/gui/View.cpp similarity index 98% rename from src/fw/gui/View.cpp rename to src/tools/gui/View.cpp index 96620dd02..5d3a207cd 100644 --- a/src/fw/gui/View.cpp +++ b/src/tools/gui/View.cpp @@ -1,7 +1,7 @@ #include "View.h" #include "ImGuiEx.h" -using namespace fw; +using namespace tools; REGISTER { diff --git a/src/fw/gui/View.h b/src/tools/gui/View.h similarity index 77% rename from src/fw/gui/View.h rename to src/tools/gui/View.h index c1b57f743..ccf48bd64 100644 --- a/src/fw/gui/View.h +++ b/src/tools/gui/View.h @@ -1,12 +1,12 @@ #pragma once -#include "fw/core/geometry/Box2D.h" -#include "fw/core/geometry/Rect.h" -#include "fw/core/reflection/reflection" +#include "tools/core/geometry/Box2D.h" +#include "tools/core/geometry/Rect.h" +#include "tools/core/reflection/reflection" #include "ImGuiEx.h" // ImGui with extensions -namespace fw +namespace tools { /** * View is an abstract class to provide a GUI for a specific Node. @@ -22,7 +22,7 @@ namespace fw virtual ~View() = default; bool draw(); virtual bool onDraw() = 0; - fw::Vec2 position(Space) const; // Get position in a given Space + tools::Vec2 position(Space) const; // Get position in a given Space void position(Vec2 _delta, Space ); // Set position in a given Space Rect rect(Space) const; // Get rectangle in a given Space void translate(Vec2 _delta); diff --git a/src/tools/gui/gui.cpp b/src/tools/gui/gui.cpp new file mode 100644 index 000000000..d97426d3d --- /dev/null +++ b/src/tools/gui/gui.cpp @@ -0,0 +1,25 @@ +#include "gui.h" +#include "tools/core/core.h" + +tools::Config* tools::g_conf{nullptr}; + +void tools::gui_init() +{ + LOG_MESSAGE("tools", "gui_init() ...\n"); + EXPECT( g_conf == nullptr, "tools::g_conf is already initialized\n") + g_conf = new Config(); + + Pool::init(); + LOG_MESSAGE("tools", "gui_init() OK\n"); +}; + +void tools::gui_shutdown() +{ + LOG_MESSAGE("tools", "gui_shutdown() ..\n"); + EXPECT( g_conf != nullptr, "tools::g_conf was not initialized, did you call tools::shutdown() twice?\n") + delete g_conf; + g_conf = nullptr; + + tools::core_shutdown(); + LOG_MESSAGE("tools", "gui_shutdown() OK\n"); +}; \ No newline at end of file diff --git a/src/tools/gui/gui.h b/src/tools/gui/gui.h new file mode 100644 index 000000000..4b2eb640e --- /dev/null +++ b/src/tools/gui/gui.h @@ -0,0 +1,9 @@ +#pragma once +#include "Config.h" + +namespace tools +{ + extern Config* g_conf; // Globally accessible configuration. Must be initialized with tools::init() before use; + void gui_init(); // Call before to use tools::gui + void gui_shutdown(); // Undo gui_init() +} \ No newline at end of file