-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@cfunction for function taking binded class within c++ #460
Comments
Posibly i should change julia signature
|
Hi, With cxxWrap I recommend making a function that accepts a The pointer is best generated in Julia, as here in this example: Line 119 in b1c07f1
|
Sorry, i still dont get which type should be in c++ signature for binded struct. SafeCFunction know how to handle custom structs? Is it corect way to get SafeCFucntion from julia? jlcxx::SafeCFunction *f_data = (jlcxx::SafeCFunction *) jl_unbox_voidpointer(jl_eval_string("@safe_cfunction(testf, Cfloat, (Cfloat, Cfloat))"));
auto f = jlcxx::make_function_pointer<float(float, float)>(*f_data); This code crash when |
I try out to modify example from doc. (original one work correctly) function Test(eg::CppTypes.Database) :: Cvoid
println("im test function")
end
ptr = @safe_cfunction(Test, Cvoid, (Main.CppTypes.DatabaseAllocated,))
println(typeof(ptr))
test_safe_cfunction(ptr) with the following test_safe_cfunction: types.method("test_safe_cfunction", [](jlcxx::SafeCFunction f_data) {
auto *f = jlcxx::make_function_pointer<void(DataBase* )>(f_data);
std::cout << f << std::endl;
}); and it just stop execution, nothing we printed out |
Its not obvious how to get |
I think it should work like this: function Test(eg::CxxRef{CppTypes.Database}) :: Cvoid
println("im test function")
end
ptr = @safe_cfunction(Test, Cvoid, (CxxRef{CppTypes.Database},))
println(typeof(ptr))
test_safe_cfunction(ptr) types.method("test_safe_cfunction", [](jlcxx::SafeCFunction f_data) {
auto *f = jlcxx::make_function_pointer<void(DataBase&)>(f_data);
std::cout << f << std::endl;
}); Or if you prefer pointers you can use |
Hi.
Sorry for silly question, but how to use
@cfunction
in the foolowing case:Suppose we bind class:
and write julia function which take this class:
and try to get
cfunction
pointer on this function from c++:Pointer exist, but call this is trow an exception.
where im wrong?
Binded classes wrapped on julia side
Thanks
The text was updated successfully, but these errors were encountered: