|
|
@@ -53,7 +53,7 @@ int lua_Effect__gc(lua_State* state)
|
|
|
{
|
|
|
case 1:
|
|
|
{
|
|
|
- if (lua_type(state, 1) == LUA_TUSERDATA)
|
|
|
+ if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL))
|
|
|
{
|
|
|
void* userdata = luaL_checkudata(state, 1, "Effect");
|
|
|
luaL_argcheck(state, userdata != NULL, 1, "'Effect' expected.");
|
|
|
@@ -93,7 +93,7 @@ int lua_Effect_addRef(lua_State* state)
|
|
|
{
|
|
|
case 1:
|
|
|
{
|
|
|
- if (lua_type(state, 1) == LUA_TUSERDATA)
|
|
|
+ if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL))
|
|
|
{
|
|
|
Effect* instance = getInstance(state);
|
|
|
instance->addRef();
|
|
|
@@ -127,7 +127,7 @@ int lua_Effect_bind(lua_State* state)
|
|
|
{
|
|
|
case 1:
|
|
|
{
|
|
|
- if (lua_type(state, 1) == LUA_TUSERDATA)
|
|
|
+ if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL))
|
|
|
{
|
|
|
Effect* instance = getInstance(state);
|
|
|
instance->bind();
|
|
|
@@ -161,7 +161,7 @@ int lua_Effect_getId(lua_State* state)
|
|
|
{
|
|
|
case 1:
|
|
|
{
|
|
|
- if (lua_type(state, 1) == LUA_TUSERDATA)
|
|
|
+ if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL))
|
|
|
{
|
|
|
Effect* instance = getInstance(state);
|
|
|
const char* result = instance->getId();
|
|
|
@@ -198,7 +198,7 @@ int lua_Effect_getRefCount(lua_State* state)
|
|
|
{
|
|
|
case 1:
|
|
|
{
|
|
|
- if (lua_type(state, 1) == LUA_TUSERDATA)
|
|
|
+ if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL))
|
|
|
{
|
|
|
Effect* instance = getInstance(state);
|
|
|
unsigned int result = instance->getRefCount();
|
|
|
@@ -235,33 +235,49 @@ int lua_Effect_getUniform(lua_State* state)
|
|
|
{
|
|
|
case 2:
|
|
|
{
|
|
|
- if (lua_type(state, 1) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 2) == LUA_TSTRING)
|
|
|
+ if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
|
|
|
{
|
|
|
// Get parameter 1 off the stack.
|
|
|
- const char* param1 = luaL_checkstring(state, 2);
|
|
|
+ const char* param1 = ScriptController::getInstance()->getString(2, false);
|
|
|
|
|
|
Effect* instance = getInstance(state);
|
|
|
- ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
|
|
|
- object->instance = (void*)instance->getUniform(param1);
|
|
|
- object->owns = false;
|
|
|
- luaL_getmetatable(state, "Uniform");
|
|
|
- lua_setmetatable(state, -2);
|
|
|
+ void* returnPtr = (void*)instance->getUniform(param1);
|
|
|
+ if (returnPtr)
|
|
|
+ {
|
|
|
+ ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
|
|
|
+ object->instance = returnPtr;
|
|
|
+ object->owns = false;
|
|
|
+ luaL_getmetatable(state, "Uniform");
|
|
|
+ lua_setmetatable(state, -2);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ lua_pushnil(state);
|
|
|
+ }
|
|
|
|
|
|
return 1;
|
|
|
}
|
|
|
- else if (lua_type(state, 1) == LUA_TUSERDATA &&
|
|
|
+ else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
|
|
|
lua_type(state, 2) == LUA_TNUMBER)
|
|
|
{
|
|
|
// Get parameter 1 off the stack.
|
|
|
unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
|
|
|
|
|
|
Effect* instance = getInstance(state);
|
|
|
- ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
|
|
|
- object->instance = (void*)instance->getUniform(param1);
|
|
|
- object->owns = false;
|
|
|
- luaL_getmetatable(state, "Uniform");
|
|
|
- lua_setmetatable(state, -2);
|
|
|
+ void* returnPtr = (void*)instance->getUniform(param1);
|
|
|
+ if (returnPtr)
|
|
|
+ {
|
|
|
+ ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
|
|
|
+ object->instance = returnPtr;
|
|
|
+ object->owns = false;
|
|
|
+ luaL_getmetatable(state, "Uniform");
|
|
|
+ lua_setmetatable(state, -2);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ lua_pushnil(state);
|
|
|
+ }
|
|
|
|
|
|
return 1;
|
|
|
}
|
|
|
@@ -292,7 +308,7 @@ int lua_Effect_getUniformCount(lua_State* state)
|
|
|
{
|
|
|
case 1:
|
|
|
{
|
|
|
- if (lua_type(state, 1) == LUA_TUSERDATA)
|
|
|
+ if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL))
|
|
|
{
|
|
|
Effect* instance = getInstance(state);
|
|
|
unsigned int result = instance->getUniformCount();
|
|
|
@@ -329,18 +345,26 @@ int lua_Effect_getVertexAttribute(lua_State* state)
|
|
|
{
|
|
|
case 2:
|
|
|
{
|
|
|
- if (lua_type(state, 1) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 2) == LUA_TSTRING)
|
|
|
+ if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
|
|
|
{
|
|
|
// Get parameter 1 off the stack.
|
|
|
- const char* param1 = luaL_checkstring(state, 2);
|
|
|
+ const char* param1 = ScriptController::getInstance()->getString(2, false);
|
|
|
|
|
|
Effect* instance = getInstance(state);
|
|
|
- ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
|
|
|
- object->instance = (void*)new GLint(instance->getVertexAttribute(param1));
|
|
|
- object->owns = true;
|
|
|
- luaL_getmetatable(state, "GLint");
|
|
|
- lua_setmetatable(state, -2);
|
|
|
+ void* returnPtr = (void*)new GLint(instance->getVertexAttribute(param1));
|
|
|
+ if (returnPtr)
|
|
|
+ {
|
|
|
+ ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
|
|
|
+ object->instance = returnPtr;
|
|
|
+ object->owns = true;
|
|
|
+ luaL_getmetatable(state, "GLint");
|
|
|
+ lua_setmetatable(state, -2);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ lua_pushnil(state);
|
|
|
+ }
|
|
|
|
|
|
return 1;
|
|
|
}
|
|
|
@@ -371,7 +395,7 @@ int lua_Effect_release(lua_State* state)
|
|
|
{
|
|
|
case 1:
|
|
|
{
|
|
|
- if (lua_type(state, 1) == LUA_TUSERDATA)
|
|
|
+ if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL))
|
|
|
{
|
|
|
Effect* instance = getInstance(state);
|
|
|
instance->release();
|
|
|
@@ -405,18 +429,12 @@ int lua_Effect_setValue(lua_State* state)
|
|
|
{
|
|
|
case 3:
|
|
|
{
|
|
|
- if (lua_type(state, 1) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 2) == LUA_TUSERDATA &&
|
|
|
+ if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
|
|
|
lua_type(state, 3) == LUA_TNUMBER)
|
|
|
{
|
|
|
// Get parameter 1 off the stack.
|
|
|
- void* userdata2 = ScriptController::getInstance()->getObjectPointer(2, "Uniform");
|
|
|
- if (!userdata2)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Uniform' for parameter 2.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Uniform* param1 = (Uniform*)((ScriptController::LuaObject*)userdata2)->instance;
|
|
|
+ Uniform* param1 = ScriptController::getInstance()->getObjectPointer<Uniform>(2, "Uniform", false);
|
|
|
|
|
|
// Get parameter 2 off the stack.
|
|
|
float param2 = (float)luaL_checknumber(state, 3);
|
|
|
@@ -426,18 +444,12 @@ int lua_Effect_setValue(lua_State* state)
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
- else if (lua_type(state, 1) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 2) == LUA_TUSERDATA &&
|
|
|
+ else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
|
|
|
(lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TLIGHTUSERDATA))
|
|
|
{
|
|
|
// Get parameter 1 off the stack.
|
|
|
- void* userdata2 = ScriptController::getInstance()->getObjectPointer(2, "Uniform");
|
|
|
- if (!userdata2)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Uniform' for parameter 2.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Uniform* param1 = (Uniform*)((ScriptController::LuaObject*)userdata2)->instance;
|
|
|
+ Uniform* param1 = ScriptController::getInstance()->getObjectPointer<Uniform>(2, "Uniform", false);
|
|
|
|
|
|
// Get parameter 2 off the stack.
|
|
|
float* param2 = ScriptController::getInstance()->getFloatPointer(3);
|
|
|
@@ -447,18 +459,12 @@ int lua_Effect_setValue(lua_State* state)
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
- else if (lua_type(state, 1) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 2) == LUA_TUSERDATA &&
|
|
|
+ else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
|
|
|
lua_type(state, 3) == LUA_TNUMBER)
|
|
|
{
|
|
|
// Get parameter 1 off the stack.
|
|
|
- void* userdata2 = ScriptController::getInstance()->getObjectPointer(2, "Uniform");
|
|
|
- if (!userdata2)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Uniform' for parameter 2.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Uniform* param1 = (Uniform*)((ScriptController::LuaObject*)userdata2)->instance;
|
|
|
+ Uniform* param1 = ScriptController::getInstance()->getObjectPointer<Uniform>(2, "Uniform", false);
|
|
|
|
|
|
// Get parameter 2 off the stack.
|
|
|
int param2 = (int)luaL_checkint(state, 3);
|
|
|
@@ -468,18 +474,12 @@ int lua_Effect_setValue(lua_State* state)
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
- else if (lua_type(state, 1) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 2) == LUA_TUSERDATA &&
|
|
|
+ else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
|
|
|
(lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TLIGHTUSERDATA))
|
|
|
{
|
|
|
// Get parameter 1 off the stack.
|
|
|
- void* userdata2 = ScriptController::getInstance()->getObjectPointer(2, "Uniform");
|
|
|
- if (!userdata2)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Uniform' for parameter 2.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Uniform* param1 = (Uniform*)((ScriptController::LuaObject*)userdata2)->instance;
|
|
|
+ Uniform* param1 = ScriptController::getInstance()->getObjectPointer<Uniform>(2, "Uniform", false);
|
|
|
|
|
|
// Get parameter 2 off the stack.
|
|
|
int* param2 = ScriptController::getInstance()->getIntPointer(3);
|
|
|
@@ -489,243 +489,135 @@ int lua_Effect_setValue(lua_State* state)
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
- else if (lua_type(state, 1) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 2) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 3) == LUA_TUSERDATA)
|
|
|
+ else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL))
|
|
|
{
|
|
|
// Get parameter 1 off the stack.
|
|
|
- void* userdata2 = ScriptController::getInstance()->getObjectPointer(2, "Uniform");
|
|
|
- if (!userdata2)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Uniform' for parameter 2.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Uniform* param1 = (Uniform*)((ScriptController::LuaObject*)userdata2)->instance;
|
|
|
+ Uniform* param1 = ScriptController::getInstance()->getObjectPointer<Uniform>(2, "Uniform", false);
|
|
|
|
|
|
// Get parameter 2 off the stack.
|
|
|
- void* userdata3 = ScriptController::getInstance()->getObjectPointer(3, "Matrix");
|
|
|
- if (!userdata3)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Matrix' for parameter 3.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Matrix* param2 = (Matrix*)((ScriptController::LuaObject*)userdata3)->instance;
|
|
|
+ Matrix* param2 = ScriptController::getInstance()->getObjectPointer<Matrix>(3, "Matrix", true);
|
|
|
|
|
|
Effect* instance = getInstance(state);
|
|
|
instance->setValue(param1, *param2);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
- else if (lua_type(state, 1) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 2) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 3) == LUA_TUSERDATA)
|
|
|
+ else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL))
|
|
|
{
|
|
|
// Get parameter 1 off the stack.
|
|
|
- void* userdata2 = ScriptController::getInstance()->getObjectPointer(2, "Uniform");
|
|
|
- if (!userdata2)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Uniform' for parameter 2.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Uniform* param1 = (Uniform*)((ScriptController::LuaObject*)userdata2)->instance;
|
|
|
+ Uniform* param1 = ScriptController::getInstance()->getObjectPointer<Uniform>(2, "Uniform", false);
|
|
|
|
|
|
// Get parameter 2 off the stack.
|
|
|
- void* userdata3 = ScriptController::getInstance()->getObjectPointer(3, "Matrix");
|
|
|
- if (!userdata3)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Matrix' for parameter 3.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Matrix* param2 = (Matrix*)((ScriptController::LuaObject*)userdata3)->instance;
|
|
|
+ Matrix* param2 = ScriptController::getInstance()->getObjectPointer<Matrix>(3, "Matrix", false);
|
|
|
|
|
|
Effect* instance = getInstance(state);
|
|
|
instance->setValue(param1, param2);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
- else if (lua_type(state, 1) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 2) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 3) == LUA_TUSERDATA)
|
|
|
+ else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL))
|
|
|
{
|
|
|
// Get parameter 1 off the stack.
|
|
|
- void* userdata2 = ScriptController::getInstance()->getObjectPointer(2, "Uniform");
|
|
|
- if (!userdata2)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Uniform' for parameter 2.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Uniform* param1 = (Uniform*)((ScriptController::LuaObject*)userdata2)->instance;
|
|
|
+ Uniform* param1 = ScriptController::getInstance()->getObjectPointer<Uniform>(2, "Uniform", false);
|
|
|
|
|
|
// Get parameter 2 off the stack.
|
|
|
- void* userdata3 = ScriptController::getInstance()->getObjectPointer(3, "Vector2");
|
|
|
- if (!userdata3)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Vector2' for parameter 3.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Vector2* param2 = (Vector2*)((ScriptController::LuaObject*)userdata3)->instance;
|
|
|
+ Vector2* param2 = ScriptController::getInstance()->getObjectPointer<Vector2>(3, "Vector2", true);
|
|
|
|
|
|
Effect* instance = getInstance(state);
|
|
|
instance->setValue(param1, *param2);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
- else if (lua_type(state, 1) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 2) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 3) == LUA_TUSERDATA)
|
|
|
+ else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL))
|
|
|
{
|
|
|
// Get parameter 1 off the stack.
|
|
|
- void* userdata2 = ScriptController::getInstance()->getObjectPointer(2, "Uniform");
|
|
|
- if (!userdata2)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Uniform' for parameter 2.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Uniform* param1 = (Uniform*)((ScriptController::LuaObject*)userdata2)->instance;
|
|
|
+ Uniform* param1 = ScriptController::getInstance()->getObjectPointer<Uniform>(2, "Uniform", false);
|
|
|
|
|
|
// Get parameter 2 off the stack.
|
|
|
- void* userdata3 = ScriptController::getInstance()->getObjectPointer(3, "Vector2");
|
|
|
- if (!userdata3)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Vector2' for parameter 3.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Vector2* param2 = (Vector2*)((ScriptController::LuaObject*)userdata3)->instance;
|
|
|
+ Vector2* param2 = ScriptController::getInstance()->getObjectPointer<Vector2>(3, "Vector2", false);
|
|
|
|
|
|
Effect* instance = getInstance(state);
|
|
|
instance->setValue(param1, param2);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
- else if (lua_type(state, 1) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 2) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 3) == LUA_TUSERDATA)
|
|
|
+ else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL))
|
|
|
{
|
|
|
// Get parameter 1 off the stack.
|
|
|
- void* userdata2 = ScriptController::getInstance()->getObjectPointer(2, "Uniform");
|
|
|
- if (!userdata2)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Uniform' for parameter 2.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Uniform* param1 = (Uniform*)((ScriptController::LuaObject*)userdata2)->instance;
|
|
|
+ Uniform* param1 = ScriptController::getInstance()->getObjectPointer<Uniform>(2, "Uniform", false);
|
|
|
|
|
|
// Get parameter 2 off the stack.
|
|
|
- void* userdata3 = ScriptController::getInstance()->getObjectPointer(3, "Vector3");
|
|
|
- if (!userdata3)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Vector3' for parameter 3.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Vector3* param2 = (Vector3*)((ScriptController::LuaObject*)userdata3)->instance;
|
|
|
+ Vector3* param2 = ScriptController::getInstance()->getObjectPointer<Vector3>(3, "Vector3", true);
|
|
|
|
|
|
Effect* instance = getInstance(state);
|
|
|
instance->setValue(param1, *param2);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
- else if (lua_type(state, 1) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 2) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 3) == LUA_TUSERDATA)
|
|
|
+ else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL))
|
|
|
{
|
|
|
// Get parameter 1 off the stack.
|
|
|
- void* userdata2 = ScriptController::getInstance()->getObjectPointer(2, "Uniform");
|
|
|
- if (!userdata2)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Uniform' for parameter 2.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Uniform* param1 = (Uniform*)((ScriptController::LuaObject*)userdata2)->instance;
|
|
|
+ Uniform* param1 = ScriptController::getInstance()->getObjectPointer<Uniform>(2, "Uniform", false);
|
|
|
|
|
|
// Get parameter 2 off the stack.
|
|
|
- void* userdata3 = ScriptController::getInstance()->getObjectPointer(3, "Vector3");
|
|
|
- if (!userdata3)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Vector3' for parameter 3.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Vector3* param2 = (Vector3*)((ScriptController::LuaObject*)userdata3)->instance;
|
|
|
+ Vector3* param2 = ScriptController::getInstance()->getObjectPointer<Vector3>(3, "Vector3", false);
|
|
|
|
|
|
Effect* instance = getInstance(state);
|
|
|
instance->setValue(param1, param2);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
- else if (lua_type(state, 1) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 2) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 3) == LUA_TUSERDATA)
|
|
|
+ else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL))
|
|
|
{
|
|
|
// Get parameter 1 off the stack.
|
|
|
- void* userdata2 = ScriptController::getInstance()->getObjectPointer(2, "Uniform");
|
|
|
- if (!userdata2)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Uniform' for parameter 2.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Uniform* param1 = (Uniform*)((ScriptController::LuaObject*)userdata2)->instance;
|
|
|
+ Uniform* param1 = ScriptController::getInstance()->getObjectPointer<Uniform>(2, "Uniform", false);
|
|
|
|
|
|
// Get parameter 2 off the stack.
|
|
|
- void* userdata3 = ScriptController::getInstance()->getObjectPointer(3, "Vector4");
|
|
|
- if (!userdata3)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Vector4' for parameter 3.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Vector4* param2 = (Vector4*)((ScriptController::LuaObject*)userdata3)->instance;
|
|
|
+ Vector4* param2 = ScriptController::getInstance()->getObjectPointer<Vector4>(3, "Vector4", true);
|
|
|
|
|
|
Effect* instance = getInstance(state);
|
|
|
instance->setValue(param1, *param2);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
- else if (lua_type(state, 1) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 2) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 3) == LUA_TUSERDATA)
|
|
|
+ else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL))
|
|
|
{
|
|
|
// Get parameter 1 off the stack.
|
|
|
- void* userdata2 = ScriptController::getInstance()->getObjectPointer(2, "Uniform");
|
|
|
- if (!userdata2)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Uniform' for parameter 2.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Uniform* param1 = (Uniform*)((ScriptController::LuaObject*)userdata2)->instance;
|
|
|
+ Uniform* param1 = ScriptController::getInstance()->getObjectPointer<Uniform>(2, "Uniform", false);
|
|
|
|
|
|
// Get parameter 2 off the stack.
|
|
|
- void* userdata3 = ScriptController::getInstance()->getObjectPointer(3, "Vector4");
|
|
|
- if (!userdata3)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Vector4' for parameter 3.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Vector4* param2 = (Vector4*)((ScriptController::LuaObject*)userdata3)->instance;
|
|
|
+ Vector4* param2 = ScriptController::getInstance()->getObjectPointer<Vector4>(3, "Vector4", false);
|
|
|
|
|
|
Effect* instance = getInstance(state);
|
|
|
instance->setValue(param1, param2);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
- else if (lua_type(state, 1) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 2) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 3) == LUA_TUSERDATA)
|
|
|
+ else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL))
|
|
|
{
|
|
|
// Get parameter 1 off the stack.
|
|
|
- void* userdata2 = ScriptController::getInstance()->getObjectPointer(2, "Uniform");
|
|
|
- if (!userdata2)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Uniform' for parameter 2.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Uniform* param1 = (Uniform*)((ScriptController::LuaObject*)userdata2)->instance;
|
|
|
+ Uniform* param1 = ScriptController::getInstance()->getObjectPointer<Uniform>(2, "Uniform", false);
|
|
|
|
|
|
// Get parameter 2 off the stack.
|
|
|
- void* userdata3 = ScriptController::getInstance()->getObjectPointer(3, "TextureSampler");
|
|
|
- if (!userdata3)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Texture::Sampler' for parameter 3.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Texture::Sampler* param2 = (Texture::Sampler*)((ScriptController::LuaObject*)userdata3)->instance;
|
|
|
+ Texture::Sampler* param2 = ScriptController::getInstance()->getObjectPointer<Texture::Sampler>(3, "TextureSampler", false);
|
|
|
|
|
|
Effect* instance = getInstance(state);
|
|
|
instance->setValue(param1, param2);
|
|
|
@@ -741,19 +633,13 @@ int lua_Effect_setValue(lua_State* state)
|
|
|
}
|
|
|
case 4:
|
|
|
{
|
|
|
- if (lua_type(state, 1) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 2) == LUA_TUSERDATA &&
|
|
|
+ if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
|
|
|
(lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TLIGHTUSERDATA) &&
|
|
|
lua_type(state, 4) == LUA_TNUMBER)
|
|
|
{
|
|
|
// Get parameter 1 off the stack.
|
|
|
- void* userdata2 = ScriptController::getInstance()->getObjectPointer(2, "Uniform");
|
|
|
- if (!userdata2)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Uniform' for parameter 2.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Uniform* param1 = (Uniform*)((ScriptController::LuaObject*)userdata2)->instance;
|
|
|
+ Uniform* param1 = ScriptController::getInstance()->getObjectPointer<Uniform>(2, "Uniform", false);
|
|
|
|
|
|
// Get parameter 2 off the stack.
|
|
|
float* param2 = ScriptController::getInstance()->getFloatPointer(3);
|
|
|
@@ -766,19 +652,13 @@ int lua_Effect_setValue(lua_State* state)
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
- else if (lua_type(state, 1) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 2) == LUA_TUSERDATA &&
|
|
|
+ else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
|
|
|
(lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TLIGHTUSERDATA) &&
|
|
|
lua_type(state, 4) == LUA_TNUMBER)
|
|
|
{
|
|
|
// Get parameter 1 off the stack.
|
|
|
- void* userdata2 = ScriptController::getInstance()->getObjectPointer(2, "Uniform");
|
|
|
- if (!userdata2)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Uniform' for parameter 2.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Uniform* param1 = (Uniform*)((ScriptController::LuaObject*)userdata2)->instance;
|
|
|
+ Uniform* param1 = ScriptController::getInstance()->getObjectPointer<Uniform>(2, "Uniform", false);
|
|
|
|
|
|
// Get parameter 2 off the stack.
|
|
|
int* param2 = ScriptController::getInstance()->getIntPointer(3);
|
|
|
@@ -791,28 +671,16 @@ int lua_Effect_setValue(lua_State* state)
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
- else if (lua_type(state, 1) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 2) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 3) == LUA_TUSERDATA &&
|
|
|
+ else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
|
|
|
lua_type(state, 4) == LUA_TNUMBER)
|
|
|
{
|
|
|
// Get parameter 1 off the stack.
|
|
|
- void* userdata2 = ScriptController::getInstance()->getObjectPointer(2, "Uniform");
|
|
|
- if (!userdata2)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Uniform' for parameter 2.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Uniform* param1 = (Uniform*)((ScriptController::LuaObject*)userdata2)->instance;
|
|
|
+ Uniform* param1 = ScriptController::getInstance()->getObjectPointer<Uniform>(2, "Uniform", false);
|
|
|
|
|
|
// Get parameter 2 off the stack.
|
|
|
- void* userdata3 = ScriptController::getInstance()->getObjectPointer(3, "Matrix");
|
|
|
- if (!userdata3)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Matrix' for parameter 3.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Matrix* param2 = (Matrix*)((ScriptController::LuaObject*)userdata3)->instance;
|
|
|
+ Matrix* param2 = ScriptController::getInstance()->getObjectPointer<Matrix>(3, "Matrix", false);
|
|
|
|
|
|
// Get parameter 3 off the stack.
|
|
|
unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4);
|
|
|
@@ -822,28 +690,16 @@ int lua_Effect_setValue(lua_State* state)
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
- else if (lua_type(state, 1) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 2) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 3) == LUA_TUSERDATA &&
|
|
|
+ else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
|
|
|
lua_type(state, 4) == LUA_TNUMBER)
|
|
|
{
|
|
|
// Get parameter 1 off the stack.
|
|
|
- void* userdata2 = ScriptController::getInstance()->getObjectPointer(2, "Uniform");
|
|
|
- if (!userdata2)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Uniform' for parameter 2.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Uniform* param1 = (Uniform*)((ScriptController::LuaObject*)userdata2)->instance;
|
|
|
+ Uniform* param1 = ScriptController::getInstance()->getObjectPointer<Uniform>(2, "Uniform", false);
|
|
|
|
|
|
// Get parameter 2 off the stack.
|
|
|
- void* userdata3 = ScriptController::getInstance()->getObjectPointer(3, "Vector2");
|
|
|
- if (!userdata3)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Vector2' for parameter 3.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Vector2* param2 = (Vector2*)((ScriptController::LuaObject*)userdata3)->instance;
|
|
|
+ Vector2* param2 = ScriptController::getInstance()->getObjectPointer<Vector2>(3, "Vector2", false);
|
|
|
|
|
|
// Get parameter 3 off the stack.
|
|
|
unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4);
|
|
|
@@ -853,28 +709,16 @@ int lua_Effect_setValue(lua_State* state)
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
- else if (lua_type(state, 1) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 2) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 3) == LUA_TUSERDATA &&
|
|
|
+ else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
|
|
|
lua_type(state, 4) == LUA_TNUMBER)
|
|
|
{
|
|
|
// Get parameter 1 off the stack.
|
|
|
- void* userdata2 = ScriptController::getInstance()->getObjectPointer(2, "Uniform");
|
|
|
- if (!userdata2)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Uniform' for parameter 2.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Uniform* param1 = (Uniform*)((ScriptController::LuaObject*)userdata2)->instance;
|
|
|
+ Uniform* param1 = ScriptController::getInstance()->getObjectPointer<Uniform>(2, "Uniform", false);
|
|
|
|
|
|
// Get parameter 2 off the stack.
|
|
|
- void* userdata3 = ScriptController::getInstance()->getObjectPointer(3, "Vector3");
|
|
|
- if (!userdata3)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Vector3' for parameter 3.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Vector3* param2 = (Vector3*)((ScriptController::LuaObject*)userdata3)->instance;
|
|
|
+ Vector3* param2 = ScriptController::getInstance()->getObjectPointer<Vector3>(3, "Vector3", false);
|
|
|
|
|
|
// Get parameter 3 off the stack.
|
|
|
unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4);
|
|
|
@@ -884,28 +728,16 @@ int lua_Effect_setValue(lua_State* state)
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
- else if (lua_type(state, 1) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 2) == LUA_TUSERDATA &&
|
|
|
- lua_type(state, 3) == LUA_TUSERDATA &&
|
|
|
+ else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
|
|
|
lua_type(state, 4) == LUA_TNUMBER)
|
|
|
{
|
|
|
// Get parameter 1 off the stack.
|
|
|
- void* userdata2 = ScriptController::getInstance()->getObjectPointer(2, "Uniform");
|
|
|
- if (!userdata2)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Uniform' for parameter 2.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Uniform* param1 = (Uniform*)((ScriptController::LuaObject*)userdata2)->instance;
|
|
|
+ Uniform* param1 = ScriptController::getInstance()->getObjectPointer<Uniform>(2, "Uniform", false);
|
|
|
|
|
|
// Get parameter 2 off the stack.
|
|
|
- void* userdata3 = ScriptController::getInstance()->getObjectPointer(3, "Vector4");
|
|
|
- if (!userdata3)
|
|
|
- {
|
|
|
- lua_pushstring(state, "Failed to retrieve a valid object pointer of type 'Vector4' for parameter 3.");
|
|
|
- lua_error(state);
|
|
|
- }
|
|
|
- Vector4* param2 = (Vector4*)((ScriptController::LuaObject*)userdata3)->instance;
|
|
|
+ Vector4* param2 = ScriptController::getInstance()->getObjectPointer<Vector4>(3, "Vector4", false);
|
|
|
|
|
|
// Get parameter 3 off the stack.
|
|
|
unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4);
|
|
|
@@ -942,20 +774,28 @@ int lua_Effect_static_createFromFile(lua_State* state)
|
|
|
{
|
|
|
case 2:
|
|
|
{
|
|
|
- if (lua_type(state, 1) == LUA_TSTRING &&
|
|
|
- lua_type(state, 2) == LUA_TSTRING)
|
|
|
+ if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
|
|
|
{
|
|
|
// Get parameter 1 off the stack.
|
|
|
- const char* param1 = luaL_checkstring(state, 1);
|
|
|
+ const char* param1 = ScriptController::getInstance()->getString(1, false);
|
|
|
|
|
|
// Get parameter 2 off the stack.
|
|
|
- const char* param2 = luaL_checkstring(state, 2);
|
|
|
+ const char* param2 = ScriptController::getInstance()->getString(2, false);
|
|
|
|
|
|
- ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
|
|
|
- object->instance = (void*)Effect::createFromFile(param1, param2);
|
|
|
- object->owns = false;
|
|
|
- luaL_getmetatable(state, "Effect");
|
|
|
- lua_setmetatable(state, -2);
|
|
|
+ void* returnPtr = (void*)Effect::createFromFile(param1, param2);
|
|
|
+ if (returnPtr)
|
|
|
+ {
|
|
|
+ ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
|
|
|
+ object->instance = returnPtr;
|
|
|
+ object->owns = false;
|
|
|
+ luaL_getmetatable(state, "Effect");
|
|
|
+ lua_setmetatable(state, -2);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ lua_pushnil(state);
|
|
|
+ }
|
|
|
|
|
|
return 1;
|
|
|
}
|
|
|
@@ -968,24 +808,32 @@ int lua_Effect_static_createFromFile(lua_State* state)
|
|
|
}
|
|
|
case 3:
|
|
|
{
|
|
|
- if (lua_type(state, 1) == LUA_TSTRING &&
|
|
|
- lua_type(state, 2) == LUA_TSTRING &&
|
|
|
- lua_type(state, 3) == LUA_TSTRING)
|
|
|
+ if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
|
|
|
{
|
|
|
// Get parameter 1 off the stack.
|
|
|
- const char* param1 = luaL_checkstring(state, 1);
|
|
|
+ const char* param1 = ScriptController::getInstance()->getString(1, false);
|
|
|
|
|
|
// Get parameter 2 off the stack.
|
|
|
- const char* param2 = luaL_checkstring(state, 2);
|
|
|
+ const char* param2 = ScriptController::getInstance()->getString(2, false);
|
|
|
|
|
|
// Get parameter 3 off the stack.
|
|
|
- const char* param3 = luaL_checkstring(state, 3);
|
|
|
+ const char* param3 = ScriptController::getInstance()->getString(3, false);
|
|
|
|
|
|
- ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
|
|
|
- object->instance = (void*)Effect::createFromFile(param1, param2, param3);
|
|
|
- object->owns = false;
|
|
|
- luaL_getmetatable(state, "Effect");
|
|
|
- lua_setmetatable(state, -2);
|
|
|
+ void* returnPtr = (void*)Effect::createFromFile(param1, param2, param3);
|
|
|
+ if (returnPtr)
|
|
|
+ {
|
|
|
+ ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
|
|
|
+ object->instance = returnPtr;
|
|
|
+ object->owns = false;
|
|
|
+ luaL_getmetatable(state, "Effect");
|
|
|
+ lua_setmetatable(state, -2);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ lua_pushnil(state);
|
|
|
+ }
|
|
|
|
|
|
return 1;
|
|
|
}
|
|
|
@@ -1016,20 +864,28 @@ int lua_Effect_static_createFromSource(lua_State* state)
|
|
|
{
|
|
|
case 2:
|
|
|
{
|
|
|
- if (lua_type(state, 1) == LUA_TSTRING &&
|
|
|
- lua_type(state, 2) == LUA_TSTRING)
|
|
|
+ if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
|
|
|
{
|
|
|
// Get parameter 1 off the stack.
|
|
|
- const char* param1 = luaL_checkstring(state, 1);
|
|
|
+ const char* param1 = ScriptController::getInstance()->getString(1, false);
|
|
|
|
|
|
// Get parameter 2 off the stack.
|
|
|
- const char* param2 = luaL_checkstring(state, 2);
|
|
|
+ const char* param2 = ScriptController::getInstance()->getString(2, false);
|
|
|
|
|
|
- ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
|
|
|
- object->instance = (void*)Effect::createFromSource(param1, param2);
|
|
|
- object->owns = false;
|
|
|
- luaL_getmetatable(state, "Effect");
|
|
|
- lua_setmetatable(state, -2);
|
|
|
+ void* returnPtr = (void*)Effect::createFromSource(param1, param2);
|
|
|
+ if (returnPtr)
|
|
|
+ {
|
|
|
+ ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
|
|
|
+ object->instance = returnPtr;
|
|
|
+ object->owns = false;
|
|
|
+ luaL_getmetatable(state, "Effect");
|
|
|
+ lua_setmetatable(state, -2);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ lua_pushnil(state);
|
|
|
+ }
|
|
|
|
|
|
return 1;
|
|
|
}
|
|
|
@@ -1042,24 +898,32 @@ int lua_Effect_static_createFromSource(lua_State* state)
|
|
|
}
|
|
|
case 3:
|
|
|
{
|
|
|
- if (lua_type(state, 1) == LUA_TSTRING &&
|
|
|
- lua_type(state, 2) == LUA_TSTRING &&
|
|
|
- lua_type(state, 3) == LUA_TSTRING)
|
|
|
+ if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
|
|
|
+ (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
|
|
|
{
|
|
|
// Get parameter 1 off the stack.
|
|
|
- const char* param1 = luaL_checkstring(state, 1);
|
|
|
+ const char* param1 = ScriptController::getInstance()->getString(1, false);
|
|
|
|
|
|
// Get parameter 2 off the stack.
|
|
|
- const char* param2 = luaL_checkstring(state, 2);
|
|
|
+ const char* param2 = ScriptController::getInstance()->getString(2, false);
|
|
|
|
|
|
// Get parameter 3 off the stack.
|
|
|
- const char* param3 = luaL_checkstring(state, 3);
|
|
|
+ const char* param3 = ScriptController::getInstance()->getString(3, false);
|
|
|
|
|
|
- ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
|
|
|
- object->instance = (void*)Effect::createFromSource(param1, param2, param3);
|
|
|
- object->owns = false;
|
|
|
- luaL_getmetatable(state, "Effect");
|
|
|
- lua_setmetatable(state, -2);
|
|
|
+ void* returnPtr = (void*)Effect::createFromSource(param1, param2, param3);
|
|
|
+ if (returnPtr)
|
|
|
+ {
|
|
|
+ ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
|
|
|
+ object->instance = returnPtr;
|
|
|
+ object->owns = false;
|
|
|
+ luaL_getmetatable(state, "Effect");
|
|
|
+ lua_setmetatable(state, -2);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ lua_pushnil(state);
|
|
|
+ }
|
|
|
|
|
|
return 1;
|
|
|
}
|
|
|
@@ -1090,11 +954,19 @@ int lua_Effect_static_getCurrentEffect(lua_State* state)
|
|
|
{
|
|
|
case 0:
|
|
|
{
|
|
|
- ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
|
|
|
- object->instance = (void*)Effect::getCurrentEffect();
|
|
|
- object->owns = false;
|
|
|
- luaL_getmetatable(state, "Effect");
|
|
|
- lua_setmetatable(state, -2);
|
|
|
+ void* returnPtr = (void*)Effect::getCurrentEffect();
|
|
|
+ if (returnPtr)
|
|
|
+ {
|
|
|
+ ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
|
|
|
+ object->instance = returnPtr;
|
|
|
+ object->owns = false;
|
|
|
+ luaL_getmetatable(state, "Effect");
|
|
|
+ lua_setmetatable(state, -2);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ lua_pushnil(state);
|
|
|
+ }
|
|
|
|
|
|
return 1;
|
|
|
break;
|