Browse Source

Regeneration of shared (with manual fixes)

Stan Hebben 6 years ago
parent
commit
f943f53cca

+ 10
- 10
Shared/src/main/java/compactio/CompactBytesDataInput.java View File

39
     
39
     
40
     @Override
40
     @Override
41
     public boolean readBool() {
41
     public boolean readBool() {
42
-        return this.readByte() != (byte)0;
42
+        return (this.readByte() & 0xFF) != (0 & 0xFF);
43
     }
43
     }
44
     
44
     
45
     @Override
45
     @Override
46
     public int readByte() {
46
     public int readByte() {
47
-        return (data[offset++]) & 0xFF;
47
+        return data[offset++];
48
     }
48
     }
49
     
49
     
50
     @Override
50
     @Override
51
     public byte readSByte() {
51
     public byte readSByte() {
52
-        return data[offset++];
52
+        return (byte)(data[offset++]);
53
     }
53
     }
54
     
54
     
55
     @Override
55
     @Override
190
             int bvalue = this.readByte();
190
             int bvalue = this.readByte();
191
             int remainingBits = result.length - 8 * i;
191
             int remainingBits = result.length - 8 * i;
192
             if (remainingBits > 0)
192
             if (remainingBits > 0)
193
-                result[i * 8 + 0] = (bvalue & (byte)1) > (byte)0;
193
+                result[i * 8 + 0] = ((bvalue & 1) & 0xFF) > (0 & 0xFF);
194
             if (remainingBits > 1)
194
             if (remainingBits > 1)
195
-                result[i * 8 + 2] = (bvalue & (byte)4) > (byte)0;
195
+                result[i * 8 + 2] = ((bvalue & 4) & 0xFF) > (0 & 0xFF);
196
             if (remainingBits > 3)
196
             if (remainingBits > 3)
197
-                result[i * 8 + 3] = (bvalue & (byte)8) > (byte)0;
197
+                result[i * 8 + 3] = ((bvalue & 8) & 0xFF) > (0 & 0xFF);
198
             if (remainingBits > 4)
198
             if (remainingBits > 4)
199
-                result[i * 8 + 4] = (bvalue & (byte)16) > (byte)0;
199
+                result[i * 8 + 4] = ((bvalue & 16) & 0xFF) > (0 & 0xFF);
200
             if (remainingBits > 5)
200
             if (remainingBits > 5)
201
-                result[i * 8 + 5] = (bvalue & (byte)32) > (byte)0;
201
+                result[i * 8 + 5] = ((bvalue & 32) & 0xFF) > (0 & 0xFF);
202
             if (remainingBits > 6)
202
             if (remainingBits > 6)
203
-                result[i * 8 + 6] = (bvalue & (byte)64) > (byte)0;
203
+                result[i * 8 + 6] = ((bvalue & 64) & 0xFF) > (0 & 0xFF);
204
             if (remainingBits > 7)
204
             if (remainingBits > 7)
205
-                result[i * 8 + 7] = (bvalue & (byte)-128) > (byte)0;
205
+                result[i * 8 + 7] = ((bvalue & 128) & 0xFF) > (0 & 0xFF);
206
         }
206
         }
207
         return result;
207
         return result;
208
     }
208
     }

+ 3
- 3
Shared/src/main/java/listeners/ListenerList.java View File

1
 package listeners;
1
 package listeners;
2
 
2
 
3
-import zsynthetic.FunctionTToVoid;
3
+import java.util.function.Consumer;
4
 
4
 
5
 public final class ListenerList<T> {
5
 public final class ListenerList<T> {
6
     public static final int PRIORITY_HIGH = 100;
6
     public static final int PRIORITY_HIGH = 100;
43
         this.first = this.last = null;
43
         this.first = this.last = null;
44
     }
44
     }
45
     
45
     
46
-    public void accept(FunctionTToVoid<T> consumer) {
46
+    public void accept(Consumer<T> consumer) {
47
         ListenerList<T>.EventListenerNode current = first;
47
         ListenerList<T>.EventListenerNode current = first;
48
         while (current != null) {
48
         while (current != null) {
49
-            consumer.invoke(current.getListener());
49
+            consumer.accept(current.getListener());
50
             current = current.next;
50
             current = current.next;
51
         }
51
         }
52
     }
52
     }

+ 3
- 3
Shared/src/main/java/live/ImmutableLiveObject.java View File

1
 package live;
1
 package live;
2
 
2
 
3
+import java.util.function.BiConsumer;
3
 import listeners.DummyListenerHandle;
4
 import listeners.DummyListenerHandle;
4
 import listeners.ListenerHandle;
5
 import listeners.ListenerHandle;
5
-import zsynthetic.FunctionTTToVoid;
6
 
6
 
7
 public final class ImmutableLiveObject<T> implements LiveObject<T> {
7
 public final class ImmutableLiveObject<T> implements LiveObject<T> {
8
     public final T value;
8
     public final T value;
12
     }
12
     }
13
     
13
     
14
     @Override
14
     @Override
15
-    public ListenerHandle<FunctionTTToVoid<T>> addListener(FunctionTTToVoid<T> listener) {
16
-        return new DummyListenerHandle<FunctionTTToVoid<T>>(listener);
15
+    public ListenerHandle<BiConsumer<T, T>> addListener(BiConsumer<T, T> listener) {
16
+        return new DummyListenerHandle<BiConsumer<T, T>>(listener);
17
     }
17
     }
18
     
18
     
19
     public T getValue() {
19
     public T getValue() {

+ 3
- 3
Shared/src/main/java/live/ImmutableLiveString.java View File

1
 package live;
1
 package live;
2
 
2
 
3
+import java.util.function.BiConsumer;
3
 import listeners.DummyListenerHandle;
4
 import listeners.DummyListenerHandle;
4
 import listeners.ListenerHandle;
5
 import listeners.ListenerHandle;
5
-import zsynthetic.FunctionStringStringToVoid;
6
 
6
 
7
 public final class ImmutableLiveString implements LiveString {
7
 public final class ImmutableLiveString implements LiveString {
8
     public final String value;
8
     public final String value;
12
     }
12
     }
13
     
13
     
14
     @Override
14
     @Override
15
-    public ListenerHandle<FunctionStringStringToVoid> addListener(FunctionStringStringToVoid listener) {
16
-        return new DummyListenerHandle<FunctionStringStringToVoid>(listener);
15
+    public ListenerHandle<BiConsumer<String, String>> addListener(BiConsumer<String, String> listener) {
16
+        return new DummyListenerHandle<BiConsumer<String, String>>(listener);
17
     }
17
     }
18
     
18
     
19
     public String getValue() {
19
     public String getValue() {

+ 2
- 2
Shared/src/main/java/live/LiveObject.java View File

1
 package live;
1
 package live;
2
 
2
 
3
+import java.util.function.BiConsumer;
3
 import listeners.ListenerHandle;
4
 import listeners.ListenerHandle;
4
-import zsynthetic.FunctionTTToVoid;
5
 
5
 
6
 public interface LiveObject<T> {
6
 public interface LiveObject<T> {
7
     T getValue();
7
     T getValue();
8
     
8
     
9
-    ListenerHandle<FunctionTTToVoid<T>> addListener(FunctionTTToVoid<T> listener);
9
+    ListenerHandle<BiConsumer<T, T>> addListener(BiConsumer<T, T> listener);
10
 }
10
 }

+ 2
- 2
Shared/src/main/java/live/LiveString.java View File

1
 package live;
1
 package live;
2
 
2
 
3
+import java.util.function.BiConsumer;
3
 import listeners.ListenerHandle;
4
 import listeners.ListenerHandle;
4
-import zsynthetic.FunctionStringStringToVoid;
5
 
5
 
6
 public interface LiveString {
6
 public interface LiveString {
7
     String getValue();
7
     String getValue();
8
     
8
     
9
-    ListenerHandle<FunctionStringStringToVoid> addListener(FunctionStringStringToVoid listener);
9
+    ListenerHandle<BiConsumer<String, String>> addListener(BiConsumer<String, String> listener);
10
 }
10
 }

+ 1
- 2
Shared/src/main/java/org/openzen/zencode/shared/CodePosition.java View File

3
 public final class CodePosition {
3
 public final class CodePosition {
4
     public static final CodePosition BUILTIN = new CodePosition(new VirtualSourceFile("builtin"), 0, 0, 0, 0);
4
     public static final CodePosition BUILTIN = new CodePosition(new VirtualSourceFile("builtin"), 0, 0, 0, 0);
5
     public static final CodePosition NATIVE = new CodePosition(new VirtualSourceFile("native"), 0, 0, 0, 0);
5
     public static final CodePosition NATIVE = new CodePosition(new VirtualSourceFile("native"), 0, 0, 0, 0);
6
-	public static final CodePosition META = new CodePosition(new VirtualSourceFile("meta"), 0, 0, 0, 0);
6
+    public static final CodePosition META = new CodePosition(new VirtualSourceFile("meta"), 0, 0, 0, 0);
7
 	public static final CodePosition UNKNOWN = new CodePosition(new VirtualSourceFile("unknown"), 0, 0, 0, 0);
7
 	public static final CodePosition UNKNOWN = new CodePosition(new VirtualSourceFile("unknown"), 0, 0, 0, 0);
8
-	
9
     public final SourceFile file;
8
     public final SourceFile file;
10
     public final int fromLine;
9
     public final int fromLine;
11
     public final int fromLineOffset;
10
     public final int fromLineOffset;

+ 1
- 8
Shared/src/main/java/org/openzen/zencode/shared/CompileExceptionCode.java View File

69
 	VARIANT_OPTION_NOT_AN_EXPRESSION,
69
 	VARIANT_OPTION_NOT_AN_EXPRESSION,
70
 	DUPLICATE_GLOBAL,
70
 	DUPLICATE_GLOBAL,
71
 	CANNOT_INFER_RETURN_TYPE,
71
 	CANNOT_INFER_RETURN_TYPE,
72
-	INVALID_SUFFIX,
73
-	NO_SUCH_MODULE,
74
-	
75
-	NO_SUCH_STORAGE_TYPE,
76
-	INVALID_STORAGE_TYPE_ARGUMENTS,
77
-	STORAGE_NOT_SUPPORTED,
78
-	INCOMPATIBLE_STORAGE_TAG,
79
-	INVALID_TYPE_ARGUMENTS
72
+	INVALID_SUFFIX
80
 }
73
 }

+ 2
- 2
Shared/src/main/java/org/openzen/zencode/shared/StringExpansion.java View File

32
 	public static Result<String, String> unescape(String self) {
32
 	public static Result<String, String> unescape(String self) {
33
 	    if (!(self.charAt(0) == self.charAt(self.length() - 1)))
33
 	    if (!(self.charAt(0) == self.charAt(self.length() - 1)))
34
 	        throw new AssertionError("Unbalanced quotes");
34
 	        throw new AssertionError("Unbalanced quotes");
35
-	    if (!(self.charAt(0) == '@' && ArrayHelpers.contains(new String[] {"\"", "'"}, Character.toString(self.charAt(1))) || ArrayHelpers.contains(new String[] {"\"", "'"}, Character.toString(self.charAt(0)))))
35
+	    if (!(self.charAt(0) == '@' && ArrayHelpers.contains(new char[] {'"', '\''}, self.charAt(1)) || ArrayHelpers.contains(new char[] {'"', '\''}, self.charAt(0))))
36
 	        throw new AssertionError("String is not quoted");
36
 	        throw new AssertionError("String is not quoted");
37
 	    if (!(self.length() >= 2))
37
 	    if (!(self.length() >= 2))
38
 	        throw new AssertionError("String is not quoted");
38
 	        throw new AssertionError("String is not quoted");
109
 	                        return new Result.Error<>(((Result.Error<Integer, String>)temp5).value);
109
 	                        return new Result.Error<>(((Result.Error<Integer, String>)temp5).value);
110
 	                    int hex3 = ((Result.Ok<Integer, String>)temp5).value;
110
 	                    int hex3 = ((Result.Ok<Integer, String>)temp5).value;
111
 	                    i = i + 5;
111
 	                    i = i + 5;
112
-	                    result.append((char)hex0 << 12 | hex1 << 8 | hex2 << 4 | hex3);
112
+	                    result.append((char)(hex0 << 12 | hex1 << 8 | hex2 << 4 | hex3));
113
 	                    break;
113
 	                    break;
114
 	                default:
114
 	                default:
115
 	                    return new Error("Illegal escape sequence");
115
 	                    return new Error("Illegal escape sequence");

+ 22
- 22
Shared/src/main/java/stdlib/Arrays.java View File

5
 import java.util.HashMap;
5
 import java.util.HashMap;
6
 import java.util.List;
6
 import java.util.List;
7
 import java.util.Map;
7
 import java.util.Map;
8
-import zsynthetic.FunctionTToBool;
9
-import zsynthetic.FunctionTToU;
10
-import zsynthetic.FunctionTToVoid;
8
+import java.util.function.Consumer;
9
+import java.util.function.Function;
10
+import java.util.function.Predicate;
11
 import zsynthetic.FunctionUSizeTToBool;
11
 import zsynthetic.FunctionUSizeTToBool;
12
 import zsynthetic.FunctionUSizeTToU;
12
 import zsynthetic.FunctionUSizeTToU;
13
 import zsynthetic.FunctionUSizeTToVoid;
13
 import zsynthetic.FunctionUSizeTToVoid;
31
         }
31
         }
32
     }
32
     }
33
     
33
     
34
-    public static <U, T> U[] map(Class<T> typeOfT, T[] self, Class<U> typeOfU, FunctionTToU<U, T> projection) {
34
+    public static <U, T> U[] map(Class<T> typeOfT, T[] self, Class<U> typeOfU, Function<T, U> projection) {
35
         U[] temp1 = (U[])(Array.newInstance(typeOfU, self.length));
35
         U[] temp1 = (U[])(Array.newInstance(typeOfU, self.length));
36
         for (int temp2 = 0; temp2 < temp1.length; temp2++)
36
         for (int temp2 = 0; temp2 < temp1.length; temp2++)
37
-            temp1[temp2] = projection.invoke(self[temp2]);
37
+            temp1[temp2] = projection.apply(self[temp2]);
38
         return temp1;
38
         return temp1;
39
     }
39
     }
40
     
40
     
41
-    public static <U, T> U[] map(Class<T> typeOfT, T[] self, Class<U> typeOfU, FunctionUSizeTToU<U, T> projection) {
41
+    public static <U, T> U[] map(Class<T> typeOfT, T[] self, Class<U> typeOfU, FunctionUSizeTToU<T, U> projection) {
42
         U[] temp1 = (U[])(Array.newInstance(typeOfU, self.length));
42
         U[] temp1 = (U[])(Array.newInstance(typeOfU, self.length));
43
         for (int temp2 = 0; temp2 < temp1.length; temp2++)
43
         for (int temp2 = 0; temp2 < temp1.length; temp2++)
44
             temp1[temp2] = projection.invoke(temp2, self[temp2]);
44
             temp1[temp2] = projection.invoke(temp2, self[temp2]);
45
         return temp1;
45
         return temp1;
46
     }
46
     }
47
     
47
     
48
-    public static <T> T[] filter(Class<T> typeOfT, T[] self, FunctionTToBool<T> predicate) {
48
+    public static <T> T[] filter(Class<T> typeOfT, T[] self, Predicate<T> predicate) {
49
         List<T> values = new ArrayList<T>();
49
         List<T> values = new ArrayList<T>();
50
         for (T value : self)
50
         for (T value : self)
51
-            if (predicate.invoke(value))
51
+            if (predicate.test(value))
52
                 values.add(value);
52
                 values.add(value);
53
         return values.toArray((T[])(Array.newInstance(typeOfT, values.size())));
53
         return values.toArray((T[])(Array.newInstance(typeOfT, values.size())));
54
     }
54
     }
63
         return values.toArray((T[])(Array.newInstance(typeOfT, values.size())));
63
         return values.toArray((T[])(Array.newInstance(typeOfT, values.size())));
64
     }
64
     }
65
     
65
     
66
-    public static <T> void each(Class<T> typeOfT, T[] self, FunctionTToVoid<T> consumer) {
66
+    public static <T> void each(Class<T> typeOfT, T[] self, Consumer<T> consumer) {
67
         for (T value : self)
67
         for (T value : self)
68
-            consumer.invoke(value);
68
+            consumer.accept(value);
69
     }
69
     }
70
     
70
     
71
     public static <T> void each(Class<T> typeOfT, T[] self, FunctionUSizeTToVoid<T> consumer) {
71
     public static <T> void each(Class<T> typeOfT, T[] self, FunctionUSizeTToVoid<T> consumer) {
75
         }
75
         }
76
     }
76
     }
77
     
77
     
78
-    public static <T> boolean contains(Class<T> typeOfT, T[] self, FunctionTToBool<T> predicate) {
78
+    public static <T> boolean contains(Class<T> typeOfT, T[] self, Predicate<T> predicate) {
79
         for (T value : self)
79
         for (T value : self)
80
-            if (predicate.invoke(value))
80
+            if (predicate.test(value))
81
                 return true;
81
                 return true;
82
         return false;
82
         return false;
83
     }
83
     }
91
         return false;
91
         return false;
92
     }
92
     }
93
     
93
     
94
-    public static <T> boolean all(Class<T> typeOfT, T[] self, FunctionTToBool<T> predicate) {
94
+    public static <T> boolean all(Class<T> typeOfT, T[] self, Predicate<T> predicate) {
95
         for (T value : self)
95
         for (T value : self)
96
-            if (!predicate.invoke(value))
96
+            if (!predicate.test(value))
97
                 return false;
97
                 return false;
98
         return true;
98
         return true;
99
     }
99
     }
107
         return true;
107
         return true;
108
     }
108
     }
109
     
109
     
110
-    public static <T> T first(Class<T> typeOfT, T[] self, FunctionTToBool<T> predicate) {
110
+    public static <T> T first(Class<T> typeOfT, T[] self, Predicate<T> predicate) {
111
         for (T value : self)
111
         for (T value : self)
112
-            if (predicate.invoke(value))
112
+            if (predicate.test(value))
113
                 return value;
113
                 return value;
114
         return null;
114
         return null;
115
     }
115
     }
123
         return null;
123
         return null;
124
     }
124
     }
125
     
125
     
126
-    public static <T> T last(Class<T> typeOfT, T[] self, FunctionTToBool<T> predicate) {
126
+    public static <T> T last(Class<T> typeOfT, T[] self, Predicate<T> predicate) {
127
         int i = self.length;
127
         int i = self.length;
128
         while (i > 0) {
128
         while (i > 0) {
129
             i--;
129
             i--;
130
-            if (predicate.invoke(self[i]))
130
+            if (predicate.test(self[i]))
131
                 return self[i];
131
                 return self[i];
132
         }
132
         }
133
         return null;
133
         return null;
143
         return null;
143
         return null;
144
     }
144
     }
145
     
145
     
146
-    public static <T> int count(Class<T> typeOfT, T[] self, FunctionTToBool<T> predicate) {
146
+    public static <T> int count(Class<T> typeOfT, T[] self, Predicate<T> predicate) {
147
         int result = 0;
147
         int result = 0;
148
         for (T value : self)
148
         for (T value : self)
149
-            if (predicate.invoke(value))
149
+            if (predicate.test(value))
150
                 result++;
150
                 result++;
151
         return result;
151
         return result;
152
     }
152
     }
161
         return result;
161
         return result;
162
     }
162
     }
163
     
163
     
164
-    public static <K, T> Map<K, T> index(Class<T> typeOfT, T[] self, Class<K> typeOfK, FunctionTToU<K, T> key) {
164
+    public static <K, T> Map<K, T> index(Class<T> typeOfT, T[] self, Class<K> typeOfK, Function<T, K> key) {
165
         Map<K, T> result = new HashMap<>();
165
         Map<K, T> result = new HashMap<>();
166
         for (T value : self)
166
         for (T value : self)
167
-            result.put(key.invoke(value), value);
167
+            result.put(key.apply(value), value);
168
         return result;
168
         return result;
169
     }
169
     }
170
 }
170
 }

+ 3
- 3
Shared/src/main/java/stdlib/Assoc.java View File

2
 
2
 
3
 import java.util.HashMap;
3
 import java.util.HashMap;
4
 import java.util.Map;
4
 import java.util.Map;
5
-import zsynthetic.FunctionTToU;
5
+import java.util.function.Function;
6
 
6
 
7
 public final class Assoc {
7
 public final class Assoc {
8
     private Assoc() {}
8
     private Assoc() {}
9
-	static <W, K, V> Map<K, W> mapValues(Class<K> typeOfK, Class<V> typeOfV, Map<K, V> self, Class<W> typeOfW, FunctionTToU<W, V> projection) {
9
+	static <W, K, V> Map<K, W> mapValues(Class<K> typeOfK, Class<V> typeOfV, Map<K, V> self, Class<W> typeOfW, Function<V, W> projection) {
10
 	    Map<K, W> result = new HashMap<>();
10
 	    Map<K, W> result = new HashMap<>();
11
 	    for (Map.Entry<K, V> temp1 : self.entrySet()) {
11
 	    for (Map.Entry<K, V> temp1 : self.entrySet()) {
12
 	        K k = temp1.getKey();
12
 	        K k = temp1.getKey();
13
 	        V v = temp1.getValue();
13
 	        V v = temp1.getValue();
14
-	        result.put(k, projection.invoke(v));
14
+	        result.put(k, projection.apply(v));
15
 	    }
15
 	    }
16
 	    return result;
16
 	    return result;
17
 	}
17
 	}

+ 5
- 0
Shared/src/main/java/stdlib/Integers.java View File

1
+package stdlib;
2
+
3
+final class Integers {
4
+    private Integers() {}
5
+}

+ 7
- 8
Shared/src/main/java/stdlib/Result.java View File

1
 package stdlib;
1
 package stdlib;
2
 
2
 
3
-import zsynthetic.FunctionTToResultWithUV;
4
-import zsynthetic.FunctionTToU;
3
+import java.util.function.Function;
5
 
4
 
6
 public abstract class Result<T, E> {
5
 public abstract class Result<T, E> {
7
-    public <R> Result<R, E> then(Class<R> typeOfR, FunctionTToResultWithUV<R, E, T> fn) {
6
+    public <R> Result<R, E> then(Class<R> typeOfR, Function<T, Result<R, E>> fn) {
8
         Result<R, E> temp1;
7
         Result<R, E> temp1;
9
         switch (this.getDiscriminant()) {
8
         switch (this.getDiscriminant()) {
10
             case Ok:
9
             case Ok:
11
                 T result = ((Result.Ok<T, E>)this).value;
10
                 T result = ((Result.Ok<T, E>)this).value;
12
-                temp1 = fn.invoke(result);
11
+                temp1 = fn.apply(result);
13
                 break;
12
                 break;
14
             case Error:
13
             case Error:
15
                 E error = ((Result.Error<T, E>)this).value;
14
                 E error = ((Result.Error<T, E>)this).value;
21
         return temp1;
20
         return temp1;
22
     }
21
     }
23
     
22
     
24
-    public <X> Result<T, X> handle(Class<X> typeOfX, FunctionTToResultWithUV<T, X, E> handler) {
23
+    public <X> Result<T, X> handle(Class<X> typeOfX, Function<E, Result<T, X>> handler) {
25
         Result<T, X> temp1;
24
         Result<T, X> temp1;
26
         switch (this.getDiscriminant()) {
25
         switch (this.getDiscriminant()) {
27
             case Ok:
26
             case Ok:
30
                 break;
29
                 break;
31
             case Error:
30
             case Error:
32
                 E error = ((Result.Error<T, E>)this).value;
31
                 E error = ((Result.Error<T, E>)this).value;
33
-                temp1 = handler.invoke(error);
32
+                temp1 = handler.apply(error);
34
                 break;
33
                 break;
35
             default:
34
             default:
36
                 throw new AssertionError("Missing case");
35
                 throw new AssertionError("Missing case");
71
         return temp1;
70
         return temp1;
72
     }
71
     }
73
     
72
     
74
-    public T orElse(FunctionTToU<T, E> other) {
73
+    public T orElse(Function<E, T> other) {
75
         T temp1;
74
         T temp1;
76
         switch (this.getDiscriminant()) {
75
         switch (this.getDiscriminant()) {
77
             case Ok:
76
             case Ok:
80
                 break;
79
                 break;
81
             case Error:
80
             case Error:
82
                 E error = ((Result.Error<T, E>)this).value;
81
                 E error = ((Result.Error<T, E>)this).value;
83
-                temp1 = other.invoke(error);
82
+                temp1 = other.apply(error);
84
                 break;
83
                 break;
85
             default:
84
             default:
86
                 throw new AssertionError("Missing case");
85
                 throw new AssertionError("Missing case");

+ 5
- 0
Shared/src/main/java/stdlib/USize.java View File

1
+package stdlib;
2
+
3
+final class USize {
4
+    private USize() {}
5
+}

+ 7
- 0
Shared/src/main/java/zsynthetic/ArrayHelpers.java View File

7
                 return true;
7
                 return true;
8
         return false;
8
         return false;
9
     }
9
     }
10
+	
11
+	public static boolean contains(char[] haystack, char needle) {
12
+        for (int i = 0; i < haystack.length; i++)
13
+            if (haystack[i] == needle)
14
+                return true;
15
+        return false;
16
+    }
10
 }
17
 }

+ 1
- 1
Shared/src/main/java/zsynthetic/FunctionBoolBoolToVoid.java View File

2
 
2
 
3
 @FunctionalInterface
3
 @FunctionalInterface
4
 public interface FunctionBoolBoolToVoid {
4
 public interface FunctionBoolBoolToVoid {
5
-    void invoke(boolean oldValue, boolean newValue);
5
+    void invoke(boolean a, boolean b);
6
 }
6
 }

+ 1
- 1
Shared/src/main/java/zsynthetic/FunctionIntIntToVoid.java View File

2
 
2
 
3
 @FunctionalInterface
3
 @FunctionalInterface
4
 public interface FunctionIntIntToVoid {
4
 public interface FunctionIntIntToVoid {
5
-    void invoke(int oldValue, int newValue);
5
+    void invoke(int a, int b);
6
 }
6
 }

+ 1
- 1
Shared/src/main/java/zsynthetic/FunctionUSizeTToBool.java View File

2
 
2
 
3
 @FunctionalInterface
3
 @FunctionalInterface
4
 public interface FunctionUSizeTToBool<T> {
4
 public interface FunctionUSizeTToBool<T> {
5
-    boolean invoke(int index, T value);
5
+    boolean invoke(int a, T b);
6
 }
6
 }

+ 2
- 2
Shared/src/main/java/zsynthetic/FunctionUSizeTToU.java View File

1
 package zsynthetic;
1
 package zsynthetic;
2
 
2
 
3
 @FunctionalInterface
3
 @FunctionalInterface
4
-public interface FunctionUSizeTToU<U, T> {
5
-    U invoke(int index, T value);
4
+public interface FunctionUSizeTToU<T, U> {
5
+    U invoke(int a, T b);
6
 }
6
 }

+ 1
- 1
Shared/src/main/java/zsynthetic/FunctionUSizeTToVoid.java View File

2
 
2
 
3
 @FunctionalInterface
3
 @FunctionalInterface
4
 public interface FunctionUSizeTToVoid<T> {
4
 public interface FunctionUSizeTToVoid<T> {
5
-    void invoke(int index, T value);
5
+    void invoke(int a, T b);
6
 }
6
 }

+ 23
- 0
Shared/src/main/java/zsynthetic/Shared.java View File

1
+package zsynthetic;
2
+
3
+public final class Shared<T extends AutoCloseable> {
4
+    private final T value;
5
+    private int refcount = 1;
6
+    
7
+    public Shared(T value) {
8
+        this.value = value;
9
+    }
10
+    
11
+    public synchronized void addRef() {
12
+        refcount++;
13
+    }
14
+    
15
+    public synchronized void release() {
16
+        refcount--;
17
+        if (refcount == 0) {
18
+            try {
19
+                value.close();
20
+            } catch (Exception ex) {}
21
+        }
22
+    }
23
+}

Loading…
Cancel
Save