From 49ea23c532cb0d8ab6e27d290484a1e2daadb347 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 5 Aug 2010 10:16:21 +0000 Subject: SWORD25: Fix for void * conversion errors It turns out that strict C++ doesn't allow function pointers to be converted to void pointers and vice versa. Since there are two callback function pointer types - one with a KEY_COMMANDS enum parameter, and the other with an unsigned char type, I changed all void * occurances to a function pointer type with an 'int' parameter, and changed all implementation methods to take in an int parameter. svn-id: r53208 --- engines/sword25/input/inputengine_script.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'engines/sword25/input/inputengine_script.cpp') diff --git a/engines/sword25/input/inputengine_script.cpp b/engines/sword25/input/inputengine_script.cpp index 0580caa983..a7bd39481b 100644 --- a/engines/sword25/input/inputengine_script.cpp +++ b/engines/sword25/input/inputengine_script.cpp @@ -57,8 +57,8 @@ using namespace Lua; // Callback-Objekte // ----------------------------------------------------------------------------- -static void TheCharacterCallback(unsigned char Character); -static void TheCommandCallback(BS_InputEngine::KEY_COMMANDS Command); +static void TheCharacterCallback(int Character); +static void TheCommandCallback(int Command); namespace { class CharacterCallbackClass : public BS_LuaCallback { @@ -68,8 +68,7 @@ namespace { Common::String Character; protected: - int PreFunctionInvokation(lua_State *L) - { + int PreFunctionInvokation(lua_State *L) { lua_pushstring(L, Character.c_str()); return 1; } @@ -242,8 +241,8 @@ static int SetMouseY(lua_State *L) { // ----------------------------------------------------------------------------- -static void TheCharacterCallback(unsigned char Character) { - CharacterCallbackPtr->Character = Character; +static void TheCharacterCallback(int Character) { + CharacterCallbackPtr->Character = static_cast(Character); lua_State *L = static_cast(BS_Kernel::GetInstance()->GetScript()->GetScriptObject()); CharacterCallbackPtr->InvokeCallbackFunctions(L, 1); } @@ -268,8 +267,8 @@ static int UnregisterCharacterCallback(lua_State *L) { // ----------------------------------------------------------------------------- -static void TheCommandCallback(BS_InputEngine::KEY_COMMANDS Command) { - CommandCallbackPtr->Command = Command; +static void TheCommandCallback(int Command) { + CommandCallbackPtr->Command = static_cast(Command); lua_State *L = static_cast(BS_Kernel::GetInstance()->GetScript()->GetScriptObject()); CommandCallbackPtr->InvokeCallbackFunctions(L, 1); } @@ -345,10 +344,8 @@ bool BS_InputEngine::_RegisterScriptBindings() { if (!BS_LuaBindhelper::AddFunctionsToLib(L, PACKAGE_LIBRARY_NAME, PACKAGE_FUNCTIONS)) return false; if (!BS_LuaBindhelper::AddConstantsToLib(L, PACKAGE_LIBRARY_NAME, PACKAGE_CONSTANTS)) return false; - Common::SharedPtr p1(new CharacterCallbackClass(L)); - CharacterCallbackPtr = p1; - Common::SharedPtr p2(new CommandCallbackClass(L)); - CommandCallbackPtr = p2; + CharacterCallbackPtr = Common::SharedPtr(new CharacterCallbackClass(L)); + CommandCallbackPtr = Common::SharedPtr(new CommandCallbackClass(L)); return true; } -- cgit v1.2.3