这是如何在 vapi 文件中编写 void 指针类型定义的后续问题?
我现在有四个几乎相同的 es,它们代表使用 unixODBCs函数[Compact] class分配的句柄。SQLAllocHandle
第一个(用于 ENV 类型句柄)如下所示:
[CCode (cname = "void", free_function = "EnvironmentHandle.free")]
[Compact]
public class EnvironmentHandle {
    [CCode (cname = "SQLAllocHandle")]
    private static Return allocate_internal (HandleType type, void* nothing, out EnvironmentHandle output_handle);
    public static Return allocate (out EnvironmentHandle output_handle) {
        return allocate_internal (HandleType.ENV, null, out output_handle);
    }
    [CCode (cname = "SQLFreeHandle")]
    private static Return free_internal (HandleType type, EnvironmentHandle handle);
    public static Return free (EnvironmentHandle handle) {
        return free_internal (HandleType.ENV, handle);
    }
}
这不编译。
是否可以使用静态类方法作为free_function?
如果没有,是否至少有一种方法可以free_function在 vapi 文件中编写自定义?
我需要一个自定义函数,因为该SQLFreeHandle函数将句柄类型和句柄作为参数。
从 vapi 用户的角度来看,真正重要的是:
[CCode (cname = "void")]
[Compact]
public class EnvironmentHandle {
    public static Return allocate (out EnvironmentHandle output_handle);
}
唯一的其他解决方案是[SimpleType] struct按照 apmasell 在原始问题中的建议使用 a 。SQLHANLDE这将隐藏 a确实是引用类型的事实。
我当前实现的完整代码可在线获取: https ://github.com/antiochus/unixodbc-vala/tree/0486f54dc3f86d9c8bf31071980e4f171aca9591