Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bindings/ruby/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is base-types ... I would avoid doing that blindly.

If the goal is to support rice > 4, could you do it conditionally.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By "conditionally", do you mean checking the rice version, or adding a cmake flag?
I can try either. I think I had problems finding out the rice version (by cmake), but it has been a while (I had this change as local fix some time before I made this PR)


if (base_AVAILABLE)
if(SISL_FOUND)
install(DIRECTORY lib/sisl
Expand Down
4 changes: 4 additions & 0 deletions bindings/ruby/ext/base_types_ruby/Eigen.cpp
Original file line number Diff line number Diff line change
@@ -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 <Eigen/Core>
#include <Eigen/Geometry>
Expand Down
15 changes: 15 additions & 0 deletions bindings/ruby/ext/base_types_ruby/Spline.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
#if __has_include("rice/rice.hpp")
#include "rice/rice.hpp"

template<class T>
T from_ruby(Rice::Object x)
{
return Rice::detail::From_Ruby<T>().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 <base/geometry/Spline.hpp>

Expand All @@ -12,12 +24,15 @@ typedef SplineBase::CoordinateType CoordinateType;

Rice::Enum<CoordinateType> coordinate_type_type;

#ifdef BASE_TYPES_OLD_RICE_API
// enum types seem to be converted automatically now?
template<>
CoordinateType from_ruby<CoordinateType>( Object x )
{
Data_Object<CoordinateType> d( x, coordinate_type_type );
return *d;
}
#endif

template<class Type>
static std::vector<Type> array_to_cpp(Array array)
Expand Down
4 changes: 4 additions & 0 deletions bindings/ruby/ext/base_types_ruby/init.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down