├── .gitattributes ├── .github └── workflows │ ├── linux.yml │ ├── mac.yml │ └── win.yml ├── .gitignore ├── .gitmodules ├── .vscode └── launch.json ├── CMakeLists.txt ├── LICENSE ├── README.md ├── bin └── script │ ├── common │ ├── clone.lua │ ├── math.lua │ └── test.lua │ ├── task │ ├── task.lua │ ├── timer.lua │ └── unit.lua │ └── type │ └── type.lua ├── build.bat ├── build.sh ├── build_mingw.bat ├── cmake ├── LuaModule.cmake ├── ModuleCompileOptions.cmake ├── ModuleImport.cmake └── cmake_uninstall.cmake.in ├── config └── lua_dkm_debug.json ├── doc ├── index.html ├── tolua++.html └── toluapp.gif ├── include ├── dmconsole.h ├── dmlua.h ├── dmlua_engine.h ├── dmlua_luaresult.h ├── dmlua_typeid.h ├── dmos.h ├── dmparser.h ├── dmrapidpool.h ├── dmsingleton.h ├── dmsnowflake.h ├── dmthread.h ├── dmtypes.h ├── dmutil.h └── sol │ ├── config.hpp │ ├── forward.hpp │ └── sol.hpp ├── samples └── dmluademo │ ├── common │ ├── enum.h │ ├── macros.h │ ├── struct.h │ └── types.h │ ├── gtest │ ├── gtest-all.cc │ ├── gtest.h │ └── gtest_main.cc │ ├── main.cpp │ ├── role │ ├── role.cpp │ ├── role.h │ ├── rolemgr.cpp │ └── rolemgr.h │ └── script │ ├── buildtolua.bat │ ├── buildtolua.sh │ ├── interface.cpp │ ├── interface.h │ ├── interface.pkg │ ├── libtolua.dll │ ├── lua54.dll │ ├── luaresult.pkg │ └── toluapp.exe ├── src ├── libtolua │ ├── SCsub │ ├── libtolua_module.def │ ├── tolua++.h │ ├── tolua_event.c │ ├── tolua_event.h │ ├── tolua_is.c │ ├── tolua_map.c │ ├── tolua_push.c │ └── tolua_to.c ├── lua51 │ ├── lapi.c │ ├── lapi.h │ ├── lauxlib.c │ ├── lauxlib.h │ ├── lbaselib.c │ ├── lcode.c │ ├── lcode.h │ ├── ldblib.c │ ├── ldebug.c │ ├── ldebug.h │ ├── ldo.c │ ├── ldo.h │ ├── ldump.c │ ├── lfunc.c │ ├── lfunc.h │ ├── lgc.c │ ├── lgc.h │ ├── linit.c │ ├── liolib.c │ ├── llex.c │ ├── llex.h │ ├── llimits.h │ ├── lmathlib.c │ ├── lmem.c │ ├── lmem.h │ ├── loadlib.c │ ├── lobject.c │ ├── lobject.h │ ├── lopcodes.c │ ├── lopcodes.h │ ├── loslib.c │ ├── lparser.c │ ├── lparser.h │ ├── lstate.c │ ├── lstate.h │ ├── lstring.c │ ├── lstring.h │ ├── lstrlib.c │ ├── ltable.c │ ├── ltable.h │ ├── ltablib.c │ ├── ltm.c │ ├── ltm.h │ ├── lua.c │ ├── lua.h │ ├── lua.hpp │ ├── luac.c │ ├── luaconf.h │ ├── lualib.h │ ├── lundump.c │ ├── lundump.h │ ├── lvm.c │ ├── lvm.h │ ├── lzio.c │ ├── lzio.h │ └── print.c ├── lua53 │ ├── lapi.c │ ├── lapi.h │ ├── lauxlib.c │ ├── lauxlib.h │ ├── lbaselib.c │ ├── lbitlib.c │ ├── lcode.c │ ├── lcode.h │ ├── lcorolib.c │ ├── lctype.c │ ├── lctype.h │ ├── ldblib.c │ ├── ldebug.c │ ├── ldebug.h │ ├── ldo.c │ ├── ldo.h │ ├── ldump.c │ ├── lfunc.c │ ├── lfunc.h │ ├── lgc.c │ ├── lgc.h │ ├── linit.c │ ├── liolib.c │ ├── llex.c │ ├── llex.h │ ├── llimits.h │ ├── lmathlib.c │ ├── lmem.c │ ├── lmem.h │ ├── loadlib.c │ ├── lobject.c │ ├── lobject.h │ ├── lopcodes.c │ ├── lopcodes.h │ ├── loslib.c │ ├── lparser.c │ ├── lparser.h │ ├── lprefix.h │ ├── lstate.c │ ├── lstate.h │ ├── lstring.c │ ├── lstring.h │ ├── lstrlib.c │ ├── ltable.c │ ├── ltable.h │ ├── ltablib.c │ ├── ltm.c │ ├── ltm.h │ ├── lua.c │ ├── lua.h │ ├── lua.hpp │ ├── luac.c │ ├── luaconf.h │ ├── lualib.h │ ├── lundump.c │ ├── lundump.h │ ├── lutf8lib.c │ ├── lvm.c │ ├── lvm.h │ ├── lzio.c │ ├── lzio.h │ └── wmain.c └── lua54 │ ├── lapi.c │ ├── lapi.h │ ├── lauxlib.c │ ├── lauxlib.h │ ├── lbaselib.c │ ├── lcode.c │ ├── lcode.h │ ├── lcorolib.c │ ├── lctype.c │ ├── lctype.h │ ├── ldblib.c │ ├── ldebug.c │ ├── ldebug.h │ ├── ldo.c │ ├── ldo.h │ ├── ldump.c │ ├── lfunc.c │ ├── lfunc.h │ ├── lgc.c │ ├── lgc.h │ ├── linit.c │ ├── liolib.c │ ├── ljumptab.h │ ├── llex.c │ ├── llex.h │ ├── llimits.h │ ├── lmathlib.c │ ├── lmem.c │ ├── lmem.h │ ├── loadlib.c │ ├── lobject.c │ ├── lobject.h │ ├── lopcodes.c │ ├── lopcodes.h │ ├── lopnames.h │ ├── loslib.c │ ├── lparser.c │ ├── lparser.h │ ├── lprefix.h │ ├── lstate.c │ ├── lstate.h │ ├── lstring.c │ ├── lstring.h │ ├── lstrlib.c │ ├── ltable.c │ ├── ltable.h │ ├── ltablib.c │ ├── ltm.c │ ├── ltm.h │ ├── lua.c │ ├── lua.h │ ├── lua.hpp │ ├── lua_module.c │ ├── lua_module.h │ ├── luac.c │ ├── luaconf.h │ ├── lualib.h │ ├── lundump.c │ ├── lundump.h │ ├── lutf8lib.c │ ├── lvm.c │ ├── lvm.h │ ├── lzio.c │ └── lzio.h └── tool ├── luacheck └── main.cpp └── toluapp ├── SCsub ├── lua ├── all.h ├── all.lua ├── array.h ├── array.lua ├── basic.h ├── basic.lua ├── bin2array ├── bin2array.exe ├── buildlua.bat ├── class.h ├── class.lua ├── clean.h ├── clean.lua ├── code.h ├── code.lua ├── compat.h ├── compat.lua ├── compat51.h ├── compat51.lua ├── container.h ├── container.lua ├── custom.h ├── custom.lua ├── declaration.h ├── declaration.lua ├── define.h ├── define.lua ├── doit.h ├── doit.lua ├── enumerate.h ├── enumerate.lua ├── feature.h ├── feature.lua ├── function.h ├── function.lua ├── module.h ├── module.lua ├── namespace.h ├── namespace.lua ├── operator.h ├── operator.lua ├── package.h ├── package.lua ├── template_class.h ├── template_class.lua ├── typedef.h ├── typedef.lua ├── variable.h ├── variable.lua ├── verbatim.h └── verbatim.lua ├── luabin.h ├── tolua.c ├── tolua_scons.pkg ├── toluabind.c ├── toluabind.h ├── toluabind_default.c.bak └── toluabind_default.h.bak /.gitattributes: -------------------------------------------------------------------------------- 1 | *.h linguist-language=C++ 2 | *.c linguist-language=C++ 3 | -------------------------------------------------------------------------------- /.github/workflows/linux.yml: -------------------------------------------------------------------------------- 1 | name: linux 2 | 3 | on: [workflow_dispatch] 4 | 5 | env: 6 | # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) 7 | BUILD_TYPE: relwithdebinfo 8 | 9 | jobs: 10 | linux: 11 | runs-on: ${{ matrix.config.os }} 12 | 13 | strategy: 14 | matrix: 15 | config: 16 | - os: ubuntu-latest 17 | cc: gcc 18 | cxx: g++ 19 | vcpkg_triplet: x64-linux 20 | - os: ubuntu-latest 21 | cc: clang 22 | cxx: clang++ 23 | vcpkg_triplet: x64-linux 24 | 25 | steps: 26 | - uses: actions/checkout@v4 27 | - uses: brinkqiang/get-cmake@v1 28 | 29 | #- name: Install dependencies 30 | # run: sudo apt-get update && sudo apt-get install -y pkg-config 31 | 32 | - name: vcpkg build 33 | uses: brinkqiang/vcpkg-action@v1 34 | id: vcpkg 35 | with: 36 | pkgs: gtest 37 | triplet: ${{ matrix.config.vcpkg_triplet }} 38 | cache-key: ${{ matrix.config.os }} 39 | token: ${{ github.token }} 40 | github-binarycache: true 41 | 42 | - name: Get current date 43 | id: date 44 | run: echo "::set-output name=date::$(date +'%Y-%m-%dT%H%M')" 45 | 46 | - name: Create Build Environment 47 | run: cmake -E make_directory ${{github.workspace}}/build 48 | 49 | - name: Configure CMake 50 | shell: bash 51 | working-directory: ${{github.workspace}}/build 52 | env: 53 | CC: ${{ matrix.config.cc }} 54 | CXX: ${{ matrix.config.cxx }} 55 | run: cmake -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=${{ matrix.config.vcpkg_triplet }} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} .. 56 | 57 | - name: Build 58 | working-directory: ${{github.workspace}}/build 59 | shell: bash 60 | run: cmake --build . --config ${{env.BUILD_TYPE}} 61 | 62 | - name: Status 63 | uses: brinkqiang/github-status-action@v2 64 | with: 65 | authToken: ${{secrets.GITHUB_TOKEN}} 66 | context: 'Set Status' 67 | description: 'Passed' 68 | state: 'success' 69 | -------------------------------------------------------------------------------- /.github/workflows/mac.yml: -------------------------------------------------------------------------------- 1 | name: mac 2 | 3 | on: [workflow_dispatch] 4 | 5 | env: 6 | # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) 7 | BUILD_TYPE: relwithdebinfo 8 | 9 | jobs: 10 | mac: 11 | runs-on: ${{ matrix.config.os }} 12 | 13 | strategy: 14 | matrix: 15 | config: 16 | - os: macos-latest 17 | cc: gcc 18 | cxx: g++ 19 | vcpkg_triplet: arm64-osx 20 | - os: macos-latest 21 | cc: clang 22 | cxx: clang++ 23 | vcpkg_triplet: arm64-osx 24 | 25 | steps: 26 | - uses: actions/checkout@v4 27 | - uses: brinkqiang/get-cmake@v1 28 | - name: vcpkg build 29 | uses: brinkqiang/vcpkg-action@v1 30 | id: vcpkg 31 | with: 32 | pkgs: gtest 33 | triplet: ${{ matrix.config.vcpkg_triplet }} 34 | cache-key: ${{ matrix.config.os }} 35 | token: ${{ github.token }} 36 | github-binarycache: true 37 | 38 | - name: Get current date 39 | id: date 40 | run: echo "::set-output name=date::$(date +'%Y-%m-%dT%H%M')" 41 | 42 | - name: Create Build Environment 43 | run: cmake -E make_directory ${{github.workspace}}/build 44 | 45 | - name: Configure CMake 46 | shell: bash 47 | working-directory: ${{github.workspace}}/build 48 | env: 49 | CC: ${{ matrix.config.cc }} 50 | CXX: ${{ matrix.config.cxx }} 51 | run: cmake -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=${{ matrix.config.vcpkg_triplet }} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} .. 52 | 53 | - name: Build 54 | working-directory: ${{github.workspace}}/build 55 | shell: bash 56 | run: cmake --build . --config ${{env.BUILD_TYPE}} 57 | 58 | - name: Status 59 | uses: brinkqiang/github-status-action@v2 60 | with: 61 | authToken: ${{secrets.GITHUB_TOKEN}} 62 | context: 'Set Status' 63 | description: 'Passed' 64 | state: 'success' 65 | -------------------------------------------------------------------------------- /.github/workflows/win.yml: -------------------------------------------------------------------------------- 1 | name: win 2 | 3 | on: [workflow_dispatch] 4 | 5 | env: 6 | # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) 7 | BUILD_TYPE: relwithdebinfo 8 | 9 | jobs: 10 | win: 11 | runs-on: ${{ matrix.config.os }} 12 | 13 | strategy: 14 | matrix: 15 | config: 16 | - os: windows-latest 17 | compiler: msvc2019 18 | vcpkg_triplet: x64-windows 19 | - os: windows-latest 20 | compiler: msvc2022 21 | vcpkg_triplet: x64-windows 22 | - os: windows-latest 23 | compiler: clang-cl 24 | flags: -T ClangCL 25 | vcpkg_triplet: x64-windows 26 | 27 | steps: 28 | - uses: actions/checkout@v4 29 | - uses: brinkqiang/get-cmake@v1 30 | - name: vcpkg build 31 | uses: brinkqiang/vcpkg-action@v1 32 | id: vcpkg 33 | with: 34 | pkgs: gtest 35 | triplet: ${{ matrix.config.vcpkg_triplet }} 36 | cache-key: ${{ matrix.config.os }} 37 | token: ${{ github.token }} 38 | github-binarycache: true 39 | 40 | - name: Get current date 41 | id: date 42 | run: echo "::set-output name=date::$(date +'%Y-%m-%dT%H%M')" 43 | 44 | - name: Create Build Environment 45 | run: cmake -E make_directory ${{github.workspace}}\build 46 | 47 | - name: Configure CMake 48 | shell: bash 49 | working-directory: ${{github.workspace}}\build 50 | run: cmake -DCMAKE_TOOLCHAIN_FILE=..\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=${{ matrix.config.vcpkg_triplet }} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{matrix.config.flags}} .. 51 | 52 | - name: Build 53 | working-directory: ${{github.workspace}}\build 54 | shell: bash 55 | run: cmake --build . --config ${{env.BUILD_TYPE}} 56 | 57 | - name: Status 58 | uses: brinkqiang/github-status-action@v2 59 | with: 60 | authToken: ${{secrets.GITHUB_TOKEN}} 61 | context: 'Set Status' 62 | description: 'Passed' 63 | state: 'success' 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | CMakeCache.txt 2 | CMakeFiles 3 | CMakeScripts 4 | Testing 5 | Makefile 6 | cmake_install.cmake 7 | install_manifest.txt 8 | compile_commands.json 9 | CTestTestfile.cmake 10 | 11 | !/bin/script/*.lua 12 | !/bin/data/*.csv 13 | /bin/* 14 | /lib/* 15 | /build/* 16 | /.vscode/* -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "(Windows) 启动", 9 | "type": "cppvsdbg", 10 | "request": "launch", 11 | "program": "${workspaceFolder}/bin/debug/dmluademo.exe", 12 | "args": [], 13 | "stopAtEntry": false, 14 | "cwd": "${fileDirname}", 15 | "environment": [], 16 | "console": "externalTerminal" 17 | }, 18 | { 19 | "name": "launch process", 20 | "type": "lua", 21 | "request": "launch", 22 | "stopOnEntry": true, 23 | "runtimeExecutable": "${workspaceFolder}/bin/debug/dmluademo.exe", 24 | "runtimeArgs": "", 25 | "consoleCoding": "utf8" 26 | } 27 | ] 28 | } -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | 3 | project(dmlua) 4 | 5 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) 6 | include(cmake/ModuleImport.cmake) 7 | include(cmake/ModuleCompileOptions.cmake) 8 | include(cmake/LuaModule.cmake) 9 | ModuleSetCompileOptions() 10 | ModuleSetWinCompilerFlags() 11 | 12 | set(LUA_MODULE lua54) 13 | 14 | add_definitions(-DLUA_COMPAT_MODULE -DLUA_COMPAT_APIINTCASTS) 15 | 16 | ShowEnvironment() 17 | 18 | LuaModuleImport("${LUA_MODULE}" "libtolua" "src/libtolua" "") 19 | 20 | ExeImport("tool" "${LUA_MODULE};libtolua") 21 | ExeImport("samples" "${LUA_MODULE};libtolua") 22 | 23 | if (WIN32) 24 | 25 | add_custom_command( 26 | TARGET dmluademo 27 | PRE_BUILD 28 | COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${CMAKE_CURRENT_SOURCE_DIR}/samples/dmluademo/script 29 | COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${CMAKE_CURRENT_SOURCE_DIR}/samples/dmluademo/script 30 | COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${CMAKE_CURRENT_SOURCE_DIR}/samples/dmluademo/script 31 | 32 | ) 33 | 34 | add_custom_command( 35 | TARGET dmluademo 36 | PRE_BUILD 37 | COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/samples/dmluademo/script/toluapp.exe -t -n interface -o interface.cpp -H interface.h interface.pkg 38 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/samples/dmluademo/script 39 | MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/samples/dmluademo/script/interface.pkg 40 | ) 41 | 42 | add_custom_command( 43 | TARGET dmluademo 44 | PRE_BUILD 45 | COMMAND ${CMAKE_COMMAND} -E copy_if_different 46 | ${CMAKE_CURRENT_SOURCE_DIR}/config/lua_dkm_debug.json 47 | $ 48 | ) 49 | 50 | endif(WIN32) 51 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 brinkqiang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /bin/script/common/clone.lua: -------------------------------------------------------------------------------- 1 | -- lua script 2 | module(..., package.seeall) 3 | 4 | function clone(object) 5 | local lookup_table = {} 6 | local function copyObj(object) 7 | if type(object) ~= 'table' then 8 | return object 9 | elseif lookup_table[object] then 10 | return lookup_table[object] 11 | end 12 | 13 | local new_table = {} 14 | lookup_table[object] = new_table 15 | for key, value in pairs(object) do 16 | new_table[copyObj(key)] = copyObj(value) 17 | end 18 | return setmetatable(new_table, getmetatable(object)) 19 | end 20 | return copyObj(object) 21 | end 22 | 23 | function clone(object, deep) 24 | local copy = {} 25 | 26 | for k, v in pairs(object) do 27 | if deep and type(v) == 'table' then v = clone(v, deep) end 28 | copy[k] = v 29 | end 30 | 31 | return setmetatable(copy, getmetatable(object)) 32 | end 33 | 34 | function main() 35 | local map = {id = 1, count = 2} 36 | local map2 = clone(map) 37 | print(map) 38 | print(map2) 39 | 40 | local map3 = {} 41 | clone(map, map3) 42 | print(map) 43 | print(map3) 44 | end 45 | -------------------------------------------------------------------------------- /bin/script/common/math.lua: -------------------------------------------------------------------------------- 1 | -- lua script 2 | module (..., package.seeall) 3 | 4 | function add(a, b, res) 5 | res.value = a + b 6 | end 7 | 8 | function bin2hex(s) 9 | s=string.gsub(s,"(.)",function (x) return string.format("%02X ",string.byte(x)) end) 10 | return s 11 | end 12 | 13 | local h2b = { 14 | ["0"] = 0, 15 | ["1"] = 1, 16 | ["2"] = 2, 17 | ["3"] = 3, 18 | ["4"] = 4, 19 | ["5"] = 5, 20 | ["6"] = 6, 21 | ["7"] = 7, 22 | ["8"] = 8, 23 | ["9"] = 9, 24 | ["A"] = 10, 25 | ["B"] = 11, 26 | ["C"] = 12, 27 | ["D"] = 13, 28 | ["E"] = 14, 29 | ["F"] = 15 30 | } 31 | 32 | function hex2bin( hexstr ) 33 | local s = string.gsub(hexstr, "(.)(.)%s", function ( h, l ) 34 | return string.char(h2b[h]*16+h2b[l]) 35 | end) 36 | return s 37 | end -------------------------------------------------------------------------------- /bin/script/common/test.lua: -------------------------------------------------------------------------------- 1 | -- lua script 2 | module (..., package.seeall) 3 | 4 | function main_vector(vec) 5 | 6 | vec:push_back('world') 7 | 8 | print(vec:size()) 9 | 10 | for i=0,vec:size()-1,1 do print(vec[i]) end 11 | 12 | end 13 | function main() 14 | local role = CreateRole(); 15 | role:SetName("Jerry2020") 16 | 17 | print("Player Name = " .. role:GetName()) 18 | print("PlayerID = " .. role:GetObjID()) 19 | 20 | ReleaseRole(role) 21 | end 22 | -------------------------------------------------------------------------------- /bin/script/task/task.lua: -------------------------------------------------------------------------------- 1 | -- lua script 2 | module (..., package.seeall) 3 | 4 | function AcceptTask(objID, taskID, ret) 5 | local role = FindRole(objID) 6 | if role == nil then 7 | ret.value = -1 8 | print("AcceptTask FindRole = nil") 9 | return 10 | end 11 | print("==================================") 12 | print("Player Name = " .. role:GetName()) 13 | print("PlayerID = " .. role:GetObjID()) 14 | print("AcceptTask taskID = " .. taskID) 15 | 16 | if role:AcceptTask(taskID) then 17 | ret.value = 0 18 | print("AcceptTask ret = " .. math.ceil(ret.value)) 19 | else 20 | ret.value = -1 21 | print("AcceptTask ret = " .. math.ceil(ret.value)) 22 | end 23 | 24 | print("###################################") 25 | end 26 | 27 | function FinishTask(objID, taskID) 28 | local role = FindRole(objID) 29 | if role == nil then 30 | print("FinishTask FindRole = nil") 31 | return 32 | end 33 | 34 | print("==================================") 35 | print("Player Name = " .. role:GetName()) 36 | print("PlayerID = " .. role:GetObjID()) 37 | print("FinishTask taskID = " .. taskID) 38 | print("==================================") 39 | role:FinishTask(taskID) 40 | end 41 | -------------------------------------------------------------------------------- /bin/script/task/timer.lua: -------------------------------------------------------------------------------- 1 | -- lua script 2 | module (..., package.seeall) 3 | 4 | function main(role, taskid) 5 | print(role:GetName() .. " & " .. taskid) 6 | role:AcceptTask(taskid) 7 | end 8 | 9 | function main1(t1) 10 | 11 | end 12 | 13 | function main2(t1, t2) 14 | 15 | end 16 | 17 | function main3(t1, t2, t3) 18 | 19 | end 20 | 21 | function main4(t1, t2, t3, t4) 22 | 23 | end 24 | 25 | function main5(t1, t2, t3, t4, t5) 26 | 27 | end 28 | -------------------------------------------------------------------------------- /bin/script/task/unit.lua: -------------------------------------------------------------------------------- 1 | -- lua script 2 | module (..., package.seeall) 3 | 4 | function main() 5 | print("==================================") 6 | print("==================================") 7 | end 8 | 9 | function main1(t1) 10 | print("==================================") 11 | print("in unit t1 = " .. t1) 12 | print("==================================") 13 | end 14 | 15 | function main2(t1, t2) 16 | print("==================================") 17 | print("in unit t1 = " .. t1) 18 | print("in unit t2 = " .. t2) 19 | print("==================================") 20 | end 21 | 22 | function main3(t1, t2, t3) 23 | print("==================================") 24 | print("in unit t1 = " .. t1) 25 | print("in unit t2 = " .. t2) 26 | print("in unit t3 = " .. t3) 27 | print("==================================") 28 | end 29 | 30 | function main4(t1, t2, t3, t4) 31 | print("==================================") 32 | print("in unit t1 = " .. t1) 33 | print("in unit t2 = " .. t2) 34 | print("in unit t3 = " .. t3) 35 | print("in unit t4 = " .. t4) 36 | print("==================================") 37 | end 38 | 39 | function main5(t1, t2, t3, t4, t5) 40 | print("==================================") 41 | print("in unit t1 = " .. t1) 42 | print("in unit t2 = " .. t2) 43 | print("in unit t3 = " .. t3) 44 | print("in unit t4 = " .. t4) 45 | print("in unit t5 = " .. t5) 46 | print("==================================") 47 | end 48 | -------------------------------------------------------------------------------- /bin/script/type/type.lua: -------------------------------------------------------------------------------- 1 | 2 | -- lua script 3 | module (..., package.seeall) 4 | 5 | function TypeTest(chData, wData, dwData, qwData, sData, nData, llData ,fData, dbData) 6 | print("==================================") 7 | print(type(chData), type(wData), type(dwData), type(qwData), type(sData), type(nData), type(llData), type(fData), type(dbData)) 8 | print(chData .. " " .. wData .. " " .. dwData .. " " .. qwData .. " " .. sData .. " " .. nData .. " " .. llData .. " " .. fData .. " " .. tonumber(dbData)) 9 | print("==================================") 10 | 11 | 12 | print(tonumber(123456789123456789)) 13 | local num = 123456789123456789 14 | print(type(num) .. " " .. num) 15 | 16 | local num2 = tonumber(123456789123456789) 17 | print(type(num2) .. " " .. num2) 18 | local num3 = 1.23 19 | print(type(num3) .. " " .. num3) 20 | 21 | end 22 | -------------------------------------------------------------------------------- /build.bat: -------------------------------------------------------------------------------- 1 | 2 | rmdir /S /Q build 3 | mkdir build 4 | pushd build 5 | cmake -A x64 -DCMAKE_BUILD_TYPE=relwithdebinfo .. 6 | cmake --build . --config relwithdebinfo -- /m:%NUMBER_OF_PROCESSORS% 7 | popd 8 | 9 | rem pause -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | rm -rf build 4 | mkdir -p build 5 | pushd build 6 | 7 | # -DCMAKE_EXPORT_COMPILE_COMMANDS=ON option is implemented only by Makefile Generators and Ninja Generators. 8 | cmake -DCMAKE_BUILD_TYPE=relwithdebinfo -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .. 9 | cmake --build . --config relwithdebinfo -- -j$(nproc) 10 | popd 11 | 12 | # popd 13 | 14 | # echo continue && read -n 1 15 | -------------------------------------------------------------------------------- /build_mingw.bat: -------------------------------------------------------------------------------- 1 | 2 | 3 | rmdir /S /Q build 2> nul 4 | mkdir build 5 | pushd build 6 | cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=relwithdebinfo .. 7 | cmake --build . --config relwithdebinfo 8 | popd 9 | 10 | rem pause -------------------------------------------------------------------------------- /cmake/cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") 2 | message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt") 3 | endif() 4 | 5 | file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files) 6 | string(REGEX REPLACE "\n" ";" files "${files}") 7 | foreach(file ${files}) 8 | message(STATUS "Uninstalling $ENV{DESTDIR}${file}") 9 | if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 10 | execute_process( 11 | COMMAND "@CMAKE_COMMAND@" -E remove "$ENV{DESTDIR}${file}" 12 | OUTPUT_VARIABLE rm_out 13 | RESULT_VARIABLE rm_retval 14 | ) 15 | if(NOT "${rm_retval}" STREQUAL "0") 16 | message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") 17 | endif() 18 | else() 19 | message(STATUS "File $ENV{DESTDIR}${file} does not exist.") 20 | endif() 21 | endforeach() 22 | -------------------------------------------------------------------------------- /config/lua_dkm_debug.json: -------------------------------------------------------------------------------- 1 | { 2 | "ScriptPaths": [ 3 | "../", 4 | "../script/" 5 | ] 6 | } -------------------------------------------------------------------------------- /doc/toluapp.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brinkqiang/dmlua/47ec88828a178e50c7d7e0558526479b7176dbbc/doc/toluapp.gif -------------------------------------------------------------------------------- /include/dmconsole.h: -------------------------------------------------------------------------------- 1 | 2 | // Copyright (c) 2018 brinkqiang (brink.qiang@gmail.com) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #ifndef __DMCONSOLE_H_INCLUDE__ 23 | #define __DMCONSOLE_H_INCLUDE__ 24 | 25 | #include "dmos.h" 26 | #include "dmsingleton.h" 27 | 28 | class IDMConsoleSink 29 | { 30 | public: 31 | virtual ~IDMConsoleSink() {}; 32 | 33 | virtual void OnCloseEvent() {}; 34 | }; 35 | 36 | class HDMConsoleMgr : public TSingleton 37 | { 38 | friend class TSingleton; 39 | public: 40 | void SetHandlerHook( IDMConsoleSink* pSink ) 41 | { 42 | m_pConsoleSink = pSink; 43 | #ifdef _WIN32 44 | 45 | if ( 0 == SetConsoleCtrlHandler( ( PHANDLER_ROUTINE ) 46 | &HDMConsoleMgr::OnConsoleEvent, true ) ) 47 | { 48 | DMASSERT( 0 ); 49 | } 50 | 51 | #else 52 | m_phSigHandler = signal( SIGINT, &HDMConsoleMgr::OnConsoleEvent ); 53 | 54 | if ( SIG_ERR == m_phSigHandler ) 55 | { 56 | DMASSERT( 0 ); 57 | } 58 | 59 | #endif 60 | } 61 | 62 | void OnCloseEvent() 63 | { 64 | if ( m_bOnce && m_pConsoleSink ) 65 | { 66 | m_bOnce = false; 67 | m_pConsoleSink->OnCloseEvent(); 68 | } 69 | } 70 | 71 | #ifdef _WIN32 72 | static BOOL WINAPI OnConsoleEvent( UINT32 dwEventType ) 73 | { 74 | switch ( dwEventType ) 75 | { 76 | case CTRL_C_EVENT: 77 | case CTRL_CLOSE_EVENT: 78 | case CTRL_LOGOFF_EVENT: 79 | case CTRL_SHUTDOWN_EVENT: 80 | { 81 | HDMConsoleMgr::Instance()->OnCloseEvent(); 82 | } 83 | break; 84 | 85 | default: 86 | DMASSERT( 0 ); 87 | break; 88 | } 89 | 90 | return TRUE; 91 | } 92 | #else 93 | static void OnConsoleEvent( int nEventType ) 94 | { 95 | switch ( nEventType ) 96 | { 97 | case SIGINT: 98 | { 99 | HDMConsoleMgr::Instance()->OnCloseEvent(); 100 | } 101 | break; 102 | 103 | default: 104 | DMASSERT( 0 ); 105 | break; 106 | } 107 | } 108 | private: 109 | sighandler_t m_phSigHandler; 110 | #endif 111 | 112 | public: 113 | HDMConsoleMgr() 114 | { 115 | #ifdef _WIN32 116 | m_pConsoleSink = NULL; 117 | m_bOnce = true; 118 | #else 119 | m_phSigHandler = NULL; 120 | m_pConsoleSink = NULL; 121 | m_bOnce = true; 122 | #endif 123 | } 124 | 125 | ~HDMConsoleMgr() 126 | { 127 | } 128 | 129 | private: 130 | IDMConsoleSink* m_pConsoleSink; 131 | bool m_bOnce; 132 | }; 133 | 134 | #endif // __DMCONSOLE_H_INCLUDE__ 135 | -------------------------------------------------------------------------------- /include/dmlua.h: -------------------------------------------------------------------------------- 1 | 2 | // Copyright (c) 2018 brinkqiang (brink.qiang@gmail.com) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #ifndef __DMLUA_H_INCLUDE__ 23 | #define __DMLUA_H_INCLUDE__ 24 | 25 | #include "dmos.h" 26 | #include "dmlua_engine.h" 27 | #include "dmlua_luaresult.h" 28 | 29 | #endif // __DMLUA_H_INCLUDE__ 30 | -------------------------------------------------------------------------------- /include/dmlua_luaresult.h: -------------------------------------------------------------------------------- 1 | 2 | // Copyright (c) 2018 brinkqiang (brink.qiang@gmail.com) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #ifndef __DMLUA_LUARESULT_H_INCLUDE__ 23 | #define __DMLUA_LUARESULT_H_INCLUDE__ 24 | 25 | #include 26 | #include "dmtypes.h" 27 | 28 | template 29 | struct LuaResult 30 | { 31 | LuaResult() : value( T() ) {} 32 | LuaResult( const T& t ) : value( t ) {} 33 | operator T& () 34 | { 35 | return value; 36 | } 37 | T value; 38 | }; 39 | 40 | template<> 41 | struct LuaResult 42 | { 43 | LuaResult() : value( std::string() ) {} 44 | operator const char* () 45 | { 46 | return value.c_str(); 47 | } 48 | std::string value; 49 | }; 50 | 51 | template<> 52 | struct LuaResult 53 | { 54 | LuaResult() : value( 0 ) {} 55 | LuaResult( const int64_t& t ) : value( t ) {} 56 | operator int64_t() 57 | { 58 | return value; 59 | } 60 | int64_t value; 61 | }; 62 | 63 | template<> 64 | struct LuaResult 65 | { 66 | LuaResult() : value( 0 ) {} 67 | LuaResult( const uint64_t& t ) : value( t ) {} 68 | operator uint64_t() 69 | { 70 | return value; 71 | } 72 | uint64_t value; 73 | }; 74 | 75 | typedef LuaResult LResultINT; 76 | typedef LuaResult LResultINT64; 77 | typedef LuaResult LResultUINT64; 78 | typedef LuaResult LResultDOUBLE; 79 | 80 | typedef LuaResult LResultSTRING; 81 | 82 | #endif // __DMLUA_LUARESULT_H_INCLUDE__ 83 | -------------------------------------------------------------------------------- /include/dmlua_typeid.h: -------------------------------------------------------------------------------- 1 | 2 | // Copyright (c) 2018 brinkqiang (brink.qiang@gmail.com) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #ifndef __DMLUA_TYPEID_H_INCLUDE__ 23 | #define __DMLUA_TYPEID_H_INCLUDE__ 24 | 25 | #ifdef __cplusplus 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | //#define Mtolua_typeid(L,TI,T) tolua_typeid_reg(L,T) 32 | 33 | struct SLuaTypeInfo 34 | { 35 | SLuaTypeInfo() 36 | : m_bInit( false ) 37 | { 38 | } 39 | std::string m_strName; 40 | bool m_bInit; 41 | }; 42 | 43 | class CluaTypeid 44 | { 45 | public: 46 | static CluaTypeid& Instance() 47 | { 48 | static CluaTypeid s; 49 | return s; 50 | } 51 | 52 | template 53 | inline void type_reg( const char* name ) 54 | { 55 | name_holder().m_strName = name; 56 | name_holder().m_bInit = true; 57 | } 58 | 59 | template 60 | inline const char* get_name() 61 | { 62 | return name_holder().m_bInit ? name_holder().m_strName.c_str() : NULL; 63 | } 64 | 65 | private: 66 | template 67 | inline SLuaTypeInfo& name_holder() 68 | { 69 | static SLuaTypeInfo sInfo; 70 | return sInfo; 71 | } 72 | }; 73 | 74 | template 75 | inline void Mtolua_typeid( lua_State* tolua_S, const char* name ) 76 | { 77 | CluaTypeid::Instance().type_reg( name ); 78 | } 79 | #endif 80 | 81 | #endif // __DMLUA_TYPEID_H_INCLUDE__ 82 | -------------------------------------------------------------------------------- /include/dmos.h: -------------------------------------------------------------------------------- 1 | 2 | // Copyright (c) 2018 brinkqiang (brink.qiang@gmail.com) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #ifndef __DMOS_H_INCLUDE__ 23 | #define __DMOS_H_INCLUDE__ 24 | 25 | #ifdef _WIN32 26 | 27 | #ifndef _WIN32_WINNT 28 | #define _WIN32_WINNT 0x0501 29 | #endif 30 | 31 | #ifndef WIN32_LEAN_AND_MEAN 32 | #define WIN32_LEAN_AND_MEAN 33 | #endif 34 | 35 | #ifndef _CRT_SECURE_NO_WARNINGS 36 | #define _CRT_SECURE_NO_WARNINGS 37 | #endif 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | 44 | #include 45 | 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | 52 | #include 53 | #include 54 | 55 | #include 56 | #include 57 | #include 58 | 59 | #include 60 | 61 | 62 | #include 63 | #include 64 | #include 65 | #include 66 | #include 67 | 68 | #pragma comment(lib, "ws2_32.lib") 69 | 70 | namespace stdext 71 | { 72 | 73 | } 74 | 75 | namespace std 76 | { 77 | using namespace stdext; 78 | } 79 | 80 | #define VSNPRINTF _vsnprintf 81 | #define SleepMs(x) Sleep(x) 82 | #ifndef INFINITE 83 | #define INFINITE 0xffffffff 84 | #endif 85 | 86 | #else 87 | 88 | #include 89 | #include 90 | #include 91 | #include 92 | #include 93 | 94 | #include 95 | 96 | #include 97 | #include 98 | #include 99 | #include 100 | #include 101 | 102 | #include 103 | #include 104 | 105 | #include 106 | #include 107 | #include 108 | 109 | #include 110 | #include 111 | #include 112 | #include 113 | #include 114 | #include 115 | #include 116 | 117 | #include 118 | #include 119 | #include 120 | #include 121 | 122 | #ifndef MAX_PATH 123 | #define MAX_PATH PATH_MAX 124 | #endif 125 | #define VSNPRINTF vsnprintf 126 | #define SleepMs(x) usleep(x*1000) 127 | #ifndef INFINITE 128 | #define INFINITE 0xffffffff 129 | #endif 130 | #endif 131 | 132 | #define PATH_IS_DELIMITER(x) ('\\' == x || '/' == x) 133 | 134 | #ifdef _WIN32 135 | #define PATH_DELIMITER '\\' 136 | #else 137 | #define PATH_DELIMITER '/' 138 | #endif 139 | 140 | #ifdef _WIN32 141 | #define PATH_DELIMITER_STR "\\" 142 | #else 143 | #define PATH_DELIMITER_STR "/" 144 | #endif 145 | #define DMASSERT assert 146 | 147 | #ifdef _WIN32 148 | #define DMAPI __stdcall 149 | typedef HANDLE DMHANDLE; 150 | #define DMINVALID_HANDLE NULL 151 | #else 152 | #define DMAPI 153 | typedef int DMHANDLE; 154 | #define DMINVALID_HANDLE 0 155 | #endif 156 | 157 | #endif // __DMOS_H_INCLUDE__ 158 | -------------------------------------------------------------------------------- /include/dmtypes.h: -------------------------------------------------------------------------------- 1 | 2 | // Copyright (c) 2018 brinkqiang (brink.qiang@gmail.com) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #ifndef __DMTYPES_H_INCLUDE__ 23 | #define __DMTYPES_H_INCLUDE__ 24 | 25 | #include 26 | 27 | #endif // __DMTYPES_H_INCLUDE__ 28 | -------------------------------------------------------------------------------- /include/sol/config.hpp: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | 3 | // Copyright (c) 2013-2020 Rapptz, ThePhD and contributors 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files (the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | // This file was generated with a script. 23 | // Generated 2022-06-25 08:14:19.336233 UTC 24 | // This header was generated with sol v3.3.0 (revision eba86625) 25 | // https://github.com/ThePhD/sol2 26 | 27 | #ifndef SOL_SINGLE_CONFIG_HPP 28 | #define SOL_SINGLE_CONFIG_HPP 29 | 30 | // beginning of sol/config.hpp 31 | 32 | /* Base, empty configuration file! 33 | 34 | To override, place a file in your include paths of the form: 35 | 36 | . (your include path here) 37 | | sol (directory, or equivalent) 38 | | config.hpp (your config.hpp file) 39 | 40 | So that when sol2 includes the file 41 | 42 | #include 43 | 44 | it gives you the configuration values you desire. Configuration values can be 45 | seen in the safety.rst of the doc/src, or at 46 | https://sol2.readthedocs.io/en/latest/safety.html ! You can also pass them through 47 | the build system, or the command line options of your compiler. 48 | 49 | */ 50 | 51 | // end of sol/config.hpp 52 | 53 | #endif // SOL_SINGLE_CONFIG_HPP 54 | -------------------------------------------------------------------------------- /samples/dmluademo/common/enum.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __ENUM_H_INCLUDE__ 3 | #define __ENUM_H_INCLUDE__ 4 | 5 | // tolua_begin 6 | 7 | typedef enum { 8 | eTaskStateStart, 9 | eTaskStateEnd, 10 | } ETaskState; 11 | // tolua_end 12 | #endif // __ENUM_H_INCLUDE__ 13 | -------------------------------------------------------------------------------- /samples/dmluademo/common/macros.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __MACROS_H_INCLUDE__ 3 | #define __MACROS_H_INCLUDE__ 4 | 5 | // tolua_begin 6 | #define MAX_HP 99999 7 | #define MAX_MP 99999 8 | 9 | #define MAX_ROLE_COUNT 10 10 | #define MAX_NAME_LEN 64 11 | // tolua_end 12 | 13 | #endif // __MACROS_H_INCLUDE__ 14 | 15 | -------------------------------------------------------------------------------- /samples/dmluademo/common/struct.h: -------------------------------------------------------------------------------- 1 | #ifndef __STRUCT_H_INCLUDE__ 2 | #define __STRUCT_H_INCLUDE__ 3 | 4 | #include "dmos.h" 5 | #include "enum.h" 6 | #include "macros.h" 7 | // tolua_begin 8 | 9 | struct STaskInfo { 10 | STaskInfo() 11 | : nTaskID( 0 ), 12 | nTaskState( 0 ), 13 | nTaskCondition( 0 ) { 14 | } 15 | 16 | ~STaskInfo() { 17 | } 18 | 19 | int nTaskID; 20 | int nTaskState; 21 | int nTaskCondition; 22 | }; 23 | 24 | typedef std::map TaskInfoMap; 25 | typedef TaskInfoMap::iterator TaskInfoMapIt; 26 | 27 | struct SPos { 28 | SPos() 29 | : x( 0 ), 30 | y( 0 ), 31 | z( 0 ) { 32 | } 33 | 34 | SPos( int _x, int _y, int _z ) 35 | : x( _x ), 36 | y( _y ), 37 | z( _z ) { 38 | } 39 | 40 | ~SPos() { 41 | } 42 | 43 | int x; 44 | int y; 45 | int z; 46 | }; 47 | 48 | // tolua_end 49 | #endif // __STRUCT_H_INCLUDE__ 50 | 51 | -------------------------------------------------------------------------------- /samples/dmluademo/common/types.h: -------------------------------------------------------------------------------- 1 | #ifndef __TYPES_H__ 2 | #define __TYPES_H__ 3 | 4 | // tolua_begin 5 | 6 | typedef unsigned char UINT8; 7 | typedef short INT16; 8 | typedef unsigned short UINT16; 9 | typedef int INT32; 10 | typedef unsigned int UINT32; 11 | 12 | #ifdef _WIN32 13 | typedef long long int INT64; 14 | typedef unsigned long long int UINT64; 15 | #else 16 | typedef long long int INT64; 17 | typedef unsigned long long int UINT64; 18 | #endif 19 | 20 | #ifdef _WIN32 21 | #define FMT_I64 "%I64d" 22 | #define FMT_U64 "%I64u" 23 | #define FMT_64X "%I64x" 24 | #else 25 | #define FMT_I64 "%lld" 26 | #define FMT_U64 "%llu" 27 | #define FMT_64X "%llx" 28 | #endif 29 | 30 | // tolua_end 31 | 32 | #endif 33 | 34 | -------------------------------------------------------------------------------- /samples/dmluademo/gtest/gtest_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include 31 | 32 | #include 33 | 34 | int main( int argc, char** argv ) { 35 | std::cout << "Running main() from gtest_main.cc\n"; 36 | testing::InitGoogleTest( &argc, argv ); 37 | int ret = RUN_ALL_TESTS(); 38 | //getchar(); 39 | return ret; 40 | } 41 | -------------------------------------------------------------------------------- /samples/dmluademo/role/role.cpp: -------------------------------------------------------------------------------- 1 | #include "role.h" 2 | #include "rolemgr.h" 3 | 4 | bool CRole::AcceptTask( int nTaskID ) { 5 | TaskInfoMapIt It = m_TaskInfoMap.find( nTaskID ); 6 | 7 | if ( It != m_TaskInfoMap.end() ) { 8 | return false; 9 | } 10 | 11 | STaskInfo oInfo; 12 | oInfo.nTaskID = nTaskID; 13 | oInfo.nTaskState = eTaskStateStart; 14 | oInfo.nTaskCondition = 0; 15 | m_TaskInfoMap[oInfo.nTaskID] = oInfo; 16 | return true; 17 | } 18 | 19 | void CRole::FinishTask( int nTaskID ) { 20 | TaskInfoMapIt It = m_TaskInfoMap.find( nTaskID ); 21 | 22 | if ( It == m_TaskInfoMap.end() ) { 23 | return; 24 | } 25 | 26 | It->second.nTaskState = eTaskStateEnd; 27 | } 28 | -------------------------------------------------------------------------------- /samples/dmluademo/role/role.h: -------------------------------------------------------------------------------- 1 | #ifndef __ROLE_H_INCLUDE__ 2 | #define __ROLE_H_INCLUDE__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "common/struct.h" 9 | 10 | class CObj { // tolua_export 11 | public: 12 | void Reset() { 13 | m_qwObjID = -1; 14 | } 15 | 16 | private: 17 | uint64_t m_qwObjID; 18 | std::string m_strName; 19 | 20 | public: 21 | // tolua_begin 22 | CObj() { 23 | Reset(); 24 | } 25 | 26 | virtual ~CObj() { 27 | Reset(); 28 | } 29 | void SetObjID(uint64_t qwObjID) { 30 | m_qwObjID = qwObjID; 31 | } 32 | uint64_t GetObjID() { 33 | return m_qwObjID; 34 | } 35 | 36 | void SetName(const char* szName) { 37 | m_strName = szName; 38 | } 39 | const char* GetName() { 40 | return m_strName.c_str(); 41 | } 42 | }; 43 | // tolua_end 44 | 45 | 46 | class CRole : public CObj { // tolua_export 47 | public: 48 | void Reset() { 49 | m_nHP = 0; 50 | m_nMP = 0; 51 | } 52 | private: 53 | int m_nHP; 54 | int m_nMP; 55 | 56 | TaskInfoMap m_TaskInfoMap; 57 | SPos m_stPos; 58 | 59 | public: 60 | // tolua_begin 61 | CRole() { 62 | Reset(); 63 | } 64 | virtual ~CRole() { 65 | Reset(); 66 | } 67 | void SetMp(int nMp) { 68 | m_nMP = nMp; 69 | } 70 | int GetMp() { 71 | return m_nMP; 72 | } 73 | 74 | void SetHp(int nHp) { 75 | m_nHP = nHp; 76 | } 77 | int GetHp() { 78 | return m_nHP; 79 | } 80 | 81 | void AddMP(int nMp) { 82 | m_nMP += nMp; 83 | } 84 | void AddHP(int nHp) { 85 | m_nHP += nHp; 86 | } 87 | 88 | 89 | void SetPos(const SPos& stPos) { 90 | m_stPos = stPos; 91 | } 92 | SPos& GetPos() { 93 | return m_stPos; 94 | } 95 | 96 | bool AcceptTask(int nTaskID); 97 | void FinishTask(int nTaskID); 98 | }; 99 | // tolua_end 100 | 101 | #endif // __ROLE_H_INCLUDE__ 102 | -------------------------------------------------------------------------------- /samples/dmluademo/role/rolemgr.cpp: -------------------------------------------------------------------------------- 1 | #include "rolemgr.h" 2 | #include "role.h" 3 | #include "dmsnowflake.h" 4 | 5 | static inline uint64_t GetNextID() 6 | { 7 | static CDMIDGenerator Gen(0, 0); 8 | return Gen.GetNextID(); 9 | } 10 | 11 | CRoleMgr::CRoleMgr() : m_qwObjID(10000) { 12 | } 13 | 14 | CRoleMgr::~CRoleMgr() { 15 | } 16 | 17 | CRole* CRoleMgr::CreateRole() { 18 | CRole* poRole = m_oRolePool.FetchObj(); 19 | 20 | if (NULL == poRole) { 21 | return NULL; 22 | } 23 | 24 | poRole->SetObjID(GetNextID()); 25 | m_mapRole[poRole->GetObjID()] = poRole; 26 | return poRole; 27 | } 28 | 29 | void CRoleMgr::ReleaseRole(CRole* poRole) { 30 | if (NULL == poRole) { 31 | return; 32 | } 33 | 34 | m_mapRole.erase(poRole->GetObjID()); 35 | m_oRolePool.ReleaseObj(poRole); 36 | } 37 | 38 | CRole* CRoleMgr::FindRole(uint64_t qwID) { 39 | MapRoleIt It = m_mapRole.find(qwID); 40 | 41 | if (It == m_mapRole.end()) { 42 | return NULL; 43 | } 44 | 45 | return It->second; 46 | } 47 | 48 | CRole* FindRole(uint64_t qwID) 49 | { 50 | return CRoleMgr::Instance()->FindRole(qwID); 51 | } 52 | 53 | CRole* CreateRole() 54 | { 55 | return CRoleMgr::Instance()->CreateRole(); 56 | } 57 | 58 | void ReleaseRole(CRole* poRole) 59 | { 60 | CRoleMgr::Instance()->ReleaseRole(poRole); 61 | } 62 | -------------------------------------------------------------------------------- /samples/dmluademo/role/rolemgr.h: -------------------------------------------------------------------------------- 1 | #ifndef __ROLEMGR_H_INCLUDE__ 2 | #define __ROLEMGR_H_INCLUDE__ 3 | 4 | #include 5 | 6 | #include "dmsingleton.h" 7 | #include "dmrapidpool.h" 8 | #include "role/role.h" 9 | 10 | class CRoleMgr : public TSingleton { 11 | friend class TSingleton; 12 | 13 | public: 14 | CRoleMgr(); 15 | ~CRoleMgr(); 16 | 17 | public: 18 | CRole* FindRole( uint64_t qwID ); 19 | CRole* CreateRole(); 20 | void ReleaseRole( CRole* poRole ); 21 | 22 | private: 23 | uint64_t GetNextObjID(); 24 | 25 | CDynamicRapidPool m_oRolePool; 26 | 27 | typedef std::map MapRole; 28 | typedef std::map::iterator MapRoleIt; 29 | MapRole m_mapRole; 30 | 31 | uint64_t m_qwObjID; 32 | }; 33 | // tolua_begin 34 | CRole* FindRole(uint64_t qwID ); 35 | CRole* CreateRole(); 36 | void ReleaseRole( CRole* poRole ); 37 | // tolua_end 38 | #endif // __ROLEMGR_H_INCLUDE__ 39 | -------------------------------------------------------------------------------- /samples/dmluademo/script/buildtolua.bat: -------------------------------------------------------------------------------- 1 | toluapp -t -n interface -o interface.cpp -H interface.h interface.pkg 2 | -------------------------------------------------------------------------------- /samples/dmluademo/script/buildtolua.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ./toluapp -t -n interface -o interface.cpp -H interface.h interface.pkg 3 | -------------------------------------------------------------------------------- /samples/dmluademo/script/interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Lua binding: interface 3 | ** Generated automatically by tolua++-1.0.93. 4 | */ 5 | 6 | /* Exported function */ 7 | TOLUA_API int tolua_interface_open (lua_State* tolua_S); 8 | 9 | -------------------------------------------------------------------------------- /samples/dmluademo/script/interface.pkg: -------------------------------------------------------------------------------- 1 | 2 | $#include "dmlua_typeid.h" 3 | 4 | $pfile "luaresult.pkg" 5 | 6 | $cfile "../common/macros.h" 7 | $cfile "../common/enum.h" 8 | $cfile "../common/struct.h" 9 | 10 | $cfile "../role/role.h" 11 | $cfile "../role/rolemgr.h" 12 | -------------------------------------------------------------------------------- /samples/dmluademo/script/libtolua.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brinkqiang/dmlua/47ec88828a178e50c7d7e0558526479b7176dbbc/samples/dmluademo/script/libtolua.dll -------------------------------------------------------------------------------- /samples/dmluademo/script/lua54.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brinkqiang/dmlua/47ec88828a178e50c7d7e0558526479b7176dbbc/samples/dmluademo/script/lua54.dll -------------------------------------------------------------------------------- /samples/dmluademo/script/luaresult.pkg: -------------------------------------------------------------------------------- 1 | $#include "dmlua_luaresult.h" 2 | $#include "dmtypes.h" 3 | 4 | 5 | struct LuaResult 6 | { 7 | TOLUA_TEMPLATE_BIND(T, int, int64_t, uint64_t, double, std::string); 8 | 9 | T value; 10 | 11 | LuaResult(); 12 | ~LuaResult(); 13 | }; 14 | 15 | namespace std 16 | { 17 | class vector 18 | { 19 | TOLUA_TEMPLATE_BIND(T, int, int64_t, uint64_t, double, std::string); 20 | 21 | void clear(); 22 | int size() const; 23 | 24 | const T& operator[](int index) const; 25 | T& operator[](int index); 26 | void push_back(T val); 27 | 28 | vector(); 29 | ~vector(); 30 | }; 31 | } 32 | -------------------------------------------------------------------------------- /samples/dmluademo/script/toluapp.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brinkqiang/dmlua/47ec88828a178e50c7d7e0558526479b7176dbbc/samples/dmluademo/script/toluapp.exe -------------------------------------------------------------------------------- /src/libtolua/SCsub: -------------------------------------------------------------------------------- 1 | Import('env') 2 | 3 | 4 | sources = [ 5 | 'tolua_event.c', 6 | 'tolua_is.c', 7 | 'tolua_map.c', 8 | 'tolua_push.c', 9 | 'tolua_to.c', 10 | ] 11 | 12 | env.lib_target_static = env.Library('#/lib/'+env['tolua_lib']+'_static', sources) 13 | 14 | if env['shared']: 15 | env.lib_target = env.SharedLibrary('#lib/'+env['tolua_lib'], sources) 16 | else: 17 | env.lib_target = env.Library('#/lib/'+env['tolua_lib'], sources) 18 | 19 | -------------------------------------------------------------------------------- /src/libtolua/libtolua_module.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | tolua_typename 3 | tolua_error 4 | tolua_isnoobj 5 | tolua_isvalue 6 | tolua_isvaluenil 7 | tolua_isboolean 8 | tolua_isnumber 9 | tolua_isinteger 10 | tolua_isstring 11 | tolua_istable 12 | tolua_isusertable 13 | tolua_isuserdata 14 | tolua_isusertype 15 | tolua_isvaluearray 16 | tolua_isbooleanarray 17 | tolua_isnumberarray 18 | tolua_isstringarray 19 | tolua_istablearray 20 | tolua_isuserdataarray 21 | tolua_isusertypearray 22 | tolua_open 23 | tolua_copy 24 | tolua_register_gc 25 | tolua_default_collect 26 | tolua_usertype 27 | tolua_beginmodule 28 | tolua_endmodule 29 | tolua_module 30 | tolua_cclass 31 | tolua_function 32 | tolua_constant 33 | tolua_variable 34 | tolua_array 35 | tolua_pushvalue 36 | tolua_pushboolean 37 | tolua_pushnumber 38 | tolua_pushinteger 39 | tolua_pushstring 40 | tolua_pushlstring 41 | tolua_pushuserdata 42 | tolua_pushusertype 43 | tolua_pushusertype_and_takeownership 44 | tolua_pushfieldvalue 45 | tolua_pushfieldboolean 46 | tolua_pushfieldnumber 47 | tolua_pushfieldstring 48 | tolua_pushfielduserdata 49 | tolua_pushfieldusertype 50 | tolua_pushfieldusertype_and_takeownership 51 | tolua_tonumber 52 | tolua_tointeger 53 | tolua_tostring 54 | tolua_tolstring 55 | tolua_tofieldlstring 56 | tolua_touserdata 57 | tolua_tousertype 58 | tolua_tovalue 59 | tolua_toboolean 60 | tolua_tofieldnumber 61 | tolua_tofieldstring 62 | tolua_tofielduserdata 63 | tolua_tofieldusertype 64 | tolua_tofieldvalue 65 | tolua_getfieldboolean 66 | tolua_dobuffer 67 | class_gc_event 68 | tolua_fast_isa 69 | -------------------------------------------------------------------------------- /src/libtolua/tolua_event.h: -------------------------------------------------------------------------------- 1 | /* tolua: event functions 2 | ** Support code for Lua bindings. 3 | ** Written by Waldemar Celes 4 | ** TeCGraf/PUC-Rio 5 | ** Apr 2003 6 | ** $Id: $ 7 | */ 8 | 9 | /* This code is free software; you can redistribute it and/or modify it. 10 | ** The software provided hereunder is on an "as is" basis, and 11 | ** the author has no obligation to provide maintenance, support, updates, 12 | ** enhancements, or modifications. 13 | */ 14 | 15 | #ifndef TOLUA_EVENT_H 16 | #define TOLUA_EVENT_H 17 | 18 | #include "tolua++.h" 19 | 20 | TOLUA_API void tolua_moduleevents( lua_State* L ); 21 | TOLUA_API int tolua_ismodulemetatable( lua_State* L ); 22 | TOLUA_API void tolua_classevents( lua_State* L ); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/lua51/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 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 "lobject.h" 12 | 13 | 14 | LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /src/lua51/lcode.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Code generator for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lcode_h 8 | #define lcode_h 9 | 10 | #include "llex.h" 11 | #include "lobject.h" 12 | #include "lopcodes.h" 13 | #include "lparser.h" 14 | 15 | 16 | /* 17 | ** Marks the end of a patch list. It is an invalid value both as an absolute 18 | ** address, and as a list link (would link an element to itself). 19 | */ 20 | #define NO_JUMP (-1) 21 | 22 | 23 | /* 24 | ** grep "ORDER OPR" if you change these enums 25 | */ 26 | typedef enum BinOpr { 27 | OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW, 28 | OPR_CONCAT, 29 | OPR_NE, OPR_EQ, 30 | OPR_LT, OPR_LE, OPR_GT, OPR_GE, 31 | OPR_AND, OPR_OR, 32 | OPR_NOBINOPR 33 | } BinOpr; 34 | 35 | 36 | typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; 37 | 38 | 39 | #define getcode(fs,e) ((fs)->f->code[(e)->u.s.info]) 40 | 41 | #define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) 42 | 43 | #define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET) 44 | 45 | LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); 46 | LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); 47 | LUAI_FUNC void luaK_fixline (FuncState *fs, int line); 48 | LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); 49 | LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); 50 | LUAI_FUNC void luaK_checkstack (FuncState *fs, int n); 51 | LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s); 52 | LUAI_FUNC int luaK_numberK (FuncState *fs, lua_Number r); 53 | LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e); 54 | LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e); 55 | LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); 56 | LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); 57 | LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e); 58 | LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); 59 | LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); 60 | LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); 61 | LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e); 62 | LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults); 63 | LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e); 64 | LUAI_FUNC int luaK_jump (FuncState *fs); 65 | LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret); 66 | LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target); 67 | LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list); 68 | LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2); 69 | LUAI_FUNC int luaK_getlabel (FuncState *fs); 70 | LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v); 71 | LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v); 72 | LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, expdesc *v2); 73 | LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore); 74 | 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /src/lua51/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 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 getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) 17 | 18 | #define resethookcount(L) (L->hookcount = L->basehookcount) 19 | 20 | 21 | LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o, 22 | const char *opname); 23 | LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2); 24 | LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1, 25 | const TValue *p2); 26 | LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1, 27 | const TValue *p2); 28 | LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...); 29 | LUAI_FUNC void luaG_errormsg (lua_State *L); 30 | LUAI_FUNC int luaG_checkcode (const Proto *pt); 31 | LUAI_FUNC int luaG_checkopenop (Instruction i); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/lua51/ldo.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 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) \ 17 | if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \ 18 | luaD_growstack(L, n); \ 19 | else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); 20 | 21 | 22 | #define incr_top(L) {luaD_checkstack(L,1); L->top++;} 23 | 24 | #define savestack(L,p) ((char *)(p) - (char *)L->stack) 25 | #define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) 26 | 27 | #define saveci(L,p) ((char *)(p) - (char *)L->base_ci) 28 | #define restoreci(L,n) ((CallInfo *)((char *)L->base_ci + (n))) 29 | 30 | 31 | /* results from luaD_precall */ 32 | #define PCRLUA 0 /* initiated a call to a Lua function */ 33 | #define PCRC 1 /* did a call to a C function */ 34 | #define PCRYIELD 2 /* C funtion yielded */ 35 | 36 | 37 | /* type of protected functions, to be ran by `runprotected' */ 38 | typedef void (*Pfunc) (lua_State *L, void *ud); 39 | 40 | LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name); 41 | LUAI_FUNC void luaD_callhook (lua_State *L, int event, int line); 42 | LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); 43 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); 44 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, 45 | ptrdiff_t oldtop, ptrdiff_t ef); 46 | LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult); 47 | LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize); 48 | LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); 49 | LUAI_FUNC void luaD_growstack (lua_State *L, int n); 50 | 51 | LUAI_FUNC void luaD_throw (lua_State *L, int errcode); 52 | LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); 53 | 54 | LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop); 55 | 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /src/lua51/ldump.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldump.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** save precompiled Lua chunks 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #include 8 | 9 | #define ldump_c 10 | #define LUA_CORE 11 | 12 | #include "lua.h" 13 | 14 | #include "lobject.h" 15 | #include "lstate.h" 16 | #include "lundump.h" 17 | 18 | typedef struct { 19 | lua_State* L; 20 | lua_Writer writer; 21 | void* data; 22 | int strip; 23 | int status; 24 | } DumpState; 25 | 26 | #define DumpMem(b,n,size,D) DumpBlock(b,(n)*(size),D) 27 | #define DumpVar(x,D) DumpMem(&x,1,sizeof(x),D) 28 | 29 | static void DumpBlock(const void* b, size_t size, DumpState* D) 30 | { 31 | if (D->status==0) 32 | { 33 | lua_unlock(D->L); 34 | D->status=(*D->writer)(D->L,b,size,D->data); 35 | lua_lock(D->L); 36 | } 37 | } 38 | 39 | static void DumpChar(int y, DumpState* D) 40 | { 41 | char x=(char)y; 42 | DumpVar(x,D); 43 | } 44 | 45 | static void DumpInt(int x, DumpState* D) 46 | { 47 | DumpVar(x,D); 48 | } 49 | 50 | static void DumpNumber(lua_Number x, DumpState* D) 51 | { 52 | DumpVar(x,D); 53 | } 54 | 55 | static void DumpVector(const void* b, int n, size_t size, DumpState* D) 56 | { 57 | DumpInt(n,D); 58 | DumpMem(b,n,size,D); 59 | } 60 | 61 | static void DumpString(const TString* s, DumpState* D) 62 | { 63 | if (s==NULL || getstr(s)==NULL) 64 | { 65 | size_t size=0; 66 | DumpVar(size,D); 67 | } 68 | else 69 | { 70 | size_t size=s->tsv.len+1; /* include trailing '\0' */ 71 | DumpVar(size,D); 72 | DumpBlock(getstr(s),size,D); 73 | } 74 | } 75 | 76 | #define DumpCode(f,D) DumpVector(f->code,f->sizecode,sizeof(Instruction),D) 77 | 78 | static void DumpFunction(const Proto* f, const TString* p, DumpState* D); 79 | 80 | static void DumpConstants(const Proto* f, DumpState* D) 81 | { 82 | int i,n=f->sizek; 83 | DumpInt(n,D); 84 | for (i=0; ik[i]; 87 | DumpChar(ttype(o),D); 88 | switch (ttype(o)) 89 | { 90 | case LUA_TNIL: 91 | break; 92 | case LUA_TBOOLEAN: 93 | DumpChar(bvalue(o),D); 94 | break; 95 | case LUA_TNUMBER: 96 | DumpNumber(nvalue(o),D); 97 | break; 98 | case LUA_TSTRING: 99 | DumpString(rawtsvalue(o),D); 100 | break; 101 | default: 102 | lua_assert(0); /* cannot happen */ 103 | break; 104 | } 105 | } 106 | n=f->sizep; 107 | DumpInt(n,D); 108 | for (i=0; ip[i],f->source,D); 109 | } 110 | 111 | static void DumpDebug(const Proto* f, DumpState* D) 112 | { 113 | int i,n; 114 | n= (D->strip) ? 0 : f->sizelineinfo; 115 | DumpVector(f->lineinfo,n,sizeof(int),D); 116 | n= (D->strip) ? 0 : f->sizelocvars; 117 | DumpInt(n,D); 118 | for (i=0; ilocvars[i].varname,D); 121 | DumpInt(f->locvars[i].startpc,D); 122 | DumpInt(f->locvars[i].endpc,D); 123 | } 124 | n= (D->strip) ? 0 : f->sizeupvalues; 125 | DumpInt(n,D); 126 | for (i=0; iupvalues[i],D); 127 | } 128 | 129 | static void DumpFunction(const Proto* f, const TString* p, DumpState* D) 130 | { 131 | DumpString((f->source==p || D->strip) ? NULL : f->source,D); 132 | DumpInt(f->linedefined,D); 133 | DumpInt(f->lastlinedefined,D); 134 | DumpChar(f->nups,D); 135 | DumpChar(f->numparams,D); 136 | DumpChar(f->is_vararg,D); 137 | DumpChar(f->maxstacksize,D); 138 | DumpCode(f,D); 139 | DumpConstants(f,D); 140 | DumpDebug(f,D); 141 | } 142 | 143 | static void DumpHeader(DumpState* D) 144 | { 145 | char h[LUAC_HEADERSIZE]; 146 | luaU_header(h); 147 | DumpBlock(h,LUAC_HEADERSIZE,D); 148 | } 149 | 150 | /* 151 | ** dump Lua function as precompiled chunk 152 | */ 153 | int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip) 154 | { 155 | DumpState D; 156 | D.L=L; 157 | D.writer=w; 158 | D.data=data; 159 | D.strip=strip; 160 | D.status=0; 161 | DumpHeader(&D); 162 | DumpFunction(f,NULL,&D); 163 | return D.status; 164 | } 165 | -------------------------------------------------------------------------------- /src/lua51/lfunc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 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 | LUAI_FUNC Proto *luaF_newproto (lua_State *L); 22 | LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e); 23 | LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e); 24 | LUAI_FUNC UpVal *luaF_newupval (lua_State *L); 25 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); 26 | LUAI_FUNC void luaF_close (lua_State *L, StkId level); 27 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); 28 | LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c); 29 | LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv); 30 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, 31 | int pc); 32 | 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/lua51/lgc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Garbage Collector 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lgc_h 8 | #define lgc_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | /* 15 | ** Possible states of the Garbage Collector 16 | */ 17 | #define GCSpause 0 18 | #define GCSpropagate 1 19 | #define GCSsweepstring 2 20 | #define GCSsweep 3 21 | #define GCSfinalize 4 22 | 23 | 24 | /* 25 | ** some userful bit tricks 26 | */ 27 | #define resetbits(x,m) ((x) &= cast(lu_byte, ~(m))) 28 | #define setbits(x,m) ((x) |= (m)) 29 | #define testbits(x,m) ((x) & (m)) 30 | #define bitmask(b) (1<<(b)) 31 | #define bit2mask(b1,b2) (bitmask(b1) | bitmask(b2)) 32 | #define l_setbit(x,b) setbits(x, bitmask(b)) 33 | #define resetbit(x,b) resetbits(x, bitmask(b)) 34 | #define testbit(x,b) testbits(x, bitmask(b)) 35 | #define set2bits(x,b1,b2) setbits(x, (bit2mask(b1, b2))) 36 | #define reset2bits(x,b1,b2) resetbits(x, (bit2mask(b1, b2))) 37 | #define test2bits(x,b1,b2) testbits(x, (bit2mask(b1, b2))) 38 | 39 | 40 | 41 | /* 42 | ** Layout for bit use in `marked' field: 43 | ** bit 0 - object is white (type 0) 44 | ** bit 1 - object is white (type 1) 45 | ** bit 2 - object is black 46 | ** bit 3 - for userdata: has been finalized 47 | ** bit 3 - for tables: has weak keys 48 | ** bit 4 - for tables: has weak values 49 | ** bit 5 - object is fixed (should not be collected) 50 | ** bit 6 - object is "super" fixed (only the main thread) 51 | */ 52 | 53 | 54 | #define WHITE0BIT 0 55 | #define WHITE1BIT 1 56 | #define BLACKBIT 2 57 | #define FINALIZEDBIT 3 58 | #define KEYWEAKBIT 3 59 | #define VALUEWEAKBIT 4 60 | #define FIXEDBIT 5 61 | #define SFIXEDBIT 6 62 | #define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) 63 | 64 | 65 | #define iswhite(x) test2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) 66 | #define isblack(x) testbit((x)->gch.marked, BLACKBIT) 67 | #define isgray(x) (!isblack(x) && !iswhite(x)) 68 | 69 | #define otherwhite(g) (g->currentwhite ^ WHITEBITS) 70 | #define isdead(g,v) ((v)->gch.marked & otherwhite(g) & WHITEBITS) 71 | 72 | #define changewhite(x) ((x)->gch.marked ^= WHITEBITS) 73 | #define gray2black(x) l_setbit((x)->gch.marked, BLACKBIT) 74 | 75 | #define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x))) 76 | 77 | #define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS) 78 | 79 | 80 | #define luaC_checkGC(L) { \ 81 | condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); \ 82 | if (G(L)->totalbytes >= G(L)->GCthreshold) \ 83 | luaC_step(L); } 84 | 85 | 86 | #define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \ 87 | luaC_barrierf(L,obj2gco(p),gcvalue(v)); } 88 | 89 | #define luaC_barriert(L,t,v) { if (valiswhite(v) && isblack(obj2gco(t))) \ 90 | luaC_barrierback(L,t); } 91 | 92 | #define luaC_objbarrier(L,p,o) \ 93 | { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \ 94 | luaC_barrierf(L,obj2gco(p),obj2gco(o)); } 95 | 96 | #define luaC_objbarriert(L,t,o) \ 97 | { if (iswhite(obj2gco(o)) && isblack(obj2gco(t))) luaC_barrierback(L,t); } 98 | 99 | LUAI_FUNC size_t luaC_separateudata (lua_State *L, int all); 100 | LUAI_FUNC void luaC_callGCTM (lua_State *L); 101 | LUAI_FUNC void luaC_freeall (lua_State *L); 102 | LUAI_FUNC void luaC_step (lua_State *L); 103 | LUAI_FUNC void luaC_fullgc (lua_State *L); 104 | LUAI_FUNC void luaC_link (lua_State *L, GCObject *o, lu_byte tt); 105 | LUAI_FUNC void luaC_linkupval (lua_State *L, UpVal *uv); 106 | LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v); 107 | LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t); 108 | 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /src/lua51/linit.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Initialization of libraries for lua.c 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #define linit_c 9 | #define LUA_LIB 10 | 11 | #include "lua.h" 12 | 13 | #include "lualib.h" 14 | #include "lauxlib.h" 15 | 16 | 17 | static const luaL_Reg lualibs[] = { 18 | {"", luaopen_base}, 19 | {LUA_LOADLIBNAME, luaopen_package}, 20 | {LUA_TABLIBNAME, luaopen_table}, 21 | {LUA_IOLIBNAME, luaopen_io}, 22 | {LUA_OSLIBNAME, luaopen_os}, 23 | {LUA_STRLIBNAME, luaopen_string}, 24 | {LUA_MATHLIBNAME, luaopen_math}, 25 | {LUA_DBLIBNAME, luaopen_debug}, 26 | {NULL, NULL} 27 | }; 28 | 29 | 30 | LUALIB_API void luaL_openlibs (lua_State *L) { 31 | const luaL_Reg *lib = lualibs; 32 | for (; lib->func; lib++) { 33 | lua_pushcfunction(L, lib->func); 34 | lua_pushstring(L, lib->name); 35 | lua_call(L, 1, 0); 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/lua51/llex.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Lexical Analyzer 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef llex_h 8 | #define llex_h 9 | 10 | #include "lobject.h" 11 | #include "lzio.h" 12 | 13 | 14 | #define FIRST_RESERVED 257 15 | 16 | /* maximum length of a reserved word */ 17 | #define TOKEN_LEN (sizeof("function")/sizeof(char)) 18 | 19 | 20 | /* 21 | * WARNING: if you change the order of this enumeration, 22 | * grep "ORDER RESERVED" 23 | */ 24 | enum RESERVED { 25 | /* terminal symbols denoted by reserved words */ 26 | TK_AND = FIRST_RESERVED, TK_BREAK, 27 | TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, 28 | TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, 29 | TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, 30 | /* other terminal symbols */ 31 | TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER, 32 | TK_NAME, TK_STRING, TK_EOS 33 | }; 34 | 35 | /* number of reserved words */ 36 | #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) 37 | 38 | 39 | /* array with token `names' */ 40 | LUAI_DATA const char *const luaX_tokens []; 41 | 42 | 43 | typedef union { 44 | lua_Number r; 45 | TString *ts; 46 | } SemInfo; /* semantics information */ 47 | 48 | 49 | typedef struct Token { 50 | int token; 51 | SemInfo seminfo; 52 | } Token; 53 | 54 | 55 | typedef struct LexState { 56 | int current; /* current character (charint) */ 57 | int linenumber; /* input line counter */ 58 | int lastline; /* line of last token `consumed' */ 59 | Token t; /* current token */ 60 | Token lookahead; /* look ahead token */ 61 | struct FuncState *fs; /* `FuncState' is private to the parser */ 62 | struct lua_State *L; 63 | ZIO *z; /* input stream */ 64 | Mbuffer *buff; /* buffer for tokens */ 65 | TString *source; /* current source name */ 66 | char decpoint; /* locale decimal point */ 67 | } LexState; 68 | 69 | 70 | LUAI_FUNC void luaX_init (lua_State *L); 71 | LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, 72 | TString *source); 73 | LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); 74 | LUAI_FUNC void luaX_next (LexState *ls); 75 | LUAI_FUNC void luaX_lookahead (LexState *ls); 76 | LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token); 77 | LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s); 78 | LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); 79 | 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /src/lua51/llimits.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Limits, basic types, and some other `installation-dependent' definitions 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef llimits_h 8 | #define llimits_h 9 | 10 | 11 | #include 12 | #include 13 | 14 | 15 | #include "lua.h" 16 | 17 | 18 | typedef LUAI_UINT32 lu_int32; 19 | 20 | typedef LUAI_UMEM lu_mem; 21 | 22 | typedef LUAI_MEM l_mem; 23 | 24 | 25 | 26 | /* chars used as small naturals (so that `char' is reserved for characters) */ 27 | typedef unsigned char lu_byte; 28 | 29 | 30 | #define MAX_SIZET ((size_t)(~(size_t)0)-2) 31 | 32 | #define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2) 33 | 34 | 35 | #define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */ 36 | 37 | /* 38 | ** conversion of pointer to integer 39 | ** this is for hashing only; there is no problem if the integer 40 | ** cannot hold the whole pointer value 41 | */ 42 | #define IntPoint(p) ((unsigned int)(lu_mem)(p)) 43 | 44 | 45 | 46 | /* type to ensure maximum alignment */ 47 | typedef LUAI_USER_ALIGNMENT_T L_Umaxalign; 48 | 49 | 50 | /* result of a `usual argument conversion' over lua_Number */ 51 | typedef LUAI_UACNUMBER l_uacNumber; 52 | 53 | 54 | /* internal assertions for in-house debugging */ 55 | #ifdef lua_assert 56 | 57 | #define check_exp(c,e) (lua_assert(c), (e)) 58 | #define api_check(l,e) lua_assert(e) 59 | 60 | #else 61 | 62 | #define lua_assert(c) ((void)0) 63 | #define check_exp(c,e) (e) 64 | #define api_check luai_apicheck 65 | 66 | #endif 67 | 68 | 69 | #ifndef UNUSED 70 | #define UNUSED(x) ((void)(x)) /* to avoid warnings */ 71 | #endif 72 | 73 | 74 | #ifndef cast 75 | #define cast(t, exp) ((t)(exp)) 76 | #endif 77 | 78 | #define cast_byte(i) cast(lu_byte, (i)) 79 | #define cast_num(i) cast(lua_Number, (i)) 80 | #define cast_int(i) cast(int, (i)) 81 | 82 | 83 | 84 | /* 85 | ** type for virtual-machine instructions 86 | ** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h) 87 | */ 88 | typedef lu_int32 Instruction; 89 | 90 | 91 | 92 | /* maximum stack for a Lua function */ 93 | #define MAXSTACK 250 94 | 95 | 96 | 97 | /* minimum size for the string table (must be power of 2) */ 98 | #ifndef MINSTRTABSIZE 99 | #define MINSTRTABSIZE 32 100 | #endif 101 | 102 | 103 | /* minimum size for string buffer */ 104 | #ifndef LUA_MINBUFFER 105 | #define LUA_MINBUFFER 32 106 | #endif 107 | 108 | 109 | #ifndef lua_lock 110 | #define lua_lock(L) ((void) 0) 111 | #define lua_unlock(L) ((void) 0) 112 | #endif 113 | 114 | #ifndef luai_threadyield 115 | #define luai_threadyield(L) {lua_unlock(L); lua_lock(L);} 116 | #endif 117 | 118 | 119 | /* 120 | ** macro to control inclusion of some hard tests on stack reallocation 121 | */ 122 | #ifndef HARDSTACKTESTS 123 | #define condhardstacktests(x) ((void)0) 124 | #else 125 | #define condhardstacktests(x) x 126 | #endif 127 | 128 | #endif 129 | -------------------------------------------------------------------------------- /src/lua51/lmem.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.c,v 1.70.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #include 9 | 10 | #define lmem_c 11 | #define LUA_CORE 12 | 13 | #include "lua.h" 14 | 15 | #include "ldebug.h" 16 | #include "ldo.h" 17 | #include "lmem.h" 18 | #include "lobject.h" 19 | #include "lstate.h" 20 | 21 | 22 | 23 | /* 24 | ** About the realloc function: 25 | ** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize); 26 | ** (`osize' is the old size, `nsize' is the new size) 27 | ** 28 | ** Lua ensures that (ptr == NULL) iff (osize == 0). 29 | ** 30 | ** * frealloc(ud, NULL, 0, x) creates a new block of size `x' 31 | ** 32 | ** * frealloc(ud, p, x, 0) frees the block `p' 33 | ** (in this specific case, frealloc must return NULL). 34 | ** particularly, frealloc(ud, NULL, 0, 0) does nothing 35 | ** (which is equivalent to free(NULL) in ANSI C) 36 | ** 37 | ** frealloc returns NULL if it cannot create or reallocate the area 38 | ** (any reallocation to an equal or smaller size cannot fail!) 39 | */ 40 | 41 | 42 | 43 | #define MINSIZEARRAY 4 44 | 45 | 46 | void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, 47 | int limit, const char *errormsg) { 48 | void *newblock; 49 | int newsize; 50 | if (*size >= limit/2) { /* cannot double it? */ 51 | if (*size >= limit) /* cannot grow even a little? */ 52 | luaG_runerror(L, errormsg); 53 | newsize = limit; /* still have at least one free place */ 54 | } 55 | else { 56 | newsize = (*size)*2; 57 | if (newsize < MINSIZEARRAY) 58 | newsize = MINSIZEARRAY; /* minimum size */ 59 | } 60 | newblock = luaM_reallocv(L, block, *size, newsize, size_elems); 61 | *size = newsize; /* update only when everything else is OK */ 62 | return newblock; 63 | } 64 | 65 | 66 | void *luaM_toobig (lua_State *L) { 67 | luaG_runerror(L, "memory allocation error: block too big"); 68 | return NULL; /* to avoid warnings */ 69 | } 70 | 71 | 72 | 73 | /* 74 | ** generic allocation routine. 75 | */ 76 | void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { 77 | global_State *g = G(L); 78 | lua_assert((osize == 0) == (block == NULL)); 79 | block = (*g->frealloc)(g->ud, block, osize, nsize); 80 | if (block == NULL && nsize > 0) 81 | luaD_throw(L, LUA_ERRMEM); 82 | lua_assert((nsize == 0) == (block == NULL)); 83 | g->totalbytes = (g->totalbytes - osize) + nsize; 84 | return block; 85 | } 86 | 87 | -------------------------------------------------------------------------------- /src/lua51/lmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lmem_h 8 | #define lmem_h 9 | 10 | 11 | #include 12 | 13 | #include "llimits.h" 14 | #include "lua.h" 15 | 16 | #define MEMERRMSG "not enough memory" 17 | 18 | 19 | #define luaM_reallocv(L,b,on,n,e) \ 20 | ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ 21 | luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \ 22 | luaM_toobig(L)) 23 | 24 | #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) 25 | #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) 26 | #define luaM_freearray(L, b, n, t) luaM_reallocv(L, (b), n, 0, sizeof(t)) 27 | 28 | #define luaM_malloc(L,t) luaM_realloc_(L, NULL, 0, (t)) 29 | #define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) 30 | #define luaM_newvector(L,n,t) \ 31 | cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) 32 | 33 | #define luaM_growvector(L,v,nelems,size,t,limit,e) \ 34 | if ((nelems)+1 > (size)) \ 35 | ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) 36 | 37 | #define luaM_reallocvector(L, v,oldn,n,t) \ 38 | ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) 39 | 40 | 41 | LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, 42 | size_t size); 43 | LUAI_FUNC void *luaM_toobig (lua_State *L); 44 | LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, 45 | size_t size_elem, int limit, 46 | const char *errormsg); 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /src/lua51/lopcodes.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lopcodes.c,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** See Copyright Notice in lua.h 4 | */ 5 | 6 | 7 | #define lopcodes_c 8 | #define LUA_CORE 9 | 10 | 11 | #include "lopcodes.h" 12 | 13 | 14 | /* ORDER OP */ 15 | 16 | const char *const luaP_opnames[NUM_OPCODES+1] = { 17 | "MOVE", 18 | "LOADK", 19 | "LOADBOOL", 20 | "LOADNIL", 21 | "GETUPVAL", 22 | "GETGLOBAL", 23 | "GETTABLE", 24 | "SETGLOBAL", 25 | "SETUPVAL", 26 | "SETTABLE", 27 | "NEWTABLE", 28 | "SELF", 29 | "ADD", 30 | "SUB", 31 | "MUL", 32 | "DIV", 33 | "MOD", 34 | "POW", 35 | "UNM", 36 | "NOT", 37 | "LEN", 38 | "CONCAT", 39 | "JMP", 40 | "EQ", 41 | "LT", 42 | "LE", 43 | "TEST", 44 | "TESTSET", 45 | "CALL", 46 | "TAILCALL", 47 | "RETURN", 48 | "FORLOOP", 49 | "FORPREP", 50 | "TFORLOOP", 51 | "SETLIST", 52 | "CLOSE", 53 | "CLOSURE", 54 | "VARARG", 55 | NULL 56 | }; 57 | 58 | 59 | #define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m)) 60 | 61 | const lu_byte luaP_opmodes[NUM_OPCODES] = { 62 | /* T A B C mode opcode */ 63 | opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */ 64 | ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */ 65 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */ 66 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LOADNIL */ 67 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */ 68 | ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_GETGLOBAL */ 69 | ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */ 70 | ,opmode(0, 0, OpArgK, OpArgN, iABx) /* OP_SETGLOBAL */ 71 | ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */ 72 | ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */ 73 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */ 74 | ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */ 75 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */ 76 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */ 77 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */ 78 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */ 79 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */ 80 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */ 81 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */ 82 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */ 83 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */ 84 | ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */ 85 | ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */ 86 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */ 87 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */ 88 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */ 89 | ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TEST */ 90 | ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */ 91 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */ 92 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */ 93 | ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */ 94 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */ 95 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */ 96 | ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TFORLOOP */ 97 | ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */ 98 | ,opmode(0, 0, OpArgN, OpArgN, iABC) /* OP_CLOSE */ 99 | ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */ 100 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */ 101 | }; 102 | 103 | -------------------------------------------------------------------------------- /src/lua51/lparser.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Lua Parser 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lparser_h 8 | #define lparser_h 9 | 10 | #include "llimits.h" 11 | #include "lobject.h" 12 | #include "lzio.h" 13 | 14 | 15 | /* 16 | ** Expression descriptor 17 | */ 18 | 19 | typedef enum { 20 | VVOID, /* no value */ 21 | VNIL, 22 | VTRUE, 23 | VFALSE, 24 | VK, /* info = index of constant in `k' */ 25 | VKNUM, /* nval = numerical value */ 26 | VLOCAL, /* info = local register */ 27 | VUPVAL, /* info = index of upvalue in `upvalues' */ 28 | VGLOBAL, /* info = index of table; aux = index of global name in `k' */ 29 | VINDEXED, /* info = table register; aux = index register (or `k') */ 30 | VJMP, /* info = instruction pc */ 31 | VRELOCABLE, /* info = instruction pc */ 32 | VNONRELOC, /* info = result register */ 33 | VCALL, /* info = instruction pc */ 34 | VVARARG /* info = instruction pc */ 35 | } expkind; 36 | 37 | typedef struct expdesc { 38 | expkind k; 39 | union { 40 | struct { int info, aux; } s; 41 | lua_Number nval; 42 | } u; 43 | int t; /* patch list of `exit when true' */ 44 | int f; /* patch list of `exit when false' */ 45 | } expdesc; 46 | 47 | 48 | typedef struct upvaldesc { 49 | lu_byte k; 50 | lu_byte info; 51 | } upvaldesc; 52 | 53 | 54 | struct BlockCnt; /* defined in lparser.c */ 55 | 56 | 57 | /* state needed to generate code for a given function */ 58 | typedef struct FuncState { 59 | Proto *f; /* current function header */ 60 | Table *h; /* table to find (and reuse) elements in `k' */ 61 | struct FuncState *prev; /* enclosing function */ 62 | struct LexState *ls; /* lexical state */ 63 | struct lua_State *L; /* copy of the Lua state */ 64 | struct BlockCnt *bl; /* chain of current blocks */ 65 | int pc; /* next position to code (equivalent to `ncode') */ 66 | int lasttarget; /* `pc' of last `jump target' */ 67 | int jpc; /* list of pending jumps to `pc' */ 68 | int freereg; /* first free register */ 69 | int nk; /* number of elements in `k' */ 70 | int np; /* number of elements in `p' */ 71 | short nlocvars; /* number of elements in `locvars' */ 72 | lu_byte nactvar; /* number of active local variables */ 73 | upvaldesc upvalues[LUAI_MAXUPVALUES]; /* upvalues */ 74 | unsigned short actvar[LUAI_MAXVARS]; /* declared-variable stack */ 75 | } FuncState; 76 | 77 | 78 | LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, 79 | const char *name); 80 | 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /src/lua51/lstring.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** String table (keeps all strings handled by Lua) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #include 9 | 10 | #define lstring_c 11 | #define LUA_CORE 12 | 13 | #include "lua.h" 14 | 15 | #include "lmem.h" 16 | #include "lobject.h" 17 | #include "lstate.h" 18 | #include "lstring.h" 19 | 20 | 21 | 22 | void luaS_resize (lua_State *L, int newsize) { 23 | GCObject **newhash; 24 | stringtable *tb; 25 | int i; 26 | if (G(L)->gcstate == GCSsweepstring) 27 | return; /* cannot resize during GC traverse */ 28 | newhash = luaM_newvector(L, newsize, GCObject *); 29 | tb = &G(L)->strt; 30 | for (i=0; isize; i++) { 33 | GCObject *p = tb->hash[i]; 34 | while (p) { /* for each node in the list */ 35 | GCObject *next = p->gch.next; /* save next */ 36 | unsigned int h = gco2ts(p)->hash; 37 | int h1 = lmod(h, newsize); /* new position */ 38 | lua_assert(cast_int(h%newsize) == lmod(h, newsize)); 39 | p->gch.next = newhash[h1]; /* chain it */ 40 | newhash[h1] = p; 41 | p = next; 42 | } 43 | } 44 | luaM_freearray(L, tb->hash, tb->size, TString *); 45 | tb->size = newsize; 46 | tb->hash = newhash; 47 | } 48 | 49 | 50 | static TString *newlstr (lua_State *L, const char *str, size_t l, 51 | unsigned int h) { 52 | TString *ts; 53 | stringtable *tb; 54 | if (l+1 > (MAX_SIZET - sizeof(TString))/sizeof(char)) 55 | luaM_toobig(L); 56 | ts = cast(TString *, luaM_malloc(L, (l+1)*sizeof(char)+sizeof(TString))); 57 | ts->tsv.len = l; 58 | ts->tsv.hash = h; 59 | ts->tsv.marked = luaC_white(G(L)); 60 | ts->tsv.tt = LUA_TSTRING; 61 | ts->tsv.reserved = 0; 62 | memcpy(ts+1, str, l*sizeof(char)); 63 | ((char *)(ts+1))[l] = '\0'; /* ending 0 */ 64 | tb = &G(L)->strt; 65 | h = lmod(h, tb->size); 66 | ts->tsv.next = tb->hash[h]; /* chain new entry */ 67 | tb->hash[h] = obj2gco(ts); 68 | tb->nuse++; 69 | if (tb->nuse > cast(lu_int32, tb->size) && tb->size <= MAX_INT/2) 70 | luaS_resize(L, tb->size*2); /* too crowded */ 71 | return ts; 72 | } 73 | 74 | 75 | TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { 76 | GCObject *o; 77 | unsigned int h = cast(unsigned int, l); /* seed */ 78 | size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */ 79 | size_t l1; 80 | for (l1=l; l1>=step; l1-=step) /* compute hash */ 81 | h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1])); 82 | for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)]; 83 | o != NULL; 84 | o = o->gch.next) { 85 | TString *ts = rawgco2ts(o); 86 | if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) { 87 | /* string may be dead */ 88 | if (isdead(G(L), o)) changewhite(o); 89 | return ts; 90 | } 91 | } 92 | return newlstr(L, str, l, h); /* not found */ 93 | } 94 | 95 | 96 | Udata *luaS_newudata (lua_State *L, size_t s, Table *e) { 97 | Udata *u; 98 | if (s > MAX_SIZET - sizeof(Udata)) 99 | luaM_toobig(L); 100 | u = cast(Udata *, luaM_malloc(L, s + sizeof(Udata))); 101 | u->uv.marked = luaC_white(G(L)); /* is not finalized */ 102 | u->uv.tt = LUA_TUSERDATA; 103 | u->uv.len = s; 104 | u->uv.metatable = NULL; 105 | u->uv.env = e; 106 | /* chain it on udata list (after main thread) */ 107 | u->uv.next = G(L)->mainthread->next; 108 | G(L)->mainthread->next = obj2gco(u); 109 | return u; 110 | } 111 | 112 | -------------------------------------------------------------------------------- /src/lua51/lstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 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 | 11 | #include "lgc.h" 12 | #include "lobject.h" 13 | #include "lstate.h" 14 | 15 | 16 | #define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char)) 17 | 18 | #define sizeudata(u) (sizeof(union Udata)+(u)->len) 19 | 20 | #define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s))) 21 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 22 | (sizeof(s)/sizeof(char))-1)) 23 | 24 | #define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT) 25 | 26 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 27 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); 28 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 29 | 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/lua51/ltable.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 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 gkey(n) (&(n)->i_key.nk) 15 | #define gval(n) (&(n)->i_val) 16 | #define gnext(n) ((n)->i_key.nk.next) 17 | 18 | #define key2tval(n) (&(n)->i_key.tvk) 19 | 20 | 21 | LUAI_FUNC const TValue *luaH_getnum (Table *t, int key); 22 | LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key); 23 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); 24 | LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key); 25 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); 26 | LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); 27 | LUAI_FUNC Table *luaH_new (lua_State *L, int narray, int lnhash); 28 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize); 29 | LUAI_FUNC void luaH_free (lua_State *L, Table *t); 30 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); 31 | LUAI_FUNC int luaH_getn (Table *t); 32 | 33 | 34 | #if defined(LUA_DEBUG) 35 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); 36 | LUAI_FUNC int luaH_isdummy (Node *n); 37 | #endif 38 | 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/lua51/ltm.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Tag methods 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #include 9 | 10 | #define ltm_c 11 | #define LUA_CORE 12 | 13 | #include "lua.h" 14 | 15 | #include "lobject.h" 16 | #include "lstate.h" 17 | #include "lstring.h" 18 | #include "ltable.h" 19 | #include "ltm.h" 20 | 21 | 22 | 23 | const char *const luaT_typenames[] = { 24 | "nil", "boolean", "userdata", "number", 25 | "string", "table", "function", "userdata", "thread", 26 | "proto", "upval" 27 | }; 28 | 29 | 30 | void luaT_init (lua_State *L) { 31 | static const char *const luaT_eventname[] = { /* ORDER TM */ 32 | "__index", "__newindex", 33 | "__gc", "__mode", "__eq", 34 | "__add", "__sub", "__mul", "__div", "__mod", 35 | "__pow", "__unm", "__len", "__lt", "__le", 36 | "__concat", "__call" 37 | }; 38 | int i; 39 | for (i=0; itmname[i] = luaS_new(L, luaT_eventname[i]); 41 | luaS_fix(G(L)->tmname[i]); /* never collect these names */ 42 | } 43 | } 44 | 45 | 46 | /* 47 | ** function to be used with macro "fasttm": optimized for absence of 48 | ** tag methods 49 | */ 50 | const TValue *luaT_gettm (Table *events, TMS event, TString *ename) { 51 | const TValue *tm = luaH_getstr(events, ename); 52 | lua_assert(event <= TM_EQ); 53 | if (ttisnil(tm)) { /* no tag method? */ 54 | events->flags |= cast_byte(1u<metatable; 66 | break; 67 | case LUA_TUSERDATA: 68 | mt = uvalue(o)->metatable; 69 | break; 70 | default: 71 | mt = G(L)->mt[ttype(o)]; 72 | } 73 | return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject); 74 | } 75 | 76 | -------------------------------------------------------------------------------- /src/lua51/ltm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 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" 17 | */ 18 | typedef enum { 19 | TM_INDEX, 20 | TM_NEWINDEX, 21 | TM_GC, 22 | TM_MODE, 23 | TM_EQ, /* last tag method with `fast' access */ 24 | TM_ADD, 25 | TM_SUB, 26 | TM_MUL, 27 | TM_DIV, 28 | TM_MOD, 29 | TM_POW, 30 | TM_UNM, 31 | TM_LEN, 32 | TM_LT, 33 | TM_LE, 34 | TM_CONCAT, 35 | TM_CALL, 36 | TM_N /* number of elements in the enum */ 37 | } TMS; 38 | 39 | 40 | 41 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \ 42 | ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) 43 | 44 | #define fasttm(l,et,e) gfasttm(G(l), et, e) 45 | 46 | LUAI_DATA const char *const luaT_typenames[]; 47 | 48 | 49 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); 50 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, 51 | TMS event); 52 | LUAI_FUNC void luaT_init (lua_State *L); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/lua51/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 | -------------------------------------------------------------------------------- /src/lua51/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 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 | /* Key to file-handle type */ 15 | #define LUA_FILEHANDLE "FILE*" 16 | 17 | 18 | #define LUA_COLIBNAME "coroutine" 19 | LUALIB_API int (luaopen_base) (lua_State *L); 20 | 21 | #define LUA_TABLIBNAME "table" 22 | LUALIB_API int (luaopen_table) (lua_State *L); 23 | 24 | #define LUA_IOLIBNAME "io" 25 | LUALIB_API int (luaopen_io) (lua_State *L); 26 | 27 | #define LUA_OSLIBNAME "os" 28 | LUALIB_API int (luaopen_os) (lua_State *L); 29 | 30 | #define LUA_STRLIBNAME "string" 31 | LUALIB_API int (luaopen_string) (lua_State *L); 32 | 33 | #define LUA_MATHLIBNAME "math" 34 | LUALIB_API int (luaopen_math) (lua_State *L); 35 | 36 | #define LUA_DBLIBNAME "debug" 37 | LUALIB_API int (luaopen_debug) (lua_State *L); 38 | 39 | #define LUA_LOADLIBNAME "package" 40 | LUALIB_API int (luaopen_package) (lua_State *L); 41 | 42 | 43 | /* open all previous libraries */ 44 | LUALIB_API void (luaL_openlibs) (lua_State *L); 45 | 46 | 47 | 48 | #ifndef lua_assert 49 | #define lua_assert(x) ((void)0) 50 | #endif 51 | 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/lua51/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 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 "lobject.h" 11 | #include "lzio.h" 12 | 13 | /* load one chunk; from lundump.c */ 14 | LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name); 15 | 16 | /* make header; from lundump.c */ 17 | LUAI_FUNC void luaU_header (char* h); 18 | 19 | /* dump one chunk; from ldump.c */ 20 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); 21 | 22 | #ifdef luac_c 23 | /* print one chunk; from print.c */ 24 | LUAI_FUNC void luaU_print (const Proto* f, int full); 25 | #endif 26 | 27 | /* for header of binary files -- this is Lua 5.1 */ 28 | #define LUAC_VERSION 0x51 29 | 30 | /* for header of binary files -- this is the official format */ 31 | #define LUAC_FORMAT 0 32 | 33 | /* size of header of binary files */ 34 | #define LUAC_HEADERSIZE 12 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/lua51/lvm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 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 | #define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o))) 17 | 18 | #define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \ 19 | (((o) = luaV_tonumber(o,n)) != NULL)) 20 | 21 | #define equalobj(L,o1,o2) \ 22 | (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2)) 23 | 24 | 25 | LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); 26 | LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2); 27 | LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); 28 | LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); 29 | LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, 30 | StkId val); 31 | LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, 32 | StkId val); 33 | LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls); 34 | LUAI_FUNC void luaV_concat (lua_State *L, int total, int last); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/lua51/lzio.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** a generic input stream interface 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #include 9 | 10 | #define lzio_c 11 | #define LUA_CORE 12 | 13 | #include "lua.h" 14 | 15 | #include "llimits.h" 16 | #include "lmem.h" 17 | #include "lstate.h" 18 | #include "lzio.h" 19 | 20 | 21 | int luaZ_fill (ZIO *z) { 22 | size_t size; 23 | lua_State *L = z->L; 24 | const char *buff; 25 | lua_unlock(L); 26 | buff = z->reader(L, z->data, &size); 27 | lua_lock(L); 28 | if (buff == NULL || size == 0) return EOZ; 29 | z->n = size - 1; 30 | z->p = buff; 31 | return char2int(*(z->p++)); 32 | } 33 | 34 | 35 | int luaZ_lookahead (ZIO *z) { 36 | if (z->n == 0) { 37 | if (luaZ_fill(z) == EOZ) 38 | return EOZ; 39 | else { 40 | z->n++; /* luaZ_fill removed first byte; put back it */ 41 | z->p--; 42 | } 43 | } 44 | return char2int(*z->p); 45 | } 46 | 47 | 48 | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { 49 | z->L = L; 50 | z->reader = reader; 51 | z->data = data; 52 | z->n = 0; 53 | z->p = NULL; 54 | } 55 | 56 | 57 | /* --------------------------------------------------------------- read --- */ 58 | size_t luaZ_read (ZIO *z, void *b, size_t n) { 59 | while (n) { 60 | size_t m; 61 | if (luaZ_lookahead(z) == EOZ) 62 | return n; /* return number of missing bytes */ 63 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ 64 | memcpy(b, z->p, m); 65 | z->n -= m; 66 | z->p += m; 67 | b = (char *)b + m; 68 | n -= m; 69 | } 70 | return 0; 71 | } 72 | 73 | /* ------------------------------------------------------------------------ */ 74 | char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) { 75 | if (n > buff->buffsize) { 76 | if (n < LUA_MINBUFFER) n = LUA_MINBUFFER; 77 | luaZ_resizebuffer(L, buff, n); 78 | } 79 | return buff->buffer; 80 | } 81 | 82 | 83 | -------------------------------------------------------------------------------- /src/lua51/lzio.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 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 char2int(c) cast(int, cast(unsigned char, (c))) 21 | 22 | #define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z)) 23 | 24 | typedef struct Mbuffer { 25 | char *buffer; 26 | size_t n; 27 | size_t buffsize; 28 | } Mbuffer; 29 | 30 | #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) 31 | 32 | #define luaZ_buffer(buff) ((buff)->buffer) 33 | #define luaZ_sizebuffer(buff) ((buff)->buffsize) 34 | #define luaZ_bufflen(buff) ((buff)->n) 35 | 36 | #define luaZ_resetbuffer(buff) ((buff)->n = 0) 37 | 38 | 39 | #define luaZ_resizebuffer(L, buff, size) \ 40 | (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \ 41 | (buff)->buffsize = size) 42 | 43 | #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) 44 | 45 | 46 | LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n); 47 | LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, 48 | void *data); 49 | LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */ 50 | LUAI_FUNC int luaZ_lookahead (ZIO *z); 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; 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 | -------------------------------------------------------------------------------- /src/lua53/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h,v 2.9 2015/03/06 19:49: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, 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(L, (n) < (L->top - L->ci->func), \ 21 | "not enough elements in the stack") 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/lua53/lcode.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lcode.h,v 1.64 2016/01/05 16:22:37 roberto Exp $ 3 | ** Code generator for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lcode_h 8 | #define lcode_h 9 | 10 | #include "llex.h" 11 | #include "lobject.h" 12 | #include "lopcodes.h" 13 | #include "lparser.h" 14 | 15 | 16 | /* 17 | ** Marks the end of a patch list. It is an invalid value both as an absolute 18 | ** address, and as a list link (would link an element to itself). 19 | */ 20 | #define NO_JUMP (-1) 21 | 22 | 23 | /* 24 | ** grep "ORDER OPR" if you change these enums (ORDER OP) 25 | */ 26 | typedef enum BinOpr { 27 | OPR_ADD, OPR_SUB, OPR_MUL, OPR_MOD, OPR_POW, 28 | OPR_DIV, 29 | OPR_IDIV, 30 | OPR_BAND, OPR_BOR, OPR_BXOR, 31 | OPR_SHL, OPR_SHR, 32 | OPR_CONCAT, 33 | OPR_EQ, OPR_LT, OPR_LE, 34 | OPR_NE, OPR_GT, OPR_GE, 35 | OPR_AND, OPR_OR, 36 | OPR_NOBINOPR 37 | } BinOpr; 38 | 39 | 40 | typedef enum UnOpr { OPR_MINUS, OPR_BNOT, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; 41 | 42 | 43 | /* get (pointer to) instruction of given 'expdesc' */ 44 | #define getinstruction(fs,e) ((fs)->f->code[(e)->u.info]) 45 | 46 | #define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) 47 | 48 | #define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET) 49 | 50 | #define luaK_jumpto(fs,t) luaK_patchlist(fs, luaK_jump(fs), t) 51 | 52 | LUAI_FUNC int luaK_codeABx( FuncState* fs, OpCode o, int A, unsigned int Bx ); 53 | LUAI_FUNC int luaK_codeABC( FuncState* fs, OpCode o, int A, int B, int C ); 54 | LUAI_FUNC int luaK_codek( FuncState* fs, int reg, int k ); 55 | LUAI_FUNC void luaK_fixline( FuncState* fs, int line ); 56 | LUAI_FUNC void luaK_nil( FuncState* fs, int from, int n ); 57 | LUAI_FUNC void luaK_reserveregs( FuncState* fs, int n ); 58 | LUAI_FUNC void luaK_checkstack( FuncState* fs, int n ); 59 | LUAI_FUNC int luaK_stringK( FuncState* fs, TString* s ); 60 | LUAI_FUNC int luaK_intK( FuncState* fs, lua_Integer n ); 61 | LUAI_FUNC void luaK_dischargevars( FuncState* fs, expdesc* e ); 62 | LUAI_FUNC int luaK_exp2anyreg( FuncState* fs, expdesc* e ); 63 | LUAI_FUNC void luaK_exp2anyregup( FuncState* fs, expdesc* e ); 64 | LUAI_FUNC void luaK_exp2nextreg( FuncState* fs, expdesc* e ); 65 | LUAI_FUNC void luaK_exp2val( FuncState* fs, expdesc* e ); 66 | LUAI_FUNC int luaK_exp2RK( FuncState* fs, expdesc* e ); 67 | LUAI_FUNC void luaK_self( FuncState* fs, expdesc* e, expdesc* key ); 68 | LUAI_FUNC void luaK_indexed( FuncState* fs, expdesc* t, expdesc* k ); 69 | LUAI_FUNC void luaK_goiftrue( FuncState* fs, expdesc* e ); 70 | LUAI_FUNC void luaK_goiffalse( FuncState* fs, expdesc* e ); 71 | LUAI_FUNC void luaK_storevar( FuncState* fs, expdesc* var, expdesc* e ); 72 | LUAI_FUNC void luaK_setreturns( FuncState* fs, expdesc* e, int nresults ); 73 | LUAI_FUNC void luaK_setoneret( FuncState* fs, expdesc* e ); 74 | LUAI_FUNC int luaK_jump( FuncState* fs ); 75 | LUAI_FUNC void luaK_ret( FuncState* fs, int first, int nret ); 76 | LUAI_FUNC void luaK_patchlist( FuncState* fs, int list, int target ); 77 | LUAI_FUNC void luaK_patchtohere( FuncState* fs, int list ); 78 | LUAI_FUNC void luaK_patchclose( FuncState* fs, int list, int level ); 79 | LUAI_FUNC void luaK_concat( FuncState* fs, int* l1, int l2 ); 80 | LUAI_FUNC int luaK_getlabel( FuncState* fs ); 81 | LUAI_FUNC void luaK_prefix( FuncState* fs, UnOpr op, expdesc* v, int line ); 82 | LUAI_FUNC void luaK_infix( FuncState* fs, BinOpr op, expdesc* v ); 83 | LUAI_FUNC void luaK_posfix( FuncState* fs, BinOpr op, expdesc* v1, 84 | expdesc* v2, int line ); 85 | LUAI_FUNC void luaK_setlist( FuncState* fs, int base, int nelems, int tostore ); 86 | 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /src/lua53/lctype.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.c,v 1.12 2014/11/02 19:19:04 roberto Exp $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lctype_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include "lctype.h" 14 | 15 | #if !LUA_USE_CTYPE /* { */ 16 | 17 | #include 18 | 19 | LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = { 20 | 0x00, /* EOZ */ 21 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0. */ 22 | 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 23 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1. */ 24 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 25 | 0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, /* 2. */ 26 | 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 27 | 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, /* 3. */ 28 | 0x16, 0x16, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 29 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 4. */ 30 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 31 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 5. */ 32 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x05, 33 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 6. */ 34 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 35 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 7. */ 36 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00, 37 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8. */ 38 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 39 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9. */ 40 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 41 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a. */ 42 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 43 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b. */ 44 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 45 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c. */ 46 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 47 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d. */ 48 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 49 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* e. */ 50 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 51 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* f. */ 52 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 53 | }; 54 | 55 | #endif /* } */ 56 | -------------------------------------------------------------------------------- /src/lua53/lctype.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.h,v 1.12 2011/07/15 12:50:29 roberto Exp $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lctype_h 8 | #define lctype_h 9 | 10 | #include "lua.h" 11 | 12 | 13 | /* 14 | ** WARNING: the functions defined here do not necessarily correspond 15 | ** to the similar functions in the standard C ctype.h. They are 16 | ** optimized for the specific needs of Lua 17 | */ 18 | 19 | #if !defined(LUA_USE_CTYPE) 20 | 21 | #if 'A' == 65 && '0' == 48 22 | /* ASCII case: can use its own tables; faster and fixed */ 23 | #define LUA_USE_CTYPE 0 24 | #else 25 | /* must use standard C ctype */ 26 | #define LUA_USE_CTYPE 1 27 | #endif 28 | 29 | #endif 30 | 31 | 32 | #if !LUA_USE_CTYPE /* { */ 33 | 34 | #include 35 | 36 | #include "llimits.h" 37 | 38 | 39 | #define ALPHABIT 0 40 | #define DIGITBIT 1 41 | #define PRINTBIT 2 42 | #define SPACEBIT 3 43 | #define XDIGITBIT 4 44 | 45 | 46 | #define MASK(B) (1 << (B)) 47 | 48 | 49 | /* 50 | ** add 1 to char to allow index -1 (EOZ) 51 | */ 52 | #define testprop(c,p) (luai_ctype_[(c)+1] & (p)) 53 | 54 | /* 55 | ** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_' 56 | */ 57 | #define lislalpha(c) testprop(c, MASK(ALPHABIT)) 58 | #define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT))) 59 | #define lisdigit(c) testprop(c, MASK(DIGITBIT)) 60 | #define lisspace(c) testprop(c, MASK(SPACEBIT)) 61 | #define lisprint(c) testprop(c, MASK(PRINTBIT)) 62 | #define lisxdigit(c) testprop(c, MASK(XDIGITBIT)) 63 | 64 | /* 65 | ** this 'ltolower' only works for alphabetic characters 66 | */ 67 | #define ltolower(c) ((c) | ('A' ^ 'a')) 68 | 69 | 70 | /* two more entries for 0 and -1 (EOZ) */ 71 | LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2]; 72 | 73 | 74 | #else /* }{ */ 75 | 76 | /* 77 | ** use standard C ctypes 78 | */ 79 | 80 | #include 81 | 82 | 83 | #define lislalpha(c) (isalpha(c) || (c) == '_') 84 | #define lislalnum(c) (isalnum(c) || (c) == '_') 85 | #define lisdigit(c) (isdigit(c)) 86 | #define lisspace(c) (isspace(c)) 87 | #define lisprint(c) (isprint(c)) 88 | #define lisxdigit(c) (isxdigit(c)) 89 | 90 | #define ltolower(c) (tolower(c)) 91 | 92 | #endif /* } */ 93 | 94 | #endif 95 | 96 | -------------------------------------------------------------------------------- /src/lua53/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h,v 2.14 2015/05/22 17:45:56 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 | 21 | LUAI_FUNC l_noret luaG_typeerror( lua_State* L, const TValue* o, 22 | const char* opname ); 23 | LUAI_FUNC l_noret luaG_concaterror( lua_State* L, const TValue* p1, 24 | const TValue* p2 ); 25 | LUAI_FUNC l_noret luaG_opinterror( lua_State* L, const TValue* p1, 26 | const TValue* p2, 27 | const char* msg ); 28 | LUAI_FUNC l_noret luaG_tointerror( lua_State* L, const TValue* p1, 29 | const TValue* p2 ); 30 | LUAI_FUNC l_noret luaG_ordererror( lua_State* L, const TValue* p1, 31 | const TValue* p2 ); 32 | LUAI_FUNC l_noret luaG_runerror( lua_State* L, const char* fmt, ... ); 33 | LUAI_FUNC const char* luaG_addinfo( lua_State* L, const char* msg, 34 | TString* src, int line ); 35 | LUAI_FUNC l_noret luaG_errormsg( lua_State* L ); 36 | LUAI_FUNC void luaG_traceexec( lua_State* L ); 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/lua53/ldo.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldo.h,v 2.29 2015/12/21 13:02:14 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 | /* 17 | ** Macro to check stack size and grow stack if needed. Parameters 18 | ** 'pre'/'pos' allow the macro to preserve a pointer into the 19 | ** stack across reallocations, doing the work only when needed. 20 | ** 'condmovestack' is used in heavy tests to force a stack reallocation 21 | ** at every check. 22 | */ 23 | #define luaD_checkstackaux(L,n,pre,pos) \ 24 | if (L->stack_last - L->top <= (n)) \ 25 | { pre; luaD_growstack(L, n); pos; } else { condmovestack(L,pre,pos); } 26 | 27 | /* In general, 'pre'/'pos' are empty (nothing to save) */ 28 | #define luaD_checkstack(L,n) luaD_checkstackaux(L,n,(void)0,(void)0) 29 | 30 | 31 | 32 | #define savestack(L,p) ((char *)(p) - (char *)L->stack) 33 | #define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) 34 | 35 | 36 | /* type of protected functions, to be ran by 'runprotected' */ 37 | typedef void ( *Pfunc )( lua_State* L, void* ud ); 38 | 39 | LUAI_FUNC int luaD_protectedparser( lua_State* L, ZIO* z, const char* name, 40 | const char* mode ); 41 | LUAI_FUNC void luaD_hook( lua_State* L, int event, int line ); 42 | LUAI_FUNC int luaD_precall( lua_State* L, StkId func, int nresults ); 43 | LUAI_FUNC void luaD_call( lua_State* L, StkId func, int nResults ); 44 | LUAI_FUNC void luaD_callnoyield( lua_State* L, StkId func, int nResults ); 45 | LUAI_FUNC int luaD_pcall( lua_State* L, Pfunc func, void* u, 46 | ptrdiff_t oldtop, ptrdiff_t ef ); 47 | LUAI_FUNC int luaD_poscall( lua_State* L, CallInfo* ci, StkId firstResult, 48 | int nres ); 49 | LUAI_FUNC void luaD_reallocstack( lua_State* L, int newsize ); 50 | LUAI_FUNC void luaD_growstack( lua_State* L, int n ); 51 | LUAI_FUNC void luaD_shrinkstack( lua_State* L ); 52 | LUAI_FUNC void luaD_inctop( lua_State* L ); 53 | 54 | LUAI_FUNC l_noret luaD_throw( lua_State* L, int errcode ); 55 | LUAI_FUNC int luaD_rawrunprotected( lua_State* L, Pfunc f, void* ud ); 56 | 57 | #endif 58 | 59 | -------------------------------------------------------------------------------- /src/lua53/lfunc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lfunc.h,v 2.15 2015/01/13 15:49:11 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 | ** maximum number of upvalues in a closure (both C and Lua). (Value 27 | ** must fit in a VM register.) 28 | */ 29 | #define MAXUPVAL 255 30 | 31 | 32 | /* 33 | ** Upvalues for Lua closures 34 | */ 35 | struct UpVal { 36 | TValue* v; /* points to stack or to its own value */ 37 | lu_mem refcount; /* reference counter */ 38 | union { 39 | struct { /* (when open) */ 40 | UpVal* next; /* linked list */ 41 | int touched; /* mark to avoid cycles with dead threads */ 42 | } open; 43 | TValue value; /* the value (when closed) */ 44 | } u; 45 | }; 46 | 47 | #define upisopen(up) ((up)->v != &(up)->u.value) 48 | 49 | 50 | LUAI_FUNC Proto* luaF_newproto( lua_State* L ); 51 | LUAI_FUNC CClosure* luaF_newCclosure( lua_State* L, int nelems ); 52 | LUAI_FUNC LClosure* luaF_newLclosure( lua_State* L, int nelems ); 53 | LUAI_FUNC void luaF_initupvals( lua_State* L, LClosure* cl ); 54 | LUAI_FUNC UpVal* luaF_findupval( lua_State* L, StkId level ); 55 | LUAI_FUNC void luaF_close( lua_State* L, StkId level ); 56 | LUAI_FUNC void luaF_freeproto( lua_State* L, Proto* f ); 57 | LUAI_FUNC const char* luaF_getlocalname( const Proto* func, int local_number, 58 | int pc ); 59 | 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/lua53/linit.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: linit.c,v 1.39 2016/12/04 20:17:24 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, LUA_PRELOAD_TABLE); 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 | 63 | /* "require" functions from 'loadedlibs' and set results to global table */ 64 | for ( lib = loadedlibs; lib->func; lib++ ) { 65 | luaL_requiref( L, lib->name, lib->func, 1 ); 66 | lua_pop( L, 1 ); /* remove lib */ 67 | } 68 | } 69 | 70 | -------------------------------------------------------------------------------- /src/lua53/llex.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: llex.h,v 1.79 2016/05/02 14:02:12 roberto Exp $ 3 | ** Lexical Analyzer 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef llex_h 8 | #define llex_h 9 | 10 | #include "lobject.h" 11 | #include "lzio.h" 12 | 13 | 14 | #define FIRST_RESERVED 257 15 | 16 | 17 | #if !defined(LUA_ENV) 18 | #define LUA_ENV "_ENV" 19 | #endif 20 | 21 | 22 | /* 23 | * WARNING: if you change the order of this enumeration, 24 | * grep "ORDER RESERVED" 25 | */ 26 | enum RESERVED { 27 | /* terminal symbols denoted by reserved words */ 28 | TK_AND = FIRST_RESERVED, TK_BREAK, 29 | TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, 30 | TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, 31 | TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, 32 | /* other terminal symbols */ 33 | TK_IDIV, TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, 34 | TK_SHL, TK_SHR, 35 | TK_DBCOLON, TK_EOS, 36 | TK_FLT, TK_INT, TK_NAME, TK_STRING 37 | }; 38 | 39 | /* number of reserved words */ 40 | #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) 41 | 42 | 43 | typedef union { 44 | lua_Number r; 45 | lua_Integer i; 46 | TString* ts; 47 | } SemInfo; /* semantics information */ 48 | 49 | 50 | typedef struct Token { 51 | int token; 52 | SemInfo seminfo; 53 | } Token; 54 | 55 | 56 | /* state of the lexer plus state of the parser when shared by all 57 | functions */ 58 | typedef struct LexState { 59 | int current; /* current character (charint) */ 60 | int linenumber; /* input line counter */ 61 | int lastline; /* line of last token 'consumed' */ 62 | Token t; /* current token */ 63 | Token lookahead; /* look ahead token */ 64 | struct FuncState* fs; /* current function (parser) */ 65 | struct lua_State* L; 66 | ZIO* z; /* input stream */ 67 | Mbuffer* buff; /* buffer for tokens */ 68 | Table* h; /* to avoid collection/reuse strings */ 69 | struct Dyndata* dyd; /* dynamic structures used by the parser */ 70 | TString* source; /* current source name */ 71 | TString* envn; /* environment variable name */ 72 | } LexState; 73 | 74 | 75 | LUAI_FUNC void luaX_init( lua_State* L ); 76 | LUAI_FUNC void luaX_setinput( lua_State* L, LexState* ls, ZIO* z, 77 | TString* source, int firstchar ); 78 | LUAI_FUNC TString* luaX_newstring( LexState* ls, const char* str, size_t l ); 79 | LUAI_FUNC void luaX_next( LexState* ls ); 80 | LUAI_FUNC int luaX_lookahead( LexState* ls ); 81 | LUAI_FUNC l_noret luaX_syntaxerror( LexState* ls, const char* s ); 82 | LUAI_FUNC const char* luaX_token2str( LexState* ls, int token ); 83 | 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /src/lua53/lmem.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.c,v 1.91 2015/03/06 19:45:54 roberto Exp $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lmem_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | #include "ldebug.h" 18 | #include "ldo.h" 19 | #include "lgc.h" 20 | #include "lmem.h" 21 | #include "lobject.h" 22 | #include "lstate.h" 23 | 24 | 25 | 26 | /* 27 | ** About the realloc function: 28 | ** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize); 29 | ** ('osize' is the old size, 'nsize' is the new size) 30 | ** 31 | ** * frealloc(ud, NULL, x, s) creates a new block of size 's' (no 32 | ** matter 'x'). 33 | ** 34 | ** * frealloc(ud, p, x, 0) frees the block 'p' 35 | ** (in this specific case, frealloc must return NULL); 36 | ** particularly, frealloc(ud, NULL, 0, 0) does nothing 37 | ** (which is equivalent to free(NULL) in ISO C) 38 | ** 39 | ** frealloc returns NULL if it cannot create or reallocate the area 40 | ** (any reallocation to an equal or smaller size cannot fail!) 41 | */ 42 | 43 | 44 | 45 | #define MINSIZEARRAY 4 46 | 47 | 48 | void* luaM_growaux_( lua_State* L, void* block, int* size, size_t size_elems, 49 | int limit, const char* what ) { 50 | void* newblock; 51 | int newsize; 52 | 53 | if ( *size >= limit / 2 ) { /* cannot double it? */ 54 | if ( *size >= limit ) { /* cannot grow even a little? */ 55 | luaG_runerror( L, "too many %s (limit is %d)", what, limit ); 56 | } 57 | 58 | newsize = limit; /* still have at least one free place */ 59 | } 60 | else { 61 | newsize = ( *size ) * 2; 62 | 63 | if ( newsize < MINSIZEARRAY ) { 64 | newsize = MINSIZEARRAY; /* minimum size */ 65 | } 66 | } 67 | 68 | newblock = luaM_reallocv( L, block, *size, newsize, size_elems ); 69 | *size = newsize; /* update only when everything else is OK */ 70 | return newblock; 71 | } 72 | 73 | 74 | l_noret luaM_toobig( lua_State* L ) { 75 | luaG_runerror( L, "memory allocation error: block too big" ); 76 | } 77 | 78 | 79 | 80 | /* 81 | ** generic allocation routine. 82 | */ 83 | void* luaM_realloc_( lua_State* L, void* block, size_t osize, size_t nsize ) { 84 | void* newblock; 85 | global_State* g = G( L ); 86 | size_t realosize = ( block ) ? osize : 0; 87 | lua_assert( ( realosize == 0 ) == ( block == NULL ) ); 88 | #if defined(HARDMEMTESTS) 89 | 90 | if ( nsize > realosize && g->gcrunning ) { 91 | luaC_fullgc( L, 1 ); /* force a GC whenever possible */ 92 | } 93 | 94 | #endif 95 | newblock = ( *g->frealloc )( g->ud, block, osize, nsize ); 96 | 97 | if ( newblock == NULL && nsize > 0 ) { 98 | lua_assert( nsize > realosize ); /* cannot fail when shrinking a block */ 99 | 100 | if ( g->version ) { /* is state fully built? */ 101 | luaC_fullgc( L, 1 ); /* try to free some memory... */ 102 | newblock = ( *g->frealloc )( g->ud, block, osize, nsize ); /* try again */ 103 | } 104 | 105 | if ( newblock == NULL ) { 106 | luaD_throw( L, LUA_ERRMEM ); 107 | } 108 | } 109 | 110 | lua_assert( ( nsize == 0 ) == ( newblock == NULL ) ); 111 | g->GCdebt = ( g->GCdebt + nsize ) - realosize; 112 | return newblock; 113 | } 114 | 115 | -------------------------------------------------------------------------------- /src/lua53/lmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.h,v 1.43 2014/12/19 17:26:14 roberto Exp $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lmem_h 8 | #define lmem_h 9 | 10 | 11 | #include 12 | 13 | #include "llimits.h" 14 | #include "lua.h" 15 | 16 | 17 | /* 18 | ** This macro reallocs a vector 'b' from 'on' to 'n' elements, where 19 | ** each element has size 'e'. In case of arithmetic overflow of the 20 | ** product 'n'*'e', it raises an error (calling 'luaM_toobig'). Because 21 | ** 'e' is always constant, it avoids the runtime division MAX_SIZET/(e). 22 | ** 23 | ** (The macro is somewhat complex to avoid warnings: The 'sizeof' 24 | ** comparison avoids a runtime comparison when overflow cannot occur. 25 | ** The compiler should be able to optimize the real test by itself, but 26 | ** when it does it, it may give a warning about "comparison is always 27 | ** false due to limited range of data type"; the +1 tricks the compiler, 28 | ** avoiding this warning but also this optimization.) 29 | */ 30 | #define luaM_reallocv(L,b,on,n,e) \ 31 | (((sizeof(n) >= sizeof(size_t) && cast(size_t, (n)) + 1 > MAX_SIZET/(e)) \ 32 | ? luaM_toobig(L) : cast_void(0)) , \ 33 | luaM_realloc_(L, (b), (on)*(e), (n)*(e))) 34 | 35 | /* 36 | ** Arrays of chars do not need any test 37 | */ 38 | #define luaM_reallocvchar(L,b,on,n) \ 39 | cast(char *, luaM_realloc_(L, (b), (on)*sizeof(char), (n)*sizeof(char))) 40 | 41 | #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) 42 | #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) 43 | #define luaM_freearray(L, b, n) luaM_realloc_(L, (b), (n)*sizeof(*(b)), 0) 44 | 45 | #define luaM_malloc(L,s) luaM_realloc_(L, NULL, 0, (s)) 46 | #define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) 47 | #define luaM_newvector(L,n,t) \ 48 | cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) 49 | 50 | #define luaM_newobject(L,tag,s) luaM_realloc_(L, NULL, tag, (s)) 51 | 52 | #define luaM_growvector(L,v,nelems,size,t,limit,e) \ 53 | if ((nelems)+1 > (size)) \ 54 | ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) 55 | 56 | #define luaM_reallocvector(L, v,oldn,n,t) \ 57 | ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) 58 | 59 | LUAI_FUNC l_noret luaM_toobig( lua_State* L ); 60 | 61 | /* not to be called directly */ 62 | LUAI_FUNC void* luaM_realloc_( lua_State* L, void* block, size_t oldsize, 63 | size_t size ); 64 | LUAI_FUNC void* luaM_growaux_( lua_State* L, void* block, int* size, 65 | size_t size_elem, int limit, 66 | const char* what ); 67 | 68 | #endif 69 | 70 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/lua53/lstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.h,v 1.61 2015/11/03 15:36:01 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 | 17 | #define sizeludata(l) (sizeof(union UUdata) + (l)) 18 | #define sizeudata(u) sizeludata((u)->len) 19 | 20 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 21 | (sizeof(s)/sizeof(char))-1)) 22 | 23 | 24 | /* 25 | ** test whether a string is a reserved word 26 | */ 27 | #define isreserved(s) ((s)->tt == LUA_TSHRSTR && (s)->extra > 0) 28 | 29 | 30 | /* 31 | ** equality for short strings, which are always internalized 32 | */ 33 | #define eqshrstr(a,b) check_exp((a)->tt == LUA_TSHRSTR, (a) == (b)) 34 | 35 | 36 | LUAI_FUNC unsigned int luaS_hash( const char* str, size_t l, 37 | unsigned int seed ); 38 | LUAI_FUNC unsigned int luaS_hashlongstr( TString* ts ); 39 | LUAI_FUNC int luaS_eqlngstr( TString* a, TString* b ); 40 | LUAI_FUNC void luaS_resize( lua_State* L, int newsize ); 41 | LUAI_FUNC void luaS_clearcache( global_State* g ); 42 | LUAI_FUNC void luaS_init( lua_State* L ); 43 | LUAI_FUNC void luaS_remove( lua_State* L, TString* ts ); 44 | LUAI_FUNC Udata* luaS_newudata( lua_State* L, size_t s ); 45 | LUAI_FUNC TString* luaS_newlstr( lua_State* L, const char* str, size_t l ); 46 | LUAI_FUNC TString* luaS_new( lua_State* L, const char* str ); 47 | LUAI_FUNC TString* luaS_createlngstrobj( lua_State* L, size_t l ); 48 | 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/lua53/ltable.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltable.h,v 2.23 2016/12/22 13:08:50 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 | /* 22 | ** writable version of 'gkey'; allows updates to individual fields, 23 | ** but not to the whole (which has incompatible type) 24 | */ 25 | #define wgkey(n) (&(n)->i_key.nk) 26 | 27 | #define invalidateTMcache(t) ((t)->flags = 0) 28 | 29 | 30 | /* true when 't' is using 'dummynode' as its hash part */ 31 | #define isdummy(t) ((t)->lastfree == NULL) 32 | 33 | 34 | /* allocated size for hash nodes */ 35 | #define allocsizenode(t) (isdummy(t) ? 0 : sizenode(t)) 36 | 37 | 38 | /* returns the key, given the value of a table entry */ 39 | #define keyfromval(v) \ 40 | (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val)))) 41 | 42 | 43 | LUAI_FUNC const TValue* luaH_getint( Table* t, lua_Integer key ); 44 | LUAI_FUNC void luaH_setint( lua_State* L, Table* t, lua_Integer key, 45 | TValue* value ); 46 | LUAI_FUNC const TValue* luaH_getshortstr( Table* t, TString* key ); 47 | LUAI_FUNC const TValue* luaH_getstr( Table* t, TString* key ); 48 | LUAI_FUNC const TValue* luaH_get( Table* t, const TValue* key ); 49 | LUAI_FUNC TValue* luaH_newkey( lua_State* L, Table* t, const TValue* key ); 50 | LUAI_FUNC TValue* luaH_set( lua_State* L, Table* t, const TValue* key ); 51 | LUAI_FUNC Table* luaH_new( lua_State* L ); 52 | LUAI_FUNC void luaH_resize( lua_State* L, Table* t, unsigned int nasize, 53 | unsigned int nhsize ); 54 | LUAI_FUNC void luaH_resizearray( lua_State* L, Table* t, unsigned int nasize ); 55 | LUAI_FUNC void luaH_free( lua_State* L, Table* t ); 56 | LUAI_FUNC int luaH_next( lua_State* L, Table* t, StkId key ); 57 | LUAI_FUNC int luaH_getn( Table* t ); 58 | 59 | 60 | #if defined(LUA_DEBUG) 61 | LUAI_FUNC Node* luaH_mainposition( const Table* t, const TValue* key ); 62 | LUAI_FUNC int luaH_isdummy( const Table* t ); 63 | #endif 64 | 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /src/lua53/ltm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.h,v 2.22 2016/02/26 19:20:15 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 | 55 | LUAI_DDEC const char* const luaT_typenames_[LUA_TOTALTAGS]; 56 | 57 | 58 | LUAI_FUNC const char* luaT_objtypename( lua_State* L, const TValue* o ); 59 | 60 | LUAI_FUNC const TValue* luaT_gettm( Table* events, TMS event, TString* ename ); 61 | LUAI_FUNC const TValue* luaT_gettmbyobj( lua_State* L, const TValue* o, 62 | TMS event ); 63 | LUAI_FUNC void luaT_init( lua_State* L ); 64 | 65 | LUAI_FUNC void luaT_callTM( lua_State* L, const TValue* f, const TValue* p1, 66 | const TValue* p2, TValue* p3, int hasres ); 67 | LUAI_FUNC int luaT_callbinTM( lua_State* L, const TValue* p1, const TValue* p2, 68 | StkId res, TMS event ); 69 | LUAI_FUNC void luaT_trybinTM( lua_State* L, const TValue* p1, const TValue* p2, 70 | StkId res, TMS event ); 71 | LUAI_FUNC int luaT_callorderTM( lua_State* L, const TValue* p1, 72 | const TValue* p2, TMS event ); 73 | 74 | 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/lua53/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.45 2017/01/12 17:14:26 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 | /* version suffix for environment variable names */ 15 | #define LUA_VERSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR 16 | 17 | 18 | LUAMOD_API int ( luaopen_base )( lua_State* L ); 19 | 20 | #define LUA_COLIBNAME "coroutine" 21 | LUAMOD_API int ( luaopen_coroutine )( lua_State* L ); 22 | 23 | #define LUA_TABLIBNAME "table" 24 | LUAMOD_API int ( luaopen_table )( lua_State* L ); 25 | 26 | #define LUA_IOLIBNAME "io" 27 | LUAMOD_API int ( luaopen_io )( lua_State* L ); 28 | 29 | #define LUA_OSLIBNAME "os" 30 | LUAMOD_API int ( luaopen_os )( lua_State* L ); 31 | 32 | #define LUA_STRLIBNAME "string" 33 | LUAMOD_API int ( luaopen_string )( lua_State* L ); 34 | 35 | #define LUA_UTF8LIBNAME "utf8" 36 | LUAMOD_API int ( luaopen_utf8 )( lua_State* L ); 37 | 38 | #define LUA_BITLIBNAME "bit32" 39 | LUAMOD_API int ( luaopen_bit32 )( lua_State* L ); 40 | 41 | #define LUA_MATHLIBNAME "math" 42 | LUAMOD_API int ( luaopen_math )( lua_State* L ); 43 | 44 | #define LUA_DBLIBNAME "debug" 45 | LUAMOD_API int ( luaopen_debug )( lua_State* L ); 46 | 47 | #define LUA_LOADLIBNAME "package" 48 | LUAMOD_API int ( luaopen_package )( lua_State* L ); 49 | 50 | 51 | /* open all previous libraries */ 52 | LUALIB_API void ( luaL_openlibs )( lua_State* L ); 53 | 54 | 55 | 56 | #if !defined(lua_assert) 57 | #define lua_assert(x) ((void)0) 58 | #endif 59 | 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/lua53/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h,v 1.45 2015/09/08 15:41:05 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, const char* name ); 27 | 28 | /* dump one chunk; from ldump.c */ 29 | LUAI_FUNC int luaU_dump( lua_State* L, const Proto* f, lua_Writer w, 30 | void* data, int strip ); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/lua53/lzio.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.c,v 1.37 2015/09/08 15:41:05 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 | 31 | if ( buff == NULL || size == 0 ) { 32 | return EOZ; 33 | } 34 | 35 | z->n = size - 1; /* discount char being returned */ 36 | z->p = buff; 37 | return cast_uchar( *( z->p++ ) ); 38 | } 39 | 40 | 41 | void luaZ_init( lua_State* L, ZIO* z, lua_Reader reader, void* data ) { 42 | z->L = L; 43 | z->reader = reader; 44 | z->data = data; 45 | z->n = 0; 46 | z->p = NULL; 47 | } 48 | 49 | 50 | /* --------------------------------------------------------------- read --- */ 51 | size_t luaZ_read( ZIO* z, void* b, size_t n ) { 52 | while ( n ) { 53 | size_t m; 54 | 55 | if ( z->n == 0 ) { /* no bytes in buffer? */ 56 | if ( luaZ_fill( z ) == EOZ ) { /* try to read more */ 57 | return n; /* no more input; return number of missing bytes */ 58 | } 59 | else { 60 | z->n++; /* luaZ_fill consumed first byte; put it back */ 61 | z->p--; 62 | } 63 | } 64 | 65 | m = ( n <= z->n ) ? n : z->n; /* min. between n and z->n */ 66 | memcpy( b, z->p, m ); 67 | z->n -= m; 68 | z->p += m; 69 | b = ( char* )b + m; 70 | n -= m; 71 | } 72 | 73 | return 0; 74 | } 75 | 76 | -------------------------------------------------------------------------------- /src/lua53/lzio.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.h,v 1.31 2015/09/08 15:41:05 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 void luaZ_init( lua_State* L, ZIO* z, lua_Reader reader, 48 | void* data ); 49 | LUAI_FUNC size_t luaZ_read( ZIO* z, void* b, size_t n ); /* read next n bytes */ 50 | 51 | 52 | 53 | /* --------- Private Part ------------------ */ 54 | 55 | struct Zio { 56 | size_t n; /* bytes still unread */ 57 | const char* p; /* current position in buffer */ 58 | lua_Reader reader; /* reader function */ 59 | void* data; /* additional data */ 60 | lua_State* L; /* Lua state (for reader) */ 61 | }; 62 | 63 | 64 | LUAI_FUNC int luaZ_fill( ZIO* z ); 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /src/lua53/wmain.c: -------------------------------------------------------------------------------- 1 | 2 | #ifdef WIN32 3 | 4 | #include 5 | #include /* declaration of __argc and __argv */ 6 | 7 | extern int main( int, char** ); 8 | 9 | int PASCAL WinMain( HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, 10 | int ncmdshow ) { 11 | int rc; 12 | extern int 13 | __argc; /* this seems to work for all the compilers we tested, except Watcom compilers */ 14 | extern char** __argv; 15 | rc = main( __argc, __argv ); 16 | return rc; 17 | } 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /src/lua54/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h $ 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 | 15 | /* Increments 'L->top', checking for stack overflows */ 16 | #define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \ 17 | "stack overflow");} 18 | 19 | 20 | /* 21 | ** If a call returns too many multiple returns, the callee may not have 22 | ** stack space to accommodate all results. In this case, this macro 23 | ** increases its stack space ('L->ci->top'). 24 | */ 25 | #define adjustresults(L,nres) \ 26 | { if ((nres) <= LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } 27 | 28 | 29 | /* Ensure the stack has at least 'n' elements */ 30 | #define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \ 31 | "not enough elements in the stack") 32 | 33 | 34 | /* 35 | ** To reduce the overhead of returning from C functions, the presence of 36 | ** to-be-closed variables in these functions is coded in the CallInfo's 37 | ** field 'nresults', in a way that functions with no to-be-closed variables 38 | ** with zero, one, or "all" wanted results have no overhead. Functions 39 | ** with other number of wanted results, as well as functions with 40 | ** variables to be closed, have an extra check. 41 | */ 42 | 43 | #define hastocloseCfunc(n) ((n) < LUA_MULTRET) 44 | 45 | /* Map [-1, inf) (range of 'nresults') into (-inf, -2] */ 46 | #define codeNresults(n) (-(n) - 3) 47 | #define decodeNresults(n) (-(n) - 3) 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/lua54/lctype.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.c $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lctype_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include "lctype.h" 14 | 15 | #if !LUA_USE_CTYPE /* { */ 16 | 17 | #include 18 | 19 | 20 | #if defined (LUA_UCID) /* accept UniCode IDentifiers? */ 21 | /* consider all non-ascii codepoints to be alphabetic */ 22 | #define NONA 0x01 23 | #else 24 | #define NONA 0x00 /* default */ 25 | #endif 26 | 27 | 28 | LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = { 29 | 0x00, /* EOZ */ 30 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0. */ 31 | 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 32 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1. */ 33 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 34 | 0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, /* 2. */ 35 | 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 36 | 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, /* 3. */ 37 | 0x16, 0x16, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 38 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 4. */ 39 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 40 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 5. */ 41 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x05, 42 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 6. */ 43 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 44 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 7. */ 45 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00, 46 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* 8. */ 47 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, 48 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* 9. */ 49 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, 50 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* a. */ 51 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, 52 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* b. */ 53 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, 54 | 0x00, 0x00, NONA, NONA, NONA, NONA, NONA, NONA, /* c. */ 55 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, 56 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* d. */ 57 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, 58 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* e. */ 59 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, 60 | NONA, NONA, NONA, NONA, NONA, 0x00, 0x00, 0x00, /* f. */ 61 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 62 | }; 63 | 64 | #endif /* } */ 65 | -------------------------------------------------------------------------------- /src/lua54/lctype.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.h $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lctype_h 8 | #define lctype_h 9 | 10 | #include "lua.h" 11 | 12 | 13 | /* 14 | ** WARNING: the functions defined here do not necessarily correspond 15 | ** to the similar functions in the standard C ctype.h. They are 16 | ** optimized for the specific needs of Lua. 17 | */ 18 | 19 | #if !defined(LUA_USE_CTYPE) 20 | 21 | #if 'A' == 65 && '0' == 48 22 | /* ASCII case: can use its own tables; faster and fixed */ 23 | #define LUA_USE_CTYPE 0 24 | #else 25 | /* must use standard C ctype */ 26 | #define LUA_USE_CTYPE 1 27 | #endif 28 | 29 | #endif 30 | 31 | 32 | #if !LUA_USE_CTYPE /* { */ 33 | 34 | #include 35 | 36 | #include "llimits.h" 37 | 38 | 39 | #define ALPHABIT 0 40 | #define DIGITBIT 1 41 | #define PRINTBIT 2 42 | #define SPACEBIT 3 43 | #define XDIGITBIT 4 44 | 45 | 46 | #define MASK(B) (1 << (B)) 47 | 48 | 49 | /* 50 | ** add 1 to char to allow index -1 (EOZ) 51 | */ 52 | #define testprop(c,p) (luai_ctype_[(c)+1] & (p)) 53 | 54 | /* 55 | ** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_' 56 | */ 57 | #define lislalpha(c) testprop(c, MASK(ALPHABIT)) 58 | #define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT))) 59 | #define lisdigit(c) testprop(c, MASK(DIGITBIT)) 60 | #define lisspace(c) testprop(c, MASK(SPACEBIT)) 61 | #define lisprint(c) testprop(c, MASK(PRINTBIT)) 62 | #define lisxdigit(c) testprop(c, MASK(XDIGITBIT)) 63 | 64 | 65 | /* 66 | ** In ASCII, this 'ltolower' is correct for alphabetic characters and 67 | ** for '.'. That is enough for Lua needs. ('check_exp' ensures that 68 | ** the character either is an upper-case letter or is unchanged by 69 | ** the transformation, which holds for lower-case letters and '.'.) 70 | */ 71 | #define ltolower(c) \ 72 | check_exp(('A' <= (c) && (c) <= 'Z') || (c) == ((c) | ('A' ^ 'a')), \ 73 | (c) | ('A' ^ 'a')) 74 | 75 | 76 | /* one entry for each character and for -1 (EOZ) */ 77 | LUAI_DDEC(const lu_byte luai_ctype_[UCHAR_MAX + 2];) 78 | 79 | 80 | #else /* }{ */ 81 | 82 | /* 83 | ** use standard C ctypes 84 | */ 85 | 86 | #include 87 | 88 | 89 | #define lislalpha(c) (isalpha(c) || (c) == '_') 90 | #define lislalnum(c) (isalnum(c) || (c) == '_') 91 | #define lisdigit(c) (isdigit(c)) 92 | #define lisspace(c) (isspace(c)) 93 | #define lisprint(c) (isprint(c)) 94 | #define lisxdigit(c) (isxdigit(c)) 95 | 96 | #define ltolower(c) (tolower(c)) 97 | 98 | #endif /* } */ 99 | 100 | #endif 101 | 102 | -------------------------------------------------------------------------------- /src/lua54/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h $ 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 | 17 | /* Active Lua function (given call info) */ 18 | #define ci_func(ci) (clLvalue(s2v((ci)->func))) 19 | 20 | 21 | #define resethookcount(L) (L->hookcount = L->basehookcount) 22 | 23 | /* 24 | ** mark for entries in 'lineinfo' array that has absolute information in 25 | ** 'abslineinfo' array 26 | */ 27 | #define ABSLINEINFO (-0x80) 28 | 29 | 30 | /* 31 | ** MAXimum number of successive Instructions WiTHout ABSolute line 32 | ** information. (A power of two allows fast divisions.) 33 | */ 34 | #if !defined(MAXIWTHABS) 35 | #define MAXIWTHABS 128 36 | #endif 37 | 38 | 39 | LUAI_FUNC int luaG_getfuncline (const Proto *f, int pc); 40 | LUAI_FUNC const char *luaG_findlocal (lua_State *L, CallInfo *ci, int n, 41 | StkId *pos); 42 | LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, 43 | const char *opname); 44 | LUAI_FUNC l_noret luaG_callerror (lua_State *L, const TValue *o); 45 | LUAI_FUNC l_noret luaG_forerror (lua_State *L, const TValue *o, 46 | const char *what); 47 | LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1, 48 | const TValue *p2); 49 | LUAI_FUNC l_noret luaG_opinterror (lua_State *L, const TValue *p1, 50 | const TValue *p2, 51 | const char *msg); 52 | LUAI_FUNC l_noret luaG_tointerror (lua_State *L, const TValue *p1, 53 | const TValue *p2); 54 | LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, 55 | const TValue *p2); 56 | LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); 57 | LUAI_FUNC const char *luaG_addinfo (lua_State *L, const char *msg, 58 | TString *src, int line); 59 | LUAI_FUNC l_noret luaG_errormsg (lua_State *L); 60 | LUAI_FUNC int luaG_traceexec (lua_State *L, const Instruction *pc); 61 | 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /src/lua54/ldo.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldo.h $ 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 | /* 17 | ** Macro to check stack size and grow stack if needed. Parameters 18 | ** 'pre'/'pos' allow the macro to preserve a pointer into the 19 | ** stack across reallocations, doing the work only when needed. 20 | ** It also allows the running of one GC step when the stack is 21 | ** reallocated. 22 | ** 'condmovestack' is used in heavy tests to force a stack reallocation 23 | ** at every check. 24 | */ 25 | #define luaD_checkstackaux(L,n,pre,pos) \ 26 | if (l_unlikely(L->stack_last - L->top <= (n))) \ 27 | { pre; luaD_growstack(L, n, 1); pos; } \ 28 | else { condmovestack(L,pre,pos); } 29 | 30 | /* In general, 'pre'/'pos' are empty (nothing to save) */ 31 | #define luaD_checkstack(L,n) luaD_checkstackaux(L,n,(void)0,(void)0) 32 | 33 | 34 | 35 | #define savestack(L,p) ((char *)(p) - (char *)L->stack) 36 | #define restorestack(L,n) ((StkId)((char *)L->stack + (n))) 37 | 38 | 39 | /* macro to check stack size, preserving 'p' */ 40 | #define checkstackGCp(L,n,p) \ 41 | luaD_checkstackaux(L, n, \ 42 | ptrdiff_t t__ = savestack(L, p); /* save 'p' */ \ 43 | luaC_checkGC(L), /* stack grow uses memory */ \ 44 | p = restorestack(L, t__)) /* 'pos' part: restore 'p' */ 45 | 46 | 47 | /* macro to check stack size and GC */ 48 | #define checkstackGC(L,fsize) \ 49 | luaD_checkstackaux(L, (fsize), luaC_checkGC(L), (void)0) 50 | 51 | 52 | /* type of protected functions, to be ran by 'runprotected' */ 53 | typedef void (*Pfunc) (lua_State *L, void *ud); 54 | 55 | LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop); 56 | LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, 57 | const char *mode); 58 | LUAI_FUNC void luaD_hook (lua_State *L, int event, int line, 59 | int fTransfer, int nTransfer); 60 | LUAI_FUNC void luaD_hookcall (lua_State *L, CallInfo *ci); 61 | LUAI_FUNC void luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, int n); 62 | LUAI_FUNC CallInfo *luaD_precall (lua_State *L, StkId func, int nResults); 63 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); 64 | LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults); 65 | LUAI_FUNC void luaD_tryfuncTM (lua_State *L, StkId func); 66 | LUAI_FUNC int luaD_closeprotected (lua_State *L, ptrdiff_t level, int status); 67 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, 68 | ptrdiff_t oldtop, ptrdiff_t ef); 69 | LUAI_FUNC void luaD_poscall (lua_State *L, CallInfo *ci, int nres); 70 | LUAI_FUNC int luaD_reallocstack (lua_State *L, int newsize, int raiseerror); 71 | LUAI_FUNC int luaD_growstack (lua_State *L, int n, int raiseerror); 72 | LUAI_FUNC void luaD_shrinkstack (lua_State *L); 73 | LUAI_FUNC void luaD_inctop (lua_State *L); 74 | 75 | LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode); 76 | LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); 77 | 78 | #endif 79 | 80 | -------------------------------------------------------------------------------- /src/lua54/lfunc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lfunc.h $ 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(offsetof(CClosure, upvalue)) + \ 15 | cast_int(sizeof(TValue)) * (n)) 16 | 17 | #define sizeLclosure(n) (cast_int(offsetof(LClosure, upvals)) + \ 18 | cast_int(sizeof(TValue *)) * (n)) 19 | 20 | 21 | /* test whether thread is in 'twups' list */ 22 | #define isintwups(L) (L->twups != L) 23 | 24 | 25 | /* 26 | ** maximum number of upvalues in a closure (both C and Lua). (Value 27 | ** must fit in a VM register.) 28 | */ 29 | #define MAXUPVAL 255 30 | 31 | 32 | #define upisopen(up) ((up)->v != &(up)->u.value) 33 | 34 | 35 | #define uplevel(up) check_exp(upisopen(up), cast(StkId, (up)->v)) 36 | 37 | 38 | /* 39 | ** maximum number of misses before giving up the cache of closures 40 | ** in prototypes 41 | */ 42 | #define MAXMISS 10 43 | 44 | 45 | 46 | /* special status to close upvalues preserving the top of the stack */ 47 | #define CLOSEKTOP (-1) 48 | 49 | 50 | LUAI_FUNC Proto *luaF_newproto (lua_State *L); 51 | LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nupvals); 52 | LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nupvals); 53 | LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl); 54 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); 55 | LUAI_FUNC void luaF_newtbcupval (lua_State *L, StkId level); 56 | LUAI_FUNC void luaF_closeupval (lua_State *L, StkId level); 57 | LUAI_FUNC void luaF_close (lua_State *L, StkId level, int status, int yy); 58 | LUAI_FUNC void luaF_unlinkupval (UpVal *uv); 59 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); 60 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, 61 | int pc); 62 | 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /src/lua54/linit.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: linit.c $ 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, LUA_PRELOAD_TABLE); 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 | {LUA_GNAME, 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 | {NULL, NULL} 54 | }; 55 | 56 | 57 | LUALIB_API void luaL_openlibs (lua_State *L) { 58 | const luaL_Reg *lib; 59 | /* "require" functions from 'loadedlibs' and set results to global table */ 60 | for (lib = loadedlibs; lib->func; lib++) { 61 | luaL_requiref(L, lib->name, lib->func, 1); 62 | lua_pop(L, 1); /* remove lib */ 63 | } 64 | } 65 | 66 | -------------------------------------------------------------------------------- /src/lua54/ljumptab.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ljumptab.h $ 3 | ** Jump Table for the Lua interpreter 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #undef vmdispatch 9 | #undef vmcase 10 | #undef vmbreak 11 | 12 | #define vmdispatch(x) goto *disptab[x]; 13 | 14 | #define vmcase(l) L_##l: 15 | 16 | #define vmbreak vmfetch(); vmdispatch(GET_OPCODE(i)); 17 | 18 | 19 | static const void *const disptab[NUM_OPCODES] = { 20 | 21 | #if 0 22 | ** you can update the following list with this command: 23 | ** 24 | ** sed -n '/^OP_/\!d; s/OP_/\&\&L_OP_/ ; s/,.*/,/ ; s/\/.*// ; p' lopcodes.h 25 | ** 26 | #endif 27 | 28 | &&L_OP_MOVE, 29 | &&L_OP_LOADI, 30 | &&L_OP_LOADF, 31 | &&L_OP_LOADK, 32 | &&L_OP_LOADKX, 33 | &&L_OP_LOADFALSE, 34 | &&L_OP_LFALSESKIP, 35 | &&L_OP_LOADTRUE, 36 | &&L_OP_LOADNIL, 37 | &&L_OP_GETUPVAL, 38 | &&L_OP_SETUPVAL, 39 | &&L_OP_GETTABUP, 40 | &&L_OP_GETTABLE, 41 | &&L_OP_GETI, 42 | &&L_OP_GETFIELD, 43 | &&L_OP_SETTABUP, 44 | &&L_OP_SETTABLE, 45 | &&L_OP_SETI, 46 | &&L_OP_SETFIELD, 47 | &&L_OP_NEWTABLE, 48 | &&L_OP_SELF, 49 | &&L_OP_ADDI, 50 | &&L_OP_ADDK, 51 | &&L_OP_SUBK, 52 | &&L_OP_MULK, 53 | &&L_OP_MODK, 54 | &&L_OP_POWK, 55 | &&L_OP_DIVK, 56 | &&L_OP_IDIVK, 57 | &&L_OP_BANDK, 58 | &&L_OP_BORK, 59 | &&L_OP_BXORK, 60 | &&L_OP_SHRI, 61 | &&L_OP_SHLI, 62 | &&L_OP_ADD, 63 | &&L_OP_SUB, 64 | &&L_OP_MUL, 65 | &&L_OP_MOD, 66 | &&L_OP_POW, 67 | &&L_OP_DIV, 68 | &&L_OP_IDIV, 69 | &&L_OP_BAND, 70 | &&L_OP_BOR, 71 | &&L_OP_BXOR, 72 | &&L_OP_SHL, 73 | &&L_OP_SHR, 74 | &&L_OP_MMBIN, 75 | &&L_OP_MMBINI, 76 | &&L_OP_MMBINK, 77 | &&L_OP_UNM, 78 | &&L_OP_BNOT, 79 | &&L_OP_NOT, 80 | &&L_OP_LEN, 81 | &&L_OP_CONCAT, 82 | &&L_OP_CLOSE, 83 | &&L_OP_TBC, 84 | &&L_OP_JMP, 85 | &&L_OP_EQ, 86 | &&L_OP_LT, 87 | &&L_OP_LE, 88 | &&L_OP_EQK, 89 | &&L_OP_EQI, 90 | &&L_OP_LTI, 91 | &&L_OP_LEI, 92 | &&L_OP_GTI, 93 | &&L_OP_GEI, 94 | &&L_OP_TEST, 95 | &&L_OP_TESTSET, 96 | &&L_OP_CALL, 97 | &&L_OP_TAILCALL, 98 | &&L_OP_RETURN, 99 | &&L_OP_RETURN0, 100 | &&L_OP_RETURN1, 101 | &&L_OP_FORLOOP, 102 | &&L_OP_FORPREP, 103 | &&L_OP_TFORPREP, 104 | &&L_OP_TFORCALL, 105 | &&L_OP_TFORLOOP, 106 | &&L_OP_SETLIST, 107 | &&L_OP_CLOSURE, 108 | &&L_OP_VARARG, 109 | &&L_OP_VARARGPREP, 110 | &&L_OP_EXTRAARG 111 | 112 | }; 113 | -------------------------------------------------------------------------------- /src/lua54/llex.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: llex.h $ 3 | ** Lexical Analyzer 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef llex_h 8 | #define llex_h 9 | 10 | #include 11 | 12 | #include "lobject.h" 13 | #include "lzio.h" 14 | 15 | 16 | /* 17 | ** Single-char tokens (terminal symbols) are represented by their own 18 | ** numeric code. Other tokens start at the following value. 19 | */ 20 | #define FIRST_RESERVED (UCHAR_MAX + 1) 21 | 22 | 23 | #if !defined(LUA_ENV) 24 | #define LUA_ENV "_ENV" 25 | #endif 26 | 27 | 28 | /* 29 | * WARNING: if you change the order of this enumeration, 30 | * grep "ORDER RESERVED" 31 | */ 32 | enum RESERVED { 33 | /* terminal symbols denoted by reserved words */ 34 | TK_AND = FIRST_RESERVED, TK_BREAK, 35 | TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, 36 | TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, 37 | TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, 38 | /* other terminal symbols */ 39 | TK_IDIV, TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, 40 | TK_SHL, TK_SHR, 41 | TK_DBCOLON, TK_EOS, 42 | TK_FLT, TK_INT, TK_NAME, TK_STRING 43 | }; 44 | 45 | /* number of reserved words */ 46 | #define NUM_RESERVED (cast_int(TK_WHILE-FIRST_RESERVED + 1)) 47 | 48 | 49 | typedef union { 50 | lua_Number r; 51 | lua_Integer i; 52 | TString *ts; 53 | } SemInfo; /* semantics information */ 54 | 55 | 56 | typedef struct Token { 57 | int token; 58 | SemInfo seminfo; 59 | } Token; 60 | 61 | 62 | /* state of the lexer plus state of the parser when shared by all 63 | functions */ 64 | typedef struct LexState { 65 | int current; /* current character (charint) */ 66 | int linenumber; /* input line counter */ 67 | int lastline; /* line of last token 'consumed' */ 68 | Token t; /* current token */ 69 | Token lookahead; /* look ahead token */ 70 | struct FuncState *fs; /* current function (parser) */ 71 | struct lua_State *L; 72 | ZIO *z; /* input stream */ 73 | Mbuffer *buff; /* buffer for tokens */ 74 | Table *h; /* to avoid collection/reuse strings */ 75 | struct Dyndata *dyd; /* dynamic structures used by the parser */ 76 | TString *source; /* current source name */ 77 | TString *envn; /* environment variable name */ 78 | } LexState; 79 | 80 | 81 | LUAI_FUNC void luaX_init (lua_State *L); 82 | LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, 83 | TString *source, int firstchar); 84 | LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); 85 | LUAI_FUNC void luaX_next (LexState *ls); 86 | LUAI_FUNC int luaX_lookahead (LexState *ls); 87 | LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s); 88 | LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); 89 | 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /src/lua54/lmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.h $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lmem_h 8 | #define lmem_h 9 | 10 | 11 | #include 12 | 13 | #include "llimits.h" 14 | #include "lua.h" 15 | 16 | 17 | #define luaM_error(L) luaD_throw(L, LUA_ERRMEM) 18 | 19 | 20 | /* 21 | ** This macro tests whether it is safe to multiply 'n' by the size of 22 | ** type 't' without overflows. Because 'e' is always constant, it avoids 23 | ** the runtime division MAX_SIZET/(e). 24 | ** (The macro is somewhat complex to avoid warnings: The 'sizeof' 25 | ** comparison avoids a runtime comparison when overflow cannot occur. 26 | ** The compiler should be able to optimize the real test by itself, but 27 | ** when it does it, it may give a warning about "comparison is always 28 | ** false due to limited range of data type"; the +1 tricks the compiler, 29 | ** avoiding this warning but also this optimization.) 30 | */ 31 | #define luaM_testsize(n,e) \ 32 | (sizeof(n) >= sizeof(size_t) && cast_sizet((n)) + 1 > MAX_SIZET/(e)) 33 | 34 | #define luaM_checksize(L,n,e) \ 35 | (luaM_testsize(n,e) ? luaM_toobig(L) : cast_void(0)) 36 | 37 | 38 | /* 39 | ** Computes the minimum between 'n' and 'MAX_SIZET/sizeof(t)', so that 40 | ** the result is not larger than 'n' and cannot overflow a 'size_t' 41 | ** when multiplied by the size of type 't'. (Assumes that 'n' is an 42 | ** 'int' or 'unsigned int' and that 'int' is not larger than 'size_t'.) 43 | */ 44 | #define luaM_limitN(n,t) \ 45 | ((cast_sizet(n) <= MAX_SIZET/sizeof(t)) ? (n) : \ 46 | cast_uint((MAX_SIZET/sizeof(t)))) 47 | 48 | 49 | /* 50 | ** Arrays of chars do not need any test 51 | */ 52 | #define luaM_reallocvchar(L,b,on,n) \ 53 | cast_charp(luaM_saferealloc_(L, (b), (on)*sizeof(char), (n)*sizeof(char))) 54 | 55 | #define luaM_freemem(L, b, s) luaM_free_(L, (b), (s)) 56 | #define luaM_free(L, b) luaM_free_(L, (b), sizeof(*(b))) 57 | #define luaM_freearray(L, b, n) luaM_free_(L, (b), (n)*sizeof(*(b))) 58 | 59 | #define luaM_new(L,t) cast(t*, luaM_malloc_(L, sizeof(t), 0)) 60 | #define luaM_newvector(L,n,t) cast(t*, luaM_malloc_(L, (n)*sizeof(t), 0)) 61 | #define luaM_newvectorchecked(L,n,t) \ 62 | (luaM_checksize(L,n,sizeof(t)), luaM_newvector(L,n,t)) 63 | 64 | #define luaM_newobject(L,tag,s) luaM_malloc_(L, (s), tag) 65 | 66 | #define luaM_growvector(L,v,nelems,size,t,limit,e) \ 67 | ((v)=cast(t *, luaM_growaux_(L,v,nelems,&(size),sizeof(t), \ 68 | luaM_limitN(limit,t),e))) 69 | 70 | #define luaM_reallocvector(L, v,oldn,n,t) \ 71 | (cast(t *, luaM_realloc_(L, v, cast_sizet(oldn) * sizeof(t), \ 72 | cast_sizet(n) * sizeof(t)))) 73 | 74 | #define luaM_shrinkvector(L,v,size,fs,t) \ 75 | ((v)=cast(t *, luaM_shrinkvector_(L, v, &(size), fs, sizeof(t)))) 76 | 77 | LUAI_FUNC l_noret luaM_toobig (lua_State *L); 78 | 79 | /* not to be called directly */ 80 | LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, 81 | size_t size); 82 | LUAI_FUNC void *luaM_saferealloc_ (lua_State *L, void *block, size_t oldsize, 83 | size_t size); 84 | LUAI_FUNC void luaM_free_ (lua_State *L, void *block, size_t osize); 85 | LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int nelems, 86 | int *size, int size_elem, int limit, 87 | const char *what); 88 | LUAI_FUNC void *luaM_shrinkvector_ (lua_State *L, void *block, int *nelem, 89 | int final_n, int size_elem); 90 | LUAI_FUNC void *luaM_malloc_ (lua_State *L, size_t size, int tag); 91 | 92 | #endif 93 | 94 | -------------------------------------------------------------------------------- /src/lua54/lopnames.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lopnames.h $ 3 | ** Opcode names 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #if !defined(lopnames_h) 8 | #define lopnames_h 9 | 10 | #include 11 | 12 | 13 | /* ORDER OP */ 14 | 15 | static const char *const opnames[] = { 16 | "MOVE", 17 | "LOADI", 18 | "LOADF", 19 | "LOADK", 20 | "LOADKX", 21 | "LOADFALSE", 22 | "LFALSESKIP", 23 | "LOADTRUE", 24 | "LOADNIL", 25 | "GETUPVAL", 26 | "SETUPVAL", 27 | "GETTABUP", 28 | "GETTABLE", 29 | "GETI", 30 | "GETFIELD", 31 | "SETTABUP", 32 | "SETTABLE", 33 | "SETI", 34 | "SETFIELD", 35 | "NEWTABLE", 36 | "SELF", 37 | "ADDI", 38 | "ADDK", 39 | "SUBK", 40 | "MULK", 41 | "MODK", 42 | "POWK", 43 | "DIVK", 44 | "IDIVK", 45 | "BANDK", 46 | "BORK", 47 | "BXORK", 48 | "SHRI", 49 | "SHLI", 50 | "ADD", 51 | "SUB", 52 | "MUL", 53 | "MOD", 54 | "POW", 55 | "DIV", 56 | "IDIV", 57 | "BAND", 58 | "BOR", 59 | "BXOR", 60 | "SHL", 61 | "SHR", 62 | "MMBIN", 63 | "MMBINI", 64 | "MMBINK", 65 | "UNM", 66 | "BNOT", 67 | "NOT", 68 | "LEN", 69 | "CONCAT", 70 | "CLOSE", 71 | "TBC", 72 | "JMP", 73 | "EQ", 74 | "LT", 75 | "LE", 76 | "EQK", 77 | "EQI", 78 | "LTI", 79 | "LEI", 80 | "GTI", 81 | "GEI", 82 | "TEST", 83 | "TESTSET", 84 | "CALL", 85 | "TAILCALL", 86 | "RETURN", 87 | "RETURN0", 88 | "RETURN1", 89 | "FORLOOP", 90 | "FORPREP", 91 | "TFORPREP", 92 | "TFORCALL", 93 | "TFORLOOP", 94 | "SETLIST", 95 | "CLOSURE", 96 | "VARARG", 97 | "VARARGPREP", 98 | "EXTRAARG", 99 | NULL 100 | }; 101 | 102 | #endif 103 | 104 | -------------------------------------------------------------------------------- /src/lua54/lprefix.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lprefix.h $ 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 | -------------------------------------------------------------------------------- /src/lua54/lstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.h $ 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 | /* 16 | ** Memory-allocation error message must be preallocated (it cannot 17 | ** be created after memory is exhausted) 18 | */ 19 | #define MEMERRMSG "not enough memory" 20 | 21 | 22 | /* 23 | ** Size of a TString: Size of the header plus space for the string 24 | ** itself (including final '\0'). 25 | */ 26 | #define sizelstring(l) (offsetof(TString, contents) + ((l) + 1) * sizeof(char)) 27 | 28 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 29 | (sizeof(s)/sizeof(char))-1)) 30 | 31 | 32 | /* 33 | ** test whether a string is a reserved word 34 | */ 35 | #define isreserved(s) ((s)->tt == LUA_VSHRSTR && (s)->extra > 0) 36 | 37 | 38 | /* 39 | ** equality for short strings, which are always internalized 40 | */ 41 | #define eqshrstr(a,b) check_exp((a)->tt == LUA_VSHRSTR, (a) == (b)) 42 | 43 | 44 | LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); 45 | LUAI_FUNC unsigned int luaS_hashlongstr (TString *ts); 46 | LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); 47 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 48 | LUAI_FUNC void luaS_clearcache (global_State *g); 49 | LUAI_FUNC void luaS_init (lua_State *L); 50 | LUAI_FUNC void luaS_remove (lua_State *L, TString *ts); 51 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, int nuvalue); 52 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 53 | LUAI_FUNC TString *luaS_new (lua_State *L, const char *str); 54 | LUAI_FUNC TString *luaS_createlngstrobj (lua_State *L, size_t l); 55 | 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/lua54/ltable.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltable.h $ 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)->u.next) 16 | 17 | 18 | /* 19 | ** Clear all bits of fast-access metamethods, which means that the table 20 | ** may have any of these metamethods. (First access that fails after the 21 | ** clearing will set the bit again.) 22 | */ 23 | #define invalidateTMcache(t) ((t)->flags &= ~maskflags) 24 | 25 | 26 | /* true when 't' is using 'dummynode' as its hash part */ 27 | #define isdummy(t) ((t)->lastfree == NULL) 28 | 29 | 30 | /* allocated size for hash nodes */ 31 | #define allocsizenode(t) (isdummy(t) ? 0 : sizenode(t)) 32 | 33 | 34 | /* returns the Node, given the value of a table entry */ 35 | #define nodefromval(v) cast(Node *, (v)) 36 | 37 | 38 | LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key); 39 | LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key, 40 | TValue *value); 41 | LUAI_FUNC const TValue *luaH_getshortstr (Table *t, TString *key); 42 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); 43 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); 44 | LUAI_FUNC void luaH_newkey (lua_State *L, Table *t, const TValue *key, 45 | TValue *value); 46 | LUAI_FUNC void luaH_set (lua_State *L, Table *t, const TValue *key, 47 | TValue *value); 48 | LUAI_FUNC void luaH_finishset (lua_State *L, Table *t, const TValue *key, 49 | const TValue *slot, TValue *value); 50 | LUAI_FUNC Table *luaH_new (lua_State *L); 51 | LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize, 52 | unsigned int nhsize); 53 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize); 54 | LUAI_FUNC void luaH_free (lua_State *L, Table *t); 55 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); 56 | LUAI_FUNC lua_Unsigned luaH_getn (Table *t); 57 | LUAI_FUNC unsigned int luaH_realasize (const Table *t); 58 | 59 | 60 | #if defined(LUA_DEBUG) 61 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); 62 | LUAI_FUNC int luaH_isdummy (const Table *t); 63 | #endif 64 | 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /src/lua54/ltm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.h $ 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_CLOSE, 44 | TM_N /* number of elements in the enum */ 45 | } TMS; 46 | 47 | 48 | /* 49 | ** Mask with 1 in all fast-access methods. A 1 in any of these bits 50 | ** in the flag of a (meta)table means the metatable does not have the 51 | ** corresponding metamethod field. (Bit 7 of the flag is used for 52 | ** 'isrealasize'.) 53 | */ 54 | #define maskflags (~(~0u << (TM_EQ + 1))) 55 | 56 | 57 | /* 58 | ** Test whether there is no tagmethod. 59 | ** (Because tagmethods use raw accesses, the result may be an "empty" nil.) 60 | */ 61 | #define notm(tm) ttisnil(tm) 62 | 63 | 64 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \ 65 | ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) 66 | 67 | #define fasttm(l,et,e) gfasttm(G(l), et, e) 68 | 69 | #define ttypename(x) luaT_typenames_[(x) + 1] 70 | 71 | LUAI_DDEC(const char *const luaT_typenames_[LUA_TOTALTYPES];) 72 | 73 | 74 | LUAI_FUNC const char *luaT_objtypename (lua_State *L, const TValue *o); 75 | 76 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); 77 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, 78 | TMS event); 79 | LUAI_FUNC void luaT_init (lua_State *L); 80 | 81 | LUAI_FUNC void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1, 82 | const TValue *p2, const TValue *p3); 83 | LUAI_FUNC void luaT_callTMres (lua_State *L, const TValue *f, 84 | const TValue *p1, const TValue *p2, StkId p3); 85 | LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2, 86 | StkId res, TMS event); 87 | LUAI_FUNC void luaT_tryconcatTM (lua_State *L); 88 | LUAI_FUNC void luaT_trybinassocTM (lua_State *L, const TValue *p1, 89 | const TValue *p2, int inv, StkId res, TMS event); 90 | LUAI_FUNC void luaT_trybiniTM (lua_State *L, const TValue *p1, lua_Integer i2, 91 | int inv, StkId res, TMS event); 92 | LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1, 93 | const TValue *p2, TMS event); 94 | LUAI_FUNC int luaT_callorderiTM (lua_State *L, const TValue *p1, int v2, 95 | int inv, int isfloat, TMS event); 96 | 97 | LUAI_FUNC void luaT_adjustvarargs (lua_State *L, int nfixparams, 98 | struct CallInfo *ci, const Proto *p); 99 | LUAI_FUNC void luaT_getvarargs (lua_State *L, struct CallInfo *ci, 100 | StkId where, int wanted); 101 | 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /src/lua54/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 | -------------------------------------------------------------------------------- /src/lua54/lua_module.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __LUA_MODULE_H_INCLUDE__ 3 | #define __LUA_MODULE_H_INCLUDE__ 4 | 5 | #if defined(LUA_COMPAT_MODULE) 6 | static const char* luaL_findtable(lua_State* L, int idx, const char* fname, 7 | int szhint); 8 | 9 | static int libsize(const luaL_Reg* l); 10 | 11 | LUALIB_API void luaL_pushmodule(lua_State* L, const char* modname, 12 | int sizehint); 13 | #endif 14 | 15 | #endif // __LUA_MODULE_H_INCLUDE__ 16 | -------------------------------------------------------------------------------- /src/lua54/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h $ 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 | /* version suffix for environment variable names */ 15 | #define LUA_VERSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR 16 | 17 | 18 | LUAMOD_API int (luaopen_base) (lua_State *L); 19 | 20 | #define LUA_COLIBNAME "coroutine" 21 | LUAMOD_API int (luaopen_coroutine) (lua_State *L); 22 | 23 | #define LUA_TABLIBNAME "table" 24 | LUAMOD_API int (luaopen_table) (lua_State *L); 25 | 26 | #define LUA_IOLIBNAME "io" 27 | LUAMOD_API int (luaopen_io) (lua_State *L); 28 | 29 | #define LUA_OSLIBNAME "os" 30 | LUAMOD_API int (luaopen_os) (lua_State *L); 31 | 32 | #define LUA_STRLIBNAME "string" 33 | LUAMOD_API int (luaopen_string) (lua_State *L); 34 | 35 | #define LUA_UTF8LIBNAME "utf8" 36 | LUAMOD_API int (luaopen_utf8) (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 | #endif 53 | -------------------------------------------------------------------------------- /src/lua54/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h $ 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 | /* 22 | ** Encode major-minor version in one byte, one nibble for each 23 | */ 24 | #define MYINT(s) (s[0]-'0') /* assume one-digit numerals */ 25 | #define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR)) 26 | 27 | #define LUAC_FORMAT 0 /* this is the official format */ 28 | 29 | /* load one chunk; from lundump.c */ 30 | LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, const char* name); 31 | 32 | /* dump one chunk; from ldump.c */ 33 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, 34 | void* data, int strip); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/lua54/lzio.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.c $ 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 | -------------------------------------------------------------------------------- /src/lua54/lzio.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.h $ 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 void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, 48 | void *data); 49 | LUAI_FUNC size_t luaZ_read (ZIO* z, void *b, size_t n); /* read next n bytes */ 50 | 51 | 52 | 53 | /* --------- Private Part ------------------ */ 54 | 55 | struct Zio { 56 | size_t n; /* bytes still unread */ 57 | const char *p; /* current position in buffer */ 58 | lua_Reader reader; /* reader function */ 59 | void *data; /* additional data */ 60 | lua_State *L; /* Lua state (for reader) */ 61 | }; 62 | 63 | 64 | LUAI_FUNC int luaZ_fill (ZIO *z); 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /tool/luacheck/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "dmlua.h" 3 | 4 | 5 | int main(int argc, char** argv) { 6 | 7 | CDMLuaEngine oDMLuaEngine; 8 | 9 | std::string strScriptRootPath = DMGetRootPath(); 10 | oDMLuaEngine.SetRootPath(strScriptRootPath + PATH_DELIMITER_STR + ".." + PATH_DELIMITER_STR + "script"); 11 | 12 | if (!oDMLuaEngine.ReloadScript()) { 13 | return -1; 14 | } 15 | 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /tool/toluapp/SCsub: -------------------------------------------------------------------------------- 1 | Import('env') 2 | 3 | src = [ 4 | env.Object('tolua.c'), 5 | ] 6 | 7 | 8 | #toluabind = env.LuaBinding('toluabind.c', 'tolua_scons.pkg', 'tolua', bootstrap = True) 9 | 10 | env.bin_target = env.Program('#/bin/'+env['tolua_bin'], src, LIBS = ['$tolua_lib'] + env['LIBS']) 11 | 12 | env.bootstrap_target = env.Program('#/bin/'+env['TOLUAPP_BOOTSTRAP'], src + ['toluabind_default.c', env.lib_target_static], LIBS = env['LIBS']) 13 | -------------------------------------------------------------------------------- /tool/toluapp/lua/all.lua: -------------------------------------------------------------------------------- 1 | dofile(path.."compat51.lua") 2 | dofile(path.."compat.lua") 3 | dofile(path.."basic.lua") 4 | dofile(path.."feature.lua") 5 | dofile(path.."verbatim.lua") 6 | dofile(path.."code.lua") 7 | dofile(path.."typedef.lua") 8 | dofile(path.."container.lua") 9 | dofile(path.."package.lua") 10 | dofile(path.."module.lua") 11 | dofile(path.."namespace.lua") 12 | dofile(path.."define.lua") 13 | dofile(path.."enumerate.lua") 14 | dofile(path.."declaration.lua") 15 | dofile(path.."variable.lua") 16 | dofile(path.."array.lua") 17 | dofile(path.."function.lua") 18 | dofile(path.."operator.lua") 19 | dofile(path.."template_class.lua") 20 | dofile(path.."class.lua") 21 | dofile(path.."clean.lua") 22 | --dofile(path.."custom.lua") 23 | dofile(path.."doit.lua") 24 | 25 | local err,msg = xpcall(doit, debug.traceback) 26 | if not err then 27 | --print("**** msg is "..tostring(msg)) 28 | local _,_,label,msg = strfind(msg,"(.-:.-:%s*)(.*)") 29 | tolua_error(msg,label) 30 | end 31 | -------------------------------------------------------------------------------- /tool/toluapp/lua/bin2array: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brinkqiang/dmlua/47ec88828a178e50c7d7e0558526479b7176dbbc/tool/toluapp/lua/bin2array -------------------------------------------------------------------------------- /tool/toluapp/lua/bin2array.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brinkqiang/dmlua/47ec88828a178e50c7d7e0558526479b7176dbbc/tool/toluapp/lua/bin2array.exe -------------------------------------------------------------------------------- /tool/toluapp/lua/buildlua.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | for /f %%i in ('dir %~dp0*.lua /b') do ( 4 | echo checking "%~dp0%%i" 5 | %~dp0bin2array "%%i" 6 | if errorlevel 1 ( 7 | echo error: "%~dp0%%i" 8 | goto FAILED 9 | ) 10 | ) 11 | 12 | goto END 13 | 14 | :FAILED 15 | pause 16 | 17 | :END 18 | -------------------------------------------------------------------------------- /tool/toluapp/lua/clean.lua: -------------------------------------------------------------------------------- 1 | -- mark up comments and strings 2 | STR1 = "\001" 3 | STR2 = "\002" 4 | STR3 = "\003" 5 | STR4 = "\004" 6 | REM = "\005" 7 | ANY = "([\001-\005])" 8 | ESC1 = "\006" 9 | ESC2 = "\007" 10 | 11 | MASK = { -- the substitution order is important 12 | {ESC1, "\\'"}, 13 | {ESC2, '\\"'}, 14 | {STR1, "'"}, 15 | {STR2, '"'}, 16 | {STR3, "%[%["}, 17 | {STR4, "%]%]"}, 18 | {REM , "%-%-"}, 19 | } 20 | 21 | function mask (s) 22 | for i = 1,#MASK do 23 | s = gsub(s,MASK[i][2],MASK[i][1]) 24 | end 25 | return s 26 | end 27 | 28 | function unmask (s) 29 | for i = 1,#MASK do 30 | s = gsub(s,MASK[i][1],MASK[i][2]) 31 | end 32 | return s 33 | end 34 | 35 | function clean (s) 36 | -- check for compilation error 37 | local code = "return function ()\n" .. s .. "\n end" 38 | if not dostring(code) then 39 | return nil 40 | end 41 | 42 | if flags['C'] then 43 | return s 44 | end 45 | 46 | local S = "" -- saved string 47 | 48 | s = mask(s) 49 | 50 | -- remove blanks and comments 51 | while 1 do 52 | local b,e,d = strfind(s,ANY) 53 | if b then 54 | S = S..strsub(s,1,b-1) 55 | s = strsub(s,b+1) 56 | if d==STR1 or d==STR2 then 57 | e = strfind(s,d) 58 | S = S ..d..strsub(s,1,e) 59 | s = strsub(s,e+1) 60 | elseif d==STR3 then 61 | e = strfind(s,STR4) 62 | S = S..d..strsub(s,1,e) 63 | s = strsub(s,e+1) 64 | elseif d==REM then 65 | s = gsub(s,"[^\n]*(\n?)","%1",1) 66 | end 67 | else 68 | S = S..s 69 | break 70 | end 71 | end 72 | -- eliminate unecessary spaces 73 | S = gsub(S,"[ \t]+"," ") 74 | S = gsub(S,"[ \t]*\n[ \t]*","\n") 75 | S = gsub(S,"\n+","\n") 76 | S = unmask(S) 77 | return S 78 | end 79 | 80 | -------------------------------------------------------------------------------- /tool/toluapp/lua/code.lua: -------------------------------------------------------------------------------- 1 | -- tolua: code class 2 | -- Written by Waldemar Celes 3 | -- TeCGraf/PUC-Rio 4 | -- Jul 1999 5 | -- $Id: $ 6 | 7 | -- This code is free software; you can redistribute it and/or modify it. 8 | -- The software provided hereunder is on an "as is" basis, and 9 | -- the author has no obligation to provide maintenance, support, updates, 10 | -- enhancements, or modifications. 11 | 12 | -- global 13 | code_n = 1 14 | 15 | -- Code class 16 | -- Represents Lua code to be compiled and included 17 | -- in the initialization function. 18 | -- The following fields are stored: 19 | -- text = text code 20 | classCode = { 21 | text = '', 22 | } 23 | classCode.__index = classCode 24 | setmetatable(classCode,classFeature) 25 | 26 | -- register code 27 | function classCode:register (pre) 28 | pre = pre or '' 29 | -- clean Lua code 30 | local s = clean(self.text) 31 | if not s then 32 | --print(self.text) 33 | error("parser error in embedded code") 34 | end 35 | 36 | -- get first line 37 | local _, _, first_line=string.find(self.text, "^([^\n\r]*)") 38 | if string.find(first_line, "^%s*%-%-") then 39 | if string.find(first_line, "^%-%-##") then 40 | first_line = string.gsub(first_line, "^%-%-##", "") 41 | if flags['C'] then 42 | s = string.gsub(s, "^%-%-##[^\n\r]*\n", "") 43 | end 44 | end 45 | else 46 | first_line = "" 47 | end 48 | 49 | -- pad to 16 bytes 50 | local npad = 16 - (#s % 16) 51 | local spad = "" 52 | for i=1,npad do 53 | spad = spad .. "-" 54 | end 55 | s = s..spad 56 | 57 | -- convert to C 58 | output('\n'..pre..'{ /* begin embedded lua code */\n') 59 | output(pre..' int top = lua_gettop(tolua_S);') 60 | output(pre..' static const unsigned char B[] = {\n ') 61 | local t={n=0} 62 | 63 | local b = gsub(s,'(.)',function (c) 64 | local e = '' 65 | t.n=t.n+1 if t.n==15 then t.n=0 e='\n'..pre..' ' end 66 | return format('%3u,%s',strbyte(c),e) 67 | end 68 | ) 69 | output(b..strbyte(" ")) 70 | output('\n'..pre..' };\n') 71 | if first_line and first_line ~= "" then 72 | output(pre..' tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: '..first_line..'");') 73 | else 74 | output(pre..' tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code '..code_n..'");') 75 | end 76 | output(pre..' lua_settop(tolua_S, top);') 77 | output(pre..'} /* end of embedded lua code */\n\n') 78 | code_n = code_n +1 79 | end 80 | 81 | 82 | -- Print method 83 | function classCode:print (ident,close) 84 | print(ident.."Code{") 85 | print(ident.." text = [["..self.text.."]],") 86 | print(ident.."}"..close) 87 | end 88 | 89 | 90 | -- Internal constructor 91 | function _Code (t) 92 | setmetatable(t,classCode) 93 | append(t) 94 | return t 95 | end 96 | 97 | -- Constructor 98 | -- Expects a string representing the code text 99 | function Code (l) 100 | return _Code { 101 | text = l 102 | } 103 | end 104 | 105 | 106 | -------------------------------------------------------------------------------- /tool/toluapp/lua/compat51.lua: -------------------------------------------------------------------------------- 1 | if string.find(_VERSION, "5%.0") then 2 | return 3 | end 4 | 5 | -- "loadfile" 6 | local function pp_dofile(path) 7 | 8 | local loaded = false 9 | local getfile = function() 10 | 11 | if loaded then 12 | return 13 | else 14 | local file,err = io.open(path) 15 | if not file then 16 | error("error loading file "..path..": "..err) 17 | end 18 | local ret = file:read("*a") 19 | file:close() 20 | 21 | ret = string.gsub(ret, "%.%.%.%s*%)", "...) local arg = {n=select('#', ...), ...};") 22 | 23 | loaded = true 24 | return ret 25 | end 26 | end 27 | 28 | local f, errmsg = load(getfile, path) 29 | if not f then 30 | 31 | error("error loading file "..path ..": " .. errmsg) 32 | end 33 | return f() 34 | end 35 | 36 | old_dofile = dofile 37 | dofile = pp_dofile 38 | 39 | 40 | -- string.gsub 41 | --[[ 42 | local ogsub = string.gsub 43 | local function compgsub(a,b,c,d) 44 | if type(c) == "function" then 45 | local oc = c 46 | c = function (...) return oc(...) or '' end 47 | end 48 | return ogsub(a,b,c,d) 49 | end 50 | string.repl = ogsub 51 | --]] 52 | 53 | --string.gsub = compgsub 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /tool/toluapp/lua/custom.lua: -------------------------------------------------------------------------------- 1 | 2 | function extract_code(fn,s) 3 | local code = "" 4 | if fn then 5 | code = '\n$#include "'..fn..'"\n' 6 | end 7 | s= "\n" .. s .. "\n" -- add blank lines as sentinels 8 | local _,e,c,t = strfind(s, "\n([^\n]-)SCRIPT_([%w_]*)[^\n]*\n") 9 | while e do 10 | t = strlower(t) 11 | if t == "bind_begin" then 12 | _,e,c = strfind(s,"(.-)\n[^\n]*SCRIPT_BIND_END[^\n]*\n",e) 13 | if not e then 14 | tolua_error("Unbalanced 'SCRIPT_BIND_BEGIN' directive in header file") 15 | end 16 | end 17 | if t == "bind_class" or t == "bind_block" then 18 | local b 19 | _,e,c,b = string.find(s, "([^{]-)(%b{})", e) 20 | c = c..'{\n'..extract_code(nil, b)..'\n};\n' 21 | end 22 | code = code .. c .. "\n" 23 | _,e,c,t = strfind(s, "\n([^\n]-)SCRIPT_([%w_]*)[^\n]*\n",e) 24 | end 25 | return code 26 | end 27 | 28 | function preprocess_hook(p) 29 | end 30 | 31 | function preparse_hook(p) 32 | end 33 | 34 | function include_file_hook(p, filename) 35 | do return end 36 | --print("FILENAME is "..filename) 37 | p.code = string.gsub(p.code, "\n%s*SigC::Signal", "\n\ttolua_readonly SigC::Signal") 38 | p.code = string.gsub(p.code, "#ifdef __cplusplus\nextern \"C\" {\n#endif", "") 39 | p.code = string.gsub(p.code, "#ifdef __cplusplus\n};?\n#endif", "") 40 | p.code = string.gsub(p.code, "DECLSPEC", "") 41 | p.code = string.gsub(p.code, "SDLCALL", "") 42 | p.code = string.gsub(p.code, "DLLINTERFACE", "") 43 | p.code = string.gsub(p.code, "#define[^\n]*_[hH]_?%s*\n", "\n") 44 | --print("code is "..p.code) 45 | end 46 | -------------------------------------------------------------------------------- /tool/toluapp/lua/define.lua: -------------------------------------------------------------------------------- 1 | -- tolua: define class 2 | -- Written by Waldemar Celes 3 | -- TeCGraf/PUC-Rio 4 | -- Jul 1998 5 | -- $Id: define.lua,v 1.2 1999/07/28 22:21:08 celes Exp $ 6 | 7 | -- This code is free software; you can redistribute it and/or modify it. 8 | -- The software provided hereunder is on an "as is" basis, and 9 | -- the author has no obligation to provide maintenance, support, updates, 10 | -- enhancements, or modifications. 11 | 12 | 13 | -- Define class 14 | -- Represents a numeric const definition 15 | -- The following filds are stored: 16 | -- name = constant name 17 | classDefine = { 18 | name = '', 19 | } 20 | classDefine.__index = classDefine 21 | setmetatable(classDefine,classFeature) 22 | 23 | -- register define 24 | function classDefine:register (pre) 25 | if not self:check_public_access() then 26 | return 27 | end 28 | 29 | pre = pre or '' 30 | output(pre..'tolua_constant(tolua_S,"'..self.lname..'",'..self.name..');') 31 | end 32 | 33 | -- Print method 34 | function classDefine:print (ident,close) 35 | print(ident.."Define{") 36 | print(ident.." name = '"..self.name.."',") 37 | print(ident.." lname = '"..self.lname.."',") 38 | print(ident.."}"..close) 39 | end 40 | 41 | 42 | -- Internal constructor 43 | function _Define (t) 44 | setmetatable(t,classDefine) 45 | t:buildnames() 46 | 47 | if t.name == '' then 48 | error("#invalid define") 49 | end 50 | 51 | append(t) 52 | return t 53 | end 54 | 55 | -- Constructor 56 | -- Expects a string representing the constant name 57 | function Define (n) 58 | return _Define{ 59 | name = n 60 | } 61 | end 62 | 63 | 64 | -------------------------------------------------------------------------------- /tool/toluapp/lua/doit.lua: -------------------------------------------------------------------------------- 1 | -- Generate binding code 2 | -- Written by Waldemar Celes 3 | -- TeCGraf/PUC-Rio 4 | -- Jul 1998 5 | -- Last update: Apr 2003 6 | -- $Id: $ 7 | 8 | 9 | -- This code is free software; you can redistribute it and/or modify it. 10 | -- The software provided hereunder is on an "as is" basis, and 11 | -- the author has no obligation to provide maintenance, support, updates, 12 | -- enhancements, or modifications. 13 | 14 | function parse_extra() 15 | 16 | for k,v in ipairs(_extra_parameters or {}) do 17 | 18 | local b,e,name,value = string.find(v, "^([^=]*)=(.*)$") 19 | if b then 20 | _extra_parameters[name] = value 21 | else 22 | _extra_parameters[v] = true 23 | end 24 | end 25 | end 26 | 27 | function doit () 28 | -- define package name, if not provided 29 | if not flags.n then 30 | if flags.f then 31 | flags.n = gsub(flags.f,"%..*$","") 32 | _,_,flags.n = string.find(flags.n, "([^/\\]*)$") 33 | else 34 | error("#no package name nor input file provided") 35 | end 36 | end 37 | 38 | -- parse table with extra paramters 39 | parse_extra() 40 | 41 | -- do this after setting the package name 42 | if flags['L'] then 43 | dofile(flags['L']) 44 | end 45 | 46 | -- add cppstring 47 | if not flags['S'] then 48 | _basic['string'] = 'cppstring' 49 | _basic['std::string'] = 'cppstring' 50 | _basic_ctype.cppstring = 'const char*' 51 | end 52 | 53 | -- proccess package 54 | local p = Package(flags.n,flags.f) 55 | 56 | if flags.p then 57 | return -- only parse 58 | end 59 | 60 | if flags.o then 61 | local st,msg = writeto(flags.o) 62 | if not st then 63 | error('#'..msg) 64 | end 65 | end 66 | 67 | p:decltype() 68 | if flags.P then 69 | p:print() 70 | else 71 | push(p) 72 | pre_output_hook(p) 73 | pop() 74 | p:preamble() 75 | p:supcode() 76 | push(p) 77 | pre_register_hook(p) 78 | pop() 79 | p:register() 80 | push(p) 81 | post_output_hook(p) 82 | pop() 83 | end 84 | 85 | if flags.o then 86 | writeto() 87 | end 88 | 89 | -- write header file 90 | if not flags.P then 91 | if flags.H then 92 | local st,msg = writeto(flags.H) 93 | if not st then 94 | error('#'..msg) 95 | end 96 | p:header() 97 | writeto() 98 | end 99 | end 100 | end 101 | 102 | -------------------------------------------------------------------------------- /tool/toluapp/lua/enumerate.lua: -------------------------------------------------------------------------------- 1 | -- tolua: enumerate class 2 | -- Written by Waldemar Celes 3 | -- TeCGraf/PUC-Rio 4 | -- Jul 1998 5 | -- $Id: enumerate.lua,v 1.3 2000/01/24 20:41:15 celes Exp $ 6 | 7 | -- This code is free software; you can redistribute it and/or modify it. 8 | -- The software provided hereunder is on an "as is" basis, and 9 | -- the author has no obligation to provide maintenance, support, updates, 10 | -- enhancements, or modifications. 11 | 12 | 13 | -- Enumerate class 14 | -- Represents enumeration 15 | -- The following fields are stored: 16 | -- {i} = list of constant names 17 | classEnumerate = { 18 | } 19 | classEnumerate.__index = classEnumerate 20 | setmetatable(classEnumerate,classFeature) 21 | 22 | -- register enumeration 23 | function classEnumerate:register (pre) 24 | if not self:check_public_access() then 25 | return 26 | end 27 | pre = pre or '' 28 | local nspace = getnamespace(classContainer.curr) 29 | local i=1 30 | while self[i] do 31 | if self.lnames[i] and self.lnames[i] ~= "" then 32 | 33 | output(pre..'tolua_constant(tolua_S,"'..self.lnames[i]..'",'..nspace..self[i]..');') 34 | end 35 | i = i+1 36 | end 37 | end 38 | 39 | -- Print method 40 | function classEnumerate:print (ident,close) 41 | print(ident.."Enumerate{") 42 | print(ident.." name = "..self.name) 43 | local i=1 44 | while self[i] do 45 | print(ident.." '"..self[i].."'("..self.lnames[i].."),") 46 | i = i+1 47 | end 48 | print(ident.."}"..close) 49 | end 50 | 51 | -- Internal constructor 52 | function _Enumerate (t,varname) 53 | setmetatable(t,classEnumerate) 54 | append(t) 55 | appendenum(t) 56 | if varname and varname ~= "" then 57 | if t.name ~= "" then 58 | Variable(t.name.." "..varname) 59 | else 60 | local ns = getcurrnamespace() 61 | warning("Variable "..ns..varname.." of type is declared as read-only") 62 | Variable("tolua_readonly int "..varname) 63 | end 64 | end 65 | local parent = classContainer.curr 66 | if parent then 67 | t.access = parent.curr_member_access 68 | t.global_access = t:check_public_access() 69 | end 70 | return t 71 | end 72 | 73 | -- Constructor 74 | -- Expects a string representing the enumerate body 75 | function Enumerate (n,b,varname) 76 | b = string.gsub(b, ",[%s\n]*}", "\n}") -- eliminate last ',' 77 | local t = split(strsub(b,2,-2),',') -- eliminate braces 78 | local i = 1 79 | local e = {n=0} 80 | while t[i] do 81 | local tt = split(t[i],'=') -- discard initial value 82 | e.n = e.n + 1 83 | e[e.n] = tt[1] 84 | i = i+1 85 | end 86 | -- set lua names 87 | i = 1 88 | e.lnames = {} 89 | local ns = getcurrnamespace() 90 | while e[i] do 91 | local t = split(e[i],'@') 92 | e[i] = t[1] 93 | if not t[2] then 94 | t[2] = applyrenaming(t[1]) 95 | end 96 | e.lnames[i] = t[2] or t[1] 97 | _global_enums[ ns..e[i] ] = (ns..e[i]) 98 | i = i+1 99 | end 100 | e.name = n 101 | if n ~= "" then 102 | Typedef("int "..n) 103 | end 104 | return _Enumerate(e, varname) 105 | end 106 | 107 | -------------------------------------------------------------------------------- /tool/toluapp/lua/feature.lua: -------------------------------------------------------------------------------- 1 | -- tolua: abstract feature class 2 | -- Written by Waldemar Celes 3 | -- TeCGraf/PUC-Rio 4 | -- Jul 1998 5 | -- $Id: $ 6 | 7 | -- This code is free software; you can redistribute it and/or modify it. 8 | -- The software provided hereunder is on an "as is" basis, and 9 | -- the author has no obligation to provide maintenance, support, updates, 10 | -- enhancements, or modifications. 11 | 12 | 13 | -- Feature class 14 | -- Represents the base class of all mapped feature. 15 | classFeature = { 16 | } 17 | classFeature.__index = classFeature 18 | 19 | -- write support code 20 | function classFeature:supcode () 21 | end 22 | 23 | -- output tag 24 | function classFeature:decltype () 25 | end 26 | 27 | -- register feature 28 | function classFeature:register (pre) 29 | end 30 | 31 | -- translate verbatim 32 | function classFeature:preamble () 33 | end 34 | 35 | -- check if it is a variable 36 | function classFeature:isvariable () 37 | return false 38 | end 39 | 40 | -- check if it requires collection 41 | function classFeature:requirecollection (t) 42 | return false 43 | end 44 | 45 | -- build names 46 | function classFeature:buildnames () 47 | if self.name and self.name~='' then 48 | local n = split(self.name,'@') 49 | self.name = n[1] 50 | self.name = string.gsub(self.name, ":%d*$", "") 51 | if not n[2] then 52 | n[2] = applyrenaming(n[1]) 53 | end 54 | self.lname = n[2] or gsub(n[1],"%[.-%]","") 55 | self.lname = string.gsub(self.lname, ":%d*$", "") 56 | self.original_name = self.name 57 | self.lname = clean_template(self.lname) 58 | end 59 | if not self.is_parameter then 60 | self.name = getonlynamespace() .. self.name 61 | end 62 | 63 | local parent = classContainer.curr 64 | if parent then 65 | self.access = parent.curr_member_access 66 | self.global_access = self:check_public_access() 67 | else 68 | end 69 | end 70 | 71 | function classFeature:check_public_access() 72 | 73 | if type(self.global_access) == "boolean" then 74 | return self.global_access 75 | end 76 | 77 | if self.access and self.access ~= 0 then 78 | return false 79 | end 80 | 81 | local parent = classContainer.curr 82 | while parent do 83 | if parent.access and parent.access ~= 0 then 84 | return false 85 | end 86 | parent = parent.prox 87 | end 88 | return true 89 | end 90 | 91 | function clean_template(t) 92 | 93 | return string.gsub(t, "[<>:, %*]", "_") 94 | end 95 | 96 | -- check if feature is inside a container definition 97 | -- it returns the container class name or nil. 98 | function classFeature:incontainer (which) 99 | if self.parent then 100 | local parent = self.parent 101 | while parent do 102 | if parent.classtype == which then 103 | return parent.name 104 | end 105 | parent = parent.parent 106 | end 107 | end 108 | return nil 109 | end 110 | 111 | function classFeature:inclass () 112 | return self:incontainer('class') 113 | end 114 | 115 | function classFeature:inmodule () 116 | return self:incontainer('module') 117 | end 118 | 119 | function classFeature:innamespace () 120 | return self:incontainer('namespace') 121 | end 122 | 123 | -- return C binding function name based on name 124 | -- the client specifies a prefix 125 | function classFeature:cfuncname (n) 126 | 127 | if self.parent then 128 | n = self.parent:cfuncname(n) 129 | end 130 | 131 | local fname = self.lname 132 | if not fname or fname == '' then 133 | fname = self.name 134 | end 135 | n = string.gsub(n..'_'.. (fname), "[<>:, \\.%*&]", "_") 136 | 137 | return n 138 | end 139 | 140 | -------------------------------------------------------------------------------- /tool/toluapp/lua/module.lua: -------------------------------------------------------------------------------- 1 | -- tolua: module class 2 | -- Written by Waldemar Celes 3 | -- TeCGraf/PUC-Rio 4 | -- Jul 1998 5 | -- $Id: $ 6 | 7 | -- This code is free software; you can redistribute it and/or modify it. 8 | -- The software provided hereunder is on an "as is" basis, and 9 | -- the author has no obligation to provide maintenance, support, updates, 10 | -- enhancements, or modifications. 11 | 12 | 13 | 14 | -- Module class 15 | -- Represents module. 16 | -- The following fields are stored: 17 | -- {i} = list of objects in the module. 18 | classModule = { 19 | classtype = 'module' 20 | } 21 | classModule.__index = classModule 22 | setmetatable(classModule,classContainer) 23 | 24 | -- register module 25 | function classModule:register (pre) 26 | pre = pre or '' 27 | push(self) 28 | output(pre..'tolua_module(tolua_S,"'..self.name..'",',self:hasvar(),');') 29 | output(pre..'tolua_beginmodule(tolua_S,"'..self.name..'");') 30 | local i=1 31 | while self[i] do 32 | self[i]:register(pre..' ') 33 | i = i+1 34 | end 35 | output(pre..'tolua_endmodule(tolua_S);') 36 | pop() 37 | end 38 | 39 | -- Print method 40 | function classModule:print (ident,close) 41 | print(ident.."Module{") 42 | print(ident.." name = '"..self.name.."';") 43 | local i=1 44 | while self[i] do 45 | self[i]:print(ident.." ",",") 46 | i = i+1 47 | end 48 | print(ident.."}"..close) 49 | end 50 | 51 | -- Internal constructor 52 | function _Module (t) 53 | setmetatable(t,classModule) 54 | append(t) 55 | return t 56 | end 57 | 58 | -- Constructor 59 | -- Expects two string representing the module name and body. 60 | function Module (n,b) 61 | local t = _Module(_Container{name=n}) 62 | push(t) 63 | t:parse(strsub(b,2,strlen(b)-1)) -- eliminate braces 64 | pop() 65 | return t 66 | end 67 | 68 | 69 | -------------------------------------------------------------------------------- /tool/toluapp/lua/namespace.lua: -------------------------------------------------------------------------------- 1 | -- tolua: namespace class 2 | -- Written by Waldemar Celes 3 | -- TeCGraf/PUC-Rio 4 | -- Jul 2003 5 | -- $Id: $ 6 | 7 | -- This code is free software; you can redistribute it and/or modify it. 8 | -- The software provided hereunder is on an "as is" basis, and 9 | -- the author has no obligation to provide maintenance, support, updates, 10 | -- enhancements, or modifications. 11 | 12 | 13 | -- Namespace class 14 | -- Represents a namesapce definition. 15 | -- Stores the following fields: 16 | -- name = class name 17 | -- {i} = list of members 18 | classNamespace = { 19 | classtype = 'namespace', 20 | name = '', 21 | } 22 | classNamespace.__index = classNamespace 23 | setmetatable(classNamespace,classModule) 24 | 25 | -- Print method 26 | function classNamespace:print (ident,close) 27 | print(ident.."Namespace{") 28 | print(ident.." name = '"..self.name.."',") 29 | local i=1 30 | while self[i] do 31 | self[i]:print(ident.." ",",") 32 | i = i+1 33 | end 34 | print(ident.."}"..close) 35 | end 36 | 37 | -- Internal constructor 38 | function _Namespace (t) 39 | setmetatable(t,classNamespace) 40 | append(t) 41 | return t 42 | end 43 | 44 | -- Constructor 45 | -- Expects the name and the body of the namespace. 46 | function Namespace (n,b) 47 | local c = _Namespace(_Container{name=n}) 48 | push(c) 49 | c:parse(strsub(b,2,strlen(b)-1)) -- eliminate braces 50 | pop() 51 | end 52 | 53 | -------------------------------------------------------------------------------- /tool/toluapp/lua/template_class.lua: -------------------------------------------------------------------------------- 1 | 2 | _global_templates = {} 3 | 4 | classTemplateClass = { 5 | 6 | name = '', 7 | body = '', 8 | parents = {}, 9 | args = {}, -- the template arguments 10 | } 11 | 12 | classTemplateClass.__index = classTemplateClass 13 | 14 | 15 | function classTemplateClass:throw(types, local_scope) 16 | 17 | --if table.getn(types) ~= table.getn(self.args) then 18 | -- error("#invalid parameter count") 19 | --end 20 | 21 | -- replace 22 | for i =1 , types.n do 23 | 24 | local Il = split_c_tokens(types[i], " ") 25 | if #Il ~= #self.args then 26 | error("#invalid parameter count for "..types[i]) 27 | end 28 | local bI = self.body 29 | local pI = {} 30 | for j = 1,self.args.n do 31 | --Tl[j] = findtype(Tl[j]) or Tl[j] 32 | bI = string.gsub(bI, "([^_%w])"..self.args[j].."([^_%w])", "%1"..Il[j].."%2") 33 | if self.parents then 34 | for i=1,#self.parents do 35 | pI[i] = string.gsub(self.parents[i], "([^_%w]?)"..self.args[j].."([^_%w]?)", "%1"..Il[j].."%2") 36 | end 37 | end 38 | end 39 | --local append = "<"..string.gsub(types[i], "%s+", ",")..">" 40 | local append = "<"..concat(Il, 1, #Il, ",")..">" 41 | append = string.gsub(append, "%s*,%s*", ",") 42 | append = string.gsub(append, ">>", "> >") 43 | for i=1,#pI do 44 | --pI[i] = string.gsub(pI[i], ">>", "> >") 45 | pI[i] = resolve_template_types(pI[i]) 46 | end 47 | bI = string.gsub(bI, ">>", "> >") 48 | local n = self.name 49 | if local_scope then 50 | n = self.local_name 51 | end 52 | 53 | Class(n..append, pI, bI) 54 | end 55 | end 56 | 57 | 58 | function TemplateClass(name, parents, body, parameters) 59 | 60 | local o = { 61 | 62 | parents = parents, 63 | body = body, 64 | args = parameters, 65 | } 66 | 67 | local oname = string.gsub(name, "@.*$", "") 68 | oname = getnamespace(classContainer.curr)..oname 69 | o.name = oname 70 | 71 | o.local_name = name 72 | 73 | setmetatable(o, classTemplateClass) 74 | 75 | if _global_templates[oname] then 76 | warning("Duplicate declaration of template "..oname) 77 | else 78 | _global_templates[oname] = o 79 | end 80 | 81 | return o 82 | end 83 | -------------------------------------------------------------------------------- /tool/toluapp/lua/typedef.lua: -------------------------------------------------------------------------------- 1 | -- tolua: typedef class 2 | -- Written by Waldemar Celes 3 | -- TeCGraf/PUC-Rio 4 | -- Jul 1998 5 | -- $Id: $ 6 | 7 | -- This code is free software; you can redistribute it and/or modify it. 8 | -- The software provided hereunder is on an "as is" basis, and 9 | -- the author has no obligation to provide maintenance, support, updates, 10 | -- enhancements, or modifications. 11 | 12 | 13 | 14 | -- Typedef class 15 | -- Represents a type synonym. 16 | -- The 'de facto' type replaces the typedef before the 17 | -- remaining code is parsed. 18 | -- The following fields are stored: 19 | -- utype = typedef name 20 | -- type = 'the facto' type 21 | -- mod = modifiers to the 'de facto' type 22 | classTypedef = { 23 | utype = '', 24 | mod = '', 25 | type = '' 26 | } 27 | classTypedef.__index = classTypedef 28 | 29 | -- Print method 30 | function classTypedef:print (ident,close) 31 | print(ident.."Typedef{") 32 | print(ident.." utype = '"..self.utype.."',") 33 | print(ident.." mod = '"..self.mod.."',") 34 | print(ident.." type = '"..self.type.."',") 35 | print(ident.."}"..close) 36 | end 37 | 38 | -- Return it's not a variable 39 | function classTypedef:isvariable () 40 | return false 41 | end 42 | 43 | -- Internal constructor 44 | function _Typedef (t) 45 | setmetatable(t,classTypedef) 46 | t.type = resolve_template_types(t.type) 47 | appendtypedef(t) 48 | return t 49 | end 50 | 51 | -- Constructor 52 | -- Expects one string representing the type definition. 53 | function Typedef (s) 54 | if strfind(string.gsub(s, '%b<>', ''),'[%*&]') then 55 | tolua_error("#invalid typedef: pointers (and references) are not supported") 56 | end 57 | local o = {mod = ''} 58 | if string.find(s, "[<>]") then 59 | _,_,o.type,o.utype = string.find(s, "^%s*([^<>]+%b<>[^%s]*)%s+(.-)$") 60 | else 61 | local t = split(gsub(s,"%s%s*"," ")," ") 62 | o = { 63 | utype = t[t.n], 64 | type = t[t.n-1], 65 | mod = concat(t,1,t.n-2), 66 | } 67 | end 68 | return _Typedef(o) 69 | end 70 | 71 | 72 | -------------------------------------------------------------------------------- /tool/toluapp/lua/verbatim.lua: -------------------------------------------------------------------------------- 1 | -- tolua: verbatim class 2 | -- Written by Waldemar Celes 3 | -- TeCGraf/PUC-Rio 4 | -- Jul 1998 5 | -- $Id: verbatim.lua,v 1.3 2000/01/24 20:41:16 celes Exp $ 6 | 7 | -- This code is free software; you can redistribute it and/or modify it. 8 | -- The software provided hereunder is on an "as is" basis, and 9 | -- the author has no obligation to provide maintenance, support, updates, 10 | -- enhancements, or modifications. 11 | 12 | 13 | 14 | -- Verbatim class 15 | -- Represents a line translated directed to the binding file. 16 | -- The following filds are stored: 17 | -- line = line text 18 | classVerbatim = { 19 | line = '', 20 | cond = nil, -- condition: where to generate the code (s=suport, r=register) 21 | } 22 | classVerbatim.__index = classVerbatim 23 | setmetatable(classVerbatim,classFeature) 24 | 25 | -- preamble verbatim 26 | function classVerbatim:preamble () 27 | if self.cond == '' then 28 | write(self.line) 29 | end 30 | end 31 | 32 | -- support code 33 | function classVerbatim:supcode () 34 | if strfind(self.cond,'s') then 35 | write(self.line) 36 | write('\n') 37 | end 38 | end 39 | 40 | -- register code 41 | function classVerbatim:register (pre) 42 | if strfind(self.cond,'r') then 43 | write(self.line) 44 | end 45 | end 46 | 47 | 48 | -- Print method 49 | function classVerbatim:print (ident,close) 50 | print(ident.."Verbatim{") 51 | print(ident.." line = '"..self.line.."',") 52 | print(ident.."}"..close) 53 | end 54 | 55 | 56 | -- Internal constructor 57 | function _Verbatim (t) 58 | setmetatable(t,classVerbatim) 59 | append(t) 60 | return t 61 | end 62 | 63 | -- Constructor 64 | -- Expects a string representing the text line 65 | function Verbatim (l,cond) 66 | if strsub(l,1,1) == "'" then 67 | l = strsub(l,2) 68 | elseif strsub(l,1,1) == '$' then 69 | cond = 'sr' -- generates in both suport and register fragments 70 | l = strsub(l,2) 71 | end 72 | return _Verbatim { 73 | line = l, 74 | cond = cond or '', 75 | } 76 | end 77 | 78 | 79 | -------------------------------------------------------------------------------- /tool/toluapp/luabin.h: -------------------------------------------------------------------------------- 1 | 2 | #include "lua/compat51.h" 3 | 4 | #include "lua/compat.h" 5 | #include "lua/basic.h" 6 | #include "lua/feature.h" 7 | #include "lua/verbatim.h" 8 | #include "lua/code.h" 9 | #include "lua/typedef.h" 10 | #include "lua/container.h" 11 | #include "lua/package.h" 12 | #include "lua/module.h" 13 | #include "lua/namespace.h" 14 | #include "lua/define.h" 15 | #include "lua/enumerate.h" 16 | #include "lua/declaration.h" 17 | #include "lua/variable.h" 18 | #include "lua/array.h" 19 | #include "lua/function.h" 20 | #include "lua/operator.h" 21 | #include "lua/template_class.h" 22 | #include "lua/class.h" 23 | #include "lua/clean.h" 24 | //#include "lua/custom.h" 25 | #include "lua/doit.h" -------------------------------------------------------------------------------- /tool/toluapp/tolua_scons.pkg: -------------------------------------------------------------------------------- 1 | $lfile "src/bin/lua/compat-5.1.lua" 2 | $lfile "src/bin/lua/compat.lua" 3 | $lfile "src/bin/lua/basic.lua" 4 | $lfile "src/bin/lua/feature.lua" 5 | $lfile "src/bin/lua/verbatim.lua" 6 | $lfile "src/bin/lua/code.lua" 7 | $lfile "src/bin/lua/typedef.lua" 8 | $lfile "src/bin/lua/container.lua" 9 | $lfile "src/bin/lua/package.lua" 10 | $lfile "src/bin/lua/module.lua" 11 | $lfile "src/bin/lua/namespace.lua" 12 | $lfile "src/bin/lua/define.lua" 13 | $lfile "src/bin/lua/enumerate.lua" 14 | $lfile "src/bin/lua/declaration.lua" 15 | $lfile "src/bin/lua/variable.lua" 16 | $lfile "src/bin/lua/array.lua" 17 | $lfile "src/bin/lua/function.lua" 18 | $lfile "src/bin/lua/operator.lua" 19 | $lfile "src/bin/lua/template_class.lua" 20 | $lfile "src/bin/lua/class.lua" 21 | $lfile "src/bin/lua/clean.lua" 22 | $lfile "src/bin/lua/doit.lua" 23 | 24 | $[ 25 | local err,msg = pcall(doit) 26 | if not err then 27 | local _,_,label,msg = strfind(msg,"(.-:.-:%s*)(.*)") 28 | tolua_error(msg,label) 29 | print(debug.traceback()) 30 | end 31 | $] 32 | -------------------------------------------------------------------------------- /tool/toluapp/toluabind.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Lua binding: tolua 3 | ** Generated automatically by tolua++-1.0.92 on Sun Feb 15 22:29:48 2009. 4 | */ 5 | 6 | /* Exported function */ 7 | TOLUA_API int tolua_tolua_open( lua_State* tolua_S ); 8 | 9 | -------------------------------------------------------------------------------- /tool/toluapp/toluabind_default.h.bak: -------------------------------------------------------------------------------- 1 | /* 2 | ** Lua binding: tolua 3 | ** Generated automatically by tolua++-1.0.8pre2 on Tue Dec 13 01:43:55 2005. 4 | */ 5 | 6 | /* Exported function */ 7 | TOLUA_API int tolua_tolua_open( lua_State* tolua_S ); 8 | 9 | --------------------------------------------------------------------------------