diff --git a/autogen/src/analysis.cpp b/autogen/src/analysis.cpp index 128d215..9423469 100644 --- a/autogen/src/analysis.cpp +++ b/autogen/src/analysis.cpp @@ -80,7 +80,8 @@ bool findInstanceAnnotation(CXCursor cur) { if (kind != CXCursor_AnnotateAttr) return CXChildVisit_Continue; std::string annString = x_clang_toString(clang_getCursorDisplayName(cur)); - if (annString == "OB::INSTANCE") found = true; + // if (annString == "OB::INSTANCE") found = true; + if (annString == "OB::def_inst") found = true; return CXChildVisit_Break; }); @@ -154,6 +155,19 @@ void processClass(CXCursor cur, AnalysisState* state, std::string className) { anly.name = className; anly.baseClass = baseClass; + + // Add misc flags and options + auto instanceDef = findAnnotation(cur, "OB::def_inst"); + auto result = parseAnnotationString(instanceDef.value()); + + if (result.count("service")) + anly.flags = anly.flags | ClassFlag_Service | ClassFlag_NotCreatable; + if (result.count("not_creatable")) + anly.flags = anly.flags | ClassFlag_NotCreatable; + if (result.count("hidden")) + anly.flags = anly.flags | ClassFlag_Hidden; + + anly.explorerIcon = result["explorer_icon"]; // Find annotated fields x_clang_visitChildren(cur, [&](CXCursor cur, CXCursor parent) { diff --git a/autogen/src/analysis.h b/autogen/src/analysis.h index bafeab2..5f08147 100644 --- a/autogen/src/analysis.h +++ b/autogen/src/analysis.h @@ -10,10 +10,23 @@ struct PropertyAnalysis { std::string backingFieldType; }; +enum ClassFlags { + ClassFlag_NotCreatable = 1<<0, + ClassFlag_Service = 1<<1, + ClassFlag_Hidden = 1<<2, +}; + +// https://stackoverflow.com/a/1448478/16255372 +inline ClassFlags operator|(ClassFlags a, ClassFlags b) { + return static_cast(static_cast(a) | static_cast(b)); +} + struct ClassAnalysis { std::string name; std::string baseClass; std::vector properties; + ClassFlags flags = (ClassFlags)0; + std::string explorerIcon; }; struct AnalysisState { diff --git a/autogen/src/main.cpp b/autogen/src/main.cpp index 8d2d7db..082a983 100644 --- a/autogen/src/main.cpp +++ b/autogen/src/main.cpp @@ -44,6 +44,16 @@ int main(int argc, char** argv) { printf("Class: %s\n", clazz.name.c_str()); if (clazz.baseClass != "") printf("==> Base class: %s\n", clazz.baseClass.c_str()); + if (clazz.explorerIcon != "") + printf("==> Explorer icon: %s\n", clazz.explorerIcon.c_str()); + printf("==> Flags (%x): ", clazz.flags); + if (clazz.flags & ClassFlag_Service) + printf("INSTANCE_SERVICE "); + if (clazz.flags & ClassFlag_NotCreatable) + printf("INSTANCE_NOT_CREATABLE "); + if (clazz.flags & ClassFlag_Hidden) + printf("INSTANCE_HIDDEN"); + printf("\n"); if (!clazz.properties.empty()) printf("==> Properties:\n"); diff --git a/core/src/objects/annotation.h b/core/src/objects/annotation.h index d1aecb6..1b7303f 100644 --- a/core/src/objects/annotation.h +++ b/core/src/objects/annotation.h @@ -2,6 +2,9 @@ // Markers for the autogen engine to generate getters, setters, lua, etc. -#define INSTANCE [[clang::annotate("OB::INSTANCE")]] +#define def_inst(...) clang::annotate("OB::def_inst", #__VA_ARGS__) -#define def_prop(...) clang::annotate("OB::def_prop", #__VA_ARGS__) \ No newline at end of file +#define def_prop(...) clang::annotate("OB::def_prop", #__VA_ARGS__) + +#define cframe_position_prop(...) clang::annotate("OB::cframe_position_prop", #__VA_ARGS__) +#define cframe_rotation_prop(...) clang::annotate("OB::cframe_rotation_prop", #__VA_ARGS__) \ No newline at end of file diff --git a/core/src/objects/part.h b/core/src/objects/part.h index 2406a7e..aa70932 100644 --- a/core/src/objects/part.h +++ b/core/src/objects/part.h @@ -28,7 +28,7 @@ struct PartConstructParams { class Snap; -class INSTANCE Part : public Instance { +class [[ def_inst(explorer_icon="part") ]] Part : public Instance { protected: // Joints where this part is Part0 std::vector> primaryJoints; @@ -51,24 +51,33 @@ public: const static InstanceType TYPE; Vector3 velocity; + [[ def_prop(name="cframe"), cframe_position_prop(name="Position"), cframe_rotation_prop(name="Rotation") ]] CFrame cframe; - [[ def_prop(name="Size") ]] + [[ def_prop(name="Size", category=PART) ]] glm::vec3 size; - [[ def_prop(name="Color") ]] + [[ def_prop(name="Color", category=APPEARANCE) ]] Color3 color; - [[ def_prop(name="Transparency") ]] + [[ def_prop(name="Transparency", category=APPEARANCE) ]] float transparency = 0.f; bool selected = false; + [[ def_prop(name="Anchored", category=BEHAVIOR) ]] bool anchored = false; + [[ def_prop(name="Locked", category=BEHAVIOR) ]] bool locked = false; rp::RigidBody* rigidBody = nullptr; + [[ def_prop(name="TopSurface", category=SURFACE) ]] SurfaceType topSurface = SurfaceType::SurfaceStuds; + [[ def_prop(name="BottomSurface", category=SURFACE) ]] SurfaceType bottomSurface = SurfaceType::SurfaceInlets; + [[ def_prop(name="LeftSurface", category=SURFACE) ]] SurfaceType leftSurface = SurfaceType::SurfaceSmooth; + [[ def_prop(name="RightSurface", category=SURFACE) ]] SurfaceType rightSurface = SurfaceType::SurfaceSmooth; + [[ def_prop(name="FrontSurface", category=SURFACE) ]] SurfaceType frontSurface = SurfaceType::SurfaceSmooth; + [[ def_prop(name="BackSurface", category=SURFACE) ]] SurfaceType backSurface = SurfaceType::SurfaceSmooth; Part();