made script "inheritance" less OOP

This commit is contained in:
Karroffel
2017-05-13 13:55:04 +02:00
parent cf30b0f39d
commit fad8f7c9eb
6 changed files with 84 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
#ifndef GODOT_H
#define GODOT_H
#ifndef GODOT_HPP
#define GODOT_HPP
#include <cstdlib>
@@ -11,9 +11,30 @@
#include <Object.hpp>
#include <GodotGlobal.hpp>
namespace godot {
template<class T>
class GodotScript {
public:
T *owner;
// GodotScript() {}
void _init() {}
static char *___get_base_type_name()
{
return T::___get_class_name();
}
static void _register_methods() {}
};
#if !defined(_WIN32)
@@ -28,11 +49,8 @@ namespace godot {
#define GODOT_CLASS(Name, Base) \
#define GODOT_CLASS(Name) \
public: inline static char *___get_type_name() { return (char *) #Name; } \
inline static char *___get_base_type_name() { return (char *) #Base; } \
Base *self; \
inline Name(godot_object *o) { self = (Base *) o; } \
private:
#define GODOT_SUBCLASS(Name, Base) \
@@ -73,7 +91,8 @@ T *as(Object *obj)
template<class T>
void *_godot_class_instance_func(godot_object *p, void *method_data)
{
T *d = new T(p);
T *d = new T();
*(godot_object **) &d->owner = p;
d->_init();
return d;
}

View File

@@ -0,0 +1,30 @@
#ifndef GODOT_GLOBAL_HPP
#define GODOT_GLOBAL_HPP
#if defined(_WIN32)
# ifdef _GD_CPP_CORE_API_IMPL
# define GD_CPP_CORE_API __declspec(dllexport)
# else
# define GD_CPP_CORE_API __declspec(dllimport)
# endif
#else
# define GD_CPP_CORE_API
#endif
#include "String.hpp"
namespace godot {
class GD_CPP_CORE_API Godot {
public:
static void print(const String& message);
static void print_warning(const String& description, const String& function, const String& file, int line);
static void print_error(const String& description, const String& function, const String& file, int line);
};
}
#endif