Skip to content
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

cpptype of empty array #463

Open
ethomag opened this issue Feb 20, 2020 · 1 comment
Open

cpptype of empty array #463

ethomag opened this issue Feb 20, 2020 · 1 comment

Comments

@ethomag
Copy link

ethomag commented Feb 20, 2020

I'm using Cxx to interface a fairly complicated C++ library. A test case that worked fine in July (I think I was using Julia 1.1 and Cxx 0.3.x) failed with Julia 1.3.1 and Cxx 0.4.0.
I tried to understand what was happening (I can safely say that this code is way beyond my competence level), but the following patch in Cxx got it working again:

$ git diff
diff --git a/src/typetranslation.jl b/src/typetranslation.jl
index aa5e370..b82b290 100644
--- a/src/typetranslation.jl
+++ b/src/typetranslation.jl
@@ -292,7 +292,7 @@ function cpptype(C,::Type{T}) where T
         InverseMappedTypes[MappedTypes[T]] = T
         # For callable julia types, also add an operator() method to the anonymous
         # class
-        if !isempty(T.name.mt)
+        if !isempty(T.name.mt) && isa(T.name.mt.defs, Core.TypeMapEntry)
             linfo = T.name.mt.defs.func
             sig = T.name.mt.defs.sig
             nargt = length(sig.parameters)-1

What I think caused the problem was that in the testcase, one of the parameters to a C++ function was an empty array (Array{Complex{Float64}}(undef, 0, 0)) and that confused Cxx type translation. Since I hardly understand what I'm doing, I welcome someone with the proper competence to make a proper patch.

@Gnimuc
Copy link
Member

Gnimuc commented Feb 21, 2020

Hi @Keno, do you have time to take a look at this and many other recent issues?

ethomag added a commit to ethomag/Cxx.jl that referenced this issue Apr 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants