JuliaInterop / Cxx.jl

The Julia C++ Interface

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trying to wrap a function that returns a std::vector<std::string>*

jstrube opened this issue · comments

I'm trying to develop bindings for a file format: https://github.com/iLCSoft/LCIO
My package is this one:
https://github.com/jstrube/LCIO_Cxx

I'm struggling to understand a test failure:

┌ Warning: The two argument form of `func_for_method_checked` is deprecated. Pass sparams in addition.
│   caller = get_llvmf_decl(::Type) at cxxstr.jl:105
└ @ Cxx.CxxCore ~/.julia/packages/Cxx/7d2lG/src/cxxstr.jl:105
In file included from /Cxx.cpp:1:
:3:35: error: expected unqualified-id
            auto &r = __juliavar1.;
                                  ^
(const class std::vector<class std::__cxx11::basic_string<char>, class std::allocator<class std::__cxx11::basic_string<char> > > *) @0x000000000537f1d8

23
printing names
:3:35: error: expected unqualified-id
            auto &r = __juliavar1.;
                                  ^
(class std::__cxx11::basic_string<char> &) {
 ._M_dataplus = Cxx.CxxCore.CppRef{Cxx.CxxCore.CppBaseType{Symbol("std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider")},(false, false, false)}(<not found in compilation unit>)

 ._M_string_length = (unsigned long long &) 11
 . = :3:35: error: expected unqualified-id
            auto &r = __juliavar1.;
                                  ^
:3:35: error: expected unqualified-id
            auto &r = __juliavar1.;
                                  ^
ERROR: LoadError: Tried to Emit Invalid Decl
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] EmitTopLevelDecl(::Cxx.CxxCore.ClangCompiler, ::Cxx.CxxCore.CppPtr{Cxx.CxxCore.CxxQualType{Cxx.CxxCore.CppBaseType{Symbol("clang::Decl")},(false, false, false)},(false, false, false)}) at /home/jstrube/.julia/packages/Cxx/7d2lG/src/cxxstr.jl:258
 [3] #s37#70 at /home/jstrube/.julia/packages/Cxx/7d2lG/src/cxxstr.jl:708 [inlined]
 [4] #s37#70(::Any, ::Any, ::Any, ::Any) at ./none:0
 [5] (::Core.GeneratedFunctionStub)(::Any, ::Vararg{Any,N} where N) at ./boot.jl:524
 [6] show(::Base.TTY, ::Cxx.CxxCore.CppRef{Cxx.CxxCore.CppTemplate{Cxx.CxxCore.CppBaseType{Symbol("std::__cxx11::basic_string")},Tuple{UInt8,Cxx.CxxCore.CxxQualType{Cxx.CxxCore.CppTemplate{Cxx.CxxCore.CppBaseType{Symbol("std::char_traits")},Tuple{UInt8}},(false, false, false)},Cxx.CxxCore.CxxQualType{Cxx.CxxCore.CppTemplate{Cxx.CxxCore.CppBaseType{Symbol("std::allocator")},Tuple{UInt8}},(false, false, false)}}},(false, false, false)}) at /home/jstrube/.julia/packages/Cxx/7d2lG/src/show.jl:7
 [7] print(::Base.TTY, ::Cxx.CxxCore.CppRef{Cxx.CxxCore.CppTemplate{Cxx.CxxCore.CppBaseType{Symbol("std::__cxx11::basic_string")},Tuple{UInt8,Cxx.CxxCore.CxxQualType{Cxx.CxxCore.CppTemplate{Cxx.CxxCore.CppBaseType{Symbol("std::char_traits")},Tuple{UInt8}},(false, false, false)},Cxx.CxxCore.CxxQualType{Cxx.CxxCore.CppTemplate{Cxx.CxxCore.CppBaseType{Symbol("std::allocator")},Tuple{UInt8}},(false, false, false)}}},(false, false, false)}) at ./strings/io.jl:37
 [8] print(::Base.TTY, ::Cxx.CxxCore.CppRef{Cxx.CxxCore.CppTemplate{Cxx.CxxCore.CppBaseType{Symbol("std::__cxx11::basic_string")},Tuple{UInt8,Cxx.CxxCore.CxxQualType{Cxx.CxxCore.CppTemplate{Cxx.CxxCore.CppBaseType{Symbol("std::char_traits")},Tuple{UInt8}},(false, false, false)},Cxx.CxxCore.CxxQualType{Cxx.CxxCore.CppTemplate{Cxx.CxxCore.CppBaseType{Symbol("std::allocator")},Tuple{UInt8}},(false, false, false)}}},(false, false, false)}, ::Char) at ./strings/io.jl:48
 [9] println(::Base.TTY, ::Cxx.CxxCore.CppRef{Cxx.CxxCore.CppTemplate{Cxx.CxxCore.CppBaseType{Symbol("std::__cxx11::basic_string")},Tuple{UInt8,Cxx.CxxCore.CxxQualType{Cxx.CxxCore.CppTemplate{Cxx.CxxCore.CppBaseType{Symbol("std::char_traits")},Tuple{UInt8}},(false, false, false)},Cxx.CxxCore.CxxQualType{Cxx.CxxCore.CppTemplate{Cxx.CxxCore.CppBaseType{Symbol("std::allocator")},Tuple{UInt8}},(false, false, false)}}},(false, false, false)}) at ./strings/io.jl:75
 [10] println(::Cxx.CxxCore.CppRef{Cxx.CxxCore.CppTemplate{Cxx.CxxCore.CppBaseType{Symbol("std::__cxx11::basic_string")},Tuple{UInt8,Cxx.CxxCore.CxxQualType{Cxx.CxxCore.CppTemplate{Cxx.CxxCore.CppBaseType{Symbol("std::char_traits")},Tuple{UInt8}},(false, false, false)},Cxx.CxxCore.CxxQualType{Cxx.CxxCore.CppTemplate{Cxx.CxxCore.CppBaseType{Symbol("std::allocator")},Tuple{UInt8}},(false, false, false)}}},(false, false, false)}) at ./coreio.jl:4
 [11] (::getfield(Main, Symbol("##5#6")))(::Cxx.CxxCore.CppPtr{Cxx.CxxCore.CxxQualType{Cxx.CxxCore.CppBaseType{Symbol("IO::LCReader")},(false, false, false)},(false, false, false)}) at /home/jstrube/.julia/dev/LCIO_Cxx/test/runtests.jl:44
 [12] open(::getfield(Main, Symbol("##5#6")), ::String) at /home/jstrube/.julia/dev/LCIO_Cxx/src/LCIO_Cxx.jl:74
 [13] top-level scope at /home/jstrube/.julia/dev/LCIO_Cxx/test/runtests.jl:34
 [14] include at ./boot.jl:328 [inlined]
 [15] include_relative(::Module, ::String) at ./loading.jl:1094
 [16] include(::Module, ::String) at ./Base.jl:31
 [17] include(::String) at ./client.jl:431
 [18] top-level scope at none:5
in expression starting at /home/jstrube/.julia/dev/LCIO_Cxx/test/runtests.jl:34
ERROR: Package LCIO_Cxx errored during testing

The method I'm trying to wrap is this one:
https://github.com/iLCSoft/LCIO/blob/27c67df622c934f3258a38e167b4b358781f306a/src/cpp/include/pre-generated/EVENT/LCEvent.h#L60

And I'm trying to wrap it like this:
https://github.com/jstrube/LCIO_Cxx/blob/master/src/LCIO_Cxx.jl#L39-L57

The error message looks like Cxx stopped halfway through creating a tempvar, but I don't understand what's going on and whether this is a Cxx bug, or a bug in my code.
Any help would be appreciated.

ps: sorry, the package isn't quite self-contained, yet. To test, please ] add LCIO and change the path to the C++ libs near the top of LCIO_Cxx.jl.