Added Variant constructor for Object types
parent
fe4f8b9581
commit
c40a9dce51
|
@ -197,6 +197,7 @@ fn generate_class_header(used_classes: &HashSet<&String>, class: &GodotClass) ->
|
||||||
// object constructor
|
// object constructor
|
||||||
if !class.singleton {
|
if !class.singleton {
|
||||||
contents = contents + "\t" + strip_name(&class.name) + "(const Object& ptr);\n\n";
|
contents = contents + "\t" + strip_name(&class.name) + "(const Object& ptr);\n\n";
|
||||||
|
contents = contents + "\t" + strip_name(&class.name) + "(const Variant& obj);\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// object cast
|
// object cast
|
||||||
|
@ -325,6 +326,10 @@ fn generate_class_implementation(icalls: &mut HashSet<(String, Vec<String>)>, us
|
||||||
contents = contents + "" + strip_name(&class.name) + "::" + strip_name(&class.name) + "(const Object& ptr)\n{\n";
|
contents = contents + "" + strip_name(&class.name) + "::" + strip_name(&class.name) + "(const Object& ptr)\n{\n";
|
||||||
contents = contents + "\t__core_object = ptr.__core_object;\n";
|
contents = contents + "\t__core_object = ptr.__core_object;\n";
|
||||||
contents = contents + "}\n\n\n";
|
contents = contents + "}\n\n\n";
|
||||||
|
|
||||||
|
contents = contents + "" + strip_name(&class.name) + "::" + strip_name(&class.name) + "(const Variant& obj)\n{\n";
|
||||||
|
contents = contents + "\t__core_object = ((Object) obj).__core_object;\n";
|
||||||
|
contents = contents + "}\n\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Object constructor
|
// Object constructor
|
||||||
|
|
|
@ -13,9 +13,10 @@ namespace godot {
|
||||||
|
|
||||||
|
|
||||||
#define GODOT_CLASS(Name, Base) \
|
#define GODOT_CLASS(Name, Base) \
|
||||||
public: static char *___get_type_name() { return (char *) #Name; } \
|
public: inline static char *___get_type_name() { return (char *) #Name; } \
|
||||||
static char *___get_base_type_name() { return (char *) #Base; } \
|
inline static char *___get_base_type_name() { return (char *) #Base; } \
|
||||||
Name(godot_object *o) { __core_object = o; } \
|
inline Name(godot_object *o) { __core_object = o; } \
|
||||||
|
inline Name(const Variant& obj) { __core_object = ((Object) obj).__core_object; } \
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
@ -539,7 +540,6 @@ void register_property(char *name, void (T::*setter)(P), P (T::*getter)(), P def
|
||||||
attr.type = def_val.get_type();
|
attr.type = def_val.get_type();
|
||||||
attr.default_value = *(godot_variant *) &def_val;
|
attr.default_value = *(godot_variant *) &def_val;
|
||||||
attr.hint = hint;
|
attr.hint = hint;
|
||||||
attr.listed = true;
|
|
||||||
attr.rset_type = rpc_mode;
|
attr.rset_type = rpc_mode;
|
||||||
attr.usage = usage;
|
attr.usage = usage;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue