rice 4.0.3 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -0
  3. data/Rakefile +1 -1
  4. data/include/rice/rice.hpp +2597 -1771
  5. data/include/rice/stl.hpp +1580 -271
  6. data/lib/mkmf-rice.rb +5 -2
  7. data/lib/version.rb +1 -1
  8. data/rice/Arg.hpp +6 -6
  9. data/rice/Arg.ipp +8 -9
  10. data/rice/Constructor.hpp +2 -2
  11. data/rice/Data_Object.ipp +69 -15
  12. data/rice/Data_Object_defn.hpp +1 -15
  13. data/rice/Data_Type.ipp +56 -86
  14. data/rice/Data_Type_defn.hpp +14 -17
  15. data/rice/Director.hpp +0 -1
  16. data/rice/Enum.ipp +31 -22
  17. data/rice/Exception.ipp +2 -3
  18. data/rice/Exception_defn.hpp +5 -5
  19. data/rice/HandlerRegistration.hpp +15 -0
  20. data/rice/Return.hpp +5 -4
  21. data/rice/Return.ipp +8 -3
  22. data/rice/detail/ExceptionHandler.hpp +8 -0
  23. data/rice/detail/ExceptionHandler.ipp +28 -0
  24. data/rice/detail/{Exception_Handler_defn.hpp → ExceptionHandler_defn.hpp} +17 -21
  25. data/rice/detail/HandlerRegistry.hpp +51 -0
  26. data/rice/detail/HandlerRegistry.ipp +20 -0
  27. data/rice/detail/InstanceRegistry.hpp +34 -0
  28. data/rice/detail/InstanceRegistry.ipp +50 -0
  29. data/rice/detail/MethodInfo.ipp +1 -1
  30. data/rice/detail/NativeAttribute.hpp +26 -15
  31. data/rice/detail/NativeAttribute.ipp +76 -47
  32. data/rice/detail/NativeFunction.hpp +60 -13
  33. data/rice/detail/NativeFunction.ipp +103 -85
  34. data/rice/detail/NativeIterator.hpp +49 -0
  35. data/rice/detail/NativeIterator.ipp +102 -0
  36. data/rice/detail/NativeRegistry.hpp +31 -0
  37. data/rice/detail/{method_data.ipp → NativeRegistry.ipp} +20 -16
  38. data/rice/detail/Registries.hpp +26 -0
  39. data/rice/detail/Registries.ipp +23 -0
  40. data/rice/detail/RubyFunction.hpp +6 -11
  41. data/rice/detail/RubyFunction.ipp +10 -22
  42. data/rice/detail/Type.hpp +1 -1
  43. data/rice/detail/Type.ipp +3 -2
  44. data/rice/detail/TypeRegistry.hpp +8 -11
  45. data/rice/detail/TypeRegistry.ipp +3 -28
  46. data/rice/detail/Wrapper.hpp +0 -2
  47. data/rice/detail/Wrapper.ipp +73 -23
  48. data/rice/detail/cpp_protect.hpp +93 -0
  49. data/rice/detail/default_allocation_func.ipp +1 -1
  50. data/rice/detail/from_ruby.ipp +206 -2
  51. data/rice/detail/to_ruby.ipp +39 -5
  52. data/rice/detail/to_ruby_defn.hpp +1 -1
  53. data/rice/forward_declares.ipp +6 -0
  54. data/rice/global_function.hpp +0 -4
  55. data/rice/global_function.ipp +0 -6
  56. data/rice/rice.hpp +29 -24
  57. data/rice/stl.hpp +6 -1
  58. data/test/embed_ruby.cpp +0 -14
  59. data/test/test_Array.cpp +20 -24
  60. data/test/test_Class.cpp +8 -47
  61. data/test/test_Constructor.cpp +0 -2
  62. data/test/test_Data_Object.cpp +25 -11
  63. data/test/test_Data_Type.cpp +124 -28
  64. data/test/test_Director.cpp +12 -13
  65. data/test/test_Enum.cpp +65 -26
  66. data/test/test_Inheritance.cpp +9 -9
  67. data/test/test_Iterator.cpp +134 -5
  68. data/test/test_Keep_Alive.cpp +7 -7
  69. data/test/test_Memory_Management.cpp +1 -1
  70. data/test/test_Module.cpp +25 -62
  71. data/test/test_Object.cpp +66 -3
  72. data/test/test_Ownership.cpp +12 -13
  73. data/test/test_Self.cpp +12 -13
  74. data/test/test_Stl_Map.cpp +696 -0
  75. data/test/test_Stl_Optional.cpp +3 -3
  76. data/test/test_Stl_Pair.cpp +38 -2
  77. data/test/test_Stl_Reference_Wrapper.cpp +102 -0
  78. data/test/test_Stl_SmartPointer.cpp +5 -5
  79. data/test/test_Stl_Unordered_Map.cpp +697 -0
  80. data/test/test_Stl_Variant.cpp +301 -0
  81. data/test/test_Stl_Vector.cpp +200 -41
  82. data/test/test_Struct.cpp +3 -3
  83. data/test/test_To_From_Ruby.cpp +6 -0
  84. data/test/test_Tracking.cpp +239 -0
  85. data/test/unittest.hpp +13 -4
  86. metadata +23 -13
  87. data/rice/detail/Exception_Handler.hpp +0 -8
  88. data/rice/detail/Exception_Handler.ipp +0 -28
  89. data/rice/detail/Iterator.hpp +0 -23
  90. data/rice/detail/Iterator.ipp +0 -47
  91. data/rice/detail/function_traits.hpp +0 -124
  92. data/rice/detail/method_data.hpp +0 -29
  93. data/rice/detail/rice_traits.hpp +0 -116
  94. data/rice/ruby_try_catch.hpp +0 -86
@@ -1,116 +0,0 @@
1
- #ifndef Rice__detail__traits__hpp_
2
- #define Rice__detail__traits__hpp_
3
-
4
- #include <ostream>
5
- #include <string>
6
- #include <type_traits>
7
- #include <vector>
8
-
9
- namespace Rice
10
- {
11
- namespace detail
12
- {
13
- // Get the base_type of T - without pointer, reference, const or volatile
14
- template<typename T>
15
- using intrinsic_type = typename std::remove_cv_t<std::remove_reference_t<std::remove_pointer_t<T>>>;
16
-
17
- // Recursively remove const/volatilr
18
- template<typename T>
19
- struct remove_cv_recursive
20
- {
21
- using type = T;
22
- };
23
-
24
- template<typename T>
25
- struct remove_cv_recursive<T const volatile>
26
- {
27
- using type = typename remove_cv_recursive<T>::type;
28
- };
29
-
30
- template<typename T>
31
- struct remove_cv_recursive<T volatile>
32
- {
33
- using type = typename remove_cv_recursive<T>::type;
34
- };
35
-
36
- template<typename T>
37
- struct remove_cv_recursive<T const>
38
- {
39
- using type = typename remove_cv_recursive<T>::type;
40
- };
41
-
42
- template<typename T>
43
- struct remove_cv_recursive<T&>
44
- {
45
- using type = typename remove_cv_recursive<T>::type&;
46
- };
47
-
48
- /* template<typename T>
49
- struct remove_cv_recursive<T&&>
50
- {
51
- using type = typename remove_cv_recursive<T>::type&&;
52
- };*/
53
-
54
- template<typename T>
55
- struct remove_cv_recursive<T*>
56
- {
57
- using type = typename remove_cv_recursive<T>::type*;
58
- };
59
-
60
- template<typename T>
61
- using remove_cv_recursive_t = typename remove_cv_recursive<T>::type;
62
-
63
- // Does the Type work with ostreams? This is used to implement #to_s
64
- template<typename T, typename = void>
65
- struct is_ostreamable : std::false_type {};
66
-
67
- template<typename T>
68
- struct is_ostreamable<T, std::void_t<decltype(std::declval<std::ostream&>() << std::declval<T>())>> : std::true_type {};
69
-
70
- template<typename T>
71
- constexpr bool is_ostreamable_v = is_ostreamable<T>::value;
72
-
73
- // Is the type comparable?
74
- template<typename T, typename SFINAE = void>
75
- struct is_comparable : std::false_type {};
76
-
77
- template<typename T>
78
- struct is_comparable<T, std::void_t<decltype(std::declval<T>() == std::declval<T>())>> : std::true_type {};
79
-
80
- template<typename T>
81
- constexpr bool is_comparable_v = is_comparable<T>::value;
82
-
83
- template <typename U, typename V>
84
- struct is_comparable<std::pair<U, V>>
85
- {
86
- static const bool value = is_comparable_v<U> && is_comparable_v<V>;
87
- };
88
-
89
- template <typename T>
90
- struct is_comparable<std::vector<T>>
91
- {
92
- static const bool value = is_comparable_v<T>;
93
- };
94
-
95
- // -- Tuple Helpers ---
96
- template<typename T>
97
- struct tuple_shift;
98
-
99
- template<typename T, typename...Arg_Ts>
100
- struct tuple_shift<std::tuple<T, Arg_Ts...>>
101
- {
102
- using type = std::tuple<Arg_Ts...>;
103
- };
104
-
105
- template<template<typename, typename...> typename T, typename...Arg_Ts>
106
- struct tuple_map;
107
-
108
- template<template<typename, typename...> typename T, typename...Arg_Ts>
109
- struct tuple_map<T, std::tuple<Arg_Ts...>>
110
- {
111
- using type = std::tuple<T<remove_cv_recursive_t<Arg_Ts>>...>;
112
- };
113
- } // detail
114
- } // Rice
115
-
116
- #endif // Rice__detail__traits__hpp_
@@ -1,86 +0,0 @@
1
- #ifndef Rice__ruby_try_catch__hpp_
2
- #define Rice__ruby_try_catch__hpp_
3
-
4
- #include <stdexcept>
5
-
6
- #include "detail/Jump_Tag.hpp"
7
- #include "Exception_defn.hpp"
8
-
9
- /*! \def RUBY_TRY
10
- * \brief Start a block to catch Ruby exceptions and rethrow them.
11
- */
12
- // Goto is used here to avoid having to use a second try/catch block (we
13
- // can't rb_exc_raise directly out of the catch blocks below, since the
14
- // exceptions will not get properly cleaned up).
15
- // The labels are located before the try and not after it so the function can't
16
- // "fall through" into the exception-handling code accidentally.
17
- #define RUBY_TRY \
18
- VALUE Rice__ruby_exc = Qnil; \
19
- int Rice__ruby_jump_tag = 0; \
20
- \
21
- goto start_of_RUBY_TRY; \
22
- \
23
- Rice__ruby_exception: \
24
- rb_exc_raise(Rice__ruby_exc); \
25
- Rice__ruby_jump_tag: \
26
- rb_jump_tag(Rice__ruby_jump_tag); \
27
- \
28
- start_of_RUBY_TRY: \
29
- try
30
-
31
- /*! \def RUBY_RETHROW(ex)
32
- * \brief Given a Ruby exception as a VALUE, safely raise the exception as a
33
- * Ruby exception. This should be used inside a RUBY_TRY/RUBY_CATCH
34
- * block.
35
- */
36
- #define RUBY_RETHROW(ex) \
37
- Rice__ruby_exc = ex; \
38
- goto Rice__ruby_exception;
39
-
40
- /*! \def RUBY_CATCH
41
- * \brief End a RUBY_TRY block.
42
- */
43
- #define RUBY_CATCH \
44
- catch(::Rice::Exception const & ex) \
45
- { \
46
- RUBY_RETHROW(ex.value()); \
47
- } \
48
- catch(::Rice::Jump_Tag const & ex) \
49
- { \
50
- Rice__ruby_jump_tag = ex.tag; \
51
- goto Rice__ruby_jump_tag; \
52
- } \
53
- catch(std::bad_alloc const & ex) \
54
- { \
55
- /* This won't work quite right if the rb_exc_new2 fails; not */ \
56
- /* much we can do about that, since Ruby doesn't give us access */ \
57
- /* to a pre-allocated NoMemoryError object */ \
58
- RUBY_RETHROW(rb_exc_new2(rb_eNoMemError, ex.what())); \
59
- } \
60
- catch(std::invalid_argument const & ex) \
61
- { \
62
- /* This can raise a NoMemoryError in VERY rare circumstances */ \
63
- RUBY_RETHROW(rb_exc_new2(rb_eArgError, ex.what())); \
64
- } \
65
- catch(std::domain_error const & ex) \
66
- { \
67
- /* This can raise a NoMemoryError in VERY rare circumstances */ \
68
- RUBY_RETHROW(rb_exc_new2(rb_eFloatDomainError, ex.what())); \
69
- } \
70
- catch(std::out_of_range const & ex) \
71
- { \
72
- /* This can raise a NoMemoryError in VERY rare circumstances */ \
73
- RUBY_RETHROW(rb_exc_new2(rb_eRangeError, ex.what())); \
74
- } \
75
- catch(std::exception const & ex) \
76
- { \
77
- /* This can raise a NoMemoryError in VERY rare circumstances */ \
78
- RUBY_RETHROW(rb_exc_new2(rb_eRuntimeError, ex.what())); \
79
- } \
80
- catch(...) \
81
- { \
82
- RUBY_RETHROW(rb_exc_new2(rb_eRuntimeError, "unknown C++ exception thrown")); \
83
- } \
84
-
85
- #endif // Rice__ruby_try_catch__hpp_
86
-