├── test
├── genCode
│ ├── genProto.exe
│ ├── TestProto.xml.cache
│ ├── TestProto.xml
│ └── lua
│ │ └── TestProto.lua
├── CMakeLists.txt
├── csharp
│ ├── App.config
│ ├── cshap.csproj.user
│ ├── proto4z.sln
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── cshap.csproj
├── lua53
│ ├── lua.hpp
│ ├── lapi.h
│ ├── vc
│ │ ├── lua53.vcxproj.user
│ │ └── lua53.sln
│ ├── CMakeLists.txt
│ ├── lundump.h
│ ├── lprefix.h
│ ├── lualib.h
│ ├── lstring.h
│ ├── ldebug.h
│ ├── ldo.h
│ ├── lfunc.h
│ ├── lzio.h
│ ├── ltable.h
│ ├── lzio.c
│ ├── linit.c
│ ├── ltm.h
│ ├── lvm.h
│ ├── lctype.h
│ ├── lctype.c
│ ├── llex.h
│ ├── lmem.h
│ ├── lmem.c
│ ├── lcode.h
│ ├── lparser.h
│ ├── lopcodes.c
│ ├── lfunc.c
│ ├── ltm.c
│ ├── lcorolib.c
│ ├── lgc.h
│ ├── lstring.c
│ ├── ldump.c
│ ├── lbitlib.c
│ ├── llimits.h
│ ├── lundump.c
│ ├── lutf8lib.c
│ └── lstate.h
├── cpp
│ ├── CMakeLists.txt
│ ├── cpp.vcxproj.filters
│ ├── TestWeb.h
│ └── test.cpp
├── bin
│ └── main.lua
└── test.sln
├── .gitattributes
├── genProto.tools
├── CMakeLists.txt
├── genProto.vcxproj.user
├── genProto.sln
├── src
│ ├── parseProto.h
│ ├── genLUA.h
│ ├── genBase.cpp
│ ├── genCPP.h
│ ├── genBase.h
│ ├── genCSharp.h
│ ├── parseCache.h
│ ├── main.cpp
│ ├── common.h
│ ├── genLUA.cpp
│ ├── any.h
│ └── parseCache.cpp
├── genProto.vcxproj.filters
└── depends
│ └── md5
│ ├── md5.h
│ └── md5.cpp
├── CMakeLists.txt
├── HISTORY
├── .travis.yml
├── .github
└── workflows
│ └── cmake.yml
├── COPYRIGHT
├── .gitignore
└── README.md
/test/genCode/genProto.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zsummer/proto4z/HEAD/test/genCode/genProto.exe
--------------------------------------------------------------------------------
/test/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.6)
2 | project(test)
3 | set(EXECUTABLE_OUTPUT_PATH ${PROTO4Z_BIN_OUT_PATH})
4 | add_subdirectory(cpp)
5 | add_subdirectory(lua53)
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/test/csharp/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/test/lua53/lua.hpp:
--------------------------------------------------------------------------------
1 | // lua.hpp
2 | // Lua header files for C++
3 | // <> not supplied automatically because Lua also compiles as C++
4 |
5 | extern "C" {
6 | #include "lua.h"
7 | #include "lualib.h"
8 | #include "lauxlib.h"
9 | }
10 |
--------------------------------------------------------------------------------
/test/cpp/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.6)
2 | project(cpptest)
3 |
4 | include_directories(../../)
5 | include_directories(../genCode)
6 |
7 | set(EXECUTABLE_OUTPUT_PATH ${PROTO4Z_BIN_OUT_PATH})
8 |
9 | add_executable(cpptest${LIB_SUFFIX} test.cpp)
10 | if(APPLE)
11 | target_link_libraries(cpptest${LIB_SUFFIX} pthread m)
12 | else()
13 | target_link_libraries(cpptest${LIB_SUFFIX} pthread rt m)
14 | endif()
15 |
16 |
17 |
--------------------------------------------------------------------------------
/test/csharp/cshap.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 发布\
5 |
6 |
7 |
8 |
9 |
10 | zh-CN
11 | false
12 |
13 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Standard to msysgit
13 | *.doc diff=astextplain
14 | *.DOC diff=astextplain
15 | *.docx diff=astextplain
16 | *.DOCX diff=astextplain
17 | *.dot diff=astextplain
18 | *.DOT diff=astextplain
19 | *.pdf diff=astextplain
20 | *.PDF diff=astextplain
21 | *.rtf diff=astextplain
22 | *.RTF diff=astextplain
23 |
--------------------------------------------------------------------------------
/genProto.tools/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.6)
2 | project(genProto)
3 |
4 |
5 | add_definitions(-Wall -O0 -g -ggdb -DNDEBUG -std=c++11 -D_GLIBCXX_USE_NANOSLEEP )
6 |
7 | set(EXECUTABLE_OUTPUT_PATH ${PROTO4Z_GEN_CODE_PATH})
8 |
9 | aux_source_directory(./src source)
10 | aux_source_directory(./depends depends)
11 | aux_source_directory(./depends/md5 md5)
12 |
13 | if (APPLE)
14 | add_executable(genProtoMac ${source} ${depends} ${md5})
15 | target_link_libraries(genProtoMac pthread)
16 | else()
17 | add_executable(genProto ${source} ${depends} ${md5})
18 | target_link_libraries(genProto pthread rt)
19 | endif()
20 |
--------------------------------------------------------------------------------
/test/lua53/lapi.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lapi.h,v 2.8 2014/07/15 21:26:50 roberto Exp $
3 | ** Auxiliary functions from Lua API
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lapi_h
8 | #define lapi_h
9 |
10 |
11 | #include "llimits.h"
12 | #include "lstate.h"
13 |
14 | #define api_incr_top(L) {L->top++; api_check(L->top <= L->ci->top, \
15 | "stack overflow");}
16 |
17 | #define adjustresults(L,nres) \
18 | { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; }
19 |
20 | #define api_checknelems(L,n) api_check((n) < (L->top - L->ci->func), \
21 | "not enough elements in the stack")
22 |
23 |
24 | #endif
25 |
--------------------------------------------------------------------------------
/test/lua53/vc/lua53.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(OutDir)
5 | WindowsLocalDebugger
6 |
7 |
8 | $(OutDir)
9 | WindowsLocalDebugger
10 |
11 |
--------------------------------------------------------------------------------
/test/genCode/TestProto.xml.cache:
--------------------------------------------------------------------------------
1 |
2 |
3 | 67374b8721ae6336d10bea97832a9487
4 | 32543e8255208ccc3dc73b13c6325e0c
5 | 14b631778b7f8d6fa7021c409bf548ce
6 | 3a78af7f3d015d07dbe5ae03a01a5e07
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/test/lua53/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.6)
2 | project(lua53)
3 |
4 | include_directories(../../luasrc/)
5 | include_directories(./)
6 | aux_source_directory(./ source)
7 | aux_source_directory(../../luasrc/ luasrc)
8 | set(EXECUTABLE_OUTPUT_PATH ${PROTO4Z_BIN_OUT_PATH})
9 |
10 |
11 | if (CMAKE_BUILD_TYPE STREQUAL "Debug")
12 | add_definitions(-Wall -g -ggdb -O0 -D_GLIBCXX_USE_NANOSLEEP)
13 | else()
14 | add_definitions(-Wall -O2 -DNDEBUG -D_GLIBCXX_USE_NANOSLEEP)
15 | endif()
16 | set(CMAKE_CXX_FLAGS -std=c++11)
17 |
18 |
19 | add_executable(lua53 ${source} ${luasrc})
20 |
21 |
22 | if(APPLE)
23 | target_link_libraries(lua53 pthread m)
24 | else()
25 | target_link_libraries(lua53 pthread rt m)
26 | endif()
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.6)
2 | project(proto4z)
3 |
4 | set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "")
5 |
6 | set(LIB_SUFFIX "")
7 |
8 | if (CMAKE_BUILD_TYPE STREQUAL "Debug")
9 | add_definitions(-Wall -g -ggdb -O0 )
10 | set(LIB_SUFFIX "_d")
11 | else()
12 | add_definitions(-Wall -O2 -DNDEBUG )
13 | endif()
14 | set(CMAKE_CXX_FLAGS -std=c++11)
15 |
16 |
17 |
18 | SET(PROTO4Z_GEN_CODE_PATH ${proto4z_SOURCE_DIR}/test/genCode)
19 | SET(PROTO4Z_BIN_OUT_PATH ${proto4z_SOURCE_DIR}/test/bin)
20 |
21 | add_subdirectory(genProto.tools)
22 | add_subdirectory(test)
23 |
24 | install(FILES
25 | ${proto4z_SOURCE_DIR}/proto4z.h
26 | ${proto4z_SOURCE_DIR}/dbHelper.h
27 | ${proto4z_SOURCE_DIR}/Proto4z.cs
28 | ${proto4z_SOURCE_DIR}/proto4z.lua
29 | ${proto4z_SOURCE_DIR}/README.md
30 | ${proto4z_SOURCE_DIR}/COPYRIGHT
31 | DESTINATION include/proto4z)
32 |
33 |
--------------------------------------------------------------------------------
/genProto.tools/genProto.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(OutDir)
5 | WindowsLocalDebugger
6 |
7 |
8 | $(OutDir)
9 | WindowsLocalDebugger
10 |
11 |
12 | ..\test\genCode
13 | WindowsLocalDebugger
14 |
15 |
--------------------------------------------------------------------------------
/HISTORY:
--------------------------------------------------------------------------------
1 | HISTORY for proto4z
2 |
3 | /*
4 | * UPDATES LOG
5 | *
6 | * VERSION 0.1.0
7 | * create the first project.
8 | * support big-endian or little-endian
9 | *
10 | * VERSION 0.3.0
11 | * support user-defined header
12 | * WriteStream support auto alloc memory or attach exist memory
13 | * proto4z support stl container
14 | *
15 | * VERSION 0.4.0
16 | * Add some useful interface method
17 | *
18 | * VERSION 0.5.0
19 | * Add static buff for optimize
20 | * Add genProto tools
21 | *
22 | * VERSION 1.0.0
23 | * Add HTTP protocol
24 | *
25 | * VERSION 1.1.0
26 | * support HTTP chunked header
27 | * support HTTP decode and encode method
28 | *
29 | * VERSION 1.2.0
30 | * new naming notations
31 | * simplify traits
32 | *
33 | *
34 | */
35 |
36 | (end of HISTORY)
37 |
--------------------------------------------------------------------------------
/test/cpp/cpp.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | 源文件
16 |
17 |
18 |
19 |
20 | 头文件
21 |
22 |
23 | 源文件
24 |
25 |
26 |
--------------------------------------------------------------------------------
/test/lua53/lundump.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lundump.h,v 1.44 2014/06/19 18:27:20 roberto Exp $
3 | ** load precompiled Lua chunks
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lundump_h
8 | #define lundump_h
9 |
10 | #include "llimits.h"
11 | #include "lobject.h"
12 | #include "lzio.h"
13 |
14 |
15 | /* data to catch conversion errors */
16 | #define LUAC_DATA "\x19\x93\r\n\x1a\n"
17 |
18 | #define LUAC_INT 0x5678
19 | #define LUAC_NUM cast_num(370.5)
20 |
21 | #define MYINT(s) (s[0]-'0')
22 | #define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR))
23 | #define LUAC_FORMAT 0 /* this is the official format */
24 |
25 | /* load one chunk; from lundump.c */
26 | LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff,
27 | const char* name);
28 |
29 | /* dump one chunk; from ldump.c */
30 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w,
31 | void* data, int strip);
32 |
33 | #endif
34 |
--------------------------------------------------------------------------------
/test/csharp/proto4z.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.21005.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "proto4z", "proto4z.csproj", "{D5BDE960-7180-4BB0-BB58-3C4AB6ADA7D0}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {D5BDE960-7180-4BB0-BB58-3C4AB6ADA7D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {D5BDE960-7180-4BB0-BB58-3C4AB6ADA7D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {D5BDE960-7180-4BB0-BB58-3C4AB6ADA7D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {D5BDE960-7180-4BB0-BB58-3C4AB6ADA7D0}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/test/lua53/lprefix.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lprefix.h,v 1.2 2014/12/29 16:54:13 roberto Exp $
3 | ** Definitions for Lua code that must come before any other header file
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lprefix_h
8 | #define lprefix_h
9 |
10 |
11 | /*
12 | ** Allows POSIX/XSI stuff
13 | */
14 | #if !defined(LUA_USE_C89) /* { */
15 |
16 | #if !defined(_XOPEN_SOURCE)
17 | #define _XOPEN_SOURCE 600
18 | #elif _XOPEN_SOURCE == 0
19 | #undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */
20 | #endif
21 |
22 | /*
23 | ** Allows manipulation of large files in gcc and some other compilers
24 | */
25 | #if !defined(LUA_32BITS) && !defined(_FILE_OFFSET_BITS)
26 | #define _LARGEFILE_SOURCE 1
27 | #define _FILE_OFFSET_BITS 64
28 | #endif
29 |
30 | #endif /* } */
31 |
32 |
33 | /*
34 | ** Windows stuff
35 | */
36 | #if defined(_WIN32) /* { */
37 |
38 | #if !defined(_CRT_SECURE_NO_WARNINGS)
39 | #define _CRT_SECURE_NO_WARNINGS /* avoid warnings about ISO C functions */
40 | #endif
41 |
42 | #endif /* } */
43 |
44 | #endif
45 |
46 |
--------------------------------------------------------------------------------
/test/csharp/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的常规信息通过以下
6 | // 特性集控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("ConsoleApplication2")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ConsoleApplication2")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 使此程序集中的类型
18 | // 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | // 则将该类型上的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("406c5ef7-62e9-445b-8815-451229a7eb25")]
24 |
25 | // 程序集的版本信息由下面四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/test/lua53/vc/lua53.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.21005.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lua53", "lua53.vcxproj", "{0459E5F7-73C8-4665-9E5C-355E5ADA243D}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Win32 = Debug|Win32
11 | Debug|x64 = Debug|x64
12 | Release|Win32 = Release|Win32
13 | Release|x64 = Release|x64
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {0459E5F7-73C8-4665-9E5C-355E5ADA243D}.Debug|Win32.ActiveCfg = Debug|Win32
17 | {0459E5F7-73C8-4665-9E5C-355E5ADA243D}.Debug|Win32.Build.0 = Debug|Win32
18 | {0459E5F7-73C8-4665-9E5C-355E5ADA243D}.Debug|x64.ActiveCfg = Debug|x64
19 | {0459E5F7-73C8-4665-9E5C-355E5ADA243D}.Debug|x64.Build.0 = Debug|x64
20 | {0459E5F7-73C8-4665-9E5C-355E5ADA243D}.Release|Win32.ActiveCfg = Release|Win32
21 | {0459E5F7-73C8-4665-9E5C-355E5ADA243D}.Release|Win32.Build.0 = Release|Win32
22 | {0459E5F7-73C8-4665-9E5C-355E5ADA243D}.Release|x64.ActiveCfg = Release|x64
23 | {0459E5F7-73C8-4665-9E5C-355E5ADA243D}.Release|x64.Build.0 = Release|x64
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/genProto.tools/genProto.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.21005.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "genProto", "genProto.vcxproj", "{AD368D24-8C2B-4848-822F-0827E725CAD7}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Win32 = Debug|Win32
11 | Debug|x64 = Debug|x64
12 | Release|Win32 = Release|Win32
13 | Release|x64 = Release|x64
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {AD368D24-8C2B-4848-822F-0827E725CAD7}.Debug|Win32.ActiveCfg = Debug|Win32
17 | {AD368D24-8C2B-4848-822F-0827E725CAD7}.Debug|Win32.Build.0 = Debug|Win32
18 | {AD368D24-8C2B-4848-822F-0827E725CAD7}.Debug|x64.ActiveCfg = Debug|x64
19 | {AD368D24-8C2B-4848-822F-0827E725CAD7}.Debug|x64.Build.0 = Debug|x64
20 | {AD368D24-8C2B-4848-822F-0827E725CAD7}.Release|Win32.ActiveCfg = Release|Win32
21 | {AD368D24-8C2B-4848-822F-0827E725CAD7}.Release|Win32.Build.0 = Release|Win32
22 | {AD368D24-8C2B-4848-822F-0827E725CAD7}.Release|x64.ActiveCfg = Release|x64
23 | {AD368D24-8C2B-4848-822F-0827E725CAD7}.Release|x64.Build.0 = Release|x64
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: true
2 | language: cpp
3 | matrix:
4 | include:
5 |
6 | # linux version have unique dependencies, so we set them up individually
7 | - os: linux
8 | dist: trusty
9 | compiler: clang
10 | addons:
11 | apt:
12 | sources:
13 | - ubuntu-toolchain-r-test
14 | packages:
15 | - g++-4.9
16 | sudo: required
17 | env:
18 | - TARGET="trusty"
19 |
20 | # OS X Xcode
21 | - os: osx
22 | osx_image: xcode8.3
23 | env:
24 | - TOOL="xcode-osx"
25 |
26 |
27 |
28 |
29 | before_install:
30 | - if [ "${TRAVIS_OS_NAME}" = "linux" ]; then sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test; fi
31 | - if [ "${TRAVIS_OS_NAME}" = "linux" ]; then sudo apt-get update -qq; fi
32 |
33 | install:
34 | - if [ "${TRAVIS_OS_NAME}" = "linux" ]; then sudo apt-get install -qq cmake; fi
35 | - if [ "${TRAVIS_OS_NAME}" = "linux" ]; then sudo apt-get install -qq g++-4.9; fi
36 | - if [ "${TRAVIS_OS_NAME}" = "linux" ]; then export CXX="g++-4.9"; fi
37 | script:
38 | - cmake --version
39 | - cmake .
40 | - make
41 | - ls test/bin/*
42 | - ls test/genCode/*
43 | - cd test/genCode
44 | - if [ "${TRAVIS_OS_NAME}" = "linux" ]; then ./genProto; fi
45 | - if [ "${TRAVIS_OS_NAME}" = "osx" ]; then ./genProtoMac; fi
46 | - cd ../../
47 | - cd test/bin
48 | - ./cpptest
49 | - ./lua53
50 |
--------------------------------------------------------------------------------
/test/lua53/lualib.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lualib.h,v 1.44 2014/02/06 17:32:33 roberto Exp $
3 | ** Lua standard libraries
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 |
8 | #ifndef lualib_h
9 | #define lualib_h
10 |
11 | #include "lua.h"
12 |
13 |
14 |
15 | LUAMOD_API int (luaopen_base) (lua_State *L);
16 |
17 | #define LUA_COLIBNAME "coroutine"
18 | LUAMOD_API int (luaopen_coroutine) (lua_State *L);
19 |
20 | #define LUA_TABLIBNAME "table"
21 | LUAMOD_API int (luaopen_table) (lua_State *L);
22 |
23 | #define LUA_IOLIBNAME "io"
24 | LUAMOD_API int (luaopen_io) (lua_State *L);
25 |
26 | #define LUA_OSLIBNAME "os"
27 | LUAMOD_API int (luaopen_os) (lua_State *L);
28 |
29 | #define LUA_STRLIBNAME "string"
30 | LUAMOD_API int (luaopen_string) (lua_State *L);
31 |
32 | #define LUA_UTF8LIBNAME "utf8"
33 | LUAMOD_API int (luaopen_utf8) (lua_State *L);
34 |
35 | #define LUA_BITLIBNAME "bit32"
36 | LUAMOD_API int (luaopen_bit32) (lua_State *L);
37 |
38 | #define LUA_MATHLIBNAME "math"
39 | LUAMOD_API int (luaopen_math) (lua_State *L);
40 |
41 | #define LUA_DBLIBNAME "debug"
42 | LUAMOD_API int (luaopen_debug) (lua_State *L);
43 |
44 | #define LUA_LOADLIBNAME "package"
45 | LUAMOD_API int (luaopen_package) (lua_State *L);
46 |
47 |
48 | /* open all previous libraries */
49 | LUALIB_API void (luaL_openlibs) (lua_State *L);
50 |
51 |
52 |
53 | #if !defined(lua_assert)
54 | #define lua_assert(x) ((void)0)
55 | #endif
56 |
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/.github/workflows/cmake.yml:
--------------------------------------------------------------------------------
1 | name: CITest
2 |
3 | on:
4 | # push:
5 | # branches: [ master ]
6 | pull_request:
7 | branches: [ master ]
8 |
9 | env:
10 | # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
11 | BUILD_TYPE: Release
12 |
13 | jobs:
14 | build:
15 | strategy:
16 | matrix:
17 | cc: [gcc, clang]
18 | os: [ubuntu-latest, macos-latest]
19 | #exclude:
20 | # - os: macos-latest
21 | # cc: clang
22 |
23 | runs-on: ${{ matrix.os }}
24 |
25 | steps:
26 | - uses: actions/checkout@v2
27 | env:
28 | CC: ${{ matrix.cc }}
29 | - name: config cmake
30 | run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
31 |
32 | - name: build
33 | # Build your program with the given configuration
34 | run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
35 |
36 | - name: test base
37 | working-directory: ${{github.workspace}}/test/bin
38 | run: |
39 | ./cpptest
40 | ./lua53
41 |
42 | - name: test genProto
43 | if: runner.os == 'Linux'
44 | working-directory: ${{github.workspace}}/test/genCode
45 | run: |
46 | ./genProto
47 |
48 | - name: test genProtoMac
49 | if: runner.os == 'macOS'
50 | working-directory: ${{github.workspace}}/test/genCode
51 | run: |
52 | ./genProtoMac
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/test/lua53/lstring.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lstring.h,v 1.56 2014/07/18 14:46:47 roberto Exp $
3 | ** String table (keep all strings handled by Lua)
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lstring_h
8 | #define lstring_h
9 |
10 | #include "lgc.h"
11 | #include "lobject.h"
12 | #include "lstate.h"
13 |
14 |
15 | #define sizelstring(l) (sizeof(union UTString) + ((l) + 1) * sizeof(char))
16 | #define sizestring(s) sizelstring((s)->len)
17 |
18 | #define sizeludata(l) (sizeof(union UUdata) + (l))
19 | #define sizeudata(u) sizeludata((u)->len)
20 |
21 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \
22 | (sizeof(s)/sizeof(char))-1))
23 |
24 |
25 | /*
26 | ** test whether a string is a reserved word
27 | */
28 | #define isreserved(s) ((s)->tt == LUA_TSHRSTR && (s)->extra > 0)
29 |
30 |
31 | /*
32 | ** equality for short strings, which are always internalized
33 | */
34 | #define eqshrstr(a,b) check_exp((a)->tt == LUA_TSHRSTR, (a) == (b))
35 |
36 |
37 | LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed);
38 | LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b);
39 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize);
40 | LUAI_FUNC void luaS_remove (lua_State *L, TString *ts);
41 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s);
42 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
43 | LUAI_FUNC TString *luaS_new (lua_State *L, const char *str);
44 |
45 |
46 | #endif
47 |
--------------------------------------------------------------------------------
/test/lua53/ldebug.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: ldebug.h,v 2.12 2014/11/10 14:46:05 roberto Exp $
3 | ** Auxiliary functions from Debug Interface module
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef ldebug_h
8 | #define ldebug_h
9 |
10 |
11 | #include "lstate.h"
12 |
13 |
14 | #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1)
15 |
16 | #define getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : -1)
17 |
18 | #define resethookcount(L) (L->hookcount = L->basehookcount)
19 |
20 | /* Active Lua function (given call info) */
21 | #define ci_func(ci) (clLvalue((ci)->func))
22 |
23 |
24 | LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o,
25 | const char *opname);
26 | LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1,
27 | const TValue *p2);
28 | LUAI_FUNC l_noret luaG_opinterror (lua_State *L, const TValue *p1,
29 | const TValue *p2,
30 | const char *msg);
31 | LUAI_FUNC l_noret luaG_tointerror (lua_State *L, const TValue *p1,
32 | const TValue *p2);
33 | LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1,
34 | const TValue *p2);
35 | LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...);
36 | LUAI_FUNC l_noret luaG_errormsg (lua_State *L);
37 | LUAI_FUNC void luaG_traceexec (lua_State *L);
38 |
39 |
40 | #endif
41 |
--------------------------------------------------------------------------------
/COPYRIGHT:
--------------------------------------------------------------------------------
1 | proto4z License
2 | -----------
3 |
4 | proto4z is licensed under the terms of the MIT license reproduced below.
5 | This means that proto4z is free software and can be used for both academic
6 | and commercial purposes at absolutely no cost.
7 |
8 |
9 | ===============================================================================
10 |
11 | Copyright (C) 2013-2015 YaweiZhang .
12 |
13 | Permission is hereby granted, free of charge, to any person obtaining a copy
14 | of this software and associated documentation files (the "Software"), to deal
15 | in the Software without restriction, including without limitation the rights
16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 | copies of the Software, and to permit persons to whom the Software is
18 | furnished to do so, subject to the following conditions:
19 |
20 | The above copyright notice and this permission notice shall be included in
21 | all copies or substantial portions of the Software.
22 |
23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 | THE SOFTWARE.
30 |
31 | ===============================================================================
32 |
33 | (end of COPYRIGHT)
34 |
35 |
--------------------------------------------------------------------------------
/test/lua53/ldo.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: ldo.h,v 2.21 2014/10/25 11:50:46 roberto Exp $
3 | ** Stack and Call structure of Lua
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef ldo_h
8 | #define ldo_h
9 |
10 |
11 | #include "lobject.h"
12 | #include "lstate.h"
13 | #include "lzio.h"
14 |
15 |
16 | #define luaD_checkstack(L,n) if (L->stack_last - L->top <= (n)) \
17 | luaD_growstack(L, n); else condmovestack(L);
18 |
19 |
20 | #define incr_top(L) {L->top++; luaD_checkstack(L,0);}
21 |
22 | #define savestack(L,p) ((char *)(p) - (char *)L->stack)
23 | #define restorestack(L,n) ((TValue *)((char *)L->stack + (n)))
24 |
25 |
26 | /* type of protected functions, to be ran by 'runprotected' */
27 | typedef void (*Pfunc) (lua_State *L, void *ud);
28 |
29 | LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name,
30 | const char *mode);
31 | LUAI_FUNC void luaD_hook (lua_State *L, int event, int line);
32 | LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults);
33 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults,
34 | int allowyield);
35 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u,
36 | ptrdiff_t oldtop, ptrdiff_t ef);
37 | LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult);
38 | LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
39 | LUAI_FUNC void luaD_growstack (lua_State *L, int n);
40 | LUAI_FUNC void luaD_shrinkstack (lua_State *L);
41 |
42 | LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode);
43 | LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
44 |
45 | #endif
46 |
47 |
--------------------------------------------------------------------------------
/test/lua53/lfunc.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lfunc.h,v 2.14 2014/06/19 18:27:20 roberto Exp $
3 | ** Auxiliary functions to manipulate prototypes and closures
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lfunc_h
8 | #define lfunc_h
9 |
10 |
11 | #include "lobject.h"
12 |
13 |
14 | #define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \
15 | cast(int, sizeof(TValue)*((n)-1)))
16 |
17 | #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \
18 | cast(int, sizeof(TValue *)*((n)-1)))
19 |
20 |
21 | /* test whether thread is in 'twups' list */
22 | #define isintwups(L) (L->twups != L)
23 |
24 |
25 | /*
26 | ** Upvalues for Lua closures
27 | */
28 | struct UpVal {
29 | TValue *v; /* points to stack or to its own value */
30 | lu_mem refcount; /* reference counter */
31 | union {
32 | struct { /* (when open) */
33 | UpVal *next; /* linked list */
34 | int touched; /* mark to avoid cycles with dead threads */
35 | } open;
36 | TValue value; /* the value (when closed) */
37 | } u;
38 | };
39 |
40 | #define upisopen(up) ((up)->v != &(up)->u.value)
41 |
42 |
43 | LUAI_FUNC Proto *luaF_newproto (lua_State *L);
44 | LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nelems);
45 | LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nelems);
46 | LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl);
47 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level);
48 | LUAI_FUNC void luaF_close (lua_State *L, StkId level);
49 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f);
50 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number,
51 | int pc);
52 |
53 |
54 | #endif
55 |
--------------------------------------------------------------------------------
/test/lua53/lzio.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lzio.h,v 1.30 2014/12/19 17:26:14 roberto Exp $
3 | ** Buffered streams
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 |
8 | #ifndef lzio_h
9 | #define lzio_h
10 |
11 | #include "lua.h"
12 |
13 | #include "lmem.h"
14 |
15 |
16 | #define EOZ (-1) /* end of stream */
17 |
18 | typedef struct Zio ZIO;
19 |
20 | #define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z))
21 |
22 |
23 | typedef struct Mbuffer {
24 | char *buffer;
25 | size_t n;
26 | size_t buffsize;
27 | } Mbuffer;
28 |
29 | #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0)
30 |
31 | #define luaZ_buffer(buff) ((buff)->buffer)
32 | #define luaZ_sizebuffer(buff) ((buff)->buffsize)
33 | #define luaZ_bufflen(buff) ((buff)->n)
34 |
35 | #define luaZ_buffremove(buff,i) ((buff)->n -= (i))
36 | #define luaZ_resetbuffer(buff) ((buff)->n = 0)
37 |
38 |
39 | #define luaZ_resizebuffer(L, buff, size) \
40 | ((buff)->buffer = luaM_reallocvchar(L, (buff)->buffer, \
41 | (buff)->buffsize, size), \
42 | (buff)->buffsize = size)
43 |
44 | #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0)
45 |
46 |
47 | LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n);
48 | LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader,
49 | void *data);
50 | LUAI_FUNC size_t luaZ_read (ZIO* z, void *b, size_t n); /* read next n bytes */
51 |
52 |
53 |
54 | /* --------- Private Part ------------------ */
55 |
56 | struct Zio {
57 | size_t n; /* bytes still unread */
58 | const char *p; /* current position in buffer */
59 | lua_Reader reader; /* reader function */
60 | void *data; /* additional data */
61 | lua_State *L; /* Lua state (for reader) */
62 | };
63 |
64 |
65 | LUAI_FUNC int luaZ_fill (ZIO *z);
66 |
67 | #endif
68 |
--------------------------------------------------------------------------------
/test/lua53/ltable.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: ltable.h,v 2.20 2014/09/04 18:15:29 roberto Exp $
3 | ** Lua tables (hash)
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef ltable_h
8 | #define ltable_h
9 |
10 | #include "lobject.h"
11 |
12 |
13 | #define gnode(t,i) (&(t)->node[i])
14 | #define gval(n) (&(n)->i_val)
15 | #define gnext(n) ((n)->i_key.nk.next)
16 |
17 |
18 | /* 'const' to avoid wrong writings that can mess up field 'next' */
19 | #define gkey(n) cast(const TValue*, (&(n)->i_key.tvk))
20 |
21 | #define wgkey(n) (&(n)->i_key.nk)
22 |
23 | #define invalidateTMcache(t) ((t)->flags = 0)
24 |
25 |
26 | /* returns the key, given the value of a table entry */
27 | #define keyfromval(v) \
28 | (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val))))
29 |
30 |
31 | LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key);
32 | LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key,
33 | TValue *value);
34 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key);
35 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key);
36 | LUAI_FUNC TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key);
37 | LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key);
38 | LUAI_FUNC Table *luaH_new (lua_State *L);
39 | LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize,
40 | unsigned int nhsize);
41 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize);
42 | LUAI_FUNC void luaH_free (lua_State *L, Table *t);
43 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key);
44 | LUAI_FUNC int luaH_getn (Table *t);
45 |
46 |
47 | #if defined(LUA_DEBUG)
48 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key);
49 | LUAI_FUNC int luaH_isdummy (Node *n);
50 | #endif
51 |
52 |
53 | #endif
54 |
--------------------------------------------------------------------------------
/test/lua53/lzio.c:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lzio.c,v 1.36 2014/11/02 19:19:04 roberto Exp $
3 | ** Buffered streams
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #define lzio_c
8 | #define LUA_CORE
9 |
10 | #include "lprefix.h"
11 |
12 |
13 | #include
14 |
15 | #include "lua.h"
16 |
17 | #include "llimits.h"
18 | #include "lmem.h"
19 | #include "lstate.h"
20 | #include "lzio.h"
21 |
22 |
23 | int luaZ_fill (ZIO *z) {
24 | size_t size;
25 | lua_State *L = z->L;
26 | const char *buff;
27 | lua_unlock(L);
28 | buff = z->reader(L, z->data, &size);
29 | lua_lock(L);
30 | if (buff == NULL || size == 0)
31 | return EOZ;
32 | z->n = size - 1; /* discount char being returned */
33 | z->p = buff;
34 | return cast_uchar(*(z->p++));
35 | }
36 |
37 |
38 | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) {
39 | z->L = L;
40 | z->reader = reader;
41 | z->data = data;
42 | z->n = 0;
43 | z->p = NULL;
44 | }
45 |
46 |
47 | /* --------------------------------------------------------------- read --- */
48 | size_t luaZ_read (ZIO *z, void *b, size_t n) {
49 | while (n) {
50 | size_t m;
51 | if (z->n == 0) { /* no bytes in buffer? */
52 | if (luaZ_fill(z) == EOZ) /* try to read more */
53 | return n; /* no more input; return number of missing bytes */
54 | else {
55 | z->n++; /* luaZ_fill consumed first byte; put it back */
56 | z->p--;
57 | }
58 | }
59 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */
60 | memcpy(b, z->p, m);
61 | z->n -= m;
62 | z->p += m;
63 | b = (char *)b + m;
64 | n -= m;
65 | }
66 | return 0;
67 | }
68 |
69 | /* ------------------------------------------------------------------------ */
70 | char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) {
71 | if (n > buff->buffsize) {
72 | if (n < LUA_MINBUFFER) n = LUA_MINBUFFER;
73 | luaZ_resizebuffer(L, buff, n);
74 | }
75 | return buff->buffer;
76 | }
77 |
78 |
79 |
--------------------------------------------------------------------------------
/test/lua53/linit.c:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: linit.c,v 1.38 2015/01/05 13:48:33 roberto Exp $
3 | ** Initialization of libraries for lua.c and other clients
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 |
8 | #define linit_c
9 | #define LUA_LIB
10 |
11 | /*
12 | ** If you embed Lua in your program and need to open the standard
13 | ** libraries, call luaL_openlibs in your program. If you need a
14 | ** different set of libraries, copy this file to your project and edit
15 | ** it to suit your needs.
16 | **
17 | ** You can also *preload* libraries, so that a later 'require' can
18 | ** open the library, which is already linked to the application.
19 | ** For that, do the following code:
20 | **
21 | ** luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD");
22 | ** lua_pushcfunction(L, luaopen_modname);
23 | ** lua_setfield(L, -2, modname);
24 | ** lua_pop(L, 1); // remove _PRELOAD table
25 | */
26 |
27 | #include "lprefix.h"
28 |
29 |
30 | #include
31 |
32 | #include "lua.h"
33 |
34 | #include "lualib.h"
35 | #include "lauxlib.h"
36 |
37 |
38 | /*
39 | ** these libs are loaded by lua.c and are readily available to any Lua
40 | ** program
41 | */
42 | static const luaL_Reg loadedlibs[] = {
43 | {"_G", luaopen_base},
44 | {LUA_LOADLIBNAME, luaopen_package},
45 | {LUA_COLIBNAME, luaopen_coroutine},
46 | {LUA_TABLIBNAME, luaopen_table},
47 | {LUA_IOLIBNAME, luaopen_io},
48 | {LUA_OSLIBNAME, luaopen_os},
49 | {LUA_STRLIBNAME, luaopen_string},
50 | {LUA_MATHLIBNAME, luaopen_math},
51 | {LUA_UTF8LIBNAME, luaopen_utf8},
52 | {LUA_DBLIBNAME, luaopen_debug},
53 | #if defined(LUA_COMPAT_BITLIB)
54 | {LUA_BITLIBNAME, luaopen_bit32},
55 | #endif
56 | {NULL, NULL}
57 | };
58 |
59 |
60 | LUALIB_API void luaL_openlibs (lua_State *L) {
61 | const luaL_Reg *lib;
62 | /* "require" functions from 'loadedlibs' and set results to global table */
63 | for (lib = loadedlibs; lib->func; lib++) {
64 | luaL_requiref(L, lib->name, lib->func, 1);
65 | lua_pop(L, 1); /* remove lib */
66 | }
67 | }
68 |
69 |
--------------------------------------------------------------------------------
/test/lua53/ltm.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: ltm.h,v 2.21 2014/10/25 11:50:46 roberto Exp $
3 | ** Tag methods
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef ltm_h
8 | #define ltm_h
9 |
10 |
11 | #include "lobject.h"
12 |
13 |
14 | /*
15 | * WARNING: if you change the order of this enumeration,
16 | * grep "ORDER TM" and "ORDER OP"
17 | */
18 | typedef enum {
19 | TM_INDEX,
20 | TM_NEWINDEX,
21 | TM_GC,
22 | TM_MODE,
23 | TM_LEN,
24 | TM_EQ, /* last tag method with fast access */
25 | TM_ADD,
26 | TM_SUB,
27 | TM_MUL,
28 | TM_MOD,
29 | TM_POW,
30 | TM_DIV,
31 | TM_IDIV,
32 | TM_BAND,
33 | TM_BOR,
34 | TM_BXOR,
35 | TM_SHL,
36 | TM_SHR,
37 | TM_UNM,
38 | TM_BNOT,
39 | TM_LT,
40 | TM_LE,
41 | TM_CONCAT,
42 | TM_CALL,
43 | TM_N /* number of elements in the enum */
44 | } TMS;
45 |
46 |
47 |
48 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \
49 | ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e]))
50 |
51 | #define fasttm(l,et,e) gfasttm(G(l), et, e)
52 |
53 | #define ttypename(x) luaT_typenames_[(x) + 1]
54 | #define objtypename(x) ttypename(ttnov(x))
55 |
56 | LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS];
57 |
58 |
59 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename);
60 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o,
61 | TMS event);
62 | LUAI_FUNC void luaT_init (lua_State *L);
63 |
64 | LUAI_FUNC void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1,
65 | const TValue *p2, TValue *p3, int hasres);
66 | LUAI_FUNC int luaT_callbinTM (lua_State *L, const TValue *p1, const TValue *p2,
67 | StkId res, TMS event);
68 | LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2,
69 | StkId res, TMS event);
70 | LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1,
71 | const TValue *p2, TMS event);
72 |
73 |
74 |
75 | #endif
76 |
--------------------------------------------------------------------------------
/test/lua53/lvm.h:
--------------------------------------------------------------------------------
1 | /*
2 | ** $Id: lvm.h,v 2.34 2014/08/01 17:24:02 roberto Exp $
3 | ** Lua virtual machine
4 | ** See Copyright Notice in lua.h
5 | */
6 |
7 | #ifndef lvm_h
8 | #define lvm_h
9 |
10 |
11 | #include "ldo.h"
12 | #include "lobject.h"
13 | #include "ltm.h"
14 |
15 |
16 | #if !defined(LUA_NOCVTN2S)
17 | #define cvt2str(o) ttisnumber(o)
18 | #else
19 | #define cvt2str(o) 0 /* no conversion from numbers to strings */
20 | #endif
21 |
22 |
23 | #if !defined(LUA_NOCVTS2N)
24 | #define cvt2num(o) ttisstring(o)
25 | #else
26 | #define cvt2num(o) 0 /* no conversion from strings to numbers */
27 | #endif
28 |
29 |
30 | #define tonumber(o,n) \
31 | (ttisfloat(o) ? (*(n) = fltvalue(o), 1) : luaV_tonumber_(o,n))
32 |
33 | #define tointeger(o,i) \
34 | (ttisinteger(o) ? (*(i) = ivalue(o), 1) : luaV_tointeger_(o,i))
35 |
36 | #define intop(op,v1,v2) l_castU2S(l_castS2U(v1) op l_castS2U(v2))
37 |
38 | #define luaV_rawequalobj(t1,t2) luaV_equalobj(NULL,t1,t2)
39 |
40 |
41 | LUAI_FUNC int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2);
42 | LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r);
43 | LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r);
44 | LUAI_FUNC int luaV_tonumber_ (const TValue *obj, lua_Number *n);
45 | LUAI_FUNC int luaV_tointeger_ (const TValue *obj, lua_Integer *p);
46 | LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key,
47 | StkId val);
48 | LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key,
49 | StkId val);
50 | LUAI_FUNC void luaV_finishOp (lua_State *L);
51 | LUAI_FUNC void luaV_execute (lua_State *L);
52 | LUAI_FUNC void luaV_concat (lua_State *L, int total);
53 | LUAI_FUNC lua_Integer luaV_div (lua_State *L, lua_Integer x, lua_Integer y);
54 | LUAI_FUNC lua_Integer luaV_mod (lua_State *L, lua_Integer x, lua_Integer y);
55 | LUAI_FUNC lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y);
56 | LUAI_FUNC void luaV_objlen (lua_State *L, StkId ra, const TValue *rb);
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/test/cpp/TestWeb.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #ifndef _TEST_HTTP_H_
3 | #define _TEST_HTTP_H_
4 | #include
5 | #include
6 | #include