Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/actions/dotnet/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ runs:
- name: Build
run: dotnet build $Env:SOLUTION_PATH -c Release --no-restore -p:NoWarn=1591
shell: pwsh
# - name: Test
# run: dotnet test $Env:SOLUTION_PATH --no-restore --verbosity minimal
# shell: pwsh
- name: Test
run: dotnet test $Env:SOLUTION_PATH --no-restore --verbosity minimal
shell: pwsh
- name: Pack
run: |
Invoke-Expression "dotnet pack $Env:SOLUTION_PATH -c Release -o ./artifacts --no-restore --no-build $($Env:VERSION_SUFFIX ? "--version-suffix=$Env:VERSION_SUFFIX" : $null)"
Expand Down
9 changes: 3 additions & 6 deletions src/Laylua.Playground/Laylua.Playground.csproj
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../Laylua.targets"/>
<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFramework>net8.0</TargetFramework>

<OutputType>Exe</OutputType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPackable>false</IsPackable>
<RootNamespace>Laylua.Console</RootNamespace>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Laylua\Laylua.csproj"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Laylua.Natives" Version="1.0.0-alpha.1" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
</ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/Laylua.Tests/Laylua.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Laylua.Natives" Version="1.0.0-alpha.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
Expand Down
11 changes: 11 additions & 0 deletions src/Laylua.Tests/Tests/Moon/ErrorHandlingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,15 @@ public void LuaError_LuaFunction_ProtectedLongJmp_GetsCaughtWithLuaException()
// Act & Assert
Assert.Throws<LuaException>(() => function.Call());
}

[Test]
public void LuaError_NestedLuaFunction_ProtectedLongJmp_GetsCaughtWithLuaException()
{
// Arrange
Lua.SetGlobal("print", (Action<int>) Console.WriteLine);
Lua.SetGlobal("func", (string code) => Lua.Execute(code));

// Act & Assert
Assert.Throws<LuaException>(() => Lua.Execute(@"print(func('print(\'abc\')'))"));
}
}
1 change: 1 addition & 0 deletions src/Laylua/Laylua.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<!-- </PropertyGroup>-->

<ItemGroup>
<PackageReference Include="Laylua.Natives" Version="1.0.0-alpha.1" PrivateAssets="analyzers;build" />
<PackageReference Include="Qommon" Version="4.0.1"/>
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ public static IntPtr CreateLuaHookFunctionWrapper(LuaHookFunction function)
return asmPtr;
}


[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Span<byte> AllocFunctionWrapperAsm(out IntPtr asmPtr)
{
Expand All @@ -272,7 +271,9 @@ private static void WriteFunctionWrapperPointers(Span<byte> asmSpan,
#endif
)
{
// var functionPtr = Marshal.GetFunctionPointerForDelegate(function);
#if TRACE_PANIC
var functionPtr = Marshal.GetFunctionPointerForDelegate(function);
#endif
var functionWrapperPtr = Marshal.GetFunctionPointerForDelegate(functionWrapper);

// MemoryMarshal.Write(asmSpan.Slice(21), ref functionPtr);
Expand Down
4 changes: 3 additions & 1 deletion src/Laylua/Moon/Native/Laylua/LayluaNative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ internal static void ThrowPanicException(lua_State* L)

private static void InitializePanicHooks()
{
var libraryHandle = NativeLibrary.Load("lua54", typeof(LayluaNative).Assembly, null);

static IntPtr PrepareHookAsm(IntPtr export, IntPtr throwPanicExceptionPtr)
{
delegate* unmanaged[Cdecl]<lua_State*, void*, void*> mPtrDel = &SetPanicJump;
Expand Down Expand Up @@ -263,7 +265,7 @@ static IntPtr PrepareHookAsm(IntPtr export, IntPtr throwPanicExceptionPtr)
if (delegateType == null)
throw new InvalidOperationException($"No matching panic delegate '{delegateName}' found.");

if (!NativeLibrary.TryGetExport(NativeLibrary.Load(OperatingSystem.IsWindows() ? "lua54" : "liblua54.so"), exportName, out var exportPtr))
if (!NativeLibrary.TryGetExport(libraryHandle, exportName, out var exportPtr))
{
if (method.GetCustomAttribute<OptionalExportAttribute>() == null)
throw new InvalidOperationException($"No export '{exportName}' found.");
Expand Down
7 changes: 7 additions & 0 deletions src/nuget.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="quahu" value="https://www.myget.org/F/quahu/api/v3/index.json" />
</packageSources>
</configuration>