protobuf_java_helpers 0.1.0-java → 0.1.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gemfile.lock +1 -1
- data/ext/ruby_protobuf/Varinter.java +16 -16
- data/lib/jars/protobuf_java_helpers.jar +0 -0
- data/lib/protobuf_java_helpers/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3f9b31577a8febb01cea661b249658bd7687ae2
|
4
|
+
data.tar.gz: 900ded1d519d468307eb34efc4bb313731fec93b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99ab497203ad7e98a8cc4a3fe63dbcc7098e8f4dc749a777748d8a476d073724a4062c41b8df4932da68aba0f87460292e0a8bd0456ce3c519d8413a630343fb
|
7
|
+
data.tar.gz: 56ba95bebf58a01272beaf2665d8ad3fd1466d52aa83d459f41e534ad383f622d0a8870188e11000b6b88ab96637b54e2ebf85fe3563f0af94d9af27d87ac109
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -39,11 +39,11 @@ public class Varinter {
|
|
39
39
|
}
|
40
40
|
|
41
41
|
@JRubyMethod(name = "acceptable?")
|
42
|
-
public static IRubyObject acceptable_p( ThreadContext context, IRubyObject self ) {
|
42
|
+
public static IRubyObject acceptable_p( ThreadContext context, IRubyObject self, IRubyObject recv ) {
|
43
43
|
org.jruby.Ruby runtime = context.getRuntime();
|
44
44
|
|
45
|
-
if (
|
46
|
-
long value = ((RubyFixnum)
|
45
|
+
if (recv instanceof RubyInteger || recv instanceof RubyFixnum) {
|
46
|
+
long value = ((RubyFixnum) recv).getLongValue();
|
47
47
|
|
48
48
|
if (value >= 0 && value <= INT32_MAX) {
|
49
49
|
return runtime.getTrue();
|
@@ -56,12 +56,12 @@ public class Varinter {
|
|
56
56
|
}
|
57
57
|
|
58
58
|
@JRubyMethod
|
59
|
-
public static IRubyObject to_varint( ThreadContext context, IRubyObject self ) {
|
60
|
-
if (!(
|
59
|
+
public static IRubyObject to_varint( ThreadContext context, IRubyObject self, IRubyObject recv ) {
|
60
|
+
if (!(recv instanceof RubyInteger || recv instanceof RubyFixnum)) {
|
61
61
|
return context.nil;
|
62
62
|
}
|
63
63
|
|
64
|
-
long value = ((RubyFixnum)
|
64
|
+
long value = ((RubyFixnum) recv).getLongValue();
|
65
65
|
org.jruby.Ruby runtime = context.getRuntime();
|
66
66
|
RubyString bit_string = runtime.newString(new ByteList(internal_to_varint(value), true));
|
67
67
|
bit_string.force_encoding(context, runtime.getEncodingService().getEncoding(org.jcodings.specific.ASCIIEncoding.INSTANCE));
|
@@ -69,12 +69,12 @@ public class Varinter {
|
|
69
69
|
}
|
70
70
|
|
71
71
|
@JRubyMethod
|
72
|
-
public static IRubyObject to_varint_64( ThreadContext context, IRubyObject self ) {
|
73
|
-
if (!(
|
72
|
+
public static IRubyObject to_varint_64( ThreadContext context, IRubyObject self, IRubyObject recv ) {
|
73
|
+
if (!(recv instanceof RubyInteger || recv instanceof RubyFixnum)) {
|
74
74
|
return context.nil;
|
75
75
|
}
|
76
76
|
|
77
|
-
long value = ((RubyFixnum)
|
77
|
+
long value = ((RubyFixnum) recv).getLongValue();
|
78
78
|
org.jruby.Ruby runtime = context.getRuntime();
|
79
79
|
RubyString bit_string = runtime.newString(new ByteList(internal_to_varint(value & 0xffffffffffffffffL), true));
|
80
80
|
bit_string.force_encoding(context, runtime.getEncodingService().getEncoding(org.jcodings.specific.ASCIIEncoding.INSTANCE));
|
@@ -82,17 +82,17 @@ public class Varinter {
|
|
82
82
|
}
|
83
83
|
|
84
84
|
@JRubyMethod
|
85
|
-
public static IRubyObject read_varint(ThreadContext context, IRubyObject self) throws IOException {
|
85
|
+
public static IRubyObject read_varint(ThreadContext context, IRubyObject self, IRubyObject recv ) throws IOException {
|
86
86
|
long value = 0L;
|
87
87
|
int index = 0;
|
88
88
|
long current_byte;
|
89
89
|
|
90
|
-
if (
|
91
|
-
StringIO
|
90
|
+
if (recv instanceof StringIO) {
|
91
|
+
StringIO current_recv = ((StringIO)recv);
|
92
92
|
RubyFixnum fixnum;
|
93
93
|
|
94
94
|
do {
|
95
|
-
fixnum = ((RubyFixnum)(
|
95
|
+
fixnum = ((RubyFixnum)(current_recv.getbyte(context)));
|
96
96
|
current_byte = fixnum.getLongValue();
|
97
97
|
if (index == 0 && current_byte < 128) { return context.getRuntime().newFixnum(current_byte); }
|
98
98
|
value = (value | ((current_byte & 0x7f) << (7 * index)));
|
@@ -102,11 +102,11 @@ public class Varinter {
|
|
102
102
|
return context.getRuntime().newFixnum(value);
|
103
103
|
}
|
104
104
|
|
105
|
-
if (
|
106
|
-
RubyIO
|
105
|
+
if (recv instanceof RubyIO) {
|
106
|
+
RubyIO current_recv = ((RubyIO)recv);
|
107
107
|
|
108
108
|
do {
|
109
|
-
current_byte =
|
109
|
+
current_byte = current_recv.getByte(context);
|
110
110
|
if (index == 0 && current_byte < 128) { return context.getRuntime().newFixnum(current_byte); }
|
111
111
|
value = (value | ((current_byte & 0x7f) << (7 * index)));
|
112
112
|
index++;
|
Binary file
|