From b5d8b912833593ac2c819b35b5b270ddf4660e4b Mon Sep 17 00:00:00 2001 From: PhilippNaused Date: Fri, 16 Jan 2026 20:53:55 +0100 Subject: [PATCH 1/3] update library name --- KeraLua.Symbol.nuspec | 2 +- KeraLua.nuspec | 44 ++++++++++---------- README.md | 2 +- build/Android/KeraLua.Android.csproj | 16 +++---- build/Android/KeraLua.net9.0-android.csproj | 16 +++---- build/TVOS/KeraLua.TVOS.csproj | 2 +- build/TVOS/KeraLua.net9.0-tvos.csproj | 2 +- build/iOS/KeraLua.XamariniOS.csproj | 2 +- build/iOS/KeraLua.net9.0-ios.csproj | 2 +- build/iOS/KeraLua.net9.0-maccatalyst.csproj | 2 +- build/macOS/KeraLua.XamarinMac.csproj | 2 +- build/macOS/KeraLua.net9.0-macos.csproj | 2 +- build/targets/BuildLua.Android.targets | 2 +- build/targets/BuildLua.Linux.targets | 6 +-- build/targets/BuildLua.MacCatalyst.targets | 2 +- build/targets/BuildLua.OSX.targets | 6 +-- build/targets/BuildLua.TVOS.targets | 2 +- build/targets/BuildLua.WatchOS.targets | 2 +- build/targets/BuildLua.Windows.targets | 4 +- build/targets/BuildLua.iOS.targets | 2 +- build/targets/KeraLua.targets | 44 ++++++++++---------- devops/azure-devops.yml | 28 ++++++------- src/NativeMethods.cs | 10 ++--- tests/build/net46/KeraLuaTest.csproj | 14 +++---- tests/build/net9.0/KeraLuaTest.net9.0.csproj | 12 +++--- 25 files changed, 114 insertions(+), 114 deletions(-) diff --git a/KeraLua.Symbol.nuspec b/KeraLua.Symbol.nuspec index 1e96da08..3876f907 100644 --- a/KeraLua.Symbol.nuspec +++ b/KeraLua.Symbol.nuspec @@ -10,7 +10,7 @@ https://raw.githubusercontent.com/nlua/KeraLua/main/KeraLua.png false - C# Native bindings of Lua 5.4 (compatible with iOS/Mac/Android/UWP/.NET) + C# Native bindings of Lua 5.5 (compatible with iOS/Mac/Android/UWP/.NET) Release: 2bffe65 Copyright © Vinicius Jarina 2026 diff --git a/KeraLua.nuspec b/KeraLua.nuspec index 53a75e59..5961b362 100644 --- a/KeraLua.nuspec +++ b/KeraLua.nuspec @@ -10,7 +10,7 @@ https://raw.githubusercontent.com/nlua/KeraLua/main/KeraLua.png false - C# Native bindings of Lua 5.4 (compatible with iOS/Mac/Android/.NET/UWP) + C# Native bindings of Lua 5.5 (compatible with iOS/Mac/Android/.NET/UWP) Release: 2bffe65 Copyright © Vinicius Jarina 2026 @@ -71,27 +71,27 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/README.md b/README.md index e83f906a..55debd9b 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ KeraLua |![win](https://badgen.net/badge/icon/Windows,.NET%20Core?icon=windows&label&list=1) | [![Build Status](https://dev.azure.com/codefoco/NuGets/_apis/build/status/KeraLua?branchName=main&jobName=Windows)](https://dev.azure.com/codefoco/NuGets/_build/latest?definitionId=64&branchName=main) | -C# Native bindings of Lua 5.4 (compatible with iOS/Mac/Android/UWP/.NET) +C# Native bindings of Lua 5.5 (compatible with iOS/Mac/Android/UWP/.NET) Before build fetch the submodules: diff --git a/build/Android/KeraLua.Android.csproj b/build/Android/KeraLua.Android.csproj index 58d6b587..89367ac3 100644 --- a/build/Android/KeraLua.Android.csproj +++ b/build/Android/KeraLua.Android.csproj @@ -48,17 +48,17 @@ - - libs\arm64-v8a\liblua54.so + + libs\arm64-v8a\liblua55.so - - libs\armeabi-v7a\liblua54.so + + libs\armeabi-v7a\liblua55.so - - libs\x86\liblua54.so + + libs\x86\liblua55.so - - libs\x86_64\liblua54.so + + libs\x86_64\liblua55.so diff --git a/build/Android/KeraLua.net9.0-android.csproj b/build/Android/KeraLua.net9.0-android.csproj index 9034e1f2..106b6b5b 100644 --- a/build/Android/KeraLua.net9.0-android.csproj +++ b/build/Android/KeraLua.net9.0-android.csproj @@ -42,17 +42,17 @@ - - libs\arm64-v8a\liblua54.so + + libs\arm64-v8a\liblua55.so - - libs\armeabi-v7a\liblua54.so + + libs\armeabi-v7a\liblua55.so - - libs\x86\liblua54.so + + libs\x86\liblua55.so - - libs\x86_64\liblua54.so + + libs\x86_64\liblua55.so diff --git a/build/TVOS/KeraLua.TVOS.csproj b/build/TVOS/KeraLua.TVOS.csproj index 6cc7115d..76f27d67 100644 --- a/build/TVOS/KeraLua.TVOS.csproj +++ b/build/TVOS/KeraLua.TVOS.csproj @@ -52,7 +52,7 @@ - + Framework diff --git a/build/TVOS/KeraLua.net9.0-tvos.csproj b/build/TVOS/KeraLua.net9.0-tvos.csproj index f429b758..0ac4f46e 100644 --- a/build/TVOS/KeraLua.net9.0-tvos.csproj +++ b/build/TVOS/KeraLua.net9.0-tvos.csproj @@ -47,7 +47,7 @@ - + Framework diff --git a/build/iOS/KeraLua.XamariniOS.csproj b/build/iOS/KeraLua.XamariniOS.csproj index 38bc8ef9..b552d5fa 100644 --- a/build/iOS/KeraLua.XamariniOS.csproj +++ b/build/iOS/KeraLua.XamariniOS.csproj @@ -42,7 +42,7 @@ - + Framework diff --git a/build/iOS/KeraLua.net9.0-ios.csproj b/build/iOS/KeraLua.net9.0-ios.csproj index 6ec0578b..94558ffa 100644 --- a/build/iOS/KeraLua.net9.0-ios.csproj +++ b/build/iOS/KeraLua.net9.0-ios.csproj @@ -38,7 +38,7 @@ - + Framework diff --git a/build/iOS/KeraLua.net9.0-maccatalyst.csproj b/build/iOS/KeraLua.net9.0-maccatalyst.csproj index 417295f3..6ffffa71 100644 --- a/build/iOS/KeraLua.net9.0-maccatalyst.csproj +++ b/build/iOS/KeraLua.net9.0-maccatalyst.csproj @@ -38,7 +38,7 @@ - + Framework diff --git a/build/macOS/KeraLua.XamarinMac.csproj b/build/macOS/KeraLua.XamarinMac.csproj index e8365448..850a5798 100644 --- a/build/macOS/KeraLua.XamarinMac.csproj +++ b/build/macOS/KeraLua.XamarinMac.csproj @@ -41,7 +41,7 @@ - + Dynamic False diff --git a/build/macOS/KeraLua.net9.0-macos.csproj b/build/macOS/KeraLua.net9.0-macos.csproj index 36b0a8db..999909ef 100644 --- a/build/macOS/KeraLua.net9.0-macos.csproj +++ b/build/macOS/KeraLua.net9.0-macos.csproj @@ -39,7 +39,7 @@ - + Dynamic False diff --git a/build/targets/BuildLua.Android.targets b/build/targets/BuildLua.Android.targets index c11687bd..8a387b1c 100644 --- a/build/targets/BuildLua.Android.targets +++ b/build/targets/BuildLua.Android.targets @@ -3,7 +3,7 @@ android_build android - liblua54.so + liblua55.so arm arm64 x86 diff --git a/build/targets/BuildLua.Linux.targets b/build/targets/BuildLua.Linux.targets index 669cfcbf..fb91d92f 100644 --- a/build/targets/BuildLua.Linux.targets +++ b/build/targets/BuildLua.Linux.targets @@ -3,9 +3,9 @@ linux-x64 linux-arm64 - lib64/liblua54.so - $(OutputRuntimeDir)\$(LinuxAMD64BuildDir)\native\liblua54.so - $(OutputRuntimeDir)\$(LinuxARM64BuildDir)\native\liblua54.so + lib64/liblua55.so + $(OutputRuntimeDir)\$(LinuxAMD64BuildDir)\native\liblua55.so + $(OutputRuntimeDir)\$(LinuxARM64BuildDir)\native\liblua55.so diff --git a/build/targets/BuildLua.MacCatalyst.targets b/build/targets/BuildLua.MacCatalyst.targets index 263cee28..8a9ed057 100644 --- a/build/targets/BuildLua.MacCatalyst.targets +++ b/build/targets/BuildLua.MacCatalyst.targets @@ -3,7 +3,7 @@ ios_build maccatalyst - liblua54.framework + liblua55.framework diff --git a/build/targets/BuildLua.OSX.targets b/build/targets/BuildLua.OSX.targets index 84e51f21..2d77608a 100644 --- a/build/targets/BuildLua.OSX.targets +++ b/build/targets/BuildLua.OSX.targets @@ -5,9 +5,9 @@ osx-64 osx-arm64 osx - lib64/liblua54.dylib - lib/liblua54.dylib - liblua54.dylib + lib64/liblua55.dylib + lib/liblua55.dylib + liblua55.dylib 10 12.2 diff --git a/build/targets/BuildLua.TVOS.targets b/build/targets/BuildLua.TVOS.targets index 4d3ead1b..b7f3a49c 100644 --- a/build/targets/BuildLua.TVOS.targets +++ b/build/targets/BuildLua.TVOS.targets @@ -3,7 +3,7 @@ ios_build tvos - liblua54.framework + liblua55.framework diff --git a/build/targets/BuildLua.WatchOS.targets b/build/targets/BuildLua.WatchOS.targets index 89544671..56e3a39c 100644 --- a/build/targets/BuildLua.WatchOS.targets +++ b/build/targets/BuildLua.WatchOS.targets @@ -3,7 +3,7 @@ ios_build watchos - liblua54.framework + liblua55.framework diff --git a/build/targets/BuildLua.Windows.targets b/build/targets/BuildLua.Windows.targets index a57ac366..217a5b35 100644 --- a/build/targets/BuildLua.Windows.targets +++ b/build/targets/BuildLua.Windows.targets @@ -5,8 +5,8 @@ win-x64 win-arm64 win-arm - bin\lua54.dll - bin64\lua54.dll + bin\lua55.dll + bin64\lua55.dll diff --git a/build/targets/BuildLua.iOS.targets b/build/targets/BuildLua.iOS.targets index e3ff3793..dd81f3d6 100644 --- a/build/targets/BuildLua.iOS.targets +++ b/build/targets/BuildLua.iOS.targets @@ -3,7 +3,7 @@ ios_build ios - liblua54.framework + liblua55.framework diff --git a/build/targets/KeraLua.targets b/build/targets/KeraLua.targets index afdddabb..f238e6f8 100644 --- a/build/targets/KeraLua.targets +++ b/build/targets/KeraLua.targets @@ -2,7 +2,7 @@ - + True @@ -31,9 +31,9 @@ - $(MSBuildThisFileDirectory)..\..\runtimes\win-$(PreferredNativeLua)\native\lua54.dll - $(MSBuildThisFileDirectory)..\..\runtimes\osx\native\liblua54.dylib - $(MSBuildThisFileDirectory)..\..\runtimes\linux-$(PreferredNativeLua)\native\liblua54.so + $(MSBuildThisFileDirectory)..\..\runtimes\win-$(PreferredNativeLua)\native\lua55.dll + $(MSBuildThisFileDirectory)..\..\runtimes\osx\native\liblua55.dylib + $(MSBuildThisFileDirectory)..\..\runtimes\linux-$(PreferredNativeLua)\native\liblua55.so @@ -54,35 +54,35 @@ - - x86\lua54.dll + + x86\lua55.dll PreserveNewest - - x64\lua54.dll + + x64\lua55.dll PreserveNewest - - ARM64\lua54.dll + + ARM64\lua55.dll PreserveNewest - - x86\liblua54.so + + x86\liblua55.so PreserveNewest - - x64\liblua54.so + + x64\liblua55.so PreserveNewest - - ARM64\liblua54.so + + ARM64\liblua55.so PreserveNewest diff --git a/devops/azure-devops.yml b/devops/azure-devops.yml index a349e464..ad2d1053 100644 --- a/devops/azure-devops.yml +++ b/devops/azure-devops.yml @@ -171,11 +171,11 @@ stages: workingDirectory: ./external/lua displayName: 'Build x64 Lua based on Ubuntu 18' - - script: 'mv ./external/lua/out-arm64/liblua54.so ./runtimes/linux-arm64/native/liblua54.so' - displayName: 'Move arm64 liblua54.so' + - script: 'mv ./external/lua/out-arm64/liblua55.so ./runtimes/linux-arm64/native/liblua55.so' + displayName: 'Move arm64 liblua55.so' - - script: 'mv ./external/lua/out-x64/liblua54.so ./runtimes/linux-x64/native/liblua54.so' - displayName: 'Move x64 liblua54.so' + - script: 'mv ./external/lua/out-x64/liblua55.so ./runtimes/linux-x64/native/liblua55.so' + displayName: 'Move x64 liblua55.so' - task: MSBuild@1 displayName: 'Build solution KeraLua.sln' @@ -184,17 +184,17 @@ stages: configuration: Release - task: PublishPipelineArtifact@1 - displayName: 'Publish Pipeline Artifact: liblua54.so' + displayName: 'Publish Pipeline Artifact: liblua55.so' inputs: - targetPath: 'runtimes/linux-x64/native/liblua54.so' - artifact: 'liblua54.so.x64' + targetPath: 'runtimes/linux-x64/native/liblua55.so' + artifact: 'liblua55.so.x64' publishLocation: 'pipeline' - task: PublishPipelineArtifact@1 - displayName: 'Publish Pipeline Artifact: liblua54.so' + displayName: 'Publish Pipeline Artifact: liblua55.so' inputs: - targetPath: 'runtimes/linux-arm64/native/liblua54.so' - artifact: 'liblua54.so.arm64' + targetPath: 'runtimes/linux-arm64/native/liblua55.so' + artifact: 'liblua55.so.arm64' publishLocation: 'pipeline' - template: send-telegram.yml@templates @@ -354,17 +354,17 @@ stages: targetPath: './runtimes/' - task: DownloadPipelineArtifact@2 - displayName: 'Download Build liblua54.so x64 (Linux)' + displayName: 'Download Build liblua55.so x64 (Linux)' inputs: buildType: 'current' - artifactName: 'liblua54.so.x64' + artifactName: 'liblua55.so.x64' targetPath: 'runtimes/linux-x64/native/' - task: DownloadPipelineArtifact@2 - displayName: 'Download Build liblua54.so arm64 (Linux)' + displayName: 'Download Build liblua55.so arm64 (Linux)' inputs: buildType: 'current' - artifactName: 'liblua54.so.arm64' + artifactName: 'liblua55.so.arm64' targetPath: 'runtimes/linux-arm64/native/' - script: 'nuget setapikey $(apikey)' diff --git a/src/NativeMethods.cs b/src/NativeMethods.cs index dc7316e7..f4e9f7f2 100644 --- a/src/NativeMethods.cs +++ b/src/NativeMethods.cs @@ -24,15 +24,15 @@ namespace KeraLua internal static class NativeMethods { #if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__ - private const string LuaLibraryName = "@rpath/liblua54.framework/liblua54"; + private const string LuaLibraryName = "@rpath/liblua55.framework/liblua55"; #elif __ANDROID__ - private const string LuaLibraryName = "liblua54.so"; + private const string LuaLibraryName = "liblua55.so"; #elif __MACOS__ - private const string LuaLibraryName = "liblua54.dylib"; + private const string LuaLibraryName = "liblua55.dylib"; #elif WINDOWS_UWP - private const string LuaLibraryName = "lua54.dll"; + private const string LuaLibraryName = "lua55.dll"; #else - private const string LuaLibraryName = "lua54"; + private const string LuaLibraryName = "lua55"; #endif #pragma warning disable IDE1006 // Naming Styles diff --git a/tests/build/net46/KeraLuaTest.csproj b/tests/build/net46/KeraLuaTest.csproj index 281e9b06..addae5f5 100644 --- a/tests/build/net46/KeraLuaTest.csproj +++ b/tests/build/net46/KeraLuaTest.csproj @@ -1,4 +1,4 @@ - + @@ -98,16 +98,16 @@ - - lua54.dll + + lua55.dll PreserveNewest - - liblua54.dylib + + liblua55.dylib PreserveNewest - - liblua54.so + + liblua55.so PreserveNewest diff --git a/tests/build/net9.0/KeraLuaTest.net9.0.csproj b/tests/build/net9.0/KeraLuaTest.net9.0.csproj index 6b08197e..df56c600 100644 --- a/tests/build/net9.0/KeraLuaTest.net9.0.csproj +++ b/tests/build/net9.0/KeraLuaTest.net9.0.csproj @@ -76,16 +76,16 @@ - - lua54.dll + + lua55.dll PreserveNewest - - liblua54.dylib + + liblua55.dylib PreserveNewest - - liblua54.so + + liblua55.so PreserveNewest From b22554f30362aaa56cd56b4e1527d193b6339407 Mon Sep 17 00:00:00 2001 From: PhilippNaused Date: Fri, 16 Jan 2026 22:40:06 +0100 Subject: [PATCH 2/3] Update API for 5.5 --- src/KeraLua.Core.projitems | 55 +++++++++++++++++----------------- src/Lua.cs | 41 ++++++++++++++++++++------ src/LuaDebug.cs | 8 +++-- src/LuaGC.cs | 49 +++++++++++++++++++++++-------- src/LuaLibrary.cs | 60 ++++++++++++++++++++++++++++++++++++++ src/LuaRegistry.cs | 15 +++++----- src/Names.txt | 7 ++++- src/NativeMethods.cs | 22 ++++++++++---- 8 files changed, 194 insertions(+), 63 deletions(-) create mode 100644 src/LuaLibrary.cs diff --git a/src/KeraLua.Core.projitems b/src/KeraLua.Core.projitems index 04de032b..bce3ccd2 100644 --- a/src/KeraLua.Core.projitems +++ b/src/KeraLua.Core.projitems @@ -1,28 +1,29 @@ - - - - $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - true - {BD205AD6-760E-48F3-BAB2-21447396BD17} - - - KeraLua - - - - - - - - - - - - - - - - - - + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + {BD205AD6-760E-48F3-BAB2-21447396BD17} + + + KeraLua + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Lua.cs b/src/Lua.cs index ef75c3aa..788591e5 100644 --- a/src/Lua.cs +++ b/src/Lua.cs @@ -44,7 +44,9 @@ public Lua(bool openLibs = true) { Encoding = Encoding.ASCII; - _luaState = NativeMethods.luaL_newstate(); + _luaState = NativeMethods.luaL_newstate(); + if (_luaState == IntPtr.Zero) + throw new OutOfMemoryException("Could not allocate memory for new Lua state"); if (openLibs) OpenLibs(); @@ -55,15 +57,20 @@ public Lua(bool openLibs = true) /// /// Initialize Lua state with allocator function and user data value /// This method will NOT open the default libs. - /// Creates a new thread running in a new, independent state. Returns NULL if it cannot create the thread or the state (due to lack of memory). The argument f is the allocator function; Lua does all memory allocation for this state through this function (see lua_Alloc). The second argument, ud, is an opaque pointer that Lua passes to the allocator in every call. + /// Creates a new thread running in a new, independent state. Returns NULL if it cannot create the thread or the state (due to lack of memory). The argument is the allocator function; Lua does all memory allocation for this state through this function (see ). + /// The second argument, , is an opaque pointer that Lua passes to the allocator in every call. + /// The third argument, , is a seed for the hashing of strings. /// /// LuaAlloc allocator function called to alloc/free memory /// opaque pointer passed to allocator - public Lua(LuaAlloc allocator, IntPtr ud) + /// seed for the hashing of strings + public Lua(LuaAlloc allocator, IntPtr ud, uint seed) { Encoding = Encoding.ASCII; - _luaState = NativeMethods.lua_newstate(allocator.ToFunctionPointer(), ud); + _luaState = NativeMethods.lua_newstate(allocator.ToFunctionPointer(), ud, seed); + if (_luaState == IntPtr.Zero) + throw new OutOfMemoryException("Could not allocate memory for new Lua state"); SetExtraObject(this, true); } @@ -1126,7 +1133,7 @@ public LuaStatus Resume(Lua from, int arguments) /// public int ResetThread() { - return NativeMethods.lua_resetthread(_luaState); + return NativeMethods.lua_closethread(_luaState, IntPtr.Zero); } /// @@ -1579,7 +1586,7 @@ public void UpValueJoin(int functionIndex1, int n1, int functionIndex2, int n2) } /// - /// Return the version of Lua (e.g 504) + /// Return the version of Lua (e.g 505) /// /// public double Version() @@ -2006,11 +2013,26 @@ public bool NewMetaTable(string name) } /// - /// Opens all standard Lua libraries into the given state. + /// Opens (loads) and preloads selected standard libraries into the state. + /// + /// Libraries to load + /// Libraries to preload + /// + /// To preload means to add the library loader into the table package.preload, so that the library can be required later by the program. + /// Keep in mind that require itself is provided by the package library. + /// If a program does not load that library, it will be unable to require anything. + /// + public void OpenSelectedLibs(LuaLibrary load, LuaLibrary preload) + { + NativeMethods.luaL_openselectedlibs(_luaState, load, preload); + } + + /// + /// Opens all standard Lua libraries into the given state. /// public void OpenLibs() { - NativeMethods.luaL_openlibs(_luaState); + OpenSelectedLibs(LuaLibrary.All, LuaLibrary.None); } /// @@ -2025,7 +2047,8 @@ public long OptInteger(int argument, long d) } /// - /// If the function argument arg is a string, returns this string. If this argument is absent or is nil, returns d /// + /// If the function argument arg is a string, returns this string. If this argument is absent or is nil, returns d + /// /// /// /// diff --git a/src/LuaDebug.cs b/src/LuaDebug.cs index 2cd6de43..d5cb3559 100644 --- a/src/LuaDebug.cs +++ b/src/LuaDebug.cs @@ -81,6 +81,10 @@ public static LuaDebug FromIntPtr(IntPtr ar) /// [MarshalAs(UnmanagedType.I1)] public bool IsVarArg; /* (u) */ + /// + /// number of extra arguments + /// + public byte NumberExtraArguments; /// /// true if this function invocation was called by a tail call. In this case, the caller of this level is not in the stack. /// @@ -90,12 +94,12 @@ public static LuaDebug FromIntPtr(IntPtr ar) /// /// The index on the stack of the first value being "transferred", that is, parameters in a call or return values in a return. (The other values are in consecutive indices.) Using this index, you can access and modify these values through lua_getlocal and lua_setlocal. This field is only meaningful during a call hook, denoting the first parameter, or a return hook, denoting the first value being returned. (For call hooks, this value is always 1.) /// - public ushort IndexFirstValue; /* (r) index of first value transferred */ + public int IndexFirstValue; /* (r) index of first value transferred */ /// /// The number of values being transferred (see previous item). (For calls of Lua functions, this value is always equal to nparams.) /// - public ushort NumberTransferredValues; /* (r) number of transferred values */ + public int NumberTransferredValues; /* (r) number of transferred values */ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 60)] byte[] shortSource; diff --git a/src/LuaGC.cs b/src/LuaGC.cs index ef3a899c..c5b1729e 100644 --- a/src/LuaGC.cs +++ b/src/LuaGC.cs @@ -34,26 +34,51 @@ public enum LuaGC /// Step = 5, /// - /// The options LUA_GCSETPAUSE and LUA_GCSETSTEPMUL of the function lua_gc are deprecated. You should use the new option LUA_GCINC to set them. + /// returns a boolean that tells whether the collector is running /// - [Obsolete("Deprecatad since Lua 5.4, Use Incremental instead")] - SetPause = 6, + IsRunning = 6, /// - /// The options LUA_GCSETPAUSE and LUA_GCSETSTEPMUL of the function lua_gc are deprecated. You should use the new option LUA_GCINC to set them. + /// Changes the collector to generational mode with the given parameters (see §2.5.2). Returns the previous mode (LUA_GCGEN or LUA_GCINC). /// - [Obsolete("Deprecatad since Lua 5.4, Use Incremental instead")] - SetStepMultiplier = 7, + Generational = 7, /// - /// returns a boolean that tells whether the collector is running + /// Changes the collector to incremental mode with the given parameters (see §2.5.1). Returns the previous mode (LUA_GCGEN or LUA_GCINC). /// - IsRunning = 9, + Incremental = 8, /// - /// Changes the collector to generational mode with the given parameters (see §2.5.2). Returns the previous mode (LUA_GCGEN or LUA_GCINC). + /// Changes and/or returns the value of a parameter of the collector. /// - Generational = 10, + Parameter = 9, + } + + /// + /// Garbage Collector operations for use with + /// + public enum LuaGCParameter + { /// - /// Changes the collector to incremental mode with the given parameters (see §2.5.1). Returns the previous mode (LUA_GCGEN or LUA_GCINC). + /// The minor multiplier. + /// + MinorMultiplier = 0, + /// + /// The major-minor multiplier. + /// + MajorMinorMultiplier = 1, + /// + /// The minor-major multiplier. + /// + MinorMajorMultiplier = 2, + /// + /// The garbage-collector pause. + /// + Pause = 3, + /// + /// The step multiplier. + /// + StepMultiplier = 4, + /// + /// The step size. /// - Incremental = 11, + StepSize = 5, } } diff --git a/src/LuaLibrary.cs b/src/LuaLibrary.cs new file mode 100644 index 00000000..7d25d1d0 --- /dev/null +++ b/src/LuaLibrary.cs @@ -0,0 +1,60 @@ +using System; + +namespace KeraLua +{ + /// + /// The lua standard libraries + /// + [Flags] + public enum LuaLibrary + { + /// + /// no library. + /// + None = 0, + /// + /// the basic library. + /// + Basic = 1, + /// + /// the package library. + /// + Package = Basic << 1, + /// + /// the coroutine library. + /// + Coroutine = Package << 1, + /// + /// the string library. + /// + String = Os << 1, + /// + /// the UTF-8 library. + /// + Utf8 = Table << 1, + /// + /// the table library. + /// + Table = String << 1, + /// + /// the mathematical library. + /// + Math = Io << 1, + /// + /// the I/O library. + /// + Io = Debug << 1, + /// + /// the operating system library. + /// + Os = Math << 1, + /// + /// the debug library. + /// + Debug = Coroutine << 1, + /// + /// all libraries. + /// + All = ~None, + } +} diff --git a/src/LuaRegistry.cs b/src/LuaRegistry.cs index 16bf4f2a..474702f1 100644 --- a/src/LuaRegistry.cs +++ b/src/LuaRegistry.cs @@ -7,11 +7,10 @@ public enum LuaRegistry #pragma warning restore CA1008 // Enums should have zero value { - /* LUAI_MAXSTACK 1000000 */ /// - /// pseudo-index used by registry table + /// pseudo-index used by registry table: -1073742823 /// - Index = -1000000 - 1000 + Index = -(int.MaxValue / 2 + 1000) } /// @@ -21,13 +20,15 @@ public enum LuaRegistry public enum LuaRegistryIndex #pragma warning restore CA1008 // Enums should have zero value { - /// - /// At this index the registry has the main thread of the state. - /// - MainThread = 1, + /* index 1 is reserved for the reference mechanism */ + /// /// At this index the registry has the global environment. /// Globals = 2, + /// + /// At this index the registry has the main thread of the state. + /// + MainThread = 3 } } diff --git a/src/Names.txt b/src/Names.txt index b084294e..ed0becb2 100644 --- a/src/Names.txt +++ b/src/Names.txt @@ -16,6 +16,7 @@ luaL_checkudata luaL_checkversion_ luaL_error luaL_execresult +luaL_alloc luaL_fileresult luaL_getmetafield luaL_getsubtable @@ -26,7 +27,8 @@ luaL_loadfilex luaL_loadstring luaL_newmetatable luaL_newstate -luaL_openlibs +luaL_makeseed +luaL_openselectedlibs luaL_optinteger luaL_optlstring luaL_optnumber @@ -80,6 +82,7 @@ lua_len lua_load lua_newstate lua_newthread +lua_closethread lua_newuserdata lua_next lua_pcallk @@ -89,6 +92,7 @@ lua_pushfstring lua_pushinteger lua_pushlightuserdata lua_pushlstring +lua_pushexternalstring lua_pushnil lua_pushnumber lua_pushstring @@ -117,6 +121,7 @@ lua_settop lua_setupvalue lua_setuservalue lua_status +lua_numbertocstring lua_stringtonumber lua_toboolean lua_tocfunction diff --git a/src/NativeMethods.cs b/src/NativeMethods.cs index f4e9f7f2..aecd2a7a 100644 --- a/src/NativeMethods.cs +++ b/src/NativeMethods.cs @@ -155,11 +155,14 @@ internal static extern int lua_load string mode); [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)] - internal static extern lua_State lua_newstate(lua_Alloc allocFunction, voidptr_t ud); + internal static extern lua_State lua_newstate(lua_Alloc allocFunction, voidptr_t ud, uint seed); [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)] internal static extern lua_State lua_newthread(lua_State luaState); + [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lua_closethread(lua_State luaState, lua_State from); + [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)] internal static extern voidptr_t lua_newuserdatauv(lua_State luaState, size_t size, int nuvalue); @@ -190,6 +193,9 @@ internal static extern int lua_pcallk [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)] internal static extern charptr_t lua_pushlstring(lua_State luaState, byte[] s, size_t len); + [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern charptr_t lua_pushexternalstring(lua_State luaState, byte[] s, size_t len, lua_Alloc falloc, voidptr_t ud); + [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)] internal static extern void lua_pushnil(lua_State luaState); @@ -226,9 +232,6 @@ internal static extern int lua_pcallk [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)] internal static extern void lua_rawsetp(lua_State luaState, int index, voidptr_t p); - [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)] - internal static extern int lua_resetthread(lua_State luaState); - [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)] internal static extern int lua_resume(lua_State luaState, lua_State from, int nargs, out int results); @@ -274,6 +277,9 @@ internal static extern int lua_pcallk [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)] internal static extern int lua_status(lua_State luaState); + [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern uint lua_numbertocstring(lua_State luaState, int idx, byte[] buff); + [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] internal static extern size_t lua_stringtonumber(lua_State luaState, string s); @@ -370,6 +376,9 @@ internal static extern int lua_yieldk(lua_State luaState, [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)] internal static extern int luaL_execresult(lua_State luaState, int stat); + [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern voidptr_t luaL_alloc(voidptr_t ud, voidptr_t ptr, size_t osize, size_t nsize); + [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] internal static extern int luaL_fileresult(lua_State luaState, int stat, string fileName); @@ -400,7 +409,10 @@ internal static extern int luaL_loadbufferx internal static extern lua_State luaL_newstate(); [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)] - internal static extern void luaL_openlibs(lua_State luaState); + internal static extern uint luaL_makeseed(lua_State luaState); + + [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)] + internal static extern void luaL_openselectedlibs(lua_State luaState, LuaLibrary load, LuaLibrary preload); [DllImport(LuaLibraryName, CallingConvention = CallingConvention.Cdecl)] internal static extern lua_Integer luaL_optinteger(lua_State luaState, int arg, lua_Integer d); From 4977b88bca727b40515ffa491c3e9f0e70332232 Mon Sep 17 00:00:00 2001 From: PhilippNaused Date: Mon, 19 Jan 2026 08:46:03 +0100 Subject: [PATCH 3/3] Update lua --- external/lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/lua b/external/lua index d15dde2d..758695c8 160000 --- a/external/lua +++ b/external/lua @@ -1 +1 @@ -Subproject commit d15dde2db368f9a077842f892e85b6b759553b21 +Subproject commit 758695c84b8ce7da94eb0e540107fb58ff0833e9