crystal-lang / crystal_lib

Automatic binding generator for native libraries in Crystal
138 stars 30 forks source link

Unsupported primitive kind: Invalid (Exception) #8

Closed samis closed 8 years ago

samis commented 9 years ago

Using this input:

@[Include("eina-1/Eina.h", flags: "-I/usr/include/efl-1 -I/usr/include/eina-1 -I/usr/include/eina-1/eina -I /usr/lib/clang/3.7.0/include", prefix: %w(eina_))]
@[Link("eina")]
lib LibEina
end

The following stacktrace is produced:

Unsupported primitive kind: Invalid (Exception)
[4889111] *CallStack::unwind:Array(Pointer(Void)) +87
[4889002] *CallStack#initialize<CallStack>:Array(Pointer(Void)) +10
[4888954] *CallStack::new:CallStack +42
[4895233] *Exception#initialize<Exception, String, Nil>:CallStack +33
[4895169] *Exception::new<String>:Exception +97
[4829670] *raise<String>:NoReturn +6
[5570102] *CrystalLib::TypeMapper#map_internal<CrystalLib::TypeMapper, CrystalLib::PrimitiveType>:Crystal::Path +966
[5568664] *CrystalLib::TypeMapper#map_non_recursive<CrystalLib::TypeMapper, CrystalLib::Type+>:Crystal::ASTNode+ +136
[5573923] *CrystalLib::TypeMapper#map_internal<CrystalLib::TypeMapper, CrystalLib::TypedefType>:Crystal::ASTNode+ +787
[5568837] *CrystalLib::TypeMapper#map_non_recursive<CrystalLib::TypeMapper, CrystalLib::Type+>:Crystal::ASTNode+ +309
[5573923] *CrystalLib::TypeMapper#map_internal<CrystalLib::TypeMapper, CrystalLib::TypedefType>:Crystal::ASTNode+ +787
[5568837] *CrystalLib::TypeMapper#map_non_recursive<CrystalLib::TypeMapper, CrystalLib::Type+>:Crystal::ASTNode+ +309
[5576764] *CrystalLib::TypeMapper#map_internal<CrystalLib::TypeMapper, CrystalLib::FunctionType>:Crystal::Fun +204
[5568888] *CrystalLib::TypeMapper#map_non_recursive<CrystalLib::TypeMapper, CrystalLib::Type+>:Crystal::ASTNode+ +360
[5568494] *CrystalLib::TypeMapper#map<CrystalLib::TypeMapper, CrystalLib::Type+>:Crystal::ASTNode+ +14
[5577836] *CrystalLib::TypeMapper#expand_pending_structs<CrystalLib::TypeMapper>:Nil +412
[5568509] *CrystalLib::TypeMapper#map<CrystalLib::TypeMapper, CrystalLib::Type+>:Crystal::ASTNode+ +29
[5577836] *CrystalLib::TypeMapper#expand_pending_structs<CrystalLib::TypeMapper>:Nil +412
[5568509] *CrystalLib::TypeMapper#map<CrystalLib::TypeMapper, CrystalLib::Type+>:Crystal::ASTNode+ +29
[5586682] *CrystalLib::PrefixImporter#map_type<CrystalLib::PrefixImporter, CrystalLib::Type+>:Crystal::ASTNode+ +10
[5586197] *CrystalLib::PrefixImporter#process<CrystalLib::PrefixImporter, CrystalLib::Function>:Array(Crystal::ASTNode+)? +469
[5584500] *CrystalLib::PrefixImporter::import<Array(CrystalLib::ASTNode+), Array(String)>:Crystal::ASTNode+ +292
[5480048] *CrystalLib::LibTransformer#transform<CrystalLib::LibTransformer, Crystal::LibDef>:Crystal::LibDef +208
[5308496] *Crystal::ASTNode+ +160
[5481660] *CrystalLib::LibTransformer +124
[5308544] *Crystal::ASTNode+ +208
[4829276] ???
[4843120] main +32
[140311053354512] __libc_start_main +240
[4801753] _start +41
[0] ???

I've most likely screwed up in the definition, but just making this issue in case I didn't.

asterite commented 9 years ago

I can look at this, but I need to have access to Eina.h and its contents. There must be something missing to support.

samis commented 9 years ago

No problem, it's one of the development headers for an opensource library. The file can be viewed in the git repository at https://git.enlightenment.org/core/efl.git/tree/src/lib/eina/Eina.h

asterite commented 8 years ago

It seems the issue is that some structs use va_args or __builtin_va_args... I'm still not sure how to map those or where those are defined, I'll keep investigating.

samis commented 8 years ago

http://man7.org/linux/man-pages/man3/stdarg.3.html might help.

asterite commented 8 years ago

@samis With HEAD you can now generate bindings for eina. The headers have some nested structs inside structs and these aren't supported right now, I'll try to fix that next.

asterite commented 8 years ago

And now nested structs are also supported! \o/