2026-03-08 20:22:53 +08:00
|
|
|
// The CMLeonOS Project (https://github.com/Leonmmcoset/CMLeonOS)
|
|
|
|
|
// Copyright (C) 2025-present LeonOS 2 Developer Team
|
|
|
|
|
//
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
2026-02-03 02:44:58 +08:00
|
|
|
namespace UniLua
|
|
|
|
|
{
|
|
|
|
|
public static class LuaConf
|
|
|
|
|
{
|
|
|
|
|
public const int LUAI_BITSINT = 32;
|
|
|
|
|
|
|
|
|
|
#pragma warning disable 0429
|
|
|
|
|
public const int LUAI_MAXSTACK = (LUAI_BITSINT >= 32)
|
|
|
|
|
? 1000000
|
|
|
|
|
: 15000
|
|
|
|
|
;
|
|
|
|
|
#pragma warning restore 0429
|
|
|
|
|
|
|
|
|
|
// reserve some space for error handling
|
|
|
|
|
public const int LUAI_FIRSTPSEUDOIDX = (-LUAI_MAXSTACK-1000);
|
|
|
|
|
|
|
|
|
|
public const string LUA_SIGNATURE = "\u001bLua";
|
|
|
|
|
public static string LUA_DIRSEP {
|
|
|
|
|
get { return System.IO.Path.DirectorySeparatorChar.ToString(); }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class LuaLimits
|
|
|
|
|
{
|
|
|
|
|
public const int MAX_INT = System.Int32.MaxValue - 2;
|
|
|
|
|
public const int MAXUPVAL = System.Byte.MaxValue;
|
|
|
|
|
public const int LUAI_MAXCCALLS = 200;
|
|
|
|
|
public const int MAXSTACK = 250;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class LuaDef
|
|
|
|
|
{
|
|
|
|
|
public const int LUA_MINSTACK = 20;
|
|
|
|
|
public const int BASIC_STACK_SIZE = LUA_MINSTACK * 2;
|
|
|
|
|
public const int EXTRA_STACK = 5;
|
|
|
|
|
|
|
|
|
|
public const int LUA_RIDX_MAINTHREAD = 1;
|
|
|
|
|
public const int LUA_RIDX_GLOBALS = 2;
|
|
|
|
|
public const int LUA_RIDX_LAST = LUA_RIDX_GLOBALS;
|
|
|
|
|
|
|
|
|
|
public const int LUA_MULTRET = -1;
|
|
|
|
|
|
|
|
|
|
public const int LUA_REGISTRYINDEX = LuaConf.LUAI_FIRSTPSEUDOIDX;
|
|
|
|
|
|
|
|
|
|
// number of list items accumulate before a SETLIST instruction
|
|
|
|
|
public const int LFIELDS_PER_FLUSH = 50;
|
|
|
|
|
|
|
|
|
|
public const int LUA_IDSIZE = 60;
|
|
|
|
|
|
|
|
|
|
public const string LUA_VERSION_MAJOR = "5";
|
|
|
|
|
public const string LUA_VERSION_MINOR = "2";
|
|
|
|
|
public const string LUA_VERSION = "Lua " + LUA_VERSION_MAJOR + "." + LUA_VERSION_MINOR;
|
|
|
|
|
|
|
|
|
|
public const string LUA_ENV = "_ENV";
|
|
|
|
|
|
|
|
|
|
public const int BASE_CI_SIZE = 8;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class LuaConstants
|
|
|
|
|
{
|
|
|
|
|
public const int LUA_NOREF = -2;
|
|
|
|
|
public const int LUA_REFNIL = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum LuaType
|
|
|
|
|
{
|
|
|
|
|
LUA_TNONE = -1,
|
|
|
|
|
LUA_TNIL = 0,
|
|
|
|
|
LUA_TBOOLEAN = 1,
|
|
|
|
|
LUA_TLIGHTUSERDATA = 2,
|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