StringName is working fine with demo \o/
parent
3b82d5937b
commit
b6ba0dca13
|
@ -397,6 +397,8 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
|
||||||
|
|
||||||
result.append("")
|
result.append("")
|
||||||
result.append("\tfriend class Variant;")
|
result.append("\tfriend class Variant;")
|
||||||
|
if class_name == "String":
|
||||||
|
result.append("\tfriend class StringName;")
|
||||||
|
|
||||||
result.append("")
|
result.append("")
|
||||||
result.append("\tstatic struct _MethodBindings {")
|
result.append("\tstatic struct _MethodBindings {")
|
||||||
|
@ -439,6 +441,7 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
|
||||||
|
|
||||||
result.append("")
|
result.append("")
|
||||||
result.append("\tstatic void init_bindings();")
|
result.append("\tstatic void init_bindings();")
|
||||||
|
result.append("\tstatic void _init_bindings_constructors_destructor();")
|
||||||
|
|
||||||
result.append("")
|
result.append("")
|
||||||
result.append("public:")
|
result.append("public:")
|
||||||
|
@ -675,7 +678,7 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
|
||||||
result.append(f"{class_name}::_MethodBindings {class_name}::_method_bindings;")
|
result.append(f"{class_name}::_MethodBindings {class_name}::_method_bindings;")
|
||||||
result.append("")
|
result.append("")
|
||||||
|
|
||||||
result.append(f"void {class_name}::init_bindings() {{")
|
result.append(f"void {class_name}::_init_bindings_constructors_destructor() {{")
|
||||||
|
|
||||||
if "constructors" in builtin_api:
|
if "constructors" in builtin_api:
|
||||||
for constructor in builtin_api["constructors"]:
|
for constructor in builtin_api["constructors"]:
|
||||||
|
@ -688,7 +691,16 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
|
||||||
f"\t_method_bindings.destructor = internal::gdn_interface->variant_get_ptr_destructor({enum_type_name});"
|
f"\t_method_bindings.destructor = internal::gdn_interface->variant_get_ptr_destructor({enum_type_name});"
|
||||||
)
|
)
|
||||||
|
|
||||||
result.append(f"StringName __name;")
|
result.append("}")
|
||||||
|
|
||||||
|
result.append(f"void {class_name}::init_bindings() {{")
|
||||||
|
|
||||||
|
# StringName's constructor internally uses String, so it constructor must be ready !
|
||||||
|
if class_name == "StringName":
|
||||||
|
result.append(f"\tString::_init_bindings_constructors_destructor();")
|
||||||
|
result.append(f"\t{class_name}::_init_bindings_constructors_destructor();")
|
||||||
|
|
||||||
|
result.append(f"\tStringName __name;")
|
||||||
|
|
||||||
if "methods" in builtin_api:
|
if "methods" in builtin_api:
|
||||||
for method in builtin_api["methods"]:
|
for method in builtin_api["methods"]:
|
||||||
|
|
|
@ -78,7 +78,7 @@ protected:
|
||||||
Wrapped(GodotObject *p_godot_object);
|
Wrapped(GodotObject *p_godot_object);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static StringName get_class_static() {
|
static StringName &get_class_static() {
|
||||||
static StringName string_name = StringName("Wrapped");
|
static StringName string_name = StringName("Wrapped");
|
||||||
return string_name;
|
return string_name;
|
||||||
}
|
}
|
||||||
|
@ -159,12 +159,12 @@ public:
|
||||||
initialized = true; \
|
initialized = true; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static StringName get_class_static() { \
|
static StringName &get_class_static() { \
|
||||||
static StringName string_name = StringName(#m_class); \
|
static StringName string_name = StringName(#m_class); \
|
||||||
return string_name; \
|
return string_name; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static StringName get_parent_class_static() { \
|
static StringName &get_parent_class_static() { \
|
||||||
return m_inherits::get_class_static(); \
|
return m_inherits::get_class_static(); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
|
@ -349,12 +349,12 @@ protected:
|
||||||
public: \
|
public: \
|
||||||
static void initialize_class() {} \
|
static void initialize_class() {} \
|
||||||
\
|
\
|
||||||
static StringName get_class_static() { \
|
static StringName &get_class_static() { \
|
||||||
static StringName string_name = StringName(#m_class); \
|
static StringName string_name = StringName(#m_class); \
|
||||||
return string_name; \
|
return string_name; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static StringName get_parent_class_static() { \
|
static StringName &get_parent_class_static() { \
|
||||||
return m_inherits::get_class_static(); \
|
return m_inherits::get_class_static(); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
|
|
|
@ -191,7 +191,7 @@ void ClassDB::_register_class(bool p_virtual) {
|
||||||
T::free, // GDNativeExtensionClassFreeInstance free_instance_func; /* this one is mandatory */
|
T::free, // GDNativeExtensionClassFreeInstance free_instance_func; /* this one is mandatory */
|
||||||
&ClassDB::get_virtual_func, // GDNativeExtensionClassGetVirtual get_virtual_func;
|
&ClassDB::get_virtual_func, // GDNativeExtensionClassGetVirtual get_virtual_func;
|
||||||
nullptr, // GDNativeExtensionClassGetRID get_rid;
|
nullptr, // GDNativeExtensionClassGetRID get_rid;
|
||||||
(void *)&cl.name, // void *class_userdata;
|
(void *)&T::get_class_static(), // void *class_userdata;
|
||||||
};
|
};
|
||||||
|
|
||||||
internal::gdn_interface->classdb_register_extension_class(internal::library, cl.name._native_ptr(), cl.parent_name._native_ptr(), &class_info);
|
internal::gdn_interface->classdb_register_extension_class(internal::library, cl.name._native_ptr(), cl.parent_name._native_ptr(), &class_info);
|
||||||
|
@ -249,7 +249,7 @@ MethodBind *ClassDB::bind_vararg_method(uint32_t p_flags, StringName p_name, M p
|
||||||
std::unordered_map<StringName, ClassInfo>::iterator type_it = classes.find(instance_type);
|
std::unordered_map<StringName, ClassInfo>::iterator type_it = classes.find(instance_type);
|
||||||
if (type_it == classes.end()) {
|
if (type_it == classes.end()) {
|
||||||
memdelete(bind);
|
memdelete(bind);
|
||||||
ERR_FAIL_V_MSG(nullptr, String("Class '{0}' doesn't exist.").format(instance_type));
|
ERR_FAIL_V_MSG(nullptr, String("Class '{0}' doesn't exist.").format(Array::make(instance_type)));
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassInfo &type = type_it->second;
|
ClassInfo &type = type_it->second;
|
||||||
|
|
|
@ -121,7 +121,7 @@ public:
|
||||||
std::vector<PropertyInfo> vec;
|
std::vector<PropertyInfo> vec;
|
||||||
// First element is return value
|
// First element is return value
|
||||||
vec.reserve(argument_count + 1);
|
vec.reserve(argument_count + 1);
|
||||||
for (int i = 0; i < argument_count; i++) {
|
for (int i = 0; i < argument_count + 1; i++) {
|
||||||
vec.push_back(get_argument_info(i - 1));
|
vec.push_back(get_argument_info(i - 1));
|
||||||
}
|
}
|
||||||
return vec;
|
return vec;
|
||||||
|
|
|
@ -115,7 +115,7 @@ void ClassDB::add_property(const StringName &p_class, const PropertyInfo &p_pinf
|
||||||
}
|
}
|
||||||
|
|
||||||
MethodBind *ClassDB::get_method(const StringName &p_class, const StringName &p_method) {
|
MethodBind *ClassDB::get_method(const StringName &p_class, const StringName &p_method) {
|
||||||
ERR_FAIL_COND_V_MSG(classes.find(p_class) == classes.end(), nullptr, String("Class '{0}' not found.").format(p_class));
|
ERR_FAIL_COND_V_MSG(classes.find(p_class) == classes.end(), nullptr, String("Class '{0}' not found.").format(Array::make(p_class)));
|
||||||
|
|
||||||
ClassInfo *type = &classes[p_class];
|
ClassInfo *type = &classes[p_class];
|
||||||
while (type) {
|
while (type) {
|
||||||
|
@ -136,7 +136,7 @@ MethodBind *ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind, const M
|
||||||
std::unordered_map<StringName, ClassInfo>::iterator type_it = classes.find(instance_type);
|
std::unordered_map<StringName, ClassInfo>::iterator type_it = classes.find(instance_type);
|
||||||
if (type_it == classes.end()) {
|
if (type_it == classes.end()) {
|
||||||
memdelete(p_bind);
|
memdelete(p_bind);
|
||||||
ERR_FAIL_V_MSG(nullptr, String("Class '{0}' doesn't exist.").format(instance_type));
|
ERR_FAIL_V_MSG(nullptr, String("Class '{0}' doesn't exist.").format(Array::make(instance_type)));
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassInfo &type = type_it->second;
|
ClassInfo &type = type_it->second;
|
||||||
|
@ -240,7 +240,7 @@ void ClassDB::bind_method_godot(const StringName &p_class_name, MethodBind *p_me
|
||||||
void ClassDB::add_signal(const StringName &p_class, const MethodInfo &p_signal) {
|
void ClassDB::add_signal(const StringName &p_class, const MethodInfo &p_signal) {
|
||||||
std::unordered_map<StringName, ClassInfo>::iterator type_it = classes.find(p_class);
|
std::unordered_map<StringName, ClassInfo>::iterator type_it = classes.find(p_class);
|
||||||
|
|
||||||
ERR_FAIL_COND_MSG(type_it == classes.end(), String("Class '{0}' doesn't exist.").format(p_class));
|
ERR_FAIL_COND_MSG(type_it == classes.end(), String("Class '{0}' doesn't exist.").format(Array::make(p_class)));
|
||||||
|
|
||||||
ClassInfo &cl = type_it->second;
|
ClassInfo &cl = type_it->second;
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ void ClassDB::add_signal(const StringName &p_class, const MethodInfo &p_signal)
|
||||||
void ClassDB::bind_integer_constant(const StringName &p_class_name, const StringName &p_enum_name, const StringName &p_constant_name, GDNativeInt p_constant_value, bool p_is_bitfield) {
|
void ClassDB::bind_integer_constant(const StringName &p_class_name, const StringName &p_enum_name, const StringName &p_constant_name, GDNativeInt p_constant_value, bool p_is_bitfield) {
|
||||||
std::unordered_map<StringName, ClassInfo>::iterator type_it = classes.find(p_class_name);
|
std::unordered_map<StringName, ClassInfo>::iterator type_it = classes.find(p_class_name);
|
||||||
|
|
||||||
ERR_FAIL_COND_MSG(type_it == classes.end(), String("Class '{0}' doesn't exist.").format(p_class_name));
|
ERR_FAIL_COND_MSG(type_it == classes.end(), String("Class '{0}' doesn't exist.").format(Array::make(p_class_name)));
|
||||||
|
|
||||||
ClassInfo &type = type_it->second;
|
ClassInfo &type = type_it->second;
|
||||||
|
|
||||||
|
@ -296,7 +296,7 @@ GDNativeExtensionClassCallVirtual ClassDB::get_virtual_func(void *p_userdata, co
|
||||||
const StringName *name = reinterpret_cast<const StringName *>(p_name);
|
const StringName *name = reinterpret_cast<const StringName *>(p_name);
|
||||||
|
|
||||||
std::unordered_map<StringName, ClassInfo>::iterator type_it = classes.find(*class_name);
|
std::unordered_map<StringName, ClassInfo>::iterator type_it = classes.find(*class_name);
|
||||||
ERR_FAIL_COND_V_MSG(type_it == classes.end(), nullptr, String("Class '{0}' doesn't exist.").format(*class_name));
|
ERR_FAIL_COND_V_MSG(type_it == classes.end(), nullptr, String("Class '{0}' doesn't exist.").format(Array::make(*class_name)));
|
||||||
|
|
||||||
const ClassInfo *type = &type_it->second;
|
const ClassInfo *type = &type_it->second;
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ GDNativeExtensionClassCallVirtual ClassDB::get_virtual_func(void *p_userdata, co
|
||||||
|
|
||||||
void ClassDB::bind_virtual_method(const StringName &p_class, const StringName &p_method, GDNativeExtensionClassCallVirtual p_call) {
|
void ClassDB::bind_virtual_method(const StringName &p_class, const StringName &p_method, GDNativeExtensionClassCallVirtual p_call) {
|
||||||
std::unordered_map<StringName, ClassInfo>::iterator type_it = classes.find(p_class);
|
std::unordered_map<StringName, ClassInfo>::iterator type_it = classes.find(p_class);
|
||||||
ERR_FAIL_COND_MSG(type_it == classes.end(), String("Class '{0}' doesn't exist.").format(p_class));
|
ERR_FAIL_COND_MSG(type_it == classes.end(), String("Class '{0}' doesn't exist.").format(Array::make(p_class)));
|
||||||
|
|
||||||
ClassInfo &type = type_it->second;
|
ClassInfo &type = type_it->second;
|
||||||
|
|
||||||
|
|
|
@ -49,8 +49,8 @@ void Variant::init_bindings() {
|
||||||
to_type_constructor[i] = internal::gdn_interface->get_variant_to_type_constructor((GDNativeVariantType)i);
|
to_type_constructor[i] = internal::gdn_interface->get_variant_to_type_constructor((GDNativeVariantType)i);
|
||||||
}
|
}
|
||||||
|
|
||||||
String::init_bindings();
|
|
||||||
StringName::init_bindings();
|
StringName::init_bindings();
|
||||||
|
String::init_bindings();
|
||||||
NodePath::init_bindings();
|
NodePath::init_bindings();
|
||||||
RID::init_bindings();
|
RID::init_bindings();
|
||||||
Callable::init_bindings();
|
Callable::init_bindings();
|
||||||
|
|
Loading…
Reference in New Issue