Merge pull request #162 from BastiaanOlij/fix_subclass

Fixed GODOT_SUBCLASS macro
pull/164/head
Thomas Herzog 2018-07-30 14:59:49 +02:00 committed by GitHub
commit 6d48282187
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -46,10 +46,12 @@ T *get_wrapper(godot_object *obj)
#define GODOT_SUBCLASS(Name, Base) \ #define GODOT_SUBCLASS(Name, Base) \
public: inline static const char *___get_type_name() { return static_cast<const char *>(#Name); } \ public: inline static const char *___get_type_name() { return static_cast<const char *>(#Name); } \
inline static const char *___get_base_type_name() { return static_cast<const char *>(#Base); } \ enum { ___CLASS_IS_SCRIPT = 1, }; \
inline static Name *_new() { godot::NativeScript *script = godot::NativeScript::_new(); script->set_library(godot::get_wrapper<godot::GDNativeLibrary>((godot_object *) godot::gdnlib)); script->set_class_name(#Name); Name *instance = godot::as<Name>(script->new_()); return instance; } \
inline static const char *___get_base_type_name() { return #Base; } \
inline static Object *___get_from_variant(godot::Variant a) { return (godot::Object *) godot::as<Name>(godot::Object::___get_from_variant(a)); } \
private: private:
template<class T> template<class T>
struct _ArgCast { struct _ArgCast {
static T _arg_cast(Variant a) static T _arg_cast(Variant a)