Browse Source

Hopefully last set of bug fixes/features.

Removed commented out parts for python in the luainvaders sample.

Allowed Colour.rgba to be set as well as read.

Made sure that the functions left the Lua stack as they got it.

Made the DocumentFocus table for flags to be used in Document.Focus function.

Made the Lua function print output to the Log.
Nate Starkey 13 years ago
parent
commit
d99eaf9518

+ 0 - 17
Samples/luainvaders/src/ElementGame.cpp

@@ -29,11 +29,6 @@
 #include <Rocket/Core/ElementDocument.h>
 #include <Rocket/Core/ElementDocument.h>
 #include <Rocket/Core/Input.h>
 #include <Rocket/Core/Input.h>
 #include <Rocket/Core/Factory.h>
 #include <Rocket/Core/Factory.h>
-/*
-#include <Rocket/Core/Python/ElementInstancer.h>
-#include <Rocket/Core/Python/ElementWrapper.h>
-#include <Rocket/Core/Python/Python.h>
-*/
 #include "Defender.h"
 #include "Defender.h"
 #include "Game.h"
 #include "Game.h"
 
 
@@ -47,18 +42,6 @@ ElementGame::~ElementGame()
 	delete game;
 	delete game;
 }
 }
 
 
-void ElementGame::InitialisePythonInterface()
-{
-    //not sure that this is needed for Lua
-    /*
-	PyObject* object = python::class_<ElementGame, Rocket::Core::Python::ElementWrapper<ElementGame>, python::bases<Rocket::Core::Element>, boost::noncopyable >("ElementGame", python::init<const char*>())
-		.ptr();
-
-	Rocket::Core::Factory::RegisterElementInstancer("game", new Rocket::Core::Python::ElementInstancer(object))->RemoveReference();
-    Rocket::Core::ElementInstancerGeneric<ElementGame>();
-    */
-}
-
 // Intercepts and handles key events.
 // Intercepts and handles key events.
 void ElementGame::ProcessEvent(Rocket::Core::Event& event)
 void ElementGame::ProcessEvent(Rocket::Core::Event& event)
 {
 {

+ 0 - 3
Samples/luainvaders/src/ElementGame.h

@@ -43,9 +43,6 @@ public:
 	ElementGame(const Rocket::Core::String& tag);
 	ElementGame(const Rocket::Core::String& tag);
 	virtual ~ElementGame();
 	virtual ~ElementGame();
 
 
-	/// Initialises the python interface and registers the serialiser
-	static void InitialisePythonInterface();
-
 	/// Intercepts and handles key events.
 	/// Intercepts and handles key events.
 	void ProcessEvent(Rocket::Core::Event& event);
 	void ProcessEvent(Rocket::Core::Event& event);
 
 

+ 1 - 1
Samples/luainvaders/src/LuaInterface.cpp

@@ -114,4 +114,4 @@ int GameSetHighScoreName(lua_State* L)
     const char* name = luaL_checkstring(L,1);
     const char* name = luaL_checkstring(L,1);
     HighScores::SubmitName(name);
     HighScores::SubmitName(name);
     return 0;
     return 0;
-}
+}

+ 3 - 6
Samples/luainvaders/src/main.cpp

@@ -91,8 +91,7 @@ int main(int, char**)
 	// Initialise the Rocket Controls library.
 	// Initialise the Rocket Controls library.
 	Rocket::Controls::Initialise();
 	Rocket::Controls::Initialise();
 
 
-	// Initialise the Python interface.
-	//PythonInterface::Initialise((Shell::GetExecutablePath() + (APP_PATH "python") + PATH_SEPARATOR + Shell::GetExecutablePath() + ROCKET_PATH).CString());
+	// Initialise the Lua interface
     Rocket::Core::Lua::Interpreter::Initialise();
     Rocket::Core::Lua::Interpreter::Initialise();
     Rocket::Controls::Lua::RegisterTypes(Rocket::Core::Lua::Interpreter::GetLuaState());
     Rocket::Controls::Lua::RegisterTypes(Rocket::Core::Lua::Interpreter::GetLuaState());
 
 
@@ -124,8 +123,7 @@ int main(int, char**)
 	HighScores::Initialise();
 	HighScores::Initialise();
 
 
 	// Fire off the startup script.
 	// Fire off the startup script.
-	//PythonInterface::Import("autoexec");
-    LuaInterface::Initialise(Rocket::Core::Lua::Interpreter::GetLuaState());
+    LuaInterface::Initialise(Rocket::Core::Lua::Interpreter::GetLuaState()); //the tables/functions defined in the samples
     Rocket::Core::Lua::Interpreter::LoadFile(Rocket::Core::String(APP_PATH).Append("lua/start.lua"));
     Rocket::Core::Lua::Interpreter::LoadFile(Rocket::Core::String(APP_PATH).Append("lua/start.lua"));
 
 
 	Shell::EventLoop(GameLoop);	
 	Shell::EventLoop(GameLoop);	
@@ -133,8 +131,7 @@ int main(int, char**)
 	// Shutdown the Rocket contexts.	
 	// Shutdown the Rocket contexts.	
 	context->RemoveReference();
 	context->RemoveReference();
 	
 	
-	// Shutdown Python before we shut down Rocket.
-	//PythonInterface::Shutdown();
+	// Shutdown Lua  before we shut down Rocket.
 	Rocket::Core::Lua::Interpreter::Shutdown();
 	Rocket::Core::Lua::Interpreter::Shutdown();
 
 
 	// Shut down the game singletons.
 	// Shut down the game singletons.

+ 12 - 1
Source/Controls/Lua/DataSource.cpp

@@ -30,12 +30,23 @@
 #include <Rocket/Core/Log.h>
 #include <Rocket/Core/Log.h>
 
 
 using Rocket::Core::Log;
 using Rocket::Core::Log;
-template<> void Rocket::Core::Lua::ExtraInit<Rocket::Controls::Lua::LuaDataSource>(lua_State* L, int metatable_index) { return; }
+template<> void Rocket::Core::Lua::ExtraInit<Rocket::Controls::Lua::LuaDataSource>(lua_State* L, int metatable_index) 
+{ 
+    return; 
+}
 namespace Rocket {
 namespace Rocket {
 namespace Controls {
 namespace Controls {
 namespace Lua {
 namespace Lua {
 typedef LuaDataSource DataSource;
 typedef LuaDataSource DataSource;
 
 
+int DataSourcenew(lua_State* L)
+{
+    const char* name = luaL_checkstring(L,1);
+    LuaDataSource* ds = new LuaDataSource(name);
+    LuaType<DataSource>::push(L,ds,true);
+    return 1;
+}
+
 int DataSourceNotifyRowAdd(lua_State* L, DataSource* obj)
 int DataSourceNotifyRowAdd(lua_State* L, DataSource* obj)
 {
 {
     LUACHECKOBJ(obj);
     LUACHECKOBJ(obj);

+ 2 - 0
Source/Controls/Lua/DataSource.h

@@ -39,6 +39,8 @@ namespace Controls {
 namespace Lua {
 namespace Lua {
 typedef LuaDataSource DataSource;
 typedef LuaDataSource DataSource;
 
 
+int DataSourcenew(lua_State* L);
+
 int DataSourceNotifyRowAdd(lua_State* L, DataSource* obj);
 int DataSourceNotifyRowAdd(lua_State* L, DataSource* obj);
 int DataSourceNotifyRowRemove(lua_State* L, DataSource* obj);
 int DataSourceNotifyRowRemove(lua_State* L, DataSource* obj);
 int DataSourceNotifyRowChange(lua_State* L, DataSource* obj);
 int DataSourceNotifyRowChange(lua_State* L, DataSource* obj);

+ 9 - 2
Source/Controls/Lua/ElementForm.cpp

@@ -47,8 +47,15 @@ namespace Lua {
 //method
 //method
 int ElementFormSubmit(lua_State* L, ElementForm* obj)
 int ElementFormSubmit(lua_State* L, ElementForm* obj)
 {
 {
-    const char* name = luaL_checkstring(L,1);
-    const char* value = luaL_checkstring(L,2);
+    int top = lua_gettop(L);
+    const char* name = "";
+    const char* value = "";
+    if(top > 0)
+    {
+        name = luaL_checkstring(L,1);
+        if(top > 1)
+            value = luaL_checkstring(L,2);
+    }
     obj->Submit(name,value);
     obj->Submit(name,value);
     return 0;
     return 0;
 }
 }

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

@@ -70,19 +70,6 @@ int ElementFormControlSelectRemove(lua_State* L, ElementFormControlSelect* obj)
     return 0;
     return 0;
 }
 }
 
 
-int ElementFormControlSelectGetOption(lua_State* L, ElementFormControlSelect* obj)
-{
-    int index = luaL_checkint(L,1);
-    Rocket::Controls::SelectOption* opt = obj->GetOption(index);
-    lua_newtable(L);
-    LuaType<Rocket::Core::Element>::push(L,opt->GetElement(),false);
-    lua_setfield(L,-2,"element");
-    lua_pushstring(L,opt->GetValue().CString());
-    lua_setfield(L,-2,"value");
-    return 1;
-}
-
-
 //getters
 //getters
 int ElementFormControlSelectGetAttroptions(lua_State* L)
 int ElementFormControlSelectGetAttroptions(lua_State* L)
 {
 {
@@ -98,7 +85,6 @@ int ElementFormControlSelectGetAttrselection(lua_State* L)
 {
 {
     ElementFormControlSelect* obj = LuaType<ElementFormControlSelect>::check(L,1);
     ElementFormControlSelect* obj = LuaType<ElementFormControlSelect>::check(L,1);
     LUACHECKOBJ(obj);
     LUACHECKOBJ(obj);
-
     int selection = obj->GetSelection();
     int selection = obj->GetSelection();
     lua_pushinteger(L,selection);
     lua_pushinteger(L,selection);
     return 1;
     return 1;
@@ -120,7 +106,6 @@ Rocket::Core::Lua::RegType<ElementFormControlSelect> ElementFormControlSelectMet
 {
 {
     LUAMETHOD(ElementFormControlSelect,Add)
     LUAMETHOD(ElementFormControlSelect,Add)
     LUAMETHOD(ElementFormControlSelect,Remove)
     LUAMETHOD(ElementFormControlSelect,Remove)
-    LUAMETHOD(ElementFormControlSelect,GetOption)
     { NULL, NULL },
     { NULL, NULL },
 };
 };
 
 

+ 0 - 1
Source/Controls/Lua/ElementFormControlSelect.h

@@ -42,7 +42,6 @@ namespace Lua {
 //methods
 //methods
 int ElementFormControlSelectAdd(lua_State* L, ElementFormControlSelect* obj);
 int ElementFormControlSelectAdd(lua_State* L, ElementFormControlSelect* obj);
 int ElementFormControlSelectRemove(lua_State* L, ElementFormControlSelect* obj);
 int ElementFormControlSelectRemove(lua_State* L, ElementFormControlSelect* obj);
-int ElementFormControlSelectGetOption(lua_State* L, ElementFormControlSelect* obj);
 
 
 //getters
 //getters
 int ElementFormControlSelectGetAttroptions(lua_State* L);
 int ElementFormControlSelectGetAttroptions(lua_State* L);

+ 4 - 0
Source/Controls/Lua/LuaDataFormatter.cpp

@@ -54,11 +54,13 @@ void LuaDataFormatter::FormatData(Rocket::Core::String& formatted_data, const Ro
         return;
         return;
     }
     }
     lua_State* L = Interpreter::GetLuaState();
     lua_State* L = Interpreter::GetLuaState();
+    int top = lua_gettop(L);
     PushDataFormatterFunctionTable(L); // push the table where the function resides
     PushDataFormatterFunctionTable(L); // push the table where the function resides
     lua_rawgeti(L,-1,ref_FormatData); //push the function
     lua_rawgeti(L,-1,ref_FormatData); //push the function
     if(lua_type(L,-1) != LUA_TFUNCTION)
     if(lua_type(L,-1) != LUA_TFUNCTION)
     {
     {
         Log::Message(Log::LT_ERROR, "In LuaDataFormatter: The value for the FormatData variable must be a function. You passed in a %s.", lua_typename(L,lua_type(L,-1)));
         Log::Message(Log::LT_ERROR, "In LuaDataFormatter: The value for the FormatData variable must be a function. You passed in a %s.", lua_typename(L,lua_type(L,-1)));
+        lua_settop(L,top);
         return;
         return;
     }
     }
     lua_newtable(L); //to hold raw_data
     lua_newtable(L); //to hold raw_data
@@ -74,9 +76,11 @@ void LuaDataFormatter::FormatData(Rocket::Core::String& formatted_data, const Ro
     if(lua_type(L,-1) != LUA_TSTRING)
     if(lua_type(L,-1) != LUA_TSTRING)
     {
     {
         Log::Message(Log::LT_ERROR, "In LuaDataFormatter: the return value of FormatData must be a string. You returned a %s.", lua_typename(L,lua_type(L,-1)));
         Log::Message(Log::LT_ERROR, "In LuaDataFormatter: the return value of FormatData must be a string. You returned a %s.", lua_typename(L,lua_type(L,-1)));
+        lua_settop(L,top);
         return;
         return;
     }
     }
     formatted_data = Rocket::Core::String(lua_tostring(L,-1));
     formatted_data = Rocket::Core::String(lua_tostring(L,-1));
+    lua_settop(L,top);
 }
 }
 
 
 void LuaDataFormatter::PushDataFormatterFunctionTable(lua_State* L)
 void LuaDataFormatter::PushDataFormatterFunctionTable(lua_State* L)

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

@@ -182,6 +182,30 @@ int ColourbSetAttralpha(lua_State* L)
     return 0;
     return 0;
 }
 }
 
 
+int ColourbSetAttrrgba(lua_State* L)
+{
+    Colourb* obj = NULL;
+    int top = lua_gettop(L);
+    //each of the items are optional.
+    if(top > 0)
+    {
+        obj = LuaType<Colourb>::check(L,1);
+        LUACHECKOBJ(obj);
+        if(top > 1)
+        {
+            if(top > 2)
+            {
+                if(top > 3)
+                    obj->alpha = luaL_checkint(L,4);
+                obj->blue = luaL_checkint(L,3);
+            }
+            obj->green = luaL_checkint(L,2);
+        }
+        obj->red = luaL_checkint(L,1);
+    }
+    return 0;
+}
+
 
 
 RegType<Colourb> ColourbMethods[] =
 RegType<Colourb> ColourbMethods[] =
 {
 {
@@ -204,6 +228,7 @@ luaL_reg ColourbSetters[] =
     LUASETTER(Colourb,green)
     LUASETTER(Colourb,green)
     LUASETTER(Colourb,blue)
     LUASETTER(Colourb,blue)
     LUASETTER(Colourb,alpha)
     LUASETTER(Colourb,alpha)
+    LUASETTER(Colourb,rgba)
     { NULL, NULL },
     { NULL, NULL },
 };
 };
 
 

+ 1 - 0
Source/Core/Lua/Colourb.h

@@ -55,6 +55,7 @@ int ColourbSetAttrred(lua_State* L);
 int ColourbSetAttrgreen(lua_State* L);
 int ColourbSetAttrgreen(lua_State* L);
 int ColourbSetAttrblue(lua_State* L);
 int ColourbSetAttrblue(lua_State* L);
 int ColourbSetAttralpha(lua_State* L);
 int ColourbSetAttralpha(lua_State* L);
+int ColourbSetAttrrgba(lua_State* L);
 
 
 RegType<Colourb> ColourbMethods[];
 RegType<Colourb> ColourbMethods[];
 luaL_reg ColourbGetters[];
 luaL_reg ColourbGetters[];

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

@@ -152,6 +152,30 @@ int ColourfSetAttralpha(lua_State* L)
     return 0;
     return 0;
 }
 }
 
 
+int ColourfSetAttrrgba(lua_State* L)
+{
+    Colourf* obj = NULL;
+    int top = lua_gettop(L);
+    //each of the items are optional.
+    if(top > 0)
+    {
+        obj = LuaType<Colourf>::check(L,1);
+        LUACHECKOBJ(obj);
+        if(top > 1)
+        {
+            if(top > 2)
+            {
+                if(top > 3)
+                    obj->alpha = (float)luaL_checknumber(L,4);
+                obj->blue = (float)luaL_checknumber(L,3);
+            }
+            obj->green = (float)luaL_checknumber(L,2);
+        }
+        obj->red = (float)luaL_checknumber(L,1);
+    }
+    return 0;
+}
+
 
 
 RegType<Colourf> ColourfMethods[] =
 RegType<Colourf> ColourfMethods[] =
 {
 {
@@ -174,6 +198,7 @@ luaL_reg ColourfSetters[] =
     LUASETTER(Colourf,green)
     LUASETTER(Colourf,green)
     LUASETTER(Colourf,blue)
     LUASETTER(Colourf,blue)
     LUASETTER(Colourf,alpha)
     LUASETTER(Colourf,alpha)
+    LUASETTER(Colourf,rgba)
     { NULL, NULL },
     { NULL, NULL },
 };
 };
 
 

+ 1 - 0
Source/Core/Lua/Colourf.h

@@ -53,6 +53,7 @@ int ColourfSetAttrred(lua_State* L);
 int ColourfSetAttrgreen(lua_State* L);
 int ColourfSetAttrgreen(lua_State* L);
 int ColourfSetAttrblue(lua_State* L);
 int ColourfSetAttrblue(lua_State* L);
 int ColourfSetAttralpha(lua_State* L);
 int ColourfSetAttralpha(lua_State* L);
+int ColourfSetAttrrgba(lua_State* L);
 
 
 RegType<Colourf> ColourfMethods[];
 RegType<Colourf> ColourfMethods[];
 luaL_reg ColourfGetters[];
 luaL_reg ColourfGetters[];

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

@@ -93,8 +93,6 @@ int ContextCreateDocument(lua_State* L, Context* obj)
         tag = luaL_checkstring(L,1);
         tag = luaL_checkstring(L,1);
     Document* doc = obj->CreateDocument(tag);
     Document* doc = obj->CreateDocument(tag);
     LuaType<Document>::push(L,doc,true);
     LuaType<Document>::push(L,doc,true);
-	//for debugging
-	int count = doc->GetReferenceCount();
     return 1;
     return 1;
 }
 }
 
 

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

@@ -42,6 +42,22 @@ template<> void ExtraInit<Document>(lua_State* L, int metatable_index)
     ExtraInit<Element>(L,metatable_index);
     ExtraInit<Element>(L,metatable_index);
     LuaType<Element>::_regfunctions(L,metatable_index,metatable_index - 1);
     LuaType<Element>::_regfunctions(L,metatable_index,metatable_index - 1);
     AddTypeToElementAsTable<Document>(L);
     AddTypeToElementAsTable<Document>(L);
+    
+    //create the DocumentFocus table
+    lua_getglobal(L,"DocumentFocus");
+    if(lua_isnoneornil(L,-1))
+    {
+        lua_pop(L,1); //pop unsucessful getglobal
+        lua_newtable(L); //create a table for holding the enum
+        lua_pushinteger(L,ElementDocument::NONE);
+        lua_setfield(L,-2,"NONE");
+        lua_pushinteger(L,ElementDocument::FOCUS);
+        lua_setfield(L,-2,"FOCUS");
+        lua_pushinteger(L,ElementDocument::MODAL);
+        lua_setfield(L,-2,"MODAL");
+        lua_setglobal(L,"DocumentFocus");
+        
+    }
 }
 }
 
 
 //methods
 //methods

+ 34 - 0
Source/Core/Lua/Log.cpp

@@ -28,6 +28,8 @@
 #include "precompiled.h"
 #include "precompiled.h"
 #include "Log.h"
 #include "Log.h"
 #include <Rocket/Core/Log.h>
 #include <Rocket/Core/Log.h>
+#include <Rocket/Core/String.h>
+#include <Rocket/Core/StringUtilities.h>
 
 
 
 
 namespace Rocket {
 namespace Rocket {
@@ -66,6 +68,10 @@ template<> void ExtraInit<Log>(lua_State* L, int metatable_index)
 
 
     lua_pop(L,1); //pop the logtype table
     lua_pop(L,1); //pop the logtype table
 
 
+
+    //overwrite the default 'print' function
+    lua_register(L,"print",OverwriteLuaPrint);
+
     return;
     return;
 }
 }
 
 
@@ -78,6 +84,34 @@ int LogMessage(lua_State* L)
     return 0;
     return 0;
 }
 }
 
 
+//Based off of the luaB_print function from lbaselib.c
+int OverwriteLuaPrint(lua_State* L)
+{
+    int n = lua_gettop(L);  /* number of arguments */
+    int i;
+    lua_getglobal(L, "tostring");
+    StringList string_list = StringList();
+    String output = "";
+    for (i=1; i<=n; i++) 
+    {
+        const char *s;
+        lua_pushvalue(L, -1);  /* function to be called */
+        lua_pushvalue(L, i);   /* value to print */
+        lua_call(L, 1, 1);
+        s = lua_tostring(L, -1);  /* get result */
+        if (s == NULL)
+            return luaL_error(L, LUA_QL("tostring") " must return a string to "
+                                 LUA_QL("print"));
+        if (i>1) 
+            output += "\t";
+        output += String(s);
+        lua_pop(L, 1);  /* pop result */
+    }
+    output += "\n";
+    Log::Message(Log::LT_INFO, output.CString());
+    return 0;
+}
+
 
 
 RegType<Log> LogMethods[] =
 RegType<Log> LogMethods[] =
 {
 {

+ 1 - 0
Source/Core/Lua/Log.h

@@ -34,6 +34,7 @@ namespace Lua {
 
 
 template<> void ExtraInit<Log>(lua_State* L, int metatable_index);
 template<> void ExtraInit<Log>(lua_State* L, int metatable_index);
 int LogMessage(lua_State* L);
 int LogMessage(lua_State* L);
+int OverwriteLuaPrint(lua_State* L);
 
 
 RegType<Log> LogMethods[];
 RegType<Log> LogMethods[];
 luaL_reg LogGetters[];
 luaL_reg LogGetters[];

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

@@ -45,6 +45,7 @@ LuaEventListener::LuaEventListener(const String& code, Element* element) : Event
 
 
     //make sure there is an area to save the function
     //make sure there is an area to save the function
     lua_State* L = Interpreter::GetLuaState();
     lua_State* L = Interpreter::GetLuaState();
+    int top = lua_gettop(L);
     lua_getglobal(L,"EVENTLISTENERFUNCTIONS");
     lua_getglobal(L,"EVENTLISTENERFUNCTIONS");
     if(lua_isnoneornil(L,-1))
     if(lua_isnoneornil(L,-1))
     {
     {
@@ -68,11 +69,13 @@ LuaEventListener::LuaEventListener(const String& code, Element* element) : Event
 	else
 	else
 		parent = NULL;
 		parent = NULL;
     strFunc = function;
     strFunc = function;
+    lua_settop(L,top);
 }
 }
 
 
 //if it is passed in a Lua function
 //if it is passed in a Lua function
 LuaEventListener::LuaEventListener(lua_State* L, int narg, Element* element)
 LuaEventListener::LuaEventListener(lua_State* L, int narg, Element* element)
 {
 {
+    int top = lua_gettop(L);
     lua_getglobal(L,"EVENTLISTENERFUNCTIONS");
     lua_getglobal(L,"EVENTLISTENERFUNCTIONS");
 	if(lua_isnoneornil(L,-1))
 	if(lua_isnoneornil(L,-1))
 	{
 	{
@@ -90,6 +93,7 @@ LuaEventListener::LuaEventListener(lua_State* L, int narg, Element* element)
 		parent = element->GetOwnerDocument();
 		parent = element->GetOwnerDocument();
 	else
 	else
 		parent = NULL;
 		parent = NULL;
+    lua_settop(L,top);
 }
 }
 
 
 LuaEventListener::~LuaEventListener()
 LuaEventListener::~LuaEventListener()

+ 2 - 2
Source/Core/Lua/Rocket.cpp

@@ -79,8 +79,8 @@ int rocketCreateContext(lua_State* L)
 int rocketLoadFontFace(lua_State* L)
 int rocketLoadFontFace(lua_State* L)
 {
 {
     const char* file = luaL_checkstring(L,1);
     const char* file = luaL_checkstring(L,1);
-    FontDatabase::LoadFontFace(file);
-    return 0;
+    lua_pushboolean(L,FontDatabase::LoadFontFace(file));
+    return 1;
 }
 }
 
 
 int rocketRegisterTag(lua_State* L)
 int rocketRegisterTag(lua_State* L)

+ 8 - 8
Source/Core/Lua/Vector2f.cpp

@@ -74,8 +74,8 @@ int Vector2f__mul(lua_State* L)
     LUACHECKOBJ(lhs);
     LUACHECKOBJ(lhs);
     float rhs = (float)luaL_checknumber(L,2);
     float rhs = (float)luaL_checknumber(L,2);
 
 
-    Vector2f* res = new Vector2f(*lhs);
-    (*res) *= rhs;
+    Vector2f* res = new Vector2f(0.f,0.f);
+    (*res) = (*lhs) * rhs;
 
 
     LuaType<Vector2f>::push(L,res,true);
     LuaType<Vector2f>::push(L,res,true);
     return 1;
     return 1;
@@ -87,8 +87,8 @@ int Vector2f__div(lua_State* L)
     LUACHECKOBJ(lhs);
     LUACHECKOBJ(lhs);
     float rhs = (float)luaL_checknumber(L,2);
     float rhs = (float)luaL_checknumber(L,2);
 
 
-    Vector2f* res = new Vector2f(*lhs);
-    (*res) /= rhs;
+    Vector2f* res = new Vector2f(0.f,0.f);
+    (*res) = (*lhs) / rhs;
 
 
     LuaType<Vector2f>::push(L,res,true);
     LuaType<Vector2f>::push(L,res,true);
     return 1;
     return 1;
@@ -101,8 +101,8 @@ int Vector2f__add(lua_State* L)
     Vector2f* rhs = LuaType<Vector2f>::check(L,2);
     Vector2f* rhs = LuaType<Vector2f>::check(L,2);
     LUACHECKOBJ(rhs);
     LUACHECKOBJ(rhs);
 
 
-    Vector2f* res = new Vector2f(*lhs);
-    (*res) += (*rhs);
+    Vector2f* res = new Vector2f(0.f,0.f);
+    (*res) = (*lhs) + (*rhs);
 
 
     LuaType<Vector2f>::push(L,res,true);
     LuaType<Vector2f>::push(L,res,true);
     return 1;
     return 1;
@@ -115,8 +115,8 @@ int Vector2f__sub(lua_State* L)
     Vector2f* rhs = LuaType<Vector2f>::check(L,2);
     Vector2f* rhs = LuaType<Vector2f>::check(L,2);
     LUACHECKOBJ(rhs);
     LUACHECKOBJ(rhs);
 
 
-    Vector2f* res = new Vector2f(*lhs);
-    (*res) -= (*rhs);
+    Vector2f* res = new Vector2f(0.f,0.f);
+    (*res) = (*lhs) - (*rhs);
 
 
     LuaType<Vector2f>::push(L,res,true);
     LuaType<Vector2f>::push(L,res,true);
     return 1;
     return 1;

+ 8 - 8
Source/Core/Lua/Vector2i.cpp

@@ -73,8 +73,8 @@ int Vector2i__mul(lua_State* L)
     LUACHECKOBJ(lhs);
     LUACHECKOBJ(lhs);
     int rhs = luaL_checkint(L,2);
     int rhs = luaL_checkint(L,2);
 
 
-    Vector2i* res = new Vector2i(*lhs);
-    (*res) *= rhs;
+    Vector2i* res = new Vector2i(0,0);
+    (*res) = (*lhs) * rhs;
 
 
     LuaType<Vector2i>::push(L,res,true);
     LuaType<Vector2i>::push(L,res,true);
     return 1;
     return 1;
@@ -86,8 +86,8 @@ int Vector2i__div(lua_State* L)
     LUACHECKOBJ(lhs);
     LUACHECKOBJ(lhs);
     int rhs = luaL_checkint(L,2);
     int rhs = luaL_checkint(L,2);
 
 
-    Vector2i* res = new Vector2i(*lhs);
-    (*res) /= rhs;
+    Vector2i* res = new Vector2i(0,0);
+    (*res) = (*lhs) / rhs;
 
 
     LuaType<Vector2i>::push(L,res,true);
     LuaType<Vector2i>::push(L,res,true);
     return 1;
     return 1;
@@ -100,8 +100,8 @@ int Vector2i__add(lua_State* L)
     Vector2i* rhs = LuaType<Vector2i>::check(L,2);
     Vector2i* rhs = LuaType<Vector2i>::check(L,2);
     LUACHECKOBJ(rhs);
     LUACHECKOBJ(rhs);
 
 
-    Vector2i* res = new Vector2i(*lhs);
-    (*res) += (*rhs);
+    Vector2i* res = new Vector2i(0,0);
+    (*res) = (*lhs) + (*rhs);
 
 
     LuaType<Vector2i>::push(L,res,true);
     LuaType<Vector2i>::push(L,res,true);
     return 1;
     return 1;
@@ -114,8 +114,8 @@ int Vector2i__sub(lua_State* L)
     Vector2i* rhs = LuaType<Vector2i>::check(L,2);
     Vector2i* rhs = LuaType<Vector2i>::check(L,2);
     LUACHECKOBJ(rhs);
     LUACHECKOBJ(rhs);
 
 
-    Vector2i* res = new Vector2i(*lhs);
-    (*res) -= (*rhs);
+    Vector2i* res = new Vector2i(0,0);
+    (*res) = (*lhs) - (*rhs);
 
 
     LuaType<Vector2i>::push(L,res,true);
     LuaType<Vector2i>::push(L,res,true);
     return 1;
     return 1;