Commit 3e9ea906 authored by szefo09's avatar szefo09 Committed by GitHub

Merge pull request #8 from purerosefallen/mcpro-unity

Mcpro unity
parents 0c7eae59 2311690f
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
Assets/AssetStoreTools* Assets/AssetStoreTools*
# Visual Studio cache directory # Visual Studio cache directory
/.vs/ .vs
# Autogenerated VS/MD/Consulo solution and project files # Autogenerated VS/MD/Consulo solution and project files
ExportedObj/ ExportedObj/
...@@ -41,20 +41,26 @@ AI_core_vs2017solution/build/android/libs/ ...@@ -41,20 +41,26 @@ AI_core_vs2017solution/build/android/libs/
AI_core_vs2017solution/build/android/obj/ AI_core_vs2017solution/build/android/obj/
# ygopro # ygopro
ai/
cdb/ cdb/
config/ config/
deck/ 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
strings.conf strings.conf
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*
...@@ -2,19 +2,19 @@ LOCAL_PATH := $(call my-dir)/../../.. ...@@ -2,19 +2,19 @@ LOCAL_PATH := $(call my-dir)/../../..
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_MODULE := sqlite3 LOCAL_MODULE := sqlite3
LOCAL_SRC_FILES := ocgcore/sqlite3.c LOCAL_SRC_FILES := ocgcore/sqlite3/sqlite3.c
include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS) 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
...@@ -23,56 +23,59 @@ LOCAL_CFLAGS += -mno-unaligned-access ...@@ -23,56 +23,59 @@ LOCAL_CFLAGS += -mno-unaligned-access
endif endif
LOCAL_C_INCLUDES := $(LOCAL_PATH)/ocgcore LOCAL_C_INCLUDES := $(LOCAL_PATH)/ocgcore
LOCAL_C_INCLUDES += $(LOCAL_PATH)/ocgcore/lua
LOCAL_C_INCLUDES += $(LOCAL_PATH)/ocgcore/sqlite3
LOCAL_SRC_FILES := ocgcore/lapi.c \ LOCAL_SRC_FILES := ocgcore/lua/lapi.c \
ocgcore/lauxlib.c \ ocgcore/lua/lauxlib.c \
ocgcore/lbaselib.c \ ocgcore/lua/lbaselib.c \
ocgcore/lbitlib.c \ ocgcore/lua/lbitlib.c \
ocgcore/lcode.c \ ocgcore/lua/lcode.c \
ocgcore/lcorolib.c \ ocgcore/lua/lcorolib.c \
ocgcore/lctype.c \ ocgcore/lua/lctype.c \
ocgcore/ldblib.c \ ocgcore/lua/ldblib.c \
ocgcore/ldebug.c \ ocgcore/lua/ldebug.c \
ocgcore/ldo.c \ ocgcore/lua/ldo.c \
ocgcore/ldump.c \ ocgcore/lua/ldump.c \
ocgcore/lfunc.c \ ocgcore/lua/lfunc.c \
ocgcore/lgc.c \ ocgcore/lua/lgc.c \
ocgcore/linit.c \ ocgcore/lua/linit.c \
ocgcore/liolib.c \ ocgcore/lua/liolib.c \
ocgcore/llex.c \ ocgcore/lua/llex.c \
ocgcore/lmathlib.c \ ocgcore/lua/lmathlib.c \
ocgcore/lmem.c \ ocgcore/lua/lmem.c \
ocgcore/loadlib.c \ ocgcore/lua/loadlib.c \
ocgcore/lobject.c \ ocgcore/lua/lobject.c \
ocgcore/lopcodes.c \ ocgcore/lua/lopcodes.c \
ocgcore/loslib.c \ ocgcore/lua/loslib.c \
ocgcore/lparser.c \ ocgcore/lua/lparser.c \
ocgcore/lstate.c \ ocgcore/lua/lstate.c \
ocgcore/lstring.c \ ocgcore/lua/lstring.c \
ocgcore/lstrlib.c \ ocgcore/lua/lstrlib.c \
ocgcore/ltable.c \ ocgcore/lua/ltable.c \
ocgcore/ltablib.c \ ocgcore/lua/ltablib.c \
ocgcore/ltm.c \ ocgcore/lua/ltm.c \
ocgcore/lundump.c \ ocgcore/lua/lundump.c \
ocgcore/lvm.c \ ocgcore/lua/lutf8lib.c \
ocgcore/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)
......
...@@ -20,11 +20,11 @@ ifndef AR ...@@ -20,11 +20,11 @@ ifndef AR
endif endif
ifeq ($(config),release) ifeq ($(config),release)
OBJDIR = ../../obj/Linux/x86_64/ocgcore OBJDIR = ../../obj/gmake.linux/x86_64/ocgcore
TARGETDIR = ../../bin/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 += 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
CXXFLAGS += $(CFLAGS) -std=gnu++0x CXXFLAGS += $(CFLAGS) -std=gnu++0x
...@@ -42,11 +42,11 @@ ifeq ($(config),release) ...@@ -42,11 +42,11 @@ ifeq ($(config),release)
endif endif
ifeq ($(config),release32) ifeq ($(config),release32)
OBJDIR = ../../obj/Linux/x86/ocgcore OBJDIR = ../../obj/gmake.linux/x86/ocgcore
TARGETDIR = ../../bin/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 += 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
CXXFLAGS += $(CFLAGS) -std=gnu++0x CXXFLAGS += $(CFLAGS) -std=gnu++0x
...@@ -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 \
...@@ -173,100 +174,103 @@ $(GCH): $(PCH) ...@@ -173,100 +174,103 @@ $(GCH): $(PCH)
$(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<" $(SILENT) $(CXX) $(CXXFLAGS) -o "$@" -c "$<"
endif endif
$(OBJDIR)/lapi.o: ../../ocgcore/lapi.c $(OBJDIR)/lapi.o: ../../ocgcore/lua/lapi.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/lauxlib.o: ../../ocgcore/lauxlib.c $(OBJDIR)/lauxlib.o: ../../ocgcore/lua/lauxlib.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/lbaselib.o: ../../ocgcore/lbaselib.c $(OBJDIR)/lbaselib.o: ../../ocgcore/lua/lbaselib.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/lbitlib.o: ../../ocgcore/lbitlib.c $(OBJDIR)/lbitlib.o: ../../ocgcore/lua/lbitlib.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/lcode.o: ../../ocgcore/lcode.c $(OBJDIR)/lcode.o: ../../ocgcore/lua/lcode.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/lcorolib.o: ../../ocgcore/lcorolib.c $(OBJDIR)/lcorolib.o: ../../ocgcore/lua/lcorolib.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/lctype.o: ../../ocgcore/lctype.c $(OBJDIR)/lctype.o: ../../ocgcore/lua/lctype.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/ldblib.o: ../../ocgcore/ldblib.c $(OBJDIR)/ldblib.o: ../../ocgcore/lua/ldblib.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/ldebug.o: ../../ocgcore/ldebug.c $(OBJDIR)/ldebug.o: ../../ocgcore/lua/ldebug.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/ldo.o: ../../ocgcore/ldo.c $(OBJDIR)/ldo.o: ../../ocgcore/lua/ldo.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/ldump.o: ../../ocgcore/ldump.c $(OBJDIR)/ldump.o: ../../ocgcore/lua/ldump.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/lfunc.o: ../../ocgcore/lfunc.c $(OBJDIR)/lfunc.o: ../../ocgcore/lua/lfunc.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/lgc.o: ../../ocgcore/lgc.c $(OBJDIR)/lgc.o: ../../ocgcore/lua/lgc.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/linit.o: ../../ocgcore/linit.c $(OBJDIR)/linit.o: ../../ocgcore/lua/linit.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/liolib.o: ../../ocgcore/liolib.c $(OBJDIR)/liolib.o: ../../ocgcore/lua/liolib.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/llex.o: ../../ocgcore/llex.c $(OBJDIR)/llex.o: ../../ocgcore/lua/llex.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/lmathlib.o: ../../ocgcore/lmathlib.c $(OBJDIR)/lmathlib.o: ../../ocgcore/lua/lmathlib.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/lmem.o: ../../ocgcore/lmem.c $(OBJDIR)/lmem.o: ../../ocgcore/lua/lmem.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/loadlib.o: ../../ocgcore/loadlib.c $(OBJDIR)/loadlib.o: ../../ocgcore/lua/loadlib.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/lobject.o: ../../ocgcore/lobject.c $(OBJDIR)/lobject.o: ../../ocgcore/lua/lobject.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/lopcodes.o: ../../ocgcore/lopcodes.c $(OBJDIR)/lopcodes.o: ../../ocgcore/lua/lopcodes.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/loslib.o: ../../ocgcore/loslib.c $(OBJDIR)/loslib.o: ../../ocgcore/lua/loslib.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/lparser.o: ../../ocgcore/lparser.c $(OBJDIR)/lparser.o: ../../ocgcore/lua/lparser.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/lstate.o: ../../ocgcore/lstate.c $(OBJDIR)/lstate.o: ../../ocgcore/lua/lstate.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/lstring.o: ../../ocgcore/lstring.c $(OBJDIR)/lstring.o: ../../ocgcore/lua/lstring.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/lstrlib.o: ../../ocgcore/lstrlib.c $(OBJDIR)/lstrlib.o: ../../ocgcore/lua/lstrlib.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/ltable.o: ../../ocgcore/ltable.c $(OBJDIR)/ltable.o: ../../ocgcore/lua/ltable.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/ltablib.o: ../../ocgcore/ltablib.c $(OBJDIR)/ltablib.o: ../../ocgcore/lua/ltablib.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/ltm.o: ../../ocgcore/ltm.c $(OBJDIR)/ltm.o: ../../ocgcore/lua/ltm.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/lundump.o: ../../ocgcore/lundump.c $(OBJDIR)/lundump.o: ../../ocgcore/lua/lundump.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/lvm.o: ../../ocgcore/lvm.c $(OBJDIR)/lutf8lib.o: ../../ocgcore/lua/lutf8lib.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/lzio.o: ../../ocgcore/lzio.c $(OBJDIR)/lvm.o: ../../ocgcore/lua/lvm.c
@echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/lzio.o: ../../ocgcore/lua/lzio.c
@echo $(notdir $<) @echo $(notdir $<)
$(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<" $(SILENT) $(CC) $(CFLAGS) -o "$@" -c "$<"
$(OBJDIR)/card.o: ../../ocgcore/card.cpp $(OBJDIR)/card.o: ../../ocgcore/card.cpp
......
...@@ -20,16 +20,16 @@ ifndef RESCOMP ...@@ -20,16 +20,16 @@ ifndef RESCOMP
endif endif
ifeq ($(config),release) ifeq ($(config),release)
OBJDIR = ../../obj/Windows/x86_64/ocgcore OBJDIR = ../../obj/gmake.windows/x86_64/ocgcore
TARGETDIR = ../../bin/x86_64 TARGETDIR = ../../bin/gmake.windows/x86_64
TARGET = $(TARGETDIR)/ocgcore.dll TARGET = $(TARGETDIR)/ocgcore.dll
DEFINES += DEFINES += -DLUA_COMPAT_5_2
INCLUDES += 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
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) -std=gnu++0x -fpermissive ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) -std=gnu++0x -fpermissive
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
ALL_LDFLAGS += $(LDFLAGS) -s -shared -Wl,--out-implib="../../bin/x86_64/libocgcore.a" ALL_LDFLAGS += $(LDFLAGS) -s -shared -Wl,--out-implib="../../bin/gmake.windows/x86_64/libocgcore.a"
LDDEPS += LDDEPS +=
LIBS += $(LDDEPS) LIBS += $(LDDEPS)
LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(ALL_LDFLAGS) $(LIBS) LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(ALL_LDFLAGS) $(LIBS)
...@@ -42,16 +42,16 @@ ifeq ($(config),release) ...@@ -42,16 +42,16 @@ ifeq ($(config),release)
endif endif
ifeq ($(config),release32) ifeq ($(config),release32)
OBJDIR = ../../obj/Windows/x86/ocgcore OBJDIR = ../../obj/gmake.windows/x86/ocgcore
TARGETDIR = ../../bin/x86 TARGETDIR = ../../bin/gmake.windows/x86
TARGET = $(TARGETDIR)/ocgcore.dll TARGET = $(TARGETDIR)/ocgcore.dll
DEFINES += DEFINES += -DLUA_COMPAT_5_2
INCLUDES += 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
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) -std=gnu++0x ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) -std=gnu++0x
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
ALL_LDFLAGS += $(LDFLAGS) -s -shared -Wl,--out-implib="../../bin/x86/libocgcore.a" -m32 -L/usr/lib32 ALL_LDFLAGS += $(LDFLAGS) -s -shared -Wl,--out-implib="../../bin/gmake.windows/x86/libocgcore.a" -m32 -L/usr/lib32
LDDEPS += LDDEPS +=
LIBS += $(LDDEPS) LIBS += $(LDDEPS)
LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(ALL_LDFLAGS) $(LIBS) LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(ALL_LDFLAGS) $(LIBS)
...@@ -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 \
...@@ -172,131 +173,135 @@ $(GCH): $(PCH) ...@@ -172,131 +173,135 @@ $(GCH): $(PCH)
$(SILENT) $(CXX) -x c++-header $(ALL_CXXFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<" $(SILENT) $(CXX) -x c++-header $(ALL_CXXFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<"
endif endif
$(OBJDIR)/lapi.o: ../../ocgcore/lapi.c $(OBJDIR)/lapi.o: ../../ocgcore/lua/lapi.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)/lauxlib.o: ../../ocgcore/lauxlib.c $(OBJDIR)/lauxlib.o: ../../ocgcore/lua/lauxlib.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)/lbaselib.o: ../../ocgcore/lbaselib.c $(OBJDIR)/lbaselib.o: ../../ocgcore/lua/lbaselib.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)/lbitlib.o: ../../ocgcore/lbitlib.c $(OBJDIR)/lbitlib.o: ../../ocgcore/lua/lbitlib.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)/lcode.o: ../../ocgcore/lcode.c $(OBJDIR)/lcode.o: ../../ocgcore/lua/lcode.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)/lcorolib.o: ../../ocgcore/lcorolib.c $(OBJDIR)/lcorolib.o: ../../ocgcore/lua/lcorolib.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)/lctype.o: ../../ocgcore/lctype.c $(OBJDIR)/lctype.o: ../../ocgcore/lua/lctype.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)/ldblib.o: ../../ocgcore/ldblib.c $(OBJDIR)/ldblib.o: ../../ocgcore/lua/ldblib.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)/ldebug.o: ../../ocgcore/ldebug.c $(OBJDIR)/ldebug.o: ../../ocgcore/lua/ldebug.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)/ldo.o: ../../ocgcore/ldo.c $(OBJDIR)/ldo.o: ../../ocgcore/lua/ldo.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)/ldump.o: ../../ocgcore/ldump.c $(OBJDIR)/ldump.o: ../../ocgcore/lua/ldump.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)/lfunc.o: ../../ocgcore/lfunc.c $(OBJDIR)/lfunc.o: ../../ocgcore/lua/lfunc.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)/lgc.o: ../../ocgcore/lgc.c $(OBJDIR)/lgc.o: ../../ocgcore/lua/lgc.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)/linit.o: ../../ocgcore/linit.c $(OBJDIR)/linit.o: ../../ocgcore/lua/linit.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)/liolib.o: ../../ocgcore/liolib.c $(OBJDIR)/liolib.o: ../../ocgcore/lua/liolib.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)/llex.o: ../../ocgcore/llex.c $(OBJDIR)/llex.o: ../../ocgcore/lua/llex.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)/lmathlib.o: ../../ocgcore/lmathlib.c $(OBJDIR)/lmathlib.o: ../../ocgcore/lua/lmathlib.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)/lmem.o: ../../ocgcore/lmem.c $(OBJDIR)/lmem.o: ../../ocgcore/lua/lmem.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)/loadlib.o: ../../ocgcore/loadlib.c $(OBJDIR)/loadlib.o: ../../ocgcore/lua/loadlib.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)/lobject.o: ../../ocgcore/lobject.c $(OBJDIR)/lobject.o: ../../ocgcore/lua/lobject.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)/lopcodes.o: ../../ocgcore/lopcodes.c $(OBJDIR)/lopcodes.o: ../../ocgcore/lua/lopcodes.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)/loslib.o: ../../ocgcore/loslib.c $(OBJDIR)/loslib.o: ../../ocgcore/lua/loslib.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)/lparser.o: ../../ocgcore/lparser.c $(OBJDIR)/lparser.o: ../../ocgcore/lua/lparser.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)/lstate.o: ../../ocgcore/lstate.c $(OBJDIR)/lstate.o: ../../ocgcore/lua/lstate.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)/lstring.o: ../../ocgcore/lstring.c $(OBJDIR)/lstring.o: ../../ocgcore/lua/lstring.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)/lstrlib.o: ../../ocgcore/lstrlib.c $(OBJDIR)/lstrlib.o: ../../ocgcore/lua/lstrlib.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)/ltable.o: ../../ocgcore/ltable.c $(OBJDIR)/ltable.o: ../../ocgcore/lua/ltable.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)/ltablib.o: ../../ocgcore/ltablib.c $(OBJDIR)/ltablib.o: ../../ocgcore/lua/ltablib.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)/ltm.o: ../../ocgcore/ltm.c $(OBJDIR)/ltm.o: ../../ocgcore/lua/ltm.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)/lundump.o: ../../ocgcore/lundump.c $(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)/lvm.o: ../../ocgcore/lvm.c $(OBJDIR)/lutf8lib.o: ../../ocgcore/lua/lutf8lib.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)/lzio.o: ../../ocgcore/lzio.c $(OBJDIR)/lvm.o: ../../ocgcore/lua/lvm.c
@echo $(notdir $<)
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF $(@:%.o=%.d) -c "$<"
$(OBJDIR)/lzio.o: ../../ocgcore/lua/lzio.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 "$<"
......
...@@ -20,8 +20,8 @@ ifndef RESCOMP ...@@ -20,8 +20,8 @@ ifndef RESCOMP
endif endif
ifeq ($(config),release) ifeq ($(config),release)
OBJDIR = ../../obj/Windows/x86_64/sqlite3 OBJDIR = ../../obj/gmake.windows/x86_64/sqlite3
TARGETDIR = ../../bin/x86_64 TARGETDIR = ../../bin/gmake.windows/x86_64
TARGET = $(TARGETDIR)/sqlite3.dll TARGET = $(TARGETDIR)/sqlite3.dll
DEFINES += DEFINES +=
INCLUDES += INCLUDES +=
...@@ -29,7 +29,7 @@ ifeq ($(config),release) ...@@ -29,7 +29,7 @@ ifeq ($(config),release)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -Os -static-libgcc ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -Os -static-libgcc
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
ALL_LDFLAGS += $(LDFLAGS) -s -shared -Wl,--out-implib="../../bin/x86_64/libsqlite3.a" ALL_LDFLAGS += $(LDFLAGS) -s -shared -Wl,--out-implib="../../bin/gmake.windows/x86_64/libsqlite3.a"
LDDEPS += LDDEPS +=
LIBS += $(LDDEPS) LIBS += $(LDDEPS)
LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(ALL_LDFLAGS) $(LIBS) LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(ALL_LDFLAGS) $(LIBS)
...@@ -42,8 +42,8 @@ ifeq ($(config),release) ...@@ -42,8 +42,8 @@ ifeq ($(config),release)
endif endif
ifeq ($(config),release32) ifeq ($(config),release32)
OBJDIR = ../../obj/Windows/x86/sqlite3 OBJDIR = ../../obj/gmake.windows/x86/sqlite3
TARGETDIR = ../../bin/x86 TARGETDIR = ../../bin/gmake.windows/x86
TARGET = $(TARGETDIR)/sqlite3.dll TARGET = $(TARGETDIR)/sqlite3.dll
DEFINES += DEFINES +=
INCLUDES += INCLUDES +=
...@@ -51,7 +51,7 @@ ifeq ($(config),release32) ...@@ -51,7 +51,7 @@ ifeq ($(config),release32)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -Os -m32 -static-libgcc ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -Os -m32 -static-libgcc
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
ALL_LDFLAGS += $(LDFLAGS) -s -shared -Wl,--out-implib="../../bin/x86_64/libsqlite3.a" -m32 -L/usr/lib32 ALL_LDFLAGS += $(LDFLAGS) -s -shared -Wl,--out-implib="../../bin/gmake.windows/x86/libsqlite3.a" -m32 -L/usr/lib32
LDDEPS += LDDEPS +=
LIBS += $(LDDEPS) LIBS += $(LDDEPS)
LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(ALL_LDFLAGS) $(LIBS) LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(ALL_LDFLAGS) $(LIBS)
...@@ -124,7 +124,7 @@ $(GCH): $(PCH) ...@@ -124,7 +124,7 @@ $(GCH): $(PCH)
$(SILENT) $(CXX) -x c++-header $(ALL_CXXFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<" $(SILENT) $(CXX) -x c++-header $(ALL_CXXFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<"
endif endif
$(OBJDIR)/sqlite3.o: ../../ocgcore/sqlite3.c $(OBJDIR)/sqlite3.o: ../../ocgcore/sqlite3/sqlite3.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 "$<"
......
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15 # Visual Studio 15
VisualStudioVersion = 15.0.26403.3 VisualStudioVersion = 15.0.26403.3
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ocgcore", "ocgcore\ocgcore.vcxproj", "{63635A2D-8303-46F7-8C8B-D1C36655F820}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ocgcore", "ocgcore\ocgcore.vcxproj", "{63635A2D-8303-46F7-8C8B-D1C36655F820}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "coreWrapper", "coreWrapper\coreWrapper.csproj", "{5448596E-A4D2-4011-B8C1-5228260040D1}" Global
EndProject GlobalSection(SolutionConfigurationPlatforms) = preSolution
Global Debug|x64 = Debug|x64
GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x86 = Debug|x86
Debug|Any CPU = Debug|Any CPU Release|x64 = Release|x64
Debug|x64 = Debug|x64 Release|x86 = Release|x86
Debug|x86 = Debug|x86 EndGlobalSection
Release|Any CPU = Release|Any CPU GlobalSection(ProjectConfigurationPlatforms) = postSolution
Release|x64 = Release|x64 {63635A2D-8303-46F7-8C8B-D1C36655F820}.Debug|x64.ActiveCfg = Debug|x64
Release|x86 = Release|x86 {63635A2D-8303-46F7-8C8B-D1C36655F820}.Debug|x64.Build.0 = Debug|x64
EndGlobalSection {63635A2D-8303-46F7-8C8B-D1C36655F820}.Debug|x86.ActiveCfg = Debug|Win32
GlobalSection(ProjectConfigurationPlatforms) = postSolution {63635A2D-8303-46F7-8C8B-D1C36655F820}.Debug|x86.Build.0 = Debug|Win32
{63635A2D-8303-46F7-8C8B-D1C36655F820}.Debug|Any CPU.ActiveCfg = Debug|Win32 {63635A2D-8303-46F7-8C8B-D1C36655F820}.Release|x64.ActiveCfg = Release|x64
{63635A2D-8303-46F7-8C8B-D1C36655F820}.Debug|x64.ActiveCfg = Debug|x64 {63635A2D-8303-46F7-8C8B-D1C36655F820}.Release|x64.Build.0 = Release|x64
{63635A2D-8303-46F7-8C8B-D1C36655F820}.Debug|x64.Build.0 = Debug|x64 {63635A2D-8303-46F7-8C8B-D1C36655F820}.Release|x86.ActiveCfg = Release|Win32
{63635A2D-8303-46F7-8C8B-D1C36655F820}.Debug|x86.ActiveCfg = Debug|Win32 {63635A2D-8303-46F7-8C8B-D1C36655F820}.Release|x86.Build.0 = Release|Win32
{63635A2D-8303-46F7-8C8B-D1C36655F820}.Debug|x86.Build.0 = Debug|Win32 EndGlobalSection
{63635A2D-8303-46F7-8C8B-D1C36655F820}.Release|Any CPU.ActiveCfg = Release|Win32 GlobalSection(SolutionProperties) = preSolution
{63635A2D-8303-46F7-8C8B-D1C36655F820}.Release|x64.ActiveCfg = Release|x64 HideSolutionNode = FALSE
{63635A2D-8303-46F7-8C8B-D1C36655F820}.Release|x64.Build.0 = Release|x64 EndGlobalSection
{63635A2D-8303-46F7-8C8B-D1C36655F820}.Release|x86.ActiveCfg = Release|Win32 GlobalSection(ExtensibilityGlobals) = postSolution
{63635A2D-8303-46F7-8C8B-D1C36655F820}.Release|x86.Build.0 = Release|Win32 SolutionGuid = {6B0513E2-BC41-4C0B-91E8-E596BD9336CF}
{5448596E-A4D2-4011-B8C1-5228260040D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU EndGlobalSection
{5448596E-A4D2-4011-B8C1-5228260040D1}.Debug|Any CPU.Build.0 = Debug|Any CPU EndGlobal
{5448596E-A4D2-4011-B8C1-5228260040D1}.Debug|x64.ActiveCfg = Debug|x64
{5448596E-A4D2-4011-B8C1-5228260040D1}.Debug|x64.Build.0 = Debug|x64
{5448596E-A4D2-4011-B8C1-5228260040D1}.Debug|x86.ActiveCfg = Debug|Any CPU
{5448596E-A4D2-4011-B8C1-5228260040D1}.Debug|x86.Build.0 = Debug|Any CPU
{5448596E-A4D2-4011-B8C1-5228260040D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5448596E-A4D2-4011-B8C1-5228260040D1}.Release|Any CPU.Build.0 = Release|Any CPU
{5448596E-A4D2-4011-B8C1-5228260040D1}.Release|x64.ActiveCfg = Release|x64
{5448596E-A4D2-4011-B8C1-5228260040D1}.Release|x64.Build.0 = Release|x64
{5448596E-A4D2-4011-B8C1-5228260040D1}.Release|x86.ActiveCfg = Release|Any CPU
{5448596E-A4D2-4011-B8C1-5228260040D1}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("Precy")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Precy")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//将 ComVisible 设置为 false 将使此程序集中的类型
//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("5448596e-a4d2-4011-b8c1-5228260040d1")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{5448596E-A4D2-4011-B8C1-5228260040D1}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Percy</RootNamespace>
<AssemblyName>System.Servicemodel.Faltexception</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="coreWrapper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<StartAction>Project</StartAction>
<StartProgram>D:\yugioh\ygopro2.exe</StartProgram>
</PropertyGroup>
</Project>
\ No newline at end of file
/*
** $Id: ldump.c,v 2.17 2012/01/23 23:02:10 roberto Exp $
** save precompiled Lua chunks
** See Copyright Notice in lua.h
*/
#include <stddef.h>
#define ldump_c
#define LUA_CORE
#include "lua.h"
#include "lobject.h"
#include "lstate.h"
#include "lundump.h"
typedef struct {
lua_State* L;
lua_Writer writer;
void* data;
int strip;
int status;
} DumpState;
#define DumpMem(b,n,size,D) DumpBlock(b,(n)*(size),D)
#define DumpVar(x,D) DumpMem(&x,1,sizeof(x),D)
static void DumpBlock(const void* b, size_t size, DumpState* D)
{
if (D->status==0)
{
lua_unlock(D->L);
D->status=(*D->writer)(D->L,b,size,D->data);
lua_lock(D->L);
}
}
static void DumpChar(int y, DumpState* D)
{
char x=(char)y;
DumpVar(x,D);
}
static void DumpInt(int x, DumpState* D)
{
DumpVar(x,D);
}
static void DumpNumber(lua_Number x, DumpState* D)
{
DumpVar(x,D);
}
static void DumpVector(const void* b, int n, size_t size, DumpState* D)
{
DumpInt(n,D);
DumpMem(b,n,size,D);
}
static void DumpString(const TString* s, DumpState* D)
{
if (s==NULL)
{
size_t size=0;
DumpVar(size,D);
}
else
{
size_t size=s->tsv.len+1; /* include trailing '\0' */
DumpVar(size,D);
DumpBlock(getstr(s),size*sizeof(char),D);
}
}
#define DumpCode(f,D) DumpVector(f->code,f->sizecode,sizeof(Instruction),D)
static void DumpFunction(const Proto* f, DumpState* D);
static void DumpConstants(const Proto* f, DumpState* D)
{
int i,n=f->sizek;
DumpInt(n,D);
for (i=0; i<n; i++)
{
const TValue* o=&f->k[i];
DumpChar(ttypenv(o),D);
switch (ttypenv(o))
{
case LUA_TNIL:
break;
case LUA_TBOOLEAN:
DumpChar(bvalue(o),D);
break;
case LUA_TNUMBER:
DumpNumber(nvalue(o),D);
break;
case LUA_TSTRING:
DumpString(rawtsvalue(o),D);
break;
default: lua_assert(0);
}
}
n=f->sizep;
DumpInt(n,D);
for (i=0; i<n; i++) DumpFunction(f->p[i],D);
}
static void DumpUpvalues(const Proto* f, DumpState* D)
{
int i,n=f->sizeupvalues;
DumpInt(n,D);
for (i=0; i<n; i++)
{
DumpChar(f->upvalues[i].instack,D);
DumpChar(f->upvalues[i].idx,D);
}
}
static void DumpDebug(const Proto* f, DumpState* D)
{
int i,n;
DumpString((D->strip) ? NULL : f->source,D);
n= (D->strip) ? 0 : f->sizelineinfo;
DumpVector(f->lineinfo,n,sizeof(int),D);
n= (D->strip) ? 0 : f->sizelocvars;
DumpInt(n,D);
for (i=0; i<n; i++)
{
DumpString(f->locvars[i].varname,D);
DumpInt(f->locvars[i].startpc,D);
DumpInt(f->locvars[i].endpc,D);
}
n= (D->strip) ? 0 : f->sizeupvalues;
DumpInt(n,D);
for (i=0; i<n; i++) DumpString(f->upvalues[i].name,D);
}
static void DumpFunction(const Proto* f, DumpState* D)
{
DumpInt(f->linedefined,D);
DumpInt(f->lastlinedefined,D);
DumpChar(f->numparams,D);
DumpChar(f->is_vararg,D);
DumpChar(f->maxstacksize,D);
DumpCode(f,D);
DumpConstants(f,D);
DumpUpvalues(f,D);
DumpDebug(f,D);
}
static void DumpHeader(DumpState* D)
{
lu_byte h[LUAC_HEADERSIZE];
luaU_header(h);
DumpBlock(h,LUAC_HEADERSIZE,D);
}
/*
** dump Lua function as precompiled chunk
*/
int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip)
{
DumpState D;
D.L=L;
D.writer=w;
D.data=data;
D.strip=strip;
D.status=0;
DumpHeader(&D);
DumpFunction(f,&D);
return D.status;
}
/*
** $Id: lstring.c,v 2.24 2012/05/11 14:14:42 roberto Exp $
** String table (keeps all strings handled by Lua)
** See Copyright Notice in lua.h
*/
#include <string.h>
#define lstring_c
#define LUA_CORE
#include "lua.h"
#include "lmem.h"
#include "lobject.h"
#include "lstate.h"
#include "lstring.h"
/*
** Lua will use at most ~(2^LUAI_HASHLIMIT) bytes from a string to
** compute its hash
*/
#if !defined(LUAI_HASHLIMIT)
#define LUAI_HASHLIMIT 5
#endif
/*
** equality for long strings
*/
int luaS_eqlngstr (TString *a, TString *b) {
size_t len = a->tsv.len;
lua_assert(a->tsv.tt == LUA_TLNGSTR && b->tsv.tt == LUA_TLNGSTR);
return (a == b) || /* same instance or... */
((len == b->tsv.len) && /* equal length and ... */
(memcmp(getstr(a), getstr(b), len) == 0)); /* equal contents */
}
/*
** equality for strings
*/
int luaS_eqstr (TString *a, TString *b) {
return (a->tsv.tt == b->tsv.tt) &&
(a->tsv.tt == LUA_TSHRSTR ? eqshrstr(a, b) : luaS_eqlngstr(a, b));
}
unsigned int luaS_hash (const char *str, size_t l, unsigned int seed) {
unsigned int h = seed ^ l;
size_t l1;
size_t step = (l >> LUAI_HASHLIMIT) + 1;
for (l1 = l; l1 >= step; l1 -= step)
h = h ^ ((h<<5) + (h>>2) + cast_byte(str[l1 - 1]));
return h;
}
/*
** resizes the string table
*/
void luaS_resize (lua_State *L, int newsize) {
int i;
stringtable *tb = &G(L)->strt;
/* cannot resize while GC is traversing strings */
luaC_runtilstate(L, ~bitmask(GCSsweepstring));
if (newsize > tb->size) {
luaM_reallocvector(L, tb->hash, tb->size, newsize, GCObject *);
for (i = tb->size; i < newsize; i++) tb->hash[i] = NULL;
}
/* rehash */
for (i=0; i<tb->size; i++) {
GCObject *p = tb->hash[i];
tb->hash[i] = NULL;
while (p) { /* for each node in the list */
GCObject *next = gch(p)->next; /* save next */
unsigned int h = lmod(gco2ts(p)->hash, newsize); /* new position */
gch(p)->next = tb->hash[h]; /* chain it */
tb->hash[h] = p;
resetoldbit(p); /* see MOVE OLD rule */
p = next;
}
}
if (newsize < tb->size) {
/* shrinking slice must be empty */
lua_assert(tb->hash[newsize] == NULL && tb->hash[tb->size - 1] == NULL);
luaM_reallocvector(L, tb->hash, tb->size, newsize, GCObject *);
}
tb->size = newsize;
}
/*
** creates a new string object
*/
static TString *createstrobj (lua_State *L, const char *str, size_t l,
int tag, unsigned int h, GCObject **list) {
TString *ts;
size_t totalsize; /* total size of TString object */
totalsize = sizeof(TString) + ((l + 1) * sizeof(char));
ts = &luaC_newobj(L, tag, totalsize, list, 0)->ts;
ts->tsv.len = l;
ts->tsv.hash = h;
ts->tsv.extra = 0;
memcpy(ts+1, str, l*sizeof(char));
((char *)(ts+1))[l] = '\0'; /* ending 0 */
return ts;
}
/*
** creates a new short string, inserting it into string table
*/
static TString *newshrstr (lua_State *L, const char *str, size_t l,
unsigned int h) {
GCObject **list; /* (pointer to) list where it will be inserted */
stringtable *tb = &G(L)->strt;
TString *s;
if (tb->nuse >= cast(lu_int32, tb->size) && tb->size <= MAX_INT/2)
luaS_resize(L, tb->size*2); /* too crowded */
list = &tb->hash[lmod(h, tb->size)];
s = createstrobj(L, str, l, LUA_TSHRSTR, h, list);
tb->nuse++;
return s;
}
/*
** checks whether short string exists and reuses it or creates a new one
*/
static TString *internshrstr (lua_State *L, const char *str, size_t l) {
GCObject *o;
global_State *g = G(L);
unsigned int h = luaS_hash(str, l, g->seed);
for (o = g->strt.hash[lmod(h, g->strt.size)];
o != NULL;
o = gch(o)->next) {
TString *ts = rawgco2ts(o);
if (h == ts->tsv.hash &&
ts->tsv.len == l &&
(memcmp(str, getstr(ts), l * sizeof(char)) == 0)) {
if (isdead(G(L), o)) /* string is dead (but was not collected yet)? */
changewhite(o); /* resurrect it */
return ts;
}
}
return newshrstr(L, str, l, h); /* not found; create a new string */
}
/*
** new string (with explicit length)
*/
TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
if (l <= LUAI_MAXSHORTLEN) /* short string? */
return internshrstr(L, str, l);
else {
if (l + 1 > (MAX_SIZET - sizeof(TString))/sizeof(char))
luaM_toobig(L);
return createstrobj(L, str, l, LUA_TLNGSTR, G(L)->seed, NULL);
}
}
/*
** new zero-terminated string
*/
TString *luaS_new (lua_State *L, const char *str) {
return luaS_newlstr(L, str, strlen(str));
}
Udata *luaS_newudata (lua_State *L, size_t s, Table *e) {
Udata *u;
if (s > MAX_SIZET - sizeof(Udata))
luaM_toobig(L);
u = &luaC_newobj(L, LUA_TUSERDATA, sizeof(Udata) + s, NULL, 0)->u;
u->uv.len = s;
u->uv.metatable = NULL;
u->uv.env = e;
return u;
}
/*
** $Id: ltablib.c,v 1.63 2011/11/28 17:26:30 roberto Exp $
** Library for Table Manipulation
** See Copyright Notice in lua.h
*/
#include <stddef.h>
#define ltablib_c
#define LUA_LIB
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
#define aux_getn(L,n) \
(luaL_checktype(L, n, LUA_TTABLE), luaL_len(L, n))
#if defined(LUA_COMPAT_MAXN)
static int maxn (lua_State *L) {
lua_Number max = 0;
luaL_checktype(L, 1, LUA_TTABLE);
lua_pushnil(L); /* first key */
while (lua_next(L, 1)) {
lua_pop(L, 1); /* remove value */
if (lua_type(L, -1) == LUA_TNUMBER) {
lua_Number v = lua_tonumber(L, -1);
if (v > max) max = v;
}
}
lua_pushnumber(L, max);
return 1;
}
#endif
static int tinsert (lua_State *L) {
int e = aux_getn(L, 1) + 1; /* first empty element */
int pos; /* where to insert new element */
switch (lua_gettop(L)) {
case 2: { /* called with only 2 arguments */
pos = e; /* insert new element at the end */
break;
}
case 3: {
int i;
pos = luaL_checkint(L, 2); /* 2nd argument is the position */
if (pos > e) e = pos; /* `grow' array if necessary */
for (i = e; i > pos; i--) { /* move up elements */
lua_rawgeti(L, 1, i-1);
lua_rawseti(L, 1, i); /* t[i] = t[i-1] */
}
break;
}
default: {
return luaL_error(L, "wrong number of arguments to " LUA_QL("insert"));
}
}
lua_rawseti(L, 1, pos); /* t[pos] = v */
return 0;
}
static int tremove (lua_State *L) {
int e = aux_getn(L, 1);
int pos = luaL_optint(L, 2, e);
if (!(1 <= pos && pos <= e)) /* position is outside bounds? */
return 0; /* nothing to remove */
lua_rawgeti(L, 1, pos); /* result = t[pos] */
for ( ;pos<e; pos++) {
lua_rawgeti(L, 1, pos+1);
lua_rawseti(L, 1, pos); /* t[pos] = t[pos+1] */
}
lua_pushnil(L);
lua_rawseti(L, 1, e); /* t[e] = nil */
return 1;
}
static void addfield (lua_State *L, luaL_Buffer *b, int i) {
lua_rawgeti(L, 1, i);
if (!lua_isstring(L, -1))
luaL_error(L, "invalid value (%s) at index %d in table for "
LUA_QL("concat"), luaL_typename(L, -1), i);
luaL_addvalue(b);
}
static int tconcat (lua_State *L) {
luaL_Buffer b;
size_t lsep;
int i, last;
const char *sep = luaL_optlstring(L, 2, "", &lsep);
luaL_checktype(L, 1, LUA_TTABLE);
i = luaL_optint(L, 3, 1);
last = luaL_opt(L, luaL_checkint, 4, luaL_len(L, 1));
luaL_buffinit(L, &b);
for (; i < last; i++) {
addfield(L, &b, i);
luaL_addlstring(&b, sep, lsep);
}
if (i == last) /* add last value (if interval was not empty) */
addfield(L, &b, i);
luaL_pushresult(&b);
return 1;
}
/*
** {======================================================
** Pack/unpack
** =======================================================
*/
static int pack (lua_State *L) {
int n = lua_gettop(L); /* number of elements to pack */
lua_createtable(L, n, 1); /* create result table */
lua_pushinteger(L, n);
lua_setfield(L, -2, "n"); /* t.n = number of elements */
if (n > 0) { /* at least one element? */
int i;
lua_pushvalue(L, 1);
lua_rawseti(L, -2, 1); /* insert first element */
lua_replace(L, 1); /* move table into index 1 */
for (i = n; i >= 2; i--) /* assign other elements */
lua_rawseti(L, 1, i);
}
return 1; /* return table */
}
static int unpack (lua_State *L) {
int i, e, n;
luaL_checktype(L, 1, LUA_TTABLE);
i = luaL_optint(L, 2, 1);
e = luaL_opt(L, luaL_checkint, 3, luaL_len(L, 1));
if (i > e) return 0; /* empty range */
n = e - i + 1; /* number of elements */
if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */
return luaL_error(L, "too many results to unpack");
lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */
while (i++ < e) /* push arg[i + 1...e] */
lua_rawgeti(L, 1, i);
return n;
}
/* }====================================================== */
/*
** {======================================================
** Quicksort
** (based on `Algorithms in MODULA-3', Robert Sedgewick;
** Addison-Wesley, 1993.)
** =======================================================
*/
static void set2 (lua_State *L, int i, int j) {
lua_rawseti(L, 1, i);
lua_rawseti(L, 1, j);
}
static int sort_comp (lua_State *L, int a, int b) {
if (!lua_isnil(L, 2)) { /* function? */
int res;
lua_pushvalue(L, 2);
lua_pushvalue(L, a-1); /* -1 to compensate function */
lua_pushvalue(L, b-2); /* -2 to compensate function and `a' */
lua_call(L, 2, 1);
res = lua_toboolean(L, -1);
lua_pop(L, 1);
return res;
}
else /* a < b? */
return lua_compare(L, a, b, LUA_OPLT);
}
static void auxsort (lua_State *L, int l, int u) {
while (l < u) { /* for tail recursion */
int i, j;
/* sort elements a[l], a[(l+u)/2] and a[u] */
lua_rawgeti(L, 1, l);
lua_rawgeti(L, 1, u);
if (sort_comp(L, -1, -2)) /* a[u] < a[l]? */
set2(L, l, u); /* swap a[l] - a[u] */
else
lua_pop(L, 2);
if (u-l == 1) break; /* only 2 elements */
i = (l+u)/2;
lua_rawgeti(L, 1, i);
lua_rawgeti(L, 1, l);
if (sort_comp(L, -2, -1)) /* a[i]<a[l]? */
set2(L, i, l);
else {
lua_pop(L, 1); /* remove a[l] */
lua_rawgeti(L, 1, u);
if (sort_comp(L, -1, -2)) /* a[u]<a[i]? */
set2(L, i, u);
else
lua_pop(L, 2);
}
if (u-l == 2) break; /* only 3 elements */
lua_rawgeti(L, 1, i); /* Pivot */
lua_pushvalue(L, -1);
lua_rawgeti(L, 1, u-1);
set2(L, i, u-1);
/* a[l] <= P == a[u-1] <= a[u], only need to sort from l+1 to u-2 */
i = l; j = u-1;
for (;;) { /* invariant: a[l..i] <= P <= a[j..u] */
/* repeat ++i until a[i] >= P */
while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) {
if (i>=u) luaL_error(L, "invalid order function for sorting");
lua_pop(L, 1); /* remove a[i] */
}
/* repeat --j until a[j] <= P */
while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) {
if (j<=l) luaL_error(L, "invalid order function for sorting");
lua_pop(L, 1); /* remove a[j] */
}
if (j<i) {
lua_pop(L, 3); /* pop pivot, a[i], a[j] */
break;
}
set2(L, i, j);
}
lua_rawgeti(L, 1, u-1);
lua_rawgeti(L, 1, i);
set2(L, u-1, i); /* swap pivot (a[u-1]) with a[i] */
/* a[l..i-1] <= a[i] == P <= a[i+1..u] */
/* adjust so that smaller half is in [j..i] and larger one in [l..u] */
if (i-l < u-i) {
j=l; i=i-1; l=i+2;
}
else {
j=i+1; i=u; u=j-2;
}
auxsort(L, j, i); /* call recursively the smaller one */
} /* repeat the routine for the larger one */
}
static int sort (lua_State *L) {
int n = aux_getn(L, 1);
luaL_checkstack(L, 40, ""); /* assume array is smaller than 2^40 */
if (!lua_isnoneornil(L, 2)) /* is there a 2nd argument? */
luaL_checktype(L, 2, LUA_TFUNCTION);
lua_settop(L, 2); /* make sure there is two arguments */
auxsort(L, 1, n);
return 0;
}
/* }====================================================== */
static const luaL_Reg tab_funcs[] = {
{"concat", tconcat},
#if defined(LUA_COMPAT_MAXN)
{"maxn", maxn},
#endif
{"insert", tinsert},
{"pack", pack},
{"unpack", unpack},
{"remove", tremove},
{"sort", sort},
{NULL, NULL}
};
LUAMOD_API int luaopen_table (lua_State *L) {
luaL_newlib(L, tab_funcs);
#if defined(LUA_COMPAT_UNPACK)
/* _G.unpack = table.unpack */
lua_getfield(L, -1, "unpack");
lua_setglobal(L, "unpack");
#endif
return 1;
}
/*
** $Id: ltm.c,v 2.14 2011/06/02 19:31:40 roberto Exp $
** Tag methods
** See Copyright Notice in lua.h
*/
#include <string.h>
#define ltm_c
#define LUA_CORE
#include "lua.h"
#include "lobject.h"
#include "lstate.h"
#include "lstring.h"
#include "ltable.h"
#include "ltm.h"
static const char udatatypename[] = "userdata";
LUAI_DDEF const char *const luaT_typenames_[LUA_TOTALTAGS] = {
"no value",
"nil", "boolean", udatatypename, "number",
"string", "table", "function", udatatypename, "thread",
"proto", "upval" /* these last two cases are used for tests only */
};
void luaT_init (lua_State *L) {
static const char *const luaT_eventname[] = { /* ORDER TM */
"__index", "__newindex",
"__gc", "__mode", "__len", "__eq",
"__add", "__sub", "__mul", "__div", "__mod",
"__pow", "__unm", "__lt", "__le",
"__concat", "__call"
};
int i;
for (i=0; i<TM_N; i++) {
G(L)->tmname[i] = luaS_new(L, luaT_eventname[i]);
luaS_fix(G(L)->tmname[i]); /* never collect these names */
}
}
/*
** function to be used with macro "fasttm": optimized for absence of
** tag methods
*/
const TValue *luaT_gettm (Table *events, TMS event, TString *ename) {
const TValue *tm = luaH_getstr(events, ename);
lua_assert(event <= TM_EQ);
if (ttisnil(tm)) { /* no tag method? */
events->flags |= cast_byte(1u<<event); /* cache this fact */
return NULL;
}
else return tm;
}
const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) {
Table *mt;
switch (ttypenv(o)) {
case LUA_TTABLE:
mt = hvalue(o)->metatable;
break;
case LUA_TUSERDATA:
mt = uvalue(o)->metatable;
break;
default:
mt = G(L)->mt[ttypenv(o)];
}
return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject);
}
/* /*
** $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 /* } */
/* /*
** $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
*/ */
......
/* /*
** $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
/* /*
** $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.
/* /*
** $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);
......
/* /*
** $Id: lmem.h,v 1.38 2011/12/02 13:26:54 roberto Exp $ ** $Id: lmem.h,v 1.43.1.1 2017/04/19 17:20:42 roberto Exp $
** Interface to Memory Manager ** Interface to Memory Manager
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
...@@ -14,14 +14,33 @@ ...@@ -14,14 +14,33 @@
#include "lua.h" #include "lua.h"
/*
** This macro reallocs a vector 'b' from 'on' to 'n' elements, where
** each element has size 'e'. In case of arithmetic overflow of the
** product 'n'*'e', it raises an error (calling 'luaM_toobig'). Because
** 'e' is always constant, it avoids the runtime division MAX_SIZET/(e).
**
** (The macro is somewhat complex to avoid warnings: The 'sizeof'
** comparison avoids a runtime comparison when overflow cannot occur.
** The compiler should be able to optimize the real test by itself, but
** when it does it, it may give a warning about "comparison is always
** false due to limited range of data type"; the +1 tricks the compiler,
** avoiding this warning but also this optimization.)
*/
#define luaM_reallocv(L,b,on,n,e) \ #define luaM_reallocv(L,b,on,n,e) \
((cast(size_t, (n)+1) > MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ (((sizeof(n) >= sizeof(size_t) && cast(size_t, (n)) + 1 > MAX_SIZET/(e)) \
(luaM_toobig(L), (void *)0) : \ ? luaM_toobig(L) : cast_void(0)) , \
luaM_realloc_(L, (b), (on)*(e), (n)*(e))) luaM_realloc_(L, (b), (on)*(e), (n)*(e)))
/*
** Arrays of chars do not need any test
*/
#define luaM_reallocvchar(L,b,on,n) \
cast(char *, luaM_realloc_(L, (b), (on)*sizeof(char), (n)*sizeof(char)))
#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0)
#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0)
#define luaM_freearray(L, b, n) luaM_reallocv(L, (b), n, 0, sizeof((b)[0])) #define luaM_freearray(L, b, n) luaM_realloc_(L, (b), (n)*sizeof(*(b)), 0)
#define luaM_malloc(L,s) luaM_realloc_(L, NULL, 0, (s)) #define luaM_malloc(L,s) luaM_realloc_(L, NULL, 0, (s))
#define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) #define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t)))
......
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.
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.
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.
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