// // Copyright (c) 2008-2014 the Urho3D project. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // #pragma once #include "Context.h" #include "OctreeQuery.h" #ifdef URHO3D_PHYSICS #include "PhysicsWorld.h" #endif #ifdef URHO3D_URHO2D #include "PhysicsWorld2D.h" #endif #include "Vector2.h" #include "Vector3.h" struct lua_State; namespace Urho3D { class Context; class Pass; class SoundSource; class UIElement; } using namespace Urho3D; /// Check is String. #define tolua_isurho3dstring tolua_isstring /// Push String. #define tolua_pushurho3dstring(x, y) tolua_pushstring(x, y.CString()) /// Convert to String. const char* tolua_tourho3dstring(lua_State* L, int narg, const char* str); /// Convert to String. const char* tolua_tourho3dstring(lua_State* L, int narg, const String& str); /// Set context. void SetContext(lua_State* L, Context* context); /// Return context. Context* GetContext(lua_State* L); /// Create object. template int ToluaNewObject(lua_State* tolua_S) { T* object = Mtolua_new(T(GetContext(tolua_S))); tolua_pushusertype(tolua_S, (void*)object,T::GetTypeNameStatic().CString()); return 1; } /// Create object with garbage collection. template int ToluaNewObjectGC(lua_State* tolua_S) { T* object = Mtolua_new(T(GetContext(tolua_S))); tolua_pushusertype(tolua_S, (void*)object,T::GetTypeNameStatic().CString()); tolua_register_gc(tolua_S, lua_gettop(tolua_S)); return 1; } /// Return subsystem. template int ToluaGetSubsystem(lua_State* tolua_S) { T* subsystem = GetContext(tolua_S)->GetSubsystem(); tolua_pushusertype(tolua_S, (void*)subsystem, T::GetTypeNameStatic().CString()); return 1; } /// Check is Vector. template int ToluaIsVector(lua_State* L, int lo, const char* type, int def, tolua_Error* err); /// Check is Vector. template<> int ToluaIsVector(lua_State* L, int lo, const char* type, int def, tolua_Error* err); /// Convert to Vector. template void* ToluaToVector(lua_State* L, int narg, void* def); /// Convert to Vector. template<> void* ToluaToVector(lua_State* L, int narg, void* def); /// Push Vector to Lua as a table. template int ToluaPushVector(lua_State*L, void* data, const char* type); /// Push Vector to Lua as a table. template<> int ToluaPushVector(lua_State* L, void* data, const char* type); /// Push Vector to Lua as a table. template<> int ToluaPushVector(lua_State* L, void* data, const char* type); /// Check is PODVector. template int ToluaIsPODVector(lua_State* L, int lo, const char* type, int def, tolua_Error* err); /// Check is PODVector. template<> int ToluaIsPODVector(lua_State* L, int lo, const char* type, int def, tolua_Error* err); /// Check is PODVector. template<> int ToluaIsPODVector(lua_State* L, int lo, const char* type, int def, tolua_Error* err); /// Convert to PODVector. template void* ToluaToPODVector(lua_State* L, int narg, void* def); /// Convert PODVector. template<> void* ToluaToPODVector(lua_State* L, int narg, void* def); /// Convert PODVector. template<> void* ToluaToPODVector(lua_State* L, int narg, void* def); /// Push PODVector to Lua as a table. template int ToluaPushPODVector(lua_State* L, void* data, const char* type); /// Push PODVector to Lua as a table. template<> int ToluaPushPODVector(lua_State* L, void* data, const char* type); /// Push PODVector to Lua as a table. template<> int ToluaPushPODVector(lua_State* L, void* data, const char* type); /// Push PODVector to Lua as a table. template<> int ToluaPushPODVector(lua_State* L, void* data, const char* type); /// Push PODVector to Lua as a table. template<> int ToluaPushPODVector(lua_State* L, void* data, const char* type); #ifdef URHO3D_PHYSICS /// Push PODVector to Lua as a table. template<> int ToluaPushPODVector(lua_State* L, void* data, const char* type); #endif #ifdef URHO3D_URHO2D /// Push PODVector to Lua as a table. template<> int ToluaPushPODVector(lua_State* L, void* data, const char* type); #endif /// Push PODVector to Lua as a table. template<> int ToluaPushPODVector(lua_State* L, void* data, const char* type); /// Push PODVector to Lua as a table. template<> int ToluaPushPODVector(lua_State* L, void* data, const char* type); /// Push PODVector to Lua as a table. template<> int ToluaPushPODVector(lua_State* L, void* data, const char* type); #ifdef URHO3D_PHYSICS /// Push PODVector to Lua as a table. template<> int ToluaPushPODVector(lua_State* L, void* data, const char* type); #endif #ifdef URHO3D_URHO2D /// Push PODVector to Lua as a table. template<> int ToluaPushPODVector(lua_State* L, void* data, const char* type); #endif /// Push PODVector to Lua as a table. template<> int ToluaPushPODVector(lua_State* L, void* data, const char* type); /// Push PODVector to Lua as a table. template<> int ToluaPushPODVector(lua_State* L, void* data, const char* type); /// Push Object to Lua. void ToluaPushObject(lua_State*L, void* data, const char* type);