rice 4.8.0 → 4.9.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 (68) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +25 -1
  3. data/CMakePresets.json +77 -50
  4. data/FindRuby.cmake +1 -1
  5. data/bin/rice-doc.rb +2 -0
  6. data/include/rice/api.hpp +14 -1
  7. data/include/rice/rice.hpp +351 -132
  8. data/include/rice/stl.hpp +319 -256
  9. data/lib/rice/doc/config.rb +57 -57
  10. data/lib/rice/doc/cpp_reference.rb +158 -158
  11. data/lib/rice/doc/doxygen.rb +289 -289
  12. data/lib/rice/doc/mkdocs.rb +332 -332
  13. data/lib/rice/doc/rice.rb +48 -47
  14. data/lib/rice/doc/ruby.rb +26 -26
  15. data/lib/rice/native.rb +15 -15
  16. data/lib/rice/native_registry.rb +12 -17
  17. data/lib/rice/parameter.rb +5 -5
  18. data/lib/rice/rbs.rb +72 -72
  19. data/lib/rice/version.rb +1 -1
  20. data/lib/rubygems/builder.rb +9 -9
  21. data/lib/rubygems_plugin.rb +8 -8
  22. data/rice/Data_Type.ipp +12 -7
  23. data/rice/cpp_api/Class.hpp +5 -0
  24. data/rice/cpp_api/Class.ipp +5 -0
  25. data/rice/cpp_api/Object.hpp +6 -0
  26. data/rice/cpp_api/Object.ipp +5 -0
  27. data/rice/detail/Forwards.hpp +18 -0
  28. data/rice/detail/Forwards.ipp +60 -0
  29. data/rice/detail/Native.ipp +2 -4
  30. data/rice/detail/NativeAttributeGet.ipp +1 -1
  31. data/rice/detail/NativeAttributeSet.hpp +5 -3
  32. data/rice/detail/NativeAttributeSet.ipp +41 -33
  33. data/rice/detail/NativeMethod.ipp +25 -22
  34. data/rice/detail/NativeRegistry.hpp +4 -2
  35. data/rice/detail/NativeRegistry.ipp +42 -9
  36. data/rice/detail/Parameter.ipp +3 -4
  37. data/rice/detail/Type.ipp +4 -0
  38. data/rice/detail/Wrapper.hpp +17 -12
  39. data/rice/detail/Wrapper.ipp +95 -36
  40. data/rice/rice.hpp +3 -0
  41. data/rice/rice_api/NativeRegistry.ipp +14 -1
  42. data/rice/stl/exception.ipp +1 -1
  43. data/rice/stl/filesystem.ipp +1 -1
  44. data/rice/stl/map.ipp +13 -11
  45. data/rice/stl/multimap.ipp +13 -11
  46. data/rice/stl/pair.ipp +14 -8
  47. data/rice/stl/set.ipp +16 -16
  48. data/rice/stl/shared_ptr.hpp +16 -0
  49. data/rice/stl/shared_ptr.ipp +74 -37
  50. data/rice/stl/type_index.ipp +1 -1
  51. data/rice/stl/unique_ptr.hpp +9 -3
  52. data/rice/stl/unique_ptr.ipp +80 -124
  53. data/rice/stl/unordered_map.ipp +14 -12
  54. data/rice/stl/vector.ipp +67 -31
  55. data/test/test_Attribute.cpp +72 -0
  56. data/test/test_Callback.cpp +3 -0
  57. data/test/test_Inheritance.cpp +14 -14
  58. data/test/test_Keep_Alive_No_Wrapper.cpp +6 -2
  59. data/test/test_Stl_Map.cpp +46 -0
  60. data/test/test_Stl_Multimap.cpp +46 -0
  61. data/test/test_Stl_Set.cpp +34 -0
  62. data/test/test_Stl_SharedPtr.cpp +160 -45
  63. data/test/test_Stl_UniquePtr.cpp +48 -3
  64. data/test/test_Stl_Unordered_Map.cpp +46 -0
  65. data/test/test_Stl_Variant.cpp +10 -14
  66. data/test/test_Stl_Vector.cpp +140 -13
  67. data/test/test_Tracking.cpp +3 -0
  68. metadata +3 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1cd8fd2c5aefe04f71129457cc7452fff163a593cd1395070760bd9914541414
4
- data.tar.gz: 3ca53fb0b47080e009e54b69678f30dfa039f8d68b44ec52a4ff6a95992234d1
3
+ metadata.gz: 6482695048d122782acef1d7ee310c47c85cff57eb39c8740db46013a4af0e87
4
+ data.tar.gz: a4b3c772ac9d5baff75ad80dbc404dde8a3fc67c821836203dfdcef948877091
5
5
  SHA512:
6
- metadata.gz: 30452135eabeac3550aa1d7cdfbf834434ad9548c2aaa556d960a57eee7a99518537cd77341a40b4ec61992457756dc710e60cee0753b6fd37ffc67bad0de5c1
7
- data.tar.gz: d0ebe6f3dde0820d27db562bde3960669581d6470552aa55d9ab8e20fb633600a1af0e154d14f27004ac8334d4fa3e658b0dcde5826b828572cd57ce4661a2fc
6
+ metadata.gz: 553618d580f7734d23a0c0278636fe725f48cacd68572fa9d6cee828fed68b2af84cda1fecdad4bb65633ada077bf4b34a703e2bd25173bd4f3ae0de91c54c26
7
+ data.tar.gz: '0368ac5a1d1d957ab8a94dcec8a25c6e5cc539930848db9f78077c6006b86a6d81299af839ab1daed52fab9ce743496cebcff6e3698483961c0fc6cc2bef82b4'
data/CHANGELOG.md CHANGED
@@ -1,4 +1,27 @@
1
- # Changelog
1
+ # Changelog
2
+
3
+ ## 4.9.1 (2026-01-04)
4
+ This release focuses on improving memory management for STL containers and attribute setters.
5
+
6
+ Enhancements:
7
+ * Support `takeOwnership` and `keepAlive` when setting attributes via `Arg("value").takeOwnership()` and `Arg("value").keepAlive()`
8
+ * Add `Arg` parameter names to all STL container methods for keyword argument support
9
+ * Add `keepAlive` support for STL container operations (vector push/insert, set insert, map/multimap store)
10
+ * Add `keepAlive` for map/unordered_map/multimap keys to prevent GC of pointer-type keys
11
+
12
+ Bug Fixes:
13
+ * Fix error when multiple overloaded methods take different types of vectors
14
+ * Fix type unknown errors when using `std::shared_ptr` with g++
15
+ * Fix CMake `_Ruby_DLEXT` variable type (string, not path)
16
+ * Fix crash caused by static variable in keepAlive implementation
17
+ * Fix incorrect attribute overloading behavior
18
+
19
+ ## 4.9.0 (2026-01-01)
20
+ This release revamps smart pointer support for `std::shared_ptr` and `std::unique_ptr`.
21
+
22
+ 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.
23
+
24
+ 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.
2
25
 
3
26
  ## 4.8.0 (2025-12-29)
4
27
  This release focuses on making Rice easier to use:
@@ -25,6 +48,7 @@ However, these changes did require some breaking changes, which include:
25
48
  * `Arg("").isBuffer()` is replaced by `ArgBuffer("")`
26
49
  * `Function().noGVL()` is replaced by `NoGvL()`
27
50
  * `is_convertible` methods must now return a `double` instead of a `Convertible` enum
51
+ * 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.
28
52
 
29
53
  ## 4.7.1 (2025-10-28)
30
54
  Updates:
data/CMakePresets.json CHANGED
@@ -6,7 +6,11 @@
6
6
  "hidden": true,
7
7
  "generator": "Ninja",
8
8
  "binaryDir": "${sourceDir}/build/${presetName}",
9
- "installDir": "${sourceDir}/install/${presetName}"
9
+ "installDir": "${sourceDir}/install/${presetName}",
10
+ "cacheVariables": {
11
+ "CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
12
+ "CMAKE_CXX_FLAGS": "-Wall -ftemplate-backtrace-limit=0 -fvisibility=hidden -fvisibility-inlines-hidden"
13
+ }
10
14
  },
11
15
  {
12
16
  "name": "linux-debug",
@@ -14,7 +18,7 @@
14
18
  "displayName": "Linux Debug",
15
19
  "cacheVariables": {
16
20
  "CMAKE_BUILD_TYPE": "Debug",
17
- "CMAKE_CXX_FLAGS": "-Wall -ftemplate-backtrace-limit=0 -Og"
21
+ "CMAKE_CXX_FLAGS_DEBUG": "-ggdb3 -O0 -fno-omit-frame-pointer -fno-inline -fno-optimize-sibling-calls"
18
22
  },
19
23
  "condition": {
20
24
  "type": "equals",
@@ -28,7 +32,9 @@
28
32
  "displayName": "Linux Release",
29
33
  "cacheVariables": {
30
34
  "CMAKE_BUILD_TYPE": "Release",
31
- "CMAKE_CXX_FLAGS": "-Wall -ftemplate-backtrace-limit=0 -O3 -DNDEBUG"
35
+ "CMAKE_CXX_FLAGS_RELEASE": "-O3 -DNDEBUG",
36
+ "CMAKE_INTERPROCEDURAL_OPTIMIZATION": "ON",
37
+ "CMAKE_SHARED_LINKER_FLAGS_RELEASE": "-Wl,--exclude-libs,ALL -Wl,--strip-all"
32
38
  },
33
39
  "condition": {
34
40
  "type": "equals",
@@ -42,7 +48,8 @@
42
48
  "displayName": "macOS Debug",
43
49
  "cacheVariables": {
44
50
  "CMAKE_BUILD_TYPE": "Debug",
45
- "CMAKE_CXX_FLAGS": "-Wall -Wno-unused-private-field -ftemplate-backtrace-limit=0 -Og"
51
+ "CMAKE_CXX_FLAGS": "-Wall -Wno-unused-private-field -ftemplate-backtrace-limit=0 -fvisibility=hidden -fvisibility-inlines-hidden",
52
+ "CMAKE_CXX_FLAGS_DEBUG": "-g3 -Og -fno-omit-frame-pointer -fno-inline -gsplit-dwarf"
46
53
  },
47
54
  "condition": {
48
55
  "type": "equals",
@@ -56,7 +63,10 @@
56
63
  "displayName": "macOS Release",
57
64
  "cacheVariables": {
58
65
  "CMAKE_BUILD_TYPE": "Release",
59
- "CMAKE_CXX_FLAGS": "-Wall -Wno-unused-private-field -ftemplate-backtrace-limit=0 -O3 -DNDEBUG"
66
+ "CMAKE_CXX_FLAGS": "-Wall -Wno-unused-private-field -ftemplate-backtrace-limit=0 -fvisibility=hidden -fvisibility-inlines-hidden",
67
+ "CMAKE_CXX_FLAGS_RELEASE": "-O3 -DNDEBUG",
68
+ "CMAKE_INTERPROCEDURAL_OPTIMIZATION": "ON",
69
+ "CMAKE_SHARED_LINKER_FLAGS_RELEASE": "-Wl,-dead_strip -Wl,-x"
60
70
  },
61
71
  "condition": {
62
72
  "type": "equals",
@@ -65,99 +75,116 @@
65
75
  }
66
76
  },
67
77
  {
68
- "name": "windows",
69
- "hidden": true,
78
+ "name": "mingw-debug",
79
+ "inherits": "base",
80
+ "displayName": "Mingw x64 Debug",
81
+ "cacheVariables": {
82
+ "CMAKE_BUILD_TYPE": "Debug",
83
+ "CMAKE_CXX_COMPILER": "g++.exe",
84
+ "CMAKE_CXX_FLAGS": "-Wall -ftemplate-backtrace-limit=0 -Wa,-mbig-obj -fvisibility=hidden -fvisibility-inlines-hidden",
85
+ "CMAKE_CXX_FLAGS_DEBUG": "-g3 -Og -fno-omit-frame-pointer -fno-inline -gsplit-dwarf"
86
+ },
87
+ "condition": {
88
+ "type": "equals",
89
+ "lhs": "${hostSystemName}",
90
+ "rhs": "Windows"
91
+ }
92
+ },
93
+ {
94
+ "name": "mingw-release",
70
95
  "inherits": "base",
96
+ "displayName": "Mingw x64 Release",
97
+ "cacheVariables": {
98
+ "CMAKE_BUILD_TYPE": "Release",
99
+ "CMAKE_CXX_COMPILER": "g++.exe",
100
+ "CMAKE_CXX_FLAGS": "-Wall -ftemplate-backtrace-limit=0 -Wa,-mbig-obj -fvisibility=hidden -fvisibility-inlines-hidden",
101
+ "CMAKE_CXX_FLAGS_RELEASE": "-O3 -DNDEBUG",
102
+ "CMAKE_SHARED_LINKER_FLAGS_RELEASE": "-Wl,--exclude-all-symbols"
103
+ },
71
104
  "condition": {
72
105
  "type": "equals",
73
106
  "lhs": "${hostSystemName}",
74
107
  "rhs": "Windows"
108
+ }
109
+ },
110
+ {
111
+ "name": "windows-base",
112
+ "hidden": true,
113
+ "generator": "Ninja",
114
+ "binaryDir": "${sourceDir}/build/${presetName}",
115
+ "installDir": "${sourceDir}/install/${presetName}",
116
+ "toolchainFile": "$env{VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake",
117
+ "cacheVariables": {
118
+ "CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
119
+ "CMAKE_CXX_FLAGS": "/EHs /W4 /bigobj /utf-8 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE"
75
120
  },
76
- "toolchainFile": "$env{VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake"
121
+ "condition": {
122
+ "type": "equals",
123
+ "lhs": "${hostSystemName}",
124
+ "rhs": "Windows"
125
+ }
77
126
  },
78
127
  {
79
128
  "name": "msvc-debug",
80
- "inherits": "windows",
129
+ "inherits": "windows-base",
81
130
  "displayName": "MSVC x64 Debug",
82
131
  "cacheVariables": {
83
132
  "CMAKE_BUILD_TYPE": "Debug",
84
133
  "CMAKE_CXX_COMPILER": "cl.exe",
85
- "CMAKE_CXX_FLAGS": "/EHs /W4 /bigobj /utf-8 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE",
86
- "CMAKE_MSVC_DEBUG_INFORMATION_FORMAT": "EditAndContinue"
134
+ "CMAKE_CXX_FLAGS_DEBUG": "/Od",
135
+ "CMAKE_MSVC_DEBUG_INFORMATION_FORMAT": "ProgramDatabase"
87
136
  }
88
137
  },
89
138
  {
90
139
  "name": "msvc-release",
91
- "inherits": "windows",
140
+ "inherits": "windows-base",
92
141
  "displayName": "MSVC x64 Release",
93
142
  "cacheVariables": {
94
143
  "CMAKE_BUILD_TYPE": "Release",
95
144
  "CMAKE_CXX_COMPILER": "cl.exe",
96
- "CMAKE_CXX_FLAGS": "/EHs /W4 /bigobj /utf-8 /O2 /DNDEBUG /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE",
145
+ "CMAKE_CXX_FLAGS_RELEASE": "/O2 /DNDEBUG",
146
+ "CMAKE_INTERPROCEDURAL_OPTIMIZATION": "ON",
97
147
  "CMAKE_MSVC_DEBUG_INFORMATION_FORMAT": "ProgramDatabase"
98
148
  }
99
149
  },
150
+
100
151
  {
101
152
  "name": "clang-windows-debug",
102
- "inherits": "windows",
153
+ "inherits": "windows-base",
103
154
  "displayName": "Clang Windows Debug",
104
155
  "cacheVariables": {
105
156
  "CMAKE_BUILD_TYPE": "Debug",
106
157
  "CMAKE_CXX_COMPILER": "clang-cl.exe",
107
- "CMAKE_CXX_FLAGS": "/EHs /W4 /bigobj /utf-8 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /clang:-Wno-unused-private-field"
158
+ "CMAKE_CXX_FLAGS": "/EHs /W4 /bigobj /utf-8 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /clang:-Wno-unused-private-field",
159
+ "CMAKE_CXX_FLAGS_DEBUG": "/Od /Zi"
108
160
  }
109
161
  },
110
162
  {
111
163
  "name": "clang-windows-release",
112
- "inherits": "windows",
164
+ "inherits": "windows-base",
113
165
  "displayName": "Clang Windows Release",
114
166
  "cacheVariables": {
115
167
  "CMAKE_BUILD_TYPE": "Release",
116
168
  "CMAKE_CXX_COMPILER": "clang-cl.exe",
117
- "CMAKE_CXX_FLAGS": "/EHs /W4 /bigobj /utf-8 /O2 /DNDEBUG /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /clang:-Wno-unused-private-field"
118
- }
119
- },
120
- {
121
- "name": "mingw-debug",
122
- "inherits": "base",
123
- "displayName": "Mingw x64 Debug",
124
- "cacheVariables": {
125
- "CMAKE_BUILD_TYPE": "Debug",
126
- "CMAKE_CXX_COMPILER": "g++.exe",
127
- "CMAKE_CXX_FLAGS": "-Wall -ftemplate-backtrace-limit=0 -Wa,-mbig-obj -Og"
128
- },
129
- "condition": {
130
- "type": "equals",
131
- "lhs": "${hostSystemName}",
132
- "rhs": "Windows"
133
- }
134
- },
135
- {
136
- "name": "mingw-release",
137
- "inherits": "base",
138
- "displayName": "Mingw x64 Release",
139
- "cacheVariables": {
140
- "CMAKE_BUILD_TYPE": "Release",
141
- "CMAKE_CXX_COMPILER": "g++.exe",
142
- "CMAKE_CXX_FLAGS": "-Wall -ftemplate-backtrace-limit=0 -Wa,-mbig-obj -O3 -DNDEBUG"
143
- },
144
- "condition": {
145
- "type": "equals",
146
- "lhs": "${hostSystemName}",
147
- "rhs": "Windows"
169
+ "CMAKE_CXX_FLAGS": "/EHs /W4 /bigobj /utf-8 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /clang:-Wno-unused-private-field",
170
+ "CMAKE_CXX_FLAGS_RELEASE": "/O2 /DNDEBUG",
171
+ "CMAKE_INTERPROCEDURAL_OPTIMIZATION": "ON"
148
172
  }
149
173
  }
150
174
  ],
175
+
151
176
  "buildPresets": [
152
177
  {
153
178
  "name": "linux-debug",
154
179
  "displayName": "Build Linux Debug",
155
- "configurePreset": "linux-debug"
180
+ "configurePreset": "linux-debug",
181
+ "jobs": 6
156
182
  },
157
183
  {
158
184
  "name": "linux-release",
159
185
  "displayName": "Build Linux Release",
160
- "configurePreset": "linux-release"
186
+ "configurePreset": "linux-release",
187
+ "jobs": 6
161
188
  },
162
189
  {
163
190
  "name": "macos-debug",
@@ -200,4 +227,4 @@
200
227
  "configurePreset": "mingw-release"
201
228
  }
202
229
  ]
203
- }
230
+ }
data/FindRuby.cmake CHANGED
@@ -428,7 +428,7 @@ if (Ruby_EXECUTABLE AND NOT Ruby_EXECUTABLE STREQUAL "${_Ruby_EXECUTABLE_LAST_QU
428
428
  set(_Ruby_POSSIBLE_LIB_DIR ${_Ruby_POSSIBLE_LIB_DIR} CACHE INTERNAL "The Ruby lib dir" FORCE)
429
429
  set(Ruby_RUBY_LIB_DIR ${Ruby_RUBY_LIB_DIR} CACHE INTERNAL "The Ruby ruby-lib dir" FORCE)
430
430
  set(_Ruby_SO_NAME ${_Ruby_SO_NAME} CACHE PATH "The Ruby shared library name" FORCE)
431
- set(_Ruby_DLEXT ${_Ruby_DLEXT} CACHE PATH "Ruby extensions extension" FORCE)
431
+ set(_Ruby_DLEXT ${_Ruby_DLEXT} CACHE STRING "Ruby extensions extension" FORCE)
432
432
  set(Ruby_SITEARCH_DIR ${Ruby_SITEARCH_DIR} CACHE INTERNAL "The Ruby site arch dir" FORCE)
433
433
  set(Ruby_SITELIB_DIR ${Ruby_SITELIB_DIR} CACHE INTERNAL "The Ruby site lib dir" FORCE)
434
434
  set(Ruby_HAS_VENDOR_RUBY ${Ruby_HAS_VENDOR_RUBY} CACHE BOOL "Vendor Ruby is available" FORCE)
data/bin/rice-doc.rb CHANGED
@@ -114,6 +114,8 @@ unless Dir.exist?(config.output)
114
114
  FileUtils.mkdir_p(config.output)
115
115
  end
116
116
 
117
+ # Add the extension directory the path in case it ships with extra libraries
118
+ ENV["PATH"] = "#{File.dirname(config.extension)}#{File::PATH_SEPARATOR}#{ENV["PATH"]}"
117
119
  # Load the extension
118
120
  require config.extension
119
121
 
data/include/rice/api.hpp CHANGED
@@ -79,7 +79,20 @@ inline void Init_Native_Registry()
79
79
  }
80
80
 
81
81
  return result;
82
- }, Arg("klass").setValue());
82
+ }, Arg("klass").setValue()).
83
+
84
+ define_method("lookup_by_kind", [](detail::NativeRegistry& self, VALUE klass, detail::NativeKind kind) -> Array
85
+ {
86
+ Array result;
87
+
88
+ const std::vector<detail::Native*> natives = self.lookup(klass, kind);
89
+ for (detail::Native* native : natives)
90
+ {
91
+ result.push(native, false);
92
+ }
93
+
94
+ return result;
95
+ }, Arg("klass").setValue(), Arg("kind"));
83
96
  }
84
97
 
85
98
  // ========= TypeRegistry.hpp =========