Skip to content

Feature request: add a codegen option to create function wrappers for c structures of function ptrs #561

Description

@IanET

Several c libraries like ONNX, primarily use structs of function pointers which then get translated to Ptr{Cvoid} eg

struct OrtCustomOp
    version::UInt32
    CreateKernel::Ptr{Cvoid}
    GetName::Ptr{Cvoid}
    GetExecutionProviderType::Ptr{Cvoid}
    GetInputType::Ptr{Cvoid}
    GetInputTypeCount::Ptr{Cvoid}
   etc
end

It would be great if wrappers could be automatically created for the function ptr fields to make them easier to call eg

CreateKernel(ort_custom_op::OrtCustomOp, session_OrtCustomOpoptions, kernel_info, kernel) = @ccall $(ort_custom_op.CreateKernel)(session_options::Ptr{OrtSessionOptions}, kernel_info::Ptr{OrtKernelInfo}, kernel::Ptr{Ptr{OrtKernel}})::OrtStatusPtr
GetName(ort_custom_op::OrtCustomOp, op) = @ccall $(ort_custom_op.GetName)(op::Ptr{OrtCustomOp} )::Cwstring
GetExecutionProviderType(ort_custom_op::OrtCustomOp, op) = @ccall $(ort_custom_op.GetExecutionProviderType)(op::Ptr{OrtCustomOp})::Cwstring
etc

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions