├── .gitignore ├── .vscode ├── launch.json ├── settings.json └── task.json ├── 3rdparty ├── HP-Socket │ ├── include │ │ └── HPSocket │ │ │ ├── HPSocket-SSL.h │ │ │ ├── HPSocket.h │ │ │ ├── HPSocket4C-SSL.h │ │ │ ├── HPSocket4C.h │ │ │ ├── HPTypeDef.h │ │ │ └── SocketInterface.h │ └── lib │ │ ├── HPSocket.dll │ │ ├── HPSocket.lib │ │ ├── HPSocket_D.dll │ │ └── HPSocket_D.lib ├── libcrypto_static.lib ├── lua │ ├── CMakeLists.txt │ ├── include │ │ ├── lapi.h │ │ ├── lauxlib.h │ │ ├── lcode.h │ │ ├── lctype.h │ │ ├── ldebug.h │ │ ├── ldo.h │ │ ├── lfunc.h │ │ ├── lgc.h │ │ ├── ljumptab.h │ │ ├── llex.h │ │ ├── llimits.h │ │ ├── lmem.h │ │ ├── lobject.h │ │ ├── lopcodes.h │ │ ├── lopnames.h │ │ ├── lparser.h │ │ ├── lprefix.h │ │ ├── lstate.h │ │ ├── lstring.h │ │ ├── ltable.h │ │ ├── ltm.h │ │ ├── lua.h │ │ ├── lua.hpp │ │ ├── luaconf.h │ │ ├── lualib.h │ │ ├── lundump.h │ │ ├── lvm.h │ │ └── lzio.h │ └── src │ │ ├── lapi.c │ │ ├── lauxlib.c │ │ ├── lbaselib.c │ │ ├── lcode.c │ │ ├── lcorolib.c │ │ ├── lctype.c │ │ ├── ldblib.c │ │ ├── ldebug.c │ │ ├── ldo.c │ │ ├── ldump.c │ │ ├── lfunc.c │ │ ├── lgc.c │ │ ├── linit.c │ │ ├── liolib.c │ │ ├── llex.c │ │ ├── lmathlib.c │ │ ├── lmem.c │ │ ├── loadlib.c │ │ ├── lobject.c │ │ ├── lopcodes.c │ │ ├── loslib.c │ │ ├── lparser.c │ │ ├── lstate.c │ │ ├── lstring.c │ │ ├── lstrlib.c │ │ ├── ltable.c │ │ ├── ltablib.c │ │ ├── ltm.c │ │ ├── lua.c │ │ ├── luac.c │ │ ├── lundump.c │ │ ├── lutf8lib.c │ │ ├── lvm.c │ │ └── lzio.c └── sol │ ├── abort.hpp │ ├── as_args.hpp │ ├── as_returns.hpp │ ├── assert.hpp │ ├── base_traits.hpp │ ├── bind_traits.hpp │ ├── bytecode.hpp │ ├── call.hpp │ ├── compatibility.hpp │ ├── compatibility │ ├── compat-5.3.c.h │ ├── compat-5.3.h │ ├── compat-5.4.h │ └── lua_version.hpp │ ├── config.hpp │ ├── coroutine.hpp │ ├── debug.hpp │ ├── demangle.hpp │ ├── deprecate.hpp │ ├── detail │ └── build_version.hpp │ ├── dump_handler.hpp │ ├── ebco.hpp │ ├── environment.hpp │ ├── epilogue.hpp │ ├── error.hpp │ ├── error_handler.hpp │ ├── forward.hpp │ ├── forward_as.hpp │ ├── forward_detail.hpp │ ├── function.hpp │ ├── function_result.hpp │ ├── function_types.hpp │ ├── function_types_core.hpp │ ├── function_types_overloaded.hpp │ ├── function_types_stateful.hpp │ ├── function_types_stateless.hpp │ ├── function_types_templated.hpp │ ├── in_place.hpp │ ├── inheritance.hpp │ ├── load_result.hpp │ ├── lua_table.hpp │ ├── lua_value.hpp │ ├── make_reference.hpp │ ├── metatable.hpp │ ├── object.hpp │ ├── object_base.hpp │ ├── optional.hpp │ ├── optional_implementation.hpp │ ├── overload.hpp │ ├── packaged_coroutine.hpp │ ├── pairs_iterator.hpp │ ├── pointer_like.hpp │ ├── policies.hpp │ ├── prologue.hpp │ ├── property.hpp │ ├── protect.hpp │ ├── protected_function.hpp │ ├── protected_function_result.hpp │ ├── protected_handler.hpp │ ├── proxy_base.hpp │ ├── raii.hpp │ ├── reference.hpp │ ├── resolve.hpp │ ├── sol.hpp │ ├── stack.hpp │ ├── stack │ └── detail │ │ └── pairs.hpp │ ├── stack_check.hpp │ ├── stack_check_get.hpp │ ├── stack_check_get_qualified.hpp │ ├── stack_check_get_unqualified.hpp │ ├── stack_check_qualified.hpp │ ├── stack_check_unqualified.hpp │ ├── stack_core.hpp │ ├── stack_field.hpp │ ├── stack_get.hpp │ ├── stack_get_qualified.hpp │ ├── stack_get_unqualified.hpp │ ├── stack_guard.hpp │ ├── stack_iterator.hpp │ ├── stack_pop.hpp │ ├── stack_probe.hpp │ ├── stack_proxy.hpp │ ├── stack_proxy_base.hpp │ ├── stack_push.hpp │ ├── stack_reference.hpp │ ├── state.hpp │ ├── state_handling.hpp │ ├── state_view.hpp │ ├── string_view.hpp │ ├── table.hpp │ ├── table_core.hpp │ ├── table_iterator.hpp │ ├── table_proxy.hpp │ ├── thread.hpp │ ├── tie.hpp │ ├── traits.hpp │ ├── trampoline.hpp │ ├── tuple.hpp │ ├── types.hpp │ ├── unicode.hpp │ ├── unique_usertype_traits.hpp │ ├── unreachable.hpp │ ├── unsafe_function.hpp │ ├── unsafe_function_result.hpp │ ├── userdata.hpp │ ├── usertype.hpp │ ├── usertype_container.hpp │ ├── usertype_container_launch.hpp │ ├── usertype_core.hpp │ ├── usertype_proxy.hpp │ ├── usertype_storage.hpp │ ├── usertype_traits.hpp │ ├── utility │ ├── is_integer.hpp │ └── to_string.hpp │ ├── variadic_args.hpp │ ├── variadic_results.hpp │ ├── version.hpp │ └── wrapper.hpp ├── CMakeLists.txt ├── LICENSE ├── README.md ├── build.sh ├── config.ini ├── config └── ssl │ ├── local.newobj.org.key │ └── local.newobj.org.pem ├── include └── dll_interface.h ├── src ├── core │ ├── app.cpp │ ├── app.h │ ├── config.cpp │ ├── config.h │ ├── define.h │ ├── entry.cpp │ ├── entry.h │ ├── global.cpp │ ├── global.h │ ├── global_module.cpp │ ├── global_module.h │ ├── interceptormanager.cpp │ ├── interceptormanager.h │ ├── interface.hpp │ ├── log.cpp │ ├── log.h │ ├── lualibdetecter.cpp │ ├── lualibdetecter.h │ ├── modulemanager.cpp │ ├── modulemanager.h │ ├── statemanager.cpp │ ├── statemanager.h │ ├── structs.h │ ├── subscribemanager.cpp │ └── subscribemanager.h ├── module │ ├── basemodule.h │ ├── codec.cpp │ ├── codec.h │ ├── globalfuns.cpp │ ├── globalfuns.h │ ├── http │ │ ├── httpclient.cpp │ │ ├── httpclient.h │ │ ├── interceptor.cpp │ │ ├── interceptor.h │ │ ├── request.cpp │ │ ├── request.h │ │ ├── response.cpp │ │ ├── response.h │ │ ├── session.cpp │ │ ├── session.h │ │ ├── subscribe.cpp │ │ └── subscribe.h │ ├── ini.cpp │ ├── ini.h │ ├── mutex.cpp │ ├── mutex.h │ ├── process.cpp │ ├── process.h │ ├── timer.cpp │ └── timer.h └── utils │ ├── luautils.cpp │ ├── luautils.h │ └── parseconfig.hpp ├── tests ├── fastweb.cpp ├── fastweb.h ├── main.cpp ├── miniz.h ├── zip.cpp └── zip.h └── www ├── api └── user.lua ├── index.html └── js └── jquery-3.4.1.min.js /.gitignore: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # 此 .gitignore 文件已由 Microsoft(R) Visual Studio 自动创建。 3 | ################################################################################ 4 | 5 | /build 6 | /.vs 7 | /out 8 | /session 9 | /obj 10 | /bin 11 | 12 | /log -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "(gdb) Launch", // 配置名称,可以根据需要修改 9 | "type": "cppdbg", // 调试器类型 10 | "request": "launch", // 请求类型:启动调试 11 | "program": "${workspaceFolder}/build/fastweb", // 指定要调试的可执行程序路径 12 | "args": [ 13 | "start", 14 | "/home/nianhua/www/config.ini" 15 | ], // 程序运行时的命令行参数 16 | "stopAtEntry": false, // 是否在程序入口停止 17 | "cwd": "/home/nianhua/www", // 工作目录 18 | "environment": [], // 运行时的环境变量 19 | "externalConsole": false, // 是否使用外部终端 20 | "MIMode": "gdb", // 使用GDB作为调试器 21 | "miDebuggerPath": "/usr/bin/gdb", // GDB的路径 22 | "preLaunchTask": "build", // 调试前执行的任务 23 | "logging": { 24 | "engineLogging": true // 启用引擎日志记录 25 | }, 26 | "setupCommands": [ 27 | { 28 | "description": "Enable pretty-printing for gdb", 29 | "text": "-enable-pretty-printing", 30 | "ignoreFailures": true 31 | }, 32 | { 33 | "description": "Set Disassembly Flavor to Intel", 34 | "text": "-gdb-set disassembly-flavor intel", 35 | "ignoreFailures": true 36 | } 37 | ] 38 | } 39 | ] 40 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "cctype": "cpp", 4 | "clocale": "cpp", 5 | "cmath": "cpp", 6 | "cstdarg": "cpp", 7 | "cstddef": "cpp", 8 | "cstdio": "cpp", 9 | "cstdlib": "cpp", 10 | "cstring": "cpp", 11 | "ctime": "cpp", 12 | "cwchar": "cpp", 13 | "cwctype": "cpp", 14 | "array": "cpp", 15 | "atomic": "cpp", 16 | "*.tcc": "cpp", 17 | "bitset": "cpp", 18 | "chrono": "cpp", 19 | "codecvt": "cpp", 20 | "condition_variable": "cpp", 21 | "cstdint": "cpp", 22 | "deque": "cpp", 23 | "forward_list": "cpp", 24 | "list": "cpp", 25 | "unordered_map": "cpp", 26 | "vector": "cpp", 27 | "exception": "cpp", 28 | "algorithm": "cpp", 29 | "functional": "cpp", 30 | "iterator": "cpp", 31 | "map": "cpp", 32 | "memory": "cpp", 33 | "memory_resource": "cpp", 34 | "numeric": "cpp", 35 | "optional": "cpp", 36 | "random": "cpp", 37 | "ratio": "cpp", 38 | "regex": "cpp", 39 | "string": "cpp", 40 | "string_view": "cpp", 41 | "system_error": "cpp", 42 | "tuple": "cpp", 43 | "type_traits": "cpp", 44 | "utility": "cpp", 45 | "fstream": "cpp", 46 | "initializer_list": "cpp", 47 | "iosfwd": "cpp", 48 | "iostream": "cpp", 49 | "istream": "cpp", 50 | "limits": "cpp", 51 | "mutex": "cpp", 52 | "new": "cpp", 53 | "ostream": "cpp", 54 | "shared_mutex": "cpp", 55 | "sstream": "cpp", 56 | "stdexcept": "cpp", 57 | "streambuf": "cpp", 58 | "thread": "cpp", 59 | "cinttypes": "cpp", 60 | "typeinfo": "cpp", 61 | "variant": "cpp", 62 | "filesystem": "cpp" 63 | } 64 | } -------------------------------------------------------------------------------- /.vscode/task.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "type": "shell", 7 | "command": "cmake", 8 | "args": [ 9 | "--build", 10 | "${workspaceFolder}/build" 11 | ], 12 | "group": { 13 | "kind": "build", 14 | "isDefault": true 15 | }, 16 | "problemMatcher": [] 17 | }, 18 | { 19 | "label": "configure", 20 | "type": "shell", 21 | "command": "cmake", 22 | "args": [ 23 | "-S", 24 | "${workspaceFolder}", 25 | "-B", 26 | "${workspaceFolder}/build" 27 | ], 28 | "problemMatcher": [] 29 | } 30 | ] 31 | } -------------------------------------------------------------------------------- /3rdparty/HP-Socket/lib/HPSocket.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Liuccysdgg/fastweb/f2134c4358c7f8b76e987074072ef0224a838565/3rdparty/HP-Socket/lib/HPSocket.dll -------------------------------------------------------------------------------- /3rdparty/HP-Socket/lib/HPSocket.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Liuccysdgg/fastweb/f2134c4358c7f8b76e987074072ef0224a838565/3rdparty/HP-Socket/lib/HPSocket.lib -------------------------------------------------------------------------------- /3rdparty/HP-Socket/lib/HPSocket_D.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Liuccysdgg/fastweb/f2134c4358c7f8b76e987074072ef0224a838565/3rdparty/HP-Socket/lib/HPSocket_D.dll -------------------------------------------------------------------------------- /3rdparty/HP-Socket/lib/HPSocket_D.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Liuccysdgg/fastweb/f2134c4358c7f8b76e987074072ef0224a838565/3rdparty/HP-Socket/lib/HPSocket_D.lib -------------------------------------------------------------------------------- /3rdparty/libcrypto_static.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Liuccysdgg/fastweb/f2134c4358c7f8b76e987074072ef0224a838565/3rdparty/libcrypto_static.lib -------------------------------------------------------------------------------- /3rdparty/lua/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | project(lua) 3 | 4 | #set(LUA_VERSION_MAJOR 5) 5 | #set(LUA_VERSION_MINOR 4) 6 | #set(LUA_VERSION_PATCH 4) 7 | 8 | set(PJN_LUAEXE "lua") 9 | set(PJN_LUALIB "lualib") 10 | 11 | set(LUA_SRC 12 | src/lapi.c 13 | src/lcode.c 14 | src/lctype.c 15 | src/ldebug.c 16 | src/ldo.c 17 | src/ldump.c 18 | src/lfunc.c 19 | src/lgc.c 20 | src/llex.c 21 | src/lmem.c 22 | src/lobject.c 23 | src/lopcodes.c 24 | src/lparser.c 25 | src/lstate.c 26 | src/lstring.c 27 | src/ltable.c 28 | src/ltm.c 29 | src/lundump.c 30 | src/lvm.c 31 | src/lzio.c 32 | src/lauxlib.c 33 | src/lbaselib.c 34 | src/lcorolib.c 35 | src/ldblib.c 36 | src/liolib.c 37 | src/lmathlib.c 38 | src/loslib.c 39 | src/lstrlib.c 40 | src/ltablib.c 41 | src/lutf8lib.c 42 | src/loadlib.c 43 | src/linit.c 44 | ) 45 | include_directories(${PJN_LUALIB} include) 46 | include_directories(${PJN_LUAEXE} include) 47 | add_library(${PJN_LUALIB} STATIC ${LUA_SRC}) 48 | 49 | add_executable(${PJN_LUAEXE} src/lua.c) 50 | target_link_libraries(${PJN_LUAEXE} ${PJN_LUALIB}) 51 | 52 | set_target_properties(${PJN_LUAEXE} PROPERTIES OUTPUT_NAME lua) 53 | set_target_properties(${PJN_LUALIB} PROPERTIES OUTPUT_NAME lua) 54 | #set_target_properties(${PJN_LUAEXE} PROPERTIES OUTPUT_NAME_DEBUG "${PJN_LUAEXE}_d" OUTPUT_NAME_RELEASE ${PJN_LUAEXE}) 55 | #set_target_properties(${PJN_LUALIB} PROPERTIES OUTPUT_NAME_DEBUG "${PJN_LUALIB}_d" OUTPUT_NAME_RELEASE ${PJN_LUALIB}) 56 | 57 | set_property(TARGET ${PJN_LUALIB} PROPERTY FOLDER "3rdparty") 58 | set_property(TARGET ${PJN_LUAEXE} PROPERTY FOLDER "3rdparty") 59 | 60 | install(TARGETS ${PJN_LUAEXE} DESTINATION $,bin/debug/3rdparty,bin/release/3rdparty>) 61 | install(DIRECTORY include DESTINATION bin/debug/3rdparty) 62 | install(DIRECTORY include DESTINATION bin/release/3rdparty) 63 | 64 | 65 | install(TARGETS ${PJN_LUALIB} DESTINATION $,bin/debug/3rdparty/lib,bin/release/3rdparty/lib>) 66 | 67 | 68 | -------------------------------------------------------------------------------- /3rdparty/lua/include/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.p', checking for stack overflows */ 16 | #define api_incr_top(L) {L->top.p++; \ 17 | api_check(L, L->top.p <= L->ci->top.p, \ 18 | "stack overflow");} 19 | 20 | 21 | /* 22 | ** If a call returns too many multiple returns, the callee may not have 23 | ** stack space to accommodate all results. In this case, this macro 24 | ** increases its stack space ('L->ci->top.p'). 25 | */ 26 | #define adjustresults(L,nres) \ 27 | { if ((nres) <= LUA_MULTRET && L->ci->top.p < L->top.p) \ 28 | L->ci->top.p = L->top.p; } 29 | 30 | 31 | /* Ensure the stack has at least 'n' elements */ 32 | #define api_checknelems(L,n) \ 33 | api_check(L, (n) < (L->top.p - L->ci->func.p), \ 34 | "not enough elements in the stack") 35 | 36 | 37 | /* 38 | ** To reduce the overhead of returning from C functions, the presence of 39 | ** to-be-closed variables in these functions is coded in the CallInfo's 40 | ** field 'nresults', in a way that functions with no to-be-closed variables 41 | ** with zero, one, or "all" wanted results have no overhead. Functions 42 | ** with other number of wanted results, as well as functions with 43 | ** variables to be closed, have an extra check. 44 | */ 45 | 46 | #define hastocloseCfunc(n) ((n) < LUA_MULTRET) 47 | 48 | /* Map [-1, inf) (range of 'nresults') into (-inf, -2] */ 49 | #define codeNresults(n) (-(n) - 3) 50 | #define decodeNresults(n) (-(n) - 3) 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /3rdparty/lua/include/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 | -------------------------------------------------------------------------------- /3rdparty/lua/include/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.p))) 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 | -------------------------------------------------------------------------------- /3rdparty/lua/include/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 "llimits.h" 12 | #include "lobject.h" 13 | #include "lstate.h" 14 | #include "lzio.h" 15 | 16 | 17 | /* 18 | ** Macro to check stack size and grow stack if needed. Parameters 19 | ** 'pre'/'pos' allow the macro to preserve a pointer into the 20 | ** stack across reallocations, doing the work only when needed. 21 | ** It also allows the running of one GC step when the stack is 22 | ** reallocated. 23 | ** 'condmovestack' is used in heavy tests to force a stack reallocation 24 | ** at every check. 25 | */ 26 | #define luaD_checkstackaux(L,n,pre,pos) \ 27 | if (l_unlikely(L->stack_last.p - L->top.p <= (n))) \ 28 | { pre; luaD_growstack(L, n, 1); pos; } \ 29 | else { condmovestack(L,pre,pos); } 30 | 31 | /* In general, 'pre'/'pos' are empty (nothing to save) */ 32 | #define luaD_checkstack(L,n) luaD_checkstackaux(L,n,(void)0,(void)0) 33 | 34 | 35 | 36 | #define savestack(L,pt) (cast_charp(pt) - cast_charp(L->stack.p)) 37 | #define restorestack(L,n) cast(StkId, cast_charp(L->stack.p) + (n)) 38 | 39 | 40 | /* macro to check stack size, preserving 'p' */ 41 | #define checkstackp(L,n,p) \ 42 | luaD_checkstackaux(L, n, \ 43 | ptrdiff_t t__ = savestack(L, p), /* save 'p' */ \ 44 | p = restorestack(L, t__)) /* 'pos' part: restore 'p' */ 45 | 46 | 47 | /* macro to check stack size and GC, preserving 'p' */ 48 | #define checkstackGCp(L,n,p) \ 49 | luaD_checkstackaux(L, n, \ 50 | ptrdiff_t t__ = savestack(L, p); /* save 'p' */ \ 51 | luaC_checkGC(L), /* stack grow uses memory */ \ 52 | p = restorestack(L, t__)) /* 'pos' part: restore 'p' */ 53 | 54 | 55 | /* macro to check stack size and GC */ 56 | #define checkstackGC(L,fsize) \ 57 | luaD_checkstackaux(L, (fsize), luaC_checkGC(L), (void)0) 58 | 59 | 60 | /* type of protected functions, to be ran by 'runprotected' */ 61 | typedef void (*Pfunc) (lua_State *L, void *ud); 62 | 63 | LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop); 64 | LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, 65 | const char *mode); 66 | LUAI_FUNC void luaD_hook (lua_State *L, int event, int line, 67 | int fTransfer, int nTransfer); 68 | LUAI_FUNC void luaD_hookcall (lua_State *L, CallInfo *ci); 69 | LUAI_FUNC int luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, 70 | int narg1, int delta); 71 | LUAI_FUNC CallInfo *luaD_precall (lua_State *L, StkId func, int nResults); 72 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); 73 | LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults); 74 | LUAI_FUNC StkId luaD_tryfuncTM (lua_State *L, StkId func); 75 | LUAI_FUNC int luaD_closeprotected (lua_State *L, ptrdiff_t level, int status); 76 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, 77 | ptrdiff_t oldtop, ptrdiff_t ef); 78 | LUAI_FUNC void luaD_poscall (lua_State *L, CallInfo *ci, int nres); 79 | LUAI_FUNC int luaD_reallocstack (lua_State *L, int newsize, int raiseerror); 80 | LUAI_FUNC int luaD_growstack (lua_State *L, int n, int raiseerror); 81 | LUAI_FUNC void luaD_shrinkstack (lua_State *L); 82 | LUAI_FUNC void luaD_inctop (lua_State *L); 83 | 84 | LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode); 85 | LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); 86 | 87 | #endif 88 | 89 | -------------------------------------------------------------------------------- /3rdparty/lua/include/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.p != &(up)->u.value) 33 | 34 | 35 | #define uplevel(up) check_exp(upisopen(up), cast(StkId, (up)->v.p)) 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 StkId 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 | -------------------------------------------------------------------------------- /3rdparty/lua/include/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 | -------------------------------------------------------------------------------- /3rdparty/lua/include/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 | -------------------------------------------------------------------------------- /3rdparty/lua/include/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 | -------------------------------------------------------------------------------- /3rdparty/lua/include/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 | -------------------------------------------------------------------------------- /3rdparty/lua/include/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 | -------------------------------------------------------------------------------- /3rdparty/lua/include/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 | #endif 63 | 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /3rdparty/lua/include/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 | #include "lstate.h" 13 | 14 | 15 | /* 16 | * WARNING: if you change the order of this enumeration, 17 | * grep "ORDER TM" and "ORDER OP" 18 | */ 19 | typedef enum { 20 | TM_INDEX, 21 | TM_NEWINDEX, 22 | TM_GC, 23 | TM_MODE, 24 | TM_LEN, 25 | TM_EQ, /* last tag method with fast access */ 26 | TM_ADD, 27 | TM_SUB, 28 | TM_MUL, 29 | TM_MOD, 30 | TM_POW, 31 | TM_DIV, 32 | TM_IDIV, 33 | TM_BAND, 34 | TM_BOR, 35 | TM_BXOR, 36 | TM_SHL, 37 | TM_SHR, 38 | TM_UNM, 39 | TM_BNOT, 40 | TM_LT, 41 | TM_LE, 42 | TM_CONCAT, 43 | TM_CALL, 44 | TM_CLOSE, 45 | TM_N /* number of elements in the enum */ 46 | } TMS; 47 | 48 | 49 | /* 50 | ** Mask with 1 in all fast-access methods. A 1 in any of these bits 51 | ** in the flag of a (meta)table means the metatable does not have the 52 | ** corresponding metamethod field. (Bit 7 of the flag is used for 53 | ** 'isrealasize'.) 54 | */ 55 | #define maskflags (~(~0u << (TM_EQ + 1))) 56 | 57 | 58 | /* 59 | ** Test whether there is no tagmethod. 60 | ** (Because tagmethods use raw accesses, the result may be an "empty" nil.) 61 | */ 62 | #define notm(tm) ttisnil(tm) 63 | 64 | 65 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \ 66 | ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) 67 | 68 | #define fasttm(l,et,e) gfasttm(G(l), et, e) 69 | 70 | #define ttypename(x) luaT_typenames_[(x) + 1] 71 | 72 | LUAI_DDEC(const char *const luaT_typenames_[LUA_TOTALTYPES];) 73 | 74 | 75 | LUAI_FUNC const char *luaT_objtypename (lua_State *L, const TValue *o); 76 | 77 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); 78 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, 79 | TMS event); 80 | LUAI_FUNC void luaT_init (lua_State *L); 81 | 82 | LUAI_FUNC void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1, 83 | const TValue *p2, const TValue *p3); 84 | LUAI_FUNC void luaT_callTMres (lua_State *L, const TValue *f, 85 | const TValue *p1, const TValue *p2, StkId p3); 86 | LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2, 87 | StkId res, TMS event); 88 | LUAI_FUNC void luaT_tryconcatTM (lua_State *L); 89 | LUAI_FUNC void luaT_trybinassocTM (lua_State *L, const TValue *p1, 90 | const TValue *p2, int inv, StkId res, TMS event); 91 | LUAI_FUNC void luaT_trybiniTM (lua_State *L, const TValue *p1, lua_Integer i2, 92 | int inv, StkId res, TMS event); 93 | LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1, 94 | const TValue *p2, TMS event); 95 | LUAI_FUNC int luaT_callorderiTM (lua_State *L, const TValue *p1, int v2, 96 | int inv, int isfloat, TMS event); 97 | 98 | LUAI_FUNC void luaT_adjustvarargs (lua_State *L, int nfixparams, 99 | CallInfo *ci, const Proto *p); 100 | LUAI_FUNC void luaT_getvarargs (lua_State *L, CallInfo *ci, 101 | StkId where, int wanted); 102 | 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /3rdparty/lua/include/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 | -------------------------------------------------------------------------------- /3rdparty/lua/include/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 | -------------------------------------------------------------------------------- /3rdparty/lua/include/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 | -------------------------------------------------------------------------------- /3rdparty/lua/include/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 | -------------------------------------------------------------------------------- /3rdparty/lua/src/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 | -------------------------------------------------------------------------------- /3rdparty/lua/src/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 | -------------------------------------------------------------------------------- /3rdparty/lua/src/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 | -------------------------------------------------------------------------------- /3rdparty/sol/abort.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_ABORT_HPP 25 | #define SOL_ABORT_HPP 26 | 27 | #include 28 | 29 | #include 30 | 31 | #include 32 | 33 | // clang-format off 34 | #if SOL_IS_ON(SOL_DEBUG_BUILD) 35 | #if SOL_IS_ON(SOL_COMPILER_VCXX) 36 | #define SOL_DEBUG_ABORT() \ 37 | if (true) { ::std::abort(); } \ 38 | static_assert(true, "") 39 | #else 40 | #define SOL_DEBUG_ABORT() ::std::abort() 41 | #endif 42 | #else 43 | #define SOL_DEBUG_ABORT() static_assert(true, "") 44 | #endif 45 | // clang-format on 46 | 47 | #endif // SOL_ABORT_HPP 48 | -------------------------------------------------------------------------------- /3rdparty/sol/as_args.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this Spermission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_AS_ARGS_HPP 25 | #define SOL_AS_ARGS_HPP 26 | 27 | #include 28 | 29 | namespace sol { 30 | template 31 | struct as_args_t { 32 | T src; 33 | }; 34 | 35 | template 36 | auto as_args(Source&& source) { 37 | return as_args_t { std::forward(source) }; 38 | } 39 | 40 | namespace stack { 41 | template 42 | struct unqualified_pusher> { 43 | int push(lua_State* L, const as_args_t& e) { 44 | int p = 0; 45 | for (const auto& i : e.src) { 46 | p += stack::push(L, i); 47 | } 48 | return p; 49 | } 50 | }; 51 | } // namespace stack 52 | } // namespace sol 53 | 54 | #endif // SOL_AS_ARGS_HPP 55 | -------------------------------------------------------------------------------- /3rdparty/sol/as_returns.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_AS_RETURNS_HPP 25 | #define SOL_AS_RETURNS_HPP 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | namespace sol { 32 | template 33 | struct as_returns_t : private detail::ebco { 34 | private: 35 | using base_t = detail::ebco; 36 | 37 | public: 38 | using base_t::base_t; 39 | using base_t::value; 40 | }; 41 | 42 | template 43 | auto as_returns(Source&& source) { 44 | return as_returns_t> { std::forward(source) }; 45 | } 46 | 47 | namespace stack { 48 | template 49 | struct unqualified_pusher> { 50 | int push(lua_State* L, const as_returns_t& e) { 51 | auto& src = detail::unwrap(e.value()); 52 | int p = 0; 53 | for (const auto& i : src) { 54 | p += stack::push(L, i); 55 | } 56 | return p; 57 | } 58 | }; 59 | } // namespace stack 60 | } // namespace sol 61 | 62 | #endif // SOL_AS_RETURNS_HPP 63 | -------------------------------------------------------------------------------- /3rdparty/sol/compatibility.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_COMPATIBILITY_HPP 25 | #define SOL_COMPATIBILITY_HPP 26 | 27 | // The various pieces of the compatibility layer 28 | // comes from https://github.com/keplerproject/lua-compat-5.3 29 | // but has been modified in many places for use with sol and luajit, 30 | // though the core abstractions remain the same 31 | 32 | #include 33 | #include 34 | 35 | #if SOL_IS_ON(SOL_USE_COMPATIBILITY_LAYER) 36 | 37 | // clang-format off 38 | #if SOL_IS_ON(SOL_USING_CXX_LUA) || SOL_IS_ON(SOL_USING_CXX_LUAJIT) 39 | #ifndef COMPAT53_LUA_CPP 40 | #define COMPAT53_LUA_CPP 1 41 | #endif // Build Lua Compat layer as C++ 42 | #endif 43 | #ifndef COMPAT53_INCLUDE_SOURCE 44 | #define COMPAT53_INCLUDE_SOURCE 1 45 | #endif // Build Compat Layer Inline 46 | #include 47 | #include 48 | #endif 49 | // clang-format on 50 | 51 | #endif // SOL_COMPATIBILITY_HPP 52 | -------------------------------------------------------------------------------- /3rdparty/sol/compatibility/compat-5.4.h: -------------------------------------------------------------------------------- 1 | #ifndef NOT_KEPLER_PROJECT_COMPAT54_H_ 2 | #define NOT_KEPLER_PROJECT_COMPAT54_H_ 3 | 4 | #if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP) 5 | extern "C" { 6 | #endif 7 | #include 8 | #include 9 | #include 10 | #if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP) 11 | } 12 | #endif 13 | 14 | #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 504 15 | 16 | #if !defined(LUA_ERRGCMM) 17 | /* So Lua 5.4 actually removes this, which breaks sol2... 18 | man, this API is quite unstable...! 19 | */ 20 | # define LUA_ERRGCMM (LUA_ERRERR + 2) 21 | #endif /* LUA_ERRGCMM define */ 22 | 23 | #endif // Lua 5.4 only 24 | 25 | #endif // NOT_KEPLER_PROJECT_COMPAT54_H_ -------------------------------------------------------------------------------- /3rdparty/sol/config.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_CONFIG_HPP 25 | #define SOL_CONFIG_HPP 26 | 27 | /* Base, empty configuration file! 28 | 29 | To override, place a file in your include paths of the form: 30 | 31 | 32 | . (your include path here) 33 | | sol (directory, or equivalent) 34 | | config.hpp (your config.hpp file) 35 | 36 | 37 | So that when sol2 includes the file 38 | 39 | 40 | #include 41 | 42 | 43 | it gives you the configuration values you desire. Configuration values can be 44 | seen in the safety.rst of the doc/src, or at 45 | https://sol2.readthedocs.io/en/latest/safety.html ! You can also pass them through 46 | the build system, or the command line options of your compiler. 47 | 48 | */ 49 | 50 | #endif // SOL_CONFIG_HPP 51 | -------------------------------------------------------------------------------- /3rdparty/sol/debug.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_DEBUG_HPP 25 | #define SOL_DEBUG_HPP 26 | 27 | #include 28 | #include 29 | 30 | namespace sol { namespace detail { namespace debug { 31 | inline std::string dump_types(lua_State* L) { 32 | std::string visual; 33 | std::size_t size = lua_gettop(L) + 1; 34 | for (std::size_t i = 1; i < size; ++i) { 35 | if (i != 1) { 36 | visual += " | "; 37 | } 38 | visual += type_name(L, stack::get(L, static_cast(i))); 39 | } 40 | return visual; 41 | } 42 | 43 | inline void print_stack(lua_State* L) { 44 | std::cout << dump_types(L) << std::endl; 45 | } 46 | 47 | inline void print_section(const std::string& message, lua_State* L) { 48 | std::cout << "-- " << message << " -- [ " << dump_types(L) << " ]" << std::endl; 49 | } 50 | }}} // namespace sol::detail::debug 51 | 52 | #endif // SOL_DEBUG_HPP 53 | -------------------------------------------------------------------------------- /3rdparty/sol/deprecate.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_DEPRECATE_HPP 25 | #define SOL_DEPRECATE_HPP 26 | 27 | #ifndef SOL_DEPRECATED 28 | #ifdef _MSC_VER 29 | #define SOL_DEPRECATED __declspec(deprecated) 30 | #elif __GNUC__ 31 | #define SOL_DEPRECATED __attribute__((deprecated)) 32 | #else 33 | #define SOL_DEPRECATED [[deprecated]] 34 | #endif // compilers 35 | #endif // SOL_DEPRECATED 36 | 37 | namespace sol { namespace detail { 38 | template 39 | struct SOL_DEPRECATED deprecate_type { 40 | using type = T; 41 | }; 42 | }} // namespace sol::detail 43 | 44 | #endif // SOL_DEPRECATE_HPP 45 | -------------------------------------------------------------------------------- /3rdparty/sol/dump_handler.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_DUMP_HANDLER_HPP 25 | #define SOL_DUMP_HANDLER_HPP 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | namespace sol { 33 | 34 | class dump_error : public error { 35 | private: 36 | int m_ec; 37 | 38 | public: 39 | dump_error(int error_code_) : error("dump returned non-zero error of " + std::to_string(error_code_)), m_ec(error_code_) { 40 | } 41 | 42 | int error_code() const { 43 | return m_ec; 44 | } 45 | }; 46 | 47 | inline int dump_pass_on_error(lua_State* L_, int result_code, lua_Writer writer_function, void* userdata_pointer_, bool strip) { 48 | (void)L_; 49 | (void)writer_function; 50 | (void)userdata_pointer_; 51 | (void)strip; 52 | return result_code; 53 | } 54 | 55 | inline int dump_panic_on_error(lua_State* L_, int result_code, lua_Writer writer_function, void* userdata_pointer_, bool strip) { 56 | (void)L_; 57 | (void)writer_function; 58 | (void)userdata_pointer_; 59 | (void)strip; 60 | return luaL_error(L_, "a non-zero error code (%d) was returned by the lua_Writer for the dump function", result_code); 61 | } 62 | 63 | inline int dump_throw_on_error(lua_State* L_, int result_code, lua_Writer writer_function, void* userdata_pointer_, bool strip) { 64 | #if SOL_IS_OFF(SOL_EXCEPTIONS) 65 | return dump_panic_on_error(L_, result_code, writer_function, userdata_pointer_, strip); 66 | #else 67 | (void)L_; 68 | (void)writer_function; 69 | (void)userdata_pointer_; 70 | (void)strip; 71 | throw dump_error(result_code); 72 | #endif // no exceptions stuff 73 | } 74 | 75 | } // namespace sol 76 | 77 | #endif // SOL_DUMP_HANDLER_HPP 78 | -------------------------------------------------------------------------------- /3rdparty/sol/epilogue.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #pragma once 25 | 26 | // clang-format off 27 | 28 | #if !defined(SOL_PROLOGUE_I_) 29 | #error "[sol2] Library Prologue is missing from this translation unit." 30 | #else 31 | #undef SOL_PROLOGUE_I_ 32 | #endif 33 | 34 | #if SOL_IS_ON(SOL_BUILD_CXX_MODE) 35 | #undef _FWD 36 | #undef _MOVE 37 | #endif 38 | 39 | // clang-format on 40 | -------------------------------------------------------------------------------- /3rdparty/sol/error.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_ERROR_HPP 25 | #define SOL_ERROR_HPP 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | namespace sol { 34 | namespace detail { 35 | struct direct_error_tag { }; 36 | const auto direct_error = direct_error_tag {}; 37 | 38 | struct error_result { 39 | int results; 40 | const char* format_string; 41 | std::array argument_strings; 42 | 43 | error_result() : results(0), format_string(nullptr) { 44 | } 45 | 46 | error_result(int results_) : results(results_), format_string(nullptr) { 47 | } 48 | 49 | error_result(const char* format_string_, const char* first_message_) : results(0), format_string(format_string_), argument_strings() { 50 | argument_strings[0] = first_message_; 51 | } 52 | }; 53 | 54 | inline int handle_errors(lua_State* L, const error_result& er) { 55 | if (er.format_string == nullptr) { 56 | return er.results; 57 | } 58 | return luaL_error(L, er.format_string, er.argument_strings[0], er.argument_strings[1], er.argument_strings[2], er.argument_strings[3]); 59 | } 60 | } // namespace detail 61 | 62 | class error : public std::runtime_error { 63 | private: 64 | // Because VC++ is upsetting, most of the time! 65 | std::string what_reason; 66 | 67 | public: 68 | error(const std::string& str) : error(detail::direct_error, "lua: error: " + str) { 69 | } 70 | error(std::string&& str) : error(detail::direct_error, "lua: error: " + std::move(str)) { 71 | } 72 | error(detail::direct_error_tag, const std::string& str) : std::runtime_error(""), what_reason(str) { 73 | } 74 | error(detail::direct_error_tag, std::string&& str) : std::runtime_error(""), what_reason(std::move(str)) { 75 | } 76 | 77 | error(const error& e) = default; 78 | error(error&& e) = default; 79 | error& operator=(const error& e) = default; 80 | error& operator=(error&& e) = default; 81 | 82 | virtual const char* what() const noexcept override { 83 | return what_reason.c_str(); 84 | } 85 | }; 86 | 87 | } // namespace sol 88 | 89 | #endif // SOL_ERROR_HPP 90 | -------------------------------------------------------------------------------- /3rdparty/sol/forward_as.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_FORWARD_AS_HPP 25 | #define SOL_FORWARD_AS_HPP 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | namespace sol { 33 | template 34 | constexpr decltype(auto) forward_as(U&& value) noexcept { 35 | if constexpr (::std::is_lvalue_reference_v) { 36 | return value; 37 | } 38 | else { 39 | return ::std::move(value); 40 | } 41 | } 42 | } 43 | 44 | #endif // SOL_FORWARD_AS_HPP 45 | -------------------------------------------------------------------------------- /3rdparty/sol/forward_detail.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_FORWARD_DETAIL_HPP 25 | #define SOL_FORWARD_DETAIL_HPP 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | namespace sol { 33 | namespace detail { 34 | const bool default_safe_function_calls = 35 | #if SOL_IS_ON(SOL_SAFE_FUNCTION_CALLS) 36 | true; 37 | #else 38 | false; 39 | #endif 40 | } // namespace detail 41 | 42 | 43 | namespace meta { namespace meta_detail { 44 | }} // namespace meta::meta_detail 45 | 46 | namespace stack { namespace stack_detail { 47 | using undefined_method_func = void (*)(stack_reference); 48 | 49 | template 50 | void set_undefined_methods_on(stack_reference); 51 | 52 | struct undefined_metatable; 53 | }} // namespace stack::stack_detail 54 | } // namespace sol 55 | 56 | #endif // SOL_FORWARD_DETAIL_HPP 57 | -------------------------------------------------------------------------------- /3rdparty/sol/function_result.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_FUNCTION_RESULT_HPP 25 | #define SOL_FUNCTION_RESULT_HPP 26 | 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | namespace sol { 33 | 34 | namespace detail { 35 | template <> 36 | struct is_speshul : std::true_type { }; 37 | template <> 38 | struct is_speshul : std::true_type { }; 39 | 40 | template 41 | stack_proxy get(types, meta::index_value<0>, meta::index_value, const T& fr) { 42 | return stack_proxy(fr.lua_state(), fr.stack_index() + static_cast(I)); 43 | } 44 | 45 | template 0)>> = meta::enabler> 46 | stack_proxy get(types, meta::index_value, meta::index_value, const T& fr) { 47 | return get(types(), meta::index_value(), meta::index_value::value>(), fr); 48 | } 49 | } // namespace detail 50 | 51 | template <> 52 | struct tie_size : std::integral_constant { }; 53 | 54 | template <> 55 | struct tie_size : std::integral_constant { }; 56 | 57 | template 58 | stack_proxy get(const unsafe_function_result& fr) { 59 | return stack_proxy(fr.lua_state(), fr.stack_index() + static_cast(I)); 60 | } 61 | 62 | template 63 | stack_proxy get(types t, const unsafe_function_result& fr) { 64 | return detail::get(t, meta::index_value(), meta::index_value<0>(), fr); 65 | } 66 | 67 | template 68 | stack_proxy get(const protected_function_result& fr) { 69 | return stack_proxy(fr.lua_state(), fr.stack_index() + static_cast(I)); 70 | } 71 | 72 | template 73 | stack_proxy get(types t, const protected_function_result& fr) { 74 | return detail::get(t, meta::index_value(), meta::index_value<0>(), fr); 75 | } 76 | } // namespace sol 77 | 78 | #endif // SOL_FUNCTION_RESULT_HPP 79 | -------------------------------------------------------------------------------- /3rdparty/sol/function_types_core.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_FUNCTION_TYPES_CORE_HPP 25 | #define SOL_FUNCTION_TYPES_CORE_HPP 26 | 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | namespace sol { namespace function_detail { 33 | template 34 | int call(lua_State* L) { 35 | Fx& fx = stack::get>(L, upvalue_index(start)); 36 | int nr = fx(L); 37 | if (is_yielding) { 38 | return lua_yield(L, nr); 39 | } 40 | else { 41 | return nr; 42 | } 43 | } 44 | }} // namespace sol::function_detail 45 | 46 | #endif // SOL_FUNCTION_TYPES_CORE_HPP 47 | -------------------------------------------------------------------------------- /3rdparty/sol/function_types_overloaded.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_FUNCTION_TYPES_OVERLOAD_HPP 25 | #define SOL_FUNCTION_TYPES_OVERLOAD_HPP 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | namespace sol { namespace function_detail { 32 | template 33 | struct overloaded_function { 34 | typedef std::tuple overload_list; 35 | typedef std::make_index_sequence indices; 36 | overload_list overloads; 37 | 38 | overloaded_function(overload_list set) : overloads(std::move(set)) { 39 | } 40 | 41 | overloaded_function(Functions... fxs) : overloads(fxs...) { 42 | } 43 | 44 | template 45 | static int call(types, meta::index_value, types, types, lua_State* L, int, int, overload_list& ol) { 46 | auto& func = std::get(ol); 47 | int nr = call_detail::call_wrapped(L, func); 48 | return nr; 49 | } 50 | 51 | struct on_success { 52 | template 53 | int operator()(Args&&... args) const { 54 | return call(std::forward(args)...); 55 | } 56 | }; 57 | 58 | int operator()(lua_State* L) { 59 | on_success call_obj {}; 60 | return call_detail::overload_match(call_obj, L, 1 + start_skew, overloads); 61 | } 62 | }; 63 | }} // namespace sol::function_detail 64 | 65 | #endif // SOL_FUNCTION_TYPES_OVERLOAD_HPP 66 | -------------------------------------------------------------------------------- /3rdparty/sol/in_place.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_IN_PLACE_HPP 25 | #define SOL_IN_PLACE_HPP 26 | 27 | #include 28 | #include 29 | 30 | namespace sol { 31 | 32 | using in_place_t = std::in_place_t; 33 | constexpr std::in_place_t in_place {}; 34 | constexpr std::in_place_t in_place_of {}; 35 | 36 | template 37 | using in_place_type_t = std::in_place_type_t; 38 | template 39 | constexpr std::in_place_type_t in_place_type {}; 40 | 41 | template 42 | using in_place_index_t = std::in_place_index_t; 43 | template 44 | constexpr in_place_index_t in_place_index {}; 45 | 46 | } // namespace sol 47 | 48 | #endif // SOL_IN_PLACE_HPP 49 | -------------------------------------------------------------------------------- /3rdparty/sol/make_reference.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_MAKE_REFERENCE_HPP 25 | #define SOL_MAKE_REFERENCE_HPP 26 | 27 | #include 28 | #include 29 | 30 | namespace sol { 31 | 32 | template , typename T> 33 | R make_reference(lua_State* L, T&& value) { 34 | int backpedal = stack::push(L, std::forward(value)); 35 | R r = stack::get(L, -backpedal); 36 | if (should_pop) { 37 | lua_pop(L, backpedal); 38 | } 39 | return r; 40 | } 41 | 42 | template , typename... Args> 43 | R make_reference(lua_State* L, Args&&... args) { 44 | int backpedal = stack::push(L, std::forward(args)...); 45 | R r = stack::get(L, -backpedal); 46 | if (should_pop) { 47 | lua_pop(L, backpedal); 48 | } 49 | return r; 50 | } 51 | 52 | template , typename T> 53 | R make_reference_userdata(lua_State* L, T&& value) { 54 | int backpedal = stack::push_userdata(L, std::forward(value)); 55 | R r = stack::get(L, -backpedal); 56 | if (should_pop) { 57 | lua_pop(L, backpedal); 58 | } 59 | return r; 60 | } 61 | 62 | template , typename... Args> 63 | R make_reference_userdata(lua_State* L, Args&&... args) { 64 | int backpedal = stack::push_userdata(L, std::forward(args)...); 65 | R r = stack::get(L, -backpedal); 66 | if (should_pop) { 67 | lua_pop(L, backpedal); 68 | } 69 | return r; 70 | } 71 | 72 | } // namespace sol 73 | 74 | #endif // SOL_MAKE_REFERENCE_HPP 75 | -------------------------------------------------------------------------------- /3rdparty/sol/object_base.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_OBJECT_BASE_HPP 25 | #define SOL_OBJECT_BASE_HPP 26 | 27 | #include 28 | #include 29 | 30 | namespace sol { 31 | 32 | template 33 | class basic_object_base : public ref_t { 34 | private: 35 | using base_t = ref_t; 36 | 37 | template 38 | decltype(auto) as_stack(std::true_type) const { 39 | return stack::get(base_t::lua_state(), base_t::stack_index()); 40 | } 41 | 42 | template 43 | decltype(auto) as_stack(std::false_type) const { 44 | base_t::push(); 45 | return stack::pop(base_t::lua_state()); 46 | } 47 | 48 | template 49 | bool is_stack(std::true_type) const { 50 | return stack::check(base_t::lua_state(), base_t::stack_index(), &no_panic); 51 | } 52 | 53 | template 54 | bool is_stack(std::false_type) const { 55 | int r = base_t::registry_index(); 56 | if (r == LUA_REFNIL) 57 | return meta::any_same, lua_nil_t, nullopt_t, std::nullptr_t>::value ? true : false; 58 | if (r == LUA_NOREF) 59 | return false; 60 | auto pp = stack::push_pop(*this); 61 | return stack::check(base_t::lua_state(), -1, &no_panic); 62 | } 63 | 64 | public: 65 | basic_object_base() noexcept = default; 66 | basic_object_base(const basic_object_base&) = default; 67 | basic_object_base(basic_object_base&&) = default; 68 | basic_object_base& operator=(const basic_object_base&) = default; 69 | basic_object_base& operator=(basic_object_base&&) = default; 70 | template , basic_object_base>>> = meta::enabler> 71 | basic_object_base(T&& arg, Args&&... args) : base_t(std::forward(arg), std::forward(args)...) { 72 | } 73 | 74 | template 75 | decltype(auto) as() const { 76 | return as_stack(is_stack_based()); 77 | } 78 | 79 | template 80 | bool is() const { 81 | return is_stack(is_stack_based()); 82 | } 83 | }; 84 | } // namespace sol 85 | 86 | #endif // SOL_OBJECT_BASE_HPP 87 | -------------------------------------------------------------------------------- /3rdparty/sol/optional.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_OPTIONAL_HPP 25 | #define SOL_OPTIONAL_HPP 26 | 27 | #include 28 | #include 29 | #include 30 | #if SOL_IS_ON(SOL_USE_BOOST) 31 | #include 32 | #else 33 | #include 34 | #endif // Boost vs. Better optional 35 | 36 | 37 | #include 38 | 39 | namespace sol { 40 | 41 | #if SOL_IS_ON(SOL_USE_BOOST) 42 | template 43 | using optional = boost::optional; 44 | using nullopt_t = boost::none_t; 45 | SOL_BOOST_NONE_CONSTEXPR_I_ nullopt_t nullopt = boost::none; 46 | #endif // Boost vs. Better optional 47 | 48 | namespace meta { 49 | template 50 | using is_optional = any, is_specialization_of>; 51 | 52 | template 53 | constexpr inline bool is_optional_v = is_optional::value; 54 | } // namespace meta 55 | 56 | namespace detail { 57 | template 58 | struct associated_nullopt { 59 | inline static constexpr std::nullopt_t value = std::nullopt; 60 | }; 61 | 62 | #if SOL_IS_ON(SOL_USE_BOOST) 63 | template 64 | struct associated_nullopt> { 65 | inline static SOL_BOOST_NONE_CONSTEXPR_I_ boost::none_t value = boost::none; 66 | }; 67 | #endif // Boost nullopt 68 | 69 | #if SOL_IS_ON(SOL_USE_BOOST) 70 | template 71 | inline SOL_BOOST_NONE_CONSTEXPR_I_ auto associated_nullopt_v = associated_nullopt::value; 72 | #else 73 | template 74 | inline constexpr auto associated_nullopt_v = associated_nullopt::value; 75 | #endif // Boost continues to lag behind, to not many people's surprise... 76 | } // namespace detail 77 | } // namespace sol 78 | 79 | #if SOL_IS_ON(SOL_USE_BOOST) 80 | #undef SOL_BOOST_NONE_CONSTEXPR_I_ 81 | #endif 82 | 83 | #endif // SOL_OPTIONAL_HPP 84 | -------------------------------------------------------------------------------- /3rdparty/sol/overload.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_OVERLOAD_HPP 25 | #define SOL_OVERLOAD_HPP 26 | 27 | #include 28 | #include 29 | 30 | namespace sol { 31 | template 32 | struct overload_set { 33 | std::tuple functions; 34 | template >> = meta::enabler> 35 | overload_set(Arg&& arg, Args&&... args) : functions(std::forward(arg), std::forward(args)...) { 36 | } 37 | overload_set(const overload_set&) = default; 38 | overload_set(overload_set&&) = default; 39 | overload_set& operator=(const overload_set&) = default; 40 | overload_set& operator=(overload_set&&) = default; 41 | }; 42 | 43 | template 44 | decltype(auto) overload(Args&&... args) { 45 | return overload_set...>(std::forward(args)...); 46 | } 47 | } // namespace sol 48 | 49 | #endif // SOL_OVERLOAD_HPP 50 | -------------------------------------------------------------------------------- /3rdparty/sol/pointer_like.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_POINTER_LIKE_HPP 25 | #define SOL_POINTER_LIKE_HPP 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | namespace sol { 34 | 35 | namespace meta { 36 | namespace meta_detail { 37 | template 38 | using is_dereferenceable_test = decltype(*std::declval()); 39 | 40 | template 41 | using is_explicitly_dereferenceable_test = decltype(std::declval().operator*()); 42 | } // namespace meta_detail 43 | 44 | template 45 | using is_pointer_like = std::integral_constant && (std::is_pointer_v || is_detected_v)>; 47 | 48 | template 49 | constexpr inline bool is_pointer_like_v = is_pointer_like::value; 50 | } // namespace meta 51 | 52 | namespace detail { 53 | 54 | template 55 | auto unwrap(T&& item) -> decltype(std::forward(item)) { 56 | return std::forward(item); 57 | } 58 | 59 | template 60 | T& unwrap(std::reference_wrapper arg) { 61 | return arg.get(); 62 | } 63 | 64 | template 65 | inline decltype(auto) deref(T&& item) { 66 | using Tu = meta::unqualified_t; 67 | if constexpr (meta::is_pointer_like_v) { 68 | return *std::forward(item); 69 | } 70 | else { 71 | return std::forward(item); 72 | } 73 | } 74 | 75 | template 76 | inline decltype(auto) deref_move_only(T&& item) { 77 | using Tu = meta::unqualified_t; 78 | if constexpr (meta::is_pointer_like_v && !std::is_pointer_v && !std::is_copy_constructible_v) { 79 | return *std::forward(item); 80 | } 81 | else { 82 | return std::forward(item); 83 | } 84 | } 85 | 86 | template 87 | inline T* ptr(T& val) { 88 | return std::addressof(val); 89 | } 90 | 91 | template 92 | inline T* ptr(std::reference_wrapper val) { 93 | return std::addressof(val.get()); 94 | } 95 | 96 | template 97 | inline T* ptr(T* val) { 98 | return val; 99 | } 100 | } // namespace detail 101 | } // namespace sol 102 | 103 | #endif // SOL_POINTER_LIKE_HPP 104 | -------------------------------------------------------------------------------- /3rdparty/sol/prologue.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #pragma once 25 | 26 | // clang-format off 27 | 28 | #if defined(SOL_PROLOGUE_I_) 29 | #error "[sol2] Library Prologue was already included in translation unit and not properly ended with an epilogue." 30 | #endif 31 | 32 | #define SOL_PROLOGUE_I_ 1 33 | 34 | 35 | #if SOL_IS_ON(SOL_BUILD_CXX_MODE) 36 | #define _FWD(...) static_cast( __VA_ARGS__ ) 37 | 38 | #if SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG) 39 | #define _MOVE(...) static_cast<__typeof( __VA_ARGS__ )&&>( __VA_ARGS__ ) 40 | #else 41 | #include 42 | 43 | #define _MOVE(...) static_cast<::std::remove_reference_t<( __VA_ARGS__ )>&&>( __VA_OPT__(,) ) 44 | #endif 45 | #endif 46 | 47 | // clang-format on 48 | -------------------------------------------------------------------------------- /3rdparty/sol/protect.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_PROTECT_HPP 25 | #define SOL_PROTECT_HPP 26 | 27 | #include 28 | #include 29 | 30 | namespace sol { 31 | 32 | template 33 | struct protect_t { 34 | T value; 35 | 36 | template >> = meta::enabler> 37 | protect_t(Arg&& arg, Args&&... args) : value(std::forward(arg), std::forward(args)...) { 38 | } 39 | 40 | protect_t(const protect_t&) = default; 41 | protect_t(protect_t&&) = default; 42 | protect_t& operator=(const protect_t&) = default; 43 | protect_t& operator=(protect_t&&) = default; 44 | }; 45 | 46 | template 47 | auto protect(T&& value) { 48 | return protect_t>(std::forward(value)); 49 | } 50 | 51 | } // namespace sol 52 | 53 | #endif // SOL_PROTECT_HPP 54 | -------------------------------------------------------------------------------- /3rdparty/sol/proxy_base.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_PROXY_BASE_HPP 25 | #define SOL_PROXY_BASE_HPP 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | namespace sol { 32 | struct proxy_base_tag { }; 33 | 34 | namespace detail { 35 | template 36 | using proxy_key_t = meta::conditional_t, std::tuple>, T, 37 | std::tuple>, std::remove_reference_t&, meta::unqualified_t>>>; 38 | } 39 | 40 | template 41 | struct proxy_base : public proxy_base_tag { 42 | lua_State* lua_state() const { 43 | const Super& super = *static_cast(static_cast(this)); 44 | return super.lua_state(); 45 | } 46 | 47 | operator std::string() const { 48 | const Super& super = *static_cast(static_cast(this)); 49 | return super.template get(); 50 | } 51 | 52 | template >, is_proxy_primitive>> = meta::enabler> 53 | operator T() const { 54 | const Super& super = *static_cast(static_cast(this)); 55 | return super.template get(); 56 | } 57 | 58 | template >, meta::neg>>> = meta::enabler> 60 | operator T&() const { 61 | const Super& super = *static_cast(static_cast(this)); 62 | return super.template get(); 63 | } 64 | }; 65 | 66 | } // namespace sol 67 | 68 | #endif // SOL_PROXY_BASE_HPP 69 | -------------------------------------------------------------------------------- /3rdparty/sol/sol.hpp: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | 3 | // Copyright (c) 2013-2022 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 | #ifndef SOL_HPP 23 | #define SOL_HPP 24 | 25 | #include 26 | 27 | #if SOL_IS_ON(SOL_INSIDE_UNREAL_ENGINE) 28 | #ifdef check 29 | #pragma push_macro("check") 30 | #undef check 31 | #endif 32 | #endif // Unreal Engine 4 Bullshit 33 | 34 | #if SOL_IS_ON(SOL_COMPILER_GCC) 35 | #pragma GCC diagnostic push 36 | #pragma GCC diagnostic ignored "-Wshadow" 37 | #pragma GCC diagnostic ignored "-Wconversion" 38 | #if __GNUC__ > 6 39 | #pragma GCC diagnostic ignored "-Wnoexcept-type" 40 | #endif 41 | #elif SOL_IS_ON(SOL_COMPILER_CLANG) 42 | // we'll just let this alone for now 43 | #elif SOL_IS_ON(SOL_COMPILER_VCXX) 44 | #pragma warning(push) 45 | #pragma warning(disable : 4505) // unreferenced local function has been removed GEE THANKS 46 | #endif // clang++ vs. g++ vs. VC++ 47 | 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | #include 59 | #include 60 | #include 61 | #include 62 | #include 63 | #include 64 | #include 65 | #include 66 | #include 67 | 68 | #if SOL_IS_ON(SOL_COMPILER_GCC) 69 | #pragma GCC diagnostic pop 70 | #elif SOL_IS_ON(SOL_COMPILER_CLANG) 71 | // we'll just let this alone for now 72 | #elif SOL_IS_ON(SOL_COMPILER_VCXX) 73 | #pragma warning(pop) 74 | #endif // g++ 75 | 76 | #if SOL_IS_ON(SOL_INSIDE_UNREAL_ENGINE) 77 | #undef check 78 | #pragma pop_macro("check") 79 | #endif // Unreal Engine 4 Bullshit 80 | 81 | #endif // SOL_HPP 82 | -------------------------------------------------------------------------------- /3rdparty/sol/stack/detail/pairs.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this Spermission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_DETAIL_PAIRS_HPP 25 | #define SOL_DETAIL_PAIRS_HPP 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #include 35 | 36 | namespace sol { namespace stack { namespace stack_detail { 37 | 38 | inline bool maybe_push_lua_next_function(lua_State* L_) { 39 | stack::get_field(L_, "next"); 40 | bool is_next = stack::check(L_); 41 | if (is_next) { 42 | return true; 43 | } 44 | stack::get_field(L_, "table"); 45 | stack::record tracking{}; 46 | if (!stack::loose_table_check(L_, -1, &no_panic, tracking)) { 47 | return false; 48 | } 49 | lua_getfield(L_, -1, "next"); 50 | bool is_table_next_func = stack::check(L_, -1); 51 | if (is_table_next_func) { 52 | return true; 53 | } 54 | lua_pop(L_, 1); 55 | return false; 56 | } 57 | 58 | inline std::optional find_lua_next_function(lua_State* L_) { 59 | if (maybe_push_lua_next_function(L_)) { 60 | return stack::pop(L_); 61 | } 62 | return std::nullopt; 63 | } 64 | 65 | inline int c_lua_next(lua_State* L_) noexcept { 66 | stack_reference table_stack_ref(L_, raw_index(1)); 67 | stateless_stack_reference key_stack_ref(L_, raw_index(2)); 68 | int result = lua_next(table_stack_ref.lua_state(), table_stack_ref.stack_index()); 69 | if (result == 0) { 70 | stack::push(L_, lua_nil); 71 | return 1; 72 | } 73 | return 2; 74 | } 75 | 76 | inline int readonly_pairs(lua_State* L_) noexcept { 77 | int pushed = 0; 78 | if (!maybe_push_lua_next_function(L_)) { 79 | // we do not have the "next" function in the global namespace 80 | // from the "table" global entiry, use our own 81 | pushed += stack::push(L_, &c_lua_next); 82 | } 83 | else { 84 | pushed += 1; 85 | } 86 | int metatable_exists = lua_getmetatable(L_, 1); 87 | SOL_ASSERT(metatable_exists == 1); 88 | const auto& index_key = to_string(sol::meta_function::index); 89 | lua_getfield(L_, lua_gettop(L_), index_key.c_str()); 90 | lua_remove(L_, -2); 91 | pushed += 1; 92 | pushed += stack::push(L_, lua_nil); 93 | return pushed; 94 | } 95 | 96 | }}} // sol::stack::stack_detail 97 | 98 | #endif // SOL_DETAIL_PAIRS_HPP 99 | -------------------------------------------------------------------------------- /3rdparty/sol/stack_check.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_STACK_CHECK_HPP 25 | #define SOL_STACK_CHECK_HPP 26 | 27 | #include 28 | #include 29 | 30 | #endif // SOL_STACK_CHECK_HPP 31 | -------------------------------------------------------------------------------- /3rdparty/sol/stack_check_get.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_STACK_CHECK_GET_HPP 25 | #define SOL_STACK_CHECK_GET_HPP 26 | 27 | #include 28 | #include 29 | 30 | #endif // SOL_STACK_CHECK_GET_HPP 31 | -------------------------------------------------------------------------------- /3rdparty/sol/stack_get.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_STACK_GET_HPP 25 | #define SOL_STACK_GET_HPP 26 | 27 | #include 28 | #include 29 | 30 | #endif // SOL_STACK_GET_HPP 31 | -------------------------------------------------------------------------------- /3rdparty/sol/stack_get_qualified.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_STACK_QUALIFIED_GET_HPP 25 | #define SOL_STACK_QUALIFIED_GET_HPP 26 | 27 | #include 28 | 29 | namespace sol { namespace stack { 30 | 31 | // There are no more enable_ifs that can be used here, 32 | // so this is just for posterity, I guess? 33 | // maybe I'll fill this file in later. 34 | 35 | }} // namespace sol::stack 36 | 37 | #endif // SOL_STACK_QUALIFIED_GET_HPP 38 | -------------------------------------------------------------------------------- /3rdparty/sol/stack_guard.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_STACK_GUARD_HPP 25 | #define SOL_STACK_GUARD_HPP 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | namespace sol { 32 | namespace detail { 33 | inline void stack_fail(int, int) { 34 | #if SOL_IS_ON(SOL_EXCEPTIONS) 35 | throw error(detail::direct_error, "imbalanced stack after operation finish"); 36 | #else 37 | // Lol, what do you want, an error printout? :3c 38 | // There's no sane default here. The right way would be C-style abort(), and that's not acceptable, so 39 | // hopefully someone will register their own stack_fail thing for the `fx` parameter of stack_guard. 40 | #endif // No Exceptions 41 | } 42 | } // namespace detail 43 | 44 | struct stack_guard { 45 | lua_State* L; 46 | int top; 47 | std::function on_mismatch; 48 | 49 | stack_guard(lua_State* L) : stack_guard(L, lua_gettop(L)) { 50 | } 51 | stack_guard(lua_State* L, int top, std::function fx = detail::stack_fail) : L(L), top(top), on_mismatch(std::move(fx)) { 52 | } 53 | bool check_stack(int modification = 0) const { 54 | int bottom = lua_gettop(L) + modification; 55 | if (top == bottom) { 56 | return true; 57 | } 58 | on_mismatch(top, bottom); 59 | return false; 60 | } 61 | ~stack_guard() { 62 | check_stack(); 63 | } 64 | }; 65 | } // namespace sol 66 | 67 | #endif // SOL_STACK_GUARD_HPP 68 | -------------------------------------------------------------------------------- /3rdparty/sol/stack_pop.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_STACK_POP_HPP 25 | #define SOL_STACK_POP_HPP 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | namespace sol { namespace stack { 33 | template 34 | struct popper { 35 | inline static decltype(auto) pop(lua_State* L) { 36 | if constexpr (is_stack_based_v>) { 37 | static_assert(!is_stack_based_v>, 38 | "You cannot pop something that lives solely on the stack: it will not remain on the stack when popped and thusly will go out of " 39 | "scope!"); 40 | } 41 | else { 42 | record tracking {}; 43 | decltype(auto) r = get(L, -lua_size::value, tracking); 44 | lua_pop(L, tracking.used); 45 | return r; 46 | } 47 | } 48 | }; 49 | }} // namespace sol::stack 50 | 51 | #endif // SOL_STACK_POP_HPP 52 | -------------------------------------------------------------------------------- /3rdparty/sol/stack_proxy.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_STACK_PROXY_HPP 25 | #define SOL_STACK_PROXY_HPP 26 | 27 | #include 28 | 29 | namespace sol { 30 | struct stack_proxy : public stack_proxy_base { 31 | public: 32 | stack_proxy() : stack_proxy_base() { 33 | } 34 | stack_proxy(lua_State* L, int index) : stack_proxy_base(L, index) { 35 | } 36 | 37 | template 38 | decltype(auto) call(Args&&... args); 39 | 40 | template 41 | decltype(auto) operator()(Args&&... args) { 42 | return call<>(std::forward(args)...); 43 | } 44 | }; 45 | 46 | namespace stack { 47 | template <> 48 | struct unqualified_getter { 49 | static stack_proxy get(lua_State* L, int index, record& tracking) { 50 | tracking.use(0); 51 | return stack_proxy(L, index); 52 | } 53 | }; 54 | 55 | template <> 56 | struct unqualified_pusher { 57 | static int push(lua_State*, const stack_proxy& ref) { 58 | return ref.push(); 59 | } 60 | }; 61 | } // namespace stack 62 | } // namespace sol 63 | 64 | #endif // SOL_STACK_PROXY_HPP 65 | -------------------------------------------------------------------------------- /3rdparty/sol/stack_proxy_base.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_STACK_PROXY_BASE_HPP 25 | #define SOL_STACK_PROXY_BASE_HPP 26 | 27 | #include 28 | #include 29 | 30 | namespace sol { 31 | struct stack_proxy_base : public proxy_base { 32 | private: 33 | lua_State* m_L; 34 | int m_index; 35 | 36 | public: 37 | stack_proxy_base() : m_L(nullptr), m_index(0) { 38 | } 39 | stack_proxy_base(lua_State* L_, int index_) : m_L(L_), m_index(index_) { 40 | } 41 | 42 | template 43 | decltype(auto) get() const { 44 | return stack::get(m_L, stack_index()); 45 | } 46 | 47 | template 48 | bool is() const { 49 | return stack::check(m_L, stack_index()); 50 | } 51 | 52 | template 53 | decltype(auto) as() const { 54 | return get(); 55 | } 56 | 57 | type get_type() const noexcept { 58 | return type_of(lua_state(), stack_index()); 59 | } 60 | 61 | int push() const { 62 | return push(m_L); 63 | } 64 | 65 | int push(lua_State* L_) const { 66 | lua_pushvalue(L_, m_index); 67 | return 1; 68 | } 69 | 70 | lua_State* lua_state() const { 71 | return m_L; 72 | } 73 | int stack_index() const { 74 | return m_index; 75 | } 76 | }; 77 | 78 | namespace stack { 79 | template <> 80 | struct unqualified_getter { 81 | static stack_proxy_base get(lua_State* L_, int index_ = -1) { 82 | return stack_proxy_base(L_, index_); 83 | } 84 | }; 85 | 86 | template <> 87 | struct unqualified_pusher { 88 | static int push(lua_State*, const stack_proxy_base& proxy_reference) { 89 | return proxy_reference.push(); 90 | } 91 | }; 92 | } // namespace stack 93 | 94 | } // namespace sol 95 | 96 | #endif // SOL_STACK_PROXY_BASE_HPP 97 | -------------------------------------------------------------------------------- /3rdparty/sol/state.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_STATE_HPP 25 | #define SOL_STATE_HPP 26 | 27 | #include 28 | #include 29 | namespace fastweb 30 | { 31 | class app; 32 | } 33 | namespace sol { 34 | 35 | class state : private std::unique_ptr, public state_view { 36 | private: 37 | typedef std::unique_ptr unique_base; 38 | 39 | public: 40 | state(lua_CFunction panic = default_at_panic) : unique_base(luaL_newstate()), state_view(unique_base::get()) { 41 | set_default_state(unique_base::get(), panic); 42 | } 43 | 44 | state(lua_CFunction panic, lua_Alloc alfunc, void* alpointer = nullptr) 45 | : unique_base(lua_newstate(alfunc, alpointer)), state_view(unique_base::get()) { 46 | set_default_state(unique_base::get(), panic); 47 | } 48 | 49 | state(const state&) = delete; 50 | state(state&&) = default; 51 | state& operator=(const state&) = delete; 52 | state& operator=(state&& that) { 53 | state_view::operator=(std::move(that)); 54 | unique_base::operator=(std::move(that)); 55 | return *this; 56 | } 57 | 58 | using state_view::get; 59 | 60 | ~state() { 61 | } 62 | }; 63 | } // namespace sol 64 | 65 | #endif // SOL_STATE_HPP 66 | -------------------------------------------------------------------------------- /3rdparty/sol/string_view.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_STRING_VIEW_HPP 25 | #define SOL_STRING_VIEW_HPP 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | namespace sol { 35 | template > 36 | using basic_string_view = std::basic_string_view; 37 | 38 | typedef std::string_view string_view; 39 | typedef std::wstring_view wstring_view; 40 | typedef std::u16string_view u16string_view; 41 | typedef std::u32string_view u32string_view; 42 | typedef std::hash string_view_hash; 43 | } // namespace sol 44 | 45 | #endif // SOL_STRING_VIEW_HPP 46 | -------------------------------------------------------------------------------- /3rdparty/sol/tuple.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_TUPLE_HPP 25 | #define SOL_TUPLE_HPP 26 | 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | 33 | namespace sol { 34 | namespace detail { 35 | using swallow = std::initializer_list; 36 | } // namespace detail 37 | 38 | namespace meta { 39 | template 40 | using is_tuple = is_specialization_of; 41 | 42 | template 43 | constexpr inline bool is_tuple_v = is_tuple::value; 44 | 45 | namespace detail { 46 | template 47 | struct tuple_types_ { 48 | typedef types type; 49 | }; 50 | 51 | template 52 | struct tuple_types_> { 53 | typedef types type; 54 | }; 55 | } // namespace detail 56 | 57 | template 58 | using tuple_types = typename detail::tuple_types_::type; 59 | 60 | template 61 | struct pop_front_type; 62 | 63 | template 64 | using pop_front_type_t = typename pop_front_type::type; 65 | 66 | template 67 | struct pop_front_type> { 68 | typedef void front_type; 69 | typedef types type; 70 | }; 71 | 72 | template 73 | struct pop_front_type> { 74 | typedef Arg front_type; 75 | typedef types type; 76 | }; 77 | 78 | template 79 | using tuple_element = std::tuple_element>; 80 | 81 | template 82 | using tuple_element_t = std::tuple_element_t>; 83 | 84 | template 85 | using unqualified_tuple_element = unqualified>; 86 | 87 | template 88 | using unqualified_tuple_element_t = unqualified_t>; 89 | 90 | } // namespace meta 91 | } // namespace sol 92 | 93 | #endif // SOL_TUPLE_HPP 94 | -------------------------------------------------------------------------------- /3rdparty/sol/unreachable.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_UNREACHABLE_HPP 25 | #define SOL_UNREACHABLE_HPP 26 | 27 | #include 28 | 29 | #if SOL_HAS_BUILTIN_I_(__builtin_unreachable) 30 | #define SOL_UNREACHABLE() __builtin_unreachable(); 31 | #elif SOL_IS_ON(SOL_COMPILER_VCXX) 32 | #define SOL_UNREACHABLE() __assume(false); 33 | #else 34 | #define SOL_UNREACHABLE() __builtin_unreachable(); 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /3rdparty/sol/usertype_traits.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_USERTYPE_TRAITS_HPP 25 | #define SOL_USERTYPE_TRAITS_HPP 26 | 27 | #include 28 | 29 | namespace sol { 30 | 31 | template 32 | struct usertype_traits { 33 | static const std::string& name() { 34 | static const std::string& n = detail::short_demangle(); 35 | return n; 36 | } 37 | static const std::string& qualified_name() { 38 | static const std::string& q_n = detail::demangle(); 39 | return q_n; 40 | } 41 | static const std::string& metatable() { 42 | static const std::string m = std::string("sol.").append(detail::demangle()); 43 | return m; 44 | } 45 | static const std::string& user_metatable() { 46 | static const std::string u_m = std::string("sol.").append(detail::demangle()).append(".user"); 47 | return u_m; 48 | } 49 | static const std::string& user_gc_metatable() { 50 | static const std::string u_g_m = std::string("sol.").append(detail::demangle()).append(".user\xE2\x99\xBB"); 51 | return u_g_m; 52 | } 53 | static const std::string& gc_table() { 54 | static const std::string g_t = std::string("sol.").append(detail::demangle()).append(".\xE2\x99\xBB"); 55 | return g_t; 56 | } 57 | }; 58 | 59 | } // namespace sol 60 | 61 | #endif // SOL_USERTYPE_TRAITS_HPP 62 | -------------------------------------------------------------------------------- /3rdparty/sol/utility/is_integer.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this Spermission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_IS_INTEGER_HPP 25 | #define SOL_IS_INTEGER_HPP 26 | 27 | #include 28 | 29 | namespace sol::utility { 30 | 31 | // Returns true if the object is represented by an integer, 32 | // not a floating point number or any other type. 33 | inline bool is_integer(const sol::object& object) { 34 | auto pp = stack::push_pop(object); 35 | return lua_isinteger(object.lua_state(), -1); 36 | } 37 | inline bool is_integer(const sol::stack_object& object) { 38 | return lua_isinteger(object.lua_state(), object.stack_index()); 39 | } 40 | 41 | } // namespace sol::utility 42 | 43 | #endif // SOL_IS_INTEGER_HPP 44 | -------------------------------------------------------------------------------- /3rdparty/sol/utility/to_string.hpp: -------------------------------------------------------------------------------- 1 | // sol2 2 | 3 | // The MIT License (MIT) 4 | 5 | // Copyright (c) 2013-2022 Rapptz, ThePhD and contributors 6 | 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | // this software and associated documentation files (the "Software"), to deal in 9 | // the Software without restriction, including without limitation the rights to 10 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | // the Software, and to permit persons to whom the Software is furnished to do so, 12 | // subject to the following conditions: 13 | 14 | // The above copyright notice and this Spermission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | #ifndef SOL_TO_STRING_HPP 25 | #define SOL_TO_STRING_HPP 26 | 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | 33 | namespace sol::utility { 34 | 35 | // Converts any object into a string using luaL_tolstring. 36 | // 37 | // Note: Uses the metamethod __tostring if available. 38 | inline std::string to_string(const sol::stack_object& object) { 39 | std::size_t len; 40 | const char* str = luaL_tolstring(object.lua_state(), object.stack_index(), &len); 41 | 42 | auto result = std::string(str, len); 43 | 44 | // luaL_tolstring pushes the string onto the stack, but since 45 | // we have copied it into our std::string by now we should 46 | // remove it from the stack. 47 | lua_pop(object.lua_state(), 1); 48 | 49 | return result; 50 | } 51 | 52 | inline std::string to_string(const sol::object& object) { 53 | auto pp = sol::stack::push_pop(object); 54 | return to_string(sol::stack_object(object.lua_state(), -1)); 55 | } 56 | 57 | } // namespace sol::utility 58 | 59 | #endif // SOL_IS_INTEGER_HPP 60 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Software License 2 | 3 | Copyright (C) 2024 [liuyingjie] 4 | 5 | License Terms 6 | 7 | Usage Rights 8 | 9 | 1. Any individual or entity is free to use, copy, and distribute the binary form of this software without modification to the source code, without the need to disclose the source code. 10 | 2. If the source code is modified, the modifications must be open-sourced under the same license. This means that the modifications must be disclosed and accompanied by a copy of this license. 11 | 12 | Future Versions Updates 13 | 14 | 1. From this version onwards, all future releases will be governed by the terms of the latest version of the license. This license will automatically be nullified and replaced by the new version. 15 | 2. Users must comply with the terms of the new license issued in future releases. 16 | 17 | Liability and Disclaimer 18 | 19 | This software is provided "as is", without any express or implied warranties, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non-infringement. In no event shall the author or copyright holder be liable for any claims, damages, or other liabilities, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software. 20 | 21 | Contact Information 22 | 23 | If you have any questions, please contact us: 1585346868@qq.com Or visit our website fwlua.com. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | # Fast Web 网站服务 5 | 6 | 7 | Fast Web 是一个网站服务程序,以快速开发、部署简单为理念,旨在简化复杂的部署和环境配置,使开发者能够迅速启动并运行他们的网站。 8 | 9 | 10 | - **LUA脚本**:Lua脚本编写业务逻辑,轻松引用拓展模块 11 | - **易于部署**:支持跨平台一键部署,无需Nginx、依赖简单,轻量高效 12 | - **灵活易用**:适合各类个人博客、API接口到复杂的企业级项目 13 | - **开源共建**:欢迎开发者贡献代码,参与项目共建,推动Fast Web的发展 14 |
15 | 16 | ## ⚡立即开始 17 | 无论您是编程新手还是经验丰富的开发人员,学习和使用 Fast Web 都很容易。 18 | 19 | FastWeb官网 20 | 21 | ## 下载⬇️ 22 | 23 | 所有版本的 Fast Web 源代码和安装程序均可供下载! 24 | 最新版:点击下载 25 | 26 | ## 文档📄 27 | Fast Web 标准库的文档以及教程和指南都可以在线获取。 28 | 文档中心 29 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sudo apt update -y 3 | apt install -y git 4 | # 创建3rdparty目录 5 | mkdir -p 3rdparty 6 | 7 | # 进入3rdparty目录 8 | cd 3rdparty 9 | 10 | # 检查ylib是否已经克隆 11 | if [ ! -d "ylib" ]; then 12 | # 克隆ylib C++开发库 13 | git clone https://github.com/Liuccysdgg/ylib.git 14 | 15 | 16 | else 17 | echo "ylib exist" 18 | fi 19 | # 进入ylib目录 20 | cd ylib 21 | chmod 777 build.sh 22 | # 调用buildl.sh进行编译 23 | ./build.sh 24 | 25 | # 返回3rdparty目录 26 | cd .. 27 | # 返回最初的目录 28 | cd .. 29 | 30 | # 克隆fastweb仓库 31 | if [ ! -d "fastweb" ]; then 32 | git clone https://github.com/Liuccysdgg/fastweb.git 33 | fi 34 | 35 | # 进入fastweb目录 36 | cd fastweb 37 | 38 | # 创建build目录 39 | mkdir -p build 40 | 41 | # 进入build目录 42 | cd build 43 | 44 | # 使用cmake配置fastweb代码 45 | cmake .. 46 | 47 | # 编译fastweb 48 | make 49 | make install 50 | -------------------------------------------------------------------------------- /config.ini: -------------------------------------------------------------------------------- 1 | [variable] 2 | ;项目目录 3 | base=${config_dir} 4 | ;网站程序目录 5 | www=${config_dir}/www 6 | 7 | [scripts] 8 | ; 模块目录 9 | module_dir=${base}/module 10 | 11 | [website] 12 | ; 网站静态文件目录 13 | dir=${www} 14 | ; 默认页面-404 15 | default_404=page/404.html 16 | ; 默认首页(index.html,index.htm,index.lua) 17 | default_index=index.html 18 | ; SESSION保存目录 19 | session_dir=${base}/session 20 | ; SESSION默认过期时间 21 | session_timeout_sec=86400 22 | ; 初始化加载脚本(网站程序启动) 23 | Initialization_script= 24 | ; 调试模式,开启后启用LUA错误信息 (0=关闭 1=开启) 25 | debug=1 26 | ; 绑定域名 27 | domain=local.newobj.org,0.0.0.0 28 | ; 允许请求URL的路径直接映射到网站路径中的lua。如你的站点只允许订阅绑定模式,则设置为0关闭此功能以提高安全性。 29 | direct_url_mapping=1 30 | ; 最大上传大小限制(MB),0为不限制 31 | max_upload_size=10 32 | 33 | [log] 34 | ; 开启或关闭 35 | enable=1 36 | ; 保存目录 37 | dir=${base}/log 38 | ; 文件名(所有日志会保存到该文件中) 39 | name=%Y%m%d.log 40 | ; SQLITE日志记录(开启后可用于管理器分析日志) 41 | sqlite=1 42 | 43 | ; 域名配置信息,具体根据 website->domain 而定 44 | [local.newobj.org] 45 | ; 是否为HTTPS 46 | https=1 47 | ;HTTPS证书,完全兼容Nginx证书 48 | ; 证书KEY 49 | ssl_key=${base}/config/ssl/local.newobj.org.key 50 | ; 证书PEM文件 51 | ssl_pem=${base}/config/ssl/local.newobj.org.pem 52 | ; 证书CA文件(默认:空) 53 | ssl_ca= 54 | ; 证书密码(默认:空) 55 | ssl_pwd= 56 | ; ================验证类型================= 57 | ; 0 = 完全忽略验证证书的结果。当握手必须完成的话,就选中这个选项。其实真正有证书的人很少,尤其是在中国,那么如果 SSL 运用于一些免费的服务,比如 EMAIL 的时候,SERVER 端最好采用这个模式。 58 | ; 1 = 希望验证对方的证书。这个是最一般的模式。对 CLIENT 来说,如果设置了这样的模式,验证SERVER的证书出了任何错误,SSL 握手都告吹。对 SERVER 来说,如果设置了这样的模式,CLIENT 倒不一定要把自己的证书交出去。如果 CLIENT 没有交出证书,SERVER 自己决定下一步怎么做。 59 | ; 2 = 这是 SERVER 使用的一种模式,在这种模式下, SERVER 会向 CLIENT 要证书。如果 CLIENT 不给,SSL 握手告吹 60 | ; 3 = 这是仅能使用在 SSL SESSION RENEGOTIATION 阶段的一种方式。如果不是用这个模式的话,那么在 RENEGOTIATION 的时候,CLIENT 都要把自己的证书送给 SERVER,然后做一番分析。这个过程很消耗 CPU 时间的,而这个模式则不需要 CLIENT 在 RENEGOTIATION 的时候重复送自己的证书了。 61 | ssl_ver_type=0 62 | ; 端口,默认https为443,http为80 63 | port=8566 64 | 65 | [0.0.0.0] 66 | https=0 67 | port=8866 68 | 69 | -------------------------------------------------------------------------------- /config/ssl/local.newobj.org.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDBiTdJOfaHJ0L4 3 | BYyiN+CF5uL82wFjfrn5evWwKZ6Ie0JxDkzG/okswhtwvU75g5uhWbWzdQR47EmP 4 | uGJnrw1apVOnzV9e6XuTc2o6YMAInXn1JAfKx5bJCJJr+EnxEw9orsfXk3KGfPBC 5 | vWjzrUcm5oKvC08eCv5Na1w3ukaObQBOwGRp9QY8o046KtmR95V8RKUbtW9W1Ldp 6 | GOJDKHgSC0Os4urHxYpt11tx0u3jjzSphkE/+6F2SDGCza46huzdoYmdaY0d2F0S 7 | jiuve+6pfS8iCyMa05aHq35stWk1PWmtCYzzJXnmbWdMkadJNuQRJUyEOLQ3U2hp 8 | m+ZbJ9zjAgMBAAECggEAIQuCyxgAhfcoMh0QdCpCRdq0ayQhypE6w+RAywFwNjGF 9 | mLQuW9PeLCxAbzGDqIrWKeidY7TZPKRrswRymO2ExDNyYzZn0FbhaL3OJ4WZhF8P 10 | EdJDGlaV4mF6TsEoLudoPCGLsb1VUq1GgL7CisjNW1EEg0rVCXYrEaEBL+q4XVzm 11 | rdUFuui0qNNjSomVTMaiEjyziMQ3k1vKaMvXG8h3eO5O31z67Muy90T6eJ3nBq+3 12 | qbyfgnj3MAly1nKCQRA2IBW7by9beIz2pSz40u207d+PoCcv2/FMsXkuQ4jxji/m 13 | 8VIz1jwd5cwBfMxjZ0hcXO1Nq06WfqHnOyF+zMlfEQKBgQD5XZP6L2+qrOtOIf0U 14 | eDWAGRBCLpc16nevQ7jaovHWdIqFiqZMdnELbpYerTT17XcJx/03EIl1x7P/TJA9 15 | OaMlDG5SoY9XcFTVieZgr0osqgFixi54EEB49HuzxWDj6BMwss39ntVSTAkRzJhx 16 | D9bY5tlCvEaQpFyGPpjfVv4+xwKBgQDGr2JqgTPgrH9mCeIYOr/GwqHWhBHoibT6 17 | f16oyLdnPtctvPAzZJ/cOVHCy0nssSuPR77pK7qb2cHW+n+txq23bhkCEeNkNn6m 18 | 6yzNnG+fO9LKTm/oazqQle9UIaba4if0aIWoHl5tYbQZ//QVJpNAcMR/cwS4V4T0 19 | z/z9Q5NFBQKBgQCfyBdOYuDRYvVvXhX07MWTK/wf/AyFzpQb6G/lIC2HtasgwGOo 20 | cOgkZBqq018xCZSR3uRgSSdbIbgzKNLveCQSVDHInp7jbyXcofzNDOShU9mJeeVC 21 | p184Yad13E4mGolZVejpzsFvdysEja1MHNMUrm6d9VfdzINAvZFk4jAM9wKBgQCU 22 | NINfGt2NvF6TyM+Eb15abxi1oXKSWRZMvPHpST+1niR4k7VBQNAWQBODEI0mJ8ps 23 | aII6AEqEstxq9hSDle5DI7c32gwa1qOG82pKPWTuDHviOLw1TLc03wLVaPzDzWss 24 | X0ND8tNRGE52Dn0NweaZbQTGZQ+iSnZ8/yCh8uRJ2QKBgENPTd40kx9aP2r1/j+D 25 | ONBU8ky3MhoJ056aqYQGRIYCMCCqbXM3wXLgAN/x+75usjFz/iN8rbWcIQjw65nC 26 | SV8x721hl12U+JWvvmGV9owjGLK1pzYfdqa7ixkPO8/O3Uut48Mem/k5rSTxCTwT 27 | W+8UqBhoku6UbW3LTx5hJh4K 28 | -----END PRIVATE KEY----- 29 | -------------------------------------------------------------------------------- /include/dll_interface.h: -------------------------------------------------------------------------------- 1 | #if defined(_WIN32) || defined(_WIN64) 2 | #define DLL_EXPORT __declspec(dllexport) 3 | #else 4 | #define DLL_EXPORT __attribute__((visibility("default"))) 5 | #endif 6 | extern "C" { 7 | /// 8 | /// 注册模块入口 9 | /// 10 | /// 11 | /// 12 | /// 13 | /// 0=成功 14 | /// 1=失败 15 | /// 16 | DLL_EXPORT int fastweb_module_regist(void* sol2,void* lua); 17 | } 18 | -------------------------------------------------------------------------------- /src/core/app.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "define.h" 3 | #include "base/error.h" 4 | 5 | #include "net/http_center.h" 6 | #include "core/subscribemanager.h" 7 | #include "core/interceptormanager.h" 8 | #include "core/statemanager.h" 9 | #include "core/config.h" 10 | #include "core/log.h" 11 | #include "core/global.h" 12 | #include "core/global_module.h" 13 | 14 | namespace fastweb 15 | { 16 | class app :public ylib::error_base { 17 | public: 18 | app(); 19 | ~app(); 20 | bool start(const std::string& config_filepath); 21 | void stop(); 22 | private: 23 | /// 24 | /// 初始化执行脚本 25 | /// 26 | /// 27 | bool initialization_script(); 28 | private: 29 | // 初始化脚本虚拟机 30 | luastate* m_state_init = nullptr; 31 | // 网站服务核心 32 | network::http::center* m_center = nullptr; 33 | public: 34 | // 网站路由 35 | network::http::router* router = nullptr; 36 | // 日志 37 | std::shared_ptr log; 38 | // 订阅管理器 39 | std::shared_ptr subscribe; 40 | // 拦截器管理器 41 | std::shared_ptr interceptor; 42 | // LUA状态管理器 43 | std::shared_ptr state; 44 | // 配置 45 | std::shared_ptr config; 46 | // 应用全局变量 47 | std::shared_ptr global; 48 | // 全局托管模块 49 | std::shared_ptr gloabl_module; 50 | }; 51 | } 52 | -------------------------------------------------------------------------------- /src/core/config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "define.h" 3 | #include "base/error.h" 4 | #include "util/ini.h" 5 | #include "net/http_define.h" 6 | namespace fastweb 7 | { 8 | class config :public Interface { 9 | public: 10 | struct domain { 11 | bool https = false; 12 | ushort port = 0; 13 | network::http::ssl_config ssl; 14 | }; 15 | struct scripts { 16 | //std::vector lib_dir; 17 | std::string module_dir; 18 | uint32 lua_cache_size = 0; 19 | uint32 auto_update_sec = 0; 20 | }; 21 | struct website { 22 | struct __interceptor { 23 | std::string filepath; 24 | std::string regex_express; 25 | }; 26 | std::string dir; 27 | std::string default_404; 28 | std::vector default_index; 29 | std::string session_dir; 30 | uint32 session_timeout_sec; 31 | std::string Initialization_script; 32 | bool debug = false; 33 | std::vector domain; 34 | bool direct_url_mapping = false; 35 | uint64 max_upload_size = 0; 36 | }; 37 | 38 | struct log { 39 | bool enable = false; 40 | std::string dir; 41 | std::string name; 42 | bool sqlite = false; 43 | /*bool succ = false; 44 | bool info = false; 45 | bool warn = false; 46 | bool error = false;*/ 47 | }; 48 | public: 49 | config(fastweb::app* ptr); 50 | bool open(const std::string& ini_filepath); 51 | std::vector lua_lib_files(); 52 | 53 | 54 | void write_runtime(const ylib::json& data); 55 | ylib::json read_runtime(); 56 | 57 | private: 58 | // INI配置文件 59 | ylib::ini m_ini; 60 | private: 61 | /// 62 | /// 查询所有变量字符串 63 | /// 64 | /// 65 | /// 66 | std::vector extractVariableNames(const std::string& text); 67 | /// 68 | /// 缓存配置 69 | /// 70 | void cache(); 71 | public: 72 | std::string m_ini_filepath; 73 | scripts scripts; 74 | website website; 75 | log log; 76 | std::map domain; 77 | 78 | 79 | }; 80 | } 81 | -------------------------------------------------------------------------------- /src/core/define.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "sol/sol.hpp" 5 | #include "base/define.h" 6 | #include "util/system.h" 7 | #include "util/codec.h" 8 | #include "util/strutils.h" 9 | #include "util/file.h" 10 | #include "core/interface.hpp" 11 | 12 | 13 | #define LOG_ERROR(MSG) app()->log->error(MSG,__FILE__ ,__func__,__LINE__ ) 14 | #define LOG_WARN(MSG) app()->log->warn(MSG,__FILE__ ,__func__,__LINE__ ) 15 | #define LOG_INFO(MSG) app()->log->info(MSG,__FILE__ ,__func__,__LINE__ ) 16 | #define LOG_SUCC(MSG) app()->log->success(MSG,__FILE__ ,__func__,__LINE__ ) 17 | #define LOG_DEBUG(MSG) app()->log->debug(MSG,__FILE__ ,__func__,__LINE__ ) 18 | 19 | 20 | 21 | 22 | #define GET_APP sol::state_view lua(ts);fastweb::app* app = lua["____app"] 23 | 24 | 25 | #define ITHREAD_WAIT_MSEC(MSEC) \ 26 | for(int i=0;i<(MSEC/100);i++) \ 27 | { \ 28 | if (::ithread::m_state == 1) \ 29 | break; \ 30 | system::sleep_msec(100); \ 31 | } 32 | 33 | // 34 | #ifdef _WIN32 35 | #define PATH_EX(PATH) codec::to_gbk(PATH) 36 | #else 37 | #define PATH_EX(PATH) PATH 38 | #endif -------------------------------------------------------------------------------- /src/core/entry.cpp: -------------------------------------------------------------------------------- 1 | /*Software License 2 | 3 | Copyright(C) 2024[liuyingjie] 4 | License Terms 5 | Usage Rights 6 | 7 | Any individual or entity is free to use, copy, and distribute the binary form of this software without modification to the source code, without the need to disclose the source code. 8 | If the source code is modified, the modifications must be open - sourced under the same license.This means that the modifications must be disclosed and accompanied by a copy of this license. 9 | Future Versions Updates 10 | From this version onwards, all future releases will be governed by the terms of the latest version of the license.This license will automatically be nullified and replaced by the new version. 11 | Users must comply with the terms of the new license issued in future releases. 12 | Liability and Disclaimer 13 | This software is provided “as is”, without any express or implied warranties, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non - infringement.In no event shall the author or copyright holder be liable for any claims, damages, or other liabilities, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software. 14 | Contact Information 15 | If you have any questions, please contact us: 1585346868@qq.com Or visit our website fwlua.com. 16 | */ 17 | 18 | #include 19 | #include "core/app.h" 20 | #include "util/system.h" 21 | #include "core/define.h" 22 | #include "core/config.h" 23 | #include "entry.h" 24 | extern "C" { 25 | #ifdef _WIN32 26 | DLL_EXPORT 27 | #endif 28 | void* fastweb_start(const char* config_filepath) 29 | { 30 | fastweb::app* app = new fastweb::app(); 31 | if (app->start(config_filepath) == false) 32 | { 33 | 34 | app->log->error("fastweb start failed," + app->last_error(), __FILE__, __func__, __LINE__); 35 | app->log->write(); 36 | delete app; 37 | return nullptr; 38 | } 39 | app->log->success("success", __FILE__, __func__, __LINE__); 40 | return app; 41 | } 42 | #ifdef _WIN32 43 | DLL_EXPORT 44 | #endif 45 | void fastweb_close(void* app) 46 | { 47 | if (app == nullptr) 48 | return; 49 | auto a = static_cast(app); 50 | a->stop(); 51 | delete a; 52 | } 53 | } 54 | 55 | -------------------------------------------------------------------------------- /src/core/entry.h: -------------------------------------------------------------------------------- 1 | #if defined(_WIN32) || defined(_WIN64) 2 | #define DLL_EXPORT __declspec(dllexport) 3 | #else 4 | #define DLL_EXPORT __attribute__((visibility("default"))) 5 | #endif 6 | extern "C" { 7 | DLL_EXPORT void* fastweb_start(const char* config_filepath); 8 | DLL_EXPORT void fastweb_close(void* app); 9 | } 10 | -------------------------------------------------------------------------------- /src/core/global.cpp: -------------------------------------------------------------------------------- 1 | /*Software License 2 | 3 | Copyright(C) 2024[liuyingjie] 4 | License Terms 5 | Usage Rights 6 | 7 | Any individual or entity is free to use, copy, and distribute the binary form of this software without modification to the source code, without the need to disclose the source code. 8 | If the source code is modified, the modifications must be open - sourced under the same license.This means that the modifications must be disclosed and accompanied by a copy of this license. 9 | Future Versions Updates 10 | From this version onwards, all future releases will be governed by the terms of the latest version of the license.This license will automatically be nullified and replaced by the new version. 11 | Users must comply with the terms of the new license issued in future releases. 12 | Liability and Disclaimer 13 | This software is provided “as is”, without any express or implied warranties, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non - infringement.In no event shall the author or copyright holder be liable for any claims, damages, or other liabilities, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software. 14 | Contact Information 15 | If you have any questions, please contact us: 1585346868@qq.com Or visit our website fwlua.com. 16 | */ 17 | 18 | #include "global.h" 19 | #include "module/basemodule.h" 20 | fastweb::global::global(fastweb::app* app):Interface(app) 21 | { 22 | } 23 | fastweb::global::~global() 24 | { 25 | clear(); 26 | } 27 | 28 | void fastweb::global::regist(sol::state* lua) 29 | { 30 | m_ptrs.lock(); 31 | for_iter(iter, (*m_ptrs.parent())) 32 | { 33 | auto im = static_cast(iter->second); 34 | im->regist_global(iter->first.c_str(), lua); 35 | } 36 | m_ptrs.unlock(); 37 | } 38 | void* fastweb::global::get_ptr(const std::string& name) 39 | { 40 | void* result = nullptr; 41 | m_ptrs.get(name,result); 42 | return result; 43 | } 44 | 45 | bool fastweb::global::set_ptr(const std::string& name, void* value, sol::this_state ts) 46 | { 47 | sol::state_view lua(ts); 48 | // INIT中先注册一次,防止被销毁 49 | { 50 | lua.registry()[name] = this; 51 | lua[name] = this; 52 | } 53 | return m_ptrs.add(name, value); 54 | } 55 | 56 | sol::object fastweb::global::get_str(const std::string& name, sol::this_state s) 57 | { 58 | std::string value; 59 | if (m_values.get(name, value)) 60 | return sol::make_object(s, value); 61 | return sol::make_object(s, sol::nil); 62 | } 63 | 64 | void fastweb::global::set_str(const std::string& name, std::string value) 65 | { 66 | m_values.set(name, value, true); 67 | } 68 | 69 | void fastweb::global::clear() 70 | { 71 | //for_iter(iter, (*m_ptrs.parent())) 72 | //{ 73 | // //auto base = ((module::base*)iter->second); 74 | // //base->delete_global(); 75 | //} 76 | m_ptrs.clear(); 77 | m_values.clear(); 78 | } 79 | -------------------------------------------------------------------------------- /src/core/global.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "define.h" 3 | #include "base/error.h" 4 | #include "util/map.hpp" 5 | namespace fastweb 6 | { 7 | /// 8 | /// 应用全局变量 9 | /// 10 | class global : public Interface{ 11 | public: 12 | global(fastweb::app* app); 13 | ~global(); 14 | /// 15 | /// 注册变量 16 | /// 17 | /// 18 | void regist(sol::state* lua); 19 | /// 20 | /// 取指针 21 | /// 22 | /// 23 | /// 24 | void* get_ptr(const std::string& name); 25 | /// 26 | /// 置指针 27 | /// 28 | /// 29 | /// 30 | /// 31 | /// 32 | bool set_ptr(const std::string& name, void* value, sol::this_state ts); 33 | 34 | /// 35 | /// 取对象 36 | /// 37 | /// 38 | /// 39 | sol::object get_str(const std::string& name, sol::this_state s); 40 | /// 41 | /// 置对象 42 | /// 43 | /// 44 | /// 45 | void set_str(const std::string& name, std::string value); 46 | /// 47 | /// 清理 48 | /// 49 | void clear(); 50 | private: 51 | ylib::map m_ptrs; 52 | ylib::map m_values; 53 | }; 54 | } 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/core/global_module.cpp: -------------------------------------------------------------------------------- 1 | /*Software License 2 | 3 | Copyright(C) 2024[liuyingjie] 4 | License Terms 5 | Usage Rights 6 | 7 | Any individual or entity is free to use, copy, and distribute the binary form of this software without modification to the source code, without the need to disclose the source code. 8 | If the source code is modified, the modifications must be open - sourced under the same license.This means that the modifications must be disclosed and accompanied by a copy of this license. 9 | Future Versions Updates 10 | From this version onwards, all future releases will be governed by the terms of the latest version of the license.This license will automatically be nullified and replaced by the new version. 11 | Users must comply with the terms of the new license issued in future releases. 12 | Liability and Disclaimer 13 | This software is provided “as is”, without any express or implied warranties, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non - infringement.In no event shall the author or copyright holder be liable for any claims, damages, or other liabilities, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software. 14 | Contact Information 15 | If you have any questions, please contact us: 1585346868@qq.com Or visit our website fwlua.com. 16 | */ 17 | 18 | #include "global_module.h" 19 | fastweb::global_module::global_module(fastweb::app* app):Interface(app) 20 | { 21 | 22 | } 23 | 24 | fastweb::global_module::~global_module() 25 | { 26 | clear(); 27 | } 28 | 29 | bool fastweb::global_module::regist(const std::string& name, module::base* module_ptr) 30 | { 31 | if (m_ptrs.find(name) != m_ptrs.end()) 32 | return false; 33 | m_ptrs.emplace(name,module_ptr); 34 | return true; 35 | } 36 | 37 | void fastweb::global_module::clear() 38 | { 39 | for_iter(iter,m_ptrs) 40 | { 41 | delete iter->second; 42 | } 43 | m_ptrs.clear(); 44 | } 45 | -------------------------------------------------------------------------------- /src/core/global_module.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "define.h" 3 | #include "base/error.h" 4 | #include "util/map.hpp" 5 | namespace module 6 | { 7 | class base; 8 | } 9 | namespace fastweb 10 | { 11 | /// 12 | /// 全局托管模块(程序启动创建、程序销毁释放) 13 | /// 14 | class global_module : public Interface{ 15 | public: 16 | global_module(fastweb::app* app); 17 | ~global_module(); 18 | /// 19 | /// 创建 20 | /// 21 | /// 22 | bool regist(const std::string& name,module::base* module_ptr); 23 | /// 24 | /// 清理 25 | /// 26 | void clear(); 27 | private: 28 | std::map m_ptrs; 29 | }; 30 | } 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/core/interceptormanager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | #include "core/structs.h" 5 | #include "core/define.h" 6 | #include "net/http_reqpack.h" 7 | #include "net/http_request.h" 8 | #include "net/http_response.h" 9 | #include "net/http_router.h" 10 | #include "util/map.hpp" 11 | namespace fastweb 12 | { 13 | /// 14 | /// 拦截器管理器 15 | /// 16 | class interceptor_manager:public Interface { 17 | public: 18 | interceptor_manager(fastweb::app* app); 19 | ~interceptor_manager(); 20 | 21 | bool add(const std::string& pattern,const std::string& filepath); 22 | bool remove(const std::string& pattern); 23 | bool exist(const std::string& pattern); 24 | void clear(); 25 | private: 26 | /// 27 | /// 服务回调 28 | /// 29 | /// 30 | /// 31 | /// 32 | bool callback(network::http::reqpack* reqpack, const std::string& pattern,const std::string& filepath); 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /src/core/interface.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "base/error.h" 3 | 4 | namespace fastweb 5 | { 6 | class app; 7 | class Interface :public ylib::error_base 8 | { 9 | public: 10 | Interface(fastweb::app* ptr) 11 | { 12 | this->m_ptr = ptr; 13 | } 14 | fastweb::app* app() { return this->m_ptr; } 15 | public: 16 | fastweb::app* m_ptr = nullptr; 17 | }; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /src/core/log.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "util/file.h" 4 | #include "core/define.h" 5 | #include "util/thread.h" 6 | #include "util/queue.hpp" 7 | #include "util/sqlite3.h" 8 | namespace fastweb 9 | { 10 | class log :public Interface,private ylib::ithread { 11 | 12 | public: 13 | enum log_type { 14 | LT_SUCCESS = 1, 15 | LT_INFO = 2, 16 | LT_ERROR = 3, 17 | LT_WARN = 4, 18 | LT_DEBUG = 5, 19 | LT_LUA = 6 20 | }; 21 | private: 22 | struct log_info { 23 | log_type type = LT_SUCCESS; 24 | std::string msg; 25 | std::string filepath; 26 | std::string function; 27 | std::string create_at; 28 | int line; 29 | }; 30 | public: 31 | log(fastweb::app* ptr); 32 | ~log(); 33 | 34 | void start(); 35 | 36 | void success(const std::string& msg, const std::string& filepath, const std::string& func, int line); 37 | void info(const std::string& msg, const std::string& filepath, const std::string& func, int line); 38 | void error(const std::string& msg, const std::string& filepath, const std::string& func, int line); 39 | void warn(const std::string& msg, const std::string& filepath, const std::string& func, int line); 40 | void debug(const std::string& msg, const std::string& filepath, const std::string& func, int line); 41 | void lua(const std::string& msg); 42 | 43 | bool write(); 44 | private: 45 | void print(log_type type, const std::string& msg, const std::string& filepath, const std::string& func, int line, int color, bool error); 46 | bool run() override; 47 | 48 | 49 | 50 | private: 51 | // 当前文件名 52 | std::string m_current_name; 53 | // 文件 54 | ylib::file_io m_file; 55 | // SQLITE 56 | ylib::sqlite3 m_sqlite; 57 | // 日志队列 58 | ylib::queue m_queue; 59 | }; 60 | } 61 | -------------------------------------------------------------------------------- /src/core/lualibdetecter.cpp: -------------------------------------------------------------------------------- 1 | /*Software License 2 | 3 | Copyright(C) 2024[liuyingjie] 4 | License Terms 5 | Usage Rights 6 | 7 | Any individual or entity is free to use, copy, and distribute the binary form of this software without modification to the source code, without the need to disclose the source code. 8 | If the source code is modified, the modifications must be open - sourced under the same license.This means that the modifications must be disclosed and accompanied by a copy of this license. 9 | Future Versions Updates 10 | From this version onwards, all future releases will be governed by the terms of the latest version of the license.This license will automatically be nullified and replaced by the new version. 11 | Users must comply with the terms of the new license issued in future releases. 12 | Liability and Disclaimer 13 | This software is provided “as is”, without any express or implied warranties, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non - infringement.In no event shall the author or copyright holder be liable for any claims, damages, or other liabilities, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software. 14 | Contact Information 15 | If you have any questions, please contact us: 1585346868@qq.com Or visit our website fwlua.com. 16 | */ 17 | 18 | #include "lualibdetecter.h" 19 | #include "core/config.h" 20 | #include "core/app.h" 21 | #include "util/file.h" 22 | fastweb::lualib_detecter::lualib_detecter(fastweb::app* app):Interface(app) 23 | { 24 | } 25 | 26 | fastweb::lualib_detecter::~lualib_detecter() 27 | { 28 | } 29 | 30 | bool fastweb::lualib_detecter::changed() 31 | { 32 | auto lib_files = app()->config->lua_lib_files(); 33 | bool changed = false; 34 | if (lib_files.size() == m_files.size()) 35 | { 36 | for (size_t i = 0; i < lib_files.size(); i++) 37 | { 38 | auto iter = m_files.find(lib_files[i]); 39 | if (iter == m_files.end()) 40 | { 41 | changed = true; 42 | break; 43 | } 44 | if (ylib::file::last_write_time(lib_files[i]) != iter->second) 45 | { 46 | changed = true; 47 | break; 48 | } 49 | } 50 | } 51 | else 52 | changed = true; 53 | 54 | 55 | if (changed == false) 56 | return false; 57 | 58 | m_files.clear(); 59 | for (size_t i = 0; i < lib_files.size(); i++) 60 | m_files.emplace(lib_files[i], ylib::file::last_write_time(lib_files[i])); 61 | 62 | return true; 63 | } 64 | -------------------------------------------------------------------------------- /src/core/lualibdetecter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | #include "sol/sol.hpp" 5 | 6 | #include "base/error.h" 7 | #include "util/thread.h" 8 | #include "util/queue.hpp" 9 | #include "util/map.hpp" 10 | #include "core/structs.h" 11 | #include "core/define.h" 12 | 13 | namespace fastweb 14 | { 15 | /// 16 | /// LUALIB库变动检测 17 | /// 18 | class lualib_detecter:public Interface { 19 | public: 20 | lualib_detecter(fastweb::app* app); 21 | ~lualib_detecter(); 22 | /// 23 | /// 是否变化 24 | /// 25 | /// 26 | bool changed(); 27 | private: 28 | std::map m_files; 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /src/core/modulemanager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "sol/sol.hpp" 4 | #include "core/structs.h" 5 | #include "core/define.h" 6 | typedef int (*fastweb_module_regist)(void*, void*); 7 | typedef int (*lua_interface)(void*); 8 | struct module_info { 9 | void* dll = nullptr; 10 | fastweb_module_regist func = nullptr; 11 | }; 12 | namespace fastweb 13 | { 14 | /// 15 | /// 模块管理器 16 | /// 17 | class module_manager :public Interface { 18 | public: 19 | module_manager(fastweb::app* app); 20 | ~module_manager(); 21 | 22 | void start(); 23 | void close(); 24 | /// 25 | /// 加载虚拟机库 26 | /// 27 | /// 28 | void load(sol::state* lua); 29 | private: 30 | /// 31 | /// 加载核心库 32 | /// 33 | /// 34 | void load_core(sol::state* lua); 35 | /// 36 | /// 加载三方库 37 | /// 38 | void load_3rdparty(sol::state* lua); 39 | /// 40 | /// 加载LUA库 41 | /// 42 | /// 43 | void load_lualib(sol::state* lua); 44 | /// 45 | /// 取模块文件列表 46 | /// 47 | /// 48 | std::vector modules(); 49 | private: 50 | // DLL模块 51 | std::map m_modules; 52 | // LUA虚拟机引用 53 | std::string m_lua_include_path; 54 | std::string m_lua_include_cpath; 55 | }; 56 | } 57 | -------------------------------------------------------------------------------- /src/core/statemanager.cpp: -------------------------------------------------------------------------------- 1 | /*Software License 2 | 3 | Copyright(C) 2024[liuyingjie] 4 | License Terms 5 | Usage Rights 6 | 7 | Any individual or entity is free to use, copy, and distribute the binary form of this software without modification to the source code, without the need to disclose the source code. 8 | If the source code is modified, the modifications must be open - sourced under the same license.This means that the modifications must be disclosed and accompanied by a copy of this license. 9 | Future Versions Updates 10 | From this version onwards, all future releases will be governed by the terms of the latest version of the license.This license will automatically be nullified and replaced by the new version. 11 | Users must comply with the terms of the new license issued in future releases. 12 | Liability and Disclaimer 13 | This software is provided “as is”, without any express or implied warranties, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non - infringement.In no event shall the author or copyright holder be liable for any claims, damages, or other liabilities, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software. 14 | Contact Information 15 | If you have any questions, please contact us: 1585346868@qq.com Or visit our website fwlua.com. 16 | */ 17 | 18 | #include "statemanager.h" 19 | 20 | #include "util/file.h" 21 | #include "util/system.h" 22 | #include "util/time.h" 23 | 24 | #include "core/define.h" 25 | #include "core/config.h" 26 | #include "core/global.h" 27 | #include "core/app.h" 28 | 29 | 30 | #define LOOP_STATE_USE 1 31 | fastweb::state_manager::state_manager(fastweb::app* app):Interface(app) 32 | { 33 | lib_detecter = std::make_shared(app); 34 | module_manager = std::make_shared(app); 35 | } 36 | fastweb::state_manager::~state_manager() 37 | { 38 | } 39 | bool fastweb::state_manager::start() 40 | { 41 | close(); 42 | ::ithread::start(); 43 | module_manager->start(); 44 | return true; 45 | } 46 | 47 | void fastweb::state_manager::close() 48 | { 49 | ::ithread::stop(); 50 | ::ithread::wait(); 51 | luastate* state = nullptr; 52 | while (m_states.pop(state)) 53 | delete state; 54 | module_manager->close(); 55 | } 56 | luastate* fastweb::state_manager::create() 57 | { 58 | luastate* lua = new luastate(); 59 | lua->flag = m_flag; 60 | (*lua->state)["____app"] = app(); 61 | 62 | // 加载库或模块 63 | module_manager->load(lua->state); 64 | return lua; 65 | } 66 | 67 | luastate* fastweb::state_manager::get() 68 | { 69 | luastate* result = nullptr; 70 | while (m_states.pop(result)) 71 | { 72 | if (result->flag != m_flag) 73 | delete result; 74 | else 75 | return result; 76 | } 77 | return create(); 78 | } 79 | 80 | void fastweb::state_manager::push(luastate* state) 81 | { 82 | if (state == nullptr) 83 | return; 84 | if (state->flag != m_flag) 85 | { 86 | delete state; 87 | return; 88 | } 89 | m_states.push(state); 90 | } 91 | 92 | 93 | bool fastweb::state_manager::run() 94 | { 95 | if (lib_detecter->changed()) 96 | m_flag++; 97 | 98 | for (size_t i = 0; i < 30; i++) 99 | { 100 | if (::ithread::m_state == 1) 101 | break; 102 | system::sleep_msec(100); 103 | } 104 | 105 | return true; 106 | } 107 | 108 | -------------------------------------------------------------------------------- /src/core/statemanager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | #include "sol/sol.hpp" 5 | 6 | #include "base/error.h" 7 | #include "util/thread.h" 8 | #include "util/queue.hpp" 9 | #include "util/map.hpp" 10 | 11 | #include "core/structs.h" 12 | #include "core/lualibdetecter.h" 13 | #include "core/modulemanager.h" 14 | namespace fastweb 15 | { 16 | /// 17 | /// LUA状态管理器 18 | /// 19 | class state_manager :private ylib::ithread,public Interface { 20 | public: 21 | state_manager(fastweb::app* app); 22 | ~state_manager(); 23 | /// 24 | /// 启动 25 | /// 26 | bool start(); 27 | void close(); 28 | /// 29 | /// 取虚拟机 30 | /// 31 | /// 32 | luastate* get(); 33 | /// 34 | /// 归还虚拟机 35 | /// 36 | /// 37 | void push(luastate* state); 38 | public: 39 | // 模块管理器 40 | std::shared_ptr module_manager; 41 | private: 42 | // 虚拟机 43 | ylib::queue m_states; 44 | // 版本FLAT 45 | size_t m_flag = 0; 46 | // LIB变化检测 47 | std::shared_ptr lib_detecter; 48 | 49 | private: 50 | // 通过 ithread 继承 51 | bool run() override; 52 | /// 53 | /// 创建虚拟机 54 | /// 55 | /// 56 | luastate* create(); 57 | 58 | 59 | 60 | 61 | }; 62 | } 63 | -------------------------------------------------------------------------------- /src/core/structs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "base/define.h" 3 | #include "sol/sol.hpp" 4 | /// 5 | /// LUA字节码 6 | /// 7 | struct bytecode { 8 | // 路径 9 | std::string filepath; 10 | // 上次修改时间 11 | timestamp pre_modify_msec = 0; 12 | // 字节码 13 | std::string value; 14 | // 自动更新 15 | bool auto_update = false; 16 | }; 17 | /// 18 | /// 包装虚拟机 19 | /// 20 | struct luastate { 21 | luastate() 22 | { 23 | state = new sol::state(); 24 | } 25 | ~luastate() 26 | { 27 | delete state; 28 | } 29 | sol::state* state = nullptr; 30 | size_t flag = 0; 31 | }; -------------------------------------------------------------------------------- /src/core/subscribemanager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | #include "core/structs.h" 5 | #include "core/define.h" 6 | #include "net/http_reqpack.h" 7 | #include "net/http_request.h" 8 | #include "net/http_response.h" 9 | #include "net/http_router.h" 10 | #include "util/map.hpp" 11 | namespace fastweb 12 | { 13 | /// 14 | /// 订阅管理器 15 | /// 16 | class subscribe_manager :public Interface { 17 | public: 18 | subscribe_manager(fastweb::app* app); 19 | ~subscribe_manager(); 20 | 21 | void start(); 22 | bool add(const std::string& pattern, const std::string& filepath); 23 | bool remove(const std::string& pattern); 24 | bool exist(const std::string& pattern); 25 | void clear(); 26 | private: 27 | /// 28 | /// 服务回调 29 | /// 30 | /// 31 | /// 32 | /// 33 | /// 34 | bool callback(network::http::request* request, network::http::response* response, const std::string& pattern, const std::string& filepath); 35 | /// 36 | /// 其它 37 | /// 38 | /// 39 | /// 40 | void other(network::http::request* request, network::http::response* response); 41 | private: 42 | /// 43 | /// 未找到页面 44 | /// 45 | /// 46 | void send_404(network::http::response* response); 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /src/module/basemodule.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "sol/sol.hpp" 3 | 4 | namespace module 5 | { 6 | /// 7 | /// 模块继承接口 8 | /// 9 | class base { 10 | public: 11 | virtual ~base() {}; 12 | /// 13 | /// 注册全局变量(global类管理) 14 | /// 15 | /// 16 | /// 17 | virtual void regist_global(const char* name, sol::state* lua) = 0; 18 | /// 19 | /// 释放全局变量(global类管理) 20 | /// 21 | virtual void delete_global() = 0; 22 | /// 23 | /// 全局变量阶段获取自身指针 24 | /// 25 | /// 26 | virtual void* self() { return this; } 27 | }; 28 | } 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/module/codec.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "sol/sol.hpp" 3 | #include "basemodule.h" 4 | 5 | namespace module 6 | { 7 | /// 8 | /// 编解码 9 | /// 10 | class codec{ 11 | public: 12 | /// 13 | /// URL解码 14 | /// 15 | static std::string url_de(const std::string& value); 16 | /// 17 | /// URL编码 18 | /// 19 | static std::string url_en(const std::string& value); 20 | /// 21 | /// GBK转UTF8 22 | /// 23 | /// 24 | static std::string to_utf8(const std::string& value); 25 | static std::string to_gbk(const std::string& value); 26 | /// 27 | /// MD5校验 28 | /// 29 | /// 30 | /// 31 | static std::string md5(const std::string& value); 32 | 33 | static std::string sha1(const std::string_view& value); 34 | static std::string sha256(const std::string_view& value); 35 | static std::string hmac_sha256(const std::string_view& key,const std::string_view& value); 36 | 37 | static std::string aes_en(const std::string_view& value, const std::string_view& key, const std::string& variant,const std::string& mode); 38 | static std::string aes_de(const std::string_view& value,const std::string_view& key, const std::string& variant, const std::string& mode); 39 | 40 | 41 | static void regist(sol::state* lua); 42 | }; 43 | 44 | } 45 | 46 | -------------------------------------------------------------------------------- /src/module/globalfuns.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "core/define.h" 3 | /// 4 | /// 全局注册函数 5 | /// 6 | namespace module 7 | { 8 | class globalfuncs { 9 | public: 10 | /// 11 | /// 生成软件唯一GUID 12 | /// 13 | /// 14 | static std::string make_software_guid(); 15 | /// 16 | /// 接管打印 17 | /// 18 | /// 19 | static void print(sol::variadic_args args, sol::this_state ts); 20 | /// 21 | /// 置全局指针 22 | /// 23 | /// 24 | /// 25 | /// 26 | /// 27 | static bool set_ptr(const std::string& name, void* ptr, sol::this_state ts); 28 | 29 | /// 30 | /// 置全局文本 31 | /// 32 | /// 33 | /// 34 | static void set_str(const std::string& name,std::string value, sol::this_state ts); 35 | /// 36 | /// 取全局文本 37 | /// 38 | /// 39 | /// 40 | /// 41 | static sol::object get_str(const std::string& name, sol::this_state s); 42 | /// 43 | /// 抛出异常 44 | /// 45 | /// 46 | static void throw_string(const std::string& msg); 47 | /// 48 | /// 网站目录 49 | /// 50 | static std::string website_dir(sol::this_state ts); 51 | /// 52 | /// 创建环境 53 | /// 54 | /// 55 | static void create_env(const std::string& lua_filepath,sol::this_state ts); 56 | /// 57 | /// 转INT 58 | /// 59 | /// 60 | static std::optional toint(const sol::object& arg); 61 | 62 | 63 | static void regist(sol::state* lua); 64 | }; 65 | 66 | } 67 | 68 | -------------------------------------------------------------------------------- /src/module/http/httpclient.cpp: -------------------------------------------------------------------------------- 1 | /*Software License 2 | 3 | Copyright(C) 2024[liuyingjie] 4 | License Terms 5 | Usage Rights 6 | 7 | Any individual or entity is free to use, copy, and distribute the binary form of this software without modification to the source code, without the need to disclose the source code. 8 | If the source code is modified, the modifications must be open - sourced under the same license.This means that the modifications must be disclosed and accompanied by a copy of this license. 9 | Future Versions Updates 10 | From this version onwards, all future releases will be governed by the terms of the latest version of the license.This license will automatically be nullified and replaced by the new version. 11 | Users must comply with the terms of the new license issued in future releases. 12 | Liability and Disclaimer 13 | This software is provided “as is”, without any express or implied warranties, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non - infringement.In no event shall the author or copyright holder be liable for any claims, damages, or other liabilities, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software. 14 | Contact Information 15 | If you have any questions, please contact us: 1585346868@qq.com Or visit our website fwlua.com. 16 | */ 17 | 18 | #include "httpclient.h" 19 | 20 | module::httpclient::httpclient() 21 | { 22 | } 23 | 24 | module::httpclient::~httpclient() 25 | { 26 | } 27 | 28 | void module::httpclient::set_timeout(uint32 connect_msec, uint32 recv_msec) 29 | { 30 | m_client.set_timeout(connect_msec,recv_msec); 31 | } 32 | 33 | bool module::httpclient::get(const std::string& url) 34 | { 35 | return m_client.get(url); 36 | } 37 | 38 | bool module::httpclient::post(const std::string& url, const std::string& body) 39 | { 40 | return m_client.post(url,ylib::buffer(body)); 41 | } 42 | 43 | void module::httpclient::request_header(const std::string& name, const std::string& value) 44 | { 45 | m_client.headers_request().set(name, value); 46 | } 47 | 48 | std::string module::httpclient::response_header(const std::string& name) 49 | { 50 | return m_client.headers_response().get(name).to_string(); 51 | } 52 | 53 | std::string module::httpclient::response() 54 | { 55 | return m_client.response().to_string(); 56 | } 57 | 58 | ushort module::httpclient::status() 59 | { 60 | return m_client.status(); 61 | } 62 | 63 | void module::httpclient::regist(sol::state* lua) 64 | { 65 | lua->new_usertype("fw_httpclient", 66 | "new", sol::constructors(), 67 | "get", &module::httpclient::get, 68 | "post", &module::httpclient::post, 69 | "set_timeout", &module::httpclient::set_timeout, 70 | "request_header", &module::httpclient::request_header, 71 | "response_header", &module::httpclient::response_header, 72 | "status", &module::httpclient::status, 73 | "response", &module::httpclient::response 74 | ); 75 | } 76 | -------------------------------------------------------------------------------- /src/module/http/httpclient.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "sol/sol.hpp" 3 | #include "net/http_client_plus.h" 4 | namespace module 5 | { 6 | class httpclient 7 | { 8 | public: 9 | httpclient(); 10 | ~httpclient(); 11 | 12 | void set_timeout(uint32 connect_msec = 3000, uint32 recv_msec = 8000); 13 | bool get(const std::string& url); 14 | bool post(const std::string& url,const std::string& body); 15 | void request_header(const std::string& name,const std::string& value); 16 | std::string response_header(const std::string& name); 17 | std::string response(); 18 | ushort status(); 19 | 20 | static void regist(sol::state* lua); 21 | private: 22 | network::http::client_plus m_client; 23 | }; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /src/module/http/interceptor.cpp: -------------------------------------------------------------------------------- 1 | /*Software License 2 | 3 | Copyright(C) 2024[liuyingjie] 4 | License Terms 5 | Usage Rights 6 | 7 | Any individual or entity is free to use, copy, and distribute the binary form of this software without modification to the source code, without the need to disclose the source code. 8 | If the source code is modified, the modifications must be open - sourced under the same license.This means that the modifications must be disclosed and accompanied by a copy of this license. 9 | Future Versions Updates 10 | From this version onwards, all future releases will be governed by the terms of the latest version of the license.This license will automatically be nullified and replaced by the new version. 11 | Users must comply with the terms of the new license issued in future releases. 12 | Liability and Disclaimer 13 | This software is provided “as is”, without any express or implied warranties, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non - infringement.In no event shall the author or copyright holder be liable for any claims, damages, or other liabilities, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software. 14 | Contact Information 15 | If you have any questions, please contact us: 1585346868@qq.com Or visit our website fwlua.com. 16 | */ 17 | 18 | #include "interceptor.h" 19 | #include "core/app.h" 20 | 21 | module::interceptor::interceptor() 22 | { 23 | } 24 | 25 | module::interceptor::~interceptor() 26 | { 27 | } 28 | 29 | bool module::interceptor::add(const std::string& pattern, const std::string& filepath, sol::this_state ts) 30 | { 31 | GET_APP; 32 | return app->interceptor->add(pattern,filepath); 33 | } 34 | 35 | bool module::interceptor::remove(const std::string& pattern, sol::this_state ts) 36 | { 37 | GET_APP; 38 | return app->interceptor->remove(pattern); 39 | } 40 | 41 | bool module::interceptor::exist(const std::string& pattern, sol::this_state ts) 42 | { 43 | GET_APP; 44 | return app->interceptor->exist(pattern); 45 | } 46 | 47 | void module::interceptor::clear(sol::this_state ts) 48 | { 49 | GET_APP; 50 | return app->interceptor->clear(); 51 | } 52 | 53 | void module::interceptor::regist(sol::state* lua) 54 | { 55 | lua->new_usertype("fw_interceptor", 56 | "add", &module::interceptor::add, 57 | "remove", &module::interceptor::remove, 58 | "exist", &module::interceptor::exist, 59 | "clear", &module::interceptor::clear 60 | ); 61 | } 62 | -------------------------------------------------------------------------------- /src/module/http/interceptor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "net/http_request.h" 3 | #include "net/http_response.h" 4 | #include "sol/sol.hpp" 5 | 6 | namespace module 7 | { 8 | class interceptor 9 | { 10 | public: 11 | interceptor(); 12 | ~interceptor(); 13 | /// 14 | /// 添加 15 | /// 16 | /// 17 | /// 18 | /// 19 | static bool add(const std::string& pattern,const std::string& filepath, sol::this_state ts); 20 | /// 21 | /// 移除 22 | /// 23 | /// 24 | static bool remove(const std::string& pattern, sol::this_state ts); 25 | /// 26 | /// 是否存在 27 | /// 28 | /// 29 | /// 30 | static bool exist(const std::string& pattern, sol::this_state ts); 31 | /// 32 | /// 清空 33 | /// 34 | static void clear(sol::this_state ts); 35 | 36 | static void regist(sol::state* lua); 37 | }; 38 | } 39 | 40 | -------------------------------------------------------------------------------- /src/module/http/response.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "net/http_request.h" 3 | #include "net/http_response.h" 4 | #include "sol/sol.hpp" 5 | 6 | namespace module 7 | { 8 | class response 9 | { 10 | public: 11 | response(network::http::response* response); 12 | ~response(); 13 | 14 | bool send_data(const char* buf, size_t buf_len, ushort stateNum, const std::string& stateDesc); 15 | bool send(const std::string& value); 16 | bool sendex(const std::string& value, ushort stateNum, const std::string& stateDesc); 17 | bool send_file(const std::string& filepath, int32 downbaud, ushort stateNum, const std::string& stateDesc); 18 | bool redirect(const std::string& filepath, bool MovedPermanently = false); 19 | bool forward(const std::string& filepath); 20 | void header(const std::string& name, const std::string& value); 21 | 22 | void set(const std::string& name,const std::string& value); 23 | void sets(const sol::table& lua_table); 24 | static void regist(sol::state* lua); 25 | private: 26 | network::http::response* m_response = nullptr; 27 | std::map m_sets; 28 | }; 29 | } 30 | 31 | -------------------------------------------------------------------------------- /src/module/http/session.cpp: -------------------------------------------------------------------------------- 1 | /*Software License 2 | 3 | Copyright(C) 2024[liuyingjie] 4 | License Terms 5 | Usage Rights 6 | 7 | Any individual or entity is free to use, copy, and distribute the binary form of this software without modification to the source code, without the need to disclose the source code. 8 | If the source code is modified, the modifications must be open - sourced under the same license.This means that the modifications must be disclosed and accompanied by a copy of this license. 9 | Future Versions Updates 10 | From this version onwards, all future releases will be governed by the terms of the latest version of the license.This license will automatically be nullified and replaced by the new version. 11 | Users must comply with the terms of the new license issued in future releases. 12 | Liability and Disclaimer 13 | This software is provided “as is”, without any express or implied warranties, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non - infringement.In no event shall the author or copyright holder be liable for any claims, damages, or other liabilities, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software. 14 | Contact Information 15 | If you have any questions, please contact us: 1585346868@qq.com Or visit our website fwlua.com. 16 | */ 17 | 18 | #include "session.h" 19 | #include "net/http_website.h" 20 | module::session::session(network::http::session* session):m_session(session) 21 | { 22 | } 23 | 24 | module::session::~session() 25 | { 26 | } 27 | 28 | void module::session::init(module::request& request, const std::string& id) 29 | { 30 | if (&request == nullptr) 31 | { 32 | throw ylib::exception("the `request` parameter of the init function is nil"); 33 | } 34 | m_session->init(request.website(), id); 35 | } 36 | 37 | std::string module::session::id() 38 | { 39 | return m_session->id(); 40 | } 41 | 42 | void module::session::update() 43 | { 44 | m_session->update(); 45 | } 46 | 47 | void module::session::set(const std::string& name, const std::string& value) 48 | { 49 | m_session->set(name, value); 50 | } 51 | 52 | std::string module::session::get(const std::string& name) 53 | { 54 | return m_session->get(name); 55 | } 56 | 57 | bool module::session::check() 58 | { 59 | return m_session->check(); 60 | } 61 | 62 | void module::session::regist(sol::state* lua) 63 | { 64 | lua->new_usertype("fw_session", 65 | "check", &module::session::check, 66 | "get", &module::session::get, 67 | "id", &module::session::id, 68 | "set", &module::session::set, 69 | "update", &module::session::update, 70 | "init", &module::session::init 71 | ); 72 | } 73 | -------------------------------------------------------------------------------- /src/module/http/session.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "net/http_request.h" 3 | #include "net/http_session.h" 4 | #include "sol/sol.hpp" 5 | #include "request.h" 6 | namespace module 7 | { 8 | class session 9 | { 10 | public: 11 | session(network::http::session* session); 12 | ~session(); 13 | void init(module::request& request, const std::string& id); 14 | std::string id(); 15 | void update(); 16 | void set(const std::string& name, const std::string& value); 17 | std::string get(const std::string& name); 18 | bool check(); 19 | static void regist(sol::state* lua); 20 | private: 21 | network::http::session* m_session = nullptr; 22 | }; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /src/module/http/subscribe.cpp: -------------------------------------------------------------------------------- 1 | /*Software License 2 | 3 | Copyright(C) 2024[liuyingjie] 4 | License Terms 5 | Usage Rights 6 | 7 | Any individual or entity is free to use, copy, and distribute the binary form of this software without modification to the source code, without the need to disclose the source code. 8 | If the source code is modified, the modifications must be open - sourced under the same license.This means that the modifications must be disclosed and accompanied by a copy of this license. 9 | Future Versions Updates 10 | From this version onwards, all future releases will be governed by the terms of the latest version of the license.This license will automatically be nullified and replaced by the new version. 11 | Users must comply with the terms of the new license issued in future releases. 12 | Liability and Disclaimer 13 | This software is provided “as is”, without any express or implied warranties, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non - infringement.In no event shall the author or copyright holder be liable for any claims, damages, or other liabilities, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software. 14 | Contact Information 15 | If you have any questions, please contact us: 1585346868@qq.com Or visit our website fwlua.com. 16 | */ 17 | 18 | #include "subscribe.h" 19 | #include "core/app.h" 20 | 21 | module::subscribe::subscribe() 22 | { 23 | } 24 | 25 | module::subscribe::~subscribe() 26 | { 27 | } 28 | 29 | bool module::subscribe::add(const std::string& express_string, const std::string& filepath, sol::this_state ts) 30 | { 31 | GET_APP; 32 | return app->subscribe->add(express_string,filepath); 33 | } 34 | 35 | bool module::subscribe::remove(const std::string& express_string, sol::this_state ts) 36 | { 37 | GET_APP; 38 | return app->subscribe->remove(express_string); 39 | } 40 | 41 | bool module::subscribe::exist(const std::string& express_string, sol::this_state ts) 42 | { 43 | GET_APP; 44 | return app->subscribe->exist(express_string); 45 | } 46 | 47 | void module::subscribe::clear(sol::this_state ts) 48 | { 49 | GET_APP; 50 | return app->subscribe->clear(); 51 | } 52 | 53 | void module::subscribe::regist(sol::state* lua) 54 | { 55 | lua->new_usertype("fw_subscribe", 56 | "add", &module::subscribe::add, 57 | "remove", &module::subscribe::remove, 58 | "exist", &module::subscribe::exist, 59 | "clear", &module::subscribe::clear 60 | ); 61 | } 62 | -------------------------------------------------------------------------------- /src/module/http/subscribe.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "net/http_request.h" 3 | #include "net/http_response.h" 4 | #include "sol/sol.hpp" 5 | 6 | namespace module 7 | { 8 | class subscribe 9 | { 10 | public: 11 | subscribe(); 12 | ~subscribe(); 13 | /// 14 | /// 添加 15 | /// 16 | /// 17 | /// 18 | /// 19 | static bool add(const std::string& pattern,const std::string& filepath, sol::this_state ts); 20 | /// 21 | /// 移除 22 | /// 23 | /// 24 | static bool remove(const std::string& pattern, sol::this_state ts); 25 | /// 26 | /// 是否存在 27 | /// 28 | /// 29 | /// 30 | static bool exist(const std::string& pattern, sol::this_state ts); 31 | /// 32 | /// 清空 33 | /// 34 | static void clear(sol::this_state ts); 35 | 36 | static void regist(sol::state* lua); 37 | }; 38 | } 39 | 40 | -------------------------------------------------------------------------------- /src/module/ini.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "sol/sol.hpp" 3 | #include "util/ini.h" 4 | namespace module 5 | { 6 | /// 7 | /// INI配置 8 | /// 9 | class ini { 10 | public: 11 | ini(); 12 | ~ini(); 13 | bool open(const std::string& filepath); 14 | void close(); 15 | std::string read(const std::string& node, const std::string& key, const std::string& default_value) const; 16 | bool write(const std::string& node, const std::string& key, const std::string& value); 17 | bool del(const std::string& node, const std::string& key); 18 | sol::table nodes(sol::this_state s); 19 | sol::table keys(const std::string& node, sol::this_state s); 20 | bool exist_key(const std::string& node, const std::string& key); 21 | bool exist_node(const std::string& node); 22 | sol::table table(sol::this_state s); 23 | 24 | static void regist(sol::state* lua); 25 | private: 26 | ylib::ini m_ini; 27 | }; 28 | 29 | } 30 | 31 | -------------------------------------------------------------------------------- /src/module/mutex.cpp: -------------------------------------------------------------------------------- 1 | /*Software License 2 | 3 | Copyright(C) 2024[liuyingjie] 4 | License Terms 5 | Usage Rights 6 | 7 | Any individual or entity is free to use, copy, and distribute the binary form of this software without modification to the source code, without the need to disclose the source code. 8 | If the source code is modified, the modifications must be open - sourced under the same license.This means that the modifications must be disclosed and accompanied by a copy of this license. 9 | Future Versions Updates 10 | From this version onwards, all future releases will be governed by the terms of the latest version of the license.This license will automatically be nullified and replaced by the new version. 11 | Users must comply with the terms of the new license issued in future releases. 12 | Liability and Disclaimer 13 | This software is provided “as is”, without any express or implied warranties, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non - infringement.In no event shall the author or copyright holder be liable for any claims, damages, or other liabilities, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software. 14 | Contact Information 15 | If you have any questions, please contact us: 1585346868@qq.com Or visit our website fwlua.com. 16 | */ 17 | 18 | #include "mutex.h" 19 | 20 | module::mutex::mutex() 21 | { 22 | } 23 | 24 | module::mutex::~mutex() 25 | { 26 | } 27 | 28 | void module::mutex::lock() 29 | { 30 | m_mutex.lock(); 31 | } 32 | 33 | void module::mutex::unlock() 34 | { 35 | m_mutex.unlock(); 36 | } 37 | 38 | bool module::mutex::try_lock() 39 | { 40 | return m_mutex.try_lock(); 41 | } 42 | 43 | void module::mutex::regist(sol::state* lua) 44 | { 45 | lua->new_usertype("fw_mutex", 46 | "new", sol::constructors(), 47 | "lock", &module::mutex::lock, 48 | "unlock", &module::mutex::unlock, 49 | "try_lock", &module::mutex::try_lock, 50 | "self", &module::mutex::self 51 | ); 52 | } 53 | 54 | void module::mutex::regist_global(const char* name, sol::state* lua) 55 | { 56 | lua->registry()[name] = this; 57 | (*lua)[name] = this; 58 | } 59 | 60 | module::auto_lock::auto_lock(module::mutex& mutex):m_mutex(&mutex) 61 | { 62 | m_mutex->lock(); 63 | } 64 | 65 | module::auto_lock::~auto_lock() 66 | { 67 | m_mutex->unlock(); 68 | } 69 | 70 | void module::auto_lock::regist(sol::state* lua) 71 | { 72 | lua->new_usertype("fw_auto_lock", 73 | "new", sol::constructors() 74 | ); 75 | } 76 | -------------------------------------------------------------------------------- /src/module/mutex.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "sol/sol.hpp" 3 | #include "module/basemodule.h" 4 | #include 5 | namespace module 6 | { 7 | /// 8 | /// 互斥锁 9 | /// 10 | class mutex:public module::base { 11 | public: 12 | mutex(); 13 | ~mutex() override; 14 | /// 15 | /// 加锁 16 | /// 17 | void lock(); 18 | /// 19 | /// 释放锁 20 | /// 21 | void unlock(); 22 | /// 23 | /// 尝试加锁 24 | /// 25 | /// 26 | bool try_lock(); 27 | static void regist(sol::state* lua); 28 | private: 29 | // 通过 imodule 继承 30 | virtual void regist_global(const char* name, sol::state* lua); 31 | virtual void delete_global() { delete this; } 32 | std::mutex m_mutex; 33 | }; 34 | 35 | /// 36 | /// 自动锁 37 | /// 38 | class auto_lock 39 | { 40 | public: 41 | auto_lock(module::mutex& mutex); 42 | ~auto_lock(); 43 | static void regist(sol::state* lua); 44 | private: 45 | module::mutex *m_mutex = nullptr; 46 | }; 47 | } 48 | 49 | -------------------------------------------------------------------------------- /src/module/process.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "sol/sol.hpp" 3 | 4 | namespace module 5 | { 6 | /// 7 | /// 进程 8 | /// 9 | class process{ 10 | public: 11 | /// 12 | /// 创建 13 | /// 14 | /// 15 | /// 16 | /// 17 | /// 18 | /// 19 | /// 0=失败 否则为PID 20 | static size_t create(const std::string & filepath, const std::string & working_directory,sol::table args, bool wait_close, bool show_window); 21 | /// 22 | /// 关闭 23 | /// 24 | /// 25 | /// 26 | static bool destory(size_t pid); 27 | /// 28 | /// 进程列表 29 | /// 30 | /// 31 | /// 32 | static sol::table list(sol::this_state s); 33 | /// 34 | /// 是否存在 35 | /// 36 | /// 37 | /// 38 | static sol::table exist(const std::string& filepath, sol::this_state s); 39 | static bool exist_pid(size_t pid); 40 | /// 41 | /// 取PID路径 42 | /// 43 | /// 44 | /// 45 | static std::string getpath(size_t pid); 46 | 47 | 48 | static void regist(sol::state* lua); 49 | }; 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /src/module/timer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "sol/sol.hpp" 3 | #include "core/structs.h" 4 | #include "util/thread.h" 5 | #include "util/queue.hpp" 6 | #include "module/basemodule.h" 7 | #include 8 | #include 9 | namespace module 10 | { 11 | struct timer_info { 12 | std::string filepath; 13 | std::string name; 14 | std::string funname; 15 | bool loop = false; 16 | timestamp exec_msec = 0; 17 | timestamp msec = 0; 18 | luastate* lua = nullptr; 19 | sol::function function; 20 | }; 21 | /// 22 | /// 定时器 23 | /// 24 | class timer:private ylib::ithread,public module::base { 25 | public: 26 | timer(); 27 | ~timer(); 28 | /// 29 | /// 增加 30 | /// 31 | /// 32 | /// 33 | /// 34 | /// 35 | /// 36 | /// 37 | std::string add(const std::string& name,const std::string& filepath,const std::string& funname,int msec,bool loop, sol::this_state ts); 38 | /// 39 | /// 移除 40 | /// 41 | /// 42 | void remove(const std::string& name, sol::this_state ts); 43 | static void regist(sol::state* lua); 44 | virtual void regist_global(const char* name, sol::state* lua) override; 45 | virtual void delete_global() { delete this; } 46 | private: 47 | 48 | virtual bool run(); 49 | public: 50 | fastweb::app* m_app = nullptr; 51 | std::map m_list; 52 | ylib::queue m_removed; 53 | std::mutex m_mutex; 54 | bool m_insert = false; 55 | }; 56 | 57 | } 58 | 59 | -------------------------------------------------------------------------------- /src/utils/luautils.cpp: -------------------------------------------------------------------------------- 1 | /*Software License 2 | 3 | Copyright(C) 2024[liuyingjie] 4 | License Terms 5 | Usage Rights 6 | 7 | Any individual or entity is free to use, copy, and distribute the binary form of this software without modification to the source code, without the need to disclose the source code. 8 | If the source code is modified, the modifications must be open - sourced under the same license.This means that the modifications must be disclosed and accompanied by a copy of this license. 9 | Future Versions Updates 10 | From this version onwards, all future releases will be governed by the terms of the latest version of the license.This license will automatically be nullified and replaced by the new version. 11 | Users must comply with the terms of the new license issued in future releases. 12 | Liability and Disclaimer 13 | This software is provided “as is”, without any express or implied warranties, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non - infringement.In no event shall the author or copyright holder be liable for any claims, damages, or other liabilities, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software. 14 | Contact Information 15 | If you have any questions, please contact us: 1585346868@qq.com Or visit our website fwlua.com. 16 | */ 17 | 18 | #include "luautils.h" 19 | #include "core/define.h" 20 | #include "core/statemanager.h" -------------------------------------------------------------------------------- /src/utils/luautils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | namespace LuaUtils { 4 | 5 | 6 | } -------------------------------------------------------------------------------- /src/utils/parseconfig.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "util/ini.h" 8 | #include "util/file.h" 9 | #include "util/system.h" 10 | #include "util/strutils.h" 11 | std::vector __extractVariableNames(const std::string& text) 12 | { 13 | std::regex pattern("\\$\\{([^}]+)\\}"); // 使用捕获组提取中间的内容 14 | std::vector results; 15 | // 使用 std::sregex_iterator 迭代所有匹配项 16 | auto begin = std::sregex_iterator(text.begin(), text.end(), pattern); 17 | auto end = std::sregex_iterator(); 18 | for (std::sregex_iterator i = begin; i != end; ++i) { 19 | std::smatch match = *i; 20 | results.push_back(match[1]); // 仅添加捕获组的内容 21 | } 22 | return results; 23 | } 24 | std::tuple parseconfig(ylib::ini &ini,const std::string& ini_filepath) 25 | { 26 | if (ylib::file::exist(ini_filepath) == false) 27 | { 28 | #ifdef FASTWEB_EXE 29 | return std::make_tuple(false,"未找到配置文件: " + ini_filepath); 30 | #else 31 | return std::make_tuple(false,"not found ini: " + ini_filepath); 32 | #endif 33 | } 34 | std::string temp_filepath = ylib::file::temp_filepath() + ".bak"; 35 | if (ylib::file::copy(ini_filepath, temp_filepath) == false) 36 | { 37 | #ifdef FASTWEB_EXE 38 | return std::make_tuple(false,"Failed to copy temporary INI configuration file from '" + ini_filepath + "' to '" + temp_filepath + "'."); 39 | #else 40 | return std::make_tuple(false,"配置文件复制到临时目录失败 from '" + ini_filepath + "' to '" + temp_filepath + "'."); 41 | #endif 42 | } 43 | std::string src_content = ylib::file::read(temp_filepath); 44 | // EXE运行目录 45 | src_content = strutils::replace(src_content, "${current_dir}", strutils::replace(system::current_dir(),'\\','/')); 46 | // 配置文件目录 47 | { 48 | std::string ini_dir = ylib::file::parent_dir(std::filesystem::absolute(ini_filepath).string()); 49 | src_content = strutils::replace(strutils::replace(src_content, "${config_dir}", ini_dir), '\\', '/'); 50 | } 51 | 52 | 53 | 54 | ylib::file::write(temp_filepath,src_content); 55 | if (ini.open(temp_filepath)) 56 | { 57 | auto vars = __extractVariableNames(ylib::file::read(temp_filepath)); 58 | for (size_t i = 0; i < vars.size(); i++) 59 | { 60 | if (ini.read("variable", vars[i]) == "") 61 | { 62 | return std::make_tuple(false,"Variable declaration not found or empty content: ${" + vars[i] + "}"); 63 | } 64 | src_content = strutils::replace(src_content, "${" + vars[i] + "}", ini.read("variable", vars[i])); 65 | } 66 | } 67 | ylib::file::write(temp_filepath,src_content); 68 | ini.close(); 69 | ini.open(temp_filepath); 70 | 71 | return std::make_tuple(true,""); 72 | } 73 | -------------------------------------------------------------------------------- /tests/fastweb.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "base/define.h" 5 | #include "util/ini.h" 6 | #define FASTWEB_VERSION "V1.0.6" 7 | #define FASTWEB_MODULE_JSON_URL "https://download.fwlua.com/module/module.json" 8 | class fastweb 9 | { 10 | public: 11 | fastweb(const std::vector& param); 12 | ~fastweb(); 13 | private: 14 | struct module_info{ 15 | std::string id; 16 | std::string name; 17 | std::string name_en; 18 | std::string doc; 19 | std::string desc; 20 | std::string type; 21 | std::string download_win64; 22 | std::string download_linux_type; 23 | std::string download_linux_url; 24 | }; 25 | private: 26 | /// @brief 启动 27 | /// @param ini_filepath 28 | /// @param wait 29 | void start(std::string ini_filepath); 30 | /// @brief 停止 31 | /// @param app 32 | void stop(void* app); 33 | /// @brief 输出HELP信息 34 | void output_help(); 35 | 36 | /// @brief 创建配置文件 37 | /// @param dirpath 38 | void create_config(std::string dirpath); 39 | /// @brief 创建网站木板 40 | /// @param dirpath 41 | void create_website(std::string dirpath); 42 | /// @brief 安装模块 43 | /// @param ini_filepath 44 | /// @param name 45 | void install_module(std::string ini_filepath,std::string name); 46 | /// @brief 卸载模块 47 | /// @param ini_filepath 48 | /// @param name 49 | void uninstall_module(std::string ini_filepath,std::string name); 50 | 51 | 52 | 53 | 54 | /// @brief 模块列表 55 | void module_list(); 56 | 57 | /// @brief 模块信息 58 | /// @return 59 | bool module_infos(std::vector& list); 60 | 61 | private: 62 | /// @brief 无限等待 63 | void wait(); 64 | #ifndef _WIN32 65 | void install_module_linux(fastweb::module_info info); 66 | #else 67 | void install_module_windows(fastweb::module_info info); 68 | #endif 69 | 70 | 71 | /// @brief 解析INI配置文件 72 | /// @param ini_filepath 73 | bool parse_config(const std::string& ini_filepath); 74 | private: 75 | ylib::ini m_ini; 76 | }; -------------------------------------------------------------------------------- /tests/main.cpp: -------------------------------------------------------------------------------- 1 | /*Software License 2 | 3 | Copyright(C) 2024[liuyingjie] 4 | License Terms 5 | Usage Rights 6 | 7 | Any individual or entity is free to use, copy, and distribute the binary form of this software without modification to the source code, without the need to disclose the source code. 8 | If the source code is modified, the modifications must be open - sourced under the same license.This means that the modifications must be disclosed and accompanied by a copy of this license. 9 | Future Versions Updates 10 | From this version onwards, all future releases will be governed by the terms of the latest version of the license.This license will automatically be nullified and replaced by the new version. 11 | Users must comply with the terms of the new license issued in future releases. 12 | Liability and Disclaimer 13 | This software is provided “as is”, without any express or implied warranties, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non - infringement.In no event shall the author or copyright holder be liable for any claims, damages, or other liabilities, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software. 14 | Contact Information 15 | If you have any questions, please contact us: 1585346868@qq.com Or visit our website fwlua.com. 16 | */ 17 | #include 18 | #include "fastweb.h" 19 | #include "util/window.h" 20 | int main(int argv,char* argc[]) 21 | { 22 | 23 | std::vector param; 24 | for(size_t i=1;i