Mercurial Hosting > luan
comparison src/luan/modules/BinaryLuan.java @ 1335:e0cf0d108a77
major cleanup
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 14 Feb 2019 03:10:45 -0700 |
parents | 25746915a241 |
children | f7e2df85fc0a |
comparison
equal
deleted
inserted
replaced
1334:c88b486a9511 | 1335:e0cf0d108a77 |
---|---|
3 import java.io.UnsupportedEncodingException; | 3 import java.io.UnsupportedEncodingException; |
4 import luan.Luan; | 4 import luan.Luan; |
5 import luan.LuanTable; | 5 import luan.LuanTable; |
6 import luan.LuanFunction; | 6 import luan.LuanFunction; |
7 import luan.LuanException; | 7 import luan.LuanException; |
8 import luan.LuanMethod; | |
9 | 8 |
10 | 9 |
11 public final class BinaryLuan { | 10 public final class BinaryLuan { |
12 | 11 |
13 static int start(byte[] binary,int i) { | 12 static int start(byte[] binary,int i) { |
26 | 25 |
27 static int end(byte[] binary,Integer i,int dflt) { | 26 static int end(byte[] binary,Integer i,int dflt) { |
28 return i==null ? dflt : end(binary,i); | 27 return i==null ? dflt : end(binary,i); |
29 } | 28 } |
30 | 29 |
31 @LuanMethod public static Byte[] byte_(byte[] binary,Integer i,Integer j) throws LuanException { | 30 public static Byte[] byte_(byte[] binary,Integer i,Integer j) throws LuanException { |
32 Utils.checkNotNull(binary); | 31 Utils.checkNotNull(binary); |
33 int start = start(binary,i,1); | 32 int start = start(binary,i,1); |
34 int end = end(binary,j,start+1); | 33 int end = end(binary,j,start+1); |
35 Byte[] bytes = new Byte[end-start]; | 34 Byte[] bytes = new Byte[end-start]; |
36 for( int k=0; k<bytes.length; k++ ) { | 35 for( int k=0; k<bytes.length; k++ ) { |
37 bytes[k] = binary[start+k]; | 36 bytes[k] = binary[start+k]; |
38 } | 37 } |
39 return bytes; | 38 return bytes; |
40 } | 39 } |
41 | 40 |
42 @LuanMethod public static byte[] binary(byte... bytes) { | 41 public static byte[] binary(byte... bytes) { |
43 return bytes; | 42 return bytes; |
44 } | 43 } |
45 | 44 |
46 private static String toString(byte[] a) { | 45 private static String toString(byte[] a) { |
47 char[] ac = new char[a.length]; | 46 char[] ac = new char[a.length]; |