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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +25 -1
- data/CMakePresets.json +77 -50
- data/FindRuby.cmake +1 -1
- data/bin/rice-doc.rb +2 -0
- data/include/rice/api.hpp +14 -1
- data/include/rice/rice.hpp +351 -132
- data/include/rice/stl.hpp +319 -256
- data/lib/rice/doc/config.rb +57 -57
- data/lib/rice/doc/cpp_reference.rb +158 -158
- data/lib/rice/doc/doxygen.rb +289 -289
- data/lib/rice/doc/mkdocs.rb +332 -332
- data/lib/rice/doc/rice.rb +48 -47
- data/lib/rice/doc/ruby.rb +26 -26
- data/lib/rice/native.rb +15 -15
- data/lib/rice/native_registry.rb +12 -17
- data/lib/rice/parameter.rb +5 -5
- data/lib/rice/rbs.rb +72 -72
- data/lib/rice/version.rb +1 -1
- data/lib/rubygems/builder.rb +9 -9
- data/lib/rubygems_plugin.rb +8 -8
- data/rice/Data_Type.ipp +12 -7
- data/rice/cpp_api/Class.hpp +5 -0
- data/rice/cpp_api/Class.ipp +5 -0
- data/rice/cpp_api/Object.hpp +6 -0
- data/rice/cpp_api/Object.ipp +5 -0
- data/rice/detail/Forwards.hpp +18 -0
- data/rice/detail/Forwards.ipp +60 -0
- data/rice/detail/Native.ipp +2 -4
- data/rice/detail/NativeAttributeGet.ipp +1 -1
- data/rice/detail/NativeAttributeSet.hpp +5 -3
- data/rice/detail/NativeAttributeSet.ipp +41 -33
- data/rice/detail/NativeMethod.ipp +25 -22
- data/rice/detail/NativeRegistry.hpp +4 -2
- data/rice/detail/NativeRegistry.ipp +42 -9
- data/rice/detail/Parameter.ipp +3 -4
- data/rice/detail/Type.ipp +4 -0
- data/rice/detail/Wrapper.hpp +17 -12
- data/rice/detail/Wrapper.ipp +95 -36
- data/rice/rice.hpp +3 -0
- data/rice/rice_api/NativeRegistry.ipp +14 -1
- data/rice/stl/exception.ipp +1 -1
- data/rice/stl/filesystem.ipp +1 -1
- data/rice/stl/map.ipp +13 -11
- data/rice/stl/multimap.ipp +13 -11
- data/rice/stl/pair.ipp +14 -8
- data/rice/stl/set.ipp +16 -16
- data/rice/stl/shared_ptr.hpp +16 -0
- data/rice/stl/shared_ptr.ipp +74 -37
- data/rice/stl/type_index.ipp +1 -1
- data/rice/stl/unique_ptr.hpp +9 -3
- data/rice/stl/unique_ptr.ipp +80 -124
- data/rice/stl/unordered_map.ipp +14 -12
- data/rice/stl/vector.ipp +67 -31
- data/test/test_Attribute.cpp +72 -0
- data/test/test_Callback.cpp +3 -0
- data/test/test_Inheritance.cpp +14 -14
- data/test/test_Keep_Alive_No_Wrapper.cpp +6 -2
- data/test/test_Stl_Map.cpp +46 -0
- data/test/test_Stl_Multimap.cpp +46 -0
- data/test/test_Stl_Set.cpp +34 -0
- data/test/test_Stl_SharedPtr.cpp +160 -45
- data/test/test_Stl_UniquePtr.cpp +48 -3
- data/test/test_Stl_Unordered_Map.cpp +46 -0
- data/test/test_Stl_Variant.cpp +10 -14
- data/test/test_Stl_Vector.cpp +140 -13
- data/test/test_Tracking.cpp +3 -0
- metadata +3 -1
data/lib/rice/doc/config.rb
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
1
|
require 'yaml'
|
|
2
2
|
|
|
3
3
|
module Rice
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
module Doc
|
|
5
|
+
class Config
|
|
6
|
+
attr_reader :extension, :output, :resolvers
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
def initialize(config_path)
|
|
9
|
+
config = YAML.load_file(config_path)
|
|
10
|
+
base_dir = File.dirname(config_path)
|
|
11
|
+
@extension = File.expand_path(config['extension'], base_dir)
|
|
12
|
+
@output = File.expand_path(config['output'], base_dir)
|
|
13
|
+
@resolvers = build_resolvers(config['namespaces'] || {})
|
|
14
|
+
end
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
private
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
def build_resolvers(namespace_configs)
|
|
19
|
+
# Always include Ruby resolver for core types
|
|
20
|
+
result = { nil => Ruby.new }
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
namespace_configs.each do |namespace, config|
|
|
23
|
+
key = namespace == 'default' ? nil : namespace
|
|
24
|
+
result[key] = build_resolver(config)
|
|
25
|
+
end
|
|
26
|
+
result
|
|
27
|
+
end
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
29
|
+
def build_resolver(config)
|
|
30
|
+
resolver = config['resolver']
|
|
31
|
+
case resolver
|
|
32
|
+
when 'cppreference'
|
|
33
|
+
build_cppreference_resolver(config)
|
|
34
|
+
when 'doxygen'
|
|
35
|
+
build_doxygen_resolver(config)
|
|
36
|
+
when 'rice'
|
|
37
|
+
build_rice_resolver(config)
|
|
38
|
+
else
|
|
39
|
+
raise "Unknown resolver: #{resolver}"
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
def build_cppreference_resolver(config)
|
|
44
|
+
CppReference.new
|
|
45
|
+
end
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
def build_doxygen_resolver(config)
|
|
48
|
+
root = config['root']
|
|
49
|
+
tagfile = config['tagfile']
|
|
50
|
+
type_mappings = build_type_mappings(config['type_mappings'] || [])
|
|
51
|
+
method_mappings = config['method_mappings'] || {}
|
|
52
|
+
Doxygen.new(root, tagfile, type_mappings, method_mappings)
|
|
53
|
+
end
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
def build_rice_resolver(config)
|
|
56
|
+
Rice.new
|
|
57
|
+
end
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
59
|
+
def build_type_mappings(mappings)
|
|
60
|
+
result = {}
|
|
61
|
+
mappings.each do |mapping|
|
|
62
|
+
pattern = Regexp.new(mapping['pattern'], Regexp::IGNORECASE)
|
|
63
|
+
replacement = mapping['replacement'] || ''
|
|
64
|
+
result[pattern] = replacement
|
|
65
|
+
end
|
|
66
|
+
result
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
70
|
end
|
|
@@ -2,162 +2,162 @@ require 'open-uri'
|
|
|
2
2
|
require 'libxml-ruby'
|
|
3
3
|
|
|
4
4
|
module Rice
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
5
|
+
module Doc
|
|
6
|
+
class CppReference
|
|
7
|
+
ROOT = "https://en.cppreference.com/w"
|
|
8
|
+
INDEX = "https://raw.githubusercontent.com/p12tic/cppreference-doc/refs/heads/master/index-functions-cpp.xml"
|
|
9
|
+
#INDEX = "c:/Users/cfis/Downloads/index-functions-cpp.xml"
|
|
10
|
+
|
|
11
|
+
OPERATORS = {"assign" => "operator=",
|
|
12
|
+
"assign_plus" => "operator+=",
|
|
13
|
+
"assign_minus" => "operator-=",
|
|
14
|
+
"assign_multiply" => "operator*=",
|
|
15
|
+
"assign_divide" => "operator/=",
|
|
16
|
+
"call" => "operator()",
|
|
17
|
+
"decrement" => "operator--",
|
|
18
|
+
"dereference" => "operator*",
|
|
19
|
+
"increment" => "operator++",
|
|
20
|
+
"==" => "operator==",
|
|
21
|
+
"!=" => "operator!=",
|
|
22
|
+
"+" => "operator+",
|
|
23
|
+
"-" => "operator-",
|
|
24
|
+
"*" => "operator*",
|
|
25
|
+
"/" => "operator/",
|
|
26
|
+
"&" => "operator&",
|
|
27
|
+
"|" => "operator|",
|
|
28
|
+
"<" => "operator<",
|
|
29
|
+
">" => "operator>",
|
|
30
|
+
"<=" => "operator<=",
|
|
31
|
+
"<<" => "operator<<",
|
|
32
|
+
"[]" => "operator[]",
|
|
33
|
+
"[]=" => "operator[]"}
|
|
34
|
+
|
|
35
|
+
def initialize
|
|
36
|
+
@type_mappings = {/^enum\s*/i => '',
|
|
37
|
+
/^union\s*/i => '',
|
|
38
|
+
/<.*>/ => ''}
|
|
39
|
+
|
|
40
|
+
@method_mappings = {'std::exception' => {'message' => 'what'},
|
|
41
|
+
'std::map' => {'delete' => 'erase',
|
|
42
|
+
'include?' => 'find'},
|
|
43
|
+
'std::multimap' => {'delete' => 'erase',
|
|
44
|
+
'include?' => 'find'},
|
|
45
|
+
'std::runtime_error' => {'message' => 'what'},
|
|
46
|
+
'std::unorderedmap' => {'delete' => 'erase',
|
|
47
|
+
'include?' => 'find'},
|
|
48
|
+
'std::vector' => {'delete_at' => 'erase',
|
|
49
|
+
'first' => 'front',
|
|
50
|
+
'last' => 'back',
|
|
51
|
+
'pop' => 'pop_back',
|
|
52
|
+
'push' => 'push_back'}}
|
|
53
|
+
|
|
54
|
+
@cache = Hash.new
|
|
55
|
+
data = URI.open(INDEX).read
|
|
56
|
+
parser = LibXML::XML::Parser.string(data)
|
|
57
|
+
@doc = parser.parse
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def camelize(content, capitalize = true)
|
|
61
|
+
result = content.gsub(/(?:_)(.)/) do |matched|
|
|
62
|
+
$1.capitalize
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
result[0] = capitalize ? result[0].upcase : result[0].downcase
|
|
66
|
+
result
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def cpp_name(klass)
|
|
70
|
+
result = klass.cpp_class
|
|
71
|
+
@type_mappings.each do |key, value|
|
|
72
|
+
result = result.gsub(key, value)
|
|
73
|
+
end
|
|
74
|
+
result
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def get_node(klass, xpath)
|
|
78
|
+
node = @cache[klass]
|
|
79
|
+
if node.nil? && !@cache.has_key?(klass)
|
|
80
|
+
node = @cache[klass] = @doc.find_first(xpath)
|
|
81
|
+
end
|
|
82
|
+
node
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def class_node(klass)
|
|
86
|
+
xpath = "//class[@name='#{cpp_name(klass)}']"
|
|
87
|
+
get_node(klass, xpath)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def class_base(klass)
|
|
91
|
+
node = class_node(klass)
|
|
92
|
+
if node
|
|
93
|
+
path = node.attributes["link"]
|
|
94
|
+
"#{ROOT}/#{path}"
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def class_url(klass)
|
|
99
|
+
node = class_node(klass)
|
|
100
|
+
if node
|
|
101
|
+
"#{class_base(klass)}.html"
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def module_url(klass)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def method_url(klass, native)
|
|
109
|
+
node = class_node(klass)
|
|
110
|
+
if node
|
|
111
|
+
ruby_name = native.name
|
|
112
|
+
method_names = Array.new
|
|
113
|
+
if ruby_name == "initialize" || ruby_name == "initialize_copy"
|
|
114
|
+
return "#{class_base(klass)}.html"
|
|
115
|
+
elsif native_name = OPERATORS[ruby_name]
|
|
116
|
+
method_names << native_name
|
|
117
|
+
elsif native_name = @method_mappings.dig(cpp_name(klass), ruby_name)
|
|
118
|
+
method_names << native_name
|
|
119
|
+
elsif ruby_name.match(/\?$/)
|
|
120
|
+
native_name = ruby_name.gsub(/\?$/, "")
|
|
121
|
+
method_names << camelize(native_name, false)
|
|
122
|
+
method_names << camelize(native_name, true)
|
|
123
|
+
method_names << "is#{camelize(native_name, true)}"
|
|
124
|
+
else
|
|
125
|
+
method_names << ruby_name
|
|
126
|
+
method_names << camelize(ruby_name, false)
|
|
127
|
+
method_names << camelize(ruby_name, true)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
pattern = method_names.map do |method_name|
|
|
131
|
+
"@name='#{method_name}'"
|
|
132
|
+
end.join(" or ")
|
|
133
|
+
|
|
134
|
+
xpath = "function[#{pattern}]"
|
|
135
|
+
member_node = node&.find_first(xpath)
|
|
136
|
+
if member_node && member_node.attributes["link"]
|
|
137
|
+
"#{class_base(klass)}/#{member_node.attributes['link']}.html"
|
|
138
|
+
elsif member_node
|
|
139
|
+
"#{class_base(klass)}/#{member_node.attributes['name']}.html"
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def attribute_url(klass, native)
|
|
145
|
+
node = class_node(klass)
|
|
146
|
+
|
|
147
|
+
# Find the member node
|
|
148
|
+
attribute_name = camelize(native.name, false)
|
|
149
|
+
|
|
150
|
+
xpath = "variable[@name='#{attribute_name}']"
|
|
151
|
+
member_node = node&.find_first(xpath)
|
|
152
|
+
link = member_node.attributes["link"]
|
|
153
|
+
if member_node && link && link != "."
|
|
154
|
+
"#{class_base(klass)}/#{member_node.attributes['link']}.html"
|
|
155
|
+
elsif member_node && link && link == "."
|
|
156
|
+
"#{class_base(klass)}.html"
|
|
157
|
+
elsif member_node
|
|
158
|
+
"#{class_base(klass)}/#{member_node.attributes['name']}.html"
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
163
|
end
|