Switch from Nz prefix to namespace Nz
What a huge commit Former-commit-id: 38ac5eebf70adc1180f571f6006192d28fb99897
This commit is contained in:
@@ -14,65 +14,68 @@
|
||||
#include <memory>
|
||||
//#include <type_traits>
|
||||
|
||||
template<class T/*, class P = void*/>
|
||||
class NzLuaClass
|
||||
namespace Nz
|
||||
{
|
||||
//static_assert(std::is_same<P, void>::value || std::is_base_of<P, T>::value, "P must be a base of T");
|
||||
template<class T/*, class P = void*/>
|
||||
class LuaClass
|
||||
{
|
||||
//static_assert(std::is_same<P, void>::value || std::is_base_of<P, T>::value, "P must be a base of T");
|
||||
|
||||
public:
|
||||
using ClassFunc = int (*)(NzLuaInstance& lua, T& instance);
|
||||
using ClassIndexFunc = bool (*)(NzLuaInstance& lua, T& instance);
|
||||
using ConstructorFunc = T* (*)(NzLuaInstance& lua);
|
||||
using FinalizerFunc = bool (*)(NzLuaInstance& lua, T& instance);
|
||||
using StaticIndexFunc = bool (*)(NzLuaInstance& lua);
|
||||
using StaticFunc = int (*)(NzLuaInstance& lua);
|
||||
public:
|
||||
using ClassFunc = int (*)(LuaInstance& lua, T& instance);
|
||||
using ClassIndexFunc = bool (*)(LuaInstance& lua, T& instance);
|
||||
using ConstructorFunc = T* (*)(LuaInstance& lua);
|
||||
using FinalizerFunc = bool (*)(LuaInstance& lua, T& instance);
|
||||
using StaticIndexFunc = bool (*)(LuaInstance& lua);
|
||||
using StaticFunc = int (*)(LuaInstance& lua);
|
||||
|
||||
NzLuaClass(const NzString& name);
|
||||
LuaClass(const String& name);
|
||||
|
||||
//void Inherit(NzLuaClass<P>& parent);
|
||||
//void Inherit(LuaClass<P>& parent);
|
||||
|
||||
void Register(NzLuaInstance& lua);
|
||||
void Register(LuaInstance& lua);
|
||||
|
||||
void PushGlobalTable(NzLuaInstance& lua);
|
||||
void PushGlobalTable(LuaInstance& lua);
|
||||
|
||||
void SetConstructor(ConstructorFunc constructor);
|
||||
void SetFinalizer(FinalizerFunc finalizer);
|
||||
void SetGetter(ClassIndexFunc getter);
|
||||
void SetMethod(const NzString& name, ClassFunc method);
|
||||
void SetSetter(ClassIndexFunc setter);
|
||||
void SetStaticGetter(StaticIndexFunc getter);
|
||||
void SetStaticMethod(const NzString& name, StaticFunc func);
|
||||
void SetStaticSetter(StaticIndexFunc getter);
|
||||
void SetConstructor(ConstructorFunc constructor);
|
||||
void SetFinalizer(FinalizerFunc finalizer);
|
||||
void SetGetter(ClassIndexFunc getter);
|
||||
void SetMethod(const String& name, ClassFunc method);
|
||||
void SetSetter(ClassIndexFunc setter);
|
||||
void SetStaticGetter(StaticIndexFunc getter);
|
||||
void SetStaticMethod(const String& name, StaticFunc func);
|
||||
void SetStaticSetter(StaticIndexFunc getter);
|
||||
|
||||
private:
|
||||
static int ConstructorProxy(lua_State* state);
|
||||
static int FinalizerProxy(lua_State* state);
|
||||
static int InfoDestructor(lua_State* state);
|
||||
static int GetterProxy(lua_State* state);
|
||||
static int MethodProxy(lua_State* state);
|
||||
static int SetterProxy(lua_State* state);
|
||||
static int StaticGetterProxy(lua_State* state);
|
||||
static int StaticMethodProxy(lua_State* state);
|
||||
static int StaticSetterProxy(lua_State* state);
|
||||
private:
|
||||
static int ConstructorProxy(lua_State* state);
|
||||
static int FinalizerProxy(lua_State* state);
|
||||
static int InfoDestructor(lua_State* state);
|
||||
static int GetterProxy(lua_State* state);
|
||||
static int MethodProxy(lua_State* state);
|
||||
static int SetterProxy(lua_State* state);
|
||||
static int StaticGetterProxy(lua_State* state);
|
||||
static int StaticMethodProxy(lua_State* state);
|
||||
static int StaticSetterProxy(lua_State* state);
|
||||
|
||||
struct ClassInfo
|
||||
{
|
||||
std::vector<ClassFunc> methods;
|
||||
std::vector<StaticFunc> staticMethods;
|
||||
ClassIndexFunc getter = nullptr;
|
||||
ClassIndexFunc setter = nullptr;
|
||||
ConstructorFunc constructor = nullptr;
|
||||
FinalizerFunc finalizer = nullptr;
|
||||
StaticIndexFunc staticGetter = nullptr;
|
||||
StaticIndexFunc staticSetter = nullptr;
|
||||
NzString name;
|
||||
int globalTableRef = -1;
|
||||
};
|
||||
struct ClassInfo
|
||||
{
|
||||
std::vector<ClassFunc> methods;
|
||||
std::vector<StaticFunc> staticMethods;
|
||||
ClassIndexFunc getter = nullptr;
|
||||
ClassIndexFunc setter = nullptr;
|
||||
ConstructorFunc constructor = nullptr;
|
||||
FinalizerFunc finalizer = nullptr;
|
||||
StaticIndexFunc staticGetter = nullptr;
|
||||
StaticIndexFunc staticSetter = nullptr;
|
||||
String name;
|
||||
int globalTableRef = -1;
|
||||
};
|
||||
|
||||
std::map<NzString, ClassFunc> m_methods;
|
||||
std::map<NzString, StaticFunc> m_staticMethods;
|
||||
std::shared_ptr<ClassInfo> m_info;
|
||||
};
|
||||
std::map<String, ClassFunc> m_methods;
|
||||
std::map<String, StaticFunc> m_staticMethods;
|
||||
std::shared_ptr<ClassInfo> m_info;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Lua/LuaClass.inl>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user