Papierkorb / bindgen

Binding and wrapper generator for C/C++ libraries
GNU General Public License v3.0
179 stars 18 forks source link

Updates Crystal 0.36.1 #114

Closed kalinon closed 3 years ago

kalinon commented 3 years ago

Updates for crystal 0.36.1. There is still an issue with the QT spec:

$ crystal spec ./spec/integration/qt_spec.cr
+ rm -f arguments.o basic.o c_only.o c_wrapper.o containers.o inheritance.o virtual_override.o arguments.cpp basic.cpp c_wrapper.cpp containers.cpp inheritance.cpp virtual_override.cpp arguments.cr arguments_test.cr basic.cr basic_test.cr c_only.cr c_only_test.cr c_wrapper.cr c_wrapper_test.cr containers.cr containers_test.cr inheritance.cr inheritance_test.cr qt_test.cr virtual_override.cr virtual_override_test.cr
Argument 1 has unreachable type Proc(Void) at Test::SomeObject#CONNECT_stuffHappened(_proc_)
Argument 1 has unreachable type Proc(Void) at Test::SomeObject#CONNECT_privateSignal(_proc_)
Found 2 errors.  Aborting.
F

Failures:

  1) Qt-specific wrapper features works
     Failure/Error: tool.run!.should eq(0)

       Expected: 0
            got: 1

     # spec/integration/spec_helper.cr:80

Finished in 103.86 milliseconds
1 examples, 1 failures, 0 errors, 0 pending

Failed examples:

crystal spec spec/integration/qt_spec.cr:4 # Qt-specific wrapper features works
kalinon commented 3 years ago

Resolved conflicts, this resolved the QT issue but now the container specs are failing. Think we will need @HertzDevil 's help to resolve those:

crystal spec spec/integration/containers_spec.cr
+ rm -f arguments.o basic.o c_only.o c_wrapper.o copy_structs.o enums.o inheritance.o instance_properties.o qt.o virtual_override.o arguments.cpp basic.cpp c_wrapper.cpp copy_structs.cpp enums.cpp inheritance.cpp instance_properties.cpp qt.cpp virtual_override.cpp arguments.cr arguments_test.cr basic.cr basic_test.cr c_only.cr c_only_test.cr c_wrapper.cr c_wrapper_test.cr containers_test.cr copy_structs.cr copy_structs_test.cr enums.cr enums_test.cr inheritance.cr inheritance_test.cr instance_properties.cr instance_properties_test.cr qt.cr qt_test.cr virtual_override.cr virtual_override_test.cr
Invalid alias name "std::vector<int>" at Test::Binding::std::vector<int>
Invalid alias name "std::vector<std::vector<int>>" at Test::Binding::std::vector<std::vector<int>>
Invalid alias name "std::vector<std::string>" at Test::Binding::std::vector<std::string>
Invalid alias name "std::vector<rgb>" at Test::Binding::std::vector<rgb>
Invalid alias name "std::vector<double>" at Test::Binding::std::vector<double>
Result type std::vector<int> is unreachable at Test::Binding#integers()
Result type std::vector<std::vector<int>> is unreachable at Test::Binding#grid()
Result type std::vector<std::string> is unreachable at Test::Binding#strings()
Result type std::vector<rgb> is unreachable at Test::Binding#palette()
Argument 2 has unreachable type std::vector<double> at Test::Binding#sum(list)
Result type Binding::std::vector<int> is unreachable at Test::Containers#integers()
Result type Binding::std::vector<std::vector<int>> is unreachable at Test::Containers#grid()
Result type Binding::std::vector<std::string> is unreachable at Test::Containers#strings()
Result type Binding::std::vector<rgb> is unreachable at Test::Containers#palette()
Argument 1 has unreachable type Binding::std::vector<double> at Test::Containers#sum(list)
Found 15 errors.  Aborting.
F

Failures:

  1) container instantiation feature works
     Failure/Error: tool.run!.should eq(0)

       Expected: 0
            got: 1

     # spec/integration/spec_helper.cr:80

Finished in 610.11 milliseconds
1 examples, 1 failures, 0 errors, 0 pending

Failed examples:

crystal spec spec/integration/containers_spec.cr:4 # container instantiation feature works
kalinon commented 3 years ago

I was able to fix the cspec by adding std::__1::vector to spec/integration/containers.yml as a container:

containers:
  - class: std::vector
    type: Sequential
    instantiations:
      - [ "int" ]
      - [ "std::vector<int>" ]
  - class: std::__1::vector
    type: Sequential

However, i am still seeing C types being passed as crystal types when i try to use it on other libs:

Invalid alias camel case name "Void*" at RayLib::Binding::Void*
Invalid alias camel case name "std::true_type" at RayLib::Binding::std::true_type
Invalid alias camel case name "std::false_type" at RayLib::Binding::std::false_type
Invalid alias camel case name "std::__libcpp_is_function_imp::__dummy_type" at RayLib::Binding::std::__libcpp_is_function_imp::__dummy_type
Invalid alias camel case name "std::__two" at RayLib::Binding::std::__two
Invalid alias camel case name "decltype(std::__1::__declval<_Tp>(0))" at RayLib::Binding::decltype(std::__1::__declval<_Tp>(0))
Invalid alias camel case name "typename __select_2nd<decltype((std::__1::declval<_Tp>() = std::__1::declval<_Arg>())), true_type>::type" at RayLib::Binding::typename __select_2nd<decltype((std::__1::declval<_Tp>() = std::__1::declval<_Arg>())), true_type>::type
Invalid alias camel case name "typename __is_destructible_apply<decltype(std::__1::declval<_Tp1 &>().~_Tp1())>::type" at RayLib::Binding::typename __is_destructible_apply<decltype(std::__1::declval<_Tp1 &>().~_Tp1())>::type
Invalid alias camel case name "typename remove_reference<_Tp>::type" at RayLib::Binding::typename remove_reference<_Tp>::type
Invalid alias camel case name "typename decay<_Tp>::type" at RayLib::Binding::typename decay<_Tp>::type
Invalid alias camel case name "std::__nat" at RayLib::Binding::std::__nat
Invalid alias camel case name "std::__any" at RayLib::Binding::std::__any
Invalid alias camel case name "_Args &&..." at RayLib::Binding::_Args &&...
Invalid alias camel case name "decltype((std::__1::forward<_A0>(__a0) .* __f)(std::__1::forward<_Args>(__args)...))" at RayLib::Binding::decltype((std::__1::forward<_A0>(__a0) .* __f)(std::__1::forward<_Args>(__args)...))
Invalid alias camel case name "decltype((__a0.get() .* __f)(std::__1::forward<_Args>(__args)...))" at RayLib::Binding::decltype((__a0.get() .* __f)(std::__1::forward<_Args>(__args)...))
Invalid alias camel case name "decltype(((*std::__1::forward<_A0>(__a0)) .* __f)(std::__1::forward<_Args>(__args)...))" at RayLib::Binding::decltype(((*std::__1::forward<_A0>(__a0)) .* __f)(std::__1::forward<_Args>(__args)...))
Invalid alias camel case name "decltype(std::__1::forward<_A0>(__a0) .* __f)" at RayLib::Binding::decltype(std::__1::forward<_A0>(__a0) .* __f)
Invalid alias camel case name "decltype(__a0.get() .* __f)" at RayLib::Binding::decltype(__a0.get() .* __f)
Invalid alias camel case name "decltype((*std::__1::forward<_A0>(__a0)) .* __f)" at RayLib::Binding::decltype((*std::__1::forward<_A0>(__a0)) .* __f)
Invalid alias camel case name "decltype(std::__1::forward<_Fp>(__f)(std::__1::forward<_Args>(__args)...))" at RayLib::Binding::decltype(std::__1::forward<_Fp>(__f)(std::__1::forward<_Args>(__args)...))
Invalid alias camel case name "decltype(std::__1::__invoke(std::__1::declval<_XFp>(), std::__1::declval<_XArgs>()...))" at RayLib::Binding::decltype(std::__1::__invoke(std::__1::declval<_XFp>(), std::__1::declval<_XArgs>()...))
Invalid alias camel case name "typename enable_if<is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value>::type" at RayLib::Binding::typename enable_if<is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value>::type
Invalid alias camel case name "typename enable_if<__is_swappable<_Tp>::value>::type" at RayLib::Binding::typename enable_if<__is_swappable<_Tp>::value>::type
Invalid alias camel case name "_Tp [_Np]" at RayLib::Binding::_Tp [_Np]
Invalid alias camel case name "decltype(swap(std::__1::declval<_LHS>(), std::__1::declval<_RHS>()))" at RayLib::Binding::decltype(swap(std::__1::declval<_LHS>(), std::__1::declval<_RHS>()))
Invalid alias camel case name "typename enable_if<is_floating_point<_Fp>::value, long long>::type" at RayLib::Binding::typename enable_if<is_floating_point<_Fp>::value, long long>::type
Invalid alias camel case name "typename __sfinae_underlying_type<_Tp>::__promoted_type" at RayLib::Binding::typename __sfinae_underlying_type<_Tp>::__promoted_type
Invalid alias camel case name "typename __select_2nd<decltype(std::__1::declval<_Up>().operator&()), true_type>::type" at RayLib::Binding::typename __select_2nd<decltype(std::__1::declval<_Up>().operator&()), true_type>::type
Invalid alias camel case name "typename __select_2nd<decltype(operator&(std::__1::declval<_Up>())), true_type>::type" at RayLib::Binding::typename __select_2nd<decltype(operator&(std::__1::declval<_Up>())), true_type>::type
kalinon commented 3 years ago

@HertzDevil @docelic @Papierkorb Any help with this?

docelic commented 3 years ago

I don't have useful input on my side.

Papierkorb commented 3 years ago

I don't know what exactly is going wrong. However, looks like some kind of SNIFAE magic gets matched to be brought to Crystal, which you don't want. Sorry, don't have the time nowadays to deep-dive into bindgen anymore ...

kalinon commented 3 years ago

closing in favor of #115