Commit 2dd80e7c authored by nanahira's avatar nanahira

Merge branch 'Android' of https://github.com/Unicorn369/YGOPro2_Droid into Android

parents 3d41641b 2ce56115
...@@ -48,10 +48,12 @@ deck/ ...@@ -48,10 +48,12 @@ deck/
expansions/ expansions/
pack/ pack/
picture/ picture/
puzzle/
replay/ replay/
sound/ sound/
texture/ texture/
textures/ textures/
update/
updates/ updates/
cards.cdb cards.cdb
lflist.conf lflist.conf
...@@ -60,4 +62,5 @@ commamd.shell ...@@ -60,4 +62,5 @@ commamd.shell
AI_core_vs2017solution/core.VC.db AI_core_vs2017solution/core.VC.db
AI_core_vs2017solution/core.VC.VC.opendb AI_core_vs2017solution/core.VC.VC.opendb
AI_core_vs2017solution/System.Servicemodel.Faltexception.dll AI_core_vs2017solution/System.Servicemodel.Faltexception.dll
[Ll]ibrary_/
Assets/StreamingAssets/update.zip* Assets/StreamingAssets/update.zip*
...@@ -9,12 +9,12 @@ include $(CLEAR_VARS) ...@@ -9,12 +9,12 @@ include $(CLEAR_VARS)
LOCAL_MODULE := ocgcore LOCAL_MODULE := ocgcore
ifndef NDEBUG ifndef NDEBUG
LOCAL_CFLAGS += -g -D_DEBUG LOCAL_CFLAGS += -g -D_DEBUG -DLUA_USE_POSIX -DLUA_COMPAT_5_2
else else
LOCAL_CFLAGS += -fexpensive-optimizations -O3 LOCAL_CFLAGS += -fexpensive-optimizations -O3 -DLUA_USE_POSIX -DLUA_COMPAT_5_2
endif endif
ifeq ($(TARGET_ARCH_ABI),x86) ifeq ($(TARGET_ARCH_ABI), x86)
LOCAL_CFLAGS += -fno-stack-protector LOCAL_CFLAGS += -fno-stack-protector
endif endif
...@@ -27,54 +27,55 @@ LOCAL_C_INCLUDES += $(LOCAL_PATH)/ocgcore/lua ...@@ -27,54 +27,55 @@ LOCAL_C_INCLUDES += $(LOCAL_PATH)/ocgcore/lua
LOCAL_C_INCLUDES += $(LOCAL_PATH)/ocgcore/sqlite3 LOCAL_C_INCLUDES += $(LOCAL_PATH)/ocgcore/sqlite3
LOCAL_SRC_FILES := ocgcore/lua/lapi.c \ LOCAL_SRC_FILES := ocgcore/lua/lapi.c \
ocgcore/lua/lauxlib.c \ ocgcore/lua/lauxlib.c \
ocgcore/lua/lbaselib.c \ ocgcore/lua/lbaselib.c \
ocgcore/lua/lbitlib.c \ ocgcore/lua/lbitlib.c \
ocgcore/lua/lcode.c \ ocgcore/lua/lcode.c \
ocgcore/lua/lcorolib.c \ ocgcore/lua/lcorolib.c \
ocgcore/lua/lctype.c \ ocgcore/lua/lctype.c \
ocgcore/lua/ldblib.c \ ocgcore/lua/ldblib.c \
ocgcore/lua/ldebug.c \ ocgcore/lua/ldebug.c \
ocgcore/lua/ldo.c \ ocgcore/lua/ldo.c \
ocgcore/lua/ldump.c \ ocgcore/lua/ldump.c \
ocgcore/lua/lfunc.c \ ocgcore/lua/lfunc.c \
ocgcore/lua/lgc.c \ ocgcore/lua/lgc.c \
ocgcore/lua/linit.c \ ocgcore/lua/linit.c \
ocgcore/lua/liolib.c \ ocgcore/lua/liolib.c \
ocgcore/lua/llex.c \ ocgcore/lua/llex.c \
ocgcore/lua/lmathlib.c \ ocgcore/lua/lmathlib.c \
ocgcore/lua/lmem.c \ ocgcore/lua/lmem.c \
ocgcore/lua/loadlib.c \ ocgcore/lua/loadlib.c \
ocgcore/lua/lobject.c \ ocgcore/lua/lobject.c \
ocgcore/lua/lopcodes.c \ ocgcore/lua/lopcodes.c \
ocgcore/lua/loslib.c \ ocgcore/lua/loslib.c \
ocgcore/lua/lparser.c \ ocgcore/lua/lparser.c \
ocgcore/lua/lstate.c \ ocgcore/lua/lstate.c \
ocgcore/lua/lstring.c \ ocgcore/lua/lstring.c \
ocgcore/lua/lstrlib.c \ ocgcore/lua/lstrlib.c \
ocgcore/lua/ltable.c \ ocgcore/lua/ltable.c \
ocgcore/lua/ltablib.c \ ocgcore/lua/ltablib.c \
ocgcore/lua/ltm.c \ ocgcore/lua/ltm.c \
ocgcore/lua/lundump.c \ ocgcore/lua/lundump.c \
ocgcore/lua/lvm.c \ ocgcore/lua/lutf8lib.c \
ocgcore/lua/lzio.c \ ocgcore/lua/lvm.c \
ocgcore/card.cpp \ ocgcore/lua/lzio.c \
ocgcore/duel.cpp \ ocgcore/card.cpp \
ocgcore/effect.cpp \ ocgcore/duel.cpp \
ocgcore/field.cpp \ ocgcore/effect.cpp \
ocgcore/group.cpp \ ocgcore/field.cpp \
ocgcore/interpreter.cpp \ ocgcore/group.cpp \
ocgcore/libcard.cpp \ ocgcore/interpreter.cpp \
ocgcore/libdebug.cpp \ ocgcore/libcard.cpp \
ocgcore/libduel.cpp \ ocgcore/libdebug.cpp \
ocgcore/libeffect.cpp \ ocgcore/libduel.cpp \
ocgcore/libgroup.cpp \ ocgcore/libeffect.cpp \
ocgcore/mem.cpp \ ocgcore/libgroup.cpp \
ocgcore/ocgapi.cpp \ ocgcore/mem.cpp \
ocgcore/operations.cpp \ ocgcore/ocgapi.cpp \
ocgcore/playerop.cpp \ ocgcore/operations.cpp \
ocgcore/processor.cpp \ ocgcore/playerop.cpp \
ocgcore/scriptlib.cpp \ ocgcore/processor.cpp \
ocgcore/scriptlib.cpp \
LOCAL_LDLIBS := -llog LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY)
......
...@@ -23,7 +23,7 @@ ifeq ($(config),release) ...@@ -23,7 +23,7 @@ ifeq ($(config),release)
OBJDIR = ../../obj/gmake.linux/x86_64/ocgcore OBJDIR = ../../obj/gmake.linux/x86_64/ocgcore
TARGETDIR = ../../bin/gmake.linux/x86_64 TARGETDIR = ../../bin/gmake.linux/x86_64
TARGET = $(TARGETDIR)/libocgcore.so TARGET = $(TARGETDIR)/libocgcore.so
DEFINES += -DLUA_USE_LINUX DEFINES += -DLUA_COMPAT_5_2 -DLUA_USE_LINUX
INCLUDES += -I../../ocgcore/lua -I../../ocgcore/sqlite3 INCLUDES += -I../../ocgcore/lua -I../../ocgcore/sqlite3
CPPFLAGS += -MMD -MP $(DEFINES) $(INCLUDES) CPPFLAGS += -MMD -MP $(DEFINES) $(INCLUDES)
CFLAGS += $(CPPFLAGS) $(ARCH) -Os -fPIC -fno-strict-aliasing -Wno-multichar CFLAGS += $(CPPFLAGS) $(ARCH) -Os -fPIC -fno-strict-aliasing -Wno-multichar
...@@ -45,7 +45,7 @@ ifeq ($(config),release32) ...@@ -45,7 +45,7 @@ ifeq ($(config),release32)
OBJDIR = ../../obj/gmake.linux/x86/ocgcore OBJDIR = ../../obj/gmake.linux/x86/ocgcore
TARGETDIR = ../../bin/gmake.linux/x86 TARGETDIR = ../../bin/gmake.linux/x86
TARGET = $(TARGETDIR)/libocgcore.so TARGET = $(TARGETDIR)/libocgcore.so
DEFINES += -DLUA_USE_LINUX DEFINES += -DLUA_COMPAT_5_2 -DLUA_USE_LINUX
INCLUDES += -I../../ocgcore/lua -I../../ocgcore/sqlite3 INCLUDES += -I../../ocgcore/lua -I../../ocgcore/sqlite3
CPPFLAGS += -MMD -MP $(DEFINES) $(INCLUDES) CPPFLAGS += -MMD -MP $(DEFINES) $(INCLUDES)
CFLAGS += $(CPPFLAGS) $(ARCH) -Os -m32 -fPIC -fno-strict-aliasing -Wno-multichar CFLAGS += $(CPPFLAGS) $(ARCH) -Os -m32 -fPIC -fno-strict-aliasing -Wno-multichar
...@@ -94,6 +94,7 @@ OBJECTS := \ ...@@ -94,6 +94,7 @@ OBJECTS := \
$(OBJDIR)/ltablib.o \ $(OBJDIR)/ltablib.o \
$(OBJDIR)/ltm.o \ $(OBJDIR)/ltm.o \
$(OBJDIR)/lundump.o \ $(OBJDIR)/lundump.o \
$(OBJDIR)/lutf8lib.o \
$(OBJDIR)/lvm.o \ $(OBJDIR)/lvm.o \
$(OBJDIR)/lzio.o \ $(OBJDIR)/lzio.o \
$(OBJDIR)/card.o \ $(OBJDIR)/card.o \
...@@ -263,6 +264,9 @@ $(OBJDIR)/ltm.o: ../../ocgcore/lua/ltm.c ...@@ -263,6 +264,9 @@ $(OBJDIR)/ltm.o: ../../ocgcore/lua/ltm.c
$(OBJDIR)/lundump.o: ../../ocgcore/lua/lundump.c $(OBJDIR)/lundump.o: ../../ocgcore/lua/lundump.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/lutf8lib.o: ../../ocgcore/lua/lutf8lib.c
@echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/lvm.o: ../../ocgcore/lua/lvm.c $(OBJDIR)/lvm.o: ../../ocgcore/lua/lvm.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
......
...@@ -23,7 +23,7 @@ ifeq ($(config),release) ...@@ -23,7 +23,7 @@ ifeq ($(config),release)
OBJDIR = ../../obj/gmake.windows/x86_64/ocgcore OBJDIR = ../../obj/gmake.windows/x86_64/ocgcore
TARGETDIR = ../../bin/gmake.windows/x86_64 TARGETDIR = ../../bin/gmake.windows/x86_64
TARGET = $(TARGETDIR)/ocgcore.dll TARGET = $(TARGETDIR)/ocgcore.dll
DEFINES += DEFINES += -DLUA_COMPAT_5_2
INCLUDES += -I../../ocgcore/lua -I../../ocgcore/sqlite3 INCLUDES += -I../../ocgcore/lua -I../../ocgcore/sqlite3
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -Os -static-libgcc ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -Os -static-libgcc
...@@ -45,7 +45,7 @@ ifeq ($(config),release32) ...@@ -45,7 +45,7 @@ ifeq ($(config),release32)
OBJDIR = ../../obj/gmake.windows/x86/ocgcore OBJDIR = ../../obj/gmake.windows/x86/ocgcore
TARGETDIR = ../../bin/gmake.windows/x86 TARGETDIR = ../../bin/gmake.windows/x86
TARGET = $(TARGETDIR)/ocgcore.dll TARGET = $(TARGETDIR)/ocgcore.dll
DEFINES += DEFINES += -DLUA_COMPAT_5_2
INCLUDES += -I../../ocgcore/lua -I../../ocgcore/sqlite3 INCLUDES += -I../../ocgcore/lua -I../../ocgcore/sqlite3
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -Os -m32 -static-libgcc ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -Os -m32 -static-libgcc
...@@ -94,6 +94,7 @@ OBJECTS := \ ...@@ -94,6 +94,7 @@ OBJECTS := \
$(OBJDIR)/ltablib.o \ $(OBJDIR)/ltablib.o \
$(OBJDIR)/ltm.o \ $(OBJDIR)/ltm.o \
$(OBJDIR)/lundump.o \ $(OBJDIR)/lundump.o \
$(OBJDIR)/lutf8lib.o \
$(OBJDIR)/lvm.o \ $(OBJDIR)/lvm.o \
$(OBJDIR)/lzio.o \ $(OBJDIR)/lzio.o \
$(OBJDIR)/card.o \ $(OBJDIR)/card.o \
...@@ -292,6 +293,10 @@ $(OBJDIR)/lundump.o: ../../ocgcore/lua/lundump.c ...@@ -292,6 +293,10 @@ $(OBJDIR)/lundump.o: ../../ocgcore/lua/lundump.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF $(@:%.o=%.d) -c "$<" $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF $(@:%.o=%.d) -c "$<"
$(OBJDIR)/lutf8lib.o: ../../ocgcore/lua/lutf8lib.c
@echo $(notdir $<)
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF $(@:%.o=%.d) -c "$<"
$(OBJDIR)/lvm.o: ../../ocgcore/lua/lvm.c $(OBJDIR)/lvm.o: ../../ocgcore/lua/lvm.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF $(@:%.o=%.d) -c "$<" $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF $(@:%.o=%.d) -c "$<"
......
This diff is collapsed.
/* /*
** $Id: lapi.h,v 2.7 2009/11/27 15:37:59 roberto Exp $ ** $Id: lapi.h,v 2.9.1.1 2017/04/19 17:20:42 roberto Exp $
** Auxiliary functions from Lua API ** Auxiliary functions from Lua API
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
......
/* /*
** $Id: lauxlib.h,v 1.120 2011/11/29 15:55:08 roberto Exp $ ** $Id: lauxlib.h,v 1.131.1.1 2017/04/19 17:20:42 roberto Exp $
** Auxiliary functions for building Lua libraries ** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
...@@ -16,40 +16,48 @@ ...@@ -16,40 +16,48 @@
/* extra error code for `luaL_load' */ /* extra error code for 'luaL_loadfilex' */
#define LUA_ERRFILE (LUA_ERRERR+1) #define LUA_ERRFILE (LUA_ERRERR+1)
/* key, in the registry, for table of loaded modules */
#define LUA_LOADED_TABLE "_LOADED"
/* key, in the registry, for table of preloaded loaders */
#define LUA_PRELOAD_TABLE "_PRELOAD"
typedef struct luaL_Reg { typedef struct luaL_Reg {
const char *name; const char *name;
lua_CFunction func; lua_CFunction func;
} luaL_Reg; } luaL_Reg;
LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver); #define LUAL_NUMSIZES (sizeof(lua_Integer)*16 + sizeof(lua_Number))
#define luaL_checkversion(L) luaL_checkversion_(L, LUA_VERSION_NUM)
LUALIB_API void (luaL_checkversion_) (lua_State *L, lua_Number ver, size_t sz);
#define luaL_checkversion(L) \
luaL_checkversion_(L, LUA_VERSION_NUM, LUAL_NUMSIZES)
LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e);
LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e);
LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len); LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len);
LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg); LUALIB_API int (luaL_argerror) (lua_State *L, int arg, const char *extramsg);
LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg, LUALIB_API const char *(luaL_checklstring) (lua_State *L, int arg,
size_t *l); size_t *l);
LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg, LUALIB_API const char *(luaL_optlstring) (lua_State *L, int arg,
const char *def, size_t *l); const char *def, size_t *l);
LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg); LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int arg);
LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def); LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int arg, lua_Number def);
LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg); LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int arg);
LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg, LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int arg,
lua_Integer def); lua_Integer def);
LUALIB_API lua_Unsigned (luaL_checkunsigned) (lua_State *L, int numArg);
LUALIB_API lua_Unsigned (luaL_optunsigned) (lua_State *L, int numArg,
lua_Unsigned def);
LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg);
LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t); LUALIB_API void (luaL_checktype) (lua_State *L, int arg, int t);
LUALIB_API void (luaL_checkany) (lua_State *L, int narg); LUALIB_API void (luaL_checkany) (lua_State *L, int arg);
LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname);
LUALIB_API void (luaL_setmetatable) (lua_State *L, const char *tname); LUALIB_API void (luaL_setmetatable) (lua_State *L, const char *tname);
...@@ -59,13 +67,13 @@ LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); ...@@ -59,13 +67,13 @@ LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname);
LUALIB_API void (luaL_where) (lua_State *L, int lvl); LUALIB_API void (luaL_where) (lua_State *L, int lvl);
LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def, LUALIB_API int (luaL_checkoption) (lua_State *L, int arg, const char *def,
const char *const lst[]); const char *const lst[]);
LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname); LUALIB_API int (luaL_fileresult) (lua_State *L, int stat, const char *fname);
LUALIB_API int (luaL_execresult) (lua_State *L, int stat); LUALIB_API int (luaL_execresult) (lua_State *L, int stat);
/* pre-defined references */ /* predefined references */
#define LUA_NOREF (-2) #define LUA_NOREF (-2)
#define LUA_REFNIL (-1) #define LUA_REFNIL (-1)
...@@ -83,7 +91,7 @@ LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); ...@@ -83,7 +91,7 @@ LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s);
LUALIB_API lua_State *(luaL_newstate) (void); LUALIB_API lua_State *(luaL_newstate) (void);
LUALIB_API int (luaL_len) (lua_State *L, int idx); LUALIB_API lua_Integer (luaL_len) (lua_State *L, int idx);
LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p,
const char *r); const char *r);
...@@ -108,16 +116,13 @@ LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname, ...@@ -108,16 +116,13 @@ LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname,
#define luaL_newlibtable(L,l) \ #define luaL_newlibtable(L,l) \
lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1) lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1)
#define luaL_newlib(L,l) (luaL_newlibtable(L,l), luaL_setfuncs(L,l,0)) #define luaL_newlib(L,l) \
(luaL_checkversion(L), luaL_newlibtable(L,l), luaL_setfuncs(L,l,0))
#define luaL_argcheck(L, cond,numarg,extramsg) \ #define luaL_argcheck(L, cond,arg,extramsg) \
((void)((cond) || luaL_argerror(L, (numarg), (extramsg)))) ((void)((cond) || luaL_argerror(L, (arg), (extramsg))))
#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) #define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL))
#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) #define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL))
#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n)))
#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d)))
#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n)))
#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d)))
#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) #define luaL_typename(L,i) lua_typename(L, lua_type(L,(i)))
...@@ -207,6 +212,53 @@ LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname, ...@@ -207,6 +212,53 @@ LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname,
#endif #endif
/*
** {==================================================================
** "Abstraction Layer" for basic report of messages and errors
** ===================================================================
*/
/* print a string */
#if !defined(lua_writestring)
#define lua_writestring(s,l) fwrite((s), sizeof(char), (l), stdout)
#endif
/* print a newline and flush the output */
#if !defined(lua_writeline)
#define lua_writeline() (lua_writestring("\n", 1), fflush(stdout))
#endif
/* print an error message */
#if !defined(lua_writestringerror)
#define lua_writestringerror(s,p) \
(fprintf(stderr, (s), (p)), fflush(stderr))
#endif
/* }================================================================== */
/*
** {============================================================
** Compatibility with deprecated conversions
** =============================================================
*/
#if defined(LUA_COMPAT_APIINTCASTS)
#define luaL_checkunsigned(L,a) ((lua_Unsigned)luaL_checkinteger(L,a))
#define luaL_optunsigned(L,a,d) \
((lua_Unsigned)luaL_optinteger(L,a,(lua_Integer)(d)))
#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n)))
#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d)))
#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n)))
#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d)))
#endif
/* }============================================================ */
#endif #endif
/* /*
** $Id: lbitlib.c,v 1.16 2011/06/20 16:35:23 roberto Exp $ ** $Id: lbitlib.c,v 1.30.1.1 2017/04/19 17:20:42 roberto Exp $
** Standard library for bitwise operations ** Standard library for bitwise operations
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
...@@ -7,20 +7,36 @@ ...@@ -7,20 +7,36 @@
#define lbitlib_c #define lbitlib_c
#define LUA_LIB #define LUA_LIB
#include "lprefix.h"
#include "lua.h" #include "lua.h"
#include "lauxlib.h" #include "lauxlib.h"
#include "lualib.h" #include "lualib.h"
#if defined(LUA_COMPAT_BITLIB) /* { */
#define pushunsigned(L,n) lua_pushinteger(L, (lua_Integer)(n))
#define checkunsigned(L,i) ((lua_Unsigned)luaL_checkinteger(L,i))
/* number of bits to consider in a number */ /* number of bits to consider in a number */
#if !defined(LUA_NBITS) #if !defined(LUA_NBITS)
#define LUA_NBITS 32 #define LUA_NBITS 32
#endif #endif
/*
** a lua_Unsigned with its first LUA_NBITS bits equal to 1. (Shift must
** be made in two parts to avoid problems when LUA_NBITS is equal to the
** number of bits in a lua_Unsigned.)
*/
#define ALLONES (~(((~(lua_Unsigned)0) << (LUA_NBITS - 1)) << 1)) #define ALLONES (~(((~(lua_Unsigned)0) << (LUA_NBITS - 1)) << 1))
/* macro to trim extra bits */ /* macro to trim extra bits */
#define trim(x) ((x) & ALLONES) #define trim(x) ((x) & ALLONES)
...@@ -29,28 +45,25 @@ ...@@ -29,28 +45,25 @@
#define mask(n) (~((ALLONES << 1) << ((n) - 1))) #define mask(n) (~((ALLONES << 1) << ((n) - 1)))
typedef lua_Unsigned b_uint;
static lua_Unsigned andaux (lua_State *L) {
static b_uint andaux (lua_State *L) {
int i, n = lua_gettop(L); int i, n = lua_gettop(L);
b_uint r = ~(b_uint)0; lua_Unsigned r = ~(lua_Unsigned)0;
for (i = 1; i <= n; i++) for (i = 1; i <= n; i++)
r &= luaL_checkunsigned(L, i); r &= checkunsigned(L, i);
return trim(r); return trim(r);
} }
static int b_and (lua_State *L) { static int b_and (lua_State *L) {
b_uint r = andaux(L); lua_Unsigned r = andaux(L);
lua_pushunsigned(L, r); pushunsigned(L, r);
return 1; return 1;
} }
static int b_test (lua_State *L) { static int b_test (lua_State *L) {
b_uint r = andaux(L); lua_Unsigned r = andaux(L);
lua_pushboolean(L, r != 0); lua_pushboolean(L, r != 0);
return 1; return 1;
} }
...@@ -58,32 +71,32 @@ static int b_test (lua_State *L) { ...@@ -58,32 +71,32 @@ static int b_test (lua_State *L) {
static int b_or (lua_State *L) { static int b_or (lua_State *L) {
int i, n = lua_gettop(L); int i, n = lua_gettop(L);
b_uint r = 0; lua_Unsigned r = 0;
for (i = 1; i <= n; i++) for (i = 1; i <= n; i++)
r |= luaL_checkunsigned(L, i); r |= checkunsigned(L, i);
lua_pushunsigned(L, trim(r)); pushunsigned(L, trim(r));
return 1; return 1;
} }
static int b_xor (lua_State *L) { static int b_xor (lua_State *L) {
int i, n = lua_gettop(L); int i, n = lua_gettop(L);
b_uint r = 0; lua_Unsigned r = 0;
for (i = 1; i <= n; i++) for (i = 1; i <= n; i++)
r ^= luaL_checkunsigned(L, i); r ^= checkunsigned(L, i);
lua_pushunsigned(L, trim(r)); pushunsigned(L, trim(r));
return 1; return 1;
} }
static int b_not (lua_State *L) { static int b_not (lua_State *L) {
b_uint r = ~luaL_checkunsigned(L, 1); lua_Unsigned r = ~checkunsigned(L, 1);
lua_pushunsigned(L, trim(r)); pushunsigned(L, trim(r));
return 1; return 1;
} }
static int b_shift (lua_State *L, b_uint r, int i) { static int b_shift (lua_State *L, lua_Unsigned r, lua_Integer i) {
if (i < 0) { /* shift right? */ if (i < 0) { /* shift right? */
i = -i; i = -i;
r = trim(r); r = trim(r);
...@@ -95,91 +108,93 @@ static int b_shift (lua_State *L, b_uint r, int i) { ...@@ -95,91 +108,93 @@ static int b_shift (lua_State *L, b_uint r, int i) {
else r <<= i; else r <<= i;
r = trim(r); r = trim(r);
} }
lua_pushunsigned(L, r); pushunsigned(L, r);
return 1; return 1;
} }
static int b_lshift (lua_State *L) { static int b_lshift (lua_State *L) {
return b_shift(L, luaL_checkunsigned(L, 1), luaL_checkint(L, 2)); return b_shift(L, checkunsigned(L, 1), luaL_checkinteger(L, 2));
} }
static int b_rshift (lua_State *L) { static int b_rshift (lua_State *L) {
return b_shift(L, luaL_checkunsigned(L, 1), -luaL_checkint(L, 2)); return b_shift(L, checkunsigned(L, 1), -luaL_checkinteger(L, 2));
} }
static int b_arshift (lua_State *L) { static int b_arshift (lua_State *L) {
b_uint r = luaL_checkunsigned(L, 1); lua_Unsigned r = checkunsigned(L, 1);
int i = luaL_checkint(L, 2); lua_Integer i = luaL_checkinteger(L, 2);
if (i < 0 || !(r & ((b_uint)1 << (LUA_NBITS - 1)))) if (i < 0 || !(r & ((lua_Unsigned)1 << (LUA_NBITS - 1))))
return b_shift(L, r, -i); return b_shift(L, r, -i);
else { /* arithmetic shift for 'negative' number */ else { /* arithmetic shift for 'negative' number */
if (i >= LUA_NBITS) r = ALLONES; if (i >= LUA_NBITS) r = ALLONES;
else else
r = trim((r >> i) | ~(~(b_uint)0 >> i)); /* add signal bit */ r = trim((r >> i) | ~(trim(~(lua_Unsigned)0) >> i)); /* add signal bit */
lua_pushunsigned(L, r); pushunsigned(L, r);
return 1; return 1;
} }
} }
static int b_rot (lua_State *L, int i) { static int b_rot (lua_State *L, lua_Integer d) {
b_uint r = luaL_checkunsigned(L, 1); lua_Unsigned r = checkunsigned(L, 1);
i &= (LUA_NBITS - 1); /* i = i % NBITS */ int i = d & (LUA_NBITS - 1); /* i = d % NBITS */
r = trim(r); r = trim(r);
r = (r << i) | (r >> (LUA_NBITS - i)); if (i != 0) /* avoid undefined shift of LUA_NBITS when i == 0 */
lua_pushunsigned(L, trim(r)); r = (r << i) | (r >> (LUA_NBITS - i));
pushunsigned(L, trim(r));
return 1; return 1;
} }
static int b_lrot (lua_State *L) { static int b_lrot (lua_State *L) {
return b_rot(L, luaL_checkint(L, 2)); return b_rot(L, luaL_checkinteger(L, 2));
} }
static int b_rrot (lua_State *L) { static int b_rrot (lua_State *L) {
return b_rot(L, -luaL_checkint(L, 2)); return b_rot(L, -luaL_checkinteger(L, 2));
} }
/* /*
** get field and width arguments for field-manipulation functions, ** get field and width arguments for field-manipulation functions,
** checking whether they are valid ** checking whether they are valid.
** ('luaL_error' called without 'return' to avoid later warnings about
** 'width' being used uninitialized.)
*/ */
static int fieldargs (lua_State *L, int farg, int *width) { static int fieldargs (lua_State *L, int farg, int *width) {
int f = luaL_checkint(L, farg); lua_Integer f = luaL_checkinteger(L, farg);
int w = luaL_optint(L, farg + 1, 1); lua_Integer w = luaL_optinteger(L, farg + 1, 1);
luaL_argcheck(L, 0 <= f, farg, "field cannot be negative"); luaL_argcheck(L, 0 <= f, farg, "field cannot be negative");
luaL_argcheck(L, 0 < w, farg + 1, "width must be positive"); luaL_argcheck(L, 0 < w, farg + 1, "width must be positive");
if (f + w > LUA_NBITS) if (f + w > LUA_NBITS)
luaL_error(L, "trying to access non-existent bits"); luaL_error(L, "trying to access non-existent bits");
*width = w; *width = (int)w;
return f; return (int)f;
} }
static int b_extract (lua_State *L) { static int b_extract (lua_State *L) {
int w; int w;
b_uint r = luaL_checkunsigned(L, 1); lua_Unsigned r = trim(checkunsigned(L, 1));
int f = fieldargs(L, 2, &w); int f = fieldargs(L, 2, &w);
r = (r >> f) & mask(w); r = (r >> f) & mask(w);
lua_pushunsigned(L, r); pushunsigned(L, r);
return 1; return 1;
} }
static int b_replace (lua_State *L) { static int b_replace (lua_State *L) {
int w; int w;
b_uint r = luaL_checkunsigned(L, 1); lua_Unsigned r = trim(checkunsigned(L, 1));
b_uint v = luaL_checkunsigned(L, 2); lua_Unsigned v = trim(checkunsigned(L, 2));
int f = fieldargs(L, 3, &w); int f = fieldargs(L, 3, &w);
int m = mask(w); lua_Unsigned m = mask(w);
v &= m; /* erase bits outside given width */ r = (r & ~(m << f)) | ((v & m) << f);
r = (r & ~(m << f)) | (v << f); pushunsigned(L, r);
lua_pushunsigned(L, r);
return 1; return 1;
} }
...@@ -207,3 +222,12 @@ LUAMOD_API int luaopen_bit32 (lua_State *L) { ...@@ -207,3 +222,12 @@ LUAMOD_API int luaopen_bit32 (lua_State *L) {
return 1; return 1;
} }
#else /* }{ */
LUAMOD_API int luaopen_bit32 (lua_State *L) {
return luaL_error(L, "library 'bit32' has been deprecated");
}
#endif /* } */
This diff is collapsed.
/* /*
** $Id: lcode.h,v 1.58 2011/08/30 16:26:41 roberto Exp $ ** $Id: lcode.h,v 1.64.1.1 2017/04/19 17:20:42 roberto Exp $
** Code generator for Lua ** Code generator for Lua
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
...@@ -24,7 +24,11 @@ ...@@ -24,7 +24,11 @@
** grep "ORDER OPR" if you change these enums (ORDER OP) ** grep "ORDER OPR" if you change these enums (ORDER OP)
*/ */
typedef enum BinOpr { typedef enum BinOpr {
OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW, OPR_ADD, OPR_SUB, OPR_MUL, OPR_MOD, OPR_POW,
OPR_DIV,
OPR_IDIV,
OPR_BAND, OPR_BOR, OPR_BXOR,
OPR_SHL, OPR_SHR,
OPR_CONCAT, OPR_CONCAT,
OPR_EQ, OPR_LT, OPR_LE, OPR_EQ, OPR_LT, OPR_LE,
OPR_NE, OPR_GT, OPR_GE, OPR_NE, OPR_GT, OPR_GE,
...@@ -33,10 +37,11 @@ typedef enum BinOpr { ...@@ -33,10 +37,11 @@ typedef enum BinOpr {
} BinOpr; } BinOpr;
typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; typedef enum UnOpr { OPR_MINUS, OPR_BNOT, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr;
#define getcode(fs,e) ((fs)->f->code[(e)->u.info]) /* get (pointer to) instruction of given 'expdesc' */
#define getinstruction(fs,e) ((fs)->f->code[(e)->u.info])
#define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) #define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx)
...@@ -52,7 +57,7 @@ LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); ...@@ -52,7 +57,7 @@ LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n);
LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n);
LUAI_FUNC void luaK_checkstack (FuncState *fs, int n); LUAI_FUNC void luaK_checkstack (FuncState *fs, int n);
LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s); LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s);
LUAI_FUNC int luaK_numberK (FuncState *fs, lua_Number r); LUAI_FUNC int luaK_intK (FuncState *fs, lua_Integer n);
LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e); LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e);
LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e); LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e);
LUAI_FUNC void luaK_exp2anyregup (FuncState *fs, expdesc *e); LUAI_FUNC void luaK_exp2anyregup (FuncState *fs, expdesc *e);
......
/* /*
** $Id: lcorolib.c,v 1.4 2012/04/27 18:59:04 roberto Exp $ ** $Id: lcorolib.c,v 1.10.1.1 2017/04/19 17:20:42 roberto Exp $
** Coroutine Library ** Coroutine Library
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
#define lcorolib_c
#define LUA_LIB
#include <stdlib.h> #include "lprefix.h"
#define lcorolib_c #include <stdlib.h>
#define LUA_LIB
#include "lua.h" #include "lua.h"
...@@ -17,6 +18,13 @@ ...@@ -17,6 +18,13 @@
#include "lualib.h" #include "lualib.h"
static lua_State *getco (lua_State *L) {
lua_State *co = lua_tothread(L, 1);
luaL_argcheck(L, co, 1, "thread expected");
return co;
}
static int auxresume (lua_State *L, lua_State *co, int narg) { static int auxresume (lua_State *L, lua_State *co, int narg) {
int status; int status;
if (!lua_checkstack(co, narg)) { if (!lua_checkstack(co, narg)) {
...@@ -47,9 +55,8 @@ static int auxresume (lua_State *L, lua_State *co, int narg) { ...@@ -47,9 +55,8 @@ static int auxresume (lua_State *L, lua_State *co, int narg) {
static int luaB_coresume (lua_State *L) { static int luaB_coresume (lua_State *L) {
lua_State *co = lua_tothread(L, 1); lua_State *co = getco(L);
int r; int r;
luaL_argcheck(L, co, 1, "coroutine expected");
r = auxresume(L, co, lua_gettop(L) - 1); r = auxresume(L, co, lua_gettop(L) - 1);
if (r < 0) { if (r < 0) {
lua_pushboolean(L, 0); lua_pushboolean(L, 0);
...@@ -59,7 +66,7 @@ static int luaB_coresume (lua_State *L) { ...@@ -59,7 +66,7 @@ static int luaB_coresume (lua_State *L) {
else { else {
lua_pushboolean(L, 1); lua_pushboolean(L, 1);
lua_insert(L, -(r + 1)); lua_insert(L, -(r + 1));
return r + 1; /* return true + `resume' returns */ return r + 1; /* return true + 'resume' returns */
} }
} }
...@@ -68,12 +75,12 @@ static int luaB_auxwrap (lua_State *L) { ...@@ -68,12 +75,12 @@ static int luaB_auxwrap (lua_State *L) {
lua_State *co = lua_tothread(L, lua_upvalueindex(1)); lua_State *co = lua_tothread(L, lua_upvalueindex(1));
int r = auxresume(L, co, lua_gettop(L)); int r = auxresume(L, co, lua_gettop(L));
if (r < 0) { if (r < 0) {
if (lua_isstring(L, -1)) { /* error object is a string? */ if (lua_type(L, -1) == LUA_TSTRING) { /* error object is a string? */
luaL_where(L, 1); /* add extra info */ luaL_where(L, 1); /* add extra info */
lua_insert(L, -2); lua_insert(L, -2);
lua_concat(L, 2); lua_concat(L, 2);
} }
lua_error(L); /* propagate error */ return lua_error(L); /* propagate error */
} }
return r; return r;
} }
...@@ -102,8 +109,7 @@ static int luaB_yield (lua_State *L) { ...@@ -102,8 +109,7 @@ static int luaB_yield (lua_State *L) {
static int luaB_costatus (lua_State *L) { static int luaB_costatus (lua_State *L) {
lua_State *co = lua_tothread(L, 1); lua_State *co = getco(L);
luaL_argcheck(L, co, 1, "coroutine expected");
if (L == co) lua_pushliteral(L, "running"); if (L == co) lua_pushliteral(L, "running");
else { else {
switch (lua_status(co)) { switch (lua_status(co)) {
...@@ -129,6 +135,12 @@ static int luaB_costatus (lua_State *L) { ...@@ -129,6 +135,12 @@ static int luaB_costatus (lua_State *L) {
} }
static int luaB_yieldable (lua_State *L) {
lua_pushboolean(L, lua_isyieldable(L));
return 1;
}
static int luaB_corunning (lua_State *L) { static int luaB_corunning (lua_State *L) {
int ismain = lua_pushthread(L); int ismain = lua_pushthread(L);
lua_pushboolean(L, ismain); lua_pushboolean(L, ismain);
...@@ -143,6 +155,7 @@ static const luaL_Reg co_funcs[] = { ...@@ -143,6 +155,7 @@ static const luaL_Reg co_funcs[] = {
{"status", luaB_costatus}, {"status", luaB_costatus},
{"wrap", luaB_cowrap}, {"wrap", luaB_cowrap},
{"yield", luaB_yield}, {"yield", luaB_yield},
{"isyieldable", luaB_yieldable},
{NULL, NULL} {NULL, NULL}
}; };
......
/* /*
** $Id: lctype.c,v 1.11 2011/10/03 16:19:23 roberto Exp $ ** $Id: lctype.c,v 1.12.1.1 2017/04/19 17:20:42 roberto Exp $
** 'ctype' functions for Lua ** 'ctype' functions for Lua
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
...@@ -7,6 +7,9 @@ ...@@ -7,6 +7,9 @@
#define lctype_c #define lctype_c
#define LUA_CORE #define LUA_CORE
#include "lprefix.h"
#include "lctype.h" #include "lctype.h"
#if !LUA_USE_CTYPE /* { */ #if !LUA_USE_CTYPE /* { */
......
/* /*
** $Id: lctype.h,v 1.12 2011/07/15 12:50:29 roberto Exp $ ** $Id: lctype.h,v 1.12.1.1 2013/04/12 18:48:47 roberto Exp $
** 'ctype' functions for Lua ** 'ctype' functions for Lua
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
......
This diff is collapsed.
This diff is collapsed.
/* /*
** $Id: ldebug.h,v 2.7 2011/10/07 20:45:19 roberto Exp $ ** $Id: ldebug.h,v 2.14.1.1 2017/04/19 17:20:42 roberto Exp $
** Auxiliary functions from Debug Interface module ** Auxiliary functions from Debug Interface module
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
...@@ -13,22 +13,27 @@ ...@@ -13,22 +13,27 @@
#define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1)
#define getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) #define getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : -1)
#define resethookcount(L) (L->hookcount = L->basehookcount) #define resethookcount(L) (L->hookcount = L->basehookcount)
/* Active Lua function (given call info) */
#define ci_func(ci) (clLvalue((ci)->func))
LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o,
const char *opname); const char *opname);
LUAI_FUNC l_noret luaG_concaterror (lua_State *L, StkId p1, StkId p2); LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1,
LUAI_FUNC l_noret luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2);
LUAI_FUNC l_noret luaG_opinterror (lua_State *L, const TValue *p1,
const TValue *p2,
const char *msg);
LUAI_FUNC l_noret luaG_tointerror (lua_State *L, const TValue *p1,
const TValue *p2); const TValue *p2);
LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1,
const TValue *p2); const TValue *p2);
LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...);
LUAI_FUNC const char *luaG_addinfo (lua_State *L, const char *msg,
TString *src, int line);
LUAI_FUNC l_noret luaG_errormsg (lua_State *L); LUAI_FUNC l_noret luaG_errormsg (lua_State *L);
LUAI_FUNC void luaG_traceexec (lua_State *L);
#endif #endif
This diff is collapsed.
/* /*
** $Id: ldo.h,v 2.20 2011/11/29 15:55:08 roberto Exp $ ** $Id: ldo.h,v 2.29.1.1 2017/04/19 17:20:42 roberto Exp $
** Stack and Call structure of Lua ** Stack and Call structure of Lua
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
...@@ -13,31 +13,43 @@ ...@@ -13,31 +13,43 @@
#include "lzio.h" #include "lzio.h"
#define luaD_checkstack(L,n) if (L->stack_last - L->top <= (n)) \ /*
luaD_growstack(L, n); else condmovestack(L); ** Macro to check stack size and grow stack if needed. Parameters
** 'pre'/'pos' allow the macro to preserve a pointer into the
** stack across reallocations, doing the work only when needed.
** 'condmovestack' is used in heavy tests to force a stack reallocation
** at every check.
*/
#define luaD_checkstackaux(L,n,pre,pos) \
if (L->stack_last - L->top <= (n)) \
{ pre; luaD_growstack(L, n); pos; } else { condmovestack(L,pre,pos); }
/* In general, 'pre'/'pos' are empty (nothing to save) */
#define luaD_checkstack(L,n) luaD_checkstackaux(L,n,(void)0,(void)0)
#define incr_top(L) {L->top++; luaD_checkstack(L,0);}
#define savestack(L,p) ((char *)(p) - (char *)L->stack) #define savestack(L,p) ((char *)(p) - (char *)L->stack)
#define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) #define restorestack(L,n) ((TValue *)((char *)L->stack + (n)))
/* type of protected functions, to be ran by `runprotected' */ /* type of protected functions, to be ran by 'runprotected' */
typedef void (*Pfunc) (lua_State *L, void *ud); typedef void (*Pfunc) (lua_State *L, void *ud);
LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name,
const char *mode); const char *mode);
LUAI_FUNC void luaD_hook (lua_State *L, int event, int line); LUAI_FUNC void luaD_hook (lua_State *L, int event, int line);
LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults);
LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults, LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults);
int allowyield); LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults);
LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u,
ptrdiff_t oldtop, ptrdiff_t ef); ptrdiff_t oldtop, ptrdiff_t ef);
LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult); LUAI_FUNC int luaD_poscall (lua_State *L, CallInfo *ci, StkId firstResult,
int nres);
LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
LUAI_FUNC void luaD_growstack (lua_State *L, int n); LUAI_FUNC void luaD_growstack (lua_State *L, int n);
LUAI_FUNC void luaD_shrinkstack (lua_State *L); LUAI_FUNC void luaD_shrinkstack (lua_State *L);
LUAI_FUNC void luaD_inctop (lua_State *L);
LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode); LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode);
LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
......
This diff is collapsed.
This diff is collapsed.
/* /*
** $Id: lfunc.h,v 2.8 2012/05/08 13:53:33 roberto Exp $ ** $Id: lfunc.h,v 2.15.1.1 2017/04/19 17:39:34 roberto Exp $
** Auxiliary functions to manipulate prototypes and closures ** Auxiliary functions to manipulate prototypes and closures
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
...@@ -18,14 +18,42 @@ ...@@ -18,14 +18,42 @@
cast(int, sizeof(TValue *)*((n)-1))) cast(int, sizeof(TValue *)*((n)-1)))
/* test whether thread is in 'twups' list */
#define isintwups(L) (L->twups != L)
/*
** maximum number of upvalues in a closure (both C and Lua). (Value
** must fit in a VM register.)
*/
#define MAXUPVAL 255
/*
** Upvalues for Lua closures
*/
struct UpVal {
TValue *v; /* points to stack or to its own value */
lu_mem refcount; /* reference counter */
union {
struct { /* (when open) */
UpVal *next; /* linked list */
int touched; /* mark to avoid cycles with dead threads */
} open;
TValue value; /* the value (when closed) */
} u;
};
#define upisopen(up) ((up)->v != &(up)->u.value)
LUAI_FUNC Proto *luaF_newproto (lua_State *L); LUAI_FUNC Proto *luaF_newproto (lua_State *L);
LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems); LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nelems);
LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems); LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nelems);
LUAI_FUNC UpVal *luaF_newupval (lua_State *L); LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl);
LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level);
LUAI_FUNC void luaF_close (lua_State *L, StkId level); LUAI_FUNC void luaF_close (lua_State *L, StkId level);
LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f);
LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv);
LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number,
int pc); int pc);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment