Browse Source

Updated libraries to use the storage tags properly.

Stan Hebben 6 years ago
parent
commit
ce4064f681

+ 3
- 3
compactio/src/CompactBytesDataInput.zs View File

@@ -16,15 +16,15 @@ export class CompactBytesDataInput {
16 16
 	private const P55 as ulong = 1UL << 55;
17 17
 	private const P56 as ulong = 1UL << 56;
18 18
 	
19
-	val data as const byte[];
19
+	val data as byte[]`borrow:this;
20 20
 	var offset as usize : get;
21 21
 	
22
-	public this(data as const byte[]) {
22
+	public this(data as byte[]`borrow:this) {
23 23
 		this.data = data;
24 24
 		this.offset = 0;
25 25
 	}
26 26
 	
27
-	public this(data as const byte[], offset as usize) {
27
+	public this(data as byte[]`borrow:this, offset as usize) {
28 28
 		this.data = data;
29 29
 		this.offset = offset;
30 30
 	}

+ 50
- 50
compactio/src/CompactDataInput.zs View File

@@ -1,103 +1,103 @@
1 1
 export interface CompactDataInput {
2
-	readBool() as bool;
2
+	readBool`mutable() as bool;
3 3
 	
4
-	readByte() as sbyte;
4
+	readByte`mutable() as byte;
5 5
 	
6
-	readSByte() as byte;
6
+	readSByte`mutable() as sbyte;
7 7
 	
8
-	readShort() as short;
8
+	readShort`mutable() as short;
9 9
 	
10
-	readUShort() as ushort;
10
+	readUShort`mutable() as ushort;
11 11
 	
12
-	readInt() as int;
12
+	readInt`mutable() as int;
13 13
 	
14
-	readUInt() as uint;
14
+	readUInt`mutable() as uint;
15 15
 	
16
-	readLong() as long;
16
+	readLong`mutable() as long;
17 17
 	
18
-	readULong() as ulong;
18
+	readULong`mutable() as ulong;
19 19
 	
20
-	readVarInt() as int;
20
+	readVarInt`mutable() as int;
21 21
 	
22
-	readVarUInt() as uint;
22
+	readVarUInt`mutable() as uint;
23 23
 	
24
-	readVarLong() as long;
24
+	readVarLong`mutable() as long;
25 25
 	
26
-	readVarULong() as ulong;
26
+	readVarULong`mutable() as ulong;
27 27
 	
28
-	readFloat() as float;
28
+	readFloat`mutable() as float;
29 29
 	
30
-	readDouble() as double;
30
+	readDouble`mutable() as double;
31 31
 	
32
-	readChar() as char;
32
+	readChar`mutable() as char;
33 33
 	
34
-	readString() as string;
34
+	readString`mutable() as string;
35 35
 	
36
-	readBytes() as byte[];
36
+	readBytes`mutable() as byte[];
37 37
 	
38
-	readRawBytes(length as usize) as byte[];
38
+	readRawBytes`mutable(length as usize) as byte[];
39 39
 	
40
-	readBoolArray() as bool[];
40
+	readBoolArray`mutable() as bool[];
41 41
 	
42
-	readByteArray() as byte[];
42
+	readByteArray`mutable() as byte[];
43 43
 	
44
-	readSByteArray() as sbyte[];
44
+	readSByteArray`mutable() as sbyte[];
45 45
 	
46
-	readShortArray() as short[];
46
+	readShortArray`mutable() as short[];
47 47
 	
48
-	readShortArrayRaw(length as usize) as short[];
48
+	readShortArrayRaw`mutable(length as usize) as short[];
49 49
 	
50
-	readUShortArray() as ushort[];
50
+	readUShortArray`mutable() as ushort[];
51 51
 	
52
-	readUShortArrayRaw(length as usize) as ushort[];
52
+	readUShortArrayRaw`mutable(length as usize) as ushort[];
53 53
 	
54
-	readVarIntArray() as int[];
54
+	readVarIntArray`mutable() as int[];
55 55
 	
56
-	readVarIntArrayRaw(length as usize) as int[];
56
+	readVarIntArrayRaw`mutable(length as usize) as int[];
57 57
 	
58
-	readVarUIntArray() as uint[];
58
+	readVarUIntArray`mutable() as uint[];
59 59
 	
60
-	readVarUIntArrayRaw(length as usize) as uint[];
60
+	readVarUIntArrayRaw`mutable(length as usize) as uint[];
61 61
 	
62
-	readIntArray() as int[];
62
+	readIntArray`mutable() as int[];
63 63
 	
64
-	readIntArrayRaw(length as usize) as int[];
64
+	readIntArrayRaw`mutable(length as usize) as int[];
65 65
 	
66
-	readUIntArray() as uint[];
66
+	readUIntArray`mutable() as uint[];
67 67
 	
68
-	readUIntArrayRaw(length as usize) as uint[];
68
+	readUIntArrayRaw`mutable(length as usize) as uint[];
69 69
 	
70
-	readVarLongArray() as long[];
70
+	readVarLongArray`mutable() as long[];
71 71
 	
72
-	readVarLongArrayRaw(length as usize) as long[];
72
+	readVarLongArrayRaw`mutable(length as usize) as long[];
73 73
 	
74
-	readVarULongArray() as ulong[];
74
+	readVarULongArray`mutable() as ulong[];
75 75
 	
76
-	readVarULongArrayRaw(length as usize) as ulong[];
76
+	readVarULongArrayRaw`mutable(length as usize) as ulong[];
77 77
 	
78
-	readLongArray() as long[];
78
+	readLongArray`mutable() as long[];
79 79
 	
80
-	readLongArrayRaw(length as usize) as long[];
80
+	readLongArrayRaw`mutable(length as usize) as long[];
81 81
 	
82
-	readULongArray() as ulong[];
82
+	readULongArray`mutable() as ulong[];
83 83
 	
84
-	readULongArrayRaw(length as usize) as ulong[];
84
+	readULongArrayRaw`mutable(length as usize) as ulong[];
85 85
 	
86
-	readFloatArray() as float[];
86
+	readFloatArray`mutable() as float[];
87 87
 	
88
-	readFloatArrayRaw(length as usize) as float[];
88
+	readFloatArrayRaw`mutable(length as usize) as float[];
89 89
 	
90
-	readDoubleArray() as double[];
90
+	readDoubleArray`mutable() as double[];
91 91
 	
92
-	readDoubleArrayRaw(length as usize) as double[];
92
+	readDoubleArrayRaw`mutable(length as usize) as double[];
93 93
 	
94
-	readStringArray() as string[];
94
+	readStringArray`mutable() as string[];
95 95
 	
96
-	readStringArrayRaw(length as usize) as string[];
96
+	readStringArrayRaw`mutable(length as usize) as string[];
97 97
 	
98
-	skip(bytes as usize) as void;
98
+	skip`mutable(bytes as usize) as void;
99 99
 	
100
-	hasMore() as bool;
100
+	hasMore`mutable() as bool;
101 101
 	
102 102
 	~this;
103 103
 }

+ 7
- 7
listeners/src/ListenerList.zs View File

@@ -3,14 +3,14 @@ public class ListenerList<T> {
3 3
 	public const PRIORITY_DEFAULT = 0;
4 4
 	public const PRIORITY_LOW = -100;
5 5
 	
6
-	var first as EventListenerNode? = null;
7
-	var last as EventListenerNode? = null;
6
+	var first as EventListenerNode`borrow? = null;
7
+	var last as EventListenerNode`borrow? = null;
8 8
 	
9
-	public add(listener as T) as ListenerHandle<T>
9
+	public add(listener as T) as ListenerHandle<T>`unique
10 10
 		=> add(listener, PRIORITY_DEFAULT);
11 11
 	
12
-	public add(listener as T, priority as int) as ListenerHandle<T> {
13
-		val node = new EventListenerNode(listener, priority);
12
+	public add(listener as T, priority as int) as ListenerHandle<T>`unique {
13
+		val node = new EventListenerNode`unique(listener, priority);
14 14
 		
15 15
 		if first == null {
16 16
 			first = last = node;
@@ -55,8 +55,8 @@ public class ListenerList<T> {
55 55
 	private class EventListenerNode {
56 56
 		val listener as T : get;
57 57
 		val priority as int;
58
-		var next as EventListenerNode? = null;
59
-		var prev as EventListenerNode? = null;
58
+		var next as EventListenerNode`borrow? = null;
59
+		var prev as EventListenerNode`borrow? = null;
60 60
 		
61 61
 		public this(listener as T, priority as int) {
62 62
 			this.listener = listener;

+ 1
- 1
live/src/ImmutableLiveBool.zs View File

@@ -11,6 +11,6 @@ export class ImmutableLiveBool {
11 11
 	}
12 12
 	
13 13
 	public implements LiveBool {
14
-		addListener(listener) => new DummyListenerHandle<LiveBool.Listener>(listener);
14
+		addListener(listener) => new DummyListenerHandle<LiveBool.Listener>`unique(listener);
15 15
 	}
16 16
 }

+ 1
- 1
live/src/ImmutableLiveObject.zs View File

@@ -8,6 +8,6 @@ export class ImmutableLiveObject<T> {
8 8
 	}
9 9
 	
10 10
 	public implements LiveObject<T> {
11
-		addListener(listener) => new DummyListenerHandle<LiveObject<T>.Listener<T>>(listener);
11
+		addListener(listener) => new DummyListenerHandle<LiveObject<T>.Listener<T>>`unique(listener);
12 12
 	}
13 13
 }

+ 1
- 1
live/src/ImmutableLiveString.zs View File

@@ -8,6 +8,6 @@ export class ImmutableLiveString {
8 8
 	}
9 9
 	
10 10
 	public implements LiveString {
11
-		addListener(listener) => new DummyListenerHandle<LiveString.Listener>(listener);
11
+		addListener(listener) => new DummyListenerHandle<LiveString.Listener>`unique(listener);
12 12
 	}
13 13
 }

+ 1
- 1
live/src/LiveBool.zs View File

@@ -1,7 +1,7 @@
1 1
 public interface LiveBool {
2 2
 	get value as bool;
3 3
 	
4
-	addListener(listener as Listener) as ListenerHandle;
4
+	addListener(listener as Listener) as ListenerHandle`unique;
5 5
 	
6 6
 	alias Listener as function(oldValue as bool, newValue as bool) as void;
7 7
 	alias ListenerHandle as listeners.ListenerHandle<Listener>;

+ 1
- 1
live/src/LiveInt.zs View File

@@ -2,7 +2,7 @@ export interface LiveInt {
2 2
 	get value as int;
3 3
 	set value as int;
4 4
 	
5
-	addListener(listener as Listener) as ListenerHandle;
5
+	addListener(listener as Listener) as ListenerHandle`unique;
6 6
 	
7 7
 	alias Listener as function(oldValue as int, newValue as int) as void;
8 8
 	alias ListenerHandle as listeners.ListenerHandle<Listener>;

+ 1
- 1
live/src/LiveList.zs View File

@@ -10,7 +10,7 @@ export interface LiveList<T> : Iterable<T> {
10 10
 	
11 11
 	[](index as usize) as T;
12 12
 	
13
-	addListener(listener as Listener<T>) as ListenerHandle<T>;
13
+	addListener(listener as Listener<T>) as ListenerHandle<T>`unique;
14 14
 	
15 15
 	public interface Listener<T> {
16 16
 		onInserted(index as usize, value as T) as void;

+ 1
- 1
live/src/LiveObject.zs View File

@@ -1,7 +1,7 @@
1 1
 export interface LiveObject<T> {
2 2
 	get value as T;
3 3
 	
4
-	addListener(listener as Listener<T>) as ListenerHandle<T>;
4
+	addListener(listener as Listener<T>) as ListenerHandle<T>`unique;
5 5
 	
6 6
 	alias Listener<T> as function(oldValue as T, newValue as T) as void;
7 7
 	alias ListenerHandle<T> as listeners.ListenerHandle<Listener<T>>;

+ 1
- 1
live/src/LiveString.zs View File

@@ -1,7 +1,7 @@
1 1
 export interface LiveString {
2 2
 	get value as string;
3 3
 	
4
-	addListener(listener as Listener) as ListenerHandle;
4
+	addListener(listener as Listener) as ListenerHandle`unique;
5 5
 	
6 6
 	alias Listener as function(oldValue as string, newValue as string) as void;
7 7
 	alias ListenerHandle as listeners.ListenerHandle<Listener>;

+ 6
- 8
stdlib/src/Arrays.zs View File

@@ -41,24 +41,22 @@ export expand <T> T[] {
41 41
 		}
42 42
 	}
43 43
 	
44
-	// TODO: fix compilation for this
44
+	// TODO: fix compilation for these
45 45
 	/*[Native("reversed")]
46 46
 	public reversed() as T[] {
47 47
 		return new T[](this, (i, value) => this[length - i - 1]);
48 48
 	}*/
49 49
 	
50 50
 	[Native("mapValues")]
51
-	public map<U>(projection as function(value as T) as U) as U[] {
52
-		return new U[]<T>(this, projection);
53
-	}
51
+	public map<U>(projection as function(value as T`borrow) as U) as U[]
52
+		=> new U[]<T>(this, projection);
54 53
 	
55 54
 	[Native("mapKeyValues")]
56
-	public map<U>(projection as function(index as usize, value as T) as U) as U[] {
57
-		return new U[]<T>(this, projection);
58
-	}
55
+	public map<U>(projection as function(index as usize, value as T`borrow) as U) as U[]
56
+		=> new U[]<T>(this, projection);
59 57
 	
60 58
 	[Native("filterValues")]
61
-	public filter(predicate as function(value as T) as bool) as T[] {
59
+	public filter(predicate as function(value as T`borrow) as bool) as T[] {
62 60
 		var values = new List<T>();
63 61
 		for value in this
64 62
 			if predicate(value)

+ 2
- 3
stdlib/src/Chars.zs View File

@@ -1,5 +1,4 @@
1 1
 export expand char {
2
-	public times(number as usize) as string {
3
-		return new string(new char[](number, this));
4
-	}
2
+	public times(number as usize) as string
3
+		=> new string(new char[](number, this));
5 4
 }

+ 1
- 1
stdlib/src/StringBuildable.zs View File

@@ -1,5 +1,5 @@
1 1
 export interface StringBuildable {
2
-	toString(output as StringBuilder) as void;
2
+	toString(output as StringBuilder`borrow) as void;
3 3
 	
4 4
 	as string
5 5
 		=> new StringBuilder() << this;

+ 1
- 1
stdlib/src/StringBuilder.zs View File

@@ -41,7 +41,7 @@ export class StringBuilder {
41 41
 	[Native("appendString")]
42 42
 	public extern <<(value as string) as StringBuilder;
43 43
 	
44
-	public <<(value as StringBuildable) as StringBuilder {
44
+	public <<`shared(value as StringBuildable`borrow) as StringBuilder`shared {
45 45
 		value.toString(this);
46 46
 		return this;
47 47
 	}

+ 2
- 2
stdlib/src/Strings.zs View File

@@ -89,8 +89,8 @@ export expand string {
89 89
 		=> this.length >= length ? this : this + c.times(length - this.length);
90 90
 		
91 91
 	[Native("toAsciiBytes")]
92
-	public const toAsciiBytes() as byte[];
92
+	public const toAsciiBytes() as byte[]`unique;
93 93
 	
94 94
 	[Native("toUTF8Bytes")]
95
-	public const toUTF8Bytes() as byte[];
95
+	public const toUTF8Bytes() as byte[]`unique;
96 96
 }

Loading…
Cancel
Save