new macros for entry points, virtual method fix
parent
8aaef5a6a2
commit
63c2b9d474
|
@ -270,7 +270,7 @@ fn generate_class_header(used_classes: &HashSet<&String>, class: &GodotClass) ->
|
|||
}
|
||||
|
||||
for method in &class.methods {
|
||||
contents = contents + "\t" + (if class.singleton { "static " } else if method.is_virtual { "virtual " } else { "" }) + strip_name(&method.return_type) + (if !is_core_type(&method.return_type) && !is_primitive(&method.return_type) { " *" } else { " " }) + escape_cpp(&method.name) + "(";
|
||||
contents = contents + "\t" + (if class.singleton { "static " } else { "" }) + strip_name(&method.return_type) + (if !is_core_type(&method.return_type) && !is_primitive(&method.return_type) { " *" } else { " " }) + escape_cpp(&method.name) + "(";
|
||||
|
||||
let mut has_default = false;
|
||||
|
||||
|
@ -425,6 +425,23 @@ fn generate_class_implementation(icalls: &mut HashSet<(String, Vec<String>)>, us
|
|||
contents = contents + "\t}\n\n";
|
||||
}
|
||||
|
||||
if method.is_virtual {
|
||||
|
||||
contents = contents + "\tArray __args;\n";
|
||||
|
||||
// fill in the args
|
||||
for arg in &method.arguments {
|
||||
contents = contents + "\t__args.append(" + escape_cpp(&arg.name) + ");\n";
|
||||
}
|
||||
|
||||
contents = contents + "\t";
|
||||
|
||||
if method.return_type != "void" {
|
||||
contents = contents + "return ";
|
||||
}
|
||||
|
||||
contents = contents + "((Object *) " + core_obj_name.as_str() + ")->callv(\"" + method.name.as_str() + "\", __args);\n";
|
||||
} else {
|
||||
contents = contents + "\tstatic godot_method_bind *mb = NULL;\n"
|
||||
+ "\tif (mb == NULL) {\n"
|
||||
+ "\t\tmb = godot_method_bind_get_method(\"" + class.name.as_str() + "\", \"" + method.name.as_str() + "\");\n"
|
||||
|
@ -459,7 +476,6 @@ fn generate_class_implementation(icalls: &mut HashSet<(String, Vec<String>)>, us
|
|||
icalls.insert(icallsig);
|
||||
|
||||
|
||||
|
||||
contents = contents + name.as_str() + "(mb, (godot_object *) " + core_obj_name.as_str();
|
||||
|
||||
for arg in &method.arguments {
|
||||
|
@ -470,6 +486,7 @@ fn generate_class_implementation(icalls: &mut HashSet<(String, Vec<String>)>, us
|
|||
// contents = contents + ")";
|
||||
// }
|
||||
contents = contents + ");\n";
|
||||
}
|
||||
|
||||
contents = contents + "}\n\n";
|
||||
}
|
||||
|
|
|
@ -12,6 +12,20 @@
|
|||
namespace godot {
|
||||
|
||||
|
||||
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#define GD_EXPORT
|
||||
#else
|
||||
#define GD_EXPORT __declspec(dllexport)
|
||||
#endif
|
||||
|
||||
|
||||
#define GODOT_DLSCRIPT_INIT(arg) extern "C" void GD_EXPORT godot_dlscript_init(arg)
|
||||
#define GODOT_DLSCRIPT_TERMINATE(arg) extern "C" void GD_EXPORT godot_dlscript_terminate(arg)
|
||||
|
||||
|
||||
|
||||
#define GODOT_CLASS(Name, Base) \
|
||||
public: inline static char *___get_type_name() { return (char *) #Name; } \
|
||||
inline static char *___get_base_type_name() { return (char *) #Base; } \
|
||||
|
|
Loading…
Reference in New Issue