Allow Nodes, Resources, and TypedArrays to be exported #19
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR completes REG_PROPERTY's missing functionalities by allowing Nodes, Resources, and TypedArrays to be exported. #16 and #17 are addressed as well.
To accomodate for REG_PROPERTY's new features, its meta properties have been refactored.
REG_P_HintType
andREG_P_HintString
replaceREG_P_Info
, improving readability.REG_P_UsageFlags
lets developers specifyPropertyUsageFlags
, a constexpr made up of bitflags OR'd together. This is passed intoPropertyInfo
verbatim.REG_P_ExportAsNode
andREG_P_ExportAsResource
tell RegAutomation to treat the property as aNode
or aResource
type. It is theoretically possible to parse godot-cpp headers to figure out which types inherit fromNode
and which inherit fromResource
, but this will lead to a huge amount of overhead and add a lot of code complexity, which is why this solution is picked.A new class called
PropertyBinder
is extracted fromPattern_Property
to handle binding logic. No tests are written for it yet, butexample.h
has been updated to feature demonstrations of the new features.Test_PropertyParser
on the other hand has been updated to make sure it can properly extract information from the REG_PROPERTY macro.A notable difference between
PropertyBinder
and the previousPattern_Property
is that the mapping from C++ classes to Godot Variant enums is now a handwrittenDictionary
. This is more maintainable than relying on naming patterns, and allows us to add in additional aliases as needed.Lastly, the current implementation has just one limitation: It can't handle multidimensional arrays yet. The reasons are as follows:
TypedArray<T>
is just not supported by Godot at the moment. It won't compile.Array
on the C++ end, relying on PropertyHint and the right hint string to make the array appear as a typed multidimensional array to GDScript. However, the hint string in this situation would need to insert raw values of Variant enums, which is not possible with a mere C++ string literal.The README has been updated with REG_PROPERTY's new features and the above limitation, along with a suggested workaround.