#ifndef GODOT_H #define GODOT_H #include #include #include #include namespace godot { #define GODOT_CLASS(Name, Base) \ public: static char *___get_type_name() { return (char *) #Name; } \ static char *___get_base_type_name() { return (char *) #Base; } \ Name(godot_object *o) { __core_object = o; } \ private: // instance and destroy funcs template void *_godot_class_instance_func(godot_object *p) { T *d = new T(p); d->_init(); return d; } template void _godot_class_destroy_func(godot_object *p, void *data) { T *d = (T *) data; delete d; } template void register_class() { godot_script_register(T::___get_type_name(), T::___get_base_type_name(), _godot_class_instance_func, _godot_class_destroy_func); T::_register_methods(); } // wrapped methods template struct WrappedMethod5 { static godot_variant wrapped_method(godot_object *_, void *data, void *, int num_args, godot_variant **args) { godot_variant _variant; godot_variant_new_nil(&_variant); godot::Variant *v = (godot::Variant *) &_variant; T *obj = (T *) data; godot::Variant **arg = (godot::Variant **) args; *v = (obj->*p)(*arg[0], *arg[1], *arg[2], *arg[3], *arg[4]); return _variant; } }; template struct WrappedMethod5 { static godot_variant wrapped_method(godot_object *_, void *data, void *, int num_args, godot_variant **args) { godot_variant _variant; godot_variant_new_nil(&_variant); T *obj = (T *) data; godot::Variant **arg = (godot::Variant **) args; (obj->*p)(*arg[0], *arg[1], *arg[2], *arg[3], *arg[4]); return _variant; } }; template struct WrappedMethod4 { static godot_variant wrapped_method(godot_object *_, void *data, void *, int num_args, godot_variant **args) { godot_variant _variant; godot_variant_new_nil(&_variant); godot::Variant *v = (godot::Variant *) &_variant; T *obj = (T *) data; godot::Variant **arg = (godot::Variant **) args; *v = (obj->*p)(*arg[0], *arg[1], *arg[2], *arg[3]); return _variant; } }; template struct WrappedMethod4 { static godot_variant wrapped_method(godot_object *_, void *data, void *, int num_args, godot_variant **args) { godot_variant _variant; godot_variant_new_nil(&_variant); T *obj = (T *) data; godot::Variant **arg = (godot::Variant **) args; (obj->*p)(*arg[0], *arg[1], *arg[2], *arg[3]); return _variant; } }; template struct WrappedMethod3 { static godot_variant wrapped_method(godot_object *_, void *data, void *, int num_args, godot_variant **args) { godot_variant _variant; godot_variant_new_nil(&_variant); godot::Variant *v = (godot::Variant *) &_variant; T *obj = (T *) data; godot::Variant **arg = (godot::Variant **) args; *v = (obj->*p)(*arg[0], *arg[1], *arg[2]); return _variant; } }; template struct WrappedMethod3 { static godot_variant wrapped_method(godot_object *_, void *data, void *, int num_args, godot_variant **args) { godot_variant _variant; godot_variant_new_nil(&_variant); T *obj = (T *) data; godot::Variant **arg = (godot::Variant **) args; (obj->*p)(*arg[0], *arg[1], *arg[2]); return _variant; } }; template struct WrappedMethod2 { static godot_variant wrapped_method(godot_object *_, void *data, void *, int num_args, godot_variant **args) { godot_variant _variant; godot_variant_new_nil(&_variant); godot::Variant *v = (godot::Variant *) &_variant; T *obj = (T *) data; godot::Variant **arg = (godot::Variant **) args; *v = (obj->*p)(*arg[0], *arg[1]); return _variant; } }; template struct WrappedMethod2 { static godot_variant wrapped_method(godot_object *_, void *data, void *, int num_args, godot_variant **args) { godot_variant _variant; godot_variant_new_nil(&_variant); T *obj = (T *) data; godot::Variant **arg = (godot::Variant **) args; (obj->*p)(*arg[0], *arg[1]); return _variant; } }; template struct WrappedMethod1 { static godot_variant wrapped_method(godot_object *_, void *data, void *, int num_args, godot_variant **args) { godot_variant _variant; godot_variant_new_nil(&_variant); godot::Variant *v = (godot::Variant *) &_variant; T *obj = (T *) data; godot::Variant **arg = (godot::Variant **) args; *v = (obj->*p)(*arg[0]); return _variant; } }; template struct WrappedMethod1 { static godot_variant wrapped_method(godot_object *_, void *data, void *, int num_args, godot_variant **args) { godot_variant _variant; godot_variant_new_nil(&_variant); T *obj = (T *) data; godot::Variant **arg = (godot::Variant **) args; (obj->*p)(*arg[0]); return _variant; } }; template struct WrappedMethod0 { static godot_variant wrapped_method(godot_object *_, void *data, void *, int num_args, godot_variant **args) { godot_variant _variant; godot_variant_new_nil(&_variant); godot::Variant *v = (godot::Variant *) &_variant; T *obj = (T *) data; *v = (obj->*p)(); return _variant; } }; template struct WrappedMethod0 { static godot_variant wrapped_method(godot_object *_, void *data, void *, int num_args, godot_variant **args) { godot_variant _variant; godot_variant_new_nil(&_variant); T *obj = (T *) data; (obj->*p)(); return _variant; } }; // method registering template void register_method(char *name, godot_method_attributes attr = {}) { godot_script_add_method(T::___get_type_name(), name, &attr, &WrappedMethod0::wrapped_method); } template void register_method(char *name, godot_method_attributes attr = {}) { godot_script_add_method(T::___get_type_name(), name, &attr, &WrappedMethod1::wrapped_method); } template void register_method(char *name, godot_method_attributes attr = {}) { godot_script_add_method(T::___get_type_name(), name, &attr, &WrappedMethod2::wrapped_method); } template void register_method(char *name, godot_method_attributes attr = {}) { godot_script_add_method(T::___get_type_name(), name, &attr, &WrappedMethod3::wrapped_method); } template void register_method(char *name, godot_method_attributes attr = {}) { godot_script_add_method(T::___get_type_name(), name, &attr, &WrappedMethod4::wrapped_method); } template void register_method(char *name, godot_method_attributes attr = {}) { godot_script_add_method(T::___get_type_name(), name, &attr, &WrappedMethod5::wrapped_method); } } #endif // GODOT_H