rice 4.6.1 → 4.7.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 (185) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +31 -0
  3. data/CMakeLists.txt +0 -4
  4. data/Rakefile +2 -8
  5. data/bin/rice-doc.rb +212 -0
  6. data/bin/rice-rbs.rb +93 -0
  7. data/include/rice/rice.hpp +4972 -4015
  8. data/include/rice/stl.hpp +822 -294
  9. data/lib/rice/doc/cpp_reference.rb +166 -0
  10. data/lib/rice/doc/doxygen.rb +294 -0
  11. data/lib/rice/doc/mkdocs.rb +298 -0
  12. data/lib/rice/doc/rice.rb +29 -0
  13. data/lib/rice/doc/ruby.rb +37 -0
  14. data/lib/rice/doc.rb +5 -0
  15. data/lib/{make_rice_headers.rb → rice/make_rice_headers.rb} +3 -0
  16. data/lib/rice/native.rb +18 -0
  17. data/lib/rice/native_registry.rb +21 -0
  18. data/lib/rice/parameter.rb +7 -0
  19. data/lib/rice/rbs.rb +104 -0
  20. data/lib/rice/version.rb +1 -1
  21. data/lib/rice.rb +4 -0
  22. data/lib/rubygems/cmake_builder.rb +24 -27
  23. data/rice/Arg.hpp +4 -4
  24. data/rice/Arg.ipp +4 -4
  25. data/rice/Buffer.hpp +32 -28
  26. data/rice/Buffer.ipp +306 -178
  27. data/rice/Data_Object.ipp +101 -82
  28. data/rice/Data_Type.hpp +5 -7
  29. data/rice/Data_Type.ipp +48 -29
  30. data/rice/Enum.ipp +15 -21
  31. data/rice/Function.hpp +17 -0
  32. data/rice/Function.ipp +13 -0
  33. data/rice/Pointer.hpp +15 -0
  34. data/rice/Pointer.ipp +49 -0
  35. data/rice/Return.hpp +1 -1
  36. data/rice/Return.ipp +2 -2
  37. data/rice/api.hpp +30 -0
  38. data/rice/cpp_api/Array.hpp +2 -2
  39. data/rice/cpp_api/Array.ipp +50 -5
  40. data/rice/cpp_api/Class.hpp +0 -5
  41. data/rice/cpp_api/Class.ipp +19 -0
  42. data/rice/cpp_api/Hash.ipp +20 -0
  43. data/rice/cpp_api/Module.hpp +6 -3
  44. data/rice/cpp_api/Module.ipp +49 -11
  45. data/rice/cpp_api/Object.ipp +31 -2
  46. data/rice/cpp_api/String.hpp +1 -2
  47. data/rice/cpp_api/String.ipp +21 -1
  48. data/rice/cpp_api/Struct.ipp +5 -0
  49. data/rice/cpp_api/Symbol.ipp +34 -0
  50. data/rice/cpp_api/shared_methods.hpp +12 -12
  51. data/rice/detail/MethodInfo.hpp +4 -2
  52. data/rice/detail/MethodInfo.ipp +19 -3
  53. data/rice/detail/ModuleRegistry.hpp +18 -0
  54. data/rice/detail/ModuleRegistry.ipp +25 -0
  55. data/rice/detail/Native.hpp +45 -2
  56. data/rice/detail/Native.ipp +196 -2
  57. data/rice/detail/NativeAttributeGet.hpp +9 -4
  58. data/rice/detail/NativeAttributeGet.ipp +65 -11
  59. data/rice/detail/NativeAttributeSet.hpp +4 -0
  60. data/rice/detail/NativeAttributeSet.ipp +30 -2
  61. data/rice/detail/NativeCallbackFFI.ipp +2 -2
  62. data/rice/detail/NativeCallbackSimple.ipp +1 -1
  63. data/rice/detail/NativeFunction.hpp +11 -49
  64. data/rice/detail/NativeFunction.ipp +82 -379
  65. data/rice/detail/NativeInvoker.hpp +74 -0
  66. data/rice/detail/NativeInvoker.ipp +197 -0
  67. data/rice/detail/NativeIterator.hpp +4 -0
  68. data/rice/detail/NativeIterator.ipp +19 -0
  69. data/rice/detail/NativeMethod.hpp +97 -0
  70. data/rice/detail/NativeMethod.ipp +332 -0
  71. data/rice/detail/NativeProc.hpp +51 -0
  72. data/rice/detail/NativeProc.ipp +133 -0
  73. data/rice/detail/NativeRegistry.hpp +8 -0
  74. data/rice/detail/NativeRegistry.ipp +27 -0
  75. data/rice/detail/Parameter.hpp +47 -0
  76. data/rice/detail/Parameter.ipp +105 -0
  77. data/rice/detail/Proc.ipp +14 -13
  78. data/rice/detail/Registries.hpp +1 -0
  79. data/rice/detail/RubyType.hpp +0 -2
  80. data/rice/detail/RubyType.ipp +15 -33
  81. data/rice/detail/Type.hpp +44 -8
  82. data/rice/detail/Type.ipp +151 -49
  83. data/rice/detail/TypeRegistry.hpp +3 -0
  84. data/rice/detail/TypeRegistry.ipp +17 -27
  85. data/rice/detail/Types.ipp +430 -0
  86. data/rice/detail/Wrapper.hpp +12 -0
  87. data/rice/detail/Wrapper.ipp +45 -2
  88. data/rice/detail/from_ruby.ipp +567 -1073
  89. data/rice/detail/ruby.hpp +1 -0
  90. data/rice/detail/to_ruby.ipp +4 -635
  91. data/rice/libc/file.ipp +3 -6
  92. data/rice/rice.hpp +22 -12
  93. data/rice/rice_api/Arg.hpp +7 -0
  94. data/rice/rice_api/Arg.ipp +9 -0
  95. data/rice/rice_api/ModuleRegistry.hpp +7 -0
  96. data/rice/rice_api/ModuleRegistry.ipp +10 -0
  97. data/rice/rice_api/Native.hpp +7 -0
  98. data/rice/rice_api/Native.ipp +52 -0
  99. data/rice/rice_api/NativeRegistry.hpp +7 -0
  100. data/rice/rice_api/NativeRegistry.ipp +21 -0
  101. data/rice/rice_api/Parameter.hpp +7 -0
  102. data/rice/rice_api/Parameter.ipp +11 -0
  103. data/rice/rice_api/Registries.hpp +6 -0
  104. data/rice/rice_api/Registries.ipp +12 -0
  105. data/rice/rice_api/TypeRegistry.hpp +7 -0
  106. data/rice/rice_api/TypeRegistry.ipp +10 -0
  107. data/rice/stl/complex.ipp +35 -0
  108. data/rice/stl/exception.ipp +20 -7
  109. data/rice/stl/filesystem.hpp +6 -0
  110. data/rice/stl/filesystem.ipp +34 -0
  111. data/rice/stl/map.ipp +13 -21
  112. data/rice/stl/monostate.ipp +37 -1
  113. data/rice/stl/multimap.ipp +17 -24
  114. data/rice/stl/optional.ipp +47 -2
  115. data/rice/stl/pair.ipp +23 -58
  116. data/rice/stl/reference_wrapper.ipp +22 -1
  117. data/rice/stl/set.ipp +17 -9
  118. data/rice/stl/shared_ptr.ipp +44 -17
  119. data/rice/stl/string.ipp +175 -7
  120. data/rice/stl/string_view.ipp +5 -0
  121. data/rice/stl/tuple.ipp +38 -9
  122. data/rice/stl/unique_ptr.ipp +46 -2
  123. data/rice/stl/unordered_map.ipp +13 -21
  124. data/rice/stl/variant.ipp +47 -11
  125. data/rice/stl/vector.ipp +183 -104
  126. data/rice/stl.hpp +1 -0
  127. data/rice/traits/function_traits.hpp +2 -2
  128. data/rice/traits/method_traits.hpp +5 -16
  129. data/rice/traits/rice_traits.hpp +24 -4
  130. data/rice.gemspec +11 -22
  131. data/test/embed_ruby.cpp +0 -3
  132. data/test/test_Array.cpp +38 -38
  133. data/test/test_Attribute.cpp +187 -2
  134. data/test/test_Buffer.cpp +302 -26
  135. data/test/test_Callback.cpp +2 -3
  136. data/test/test_Class.cpp +5 -5
  137. data/test/test_Data_Object.cpp +0 -55
  138. data/test/test_Data_Type.cpp +19 -30
  139. data/test/test_Enum.cpp +4 -46
  140. data/test/test_From_Ruby.cpp +88 -81
  141. data/test/test_GVL.cpp +109 -0
  142. data/test/test_Iterator.cpp +1 -1
  143. data/test/test_Keep_Alive_No_Wrapper.cpp +5 -3
  144. data/test/test_Module.cpp +8 -9
  145. data/test/test_Object.cpp +1 -1
  146. data/test/test_Overloads.cpp +3 -3
  147. data/test/test_Stl_Map.cpp +8 -8
  148. data/test/test_Stl_Multimap.cpp +4 -4
  149. data/test/test_Stl_Pair.cpp +5 -3
  150. data/test/test_Stl_SharedPtr.cpp +24 -12
  151. data/test/test_Stl_Tuple.cpp +1 -1
  152. data/test/test_Stl_UniquePtr.cpp +8 -0
  153. data/test/test_Stl_Unordered_Map.cpp +9 -9
  154. data/test/test_Stl_Variant.cpp +9 -3
  155. data/test/test_Stl_Vector.cpp +118 -13
  156. data/test/test_To_Ruby.cpp +35 -28
  157. data/test/test_Type.cpp +256 -53
  158. data/test/unittest.hpp +35 -0
  159. metadata +66 -34
  160. data/rice/Init.hpp +0 -8
  161. data/rice/Init.ipp +0 -8
  162. data/rice/detail/RubyFunction.hpp +0 -31
  163. data/rice/detail/RubyFunction.ipp +0 -77
  164. data/sample/callbacks/extconf.rb +0 -5
  165. data/sample/callbacks/sample_callbacks.cpp +0 -35
  166. data/sample/callbacks/test.rb +0 -28
  167. data/sample/enum/extconf.rb +0 -5
  168. data/sample/enum/sample_enum.cpp +0 -40
  169. data/sample/enum/test.rb +0 -8
  170. data/sample/inheritance/animals.cpp +0 -82
  171. data/sample/inheritance/extconf.rb +0 -5
  172. data/sample/inheritance/test.rb +0 -7
  173. data/sample/map/extconf.rb +0 -5
  174. data/sample/map/map.cpp +0 -73
  175. data/sample/map/test.rb +0 -7
  176. data/test/ext/t1/Foo.hpp +0 -10
  177. data/test/ext/t1/extconf.rb +0 -4
  178. data/test/ext/t1/t1.cpp +0 -13
  179. data/test/ext/t2/extconf.rb +0 -4
  180. data/test/ext/t2/t2.cpp +0 -11
  181. data/test/ruby/test_callbacks_sample.rb +0 -28
  182. data/test/ruby/test_multiple_extensions.rb +0 -18
  183. data/test/ruby/test_multiple_extensions_same_class.rb +0 -14
  184. data/test/ruby/test_multiple_extensions_with_inheritance.rb +0 -20
  185. /data/test/{test_Stl_Type.cpp → test_Stl_Type_Info.cpp} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7751b2018cc34ce9a256db07afdac1c1334f10df1c858e08943cfe65ccc3a0b0
4
- data.tar.gz: a8e25ea390438e8ba30450501f955724e25a1fe6fcdc9b0504a393ac60af9585
3
+ metadata.gz: 75730bdd1cda9ed1d24be45b32d1cbe92b6dca8e021fdb39a8b681403fc1814a
4
+ data.tar.gz: eb653e187ef8d543007ad0ceb3e5712869d598466c21997d2fd759699742df19
5
5
  SHA512:
6
- metadata.gz: 7ac0157d22f781cf34dd1d4704df142bc42e34d811c73c1e24ef3fbb3247161f2a0e76d80584aadc09eb6d97181dbb4a957518161a9afb89f61166cce08983bc
7
- data.tar.gz: 38e129eb196928cba4bf2f003651fc7e273df2abaf605664d76cd036993d70c507e4c31fa4e09e61252c8ef71aa701390c80a2247f20419e95d37a674002be26
6
+ metadata.gz: 7c6a0d269f24af26c836ca71a7684d410d823a6661a26af1bb1ddb205b65067258119d49bcadabe9aa806884a4505213e5489d5638cdd3420b4edccd59e49928
7
+ data.tar.gz: 1a14760fb0e2903c594ae0e0a3d14077a806bf59c720323a30c6a8bc4958a0e35fd0c0436eedcd6b4a6451e8a7344098be0bab00113964127b4027c790159910
data/CHANGELOG.md CHANGED
@@ -1,3 +1,34 @@
1
+ ## 4.7.0 (2025-10-22)
2
+ Updates:
3
+ * Refactor Native wrappers - functions, methods, attributes and procs - to enable introspection API
4
+ * Introduce Pointer<T> class to wrap pointers to fundamental types and arrays.
5
+ * Add new methods Arg#setBuffer and Return#setBuffer to indicate that a C++ pointer references an array of objects versus a single object
6
+ * Add a new Introspection API that exposes Rice internals to Ruby
7
+ * Using the Introspection API, add support for generating RBS files for extensions. See bin/rice-rbs.rb
8
+ * Using the Introspection API, add support for generating Markdown documentation for extensions. See bin/rice-doc.rb
9
+ * Don't create attribute writers for const attributes
10
+ * Support attribute setters for Enums
11
+ * Support wrapping std::vector<std::unique_ptr<T>>
12
+ * Update Array#push to not always copy C++ instances. This lays the foundation for extracting references and pointers from tuples, variants and optionals.
13
+ * Add very basic support for creating std::filesystem::path instances
14
+ * Remove toy samples and test libraries. These will be replaced by a new gem that wraps the BitMapPlusPlus library (https://github.com/baderouaich/BitmapPlusPlus)
15
+ * Add support for std::runtime_error since some libraries use that as a base exception class (thus when Rice wraps custom exceptions it also needs to wrap the base class)
16
+ * Improve std::vector indexing to more closely match Ruby for negative index values
17
+ * Correctly encode UTF8 Ruby class names in exception messages
18
+ * Add support for disabling Ruby's global interpreter lock (GIL) when calling native functions
19
+
20
+ Breaking Changes:
21
+ * Custom implementations of From_Ruby must include a custom constructor:
22
+ ```
23
+ explicit From_Ruby(Arg* arg)
24
+ ```
25
+ * Custom implementations of To_Ruby must include a custom constructor:
26
+ ```
27
+ explicit To_Ruby(Return* returnInfo)
28
+ ```
29
+ * You can no longer pass a Buffer<T> to an API that takes a pointer. Instead use Buffer<T>#data or Buffer<T>::release
30
+ * The Rice_Init method has been removed.
31
+
1
32
  ## 4.6.1 (2025-06-25)
2
33
  * Improve attribute handling. Correctly deal with non-copyable/assignable attributes and return references instead of copies of objects
3
34
  * Improve Buffer implementation to deal with 4 cases:
data/CMakeLists.txt CHANGED
@@ -25,7 +25,3 @@ endif ()
25
25
 
26
26
  # Include sub-projects.
27
27
  add_subdirectory ("test")
28
- add_subdirectory ("sample/callbacks")
29
- add_subdirectory ("sample/enum")
30
- add_subdirectory ("sample/inheritance")
31
- add_subdirectory ("sample/map")
data/Rakefile CHANGED
@@ -17,13 +17,7 @@ is_mswin = !RbConfig::CONFIG['host_os'].match(/mswin/).nil?
17
17
  MAKE = is_mswin ? 'nmake' : 'make'
18
18
 
19
19
  unittest = File.join(__dir__, "test", "unittest#{RbConfig::CONFIG['EXEEXT']}")
20
- sample_callbacks = File.join(__dir__, "sample", "callbacks", "sample_callbacks.so")
21
- sample_enum = File.join(__dir__, "sample", "enum", "sample_enum.so")
22
- sample_inheritance = File.join(__dir__, "sample", "inheritance", "animals.so")
23
- sample_map = File.join(__dir__, "sample", "map", "map.so")
24
- test_ext1 = File.join(__dir__, "test", "ext", "t1", "t1.so")
25
- test_ext2 = File.join(__dir__, "test", "ext", "t2", "t2.so")
26
- binaries = [unittest, sample_callbacks, sample_enum, sample_inheritance, sample_map, test_ext1, test_ext2]
20
+ binaries = [unittest]
27
21
 
28
22
  binaries.each do |asset|
29
23
  file asset do
@@ -90,7 +84,7 @@ FileUtils.mkdir_p(include_dir) #unless File.exists?('include')
90
84
  desc "Update rice header files"
91
85
  task :headers do
92
86
  FileUtils.rm_rf(File.join(include_dir, "rice", "*"))
93
- path = File.join(__dir__, 'lib', 'make_rice_headers.rb')
87
+ path = File.join(__dir__, 'lib', 'rice', 'make_rice_headers.rb')
94
88
  # Execute make_rice_headers.rb
95
89
  run_command(Gem.ruby, path)
96
90
  end
data/bin/rice-doc.rb ADDED
@@ -0,0 +1,212 @@
1
+ require 'libxml-ruby'
2
+
3
+ # Require rice
4
+ require_relative '../lib/rice'
5
+ require_relative '../lib/rice/doc'
6
+
7
+ # Now setup option parser
8
+ require 'ostruct'
9
+ require 'optparse'
10
+
11
+ module Rice
12
+ # == Synopsis
13
+ #
14
+ # Generates Mkdocs for a Rice extension
15
+ #
16
+ # == Usage
17
+ # rice-doc [options] <rice_extension_library>
18
+ #
19
+ # Options:
20
+ # -o, --output=path Output directory
21
+ # -v, --version Show version (1.1.0)
22
+ # -h, --help Show help message
23
+
24
+ class Cmd
25
+ # :enddoc:
26
+ attr_accessor :options
27
+
28
+ def option_parser
29
+ OptionParser.new do |opts|
30
+ opts.banner = "rice-doc #{Rice::VERSION}\n" +
31
+ "Usage: rice-doc [options] <rice_extension_library_path>"
32
+
33
+ opts.separator ""
34
+ opts.separator "Options:"
35
+
36
+ opts.on('-o path', '--output=path',
37
+ 'Output generated mkdoc files to the specified directory') do |dir|
38
+ options.output = File.expand_path(dir)
39
+ end
40
+
41
+ opts.on_tail("-v version", "--version", "Show version (#{Rice::VERSION})") do
42
+ puts "ruby_prof " + Rice::VERSION
43
+ exit
44
+ end
45
+
46
+ opts.on_tail("-h", "--help", "Show help message") do
47
+ puts opts
48
+ exit
49
+ end
50
+ end
51
+ end
52
+
53
+ def parse_args
54
+ @options = OpenStruct.new
55
+ options.extension = nil
56
+ options.output = nil
57
+
58
+ # Make sure the user specified at least one file
59
+ if ARGV.length < 1 and not options.exec
60
+ puts self.option_parser
61
+ puts ""
62
+ puts "Must specify a rice extension"
63
+ exit(-1)
64
+ end
65
+
66
+ self.option_parser.parse! ARGV
67
+
68
+ if options.output.nil?
69
+ puts "Must specify an output directory with -o/--output option"
70
+ exit(-1)
71
+ elsif !Dir.exist?(options.output)
72
+ puts "Creating output directory '#{options.output}'"
73
+ Dir.mkdir(options.output)
74
+ end
75
+
76
+ options.extension = ARGV.shift
77
+
78
+ options
79
+ rescue OptionParser::InvalidOption, OptionParser::InvalidArgument, OptionParser::MissingArgument => e
80
+ puts self.option_parser
81
+ puts e.message
82
+ exit(-1)
83
+ end
84
+ end
85
+ end
86
+
87
+ # Parse command line options
88
+ cmd = Rice::Cmd.new
89
+ options = cmd.parse_args
90
+
91
+ # Load the extension
92
+ require options.extension
93
+
94
+ # Get modules and classes
95
+ modules = Rice::Registries.instance.modules.modules
96
+ klasses = Rice::Registries.instance.types.klasses
97
+
98
+ # Doxygen documentation
99
+ doxygen_root = "https://docs.opencv.org/4.x"
100
+ doxygen_index = "https://docs.opencv.org/4.x/opencv.tag"
101
+ #doxygen_index = "c:/Users/cfis/Downloads/opencv.tag"
102
+ type_mappings = {/^enum\s*/i => '',
103
+ /^union\s*/i => '',
104
+ /<.*>/ => '',
105
+ '::debug_build_guard' => ''}
106
+
107
+ method_mappings = {'Cv' => {'agast' => 'AGAST',
108
+ 'approx_poly_dp' => 'approxPolyDP',
109
+ 'calc_optical_flow_pyr_lk' => 'calcOpticalFlowPyrLK',
110
+ 'calibrate_camera_ro' => 'calibrateCameraRO',
111
+ 'cam_shift' => 'CamShift',
112
+ 'compose_rt' => 'composeRT',
113
+ 'compute_ecc' => 'computeECC',
114
+ 'create_clahe' => 'createCLAHE',
115
+ 'current_ui_framework' => 'currentUIFramework',
116
+ 'create_align_mtb' => 'createAlignMTB',
117
+ 'create_background_subtractor_knn' => 'createBackgroundSubtractorKNN',
118
+ 'create_background_subtractor_mog2' => 'createBackgroundSubtractorMOG2',
119
+ 'denoise_tvl1' => 'denoise_TVL1',
120
+ 'emd' => 'EMD',
121
+ 'estimate_affine_2d' => 'estimateAffine2D',
122
+ 'estimate_affine_partial_2d' => 'estimateAffinePartial2D',
123
+ 'fast' => 'FAST',
124
+ 'filter_2d' => 'filter2D',
125
+ 'find_chessboard_corners_sb?' => 'findChessboardCornersSB',
126
+ 'find_transform_ecc' => 'findTransformECC',
127
+ 'fit_ellipse_ams' => 'fitEllipseAMS',
128
+ 'flip_nd' => 'flipND',
129
+ 'gaussian_blur' => 'GaussianBlur',
130
+ 'get_cpu_features_line' => 'getCPUFeaturesLine',
131
+ 'get_cpu_tick_count' => 'getCPUTickCount',
132
+ 'get_number_of_cp_us' => 'getNumberOfCPUs',
133
+ 'get_optimal_dft_size' => 'getOptimalDFTSize',
134
+ 'get_rotation_matrix_2d' => 'getRotationMatrix2D',
135
+ 'get_valid_disparity_roi' => 'getValidDisparityROI',
136
+ 'group_rectangles_meanshift' => 'groupRectangles_meanshift',
137
+ 'have_open_vx?' => 'haveOpenVX',
138
+ 'hough_circles' => 'HoughCircles',
139
+ 'hough_lines' => 'HoughLines',
140
+ 'hough_lines_p' => 'HoughLinesP',
141
+ 'hough_lines_point_set' => 'HoughLinesPointSet',
142
+ 'hu_moments' => 'HuMoments',
143
+ 'init_camera_matrix_2d' => 'initCameraMatrix2D',
144
+ 'lu' => 'LU',
145
+ 'lut' => 'LUT',
146
+ 'pca_back_project' => 'PCABackProject',
147
+ 'pca_compute' => 'PCACompute',
148
+ 'pca_project' => 'PCAProject',
149
+ 'psnr' => 'PSNR',
150
+ 'rq_decomp3x3' => 'RQDecomp3x3',
151
+ 'select_roi ' => 'selectROI',
152
+ 'sep_filter_2d' => 'sepFilter2D',
153
+ 'set_rng_seed' => 'setRNGSeed',
154
+ 'set_use_open_vx' => 'setUseOpenVX',
155
+ 'solve_lp' => 'solveLP',
156
+ 'solve_pn_p_refine_lm' => 'solvePnPRefineLM',
157
+ 'solve_pn_p_refine_vvs' => 'solvePnPRefineVVS',
158
+ 'sv_back_subst' => 'SVBackSubst',
159
+ 'sv_decomp' => 'SVDecomp',
160
+ 'the_rng' => 'theRNG',
161
+ 'transpose_nd' => 'transposeND',
162
+ 'use_open_vx?' => 'useOpenVX',
163
+ 'wrapper_emd' => 'wrapperEMD'},
164
+ 'Cv::AsyncArray' => {'_get_impl' => '_getImpl',
165
+ 'wait_for?' => 'wait_for'},
166
+ 'Cv::BackgroundSubtractorKNN' => {'getk_nn_samples' => 'getkNNSamples',
167
+ 'setk_nn_samples' => 'setkNNSamples'},
168
+ 'Cv::Cuda::DeviceInfo' => {'device_id' => 'deviceID',
169
+ 'ecc_enabled?' => 'ECCEnabled',
170
+ 'max_surface_2d' => 'maxSurface2D',
171
+ 'max_texture_2d' => 'maxTexture2D',
172
+ 'pci_bus_id' => 'pciBusID',
173
+ 'pci_device_id' => 'pciDeviceID',
174
+ 'pci_domain_id' => 'pciDomainID'},
175
+ 'Cv::Cuda::GpuMat' => {'adjust_roi' => 'adjustROI',
176
+ 'locate_roi' => 'locateROI'},
177
+ 'Cv::Cuda::GpuMatND' => {'to_gpu_mat' => 'operator GpuMat'},
178
+ 'Cv::FaceDetectorYN' => {'get_nms_threshold' => 'getNMSThreshold'},
179
+ 'Cv::FaceRecognizerSF' => {'set_nms_threshold' => 'setNMSThreshold'},
180
+ 'Cv::HOGDescriptor' => {'detect_multi_scale_roi' => 'detectMultiScaleROI',
181
+ 'detect_roi' => 'detectROI'},
182
+ 'Cv::HOGDescriptor::DescriptorStorageFormat' => {'set_svm_detector' => 'setSVMDetector'},
183
+ 'Cv::Hfloat' => {'to_float' => 'operator float'},
184
+ 'Cv::Mat' => {'locate_roi' => 'locateROI'},
185
+ 'Cv::Ml::ANN_MLP' => {'get_rprop_dw0' => 'getRpropDW0',
186
+ 'get_rprop_dw_max' => 'getRpropDWMax',
187
+ 'get_rprop_dw_min' => 'getRpropDWMin',
188
+ 'get_rprop_dw_minus' => 'getRpropDWMinus',
189
+ 'get_rprop_dw_plus' => 'getRpropDWPlus',
190
+ 'set_anneal_energy_rng' => 'setAnnealEnergyRNG',
191
+ 'set_rprop_dw0' => 'setRpropDW0',
192
+ 'set_rprop_dw_max' => 'setRpropDWMax',
193
+ 'set_rprop_dw_min' => 'setRpropDWMin',
194
+ 'set_rprop_dw_minus' => 'setRpropDWMinus',
195
+ 'set_rprop_dw_plus' => 'setRpropDWPlus'},
196
+ 'Cv::Ml::DTrees' => {'get_cv_folds' => 'getCVFolds',
197
+ 'get_use1_se_rule?' => 'getUse1SERule',
198
+ 'set_cv_folds' => 'setCVFolds',
199
+ 'set_use1_se_rule' => 'setUse1SERule'},
200
+ 'Cv::Ml::RTrees' => {'get_oob_error' => 'getOOBError'}
201
+ }
202
+
203
+ doxygen_resolver = Rice::Doc::Doxygen.new(doxygen_root, doxygen_index, type_mappings, method_mappings)
204
+
205
+ # Setup resolvers per namespace
206
+ resolvers = {nil => Rice::Doc::Ruby.new,
207
+ 'Cv' => doxygen_resolver,
208
+ 'Rice' => Rice::Doc::Rice.new,
209
+ 'Std' => Rice::Doc::CppReference.new}
210
+
211
+ generator = Rice::Doc::Mkdocs.new(modules + klasses, resolvers, options.output)
212
+ generator.generate
data/bin/rice-rbs.rb ADDED
@@ -0,0 +1,93 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+
5
+ # Require rice
6
+ require 'rice'
7
+
8
+ # Now setup option parser
9
+ require 'ostruct'
10
+ require 'optparse'
11
+
12
+ module Rice
13
+ # == Synopsis
14
+ #
15
+ # Generates rbs files for a Rice extension
16
+ #
17
+ # == Usage
18
+ # rice-rbs [options] <rice_extension_library>
19
+ #
20
+ # Options:
21
+ # -o, --output=path Output directory
22
+ # -v, --version Show version (1.1.0)
23
+ # -h, --help Show help message
24
+
25
+ class Cmd
26
+ # :enddoc:
27
+ attr_accessor :options
28
+
29
+ def option_parser
30
+ OptionParser.new do |opts|
31
+ opts.banner = "rice-rbs #{Rice::VERSION}\n" +
32
+ "Usage: rice-rbs [options] <rice_extension_library_path>"
33
+
34
+ opts.separator ""
35
+ opts.separator "Options:"
36
+
37
+ opts.on('-o path', '--output=path',
38
+ 'Output generated Rbs files to the specified directory') do |dir|
39
+ options.output = File.expand_path(dir)
40
+ end
41
+
42
+ opts.on_tail("-v version", "--version", "Show version (#{Rice::VERSION})") do
43
+ puts "ruby_prof " + Rice::VERSION
44
+ exit
45
+ end
46
+
47
+ opts.on_tail("-h", "--help", "Show help message") do
48
+ puts opts
49
+ exit
50
+ end
51
+ end
52
+ end
53
+
54
+ def parse_args
55
+ @options = OpenStruct.new
56
+ options.extension = nil
57
+ options.output = nil
58
+
59
+ # Make sure the user specified at least one file
60
+ if ARGV.length < 1 and not options.exec
61
+ puts self.option_parser
62
+ puts ""
63
+ puts "Must specify a rice extension"
64
+ exit(-1)
65
+ end
66
+
67
+ self.option_parser.parse! ARGV
68
+
69
+ if options.output.nil?
70
+ puts "Must specify an output directory with -o/--output option"
71
+ exit(-1)
72
+ elsif !Dir.exist?(options.output)
73
+ puts "Creating output directory '#{options.output}'"
74
+ Dir.mkdir(options.output)
75
+ end
76
+
77
+ options.extension = ARGV.shift
78
+
79
+ options
80
+ rescue OptionParser::InvalidOption, OptionParser::InvalidArgument, OptionParser::MissingArgument => e
81
+ puts self.option_parser
82
+ puts e.message
83
+ exit(-1)
84
+ end
85
+ end
86
+ end
87
+
88
+ # Parse command line options
89
+ cmd = Rice::Cmd.new
90
+ options = cmd.parse_args
91
+
92
+ rbs = Rice::Rbs.new(options.extension, options.output)
93
+ rbs.generate