rice 4.7.0 → 4.8.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 (155) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +36 -1
  3. data/CMakeLists.txt +14 -22
  4. data/CMakePresets.json +203 -75
  5. data/FindRuby.cmake +358 -123
  6. data/bin/rice-doc.rb +56 -142
  7. data/bin/rice-rbs.rb +1 -2
  8. data/include/rice/api.hpp +248 -0
  9. data/include/rice/rice.hpp +2281 -1668
  10. data/include/rice/stl.hpp +364 -443
  11. data/lib/rice/doc/config.rb +70 -0
  12. data/lib/rice/doc/cpp_reference.rb +1 -4
  13. data/lib/rice/doc/mkdocs.rb +58 -20
  14. data/lib/rice/doc/rice.rb +20 -0
  15. data/lib/rice/doc.rb +1 -0
  16. data/lib/rice/make_rice_headers.rb +7 -0
  17. data/lib/rice/native_registry.rb +2 -2
  18. data/lib/rice/rbs.rb +4 -4
  19. data/lib/rice/version.rb +1 -1
  20. data/lib/rubygems_plugin.rb +12 -9
  21. data/rice/Arg.hpp +12 -6
  22. data/rice/Arg.ipp +14 -7
  23. data/rice/Buffer.ipp +44 -40
  24. data/rice/Callback.hpp +1 -1
  25. data/rice/Callback.ipp +2 -7
  26. data/rice/Constructor.hpp +1 -1
  27. data/rice/Constructor.ipp +11 -11
  28. data/rice/Data_Object.ipp +59 -30
  29. data/rice/Data_Type.hpp +9 -10
  30. data/rice/Data_Type.ipp +22 -25
  31. data/rice/Director.hpp +1 -0
  32. data/rice/Enum.ipp +58 -39
  33. data/rice/Exception.hpp +4 -4
  34. data/rice/Exception.ipp +7 -7
  35. data/rice/NoGVL.hpp +13 -0
  36. data/rice/Reference.hpp +56 -0
  37. data/rice/Reference.ipp +96 -0
  38. data/rice/Return.hpp +4 -1
  39. data/rice/Return.ipp +0 -6
  40. data/rice/cpp_api/Array.hpp +44 -7
  41. data/rice/cpp_api/Array.ipp +105 -9
  42. data/rice/cpp_api/Class.hpp +2 -2
  43. data/rice/cpp_api/Class.ipp +4 -4
  44. data/rice/cpp_api/Hash.ipp +7 -4
  45. data/rice/cpp_api/Module.hpp +4 -4
  46. data/rice/cpp_api/Module.ipp +12 -10
  47. data/rice/cpp_api/Object.hpp +4 -4
  48. data/rice/cpp_api/Object.ipp +15 -12
  49. data/rice/cpp_api/String.hpp +2 -2
  50. data/rice/cpp_api/String.ipp +11 -8
  51. data/rice/cpp_api/Symbol.ipp +16 -7
  52. data/rice/cpp_api/shared_methods.hpp +5 -9
  53. data/rice/detail/InstanceRegistry.hpp +0 -2
  54. data/rice/detail/Native.hpp +31 -21
  55. data/rice/detail/Native.ipp +281 -133
  56. data/rice/detail/NativeAttributeGet.hpp +5 -7
  57. data/rice/detail/NativeAttributeGet.ipp +26 -26
  58. data/rice/detail/NativeAttributeSet.hpp +2 -4
  59. data/rice/detail/NativeAttributeSet.ipp +20 -16
  60. data/rice/detail/NativeCallback.hpp +77 -0
  61. data/rice/detail/NativeCallback.ipp +280 -0
  62. data/rice/detail/NativeFunction.hpp +11 -21
  63. data/rice/detail/NativeFunction.ipp +58 -119
  64. data/rice/detail/NativeInvoker.hpp +4 -4
  65. data/rice/detail/NativeInvoker.ipp +7 -7
  66. data/rice/detail/NativeIterator.hpp +2 -4
  67. data/rice/detail/NativeIterator.ipp +18 -14
  68. data/rice/detail/NativeMethod.hpp +10 -20
  69. data/rice/detail/NativeMethod.ipp +54 -114
  70. data/rice/detail/NativeProc.hpp +5 -7
  71. data/rice/detail/NativeProc.ipp +39 -28
  72. data/rice/detail/NativeRegistry.hpp +0 -1
  73. data/rice/detail/NativeRegistry.ipp +0 -1
  74. data/rice/detail/Parameter.hpp +15 -8
  75. data/rice/detail/Parameter.ipp +102 -43
  76. data/rice/detail/Proc.ipp +14 -28
  77. data/rice/detail/RubyType.ipp +2 -53
  78. data/rice/detail/Type.hpp +23 -7
  79. data/rice/detail/Type.ipp +73 -93
  80. data/rice/detail/TypeRegistry.ipp +5 -4
  81. data/rice/detail/Wrapper.hpp +1 -1
  82. data/rice/detail/Wrapper.ipp +18 -10
  83. data/rice/detail/from_ruby.hpp +8 -6
  84. data/rice/detail/from_ruby.ipp +306 -173
  85. data/rice/detail/ruby.hpp +23 -0
  86. data/rice/libc/file.hpp +4 -4
  87. data/rice/rice.hpp +6 -8
  88. data/rice/rice_api/Native.ipp +5 -1
  89. data/rice/rice_api/Parameter.ipp +1 -1
  90. data/rice/ruby_mark.hpp +2 -1
  91. data/rice/stl/complex.ipp +12 -8
  92. data/rice/stl/map.ipp +27 -22
  93. data/rice/stl/monostate.ipp +16 -12
  94. data/rice/stl/multimap.hpp +0 -2
  95. data/rice/stl/multimap.ipp +27 -22
  96. data/rice/stl/optional.ipp +27 -11
  97. data/rice/stl/pair.ipp +5 -5
  98. data/rice/stl/reference_wrapper.ipp +5 -4
  99. data/rice/stl/set.ipp +16 -16
  100. data/rice/stl/shared_ptr.hpp +0 -16
  101. data/rice/stl/shared_ptr.ipp +34 -190
  102. data/rice/stl/string.ipp +18 -18
  103. data/rice/stl/string_view.ipp +19 -1
  104. data/rice/stl/tuple.ipp +15 -36
  105. data/rice/stl/unique_ptr.ipp +18 -8
  106. data/rice/stl/unordered_map.ipp +20 -15
  107. data/rice/stl/variant.ipp +37 -21
  108. data/rice/stl/vector.ipp +41 -36
  109. data/rice/traits/function_traits.hpp +19 -19
  110. data/rice/traits/method_traits.hpp +4 -4
  111. data/rice/traits/rice_traits.hpp +162 -39
  112. data/rice.gemspec +1 -4
  113. data/test/test_Array.cpp +261 -3
  114. data/test/test_Attribute.cpp +6 -3
  115. data/test/test_Buffer.cpp +6 -42
  116. data/test/test_Callback.cpp +77 -23
  117. data/test/test_Data_Object.cpp +2 -2
  118. data/test/test_Data_Type.cpp +23 -23
  119. data/test/test_Director.cpp +2 -4
  120. data/test/test_Enum.cpp +34 -5
  121. data/test/test_File.cpp +9 -5
  122. data/test/test_From_Ruby.cpp +7 -6
  123. data/test/test_GVL.cpp +3 -3
  124. data/test/test_Hash.cpp +1 -1
  125. data/test/test_Iterator.cpp +54 -22
  126. data/test/test_Keep_Alive.cpp +1 -1
  127. data/test/test_Keep_Alive_No_Wrapper.cpp +1 -1
  128. data/test/test_Module.cpp +5 -5
  129. data/test/test_Overloads.cpp +395 -50
  130. data/test/test_Proc.cpp +54 -0
  131. data/test/test_Reference.cpp +181 -0
  132. data/test/test_Self.cpp +2 -2
  133. data/test/test_Stl_Set.cpp +6 -6
  134. data/test/test_Stl_SharedPtr.cpp +54 -30
  135. data/test/test_Stl_String_View.cpp +12 -0
  136. data/test/test_Stl_Tuple.cpp +1 -1
  137. data/test/test_Stl_Variant.cpp +6 -14
  138. data/test/test_Stl_Vector.cpp +61 -30
  139. data/test/test_String.cpp +4 -2
  140. data/test/test_Struct.cpp +1 -1
  141. data/test/test_Symbol.cpp +12 -0
  142. data/test/test_To_Ruby.cpp +1 -0
  143. data/test/test_Type.cpp +36 -35
  144. data/test/test_global_functions.cpp +1 -1
  145. data/test/unittest.cpp +1 -1
  146. data/test/unittest.hpp +5 -5
  147. metadata +10 -24
  148. data/rice/Function.hpp +0 -17
  149. data/rice/Function.ipp +0 -13
  150. data/rice/detail/MethodInfo.hpp +0 -48
  151. data/rice/detail/MethodInfo.ipp +0 -99
  152. data/rice/detail/NativeCallbackFFI.hpp +0 -55
  153. data/rice/detail/NativeCallbackFFI.ipp +0 -152
  154. data/rice/detail/NativeCallbackSimple.hpp +0 -30
  155. data/rice/detail/NativeCallbackSimple.ipp +0 -29
data/bin/rice-doc.rb CHANGED
@@ -5,7 +5,6 @@ require_relative '../lib/rice'
5
5
  require_relative '../lib/rice/doc'
6
6
 
7
7
  # Now setup option parser
8
- require 'ostruct'
9
8
  require 'optparse'
10
9
 
11
10
  module Rice
@@ -14,67 +13,74 @@ module Rice
14
13
  # Generates Mkdocs for a Rice extension
15
14
  #
16
15
  # == Usage
17
- # rice-doc [options] <rice_extension_library>
16
+ # rice-doc [options] <config_file>
18
17
  #
19
18
  # Options:
20
- # -o, --output=path Output directory
21
- # -v, --version Show version (1.1.0)
19
+ # -v, --version Show version
22
20
  # -h, --help Show help message
23
21
 
24
22
  class Cmd
25
- # :enddoc:
26
23
  attr_accessor :options
27
24
 
28
25
  def option_parser
29
26
  OptionParser.new do |opts|
30
27
  opts.banner = "rice-doc #{Rice::VERSION}\n" +
31
- "Usage: rice-doc [options] <rice_extension_library_path>"
28
+ "Usage: rice-doc [options] <config_file.yaml>"
32
29
 
33
30
  opts.separator ""
34
31
  opts.separator "Options:"
35
32
 
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
33
+ opts.on_tail("-v", "--version", "Show version (#{Rice::VERSION})") do
34
+ puts "rice-doc " + Rice::VERSION
43
35
  exit
44
36
  end
45
37
 
46
38
  opts.on_tail("-h", "--help", "Show help message") do
47
39
  puts opts
40
+ puts ""
41
+ puts "Config file format (YAML):"
42
+ puts " extension: path/to/extension.so"
43
+ puts " output: ./docs/api"
44
+ puts " resolvers:"
45
+ puts " Std:"
46
+ puts " type: cppreference"
47
+ puts " MyNamespace:"
48
+ puts " type: doxygen"
49
+ puts " root: https://example.com/docs"
50
+ puts " tagfile: https://example.com/docs/tagfile.xml"
51
+ puts " type_mappings:"
52
+ puts " - pattern: \"^enum\\\\s*\""
53
+ puts " replacement: \"\""
54
+ puts " method_mappings:"
55
+ puts " MyNamespace::MyClass:"
56
+ puts " ruby_method: cppMethod"
57
+ puts ""
58
+ puts "Note: Ruby core types are automatically linked to docs.ruby-lang.org"
48
59
  exit
49
60
  end
50
61
  end
51
62
  end
52
63
 
53
64
  def parse_args
54
- @options = OpenStruct.new
55
- options.extension = nil
56
- options.output = nil
65
+ @options = Struct.new(:config_file).new
66
+ options.config_file = nil
67
+
68
+ self.option_parser.parse! ARGV
57
69
 
58
- # Make sure the user specified at least one file
59
- if ARGV.length < 1 and not options.exec
70
+ if ARGV.length < 1
60
71
  puts self.option_parser
61
72
  puts ""
62
- puts "Must specify a rice extension"
73
+ puts "Must specify a config file"
63
74
  exit(-1)
64
75
  end
65
76
 
66
- self.option_parser.parse! ARGV
77
+ options.config_file = ARGV.shift
67
78
 
68
- if options.output.nil?
69
- puts "Must specify an output directory with -o/--output option"
79
+ unless File.exist?(options.config_file)
80
+ puts "Config file not found: #{options.config_file}"
70
81
  exit(-1)
71
- elsif !Dir.exist?(options.output)
72
- puts "Creating output directory '#{options.output}'"
73
- Dir.mkdir(options.output)
74
82
  end
75
83
 
76
- options.extension = ARGV.shift
77
-
78
84
  options
79
85
  rescue OptionParser::InvalidOption, OptionParser::InvalidArgument, OptionParser::MissingArgument => e
80
86
  puts self.option_parser
@@ -88,125 +94,33 @@ end
88
94
  cmd = Rice::Cmd.new
89
95
  options = cmd.parse_args
90
96
 
97
+ # Load configuration
98
+ config = Rice::Doc::Config.new(options.config_file)
99
+
100
+ # Validate configuration
101
+ if config.extension.nil?
102
+ puts "Config file must specify 'extension'"
103
+ exit(-1)
104
+ end
105
+
106
+ if config.output.nil?
107
+ puts "Config file must specify 'output'"
108
+ exit(-1)
109
+ end
110
+
111
+ # Create output directory if needed
112
+ unless Dir.exist?(config.output)
113
+ puts "Creating output directory '#{config.output}'"
114
+ FileUtils.mkdir_p(config.output)
115
+ end
116
+
91
117
  # Load the extension
92
- require options.extension
118
+ require config.extension
93
119
 
94
120
  # Get modules and classes
95
121
  modules = Rice::Registries.instance.modules.modules
96
122
  klasses = Rice::Registries.instance.types.klasses
97
123
 
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)
124
+ # Generate documentation
125
+ generator = Rice::Doc::Mkdocs.new(modules + klasses, config.resolvers, config.output)
212
126
  generator.generate
data/bin/rice-rbs.rb CHANGED
@@ -6,7 +6,6 @@ require 'bundler/setup'
6
6
  require 'rice'
7
7
 
8
8
  # Now setup option parser
9
- require 'ostruct'
10
9
  require 'optparse'
11
10
 
12
11
  module Rice
@@ -52,7 +51,7 @@ module Rice
52
51
  end
53
52
 
54
53
  def parse_args
55
- @options = OpenStruct.new
54
+ @options = Struct.new(:exec, :extension, :output).new
56
55
  options.extension = nil
57
56
  options.output = nil
58
57
 
@@ -0,0 +1,248 @@
1
+ // This file is part of [rice](https://github.com/ruby-rice/rice).
2
+ //
3
+ // Copyright (C) 2025 Jason Roelofs <jasongroelofs@gmail.com>
4
+ // Paul Brannan <curlypaul924@gmail.com>,
5
+ // Charlie Savage
6
+ //
7
+ // Redistribution and use in source and binary forms, with or without
8
+ // modification, are permitted provided that the following conditions
9
+ // are met:
10
+ //
11
+ // 1. Redistributions of source code must retain the above copyright
12
+ // notice, this list of conditions and the following disclaimer.
13
+ // 2. Redistributions in binary form must reproduce the above copyright
14
+ // notice, this list of conditions and the following disclaimer in the
15
+ // documentation and/or other materials provided with the distribution.
16
+ //
17
+ // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
+ // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
+ // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
+ // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
+ // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
+ // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
+ // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+
28
+ #ifndef Rice__Api_hpp_
29
+ #define Rice__Api_hpp_
30
+
31
+
32
+ // ========= ModuleRegistry.hpp =========
33
+ #ifndef Rice_Api_Module_Registry_hpp
34
+ #define Rice_Api_Module_Registry_hpp
35
+
36
+ extern "C"
37
+ void Init_Module_Registry();
38
+
39
+ #endif
40
+
41
+ // ========= ModuleRegistry.ipp =========
42
+ using namespace Rice;
43
+
44
+ extern "C"
45
+ void Init_Module_Registry()
46
+ {
47
+ Module rb_mRice = define_module("Rice");
48
+
49
+ Rice::define_class_under<detail::ModuleRegistry>(rb_mRice, "ModuleRegistry").
50
+ define_method("modules", &detail::ModuleRegistry::modules, Return().setValue());
51
+ }
52
+
53
+ // ========= NativeRegistry.hpp =========
54
+ #ifndef Rice_Api_Native_Registry_hpp
55
+ #define Rice_Api_Native_Registry_hpp
56
+
57
+ extern "C"
58
+ void Init_Native_Registry();
59
+
60
+ #endif
61
+
62
+ // ========= NativeRegistry.ipp =========
63
+ using namespace Rice;
64
+
65
+ extern "C"
66
+ inline void Init_Native_Registry()
67
+ {
68
+ Module rb_mRice = define_module("Rice");
69
+
70
+ Rice::define_class_under<detail::NativeRegistry>(rb_mRice, "NativeRegistry").
71
+ define_method("lookup", [](detail::NativeRegistry& self, VALUE klass) -> Array
72
+ {
73
+ Array result;
74
+
75
+ const std::vector<detail::Native*> natives = self.lookup(klass);
76
+ for (detail::Native* native : natives)
77
+ {
78
+ result.push(native, false);
79
+ }
80
+
81
+ return result;
82
+ }, Arg("klass").setValue());
83
+ }
84
+
85
+ // ========= TypeRegistry.hpp =========
86
+ #ifndef Rice_Api_Type_Registry_hpp
87
+ #define Rice_Api_Type_Registry_hpp
88
+
89
+ extern "C"
90
+ void Init_Type_Registry();
91
+
92
+ #endif
93
+
94
+ // ========= TypeRegistry.ipp =========
95
+ using namespace Rice;
96
+
97
+ extern "C"
98
+ void Init_Type_Registry()
99
+ {
100
+ Module rb_mRice = define_module("Rice");
101
+
102
+ Rice::define_class_under<detail::TypeRegistry>(rb_mRice, "TypeRegistry").
103
+ define_method("klasses", &detail::TypeRegistry::klasses, Return().setValue());
104
+ }
105
+
106
+ // ========= Registries.hpp =========
107
+ #ifndef Rice_Api_Registries_hpp
108
+ #define Rice_Api_Registries_hpp
109
+
110
+ void Init_Registries();
111
+
112
+ #endif
113
+
114
+ // ========= Registries.ipp =========
115
+ using namespace Rice;
116
+
117
+ inline void Init_Registries()
118
+ {
119
+ Module rb_mRice = define_module("Rice");
120
+
121
+ define_class_under<detail::Registries>(rb_mRice, "Registries").
122
+ define_singleton_attr("instance", &detail::Registries::instance, AttrAccess::Read).
123
+ define_attr("modules", &detail::Registries::modules, AttrAccess::Read).
124
+ define_attr("natives", &detail::Registries::natives, AttrAccess::Read).
125
+ define_attr("types", &detail::Registries::types, AttrAccess::Read);
126
+ }
127
+
128
+ // ========= Arg.hpp =========
129
+ #ifndef Rice_Api_Arg_hpp
130
+ #define Rice_Api_Arg_hpp
131
+
132
+ extern "C"
133
+ void Init_Arg();
134
+
135
+ #endif
136
+
137
+ // ========= Arg.ipp =========
138
+ using namespace Rice;
139
+
140
+ inline void Init_Arg()
141
+ {
142
+ Module rb_mRice = define_module("Rice");
143
+
144
+ define_class_under<Arg>(rb_mRice, "Arg").
145
+ define_attr("name", &Arg::name, AttrAccess::Read);
146
+ }
147
+
148
+ // ========= Parameter.hpp =========
149
+ #ifndef Rice_Api_Parameter_hpp
150
+ #define Rice_Api_Parameter_hpp
151
+
152
+ extern "C"
153
+ void Init_Parameter();
154
+
155
+ #endif
156
+
157
+ // ========= Parameter.ipp =========
158
+ using namespace Rice;
159
+
160
+ inline void Init_Parameter()
161
+ {
162
+ Module rb_mRice = define_module("Rice");
163
+
164
+ define_class_under<detail::ParameterAbstract>(rb_mRice, "Parameter").
165
+ define_method("arg", &detail::ParameterAbstract::arg).
166
+ define_method("klass", &detail::ParameterAbstract::klass, Return().setValue()).
167
+ define_method("cpp_klass", &detail::ParameterAbstract::cppTypeName);
168
+ }
169
+
170
+ // ========= Native.hpp =========
171
+ #ifndef Rice_Api_Native_Function_hpp
172
+ #define Rice_Api_Native_Function_hpp
173
+
174
+ extern "C"
175
+ void Init_Native();
176
+
177
+ #endif
178
+
179
+ // ========= Native.ipp =========
180
+ using namespace Rice;
181
+
182
+ #include <ostream>
183
+
184
+ extern "C"
185
+ inline void Init_Native()
186
+ {
187
+ Module rb_mRice = define_module("Rice");
188
+
189
+ define_enum_under<detail::NativeKind>("NativeKind", rb_mRice)
190
+ .define_value("Function", detail::NativeKind::Function)
191
+ .define_value("Method", detail::NativeKind::Method)
192
+ .define_value("AttributeReader", detail::NativeKind::AttributeReader)
193
+ .define_value("AttributeWriter", detail::NativeKind::AttributeWriter)
194
+ .define_value("Proc", detail::NativeKind::Proc)
195
+ .define_value("Callback", detail::NativeKind::Callback);
196
+
197
+ define_class_under<detail::Native>(rb_mRice, "Native").
198
+ define_method("name", &detail::Native::name).
199
+ define_method("kind", &detail::Native::kind).
200
+ define_method("return_klass", &detail::Native::returnKlass, Return().setValue()).
201
+ define_method("parameters", &detail::Native::parameters).
202
+ define_method("to_s", [](detail::Native& self) -> std::string
203
+ {
204
+ std::ostringstream stream;
205
+ stream << "Native";
206
+
207
+ switch (self.kind())
208
+ {
209
+ case detail::NativeKind::Function:
210
+ stream << "Function";
211
+ break;
212
+ case detail::NativeKind::Method:
213
+ stream << "Method";
214
+ break;
215
+ case detail::NativeKind::Iterator:
216
+ stream << "Iterator";
217
+ break;
218
+ case detail::NativeKind::AttributeReader:
219
+ stream << "AttributeReader";
220
+ break;
221
+ case detail::NativeKind::AttributeWriter:
222
+ stream << "AttributeWriter";
223
+ break;
224
+ case detail::NativeKind::Proc:
225
+ stream << "Proc";
226
+ break;
227
+ case detail::NativeKind::Callback:
228
+ stream << "Callback";
229
+ break;
230
+ }
231
+
232
+ stream << "<" << self.name() << "> ";
233
+ return stream.str();
234
+ });
235
+ }
236
+
237
+ extern "C"
238
+ inline void Init_Rice_Api()
239
+ {
240
+ Init_Registries();
241
+ Init_Module_Registry();
242
+ Init_Native_Registry();
243
+ Init_Type_Registry();
244
+ Init_Arg();
245
+ Init_Parameter();
246
+ Init_Native();
247
+ }
248
+ #endif