我需要使用 Lua 的 Ada 库。我想使用一个通用包,它与其他数据一起将包含一个函数,该函数将根据数据以不同的名称在 Lua 中注册。据我了解,我应该将这个函数声明为“with Export,Convention => C”,但是当实例化这样一个包的几个实例时,库将包含几个具有相同名称的函数并且它不会编译。在这种情况下是否可以不使用“Export”,而只使用“Convention => C”,因为在 Lua 中仅使用函数引用进行注册?
with System; use System;
with Interfaces.C; use Interfaces.C;
generic
type Data is private;
Name : String;
package P is
function Call (Lua : Address) return int
with Export, Convention => C;
function Get_Name return String is (Name);
end P;
Run Code Online (Sandbox Code Playgroud) 我需要制作一个通用包,它的形参应该是访问子程序的类型。这种类型的对象被传递给这个包的子例程,我必须检查它是否为空相等。
generic
type Func_Type is private;
package Gen_Package is
function Check(Func : Func_Type) return Boolean is
(Func = null);
end;
Run Code Online (Sandbox Code Playgroud)
但这不能编译,因为比较的左操作数没有访问类型。
package P is
type T is private;
private
package NP is
type T is null record;
end NP;
end P;
Run Code Online (Sandbox Code Playgroud)
可以使用 NP.T 作为 PT 的完整声明吗?
我创建了一个具有导出和约定方面的通用函数。然后我实例化了这个函数,但它最终在我的库中带有 'r' 后缀。为什么会发生这种情况,我该如何解决?
例如:
generic
I : int;
function Test_Generic return int
with Export => True, Convention => C;
function Test_Generic return int is
begin
return I;
end;
function Test is new Test_Generic (I => 5);
-- In library this function has name testr
Run Code Online (Sandbox Code Playgroud)