infraruby-java 0.0.0 → 3.6.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 +19 -0
- data/README.md +25 -0
- data/ext/primitive/PrimitiveService.java +2023 -0
- data/ext/primitive/extconf.rb +8 -0
- data/ext/primitive/primitive.c +4075 -0
- data/infraruby-java.gemspec +16 -0
- data/lib/infraruby-java.rb +5 -0
- data/lib/primitive/primitive.jar +0 -0
- data/ruby/Boolean.rb +14 -0
- data/ruby/FalseClass.rb +3 -0
- data/ruby/Float.rb +16 -0
- data/ruby/Integer.rb +76 -0
- data/ruby/Java.rb +106 -0
- data/ruby/Java/java.lang.String.rb +7 -0
- data/ruby/NilClass.rb +5 -0
- data/ruby/Object.rb +13 -0
- data/ruby/String.rb +57 -0
- data/ruby/TrueClass.rb +3 -0
- metadata +70 -8
@@ -0,0 +1,16 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.platform = "ruby"
|
3
|
+
s.name = "infraruby-java"
|
4
|
+
s.version = "3.6.0"
|
5
|
+
s.licenses = ["MIT"]
|
6
|
+
s.author = "InfraRuby Vision"
|
7
|
+
s.email = "rubygems@infraruby.com"
|
8
|
+
s.homepage = "http://infraruby.com/"
|
9
|
+
s.summary = "InfraRuby Java integration for Ruby interpreters"
|
10
|
+
s.description = "InfraRuby Java integration for Ruby interpreters"
|
11
|
+
s.extensions = ["ext/primitive/extconf.rb"]
|
12
|
+
s.files = Dir["**/*"]
|
13
|
+
s.add_runtime_dependency "infraruby-base", "~> 3.6"
|
14
|
+
s.add_development_dependency "infraruby-task", "~> 3.6"
|
15
|
+
s.add_development_dependency "rspec", "~> 3.0"
|
16
|
+
end
|
Binary file
|
data/ruby/Boolean.rb
ADDED
data/ruby/FalseClass.rb
ADDED
data/ruby/Float.rb
ADDED
data/ruby/Integer.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
class Integer
|
2
|
+
def as_i
|
3
|
+
return self
|
4
|
+
end
|
5
|
+
|
6
|
+
def to_byte
|
7
|
+
return Byte[self]
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_byte!
|
11
|
+
if -0x80 <= self && self <= 0x7F
|
12
|
+
return Byte[self]
|
13
|
+
end
|
14
|
+
raise RangeError
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_char
|
18
|
+
return Char[self]
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_char!
|
22
|
+
if 0x0000 <= self && self <= 0xFFFF
|
23
|
+
return Char[self]
|
24
|
+
end
|
25
|
+
raise RangeError
|
26
|
+
end
|
27
|
+
|
28
|
+
def to_int16
|
29
|
+
return Int16[self]
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_int16!
|
33
|
+
if -0x8000 <= self && self <= 0x7FFF
|
34
|
+
return Int16[self]
|
35
|
+
end
|
36
|
+
raise RangeError
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_int32
|
40
|
+
return Int32[self]
|
41
|
+
end
|
42
|
+
|
43
|
+
def to_int32!
|
44
|
+
if -0x80000000 <= self && self <= 0x7FFFFFFF
|
45
|
+
return Int32[self]
|
46
|
+
end
|
47
|
+
raise RangeError
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_int64
|
51
|
+
return Int64[self]
|
52
|
+
end
|
53
|
+
|
54
|
+
def to_int64!
|
55
|
+
if -0x8000000000000000 <= self && self <= 0x7FFFFFFFFFFFFFFF
|
56
|
+
return Int64[self]
|
57
|
+
end
|
58
|
+
raise RangeError
|
59
|
+
end
|
60
|
+
|
61
|
+
def to_float32
|
62
|
+
return Float32[self]
|
63
|
+
end
|
64
|
+
|
65
|
+
def to_float64
|
66
|
+
return Float64[self]
|
67
|
+
end
|
68
|
+
|
69
|
+
alias_method :byte, :to_byte
|
70
|
+
alias_method :char, :to_char
|
71
|
+
alias_method :i16, :to_int16
|
72
|
+
alias_method :i32, :to_int32
|
73
|
+
alias_method :i64, :to_int64
|
74
|
+
alias_method :f32, :to_float32
|
75
|
+
alias_method :f64, :to_float64
|
76
|
+
end
|
data/ruby/Java.rb
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
InfraRuby.if(RUBY_ENGINE == "jruby") {
|
2
|
+
|
3
|
+
module Java
|
4
|
+
class << self
|
5
|
+
def int16
|
6
|
+
return ::Java::short
|
7
|
+
end
|
8
|
+
|
9
|
+
def int32
|
10
|
+
return ::Java::int
|
11
|
+
end
|
12
|
+
|
13
|
+
def int64
|
14
|
+
return ::Java::long
|
15
|
+
end
|
16
|
+
|
17
|
+
def float32
|
18
|
+
return ::Java::float
|
19
|
+
end
|
20
|
+
|
21
|
+
def float64
|
22
|
+
return ::Java::double
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class << self
|
27
|
+
def ARRAYCOPY(m0, i0, m1, i1, n)
|
28
|
+
Java::java.lang.System.arraycopy(m0, i0, m1, i1, n)
|
29
|
+
return
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
}
|
35
|
+
|
36
|
+
Java::boolean.define_singleton_method(:array) do |*args|
|
37
|
+
n = args.size
|
38
|
+
m = Java::boolean[n].new
|
39
|
+
n.times do |i|
|
40
|
+
m[i] = args[i]
|
41
|
+
end
|
42
|
+
return m
|
43
|
+
end
|
44
|
+
|
45
|
+
Java::byte.define_singleton_method(:array) do |*args|
|
46
|
+
n = args.size
|
47
|
+
m = Java::byte[n].new
|
48
|
+
n.times do |i|
|
49
|
+
m[i] = args[i]
|
50
|
+
end
|
51
|
+
return m
|
52
|
+
end
|
53
|
+
|
54
|
+
Java::char.define_singleton_method(:array) do |*args|
|
55
|
+
n = args.size
|
56
|
+
m = Java::char[n].new
|
57
|
+
n.times do |i|
|
58
|
+
m[i] = args[i]
|
59
|
+
end
|
60
|
+
return m
|
61
|
+
end
|
62
|
+
|
63
|
+
Java::int16.define_singleton_method(:array) do |*args|
|
64
|
+
n = args.size
|
65
|
+
m = Java::int16[n].new
|
66
|
+
n.times do |i|
|
67
|
+
m[i] = args[i]
|
68
|
+
end
|
69
|
+
return m
|
70
|
+
end
|
71
|
+
|
72
|
+
Java::int32.define_singleton_method(:array) do |*args|
|
73
|
+
n = args.size
|
74
|
+
m = Java::int32[n].new
|
75
|
+
n.times do |i|
|
76
|
+
m[i] = args[i]
|
77
|
+
end
|
78
|
+
return m
|
79
|
+
end
|
80
|
+
|
81
|
+
Java::int64.define_singleton_method(:array) do |*args|
|
82
|
+
n = args.size
|
83
|
+
m = Java::int64[n].new
|
84
|
+
n.times do |i|
|
85
|
+
m[i] = args[i]
|
86
|
+
end
|
87
|
+
return m
|
88
|
+
end
|
89
|
+
|
90
|
+
Java::float32.define_singleton_method(:array) do |*args|
|
91
|
+
n = args.size
|
92
|
+
m = Java::float32[n].new
|
93
|
+
n.times do |i|
|
94
|
+
m[i] = args[i]
|
95
|
+
end
|
96
|
+
return m
|
97
|
+
end
|
98
|
+
|
99
|
+
Java::float64.define_singleton_method(:array) do |*args|
|
100
|
+
n = args.size
|
101
|
+
m = Java::float64[n].new
|
102
|
+
n.times do |i|
|
103
|
+
m[i] = args[i]
|
104
|
+
end
|
105
|
+
return m
|
106
|
+
end
|
data/ruby/NilClass.rb
ADDED
data/ruby/Object.rb
ADDED
data/ruby/String.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
class String
|
2
|
+
class << self
|
3
|
+
alias_method :__from_java_bytes, :from_java_bytes
|
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
|
14
|
+
end
|
15
|
+
|
16
|
+
alias_method :to_java_bytes_unsafe, :to_java_bytes
|
17
|
+
|
18
|
+
def java
|
19
|
+
return to_java
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_byte
|
23
|
+
return to_i.to_byte
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_char
|
27
|
+
return to_i.to_char
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_int16
|
31
|
+
return to_i.to_int16
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_int32
|
35
|
+
return to_i.to_int32
|
36
|
+
end
|
37
|
+
|
38
|
+
def to_int32!
|
39
|
+
return to_i.to_int32!
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_int64
|
43
|
+
return to_i.to_int64
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_int64!
|
47
|
+
return to_i.to_int64!
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_float32
|
51
|
+
return to_f.to_float32
|
52
|
+
end
|
53
|
+
|
54
|
+
def to_float64
|
55
|
+
return to_f.to_float64
|
56
|
+
end
|
57
|
+
end
|
data/ruby/TrueClass.rb
ADDED
metadata
CHANGED
@@ -1,23 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infraruby-java
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.6.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: 2015-03-
|
12
|
-
dependencies:
|
13
|
-
|
11
|
+
date: 2015-03-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: infraruby-base
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.6'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: infraruby-task
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: InfraRuby Java integration for Ruby interpreters
|
14
56
|
email: rubygems@infraruby.com
|
15
57
|
executables: []
|
16
|
-
extensions:
|
58
|
+
extensions:
|
59
|
+
- ext/primitive/extconf.rb
|
17
60
|
extra_rdoc_files: []
|
18
|
-
files:
|
61
|
+
files:
|
62
|
+
- MIT-LICENSE
|
63
|
+
- README.md
|
64
|
+
- ext/primitive/PrimitiveService.java
|
65
|
+
- ext/primitive/extconf.rb
|
66
|
+
- ext/primitive/primitive.c
|
67
|
+
- infraruby-java.gemspec
|
68
|
+
- lib/infraruby-java.rb
|
69
|
+
- lib/primitive/primitive.jar
|
70
|
+
- ruby/Boolean.rb
|
71
|
+
- ruby/FalseClass.rb
|
72
|
+
- ruby/Float.rb
|
73
|
+
- ruby/Integer.rb
|
74
|
+
- ruby/Java.rb
|
75
|
+
- ruby/Java/java.lang.String.rb
|
76
|
+
- ruby/NilClass.rb
|
77
|
+
- ruby/Object.rb
|
78
|
+
- ruby/String.rb
|
79
|
+
- ruby/TrueClass.rb
|
19
80
|
homepage: http://infraruby.com/
|
20
|
-
licenses:
|
81
|
+
licenses:
|
82
|
+
- MIT
|
21
83
|
metadata: {}
|
22
84
|
post_install_message:
|
23
85
|
rdoc_options: []
|
@@ -38,5 +100,5 @@ rubyforge_project:
|
|
38
100
|
rubygems_version: 2.2.2
|
39
101
|
signing_key:
|
40
102
|
specification_version: 4
|
41
|
-
summary: InfraRuby
|
103
|
+
summary: InfraRuby Java integration for Ruby interpreters
|
42
104
|
test_files: []
|