Browse Source

Update generated code

Stan Hebben 6 years ago
parent
commit
da051f56ce

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

@@ -4,15 +4,22 @@ import java.nio.charset.StandardCharsets;
4 4
 import java.util.Arrays;
5 5
 
6 6
 public final class CompactBytesDataInput implements CompactDataInput, AutoCloseable {
7
+    private static final int P6 = 1 << 6;
7 8
     private static final int P7 = 1 << 7;
9
+    private static final int P13 = 1 << 13;
8 10
     private static final int P14 = 1 << 14;
11
+    private static final int P20 = 1 << 20;
9 12
     private static final int P21 = 1 << 21;
13
+    private static final int P27 = 1 << 27;
10 14
     private static final int P28 = 1 << 28;
15
+    private static final long P34 = 1L << 34;
11 16
     private static final long P35 = 1L << 35;
17
+    private static final long P41 = 1L << 41;
12 18
     private static final long P42 = 1L << 42;
19
+    private static final long P48 = 1L << 48;
13 20
     private static final long P49 = 1L << 49;
21
+    private static final long P55 = 1L << 55;
14 22
     private static final long P56 = 1L << 56;
15
-	
16 23
     private final byte[] data;
17 24
     private int offset;
18 25
     
@@ -86,22 +93,22 @@ public final class CompactBytesDataInput implements CompactDataInput, AutoClosea
86 93
     @Override
87 94
     public int readVarInt() {
88 95
         int value = this.readVarUInt();
89
-        return Integer.compareUnsigned(value & 1, 0) == 0 ? value >>> 1 : -((value >>> 1) + 1);
96
+        return (value & 1) == 0 ? value >>> 1 : -((value >>> 1) + 1);
90 97
     }
91 98
     
92 99
     @Override
93 100
     public int readVarUInt() {
94 101
         int value = data[offset++] & 0xFF;
95
-        if (Integer.compareUnsigned(value & CompactBytesDataInput.P7, 0) == 0)
102
+        if ((value & CompactBytesDataInput.P7) == 0)
96 103
             return value;
97 104
         value = value & CompactBytesDataInput.P7 - 1 | (data[offset++] & 0xFF) << 7;
98
-        if (Integer.compareUnsigned(value & CompactBytesDataInput.P14, 0) == 0)
105
+        if ((value & CompactBytesDataInput.P14) == 0)
99 106
             return value;
100 107
         value = value & CompactBytesDataInput.P14 - 1 | (data[offset++] & 0xFF) << 14;
101
-        if (Integer.compareUnsigned(value & CompactBytesDataInput.P21, 0) == 0)
108
+        if ((value & CompactBytesDataInput.P21) == 0)
102 109
             return value;
103 110
         value = value & CompactBytesDataInput.P21 - 1 | (data[offset++] & 0xFF) << 21;
104
-        if (Integer.compareUnsigned(value & CompactBytesDataInput.P28, 0) == 0)
111
+        if ((value & CompactBytesDataInput.P28) == 0)
105 112
             return value;
106 113
         return value & CompactBytesDataInput.P28 - 1 | (data[offset++] & 0xFF) << 28;
107 114
     }

+ 9
- 0
Shared/src/main/java/live/MutableLiveBool.java View File

@@ -0,0 +1,9 @@
1
+package live;
2
+
3
+public interface MutableLiveBool extends LiveBool {
4
+    void setValue(boolean value);
5
+	
6
+	default void toggle() {
7
+		setValue(!getValue());
8
+	}
9
+}

+ 33
- 0
Shared/src/main/java/live/SimpleLiveBool.java View File

@@ -0,0 +1,33 @@
1
+package live;
2
+
3
+import listeners.ListenerHandle;
4
+import listeners.ListenerList;
5
+import zsynthetic.FunctionBoolBoolToVoid;
6
+
7
+public final class SimpleLiveBool implements MutableLiveBool {
8
+    private final ListenerList<FunctionBoolBoolToVoid> listeners = new ListenerList<FunctionBoolBoolToVoid>();
9
+    private boolean value;
10
+    
11
+    public SimpleLiveBool(boolean value) {
12
+        this.value = value;
13
+    }
14
+    
15
+    @Override
16
+    public ListenerHandle<FunctionBoolBoolToVoid> addListener(FunctionBoolBoolToVoid listener) {
17
+        return listeners.add(listener);
18
+    }
19
+    
20
+    @Override
21
+    public void setValue(boolean value) {
22
+        if (value == this.value)
23
+            return;
24
+        boolean oldValue = this.value;
25
+        this.value = value;
26
+        listeners.accept(listener -> 
27
+        listener.invoke(oldValue, this.value));
28
+    }
29
+    
30
+    public boolean getValue() {
31
+        return value;
32
+    }
33
+}

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

@@ -6,7 +6,6 @@ public final class CodePosition {
6 6
     public static final CodePosition META = new CodePosition(new VirtualSourceFile("meta"), 0, 0, 0, 0);
7 7
     public static final CodePosition UNKNOWN = new CodePosition(new VirtualSourceFile("unknown"), 0, 0, 0, 0);
8 8
     public static final CodePosition GENERATED = new CodePosition(new VirtualSourceFile("generated"), 0, 0, 0, 0);
9
-	
10 9
     public final SourceFile file;
11 10
     public final int fromLine;
12 11
     public final int fromLineOffset;

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

@@ -7,11 +7,10 @@ public final class CompileException extends Exception {
7 7
     
8 8
     public final CodePosition position;
9 9
     public final CompileExceptionCode code;
10
-	public final String message;
11
-    
10
+    public final String message;
11
+	
12 12
     public CompileException(CodePosition position, CompileExceptionCode code, String message) {
13 13
         super(position.toString() + ": [" + code.toString() + "] " + message);
14
-		
15 14
         this.position = position;
16 15
         this.code = code;
17 16
 		this.message = message;

+ 0
- 1
Shared/src/main/java/org/openzen/zencode/shared/LiteralSourceFile.java View File

@@ -23,7 +23,6 @@ public final class LiteralSourceFile implements SourceFile {
23 23
         throw new AssertionError("Cannot update literal source files");
24 24
     }
25 25
     
26
-	@Override
27 26
     public String getFilename() {
28 27
         return filename;
29 28
     }

Loading…
Cancel
Save