Преглед на файлове

NULL checks...everywhere

Set the 'use precompiled header' option in the RocketCore project to true, and had precompiled.cpp set to 'generate'.
Nate Starkey преди 13 години
родител
ревизия
f57f412de8

+ 3 - 2
Build/RocketCore.vcproj

@@ -41,7 +41,8 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				AdditionalIncludeDirectories="..\Include;..\..\support\freetype\include"
-				UsePrecompiledHeader="0"
+				UsePrecompiledHeader="2"
+				ShowIncludes="false"
 			/>
 			<Tool
 				Name="VCManagedResourceCompilerTool"
@@ -163,7 +164,7 @@
 					>
 					<Tool
 						Name="VCCLCompilerTool"
-						UsePrecompiledHeader="0"
+						UsePrecompiledHeader="1"
 					/>
 				</FileConfiguration>
 				<FileConfiguration

+ 0 - 1
Source/Controls/Lua/ElementForm.cpp

@@ -9,7 +9,6 @@ namespace Lua {
 //method
 int ElementFormSubmit(lua_State* L, ElementForm* obj)
 {
-    LUACHECKOBJ(obj);
     const char* name = luaL_checkstring(L,1);
     const char* value = luaL_checkstring(L,2);
     obj->Submit(name,value);

+ 0 - 1
Source/Controls/Lua/ElementFormControlDataSelect.cpp

@@ -12,7 +12,6 @@ namespace Lua {
 //method
 int ElementFormControlDataSelectSetDataSource(lua_State* L, ElementFormControlDataSelect* obj)
 {
-    LUACHECKOBJ(obj);
     const char* source = luaL_checkstring(L,1);
     obj->SetDataSource(source);
     return 0;

+ 0 - 3
Source/Controls/Lua/ElementFormControlSelect.cpp

@@ -15,7 +15,6 @@ namespace Lua {
 //methods
 int ElementFormControlSelectAdd(lua_State* L, ElementFormControlSelect* obj)
 {
-    LUACHECKOBJ(obj);
     const char* rml = luaL_checkstring(L,1);
     const char* value = luaL_checkstring(L,2);
     int before = -1; //default
@@ -29,7 +28,6 @@ int ElementFormControlSelectAdd(lua_State* L, ElementFormControlSelect* obj)
 
 int ElementFormControlSelectRemove(lua_State* L, ElementFormControlSelect* obj)
 {
-    LUACHECKOBJ(obj);
     int index = luaL_checkint(L,1);
     obj->Remove(index);
     return 0;
@@ -37,7 +35,6 @@ int ElementFormControlSelectRemove(lua_State* L, ElementFormControlSelect* obj)
 
 int ElementFormControlSelectGetOption(lua_State* L, ElementFormControlSelect* obj)
 {
-    LUACHECKOBJ(obj);
     int index = luaL_checkint(L,1);
     Rocket::Controls::SelectOption* opt = obj->GetOption(index);
     lua_newtable(L);

+ 14 - 0
Source/Core/Lua/Colourb.cpp

@@ -21,7 +21,9 @@ int Colourbnew(lua_State* L)
 int Colourb__eq(lua_State* L)
 {
     Colourb* lhs = LuaType<Colourb>::check(L,1);
+    LUACHECKOBJ(lhs);
     Colourb* rhs = LuaType<Colourb>::check(L,2);
+    LUACHECKOBJ(rhs);
 
     lua_pushboolean(L, (*lhs) == (*rhs) ? 1 : 0);
     return 1;
@@ -30,7 +32,9 @@ int Colourb__eq(lua_State* L)
 int Colourb__add(lua_State* L)
 {
     Colourb* lhs = LuaType<Colourb>::check(L,1);
+    LUACHECKOBJ(lhs);
     Colourb* rhs = LuaType<Colourb>::check(L,2);
+    LUACHECKOBJ(rhs);
 
     Colourb* res = new Colourb((*lhs) + (*rhs));
 
@@ -41,6 +45,7 @@ int Colourb__add(lua_State* L)
 int Colourb__mul(lua_State* L)
 {
     Colourb* lhs = LuaType<Colourb>::check(L,1);
+    LUACHECKOBJ(lhs);
     float rhs = (float)luaL_checknumber(L,2);
 
     Colourb* res = new Colourb((*lhs) * rhs);
@@ -55,6 +60,7 @@ int Colourb__mul(lua_State* L)
 int ColourbGetAttrred(lua_State* L)
 {
     Colourb* obj = LuaType<Colourb>::check(L,1);
+    LUACHECKOBJ(obj);
     lua_pushinteger(L,obj->red);
     return 1;
 }
@@ -62,6 +68,7 @@ int ColourbGetAttrred(lua_State* L)
 int ColourbGetAttrgreen(lua_State* L)
 {
     Colourb* obj = LuaType<Colourb>::check(L,1);
+    LUACHECKOBJ(obj);
     lua_pushinteger(L,obj->green);
     return 1;
 }
@@ -69,6 +76,7 @@ int ColourbGetAttrgreen(lua_State* L)
 int ColourbGetAttrblue(lua_State* L)
 {
     Colourb* obj = LuaType<Colourb>::check(L,1);
+    LUACHECKOBJ(obj);
     lua_pushinteger(L,obj->blue);
     return 1;
 }
@@ -76,6 +84,7 @@ int ColourbGetAttrblue(lua_State* L)
 int ColourbGetAttralpha(lua_State* L)
 {
     Colourb* obj = LuaType<Colourb>::check(L,1);
+    LUACHECKOBJ(obj);
     lua_pushinteger(L,obj->alpha);
     return 1;
 }
@@ -83,6 +92,7 @@ int ColourbGetAttralpha(lua_State* L)
 int ColourbGetAttrrgba(lua_State* L)
 {
     Colourb* obj = LuaType<Colourb>::check(L,1);
+    LUACHECKOBJ(obj);
     lua_pushinteger(L,obj->red);
     lua_pushinteger(L,obj->green);
     lua_pushinteger(L,obj->blue);
@@ -95,6 +105,7 @@ int ColourbGetAttrrgba(lua_State* L)
 int ColourbSetAttrred(lua_State* L)
 {
     Colourb* obj = LuaType<Colourb>::check(L,1);
+    LUACHECKOBJ(obj);
     byte red = (byte)luaL_checkinteger(L,2);
     obj->red = red;
     return 0;
@@ -103,6 +114,7 @@ int ColourbSetAttrred(lua_State* L)
 int ColourbSetAttrgreen(lua_State* L)
 {
     Colourb* obj = LuaType<Colourb>::check(L,1);
+    LUACHECKOBJ(obj);
     byte green = (byte)luaL_checkinteger(L,2);
     obj->green = green;
     return 0;
@@ -111,6 +123,7 @@ int ColourbSetAttrgreen(lua_State* L)
 int ColourbSetAttrblue(lua_State* L)
 {
     Colourb* obj = LuaType<Colourb>::check(L,1);
+    LUACHECKOBJ(obj);
     byte blue = (byte)luaL_checkinteger(L,2);
     obj->blue = blue;
     return 0;
@@ -119,6 +132,7 @@ int ColourbSetAttrblue(lua_State* L)
 int ColourbSetAttralpha(lua_State* L)
 {
     Colourb* obj = LuaType<Colourb>::check(L,1);
+    LUACHECKOBJ(obj);
     byte alpha = (byte)luaL_checkinteger(L,2);
     obj->alpha = alpha;
     return 0;

+ 11 - 0
Source/Core/Lua/Colourf.cpp

@@ -25,7 +25,9 @@ int Colourfnew(lua_State* L)
 int Colourf__eq(lua_State* L)
 {
     Colourf* lhs = LuaType<Colourf>::check(L,1);
+    LUACHECKOBJ(lhs);
     Colourf* rhs = LuaType<Colourf>::check(L,2);
+    LUACHECKOBJ(rhs);
 
     lua_pushboolean(L, (*lhs) == (*rhs) ? 1 : 0);
     return 1;
@@ -36,6 +38,7 @@ int Colourf__eq(lua_State* L)
 int ColourfGetAttrred(lua_State* L)
 {
     Colourf* obj = LuaType<Colourf>::check(L,1);
+    LUACHECKOBJ(obj);
     lua_pushnumber(L,obj->red);
     return 1;
 }
@@ -43,6 +46,7 @@ int ColourfGetAttrred(lua_State* L)
 int ColourfGetAttrgreen(lua_State* L)
 {
     Colourf* obj = LuaType<Colourf>::check(L,1);
+    LUACHECKOBJ(obj);
     lua_pushnumber(L,obj->green);
     return 1;
 }
@@ -50,6 +54,7 @@ int ColourfGetAttrgreen(lua_State* L)
 int ColourfGetAttrblue(lua_State* L)
 {
     Colourf* obj = LuaType<Colourf>::check(L,1);
+    LUACHECKOBJ(obj);
     lua_pushnumber(L,obj->blue);
     return 1;
 }
@@ -57,6 +62,7 @@ int ColourfGetAttrblue(lua_State* L)
 int ColourfGetAttralpha(lua_State* L)
 {
     Colourf* obj = LuaType<Colourf>::check(L,1);
+    LUACHECKOBJ(obj);
     lua_pushnumber(L,obj->alpha);
     return 1;
 }
@@ -64,6 +70,7 @@ int ColourfGetAttralpha(lua_State* L)
 int ColourfGetAttrrgba(lua_State* L)
 {
     Colourf* obj = LuaType<Colourf>::check(L,1);
+    LUACHECKOBJ(obj);
     lua_pushnumber(L,obj->red);
     lua_pushnumber(L,obj->green);
     lua_pushnumber(L,obj->blue);
@@ -76,6 +83,7 @@ int ColourfGetAttrrgba(lua_State* L)
 int ColourfSetAttrred(lua_State* L)
 {
     Colourf* obj = LuaType<Colourf>::check(L,1);
+    LUACHECKOBJ(obj);
     float red = (float)luaL_checknumber(L,2);
     obj->red = red;
     return 0;
@@ -84,6 +92,7 @@ int ColourfSetAttrred(lua_State* L)
 int ColourfSetAttrgreen(lua_State* L)
 {
     Colourf* obj = LuaType<Colourf>::check(L,1);
+    LUACHECKOBJ(obj);
     float green = (float)luaL_checknumber(L,2);
     obj->green = green;
     return 0;
@@ -92,6 +101,7 @@ int ColourfSetAttrgreen(lua_State* L)
 int ColourfSetAttrblue(lua_State* L)
 {
     Colourf* obj = LuaType<Colourf>::check(L,1);
+    LUACHECKOBJ(obj);
     float blue = (float)luaL_checknumber(L,2);
     obj->blue;
     return 0;
@@ -100,6 +110,7 @@ int ColourfSetAttrblue(lua_State* L)
 int ColourfSetAttralpha(lua_State* L)
 {
     Colourf* obj = LuaType<Colourf>::check(L,1);
+    LUACHECKOBJ(obj);
     float alpha = (float)luaL_checknumber(L,2);
     obj->alpha;
     return 0;

+ 5 - 2
Source/Core/Lua/Context.cpp

@@ -14,7 +14,6 @@ typedef Rocket::Core::ElementDocument Document;
 int ContextAddEventListener(lua_State* L, Context* obj)
 {
    //need to make an EventListener for Lua before I can do anything else
-	LUACHECKOBJ(obj);
 	const char* evt = luaL_checkstring(L,1); //event
 	Element* element = NULL;
 	bool capturephase = false;
@@ -173,6 +172,7 @@ int ContextGetAttrdocuments(lua_State* L)
 int ContextGetAttrfocus_element(lua_State* L)
 {
     Context* cont = LuaType<Context>::check(L,1);
+    LUACHECKOBJ(cont);
     LuaType<Element>::push(L,cont->GetFocusElement());
     return 1;
 }
@@ -180,6 +180,7 @@ int ContextGetAttrfocus_element(lua_State* L)
 int ContextGetAttrhover_element(lua_State* L)
 {
     Context* cont = LuaType<Context>::check(L,1);
+    LUACHECKOBJ(cont);
     LuaType<Element>::push(L,cont->GetHoverElement());
     return 1;
 }
@@ -187,7 +188,7 @@ int ContextGetAttrhover_element(lua_State* L)
 int ContextGetAttrname(lua_State* L)
 {
     Context* cont = LuaType<Context>::check(L,1);
-
+    LUACHECKOBJ(cont);
     lua_pushstring(L,cont->GetName().CString());
     return 1;
 }
@@ -195,6 +196,7 @@ int ContextGetAttrname(lua_State* L)
 int ContextGetAttrroot_element(lua_State* L)
 {
     Context* cont = LuaType<Context>::check(L,1);
+    LUACHECKOBJ(cont);
     LuaType<Element>::push(L,cont->GetRootElement());
     return 1;
 }
@@ -204,6 +206,7 @@ int ContextGetAttrroot_element(lua_State* L)
 int ContextSetAttrdimensions(lua_State* L)
 {
     Context* cont = LuaType<Context>::check(L,1);
+    LUACHECKOBJ(cont);
     Vector2i* dim = LuaType<Vector2i>::check(L,2);
     cont->SetDimensions(*dim);
     return 0;

+ 3 - 0
Source/Core/Lua/Document.cpp

@@ -64,6 +64,7 @@ int DocumentCreateTextNode(lua_State* L, Document* obj)
 int DocumentGetAttrtitle(lua_State* L)
 {
     Document* doc = LuaType<Document>::check(L,1);
+    LUACHECKOBJ(doc);
     lua_pushstring(L,doc->GetTitle().CString());
     return 1;
 }
@@ -71,6 +72,7 @@ int DocumentGetAttrtitle(lua_State* L)
 int DocumentGetAttrcontext(lua_State* L)
 {
     Document* doc = LuaType<Document>::check(L,1);
+    LUACHECKOBJ(doc);
     LuaType<Context>::push(L,doc->GetContext(),false);
     return 1;
 }
@@ -80,6 +82,7 @@ int DocumentGetAttrcontext(lua_State* L)
 int DocumentSetAttrtitle(lua_State* L)
 {
     Document* doc = LuaType<Document>::check(L,1);
+    LUACHECKOBJ(doc);
     const char* title = luaL_checkstring(L,2);
     doc->SetTitle(title);
     return 0;

+ 18 - 1
Source/Core/Lua/Element.cpp

@@ -221,7 +221,6 @@ int ElementScrollIntoView(lua_State* L, Element* obj)
 
 int ElementSetAttribute(lua_State* L, Element* obj)
 {
-    LUACHECKOBJ(obj);
     const char* name = luaL_checkstring(L,1);
     const char* value = luaL_checkstring(L,2);
     obj->SetAttribute(name,String(value));
@@ -241,6 +240,7 @@ int ElementSetClass(lua_State* L, Element* obj)
 int ElementGetAttrattributes(lua_State* L)
 {
     Element* ele = LuaType<Element>::check(L,1);
+    LUACHECKOBJ(ele);
     
     int index;
     String key;
@@ -291,6 +291,7 @@ int ElementGetAttrattributes(lua_State* L)
 int ElementGetAttrchild_nodes(lua_State* L)
 {
     Element* ele = LuaType<Element>::check(L,1);
+    LUACHECKOBJ(ele);
     if(!ele->HasChildNodes())
         lua_pushnil(L);
     else
@@ -312,6 +313,7 @@ int ElementGetAttrchild_nodes(lua_State* L)
 int ElementGetAttrclass_name(lua_State* L)
 {
     Element* ele = LuaType<Element>::check(L,1);
+    LUACHECKOBJ(ele);
     const char* classnames = ele->GetClassNames().CString();
     lua_pushstring(L,classnames);
     return 1;
@@ -320,6 +322,7 @@ int ElementGetAttrclass_name(lua_State* L)
 int ElementGetAttrclient_left(lua_State* L)
 {
     Element* ele = LuaType<Element>::check(L,1);
+    LUACHECKOBJ(ele);
     lua_pushnumber(L,ele->GetClientLeft());
     return 1;
 }
@@ -327,6 +330,7 @@ int ElementGetAttrclient_left(lua_State* L)
 int ElementGetAttrclient_height(lua_State* L)
 {
     Element* ele = LuaType<Element>::check(L,1);
+    LUACHECKOBJ(ele);
     lua_pushnumber(L,ele->GetClientHeight());
     return 1;
 }
@@ -334,6 +338,7 @@ int ElementGetAttrclient_height(lua_State* L)
 int ElementGetAttrclient_top(lua_State* L)
 {
     Element* ele = LuaType<Element>::check(L,1);
+    LUACHECKOBJ(ele);
     lua_pushnumber(L,ele->GetClientTop());
     return 1;
 }
@@ -341,6 +346,7 @@ int ElementGetAttrclient_top(lua_State* L)
 int ElementGetAttrclient_width(lua_State* L)
 {
     Element* ele = LuaType<Element>::check(L,1);
+    LUACHECKOBJ(ele);
     lua_pushnumber(L,ele->GetClientWidth());
     return 1;
 }
@@ -348,6 +354,7 @@ int ElementGetAttrclient_width(lua_State* L)
 int ElementGetAttrfirst_child(lua_State* L)
 {
     Element* ele = LuaType<Element>::check(L,1);
+    LUACHECKOBJ(ele);
     Element* child = ele->GetFirstChild();
     if(child == NULL)
         lua_pushnil(L);
@@ -359,6 +366,7 @@ int ElementGetAttrfirst_child(lua_State* L)
 int ElementGetAttrid(lua_State* L)
 {
     Element* ele = LuaType<Element>::check(L,1);
+    LUACHECKOBJ(ele);
     lua_pushstring(L,ele->GetId().CString());
     return 1;
 }
@@ -366,6 +374,7 @@ int ElementGetAttrid(lua_State* L)
 int ElementGetAttrinner_rml(lua_State* L)
 {
     Element* ele = LuaType<Element>::check(L,1);
+    LUACHECKOBJ(ele);
     lua_pushstring(L,ele->GetInnerRML().CString());
     return 1;
 }
@@ -373,6 +382,7 @@ int ElementGetAttrinner_rml(lua_State* L)
 int ElementGetAttrlast_child(lua_State* L)
 {
     Element* ele = LuaType<Element>::check(L,1);
+    LUACHECKOBJ(ele);
     Element* child = ele->GetLastChild();
     if(child == NULL)
         lua_pushnil(L);
@@ -384,6 +394,7 @@ int ElementGetAttrlast_child(lua_State* L)
 int ElementGetAttrnext_sibling(lua_State* L)
 {
     Element* ele = LuaType<Element>::check(L,1);
+    LUACHECKOBJ(ele);
     Element* sibling = ele->GetNextSibling();
     if(sibling == NULL)
         lua_pushnil(L);
@@ -395,6 +406,7 @@ int ElementGetAttrnext_sibling(lua_State* L)
 int ElementGetAttroffset_height(lua_State* L)
 {
     Element* ele = LuaType<Element>::check(L,1);
+    LUACHECKOBJ(ele);
     lua_pushnumber(L,ele->GetOffsetHeight());
     return 1;
 }
@@ -402,6 +414,7 @@ int ElementGetAttroffset_height(lua_State* L)
 int ElementGetAttroffset_left(lua_State* L)
 {
     Element* ele = LuaType<Element>::check(L,1);
+    LUACHECKOBJ(ele);
     lua_pushnumber(L,ele->GetOffsetLeft());
     return 1;
 }
@@ -409,6 +422,7 @@ int ElementGetAttroffset_left(lua_State* L)
 int ElementGetAttroffset_parent(lua_State* L)
 {
     Element* ele = LuaType<Element>::check(L,1);
+    LUACHECKOBJ(ele);
     Element* parent = ele->GetOffsetParent();
     LuaType<Element>::push(L,parent,false);
     return 1;
@@ -417,6 +431,7 @@ int ElementGetAttroffset_parent(lua_State* L)
 int ElementGetAttroffset_top(lua_State* L)
 {
     Element* ele = LuaType<Element>::check(L,1);
+    LUACHECKOBJ(ele);
     lua_pushnumber(L, ele->GetOffsetTop());
     return 1;
 }
@@ -424,6 +439,7 @@ int ElementGetAttroffset_top(lua_State* L)
 int ElementGetAttroffset_width(lua_State* L)
 {
     Element* ele = LuaType<Element>::check(L,1);
+    LUACHECKOBJ(ele);
     lua_pushnumber(L,ele->GetOffsetWidth());
     return 1;
 }
@@ -431,6 +447,7 @@ int ElementGetAttroffset_width(lua_State* L)
 int ElementGetAttrowner_document(lua_State* L)
 {
     Element* ele = LuaType<Element>::check(L,1);
+    LUACHECKOBJ(ele);
     Document* doc = ele->GetOwnerDocument();
     LuaType<Document>::push(L,doc,false);
     return 1;

+ 0 - 1
Source/Core/Lua/ElementStyle.cpp

@@ -77,7 +77,6 @@ int ElementStyle__newindex(lua_State* L)
 
 int ElementStyleGetTable(lua_State* L, ElementStyle* obj)
 {
-    LUACHECKOBJ(obj);
     int index = 0;
     String key,sval;
     const Property* value;

+ 0 - 1
Source/Core/Lua/Event.cpp

@@ -13,7 +13,6 @@ namespace Lua {
 //method
 int EventStopPropagation(lua_State* L, Event* obj)
 {
-    LUACHECKOBJ(obj);
     obj->StopPropagation();
     return 0;
 }

+ 2 - 0
Source/Core/Lua/LuaEventListener.cpp

@@ -56,6 +56,7 @@ LuaEventListener::LuaEventListener(lua_State* L, int narg, Element* element)
 	lua_pushvalue(L,narg);
 	luaFuncRef = luaL_ref(L,-2); //put the funtion as a ref in to that table
 	lua_pop(L,1); //pop the EVENTLISTENERFUNCTIONS table
+
 	attached = element;
 	if(element)
 		parent = element->GetOwnerDocument();
@@ -80,6 +81,7 @@ void LuaEventListener::ProcessEvent(Event& event)
     if(!parent && attached) parent = attached->GetOwnerDocument();
     lua_State* L = Interpreter::GetLuaState();
     int top = lua_gettop(L); 
+
     //push the arguments
     lua_getglobal(L,"EVENTLISTENERFUNCTIONS");
     lua_rawgeti(L,-1,luaFuncRef);

+ 9 - 2
Source/Core/Lua/LuaType.cpp

@@ -118,8 +118,15 @@ int LuaType<T>::thunk(lua_State* L)
     lua_remove(L, 1);  // remove self so member function args start at index 1
     // get member function from upvalue
     RegType *l = static_cast<RegType*>(lua_touserdata(L, lua_upvalueindex(1)));
-    // call member function
-    return l->func(L,obj);
+    //at the moment, there isn't a case where NULL is acceptable to be used in the function, so check
+    //for it here, rather than individually for each function
+    if(obj == NULL)
+    {
+        lua_pushnil(L);
+        return 1;
+    }
+    else
+        return l->func(L,obj);  // call member function
 }
 
 

+ 17 - 3
Source/Core/Lua/Vector2f.cpp

@@ -22,6 +22,7 @@ int Vector2fnew(lua_State* L)
 int Vector2f__mul(lua_State* L)
 {
     Vector2f* lhs = LuaType<Vector2f>::check(L,1);
+    LUACHECKOBJ(lhs);
     float rhs = (float)luaL_checknumber(L,2);
 
     Vector2f* res = new Vector2f(*lhs);
@@ -34,6 +35,7 @@ int Vector2f__mul(lua_State* L)
 int Vector2f__div(lua_State* L)
 {
     Vector2f* lhs = LuaType<Vector2f>::check(L,1);
+    LUACHECKOBJ(lhs);
     float rhs = (float)luaL_checknumber(L,2);
 
     Vector2f* res = new Vector2f(*lhs);
@@ -46,7 +48,9 @@ int Vector2f__div(lua_State* L)
 int Vector2f__add(lua_State* L)
 {
     Vector2f* lhs = LuaType<Vector2f>::check(L,1);
-    Vector2f* rhs = LuaType<Vector2f>::check(L,1);
+    LUACHECKOBJ(lhs);
+    Vector2f* rhs = LuaType<Vector2f>::check(L,2);
+    LUACHECKOBJ(rhs);
 
     Vector2f* res = new Vector2f(*lhs);
     (*res) += (*rhs);
@@ -58,7 +62,9 @@ int Vector2f__add(lua_State* L)
 int Vector2f__sub(lua_State* L)
 {
     Vector2f* lhs = LuaType<Vector2f>::check(L,1);
-    Vector2f* rhs = LuaType<Vector2f>::check(L,1);
+    LUACHECKOBJ(lhs);
+    Vector2f* rhs = LuaType<Vector2f>::check(L,2);
+    LUACHECKOBJ(rhs);
 
     Vector2f* res = new Vector2f(*lhs);
     (*res) -= (*rhs);
@@ -70,7 +76,9 @@ int Vector2f__sub(lua_State* L)
 int Vector2f__eq(lua_State* L)
 {
     Vector2f* lhs = LuaType<Vector2f>::check(L,1);
-    Vector2f* rhs = LuaType<Vector2f>::check(L,1);
+    LUACHECKOBJ(lhs);
+    Vector2f* rhs = LuaType<Vector2f>::check(L,2);
+    LUACHECKOBJ(rhs);
 
     lua_pushboolean(L, (*lhs) == (*rhs) ? 1 : 0);
     return 1;
@@ -80,6 +88,7 @@ int Vector2f__eq(lua_State* L)
 int Vector2fDotProduct(lua_State* L, Vector2f* obj)
 {
     Vector2f* rhs = LuaType<Vector2f>::check(L,1);
+    LUACHECKOBJ(rhs);
     
     float res = obj->DotProduct(*rhs);
 
@@ -110,6 +119,7 @@ int Vector2fRotate(lua_State* L, Vector2f* obj)
 int Vector2fGetAttrx(lua_State*L)
 {
     Vector2f* self = LuaType<Vector2f>::check(L,1);
+    LUACHECKOBJ(self);
 
     lua_pushnumber(L,self->x);
     return 1;
@@ -118,6 +128,7 @@ int Vector2fGetAttrx(lua_State*L)
 int Vector2fGetAttry(lua_State*L)
 {
     Vector2f* self = LuaType<Vector2f>::check(L,1);
+    LUACHECKOBJ(self);
 
     lua_pushnumber(L,self->y);
     return 1;
@@ -126,6 +137,7 @@ int Vector2fGetAttry(lua_State*L)
 int Vector2fGetAttrmagnitude(lua_State*L)
 {
     Vector2f* self = LuaType<Vector2f>::check(L,1);
+    LUACHECKOBJ(self);
 
     lua_pushnumber(L,self->Magnitude());
     return 1;
@@ -134,6 +146,7 @@ int Vector2fGetAttrmagnitude(lua_State*L)
 int Vector2fSetAttrx(lua_State*L)
 {
     Vector2f* self = LuaType<Vector2f>::check(L,1);
+    LUACHECKOBJ(self);
     float value = (float)luaL_checknumber(L,2);
 
     self->x = value;
@@ -143,6 +156,7 @@ int Vector2fSetAttrx(lua_State*L)
 int Vector2fSetAttry(lua_State*L)
 {
     Vector2f* self = LuaType<Vector2f>::check(L,1);
+    LUACHECKOBJ(self);
     float value = (float)luaL_checknumber(L,2);
 
     self->y = value;

+ 16 - 3
Source/Core/Lua/Vector2i.cpp

@@ -21,6 +21,7 @@ int Vector2inew(lua_State* L)
 int Vector2i__mul(lua_State* L)
 {
     Vector2i* lhs = LuaType<Vector2i>::check(L,1);
+    LUACHECKOBJ(lhs);
     int rhs = luaL_checkint(L,2);
 
     Vector2i* res = new Vector2i(*lhs);
@@ -33,6 +34,7 @@ int Vector2i__mul(lua_State* L)
 int Vector2i__div(lua_State* L)
 {
     Vector2i* lhs = LuaType<Vector2i>::check(L,1);
+    LUACHECKOBJ(lhs);
     int rhs = luaL_checkint(L,2);
 
     Vector2i* res = new Vector2i(*lhs);
@@ -45,7 +47,9 @@ int Vector2i__div(lua_State* L)
 int Vector2i__add(lua_State* L)
 {
     Vector2i* lhs = LuaType<Vector2i>::check(L,1);
-    Vector2i* rhs = LuaType<Vector2i>::check(L,1);
+    LUACHECKOBJ(lhs);
+    Vector2i* rhs = LuaType<Vector2i>::check(L,2);
+    LUACHECKOBJ(rhs);
 
     Vector2i* res = new Vector2i(*lhs);
     (*res) += (*rhs);
@@ -57,7 +61,9 @@ int Vector2i__add(lua_State* L)
 int Vector2i__sub(lua_State* L)
 {
     Vector2i* lhs = LuaType<Vector2i>::check(L,1);
-    Vector2i* rhs = LuaType<Vector2i>::check(L,1);
+    LUACHECKOBJ(lhs);
+    Vector2i* rhs = LuaType<Vector2i>::check(L,2);
+    LUACHECKOBJ(rhs);
 
     Vector2i* res = new Vector2i(*lhs);
     (*res) -= (*rhs);
@@ -69,7 +75,9 @@ int Vector2i__sub(lua_State* L)
 int Vector2i__eq(lua_State* L)
 {
     Vector2i* lhs = LuaType<Vector2i>::check(L,1);
-    Vector2i* rhs = LuaType<Vector2i>::check(L,1);
+    LUACHECKOBJ(lhs);
+    Vector2i* rhs = LuaType<Vector2i>::check(L,2);
+    LUACHECKOBJ(rhs);
 
     lua_pushboolean(L, (*lhs) == (*rhs) ? 1 : 0);
     return 1;
@@ -78,6 +86,7 @@ int Vector2i__eq(lua_State* L)
 int Vector2iGetAttrx(lua_State*L)
 {
     Vector2i* self = LuaType<Vector2i>::check(L,1);
+    LUACHECKOBJ(self);
 
     lua_pushinteger(L,self->x);
     return 1;
@@ -86,6 +95,7 @@ int Vector2iGetAttrx(lua_State*L)
 int Vector2iGetAttry(lua_State*L)
 {
     Vector2i* self = LuaType<Vector2i>::check(L,1);
+    LUACHECKOBJ(self);
 
     lua_pushinteger(L,self->y);
     return 1;
@@ -94,6 +104,7 @@ int Vector2iGetAttry(lua_State*L)
 int Vector2iGetAttrmagnitude(lua_State*L)
 {
     Vector2i* self = LuaType<Vector2i>::check(L,1);
+    LUACHECKOBJ(self);
 
     lua_pushnumber(L,self->Magnitude());
     return 1;
@@ -102,6 +113,7 @@ int Vector2iGetAttrmagnitude(lua_State*L)
 int Vector2iSetAttrx(lua_State*L)
 {
     Vector2i* self = LuaType<Vector2i>::check(L,1);
+    LUACHECKOBJ(self);
     int value = luaL_checkint(L,2);
 
     self->x = value;
@@ -111,6 +123,7 @@ int Vector2iSetAttrx(lua_State*L)
 int Vector2iSetAttry(lua_State*L)
 {
     Vector2i* self = LuaType<Vector2i>::check(L,1);
+    LUACHECKOBJ(self);
     int value = luaL_checkint(L,2);
 
     self->y = value;