diff --git a/bindings/ruby/CMakeLists.txt b/bindings/ruby/CMakeLists.txt index 12613798..83d3cc97 100644 --- a/bindings/ruby/CMakeLists.txt +++ b/bindings/ruby/CMakeLists.txt @@ -9,6 +9,8 @@ else(SISL_FOUND) EXT_RICE base_types_ruby Eigen.cpp init.cpp) endif(SISL_FOUND) +target_compile_features(base_types_ruby PUBLIC cxx_std_17) + if (base_AVAILABLE) if(SISL_FOUND) install(DIRECTORY lib/sisl diff --git a/bindings/ruby/ext/base_types_ruby/Eigen.cpp b/bindings/ruby/ext/base_types_ruby/Eigen.cpp index 6f1ee4af..239cf523 100644 --- a/bindings/ruby/ext/base_types_ruby/Eigen.cpp +++ b/bindings/ruby/ext/base_types_ruby/Eigen.cpp @@ -1,7 +1,11 @@ +#if __has_include("rice/rice.hpp") +#include "rice/rice.hpp" +#else #include "rice/Class.hpp" #include "rice/String.hpp" #include "rice/Constructor.hpp" #include "rice/Enum.hpp" +#endif #include #include diff --git a/bindings/ruby/ext/base_types_ruby/Spline.cpp b/bindings/ruby/ext/base_types_ruby/Spline.cpp index 5c6d439c..521f522d 100644 --- a/bindings/ruby/ext/base_types_ruby/Spline.cpp +++ b/bindings/ruby/ext/base_types_ruby/Spline.cpp @@ -1,7 +1,19 @@ +#if __has_include("rice/rice.hpp") +#include "rice/rice.hpp" + +template +T from_ruby(Rice::Object x) +{ + return Rice::detail::From_Ruby().convert(x); +} + +#else +#define BASE_TYPES_OLD_RICE_API #include "rice/Class.hpp" #include "rice/String.hpp" #include "rice/Constructor.hpp" #include "rice/Enum.hpp" +#endif #include @@ -12,12 +24,15 @@ typedef SplineBase::CoordinateType CoordinateType; Rice::Enum coordinate_type_type; +#ifdef BASE_TYPES_OLD_RICE_API +// enum types seem to be converted automatically now? template<> CoordinateType from_ruby( Object x ) { Data_Object d( x, coordinate_type_type ); return *d; } +#endif template static std::vector array_to_cpp(Array array) diff --git a/bindings/ruby/ext/base_types_ruby/init.cpp b/bindings/ruby/ext/base_types_ruby/init.cpp index 6575afa1..62699eac 100644 --- a/bindings/ruby/ext/base_types_ruby/init.cpp +++ b/bindings/ruby/ext/base_types_ruby/init.cpp @@ -1,4 +1,8 @@ +#if __has_include("rice/rice.hpp") +#include "rice/rice.hpp" +#else #include "rice/Class.hpp" +#endif extern void Init_eigen_ext(); #ifdef SISL_FOUND