bel 0.3.2-x64-mingw32 → 0.3.3-x64-mingw32
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 +39 -0
- data/README.md +1 -1
- data/bel.gemspec +4 -4
- data/ext/mri/extconf.rb +20 -6
- data/lib/bel.rb +4 -3
- data/lib/bel/libbel.rb +141 -177
- data/lib/bel/libbel/bel_ast_structs.rb +150 -148
- data/lib/bel/libbel/bel_token.rb +29 -27
- data/lib/bel/libbel/bel_token_list.rb +28 -26
- data/lib/bel/{2.0 → libbel/ext/2.0}/libbel.so +0 -0
- data/lib/bel/{2.1 → libbel/ext/2.1}/libbel.so +0 -0
- data/lib/bel/{2.2 → libbel/ext/2.2}/libbel.so +0 -0
- data/lib/bel/libbel/ext/java/darwin/x86_64/libbel.bundle +0 -0
- data/lib/bel/libbel/ext/java/linux/x86_64/libbel.so +0 -0
- data/lib/bel/libbel/ext/java/mswin/i686/2.0/libbel.so +0 -0
- data/lib/bel/libbel/ext/java/mswin/i686/2.1/libbel.so +0 -0
- data/lib/bel/libbel/ext/java/mswin/i686/2.2/libbel.so +0 -0
- data/lib/bel/libbel/ext/java/mswin/x86_64/2.0/libbel.so +0 -0
- data/lib/bel/libbel/ext/java/mswin/x86_64/2.1/libbel.so +0 -0
- data/lib/bel/libbel/ext/java/mswin/x86_64/2.2/libbel.so +0 -0
- data/lib/bel/libbel/ext/mingw/i686/2.0/libbel.so +0 -0
- data/lib/bel/libbel/ext/mingw/i686/2.1/libbel.so +0 -0
- data/lib/bel/libbel/ext/mingw/i686/2.2/libbel.so +0 -0
- data/lib/bel/libbel/ext/mingw/x86_64/2.0/libbel.so +0 -0
- data/lib/bel/libbel/ext/mingw/x86_64/2.1/libbel.so +0 -0
- data/lib/bel/libbel/ext/mingw/x86_64/2.2/libbel.so +0 -0
- data/lib/bel/libbel/library_load_error.rb +30 -0
- data/lib/bel/libbel/library_resolver.rb +103 -0
- data/lib/bel/libbel/node_test.rb +29 -27
- data/lib/bel/libbel/node_transformation.rb +24 -22
- data/lib/bel/libbel/node_traversal.rb +79 -77
- data/lib/bel/libbel/platform_support_error.rb +23 -0
- data/lib/bel/version.rb +1 -1
- metadata +23 -33
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module BEL
|
2
|
+
module LibBEL
|
3
|
+
|
4
|
+
class LibraryLoadError < StandardError
|
5
|
+
|
6
|
+
ERROR_MSG = %Q{
|
7
|
+
The C extension library could not be loaded for your platform.
|
8
|
+
|
9
|
+
Host information:
|
10
|
+
|
11
|
+
RUBY_PLATFORM: #{RUBY_PLATFORM},
|
12
|
+
RbConfig::CONFIG['host_os']: #{RbConfig::CONFIG['host_os']},
|
13
|
+
RbConfig::CONFIG['host_cpu']: #{RbConfig::CONFIG['host_cpu']},
|
14
|
+
library: %s
|
15
|
+
|
16
|
+
Original error:
|
17
|
+
|
18
|
+
Name: %s,
|
19
|
+
Message: %s
|
20
|
+
}.gsub(/^\s+/, '')
|
21
|
+
|
22
|
+
attr_reader :cause
|
23
|
+
|
24
|
+
def initialize(library_name, cause=$!)
|
25
|
+
super(ERROR_MSG % [library_name, cause.class, cause.message])
|
26
|
+
@cause = cause;
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require_relative 'platform_support_error'
|
2
|
+
|
3
|
+
module BEL
|
4
|
+
module LibBEL
|
5
|
+
|
6
|
+
module LibraryResolver
|
7
|
+
|
8
|
+
EXT_BASE_PATH = File.join(File.expand_path('..', __FILE__), 'ext')
|
9
|
+
|
10
|
+
def resolve_library(lib_name)
|
11
|
+
case library_type(lib_name)
|
12
|
+
when :compiled
|
13
|
+
compiled_library(lib_name)
|
14
|
+
when :windows
|
15
|
+
windows_library(lib_name)
|
16
|
+
when :java
|
17
|
+
java_library(lib_name)
|
18
|
+
when :unknown
|
19
|
+
raise BEL::LibBEL::PlatformSupportError.new
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def library_type(lib_name)
|
26
|
+
exist = File.method(:exist?)
|
27
|
+
if compiled_library_paths(lib_name).any?(&exist)
|
28
|
+
:compiled
|
29
|
+
else
|
30
|
+
case RUBY_PLATFORM
|
31
|
+
when /mingw/i
|
32
|
+
:windows
|
33
|
+
when /java/i
|
34
|
+
:java
|
35
|
+
else
|
36
|
+
:unsupported
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def compiled_library(lib_name)
|
42
|
+
exist = File.method(:exist?)
|
43
|
+
compiled_library_paths(lib_name).select(&exist).first
|
44
|
+
end
|
45
|
+
|
46
|
+
def compiled_library_paths(lib_name)
|
47
|
+
base_path = "#{EXT_BASE_PATH}"
|
48
|
+
extensions = ['so', 'bundle', 'dylib']
|
49
|
+
|
50
|
+
extensions.map { |ext|
|
51
|
+
"%s/%s.%s" % [base_path, lib_name, ext]
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
def windows_library(lib_name)
|
56
|
+
unless RUBY_VERSION =~ /^2/
|
57
|
+
raise BEL::LibBEL::PlatformSupportError.new
|
58
|
+
end
|
59
|
+
|
60
|
+
base_path = "#{EXT_BASE_PATH}/mingw"
|
61
|
+
host_cpu = RbConfig::CONFIG['host_cpu']
|
62
|
+
File.join(base_path, host_cpu, ruby_version, 'libbel.so')
|
63
|
+
end
|
64
|
+
|
65
|
+
def java_library(lib_name)
|
66
|
+
# extra check to make sure jruby supports Ruby 2 (e.g. JRuby 9.0.0.0)
|
67
|
+
unless RUBY_VERSION =~ /^2/
|
68
|
+
raise BEL::LibBEL::PlatformSupportError.new
|
69
|
+
end
|
70
|
+
|
71
|
+
base_path = "#{EXT_BASE_PATH}/java"
|
72
|
+
host_os = RbConfig::CONFIG['host_os']
|
73
|
+
host_cpu = RbConfig::CONFIG['host_cpu']
|
74
|
+
|
75
|
+
case host_os
|
76
|
+
when /darwin/i
|
77
|
+
File.join(base_path, 'darwin', host_cpu, 'libbel.bundle')
|
78
|
+
when /mswin/i
|
79
|
+
File.join(base_path, 'mswin', host_cpu, ruby_version, 'libbel.so')
|
80
|
+
when /linux/i
|
81
|
+
File.join(base_path, 'linux', host_cpu, 'libbel.so')
|
82
|
+
else
|
83
|
+
raise BEL::LibBEL::PlatformSupportError.new
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def host_cpu
|
88
|
+
RbConfig::CONFIG['host_cpu']
|
89
|
+
end
|
90
|
+
|
91
|
+
def host_os
|
92
|
+
RbConfig::CONFIG['host_os']
|
93
|
+
end
|
94
|
+
|
95
|
+
def ruby_version
|
96
|
+
major = RbConfig::CONFIG['MAJOR']
|
97
|
+
minor = RbConfig::CONFIG['MINOR']
|
98
|
+
|
99
|
+
"%s.%s" % [major, minor]
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
data/lib/bel/libbel/node_test.rb
CHANGED
@@ -1,44 +1,46 @@
|
|
1
|
-
module
|
2
|
-
module
|
1
|
+
module BEL
|
2
|
+
module LibBEL
|
3
|
+
module NodeTest
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
def any?(predicates)
|
6
|
+
predicates.each do |predicate|
|
7
|
+
if predicate.call(self)
|
8
|
+
return true
|
9
|
+
end
|
8
10
|
end
|
11
|
+
return false
|
9
12
|
end
|
10
|
-
return false
|
11
|
-
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
def any_in_tree?(predicates)
|
15
|
+
predicates.each do |predicate|
|
16
|
+
self.traversal_method(self, :depth_first).call do |ast_node|
|
17
|
+
if predicate.call(ast_node)
|
18
|
+
return true
|
19
|
+
end
|
18
20
|
end
|
19
21
|
end
|
22
|
+
return false
|
20
23
|
end
|
21
|
-
return false
|
22
|
-
end
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
def all?(predicates)
|
26
|
+
predicates.each do |predicate|
|
27
|
+
if !predicate.call(self)
|
28
|
+
return false
|
29
|
+
end
|
28
30
|
end
|
31
|
+
return true
|
29
32
|
end
|
30
|
-
return true
|
31
|
-
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
def all_in_tree?(predicates)
|
35
|
+
predicates.each do |predicate|
|
36
|
+
self.traversal_method(self, :depth_first).call do |ast_node|
|
37
|
+
if !predicate.call(ast_node)
|
38
|
+
return false
|
39
|
+
end
|
38
40
|
end
|
39
41
|
end
|
42
|
+
return true
|
40
43
|
end
|
41
|
-
return true
|
42
44
|
end
|
43
45
|
end
|
44
46
|
end
|
@@ -1,31 +1,33 @@
|
|
1
|
-
module
|
2
|
-
module
|
1
|
+
module BEL
|
2
|
+
module LibBEL
|
3
|
+
module NodeTransformation
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
def transform(transforms, options = {})
|
6
|
+
if options[:mutate] == true
|
7
|
+
ast_node = self
|
8
|
+
else
|
9
|
+
ast_node = LibBEL::copy_ast_node(self)
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
transforms.each do |transform|
|
13
|
+
transform.call(ast_node)
|
14
|
+
end
|
15
|
+
ast_node
|
13
16
|
end
|
14
|
-
ast_node
|
15
|
-
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
def transform_tree(transforms, traversal = :depth_first, options = {})
|
19
|
+
if options[:mutate] == true
|
20
|
+
ast_node = self
|
21
|
+
else
|
22
|
+
ast_node = LibBEL::copy_ast_node(self)
|
23
|
+
end
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
25
|
+
transforms.each do |transform|
|
26
|
+
self.traversal_method(ast_node, traversal).call(transform)
|
27
|
+
end
|
27
28
|
|
28
|
-
|
29
|
+
ast_node
|
30
|
+
end
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
@@ -1,97 +1,99 @@
|
|
1
|
-
module
|
2
|
-
module
|
3
|
-
|
1
|
+
module BEL
|
2
|
+
module LibBEL
|
3
|
+
module NodeTraversal
|
4
|
+
include Enumerable
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
6
|
+
def each(traversal = :depth_first, callable = nil, &block)
|
7
|
+
func = if block_given?
|
8
|
+
block
|
9
|
+
else
|
10
|
+
callable
|
11
|
+
end
|
12
|
+
if !func
|
13
|
+
if traversal == :depth_first
|
14
|
+
enum_for(:each_depth_first)
|
15
|
+
elsif traversal == :breadth_first
|
16
|
+
enum_for(:each_breadth_first)
|
17
|
+
end
|
18
|
+
else
|
19
|
+
if traversal == :depth_first
|
20
|
+
each_depth_first(callable, &block)
|
21
|
+
elsif traversal == :breadth_first
|
22
|
+
each_breadth_first(callable, &block)
|
23
|
+
end
|
22
24
|
end
|
23
25
|
end
|
24
|
-
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
27
|
+
def each_depth_first(callable = nil, &block)
|
28
|
+
func = if block_given?
|
29
|
+
block
|
30
|
+
else
|
31
|
+
callable
|
32
|
+
end
|
33
|
+
if !func
|
34
|
+
enum_for(:each_depth_first)
|
35
|
+
else
|
36
|
+
typed_node = self.to_typed_node
|
37
|
+
func.call(typed_node)
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
39
|
+
if typed_node.is_a? (LibBEL::BelAstNodeToken)
|
40
|
+
if !typed_node.left.pointer.null?
|
41
|
+
typed_node.left.each_depth_first(func)
|
42
|
+
end
|
43
|
+
if func.respond_to?(:between)
|
44
|
+
func.between(typed_node)
|
45
|
+
end
|
46
|
+
if !typed_node.right.pointer.null?
|
47
|
+
typed_node.right.each_depth_first(func)
|
48
|
+
end
|
47
49
|
end
|
48
|
-
end
|
49
50
|
|
50
|
-
|
51
|
-
|
51
|
+
if func.respond_to?(:after)
|
52
|
+
func.after(typed_node)
|
53
|
+
end
|
52
54
|
end
|
53
55
|
end
|
54
|
-
end
|
55
56
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
57
|
+
def each_breadth_first(callable = nil, queue = [], &block)
|
58
|
+
func = if block_given?
|
59
|
+
block
|
60
|
+
else
|
61
|
+
callable
|
62
|
+
end
|
63
|
+
if !func
|
64
|
+
enum_for(:each_breadth_first)
|
65
|
+
else
|
66
|
+
typed_node = (queue.shift || self).to_typed_node
|
67
|
+
func.call(typed_node)
|
67
68
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
69
|
+
if typed_node.is_a? (LibBEL::BelAstNodeToken)
|
70
|
+
if !typed_node.left.pointer.null?
|
71
|
+
queue << typed_node.left
|
72
|
+
end
|
73
|
+
if func.respond_to?(:between)
|
74
|
+
func.between(typed_node)
|
75
|
+
end
|
76
|
+
if !typed_node.right.pointer.null?
|
77
|
+
queue << typed_node.right
|
78
|
+
end
|
74
79
|
end
|
75
|
-
if !typed_node.right.pointer.null?
|
76
|
-
queue << typed_node.right
|
77
|
-
end
|
78
|
-
end
|
79
80
|
|
80
|
-
|
81
|
-
|
82
|
-
|
81
|
+
if func.respond_to?(:after)
|
82
|
+
func.after(typed_node)
|
83
|
+
end
|
83
84
|
|
84
|
-
|
85
|
-
|
85
|
+
if !queue.empty?
|
86
|
+
queue.first.each_breadth_first(queue, &block)
|
87
|
+
end
|
86
88
|
end
|
87
89
|
end
|
88
|
-
end
|
89
90
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
91
|
+
def traversal_method(obj, traversal)
|
92
|
+
if traversal == :breadth_first
|
93
|
+
obj.method(:each_breadth_first)
|
94
|
+
else
|
95
|
+
obj.method(:each_depth_first)
|
96
|
+
end
|
95
97
|
end
|
96
98
|
end
|
97
99
|
end
|