bel 0.3.2-x86-mingw32 → 0.3.3-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +39 -0
  3. data/README.md +1 -1
  4. data/bel.gemspec +4 -4
  5. data/ext/mri/extconf.rb +20 -6
  6. data/lib/bel.rb +4 -3
  7. data/lib/bel/libbel.rb +141 -177
  8. data/lib/bel/libbel/bel_ast_structs.rb +150 -148
  9. data/lib/bel/libbel/bel_token.rb +29 -27
  10. data/lib/bel/libbel/bel_token_list.rb +28 -26
  11. data/lib/bel/{2.0 → libbel/ext/2.0}/libbel.so +0 -0
  12. data/lib/bel/libbel/ext/2.1/libbel.so +0 -0
  13. data/lib/bel/{2.2 → libbel/ext/2.2}/libbel.so +0 -0
  14. data/lib/bel/libbel/ext/java/darwin/x86_64/libbel.bundle +0 -0
  15. data/lib/bel/libbel/ext/java/linux/x86_64/libbel.so +0 -0
  16. data/lib/bel/libbel/ext/java/mswin/i686/2.0/libbel.so +0 -0
  17. data/lib/bel/{2.1 → libbel/ext/java/mswin/i686/2.1}/libbel.so +0 -0
  18. data/lib/bel/libbel/ext/java/mswin/i686/2.2/libbel.so +0 -0
  19. data/lib/bel/libbel/ext/java/mswin/x86_64/2.0/libbel.so +0 -0
  20. data/lib/bel/libbel/ext/java/mswin/x86_64/2.1/libbel.so +0 -0
  21. data/lib/bel/libbel/ext/java/mswin/x86_64/2.2/libbel.so +0 -0
  22. data/lib/bel/libbel/ext/mingw/i686/2.0/libbel.so +0 -0
  23. data/lib/bel/libbel/ext/mingw/i686/2.1/libbel.so +0 -0
  24. data/lib/bel/libbel/ext/mingw/i686/2.2/libbel.so +0 -0
  25. data/lib/bel/libbel/ext/mingw/x86_64/2.0/libbel.so +0 -0
  26. data/lib/bel/libbel/ext/mingw/x86_64/2.1/libbel.so +0 -0
  27. data/lib/bel/libbel/ext/mingw/x86_64/2.2/libbel.so +0 -0
  28. data/lib/bel/libbel/library_load_error.rb +30 -0
  29. data/lib/bel/libbel/library_resolver.rb +103 -0
  30. data/lib/bel/libbel/node_test.rb +29 -27
  31. data/lib/bel/libbel/node_transformation.rb +24 -22
  32. data/lib/bel/libbel/node_traversal.rb +79 -77
  33. data/lib/bel/libbel/platform_support_error.rb +23 -0
  34. data/lib/bel/version.rb +1 -1
  35. metadata +23 -33
@@ -2,201 +2,203 @@ require_relative 'node_traversal'
2
2
  require_relative 'node_transformation'
3
3
  require_relative 'node_test'
4
4
 
5
- module LibBEL
6
- class AstNodeTypeUnion < FFI::Union
7
- layout(
8
- :ttype, :bel_ast_token_type,
9
- :vtype, :bel_ast_value_type
10
- )
11
-
12
- def token_type
13
- self[:ttype]
14
- end
5
+ module BEL
6
+ module LibBEL
7
+ class AstNodeTypeUnion < FFI::Union
8
+ layout(
9
+ :ttype, :bel_ast_token_type,
10
+ :vtype, :bel_ast_value_type
11
+ )
12
+
13
+ def token_type
14
+ self[:ttype]
15
+ end
15
16
 
16
- def value_type
17
- self[:vtype]
17
+ def value_type
18
+ self[:vtype]
19
+ end
18
20
  end
19
- end
20
21
 
21
- class BelAstNodeTypeInfo < FFI::Struct
22
- layout(
23
- :type, :bel_ast_node_type,
24
- :union, AstNodeTypeUnion
25
- )
22
+ class BelAstNodeTypeInfo < FFI::Struct
23
+ layout(
24
+ :type, :bel_ast_node_type,
25
+ :union, AstNodeTypeUnion
26
+ )
26
27
 
27
- def type
28
- self[:type]
29
- end
28
+ def type
29
+ self[:type]
30
+ end
30
31
 
31
- def union
32
- self[:union]
32
+ def union
33
+ self[:union]
34
+ end
33
35
  end
34
- end
35
36
 
36
- class BelAstNode < FFI::Union
37
- include NodeTraversal
38
- include NodeTransformation
39
- include NodeTest
37
+ class BelAstNode < FFI::Union
38
+ include NodeTraversal
39
+ include NodeTransformation
40
+ include NodeTest
40
41
 
41
- layout(
42
- :type_info, BelAstNodeTypeInfo.ptr,
43
- :token, :pointer,
44
- :value, :pointer
45
- )
42
+ layout(
43
+ :type_info, BelAstNodeTypeInfo.ptr,
44
+ :token, :pointer,
45
+ :value, :pointer
46
+ )
46
47
 
47
- def type_info
48
- self[:type_info]
49
- end
48
+ def type_info
49
+ self[:type_info]
50
+ end
50
51
 
51
- def type_info=(type_info)
52
- self[:type_info] = type_info
53
- end
52
+ def type_info=(type_info)
53
+ self[:type_info] = type_info
54
+ end
54
55
 
55
- def token
56
- self[:token]
57
- end
56
+ def token
57
+ self[:token]
58
+ end
58
59
 
59
- def token=(token)
60
- self[:token] = token
61
- end
60
+ def token=(token)
61
+ self[:token] = token
62
+ end
62
63
 
63
- def value
64
- self[:value]
65
- end
64
+ def value
65
+ self[:value]
66
+ end
66
67
 
67
- def value=(value)
68
- self[:value] = value
69
- end
68
+ def value=(value)
69
+ self[:value] = value
70
+ end
70
71
 
71
- def to_typed_node
72
- LibBEL.typed_node(self)
72
+ def to_typed_node
73
+ LibBEL.typed_node(self)
74
+ end
73
75
  end
74
- end
75
76
 
76
- class BelAstNodeToken < FFI::Struct
77
- layout(
78
- :type, :bel_ast_node_type,
79
- :ttype, :bel_ast_token_type,
80
- :left, BelAstNode.ptr,
81
- :right, BelAstNode.ptr
82
- )
77
+ class BelAstNodeToken < FFI::Struct
78
+ layout(
79
+ :type, :bel_ast_node_type,
80
+ :ttype, :bel_ast_token_type,
81
+ :left, BelAstNode.ptr,
82
+ :right, BelAstNode.ptr
83
+ )
83
84
 
84
- def type
85
- self[:type]
86
- end
85
+ def type
86
+ self[:type]
87
+ end
87
88
 
88
- def token_type
89
- self[:ttype]
90
- end
89
+ def token_type
90
+ self[:ttype]
91
+ end
91
92
 
92
- def left
93
- self[:left]
94
- end
93
+ def left
94
+ self[:left]
95
+ end
95
96
 
96
- def left=(left)
97
- self[:left] = left
98
- end
97
+ def left=(left)
98
+ self[:left] = left
99
+ end
99
100
 
100
- def right
101
- self[:right]
102
- end
101
+ def right
102
+ self[:right]
103
+ end
103
104
 
104
- def right=(right)
105
- self[:right] = right
105
+ def right=(right)
106
+ self[:right] = right
107
+ end
106
108
  end
107
- end
108
109
 
109
- class BelAstNodeValue < FFI::Struct
110
- layout(
111
- :type, :bel_ast_node_type,
112
- :vtype, :bel_ast_value_type,
113
- :value, :string
114
- )
110
+ class BelAstNodeValue < FFI::Struct
111
+ layout(
112
+ :type, :bel_ast_node_type,
113
+ :vtype, :bel_ast_value_type,
114
+ :value, :string
115
+ )
115
116
 
116
- def type
117
- self[:type]
118
- end
117
+ def type
118
+ self[:type]
119
+ end
119
120
 
120
- def value_type
121
- self[:vtype]
122
- end
121
+ def value_type
122
+ self[:vtype]
123
+ end
123
124
 
124
- def value
125
- self[:value]
125
+ def value
126
+ self[:value]
127
+ end
126
128
  end
127
- end
128
129
 
129
- class BelAst < FFI::ManagedStruct
130
- include NodeTraversal
131
- include NodeTransformation
132
- include NodeTest
130
+ class BelAst < FFI::ManagedStruct
131
+ include NodeTraversal
132
+ include NodeTransformation
133
+ include NodeTest
133
134
 
134
- layout(
135
- :root, BelAstNode.ptr
136
- )
135
+ layout(
136
+ :root, BelAstNode.ptr
137
+ )
137
138
 
138
- def root
139
- self[:root]
140
- end
139
+ def root
140
+ self[:root]
141
+ end
141
142
 
142
- def root=(root)
143
- self[:root] = root
144
- end
143
+ def root=(root)
144
+ self[:root] = root
145
+ end
145
146
 
146
- # overrides {NodeTraversal#each_depth_first}
147
- def each_depth_first(&block)
148
- if block_given?
149
- root.each_depth_first(&block)
150
- else
151
- root.enum_for(:each_depth_first)
147
+ # overrides {NodeTraversal#each_depth_first}
148
+ def each_depth_first(&block)
149
+ if block_given?
150
+ root.each_depth_first(&block)
151
+ else
152
+ root.enum_for(:each_depth_first)
153
+ end
152
154
  end
153
- end
154
155
 
155
- # overrides {NodeTraversal#each_breadth_first}
156
- def each_breadth_first(queue = [], &block)
157
- if block_given?
158
- root.each_breadth_first(&block)
159
- else
160
- root.enum_for(:each_breadth_first)
156
+ # overrides {NodeTraversal#each_breadth_first}
157
+ def each_breadth_first(queue = [], &block)
158
+ if block_given?
159
+ root.each_breadth_first(&block)
160
+ else
161
+ root.enum_for(:each_breadth_first)
162
+ end
161
163
  end
162
- end
163
164
 
164
- def transform(transforms, options = {})
165
- transform_tree(transforms, :depth_first, options)
166
- end
165
+ def transform(transforms, options = {})
166
+ transform_tree(transforms, :depth_first, options)
167
+ end
167
168
 
168
- def transform_tree(transforms, traversal = :depth_first, options = {})
169
- copy_ast = LibBEL::copy_ast(self)
170
- options = {
171
- :mutate => true
172
- }.merge(options)
169
+ def transform_tree(transforms, traversal = :depth_first, options = {})
170
+ copy_ast = LibBEL::copy_ast(self)
171
+ options = {
172
+ :mutate => true
173
+ }.merge(options)
173
174
 
174
- copy_ast.root.transform_tree(transforms, traversal, options)
175
- copy_ast
176
- end
175
+ copy_ast.root.transform_tree(transforms, traversal, options)
176
+ copy_ast
177
+ end
177
178
 
178
- def any?(predicates)
179
- self.root.any_in_tree?(predicates)
180
- end
179
+ def any?(predicates)
180
+ self.root.any_in_tree?(predicates)
181
+ end
181
182
 
182
- def all?(predicates)
183
- self.root.all_in_tree?(predicates)
184
- end
183
+ def all?(predicates)
184
+ self.root.all_in_tree?(predicates)
185
+ end
185
186
 
186
- def self.release(ptr)
187
- if !ptr.null?
188
- LibBEL::bel_free_ast(ptr)
187
+ def self.release(ptr)
188
+ if !ptr.null?
189
+ LibBEL::bel_free_ast(ptr)
190
+ end
189
191
  end
190
192
  end
191
- end
192
193
 
193
- private
194
+ private
194
195
 
195
- def self.typed_node(bel_ast_node)
196
- if bel_ast_node.type_info.type == :BEL_TOKEN
197
- BelAstNodeToken.new(bel_ast_node.token)
198
- else
199
- BelAstNodeValue.new(bel_ast_node.value)
196
+ def self.typed_node(bel_ast_node)
197
+ if bel_ast_node.type_info.type == :BEL_TOKEN
198
+ BelAstNodeToken.new(bel_ast_node.token)
199
+ else
200
+ BelAstNodeValue.new(bel_ast_node.value)
201
+ end
200
202
  end
201
203
  end
202
204
  end
@@ -1,38 +1,40 @@
1
- module LibBEL
1
+ module BEL
2
+ module LibBEL
2
3
 
3
- class BelToken < FFI::Struct
4
+ class BelToken < FFI::Struct
4
5
 
5
- layout :type, :bel_token_type,
6
- :pos_start, :int,
7
- :pos_end, :int,
8
- :value, :pointer
6
+ layout :type, :bel_token_type,
7
+ :pos_start, :int,
8
+ :pos_end, :int,
9
+ :value, :pointer
9
10
 
10
- def type
11
- self[:type]
12
- end
11
+ def type
12
+ self[:type]
13
+ end
13
14
 
14
- def pos_start
15
- self[:pos_start]
16
- end
15
+ def pos_start
16
+ self[:pos_start]
17
+ end
17
18
 
18
- def pos_end
19
- self[:pos_end]
20
- end
19
+ def pos_end
20
+ self[:pos_end]
21
+ end
21
22
 
22
- def value
23
- self[:value].read_string
24
- end
23
+ def value
24
+ self[:value].read_string
25
+ end
25
26
 
26
- def hash
27
- [self.type, self.value, self.pos_start, self.pos_end].hash
28
- end
27
+ def hash
28
+ [self.type, self.value, self.pos_start, self.pos_end].hash
29
+ end
29
30
 
30
- def ==(other)
31
- return false if other == nil
32
- self.type == other.type && self.value == other.value &&
33
- self.pos_start == other.pos_start && self.pos_end == other.pos_end
34
- end
31
+ def ==(other)
32
+ return false if other == nil
33
+ self.type == other.type && self.value == other.value &&
34
+ self.pos_start == other.pos_start && self.pos_end == other.pos_end
35
+ end
35
36
 
36
- alias_method :eql?, :'=='
37
+ alias_method :eql?, :'=='
38
+ end
37
39
  end
38
40
  end
@@ -1,36 +1,38 @@
1
- module LibBEL
1
+ module BEL
2
+ module LibBEL
2
3
 
3
- class BelTokenList < FFI::ManagedStruct
4
- include Enumerable
4
+ class BelTokenList < FFI::ManagedStruct
5
+ include Enumerable
5
6
 
6
- layout :length, :int,
7
- :tokens, BelToken.ptr
7
+ layout :length, :int,
8
+ :tokens, BelToken.ptr
8
9
 
9
- def each
10
- if block_given?
11
- iterator = LibBEL::bel_new_token_iterator(self.pointer)
12
- while LibBEL::bel_token_iterator_end(iterator).zero?
13
- current_token = LibBEL::bel_token_iterator_get(iterator)
14
- yield LibBEL::BelToken.new(current_token)
15
- LibBEL::bel_token_iterator_next(iterator)
10
+ def each
11
+ if block_given?
12
+ iterator = LibBEL::bel_new_token_iterator(self.pointer)
13
+ while LibBEL::bel_token_iterator_end(iterator).zero?
14
+ current_token = LibBEL::bel_token_iterator_get(iterator)
15
+ yield LibBEL::BelToken.new(current_token)
16
+ LibBEL::bel_token_iterator_next(iterator)
17
+ end
18
+ LibBEL::free_bel_token_iterator(iterator)
19
+ else
20
+ enum_for(:each)
16
21
  end
17
- LibBEL::free_bel_token_iterator(iterator)
18
- else
19
- enum_for(:each)
20
22
  end
21
- end
22
23
 
23
- def token_at(position)
24
- self.each_with_index { |tk, index|
25
- if (tk.pos_start..tk.pos_end).include? position
26
- return [tk, index]
27
- end
28
- }
29
- nil
30
- end
24
+ def token_at(position)
25
+ self.each_with_index { |tk, index|
26
+ if (tk.pos_start..tk.pos_end).include? position
27
+ return [tk, index]
28
+ end
29
+ }
30
+ nil
31
+ end
31
32
 
32
- def self.release(ptr)
33
- LibBEL::free_bel_token_list(ptr)
33
+ def self.release(ptr)
34
+ LibBEL::free_bel_token_list(ptr)
35
+ end
34
36
  end
35
37
  end
36
38
  end