-
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
Is in possible to define embedded modules? #452
Comments
I try to use mingw and it obviously compile with julia CxxWrap module,
|
If I understand correctly, this is more or less what is done in this test here: https://github.com/JuliaInterop/libcxxwrap-julia/blob/main/test/test_module.cpp |
Thanks for reply. Its seems like what i searching for. (its exactly an exmple except of std part and last lines, wehere i try to call binded method) JLCXX_MODULE register_test_module(jlcxx::Module& mod)
{
using namespace test_module;
mod.add_type<Foo>("Foo")
.method("getx", &Foo::getx);
mod.method("test_method", [] () {return 1;});
}
void __dummy_protect(jl_value_t*) {}
int main(int argc, char *argv[])
{
jlcxx::cxxwrap_init();
jl_value_t* mod = jl_eval_string(R"(
module TestModule
const __cxxwrap_pointers = Ptr{Cvoid}[]
end
)");
JL_GC_PUSH1(&mod);
if (jlcxx::julia_type_name(jl_typeof(mod)) != "Module")
{
std::cout << "TestModule creation failed" << std::endl;
return 1;
}
register_julia_module((jl_module_t*)mod, register_test_module);
jl_call1(jl_get_function(jlcxx::get_cxxwrap_module(), "wraptypes"), mod);
jl_value_t* dt = jl_eval_string("TestModule.Foo");
if(jlcxx::julia_type_name(dt) != "Foo")
{
std::cout << "unexpected type name: " << jlcxx::julia_type_name(dt) << std::endl;
return 1;
}
// ***** CALL BINDED METHOD *****
jl_eval_string(R"(
v = TestModule.test_method()
println(v)
)");
} There is no crash. Simply no output in cmd. (But it is with such line Does i understand correct: we could call for binded methods from within c++ embedded julia? |
I found in the doc about jl_call1(jl_get_function(jlcxx::get_cxxwrap_module(), "wraptypes"), mod); add |
even so
not working |
I have to streamline this some more, ideally we should be able to call the |
Does julia poses fundamental limitations to declare bindings withoud shared lib (executable with embedded julia), like pybind11
PYBIND11_EMBEDDED_MODULE
?I try to create julia module and sand it through CxxWrap functions like this (it is not register function and crash during registration process)
Its seems very interesting to embed julia in existing huge cpp project (which is very complicated to split in dll to make a module).
The text was updated successfully, but these errors were encountered: