You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Add grouping annotations for class properties in GDScript
This commit is contained in:
@@ -325,6 +325,7 @@ public:
|
||||
Vector<Variant> resolved_arguments;
|
||||
|
||||
AnnotationInfo *info = nullptr;
|
||||
PropertyInfo export_info;
|
||||
|
||||
bool apply(GDScriptParser *p_this, Node *p_target) const;
|
||||
bool applies_to(uint32_t p_target_kinds) const;
|
||||
@@ -500,6 +501,7 @@ public:
|
||||
VARIABLE,
|
||||
ENUM,
|
||||
ENUM_VALUE, // For unnamed enums.
|
||||
GROUP, // For member grouping.
|
||||
};
|
||||
|
||||
Type type = UNDEFINED;
|
||||
@@ -511,6 +513,7 @@ public:
|
||||
SignalNode *signal;
|
||||
VariableNode *variable;
|
||||
EnumNode *m_enum;
|
||||
AnnotationNode *annotation;
|
||||
};
|
||||
EnumNode::Value enum_value;
|
||||
|
||||
@@ -532,6 +535,8 @@ public:
|
||||
return "enum";
|
||||
case ENUM_VALUE:
|
||||
return "enum value";
|
||||
case GROUP:
|
||||
return "group";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -552,6 +557,8 @@ public:
|
||||
return m_enum->start_line;
|
||||
case SIGNAL:
|
||||
return signal->start_line;
|
||||
case GROUP:
|
||||
return annotation->start_line;
|
||||
case UNDEFINED:
|
||||
ERR_FAIL_V_MSG(-1, "Reaching undefined member type.");
|
||||
}
|
||||
@@ -586,6 +593,9 @@ public:
|
||||
// TODO: Add parameter info.
|
||||
return type;
|
||||
}
|
||||
case GROUP: {
|
||||
return DataType();
|
||||
}
|
||||
case UNDEFINED:
|
||||
return DataType();
|
||||
}
|
||||
@@ -622,6 +632,10 @@ public:
|
||||
type = ENUM_VALUE;
|
||||
enum_value = p_enum_value;
|
||||
}
|
||||
Member(AnnotationNode *p_annotation) {
|
||||
type = GROUP;
|
||||
annotation = p_annotation;
|
||||
}
|
||||
};
|
||||
|
||||
IdentifierNode *identifier = nullptr;
|
||||
@@ -668,6 +682,10 @@ public:
|
||||
members_indices[p_enum_value.identifier->name] = members.size();
|
||||
members.push_back(Member(p_enum_value));
|
||||
}
|
||||
void add_member_group(AnnotationNode *p_annotation_node) {
|
||||
members_indices[p_annotation_node->export_info.name] = members.size();
|
||||
members.push_back(Member(p_annotation_node));
|
||||
}
|
||||
|
||||
ClassNode() {
|
||||
type = CLASS;
|
||||
@@ -1238,6 +1256,7 @@ private:
|
||||
SIGNAL = 1 << 4,
|
||||
FUNCTION = 1 << 5,
|
||||
STATEMENT = 1 << 6,
|
||||
STANDALONE = 1 << 7,
|
||||
CLASS_LEVEL = CLASS | VARIABLE | FUNCTION,
|
||||
};
|
||||
uint32_t target_kind = 0; // Flags.
|
||||
@@ -1348,6 +1367,8 @@ private:
|
||||
bool onready_annotation(const AnnotationNode *p_annotation, Node *p_target);
|
||||
template <PropertyHint t_hint, Variant::Type t_type>
|
||||
bool export_annotations(const AnnotationNode *p_annotation, Node *p_target);
|
||||
template <PropertyUsageFlags t_usage>
|
||||
bool export_group_annotations(const AnnotationNode *p_annotation, Node *p_target);
|
||||
bool warning_annotations(const AnnotationNode *p_annotation, Node *p_target);
|
||||
template <Multiplayer::RPCMode t_mode>
|
||||
bool network_annotations(const AnnotationNode *p_annotation, Node *p_target);
|
||||
|
||||
Reference in New Issue
Block a user