From bf0a92db2f770c8fd4a5eed47893c660ac1e54ee Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Wed, 17 Feb 2016 17:19:09 +0000 Subject: lua_ffi: VC2010 compilation fix git-svn-id: http://svn.miranda-ng.org/main/trunk@16295 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirLua/Modules/ffi/ffi.vcxproj | 33 +++++++++++++++++++++++++++++++ plugins/MirLua/Modules/ffi/luaffi.vcxproj | 33 ------------------------------- plugins/MirLua/Modules/ffi/src/ffi.c | 21 ++++++++++++-------- plugins/MirLua/Modules/ffi/src/ffi.h | 27 ++++++++++++++----------- 4 files changed, 62 insertions(+), 52 deletions(-) create mode 100644 plugins/MirLua/Modules/ffi/ffi.vcxproj delete mode 100644 plugins/MirLua/Modules/ffi/luaffi.vcxproj (limited to 'plugins/MirLua/Modules') diff --git a/plugins/MirLua/Modules/ffi/ffi.vcxproj b/plugins/MirLua/Modules/ffi/ffi.vcxproj new file mode 100644 index 0000000000..bef3567b8e --- /dev/null +++ b/plugins/MirLua/Modules/ffi/ffi.vcxproj @@ -0,0 +1,33 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + ffi + {817D2806-9EC5-4607-A404-F031C98A1872} + + + + + + + ffi.h + + + \ No newline at end of file diff --git a/plugins/MirLua/Modules/ffi/luaffi.vcxproj b/plugins/MirLua/Modules/ffi/luaffi.vcxproj deleted file mode 100644 index bef3567b8e..0000000000 --- a/plugins/MirLua/Modules/ffi/luaffi.vcxproj +++ /dev/null @@ -1,33 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - ffi - {817D2806-9EC5-4607-A404-F031C98A1872} - - - - - - - ffi.h - - - \ No newline at end of file diff --git a/plugins/MirLua/Modules/ffi/src/ffi.c b/plugins/MirLua/Modules/ffi/src/ffi.c index a487c53296..20dcfbdc49 100644 --- a/plugins/MirLua/Modules/ffi/src/ffi.c +++ b/plugins/MirLua/Modules/ffi/src/ffi.c @@ -8,7 +8,6 @@ */ #include "ffi.h" #include -#include /* Set to 1 to get extra debugging on print */ #define DEBUG_TOSTRING 0 @@ -102,11 +101,12 @@ static int type_error(lua_State* L, int idx, const char* to_type, int to_usr, co static void* userdata_toptr(lua_State* L, int idx) { void* ptr = lua_touserdata(L, idx); + int isfile = 0; // check for FILE* lua_getmetatable(L, idx); luaL_getmetatable(L, LUA_FILEHANDLE); - int isfile = lua_rawequal(L, -1, -2); + isfile = lua_rawequal(L, -1, -2); lua_pop(L, 2); if (isfile) { @@ -666,12 +666,14 @@ err: * and returns 1 if it exists; otherwise returns 0 and nothing is pushed */ static int get_cfunction_address(lua_State* L, int idx, cfunction* addr) { + int top = 0; + int n = 2; + cfunction* f = NULL; if (!lua_isfunction(L, idx)) return 0; - int top = lua_gettop(L); + top = lua_gettop(L); // Get the last upvalue - int n = 2; while (lua_getupvalue(L, idx, n)) { lua_pop(L, 1); n++; @@ -697,7 +699,7 @@ static int get_cfunction_address(lua_State* L, int idx, cfunction* addr) * callback_mt */ - cfunction* f = lua_touserdata(L, -3); + f = (cfunction*)lua_touserdata(L, -3); *addr = f[1]; lua_pop(L, 3); return 1; @@ -1184,6 +1186,7 @@ static int is_scalar(struct ctype* ct) static int should_pack(lua_State *L, int ct_usr, struct ctype* ct, int idx) { struct ctype argt; + int same = 0; ct_usr = lua_absindex(L, ct_usr); if (IS_COMPLEX(ct->type)) { @@ -1198,7 +1201,7 @@ static int should_pack(lua_State *L, int ct_usr, struct ctype* ct, int idx) case LUA_TUSERDATA: // don't pack if the argument is a cdata with the same type to_cdata(L, idx, &argt); - int same = is_same_type(L, ct_usr, -1, ct, &argt); + same = is_same_type(L, ct_usr, -1, ct, &argt); lua_pop(L, 1); return !same; default: @@ -1212,6 +1215,7 @@ static int do_new(lua_State* L, int is_cast) void* p; struct ctype ct; int check_ptrs = !is_cast; + int scalar = 0; check_ctype(L, 1, &ct); @@ -1270,7 +1274,7 @@ static int do_new(lua_State* L, int is_cast) return 1; } - int scalar = is_scalar(&ct); + scalar = is_scalar(&ct); if (scalar && cargs > 1) { return luaL_error(L, "too many initializers"); } @@ -1608,9 +1612,10 @@ static ptrdiff_t lookup_cdata_index(lua_State* L, int idx, int ct_usr, struct ct { struct ctype mt; ptrdiff_t off; + int type = 0; ct_usr = lua_absindex(L, ct_usr); - int type = lua_type(L, idx); + type = lua_type(L, idx); switch (type) { case LUA_TNUMBER: diff --git a/plugins/MirLua/Modules/ffi/src/ffi.h b/plugins/MirLua/Modules/ffi/src/ffi.h index a66f43de4c..577956b11d 100644 --- a/plugins/MirLua/Modules/ffi/src/ffi.h +++ b/plugins/MirLua/Modules/ffi/src/ffi.h @@ -9,30 +9,35 @@ #pragma once -#ifdef _MSC_VER -#define _CRT_SECURE_NO_WARNINGS -#endif - #define LUA_FFI_BUILD_AS_DLL #include -#include + +#if _MSC_VER < 1800 +# include "msvc/stdbool.h" +# include "msvc/inttypes.h" +#else +# include +# include +#endif + #include #include #include #ifdef __cplusplus -extern "C" { -# include "..\..\..\..\..\libs\liblua\src\lua.h" -# include "..\..\..\..\..\libs\liblua\src\lauxlib.h" -# include "..\..\..\..\..\libs\liblua\src\lualib.h" -} # define EXTERN_C extern "C" +extern "C" +{ #else +# define EXTERN_C extern +#endif # include "..\..\..\..\..\libs\liblua\src\lua.h" # include "..\..\..\..\..\libs\liblua\src\lauxlib.h" # include "..\..\..\..\..\libs\liblua\src\lualib.h" -# define EXTERN_C extern + +#ifdef __cplusplus +} #endif #ifdef _WIN32 -- cgit v1.2.3