infraruby-java 3.7.1 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +0 -5
- data/ext/primitive/PrimitiveService.java +4981 -1162
- data/ext/primitive/primitive.c +2524 -1724
- data/infraruby-java.gemspec +3 -3
- data/lib/infraruby-java.rb +121 -0
- data/lib/primitive/primitive.jar +0 -0
- data/ruby/Exception.rb +45 -0
- data/ruby/Float.rb +1 -1
- data/ruby/Integer.rb +1 -1
- data/ruby/JAVA.rb +115 -0
- data/ruby/Kernel.rb +6 -0
- data/ruby/Module.rb +6 -0
- data/ruby/Object.rb +9 -2
- data/ruby/String.rb +4 -14
- metadata +11 -9
- data/ruby/Java.rb +0 -106
- data/ruby/Java/java.lang.String.rb +0 -7
- data/ruby/NilClass.rb +0 -5
data/infraruby-java.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.platform = "ruby"
|
3
3
|
s.name = "infraruby-java"
|
4
|
-
s.version = "
|
4
|
+
s.version = "4.0.0"
|
5
5
|
s.licenses = ["MIT"]
|
6
6
|
s.author = "InfraRuby Vision"
|
7
7
|
s.email = "rubygems@infraruby.com"
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.description = "InfraRuby Java integration for Ruby interpreters"
|
11
11
|
s.extensions = ["ext/primitive/extconf.rb"]
|
12
12
|
s.files = Dir["**/*"]
|
13
|
-
s.add_runtime_dependency "infraruby-base", "~>
|
14
|
-
s.add_development_dependency "infraruby-task", "~>
|
13
|
+
s.add_runtime_dependency "infraruby-base", "~> 4.0"
|
14
|
+
s.add_development_dependency "infraruby-task", "~> 4.0"
|
15
15
|
s.add_development_dependency "rspec", "~> 3.0"
|
16
16
|
end
|
data/lib/infraruby-java.rb
CHANGED
@@ -2,4 +2,125 @@ require "infraruby-base"
|
|
2
2
|
|
3
3
|
require "primitive/primitive"
|
4
4
|
|
5
|
+
InfraRuby.if(RUBY_ENGINE == "ruby") {
|
6
|
+
|
7
|
+
module InfraRuby
|
8
|
+
module WithPackage
|
9
|
+
def __package(symbol, &block)
|
10
|
+
name = symbol.to_s
|
11
|
+
o = __get(name)
|
12
|
+
if o.nil?
|
13
|
+
o = JavaPackage.new
|
14
|
+
o.name = __join(name)
|
15
|
+
__set(name, o)
|
16
|
+
end
|
17
|
+
o.instance_eval(&block)
|
18
|
+
return
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module WithClass
|
23
|
+
def __class(name, superclass, &block)
|
24
|
+
o = __get(name)
|
25
|
+
if o.nil?
|
26
|
+
o = Class.new(superclass)
|
27
|
+
o.extend(JavaClass)
|
28
|
+
o.name = __join(name)
|
29
|
+
__set(name, o)
|
30
|
+
end
|
31
|
+
o.module_eval(&block)
|
32
|
+
return
|
33
|
+
end
|
34
|
+
|
35
|
+
def __interface(name, &block)
|
36
|
+
o = __get(name)
|
37
|
+
if o.nil?
|
38
|
+
o = Module.new
|
39
|
+
o.extend(JavaClass)
|
40
|
+
o.name = __join(name)
|
41
|
+
__set(name, o)
|
42
|
+
end
|
43
|
+
o.module_eval(&block)
|
44
|
+
return
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
module JavaBase
|
49
|
+
include WithPackage
|
50
|
+
|
51
|
+
def __get(name)
|
52
|
+
return __send__(name)
|
53
|
+
rescue
|
54
|
+
return nil
|
55
|
+
end
|
56
|
+
|
57
|
+
def __set(name, o)
|
58
|
+
c = class << self ; self ; end
|
59
|
+
c.send(:define_method, name) { o }
|
60
|
+
return
|
61
|
+
end
|
62
|
+
|
63
|
+
def __join(name)
|
64
|
+
return name
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class JavaPackage < BasicObject
|
69
|
+
include WithPackage
|
70
|
+
include WithClass
|
71
|
+
|
72
|
+
attr_accessor :name
|
73
|
+
|
74
|
+
def inspect
|
75
|
+
return @name
|
76
|
+
end
|
77
|
+
|
78
|
+
def nil?
|
79
|
+
return false
|
80
|
+
end
|
81
|
+
|
82
|
+
def __get(name)
|
83
|
+
return __send__(name)
|
84
|
+
rescue
|
85
|
+
return nil
|
86
|
+
end
|
87
|
+
|
88
|
+
def __set(name, o)
|
89
|
+
c = class << self ; self ; end
|
90
|
+
c.send(:define_method, name) { o }
|
91
|
+
return
|
92
|
+
end
|
93
|
+
|
94
|
+
def __join(name)
|
95
|
+
return "#{self.name}.#{name}"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
module JavaClass
|
100
|
+
include WithClass
|
101
|
+
include JAVA::ClassMixin
|
102
|
+
|
103
|
+
def __get(name)
|
104
|
+
return const_get(name)
|
105
|
+
rescue
|
106
|
+
return nil
|
107
|
+
end
|
108
|
+
|
109
|
+
def __set(name, o)
|
110
|
+
const_set(name, o)
|
111
|
+
return
|
112
|
+
end
|
113
|
+
|
114
|
+
def __join(name)
|
115
|
+
return "#{self.name}::#{name}"
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
module JAVA
|
121
|
+
extend InfraRuby::JavaBase
|
122
|
+
end
|
123
|
+
|
124
|
+
}
|
125
|
+
|
5
126
|
InfraRuby.load_parent_library(__dir__)
|
data/lib/primitive/primitive.jar
CHANGED
Binary file
|
data/ruby/Exception.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
class Exception
|
2
|
+
def is_a?(c)
|
3
|
+
if c == JAVA::java.lang.Throwable
|
4
|
+
return true
|
5
|
+
end
|
6
|
+
return super(c)
|
7
|
+
end
|
8
|
+
|
9
|
+
def getMessage
|
10
|
+
return message.to_j
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
InfraRuby.if(RUBY_ENGINE == "ruby") {
|
15
|
+
|
16
|
+
class << Exception
|
17
|
+
def ===(o)
|
18
|
+
if self == Exception
|
19
|
+
if o.class == JAVA::Exception
|
20
|
+
return false
|
21
|
+
end
|
22
|
+
end
|
23
|
+
return super(o)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
}
|
28
|
+
|
29
|
+
InfraRuby.if(RUBY_ENGINE == "jruby") {
|
30
|
+
|
31
|
+
class << Exception
|
32
|
+
def ===(o)
|
33
|
+
if self == Exception
|
34
|
+
if o.class <= Java::java.lang.Throwable
|
35
|
+
path = Kernel.caller_locations.first.path
|
36
|
+
unless path.end_with?(".ir")
|
37
|
+
return true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
return super(o)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
}
|
data/ruby/Float.rb
CHANGED
data/ruby/Integer.rb
CHANGED
data/ruby/JAVA.rb
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
InfraRuby.if(RUBY_ENGINE == "ruby") {
|
2
|
+
|
3
|
+
JAVA.module_eval do
|
4
|
+
__package(:java) {
|
5
|
+
__package(:lang) {
|
6
|
+
__class "Object", JAVA::BasicObject do
|
7
|
+
def equals(o)
|
8
|
+
return equal?(o)
|
9
|
+
end
|
10
|
+
|
11
|
+
def hashCode
|
12
|
+
return __id__.to_int32
|
13
|
+
end
|
14
|
+
|
15
|
+
def toString
|
16
|
+
return inspect.to_j
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
__class "Throwable", JAVA::java.lang.Object do
|
21
|
+
def initialize(message = nix)
|
22
|
+
super()
|
23
|
+
if message.nix?
|
24
|
+
@message = nil
|
25
|
+
else
|
26
|
+
@message = message
|
27
|
+
end
|
28
|
+
return
|
29
|
+
end
|
30
|
+
|
31
|
+
def toString
|
32
|
+
if @message.nil?
|
33
|
+
return self.class.toString
|
34
|
+
else
|
35
|
+
return "#{self.class}: #{@message}".j
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def getMessage
|
40
|
+
return @message
|
41
|
+
end
|
42
|
+
end
|
43
|
+
}
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
}
|
48
|
+
|
49
|
+
JAVA::Value.class_eval do
|
50
|
+
def pretty_print(pp)
|
51
|
+
return
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
JAVA::java.lang.Object.class_eval do
|
56
|
+
def ===(o)
|
57
|
+
return equals(o)
|
58
|
+
end
|
59
|
+
|
60
|
+
def eql?(o)
|
61
|
+
return equals(o)
|
62
|
+
end
|
63
|
+
|
64
|
+
def hash
|
65
|
+
return hashCode.to_i
|
66
|
+
end
|
67
|
+
|
68
|
+
def to_s
|
69
|
+
return String.from_j(toString)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
class << JAVA::java.lang.Object
|
74
|
+
def ===(o)
|
75
|
+
if self == JAVA::java.lang.Object
|
76
|
+
return true
|
77
|
+
end
|
78
|
+
return super(o)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
InfraRuby.if(RUBY_ENGINE == "ruby") {
|
83
|
+
|
84
|
+
JAVA::java.lang.Throwable.class_eval do
|
85
|
+
def exception
|
86
|
+
return JAVA::Exception.new(self)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
}
|
91
|
+
|
92
|
+
InfraRuby.if(RUBY_ENGINE == "jruby") {
|
93
|
+
|
94
|
+
JAVA::java.lang.Throwable.class_eval do
|
95
|
+
def exception
|
96
|
+
return self
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
}
|
101
|
+
|
102
|
+
class << JAVA::java.lang.Throwable
|
103
|
+
def ===(o)
|
104
|
+
if self == JAVA::java.lang.Throwable
|
105
|
+
if o.class <= Exception
|
106
|
+
return true
|
107
|
+
end
|
108
|
+
end
|
109
|
+
return super(o)
|
110
|
+
end
|
111
|
+
|
112
|
+
def exception(*args)
|
113
|
+
return new(*args).exception
|
114
|
+
end
|
115
|
+
end
|
data/ruby/Kernel.rb
ADDED
data/ruby/Module.rb
ADDED
data/ruby/Object.rb
CHANGED
@@ -1,13 +1,20 @@
|
|
1
1
|
class Object
|
2
|
+
def is_a?(c)
|
3
|
+
if c == JAVA::java.lang.Object
|
4
|
+
return true
|
5
|
+
end
|
6
|
+
return super(c)
|
7
|
+
end
|
8
|
+
|
2
9
|
def equals(o)
|
3
10
|
return eql?(o)
|
4
11
|
end
|
5
12
|
|
6
13
|
def hashCode
|
7
|
-
return hash
|
14
|
+
return hash.to_int32
|
8
15
|
end
|
9
16
|
|
10
17
|
def toString
|
11
|
-
return to_s
|
18
|
+
return to_s.to_j
|
12
19
|
end
|
13
20
|
end
|
data/ruby/String.rb
CHANGED
@@ -1,22 +1,12 @@
|
|
1
1
|
class String
|
2
2
|
class << self
|
3
|
-
alias_method :
|
4
|
-
|
5
|
-
def from_java_bytes(m, encoding = nix)
|
6
|
-
s = __from_java_bytes(m)
|
7
|
-
unless encoding.nix?
|
8
|
-
s.force_encoding(encoding)
|
9
|
-
end
|
10
|
-
return s
|
11
|
-
end
|
12
|
-
|
13
|
-
alias_method :from_java_bytes_unsafe, :from_java_bytes
|
3
|
+
alias_method :from_j_bytes_unsafe, :from_j_bytes
|
14
4
|
end
|
15
5
|
|
16
|
-
alias_method :
|
6
|
+
alias_method :to_j_bytes_unsafe, :to_j_bytes
|
17
7
|
|
18
|
-
def
|
19
|
-
return
|
8
|
+
def j
|
9
|
+
return to_j
|
20
10
|
end
|
21
11
|
|
22
12
|
def to_byte
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infraruby-java
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- InfraRuby Vision
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: infraruby-base
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '4.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '4.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: infraruby-task
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '4.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '4.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -68,12 +68,13 @@ files:
|
|
68
68
|
- lib/infraruby-java.rb
|
69
69
|
- lib/primitive/primitive.jar
|
70
70
|
- ruby/Boolean.rb
|
71
|
+
- ruby/Exception.rb
|
71
72
|
- ruby/FalseClass.rb
|
72
73
|
- ruby/Float.rb
|
73
74
|
- ruby/Integer.rb
|
74
|
-
- ruby/
|
75
|
-
- ruby/
|
76
|
-
- ruby/
|
75
|
+
- ruby/JAVA.rb
|
76
|
+
- ruby/Kernel.rb
|
77
|
+
- ruby/Module.rb
|
77
78
|
- ruby/Object.rb
|
78
79
|
- ruby/String.rb
|
79
80
|
- ruby/TrueClass.rb
|
@@ -102,3 +103,4 @@ signing_key:
|
|
102
103
|
specification_version: 4
|
103
104
|
summary: InfraRuby Java integration for Ruby interpreters
|
104
105
|
test_files: []
|
106
|
+
has_rdoc:
|