mirror of
https://gitcode.com/JianFeeeee/LuaCangjia_api.git
synced 2026-09-20 08:58:13 +00:00
feat: typed interop 原始类型直通映射 (Int64/Float64/Bool)
- C++ 层: callfunction_int/num/bool/void + run_int/num/bool/void - 新增 capture_result()/finish_call() 正确计算 lua_pcall 实际返回值数量, 修复无返回值场景下误读栈残留的问题 - C FFI 层: 11 个新导出函数 + lua_runner 结构体 tresult_* 镜像字段 - 仓颉层: callFunctionInt/Num/Bool, runScriptInt/Num/Bool, resultType() 带严格类型校验(不匹配抛 LUAERR_RESULT_TYPE) - 大整数跨 2^53 保真(字符串路径做不到) - 管道模式语义保留给字符串 API; typed run_* 为独立调用保持栈清洁 - GTest 新增 10 个 typed 测试用例(共 44 个全部通过) - 独立程序验证仓颉层运行时正确性(int/num/bool直通/大整数保真/错误路径)
This commit is contained in:
5
test/scripts/func_typed_add.lua
Normal file
5
test/scripts/func_typed_add.lua
Normal file
@ -0,0 +1,5 @@
|
||||
-- 支持 typed 参数的加法函数(整数版)
|
||||
-- 调用方传入一个整数,返回它加 1
|
||||
return function(n)
|
||||
return n + 1
|
||||
end
|
||||
4
test/scripts/func_typed_echo.lua
Normal file
4
test/scripts/func_typed_echo.lua
Normal file
@ -0,0 +1,4 @@
|
||||
-- 回声函数:返回传入的参数本身(保留类型)
|
||||
return function(x)
|
||||
return x
|
||||
end
|
||||
4
test/scripts/func_typed_mul.lua
Normal file
4
test/scripts/func_typed_mul.lua
Normal file
@ -0,0 +1,4 @@
|
||||
-- 支持 typed 参数的乘法函数(浮点数版)
|
||||
return function(n)
|
||||
return n * 2.5
|
||||
end
|
||||
4
test/scripts/func_typed_nil.lua
Normal file
4
test/scripts/func_typed_nil.lua
Normal file
@ -0,0 +1,4 @@
|
||||
-- 返回 nil 的函数
|
||||
return function()
|
||||
return nil
|
||||
end
|
||||
4
test/scripts/func_typed_not.lua
Normal file
4
test/scripts/func_typed_not.lua
Normal file
@ -0,0 +1,4 @@
|
||||
-- 逻辑非函数(布尔版)
|
||||
return function(b)
|
||||
return not b
|
||||
end
|
||||
4
test/scripts/func_typed_void.lua
Normal file
4
test/scripts/func_typed_void.lua
Normal file
@ -0,0 +1,4 @@
|
||||
-- 无参函数:返回常量整数
|
||||
return function()
|
||||
return 42
|
||||
end
|
||||
Reference in New Issue
Block a user