|
@@ -4092,7 +4092,7 @@ bool GDScriptParser::validate_annotation_arguments(AnnotationNode *p_annotation)
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
-bool GDScriptParser::tool_annotation(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class) {
|
|
|
|
|
|
+bool GDScriptParser::tool_annotation(AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class) {
|
|
#ifdef DEBUG_ENABLED
|
|
#ifdef DEBUG_ENABLED
|
|
if (_is_tool) {
|
|
if (_is_tool) {
|
|
push_error(R"("@tool" annotation can only be used once.)", p_annotation);
|
|
push_error(R"("@tool" annotation can only be used once.)", p_annotation);
|
|
@@ -4103,7 +4103,7 @@ bool GDScriptParser::tool_annotation(const AnnotationNode *p_annotation, Node *p
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
-bool GDScriptParser::icon_annotation(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class) {
|
|
|
|
|
|
+bool GDScriptParser::icon_annotation(AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class) {
|
|
ERR_FAIL_COND_V_MSG(p_target->type != Node::CLASS, false, R"("@icon" annotation can only be applied to classes.)");
|
|
ERR_FAIL_COND_V_MSG(p_target->type != Node::CLASS, false, R"("@icon" annotation can only be applied to classes.)");
|
|
ERR_FAIL_COND_V(p_annotation->resolved_arguments.is_empty(), false);
|
|
ERR_FAIL_COND_V(p_annotation->resolved_arguments.is_empty(), false);
|
|
|
|
|
|
@@ -4134,7 +4134,7 @@ bool GDScriptParser::icon_annotation(const AnnotationNode *p_annotation, Node *p
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
-bool GDScriptParser::onready_annotation(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class) {
|
|
|
|
|
|
+bool GDScriptParser::onready_annotation(AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class) {
|
|
ERR_FAIL_COND_V_MSG(p_target->type != Node::VARIABLE, false, R"("@onready" annotation can only be applied to class variables.)");
|
|
ERR_FAIL_COND_V_MSG(p_target->type != Node::VARIABLE, false, R"("@onready" annotation can only be applied to class variables.)");
|
|
|
|
|
|
if (current_class && !ClassDB::is_parent_class(current_class->get_datatype().native_type, SNAME("Node"))) {
|
|
if (current_class && !ClassDB::is_parent_class(current_class->get_datatype().native_type, SNAME("Node"))) {
|
|
@@ -4267,7 +4267,7 @@ static StringName _find_narrowest_native_or_global_class(const GDScriptParser::D
|
|
}
|
|
}
|
|
|
|
|
|
template <PropertyHint t_hint, Variant::Type t_type>
|
|
template <PropertyHint t_hint, Variant::Type t_type>
|
|
-bool GDScriptParser::export_annotations(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class) {
|
|
|
|
|
|
+bool GDScriptParser::export_annotations(AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class) {
|
|
ERR_FAIL_COND_V_MSG(p_target->type != Node::VARIABLE, false, vformat(R"("%s" annotation can only be applied to variables.)", p_annotation->name));
|
|
ERR_FAIL_COND_V_MSG(p_target->type != Node::VARIABLE, false, vformat(R"("%s" annotation can only be applied to variables.)", p_annotation->name));
|
|
ERR_FAIL_NULL_V(p_class, false);
|
|
ERR_FAIL_NULL_V(p_class, false);
|
|
|
|
|
|
@@ -4506,7 +4506,7 @@ bool GDScriptParser::export_annotations(const AnnotationNode *p_annotation, Node
|
|
// For `@export_storage` and `@export_custom`, there is no need to check the variable type, argument values,
|
|
// For `@export_storage` and `@export_custom`, there is no need to check the variable type, argument values,
|
|
// or handle array exports in a special way, so they are implemented as separate methods.
|
|
// or handle array exports in a special way, so they are implemented as separate methods.
|
|
|
|
|
|
-bool GDScriptParser::export_storage_annotation(const AnnotationNode *p_annotation, Node *p_node, ClassNode *p_class) {
|
|
|
|
|
|
+bool GDScriptParser::export_storage_annotation(AnnotationNode *p_annotation, Node *p_node, ClassNode *p_class) {
|
|
ERR_FAIL_COND_V_MSG(p_node->type != Node::VARIABLE, false, vformat(R"("%s" annotation can only be applied to variables.)", p_annotation->name));
|
|
ERR_FAIL_COND_V_MSG(p_node->type != Node::VARIABLE, false, vformat(R"("%s" annotation can only be applied to variables.)", p_annotation->name));
|
|
|
|
|
|
VariableNode *variable = static_cast<VariableNode *>(p_node);
|
|
VariableNode *variable = static_cast<VariableNode *>(p_node);
|
|
@@ -4528,7 +4528,7 @@ bool GDScriptParser::export_storage_annotation(const AnnotationNode *p_annotatio
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
-bool GDScriptParser::export_custom_annotation(const AnnotationNode *p_annotation, Node *p_node, ClassNode *p_class) {
|
|
|
|
|
|
+bool GDScriptParser::export_custom_annotation(AnnotationNode *p_annotation, Node *p_node, ClassNode *p_class) {
|
|
ERR_FAIL_COND_V_MSG(p_node->type != Node::VARIABLE, false, vformat(R"("%s" annotation can only be applied to variables.)", p_annotation->name));
|
|
ERR_FAIL_COND_V_MSG(p_node->type != Node::VARIABLE, false, vformat(R"("%s" annotation can only be applied to variables.)", p_annotation->name));
|
|
ERR_FAIL_COND_V_MSG(p_annotation->resolved_arguments.size() < 2, false, R"(Annotation "@export_custom" requires 2 arguments.)");
|
|
ERR_FAIL_COND_V_MSG(p_annotation->resolved_arguments.size() < 2, false, R"(Annotation "@export_custom" requires 2 arguments.)");
|
|
|
|
|
|
@@ -4557,31 +4557,29 @@ bool GDScriptParser::export_custom_annotation(const AnnotationNode *p_annotation
|
|
}
|
|
}
|
|
|
|
|
|
template <PropertyUsageFlags t_usage>
|
|
template <PropertyUsageFlags t_usage>
|
|
-bool GDScriptParser::export_group_annotations(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class) {
|
|
|
|
- AnnotationNode *annotation = const_cast<AnnotationNode *>(p_annotation);
|
|
|
|
-
|
|
|
|
- if (annotation->resolved_arguments.is_empty()) {
|
|
|
|
|
|
+bool GDScriptParser::export_group_annotations(AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class) {
|
|
|
|
+ if (p_annotation->resolved_arguments.is_empty()) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
- annotation->export_info.name = annotation->resolved_arguments[0];
|
|
|
|
|
|
+ p_annotation->export_info.name = p_annotation->resolved_arguments[0];
|
|
|
|
|
|
switch (t_usage) {
|
|
switch (t_usage) {
|
|
case PROPERTY_USAGE_CATEGORY: {
|
|
case PROPERTY_USAGE_CATEGORY: {
|
|
- annotation->export_info.usage = t_usage;
|
|
|
|
|
|
+ p_annotation->export_info.usage = t_usage;
|
|
} break;
|
|
} break;
|
|
|
|
|
|
case PROPERTY_USAGE_GROUP: {
|
|
case PROPERTY_USAGE_GROUP: {
|
|
- annotation->export_info.usage = t_usage;
|
|
|
|
- if (annotation->resolved_arguments.size() == 2) {
|
|
|
|
- annotation->export_info.hint_string = annotation->resolved_arguments[1];
|
|
|
|
|
|
+ p_annotation->export_info.usage = t_usage;
|
|
|
|
+ if (p_annotation->resolved_arguments.size() == 2) {
|
|
|
|
+ p_annotation->export_info.hint_string = p_annotation->resolved_arguments[1];
|
|
}
|
|
}
|
|
} break;
|
|
} break;
|
|
|
|
|
|
case PROPERTY_USAGE_SUBGROUP: {
|
|
case PROPERTY_USAGE_SUBGROUP: {
|
|
- annotation->export_info.usage = t_usage;
|
|
|
|
- if (annotation->resolved_arguments.size() == 2) {
|
|
|
|
- annotation->export_info.hint_string = annotation->resolved_arguments[1];
|
|
|
|
|
|
+ p_annotation->export_info.usage = t_usage;
|
|
|
|
+ if (p_annotation->resolved_arguments.size() == 2) {
|
|
|
|
+ p_annotation->export_info.hint_string = p_annotation->resolved_arguments[1];
|
|
}
|
|
}
|
|
} break;
|
|
} break;
|
|
}
|
|
}
|
|
@@ -4589,7 +4587,7 @@ bool GDScriptParser::export_group_annotations(const AnnotationNode *p_annotation
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
-bool GDScriptParser::warning_annotations(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class) {
|
|
|
|
|
|
+bool GDScriptParser::warning_annotations(AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class) {
|
|
#ifndef DEBUG_ENABLED
|
|
#ifndef DEBUG_ENABLED
|
|
// Only available in debug builds.
|
|
// Only available in debug builds.
|
|
return true;
|
|
return true;
|
|
@@ -4664,7 +4662,7 @@ bool GDScriptParser::warning_annotations(const AnnotationNode *p_annotation, Nod
|
|
#endif // DEBUG_ENABLED
|
|
#endif // DEBUG_ENABLED
|
|
}
|
|
}
|
|
|
|
|
|
-bool GDScriptParser::rpc_annotation(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class) {
|
|
|
|
|
|
+bool GDScriptParser::rpc_annotation(AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class) {
|
|
ERR_FAIL_COND_V_MSG(p_target->type != Node::FUNCTION, false, vformat(R"("%s" annotation can only be applied to functions.)", p_annotation->name));
|
|
ERR_FAIL_COND_V_MSG(p_target->type != Node::FUNCTION, false, vformat(R"("%s" annotation can only be applied to functions.)", p_annotation->name));
|
|
|
|
|
|
FunctionNode *function = static_cast<FunctionNode *>(p_target);
|
|
FunctionNode *function = static_cast<FunctionNode *>(p_target);
|
|
@@ -4725,7 +4723,7 @@ bool GDScriptParser::rpc_annotation(const AnnotationNode *p_annotation, Node *p_
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
-bool GDScriptParser::static_unload_annotation(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class) {
|
|
|
|
|
|
+bool GDScriptParser::static_unload_annotation(AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class) {
|
|
ERR_FAIL_COND_V_MSG(p_target->type != Node::CLASS, false, vformat(R"("%s" annotation can only be applied to classes.)", p_annotation->name));
|
|
ERR_FAIL_COND_V_MSG(p_target->type != Node::CLASS, false, vformat(R"("%s" annotation can only be applied to classes.)", p_annotation->name));
|
|
ClassNode *class_node = static_cast<ClassNode *>(p_target);
|
|
ClassNode *class_node = static_cast<ClassNode *>(p_target);
|
|
if (class_node->annotated_static_unload) {
|
|
if (class_node->annotated_static_unload) {
|