summaryrefslogtreecommitdiff
path: root/plugins/MirLua/Modules/ffi/src
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2016-02-17 17:19:09 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2016-02-17 17:19:09 +0000
commitbf0a92db2f770c8fd4a5eed47893c660ac1e54ee (patch)
tree9f49382951374c6992618512c9f3910e020a4957 /plugins/MirLua/Modules/ffi/src
parent7a8fafbb2c8a2d1175c4f92b08d1b8c30f475a4a (diff)
lua_ffi: VC2010 compilation fix
git-svn-id: http://svn.miranda-ng.org/main/trunk@16295 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/Modules/ffi/src')
-rw-r--r--plugins/MirLua/Modules/ffi/src/ffi.c21
-rw-r--r--plugins/MirLua/Modules/ffi/src/ffi.h27
2 files changed, 29 insertions, 19 deletions
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 <math.h>
-#include <inttypes.h>
/* 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 <stdint.h>
-#include <stdbool.h>
+
+#if _MSC_VER < 1800
+# include "msvc/stdbool.h"
+# include "msvc/inttypes.h"
+#else
+# include <stdbool.h>
+# include <inttypes.h>
+#endif
+
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#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