Skip to content

Errors when calling jlcxx::make_function_pointer #71

Open
@benjaminfaber

Description

@benjaminfaber

Hi, I am attempting to use CxxWrap to expose a C++ library to Julia, and I would like to pass a Julia function as a callback to the library. However, when I attempt to use jlcxx::make_function_pointer, I receive an error that some of the arguments of the signature for the function pointer I'm attempting to convert have no Julia wrapper. A MWE is below:

#include "jlcxx/jlcxx.hpp"
#include "jlcxx/functions.hpp"

class test_class {
};

JLCXX_MODULE define_julia_module(jlcxx::Module& mod) {
  mod.method("pass_func",[](jlcxx::SafeCFunction f_data) {
    auto f = jlcxx::make_function_pointer<void(int*,test_class*)>(f_data);
    });
}
julia> module wrapped
            using CxxWrap
            @wrapmodule(joinpath("lib/path","lib"))
            function __init__()
              @initcxx
            end
          end

julia> function testfunc(i::Int,c::wrapped.test_class)
          end

julia> cxxtestfunc = @safe_cfunction(testfunc, Cvoid, (CxxPtr{Cint},CxxPtr{wrapped.test_class}));

julia> wrapped.pass_func(cxxtestfunc)
ERROR: Type Pi has no Julia wrapper

This error does not arise if a double* is specified in the function pointer signature, which makes me think this is a bug, or am I just using libcxxwrap incorrectly?

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