|
@@ -25,55 +25,18 @@
|
|
|
#include "tolua++.h"
|
|
#include "tolua++.h"
|
|
|
#include "tolua++urho3d.h"
|
|
#include "tolua++urho3d.h"
|
|
|
|
|
|
|
|
-const char* tolua_tourho3dstring(lua_State* L, int narg, const char* def)
|
|
|
|
|
|
|
+const char* tolua_tourho3dstring(lua_State* L, int narg, const char* str)
|
|
|
{
|
|
{
|
|
|
- const char* s = tolua_tostring(L, narg, def);
|
|
|
|
|
|
|
+ const char* s = tolua_tostring(L, narg, str);
|
|
|
return s ? s : "";
|
|
return s ? s : "";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const char* tolua_tourho3dstring(lua_State* L, int narg, const String& def)
|
|
|
|
|
|
|
+const char* tolua_tourho3dstring(lua_State* L, int narg, const String& str)
|
|
|
{
|
|
{
|
|
|
- return tolua_tourho3dstring(L, narg, def.CString());
|
|
|
|
|
|
|
+ return tolua_tourho3dstring(L, narg, str.CString());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-int tolua_pushurho3dconstpodvectorintvector2(lua_State* L, void* data, const char* type)
|
|
|
|
|
-{
|
|
|
|
|
-#ifndef TOLUA_RELEASE
|
|
|
|
|
- assert(strcmp(type, "const PODVector<IntVector2>") == 0);
|
|
|
|
|
-#endif
|
|
|
|
|
-
|
|
|
|
|
- const PODVector<IntVector2>& vector = *((const PODVector<IntVector2>*)data);
|
|
|
|
|
- lua_newtable(L);
|
|
|
|
|
- for (unsigned i = 0; i < vector.Size(); ++i)
|
|
|
|
|
- {
|
|
|
|
|
- void* tolua_obj = Mtolua_new((IntVector2)(vector[i]));
|
|
|
|
|
- tolua_pushusertype(L,tolua_obj,"IntVector2");
|
|
|
|
|
- tolua_register_gc(L,lua_gettop(L));
|
|
|
|
|
-
|
|
|
|
|
- lua_rawseti(L, -2, i + 1);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return 1;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-int tolua_pushurho3dpodvectoruielement(lua_State* L, void* data, const char* type)
|
|
|
|
|
-{
|
|
|
|
|
-#ifndef TOLUA_RELEASE
|
|
|
|
|
- assert(strcmp(type, "const PODVector<UIElement*>") == 0);
|
|
|
|
|
-#endif
|
|
|
|
|
-
|
|
|
|
|
- const PODVector<UIElement*>& vector = *((const PODVector<UIElement*>*)data);
|
|
|
|
|
- lua_newtable(L);
|
|
|
|
|
- for (unsigned i = 0; i < vector.Size(); ++i)
|
|
|
|
|
- {
|
|
|
|
|
- tolua_pushusertype(L, vector[i], "UIElement");
|
|
|
|
|
- lua_rawseti(L, -2, i + 1);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return 1;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-int tolua_isurho3dconstpodvectorunsigned(lua_State* L, int lo, const char* type, int def, tolua_Error* err)
|
|
|
|
|
|
|
+template<> int tolua_isurho3dvector<String>(lua_State* L, int lo, const char* type, int def, tolua_Error* err)
|
|
|
{
|
|
{
|
|
|
if (lua_istable(L, lo))
|
|
if (lua_istable(L, lo))
|
|
|
{
|
|
{
|
|
@@ -82,7 +45,7 @@ int tolua_isurho3dconstpodvectorunsigned(lua_State* L, int lo, const char* type,
|
|
|
{
|
|
{
|
|
|
lua_pushinteger(L, i);
|
|
lua_pushinteger(L, i);
|
|
|
lua_gettable(L, lo);
|
|
lua_gettable(L, lo);
|
|
|
- if (!lua_isnumber(L, -1))
|
|
|
|
|
|
|
+ if (!lua_isstring(L, -1))
|
|
|
{
|
|
{
|
|
|
lua_pop(L, 1);
|
|
lua_pop(L, 1);
|
|
|
|
|
|
|
@@ -105,12 +68,12 @@ int tolua_isurho3dconstpodvectorunsigned(lua_State* L, int lo, const char* type,
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void* tolua_tourho3dconstpodvectorunsigned(lua_State* L, int narg, void* def)
|
|
|
|
|
|
|
+template<> void* tolua_tourho3dvector<String>(lua_State* L, int narg, void* def)
|
|
|
{
|
|
{
|
|
|
if (!lua_istable(L, narg))
|
|
if (!lua_istable(L, narg))
|
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
|
|
- static Vector<unsigned> result;
|
|
|
|
|
|
|
+ static Vector<String> result;
|
|
|
result.Clear();
|
|
result.Clear();
|
|
|
|
|
|
|
|
int length = lua_objlen(L, narg);
|
|
int length = lua_objlen(L, narg);
|
|
@@ -119,14 +82,14 @@ void* tolua_tourho3dconstpodvectorunsigned(lua_State* L, int narg, void* def)
|
|
|
lua_pushinteger(L, i);
|
|
lua_pushinteger(L, i);
|
|
|
lua_gettable(L, narg);
|
|
lua_gettable(L, narg);
|
|
|
|
|
|
|
|
- if (!lua_isnumber(L, -1))
|
|
|
|
|
|
|
+ if (!lua_isstring(L, -1))
|
|
|
{
|
|
{
|
|
|
lua_pop(L, 1);
|
|
lua_pop(L, 1);
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- unsigned value = (unsigned)tolua_tonumber(L, -1, 0);
|
|
|
|
|
- result.Push(value);
|
|
|
|
|
|
|
+ String string = tolua_tourho3dstring(L, -1, "");
|
|
|
|
|
+ result.Push(string);
|
|
|
|
|
|
|
|
lua_pop(L, 1);
|
|
lua_pop(L, 1);
|
|
|
}
|
|
}
|
|
@@ -134,24 +97,19 @@ void* tolua_tourho3dconstpodvectorunsigned(lua_State* L, int narg, void* def)
|
|
|
return &result;
|
|
return &result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-int tolua_pushurho3dconstpodvectorunsigned(lua_State* L, void* data, const char* type)
|
|
|
|
|
|
|
+template<> int tolua_pushurho3dvector<String>(lua_State* L, void* data, const char* type)
|
|
|
{
|
|
{
|
|
|
-#ifndef TOLUA_RELEASE
|
|
|
|
|
- assert(strcmp(type, "const PODVector<unsigned>") == 0);
|
|
|
|
|
-#endif
|
|
|
|
|
-
|
|
|
|
|
- const PODVector<unsigned>& vector = *((const PODVector<unsigned>*)data);
|
|
|
|
|
|
|
+ const Vector<String>& vectorstring = *((const Vector<String>*)data);
|
|
|
lua_newtable(L);
|
|
lua_newtable(L);
|
|
|
- for (unsigned i = 0; i < vector.Size(); ++i)
|
|
|
|
|
|
|
+ for (unsigned i = 0; i < vectorstring.Size(); ++i)
|
|
|
{
|
|
{
|
|
|
- lua_pushinteger(L, vector[i]);
|
|
|
|
|
|
|
+ tolua_pushurho3dstring(L, vectorstring[i]);
|
|
|
lua_rawseti(L, -2, i + 1);
|
|
lua_rawseti(L, -2, i + 1);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
return 1;
|
|
return 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-int tolua_isurho3dconstvectorstring(lua_State* L, int lo, const char* type, int def, tolua_Error* err)
|
|
|
|
|
|
|
+template<> int tolua_isurho3dpodvector<unsigned>(lua_State* L, int lo, const char* type, int def, tolua_Error* err)
|
|
|
{
|
|
{
|
|
|
if (lua_istable(L, lo))
|
|
if (lua_istable(L, lo))
|
|
|
{
|
|
{
|
|
@@ -160,7 +118,7 @@ int tolua_isurho3dconstvectorstring(lua_State* L, int lo, const char* type, int
|
|
|
{
|
|
{
|
|
|
lua_pushinteger(L, i);
|
|
lua_pushinteger(L, i);
|
|
|
lua_gettable(L, lo);
|
|
lua_gettable(L, lo);
|
|
|
- if (!lua_isstring(L, -1))
|
|
|
|
|
|
|
+ if (!lua_isnumber(L, -1))
|
|
|
{
|
|
{
|
|
|
lua_pop(L, 1);
|
|
lua_pop(L, 1);
|
|
|
|
|
|
|
@@ -183,12 +141,12 @@ int tolua_isurho3dconstvectorstring(lua_State* L, int lo, const char* type, int
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void* tolua_tourho3dconstvectorstring(lua_State* L, int narg, void* def)
|
|
|
|
|
|
|
+template<> void* tolua_tourho3dpodvector<unsigned>(lua_State* L, int narg, void* def)
|
|
|
{
|
|
{
|
|
|
if (!lua_istable(L, narg))
|
|
if (!lua_istable(L, narg))
|
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
|
|
- static Vector<String> result;
|
|
|
|
|
|
|
+ static Vector<unsigned> result;
|
|
|
result.Clear();
|
|
result.Clear();
|
|
|
|
|
|
|
|
int length = lua_objlen(L, narg);
|
|
int length = lua_objlen(L, narg);
|
|
@@ -197,14 +155,14 @@ void* tolua_tourho3dconstvectorstring(lua_State* L, int narg, void* def)
|
|
|
lua_pushinteger(L, i);
|
|
lua_pushinteger(L, i);
|
|
|
lua_gettable(L, narg);
|
|
lua_gettable(L, narg);
|
|
|
|
|
|
|
|
- if (!lua_isstring(L, -1))
|
|
|
|
|
|
|
+ if (!lua_isnumber(L, -1))
|
|
|
{
|
|
{
|
|
|
lua_pop(L, 1);
|
|
lua_pop(L, 1);
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- String string = tolua_tourho3dstring(L, -1, "");
|
|
|
|
|
- result.Push(string);
|
|
|
|
|
|
|
+ unsigned value = (unsigned)tolua_tonumber(L, -1, 0);
|
|
|
|
|
+ result.Push(value);
|
|
|
|
|
|
|
|
lua_pop(L, 1);
|
|
lua_pop(L, 1);
|
|
|
}
|
|
}
|
|
@@ -212,19 +170,134 @@ void* tolua_tourho3dconstvectorstring(lua_State* L, int narg, void* def)
|
|
|
return &result;
|
|
return &result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-int tolua_pushurho3dconstvectorstring(lua_State*L, void* data, const char* type)
|
|
|
|
|
|
|
+template<> int tolua_pushurho3dpodvector<int>(lua_State* L, void* data, const char* type)
|
|
|
{
|
|
{
|
|
|
-#ifndef TOLUA_RELEASE
|
|
|
|
|
- assert(strcmp(type, "const Vector<String>") == 0);
|
|
|
|
|
-#endif
|
|
|
|
|
|
|
+ const PODVector<int>& vector = *((const PODVector<int>*)data);
|
|
|
|
|
+ lua_newtable(L);
|
|
|
|
|
+ for (unsigned i = 0; i < vector.Size(); ++i)
|
|
|
|
|
+ {
|
|
|
|
|
+ lua_pushinteger(L, vector[i]);
|
|
|
|
|
+ lua_rawseti(L, -2, i + 1);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- const Vector<String>& vectorstring = *((const Vector<String>*)data);
|
|
|
|
|
|
|
+ return 1;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+template<> int tolua_pushurho3dpodvector<IntVector2>(lua_State* L, void* data, const char* type)
|
|
|
|
|
+{
|
|
|
|
|
+ const PODVector<IntVector2>& vector = *((const PODVector<IntVector2>*)data);
|
|
|
lua_newtable(L);
|
|
lua_newtable(L);
|
|
|
- for (unsigned i = 0; i < vectorstring.Size(); ++i)
|
|
|
|
|
|
|
+ for (unsigned i = 0; i < vector.Size(); ++i)
|
|
|
{
|
|
{
|
|
|
- tolua_pushurho3dstring(L, vectorstring[i]);
|
|
|
|
|
|
|
+ void* tolua_obj = Mtolua_new((IntVector2)(vector[i]));
|
|
|
|
|
+ tolua_pushusertype(L,tolua_obj,"IntVector2");
|
|
|
|
|
+ tolua_register_gc(L,lua_gettop(L));
|
|
|
|
|
+
|
|
|
|
|
+ lua_rawseti(L, -2, i + 1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return 1;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+template<> int tolua_pushurho3dpodvector<OctreeQueryResult>(lua_State* L, void* data, const char* type)
|
|
|
|
|
+{
|
|
|
|
|
+ const PODVector<OctreeQueryResult>& vector = *((const PODVector<OctreeQueryResult>*)data);
|
|
|
|
|
+ lua_newtable(L);
|
|
|
|
|
+ for (unsigned i = 0; i < vector.Size(); ++i)
|
|
|
|
|
+ {
|
|
|
|
|
+ void* tolua_obj = Mtolua_new((OctreeQueryResult)(vector[i]));
|
|
|
|
|
+ tolua_pushusertype(L,tolua_obj,"OctreeQueryResult");
|
|
|
|
|
+ tolua_register_gc(L,lua_gettop(L));
|
|
|
|
|
+
|
|
|
|
|
+ lua_rawseti(L, -2, i + 1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return 1;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+template<> int tolua_pushurho3dpodvector<PhysicsRaycastResult>(lua_State* L, void* data, const char* type)
|
|
|
|
|
+{
|
|
|
|
|
+ const PODVector<PhysicsRaycastResult>& vector = *((const PODVector<PhysicsRaycastResult>*)data);
|
|
|
|
|
+ lua_newtable(L);
|
|
|
|
|
+ for (unsigned i = 0; i < vector.Size(); ++i)
|
|
|
|
|
+ {
|
|
|
|
|
+ void* tolua_obj = Mtolua_new((PhysicsRaycastResult)(vector[i]));
|
|
|
|
|
+ tolua_pushusertype(L,tolua_obj,"PhysicsRaycastResult");
|
|
|
|
|
+ tolua_register_gc(L,lua_gettop(L));
|
|
|
|
|
+
|
|
|
|
|
+ lua_rawseti(L, -2, i + 1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return 1;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+template<> int tolua_pushurho3dpodvector<RayQueryResult>(lua_State* L, void* data, const char* type)
|
|
|
|
|
+{
|
|
|
|
|
+ const PODVector<RayQueryResult>& vector = *((const PODVector<RayQueryResult>*)data);
|
|
|
|
|
+ lua_newtable(L);
|
|
|
|
|
+ for (unsigned i = 0; i < vector.Size(); ++i)
|
|
|
|
|
+ {
|
|
|
|
|
+ void* tolua_obj = Mtolua_new((RayQueryResult)(vector[i]));
|
|
|
|
|
+ tolua_pushusertype(L,tolua_obj,"RayQueryResult");
|
|
|
|
|
+ tolua_register_gc(L,lua_gettop(L));
|
|
|
|
|
+
|
|
|
|
|
+ lua_rawseti(L, -2, i + 1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return 1;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+template<> int tolua_pushurho3dpodvector<UIElement*>(lua_State* L, void* data, const char* type)
|
|
|
|
|
+{
|
|
|
|
|
+ const PODVector<UIElement*>& vector = *((const PODVector<UIElement*>*)data);
|
|
|
|
|
+ lua_newtable(L);
|
|
|
|
|
+ for (unsigned i = 0; i < vector.Size(); ++i)
|
|
|
|
|
+ {
|
|
|
|
|
+ tolua_pushusertype(L, vector[i], "UIElement");
|
|
|
|
|
+ lua_rawseti(L, -2, i + 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ return 1;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+template<> int tolua_pushurho3dpodvector<unsigned>(lua_State* L, void* data, const char* type)
|
|
|
|
|
+{
|
|
|
|
|
+ const PODVector<unsigned>& vector = *((const PODVector<unsigned>*)data);
|
|
|
|
|
+ lua_newtable(L);
|
|
|
|
|
+ for (unsigned i = 0; i < vector.Size(); ++i)
|
|
|
|
|
+ {
|
|
|
|
|
+ lua_pushinteger(L, vector[i]);
|
|
|
lua_rawseti(L, -2, i + 1);
|
|
lua_rawseti(L, -2, i + 1);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
return 1;
|
|
return 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+template<typename T> int PushPODVector(lua_State* L, const PODVector<T>& vector, const char* type)
|
|
|
|
|
+{
|
|
|
|
|
+ lua_newtable(L);
|
|
|
|
|
+ for (unsigned i = 0; i < vector.Size(); ++i)
|
|
|
|
|
+ {
|
|
|
|
|
+ void* tolua_obj = Mtolua_new((T)(vector[i]));
|
|
|
|
|
+ tolua_pushusertype(L, tolua_obj, type);
|
|
|
|
|
+ tolua_register_gc(L, lua_gettop(L));
|
|
|
|
|
+ lua_rawseti(L, -2, i + 1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return 1;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+template<> int tolua_pushurho3dpodvector<Vector3>(lua_State* L, void* data, const char* type)
|
|
|
|
|
+{
|
|
|
|
|
+ const PODVector<Vector3>& vector = *((const PODVector<Vector3>*)data);
|
|
|
|
|
+ lua_newtable(L);
|
|
|
|
|
+ for (unsigned i = 0; i < vector.Size(); ++i)
|
|
|
|
|
+ {
|
|
|
|
|
+ void* tolua_obj = Mtolua_new((Vector3)(vector[i]));
|
|
|
|
|
+ tolua_pushusertype(L,tolua_obj,"Vector3");
|
|
|
|
|
+ tolua_register_gc(L,lua_gettop(L));
|
|
|
|
|
+
|
|
|
|
|
+ lua_rawseti(L, -2, i + 1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return 1;
|
|
|
|
|
+}
|