rice 4.10.0 → 4.11.1

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 (67) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +61 -20
  3. data/include/rice/rice.hpp +446 -415
  4. data/include/rice/stl.hpp +38 -11
  5. data/lib/rice/version.rb +1 -1
  6. data/rice/Constructor.ipp +7 -4
  7. data/rice/Data_Object.ipp +1 -1
  8. data/rice/Data_Type.ipp +18 -3
  9. data/rice/Director.hpp +3 -8
  10. data/rice/Director.ipp +20 -0
  11. data/rice/Exception.hpp +1 -2
  12. data/rice/Exception.ipp +5 -4
  13. data/rice/Pin.ipp +9 -1
  14. data/rice/cpp_api/Array.hpp +4 -4
  15. data/rice/cpp_api/Array.ipp +12 -10
  16. data/rice/cpp_api/Hash.hpp +3 -4
  17. data/rice/cpp_api/Hash.ipp +6 -5
  18. data/rice/cpp_api/Module.hpp +4 -5
  19. data/rice/cpp_api/Module.ipp +0 -4
  20. data/rice/cpp_api/Object.hpp +19 -23
  21. data/rice/cpp_api/Object.ipp +54 -54
  22. data/rice/cpp_api/String.hpp +2 -2
  23. data/rice/cpp_api/String.ipp +14 -12
  24. data/rice/cpp_api/Struct.hpp +2 -2
  25. data/rice/cpp_api/Struct.ipp +7 -5
  26. data/rice/cpp_api/shared_methods.hpp +4 -4
  27. data/rice/detail/Anchor.hpp +2 -7
  28. data/rice/detail/Anchor.ipp +5 -8
  29. data/rice/detail/InstanceRegistry.hpp +14 -6
  30. data/rice/detail/InstanceRegistry.ipp +27 -25
  31. data/rice/detail/Parameter.ipp +4 -0
  32. data/rice/detail/Wrapper.hpp +5 -3
  33. data/rice/detail/Wrapper.ipp +55 -35
  34. data/rice/detail/cpp_protect.hpp +26 -16
  35. data/rice/rice.hpp +6 -5
  36. data/rice/stl/set.ipp +14 -3
  37. data/rice/stl/vector.ipp +24 -8
  38. data/rice/traits/function_traits.hpp +8 -0
  39. data/rice/traits/rice_traits.hpp +12 -1
  40. data/test/embed_ruby.cpp +1 -2
  41. data/test/test_Array.cpp +30 -5
  42. data/test/test_Callback.cpp +1 -1
  43. data/test/test_Class.cpp +24 -1
  44. data/test/test_Data_Type.cpp +6 -32
  45. data/test/test_Director.cpp +82 -32
  46. data/test/test_Exception.cpp +1 -1
  47. data/test/test_Hash.cpp +10 -0
  48. data/test/{test_Tracking.cpp → test_Instance_Registry.cpp} +81 -16
  49. data/test/test_Iterator.cpp +119 -98
  50. data/test/test_Object.cpp +21 -11
  51. data/test/test_Ownership.cpp +163 -0
  52. data/test/test_Stl_Function.cpp +1 -1
  53. data/test/test_Stl_Map.cpp +35 -1
  54. data/test/test_Stl_Multimap.cpp +34 -0
  55. data/test/test_Stl_OStream.cpp +1 -3
  56. data/test/test_Stl_Optional.cpp +3 -3
  57. data/test/test_Stl_Pair.cpp +36 -1
  58. data/test/test_Stl_Set.cpp +71 -0
  59. data/test/test_Stl_Unordered_Map.cpp +35 -1
  60. data/test/test_Stl_Variant.cpp +3 -3
  61. data/test/test_Stl_Vector.cpp +121 -17
  62. data/test/test_Struct.cpp +3 -3
  63. data/test/unittest.cpp +1 -1
  64. metadata +3 -5
  65. data/rice/cpp_api/Builtin_Object.hpp +0 -31
  66. data/rice/cpp_api/Builtin_Object.ipp +0 -37
  67. data/test/test_Builtin_Object.cpp +0 -97
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfec1a3dda6cae1e2a2e4ead3b3d6d856487a6d214ec89a2aa7c32cab9debf24
4
- data.tar.gz: 2bb3f7480a0ffcaee70ccc15ea7410c764a67b0b6d229300264570b1e58f8b59
3
+ metadata.gz: 935f187922d58bf0dc585e30ae66b5454bb8f87ac8c640ca38d9445371991dff
4
+ data.tar.gz: d00d336620c52f7e3a56941d6402109bcc20d3a73dc4090fd3d49395cbbdc7e7
5
5
  SHA512:
6
- metadata.gz: a6e7edb4a1332104c7e2a0bf616919ceef92fb4d87bbca650898c1a8e705df20f54a02a78372a1a9b66b499c6d1e4a47ed75e8a2e20ebbe57cbfa0c6cd9a953d
7
- data.tar.gz: 9ea2f5c76ccbb2d4a8e62ead7a796ad700ef77d07cf0c2fbc59b8c7626068225900009a861a654b95dd8476c80ba1e041c46b43f2969318479a28b12f7dc8678
6
+ metadata.gz: 9c006c97da6e586d836a08b51c2d1ed37e8921e11f0dc30f45d3fcfeb5166ae5172610b958e0b9fe35a8eddb199af05b88eec1bf272541b7a39d890b0856bacf
7
+ data.tar.gz: 7795809caf1d34330279d5fb454cb935b08422b531522d721d4ba3185442426d51fd1f8795dfbbbb34daff9a19d586e0e5554925d69eed7d57aebcbba9017a6a
data/CHANGELOG.md CHANGED
@@ -1,8 +1,36 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.11.1 (2026-02-18)
4
+
5
+ ### Enhancements
6
+
7
+ * Be more lenient on wrapp Qnil values in the C++ API
8
+
9
+
10
+ ## 4.11.0 (2026-02-17)
11
+
12
+ This release focuses on improving memory management.
13
+
14
+ ### Enhancements
15
+
16
+ * C++ API is now GC safe
17
+ * C++ API wrappers no longer default to rb_cObject, avoiding unintended Object changes
18
+ * Enable Instance Registry for Ruby owned C++ objects to avoid double frees
19
+
20
+ ### Breaking Changes
21
+
22
+ * `InstanceRegistry.isEnabled` (boolean) has been replaced by an `InstanceRegistry.isEnabled` which is an enum (`Off`, `Owned`, `All`).
23
+ * `InstanceRegistry` now defaults to `Owned` - previously it was disabled. The goal of this change is to ensure C++ objects owned by Ruby are only wrapped once to avoid double free errors.
24
+ * `Object()` now defaults to `Qnil` instead of `rb_cObject`. This avoids accidentally manipulating `rb_cObject` when a wrapper is not explicitly initialized. Calling methods on wrappers that point to `Qnil` will generally raise an exception. Use `object.is_nil()` to check for `nil` before using a wrapper as a receiver.
25
+ * C++ API wrappers now store their Ruby `VALUE` in a `Pin` instead of a raw `VALUE` field. Previously, wrappers were not GC-safe and Ruby could reclaim wrapped objects while C++ still referenced them. This is now fixed, and wrappers such as `Object` can be stored safely in containers like `std::vector`.
26
+ * The global `Object` constants (`Rice::Nil`, `Rice::True`, `Rice::False`, `Rice::Undef`) have been removed.
27
+ * `Object::test()` has been removed. Use `operator bool()` or `is_nil()` depending on the desired semantics.
28
+ * Remove `Builtin_Object` since it didn't serve a useful purpose
29
+
3
30
  ## 4.10.0 (2026-02-07)
4
31
 
5
- Enhancements:
32
+ ### Enhancements
33
+
6
34
  * Ruby 4.0 support
7
35
  * Support incomplete types (PIMPL/opaque handle patterns). Rice now uses `typeid(T*)` for forward-declared types that are never fully defined.
8
36
  * Support `noexcept` functions, static members, and static member functions
@@ -11,12 +39,11 @@ Enhancements:
11
39
  * Add `std::ostream`, `std::ostringstream`, and `std::ofstream`. Ruby can write to C++ streams and pass them to C++ functions. Standard streams are exposed as `Std::COUT` and `Std::CERR`.
12
40
  * Support verifying arrays of non-fundamental types (e.g., `MyClass[2]`)
13
41
  * Delegate method calls for smart pointers to their wrapped objects via method_missing?
14
-
15
- Internal:
16
42
  * Refactor type handling by merging `TypeMapper` into `TypeDetail` and simplifying class hierarchy
17
43
  * Greatly simplify define_attr
18
44
 
19
- Incompatible Changes:
45
+ ### Breaking Changes
46
+
20
47
  * `Address_Registration_Guard` has been replaced by `Pin`. If you are using `Address_Registration_Guard`
21
48
  to protect Ruby VALUEs from garbage collection, update your code to use `Pin` instead:
22
49
 
@@ -50,15 +77,18 @@ Incompatible Changes:
50
77
  * The `Data_Type<T>::define()` method has been removed. See the [Class Templates](bindings/class_templates.md) documentation for the recommended approach.
51
78
 
52
79
  ## 4.9.1 (2026-01-04)
80
+
53
81
  This release focuses on improving memory management for STL containers and attribute setters.
54
82
 
55
- Enhancements:
83
+ ### Enhancements
84
+
56
85
  * Support `takeOwnership` and `keepAlive` when setting attributes via `Arg("value").takeOwnership()` and `Arg("value").keepAlive()`
57
86
  * Add `Arg` parameter names to all STL container methods for keyword argument support
58
87
  * Add `keepAlive` support for STL container operations (vector push/insert, set insert, map/multimap store)
59
88
  * Add `keepAlive` for map/unordered_map/multimap keys to prevent GC of pointer-type keys
60
89
 
61
- Bug Fixes:
90
+ ### Fixes
91
+
62
92
  * Fix error when multiple overloaded methods take different types of vectors
63
93
  * Fix type unknown errors when using `std::shared_ptr` with g++
64
94
  * Fix CMake `_Ruby_DLEXT` variable type (string, not path)
@@ -66,6 +96,7 @@ Bug Fixes:
66
96
  * Fix incorrect attribute overloading behavior
67
97
 
68
98
  ## 4.9.0 (2026-01-01)
99
+
69
100
  This release revamps smart pointer support for `std::shared_ptr` and `std::unique_ptr`.
70
101
 
71
102
  Rice now always creates wrapper classes for smart pointers under the `Std` module (e.g., `Std::SharedPtr≺MyClass≻`, `Std::UniquePtr≺MyClass≻`). These wrapper classes expose methods like `empty?`, `get`, `swap`, and for shared_ptr, `use_count`. Methods defined on the managed type are automatically forwarded to the wrapper class using Ruby's `Forwardable` module.
@@ -73,7 +104,10 @@ Rice now always creates wrapper classes for smart pointers under the `Std` modul
73
104
  This change is backwards compatible for Ruby code but not C++ code. If you have implemented your own Smart Pointer wrapper then please read the Smart Pointer documentation for more information on how to update it.
74
105
 
75
106
  ## 4.8.0 (2025-12-29)
76
- This release focuses on making Rice easier to use:
107
+
108
+ This release focuses on making Rice easier to use.
109
+
110
+ ### Enhancements
77
111
 
78
112
  * Compilation times are approximately 2x faster than version 4.7
79
113
  * Compiled library sizes are about 30% smaller
@@ -91,7 +125,7 @@ This release focuses on making Rice easier to use:
91
125
  * Fixed Ruby detection for Homebrew installations on macOS
92
126
  * Added support for references to fundamental types
93
127
 
94
- However, these changes did require some breaking changes, which include:
128
+ ### Breaking Changes
95
129
 
96
130
  * `Return().isBuffer()` is replaced by `ReturnBuffer()`
97
131
  * `Arg("").isBuffer()` is replaced by `ArgBuffer("")`
@@ -100,13 +134,17 @@ However, these changes did require some breaking changes, which include:
100
134
  * All function/method parameter default values are verified. You may see errors like "ArgumentError: Type is not registered with Rice" or "Invalid AnyCast". In either case, make sure to check that specified default values are correct.
101
135
 
102
136
  ## 4.7.1 (2025-10-28)
103
- Updates:
137
+
138
+ ### Enhancements
139
+
104
140
  * Update overload resolution to take into account function arguments that are tagged as buffers via Arg("").setBuffer().
105
141
  * Make second parameter optional for Array#push and update docs
106
142
  * Remove ostruct runtime dependency
107
143
 
108
144
  ## 4.7.0 (2025-10-22)
109
- Updates:
145
+
146
+ ### Enhancements
147
+
110
148
  * Refactor Native wrappers - functions, methods, attributes and procs - to enable introspection API
111
149
  * Introduce Pointer<T> class to wrap pointers to fundamental types and arrays.
112
150
  * Add new methods Arg#setBuffer and Return#setBuffer to indicate that a C++ pointer references an array of objects versus a single object
@@ -124,13 +162,14 @@ Updates:
124
162
  * Correctly encode UTF8 Ruby class names in exception messages
125
163
  * Add support for disabling Ruby's global interpreter lock (GIL) when calling native functions
126
164
 
127
- Breaking Changes:
165
+ ### Breaking Changes
166
+
128
167
  * Custom implementations of From_Ruby must include a custom constructor:
129
- ```
168
+ ```cpp
130
169
  explicit From_Ruby(Arg* arg)
131
170
  ```
132
171
  * Custom implementations of To_Ruby must include a custom constructor:
133
- ```
172
+ ```cpp
134
173
  explicit To_Ruby(Return* returnInfo)
135
174
  ```
136
175
  * You can no longer pass a Buffer<T> to an API that takes a pointer. Instead use Buffer<T>#data or Buffer<T>::release
@@ -138,6 +177,7 @@ Breaking Changes:
138
177
  * Array#push requires a second argument.
139
178
 
140
179
  ## 4.6.1 (2025-06-25)
180
+
141
181
  * Improve attribute handling. Correctly deal with non-copyable/assignable attributes and return references instead of copies of objects
142
182
  * Improve Buffer implementation to deal with 4 cases:
143
183
  - array of fundamental types (int*)
@@ -148,6 +188,7 @@ Breaking Changes:
148
188
  * Fix header check on Ubuntu 22.04
149
189
 
150
190
  ## 4.6.0 (2025-06-09)
191
+
151
192
  Rice 4.6 is a major release that adds significant new functionality based on wrapping the OpenCV library, including:
152
193
 
153
194
  * Add a new Buffer class to provide Ruby API support for pointers sent to or returned by C++
@@ -171,6 +212,7 @@ Rice 4.6 is a major release that adds significant new functionality based on wra
171
212
  * Make Enums more useful by adding coerce method to enable stringing together bitwise operators - for example Season::Winter | Season::Spring | Season::Summer.
172
213
 
173
214
  ## 4.5 (2025-02-09)
215
+
174
216
  Rice 4.5 is a major release that adds significant new functionality, including:
175
217
 
176
218
  * Support method overloading
@@ -178,7 +220,7 @@ Rice 4.5 is a major release that adds significant new functionality, including:
178
220
  * Support rvalues
179
221
  * Support using keyword arguments in Ruby to call C++ methods
180
222
  * Support C style callbacks, including adding a new define_callback method
181
- * Support wrapping C/C++ functions as Ruby procs
223
+ * Support wrapping C/C++ functions as Ruby procs
182
224
  * Support calling methods that take pointers
183
225
  * Add Data_Type#define method to more easily support C++ template classes
184
226
  * Adds #define_constant method
@@ -244,7 +286,7 @@ Rice 4.1 builds on the 4.0 release and has a number of improvements that both po
244
286
 
245
287
  * Exception handlers are now registered globally versus per module. This requires updating code that calls Class#add_handler to use register_handler instead.
246
288
  * Rename Arg#isValue to Arg#setValue and then Arg#getIsValue to Arg#isValue
247
- * Rename Return#isValue to Return#setValue and Return#getIsValue to Return#isValue
289
+ * Rename Return#isValue to Return#setValue and Return#getIsValue to Return#isValue
248
290
 
249
291
  New or improved functionality includes:
250
292
 
@@ -267,7 +309,6 @@ New or improved functionality includes:
267
309
 
268
310
  Rice also includes experimental support for instance tracking so that Rice maps the same C++ instance to the same Ruby instance each time it is passed to Ruby. See the documentation for more information.
269
311
 
270
-
271
312
  ## 4.0 (2021-4-8)
272
313
 
273
314
  Rice 4.0 is a significant change from 3.0 and has multiple backwards-incompatible
@@ -313,10 +354,10 @@ There are a ton of changes, but some of the most important ones:
313
354
 
314
355
  ## 2.1.0 (2016-1-1)
315
356
 
316
- * Fix compliation issues related to g++ and Ruby 2.3.0
357
+ * Fix compliation issues related to g++ and Ruby 2.3.0.
317
358
  To do this, I had to remove Array::to_c_array which was exposing the internals of a
318
- Ruby RArray type to the system. This is not something that we should support going forward
319
- as these internals are going to change.
359
+ Ruby RArray type to the system. This is not something that we should support going forward
360
+ as these internals are going to change.
320
361
 
321
362
  ## 2.0.0 (2015-11-27)
322
363
 
@@ -333,7 +374,7 @@ There are a ton of changes, but some of the most important ones:
333
374
 
334
375
  ## 1.7.0 (2015-1-6)
335
376
 
336
- * Ruby 2.2 support
377
+ * Ruby 2.2 support.
337
378
  Potential breaking changes. Ruby 2.2 removed RHash as a public accessible struct
338
379
  and as such I changed all of the Builtin_Objects to work directly off of RObject
339
380
  instead of the specifics (RArray, RStruct, RString, etc). If you've been using these