Browse Source

Moved into src folder

kindlich 4 years ago
parent
commit
b8a07c937b
No known key found for this signature in database
67 changed files with 199 additions and 15 deletions
  1. 1
    0
      .gitignore
  2. 5
    0
      build.gradle
  3. 0
    0
      src/main/zencode/collections/module.json
  4. 0
    0
      src/main/zencode/collections/src/HashSet.zs
  5. 0
    0
      src/main/zencode/collections/src/LinkedList.zs
  6. 0
    0
      src/main/zencode/collections/src/NoSuchElementException.zs
  7. 0
    0
      src/main/zencode/collections/src/Queue.zs
  8. 0
    0
      src/main/zencode/collections/src/Set.zs
  9. 0
    0
      src/main/zencode/collections/src/Stack.zs
  10. 0
    0
      src/main/zencode/compactio/module.json
  11. 0
    0
      src/main/zencode/compactio/src/CompactBytesDataInput.zs
  12. 0
    0
      src/main/zencode/compactio/src/CompactBytesDataOutput.zs
  13. 0
    0
      src/main/zencode/compactio/src/CompactDataInput.zs
  14. 0
    0
      src/main/zencode/compactio/src/CompactDataOutput.zs
  15. 0
    0
      src/main/zencode/io/module.json
  16. 0
    0
      src/main/zencode/io/src/IOException.zs
  17. 0
    0
      src/main/zencode/io/src/InputStream.zs
  18. 0
    0
      src/main/zencode/io/src/OutputStream.zs
  19. 0
    0
      src/main/zencode/io/src/Reader.zs
  20. 0
    0
      src/main/zencode/io/src/StringReader.zs
  21. 0
    0
      src/main/zencode/listeners/module.json
  22. 0
    0
      src/main/zencode/listeners/src/DummyListenerHandle.zs
  23. 0
    0
      src/main/zencode/listeners/src/ListenerHandle.zs
  24. 0
    0
      src/main/zencode/listeners/src/ListenerList.zs
  25. 0
    0
      src/main/zencode/live/module.json
  26. 0
    0
      src/main/zencode/live/src/ImmutableLiveBool.zs
  27. 0
    0
      src/main/zencode/live/src/ImmutableLiveObject.zs
  28. 0
    0
      src/main/zencode/live/src/ImmutableLiveString.zs
  29. 0
    0
      src/main/zencode/live/src/InverseLiveBool.zs
  30. 0
    0
      src/main/zencode/live/src/LiveArrayList.zs
  31. 0
    0
      src/main/zencode/live/src/LiveBool.zs
  32. 88
    0
      src/main/zencode/live/src/LiveConcatList.zs
  33. 15
    0
      src/main/zencode/live/src/LiveEmptyList.zs
  34. 9
    0
      src/main/zencode/live/src/LiveFloat.zs
  35. 0
    0
      src/main/zencode/live/src/LiveInt.zs
  36. 0
    0
      src/main/zencode/live/src/LiveList.zs
  37. 0
    0
      src/main/zencode/live/src/LiveObject.zs
  38. 0
    0
      src/main/zencode/live/src/LiveString.zs
  39. 2
    0
      src/main/zencode/live/src/MutableLiveBool.zs
  40. 0
    0
      src/main/zencode/live/src/MutableLiveInt.zs
  41. 0
    0
      src/main/zencode/live/src/MutableLiveList.zs
  42. 0
    0
      src/main/zencode/live/src/MutableLiveString.zs
  43. 1
    1
      src/main/zencode/live/src/SimpleLiveBool.zs
  44. 1
    1
      src/main/zencode/live/src/SimpleLiveInt.zs
  45. 1
    1
      src/main/zencode/live/src/SimpleLiveString.zs
  46. 22
    0
      src/main/zencode/stdlib/java.map
  47. 0
    0
      src/main/zencode/stdlib/module.json
  48. 3
    3
      src/main/zencode/stdlib/src/Arrays.zs
  49. 0
    0
      src/main/zencode/stdlib/src/Assoc.zs
  50. 0
    0
      src/main/zencode/stdlib/src/Chars.zs
  51. 0
    0
      src/main/zencode/stdlib/src/Comparable.zs
  52. 0
    0
      src/main/zencode/stdlib/src/EnforcementLevel.zs
  53. 0
    0
      src/main/zencode/stdlib/src/EqualsComparable.zs
  54. 0
    0
      src/main/zencode/stdlib/src/Exception.zs
  55. 0
    0
      src/main/zencode/stdlib/src/Hashable.zs
  56. 0
    0
      src/main/zencode/stdlib/src/IllegalArgumentException.zs
  57. 0
    0
      src/main/zencode/stdlib/src/Integers.zs
  58. 0
    0
      src/main/zencode/stdlib/src/Iterable.zs
  59. 4
    1
      src/main/zencode/stdlib/src/Iterator.zs
  60. 1
    1
      src/main/zencode/stdlib/src/List.zs
  61. 0
    0
      src/main/zencode/stdlib/src/Result.zs
  62. 1
    1
      src/main/zencode/stdlib/src/StringBuildable.zs
  63. 3
    3
      src/main/zencode/stdlib/src/StringBuilder.zs
  64. 27
    3
      src/main/zencode/stdlib/src/Strings.zs
  65. 0
    0
      src/main/zencode/stdlib/src/USize.zs
  66. 6
    0
      src/main/zencode/uuid/module.json
  67. 9
    0
      src/main/zencode/uuid/src/uuid.zs

+ 1
- 0
.gitignore View File

@@ -0,0 +1 @@
1
+build/

+ 5
- 0
build.gradle View File

@@ -0,0 +1,5 @@
1
+task zipItUp(type: Zip) {
2
+    from fileTree(dir: "${project.projectDir}/src/main/zencode")
3
+    archiveName "${project.name}.jar"
4
+}
5
+

collections/module.json → src/main/zencode/collections/module.json View File


collections/src/HashSet.zs → src/main/zencode/collections/src/HashSet.zs View File


collections/src/LinkedList.zs → src/main/zencode/collections/src/LinkedList.zs View File


collections/src/NoSuchElementException.zs → src/main/zencode/collections/src/NoSuchElementException.zs View File


collections/src/Queue.zs → src/main/zencode/collections/src/Queue.zs View File


collections/src/Set.zs → src/main/zencode/collections/src/Set.zs View File


collections/src/Stack.zs → src/main/zencode/collections/src/Stack.zs View File


compactio/module.json → src/main/zencode/compactio/module.json View File


compactio/src/CompactBytesDataInput.zs → src/main/zencode/compactio/src/CompactBytesDataInput.zs View File


compactio/src/CompactBytesDataOutput.zs → src/main/zencode/compactio/src/CompactBytesDataOutput.zs View File


compactio/src/CompactDataInput.zs → src/main/zencode/compactio/src/CompactDataInput.zs View File


compactio/src/CompactDataOutput.zs → src/main/zencode/compactio/src/CompactDataOutput.zs View File


io/module.json → src/main/zencode/io/module.json View File


io/src/IOException.zs → src/main/zencode/io/src/IOException.zs View File


io/src/InputStream.zs → src/main/zencode/io/src/InputStream.zs View File


io/src/OutputStream.zs → src/main/zencode/io/src/OutputStream.zs View File


io/src/Reader.zs → src/main/zencode/io/src/Reader.zs View File


io/src/StringReader.zs → src/main/zencode/io/src/StringReader.zs View File


listeners/module.json → src/main/zencode/listeners/module.json View File


listeners/src/DummyListenerHandle.zs → src/main/zencode/listeners/src/DummyListenerHandle.zs View File


listeners/src/ListenerHandle.zs → src/main/zencode/listeners/src/ListenerHandle.zs View File


listeners/src/ListenerList.zs → src/main/zencode/listeners/src/ListenerList.zs View File


live/module.json → src/main/zencode/live/module.json View File


live/src/ImmutableLiveBool.zs → src/main/zencode/live/src/ImmutableLiveBool.zs View File


live/src/ImmutableLiveObject.zs → src/main/zencode/live/src/ImmutableLiveObject.zs View File


live/src/ImmutableLiveString.zs → src/main/zencode/live/src/ImmutableLiveString.zs View File


live/src/InverseLiveBool.zs → src/main/zencode/live/src/InverseLiveBool.zs View File


live/src/LiveArrayList.zs → src/main/zencode/live/src/LiveArrayList.zs View File


live/src/LiveBool.zs → src/main/zencode/live/src/LiveBool.zs View File


+ 88
- 0
src/main/zencode/live/src/LiveConcatList.zs View File

@@ -0,0 +1,88 @@
1
+import listeners.ListenerList;
2
+import listeners.ListenerHandle;
3
+
4
+/*public class LiveConcatList<T> {
5
+	val listeners = new ListenerList<LiveList<T>.Listener<T>>;
6
+	val a as LiveList<T>;
7
+	val b as LiveList<T>;
8
+	
9
+	val aListener as ListenerHandle<LiveList<T>.Listener<T>>`unique;
10
+	val bListener as ListenerHandle<LiveList<T>.Listener<T>>`unique;
11
+	
12
+	public this(a as LiveList<T>, b as LiveList<T>) {
13
+		this.a = a;
14
+		this.b = b;
15
+		
16
+		aListener = a.addListener(new FirstListListener());
17
+		bListener = b.addListener(new SecondListListener());
18
+	}
19
+	
20
+	public implements LiveList<T> {
21
+		indexOf(value) {
22
+			var result = a.indexOf(value);
23
+			if result != null
24
+				return result;
25
+			
26
+			result = b.indexOf(value);
27
+			return result == null ? null : result + a.length;
28
+		}
29
+		
30
+		iterate() => new ConcatIterator;
31
+		
32
+		get length => a.length + b.length;
33
+		
34
+		[](index) => index < a.length ? a[index] : b[index - a.length];
35
+		
36
+		addListener(listener) => listeners.add(listener);
37
+		
38
+		iterate() => new ConcatIterator();
39
+	}
40
+	
41
+	private class ConcatIterator {
42
+		var firstList = true;
43
+		var iterator as Iterator<T>;
44
+		
45
+		public this() {
46
+			iterator = a.iterate();
47
+			if !iterator.hasNext {
48
+				firstList = false;
49
+				iterator = b.iterate();
50
+			}
51
+		}
52
+		
53
+		public implements Iterator<T> {
54
+			get hasNext => iterator.hasNext;
55
+			
56
+			next() {
57
+				val result = iterator.next();
58
+				if firstList && !iterator.hasNext {
59
+					firstList = false;
60
+					iterator = b.iterator();
61
+				}
62
+				return result;
63
+			}
64
+		}
65
+	}
66
+	
67
+	private class FirstListListener {
68
+		public implements LiveList<T>.Listener<T> {
69
+			onInserted(index, value)
70
+				=> listeners.accept(listener => listener.onInserted(index, value));
71
+			onChanged(index, oldValue, newValue)
72
+				=> listeners.accept(listener => listener.onChanged(index, oldValue, newValue));
73
+			onRemoved(index, oldValue)
74
+				=> listeners.accept(listener => listener.onRemoved(index, oldValue));
75
+		}
76
+	}
77
+	
78
+	private class SecondListListener {
79
+		public implements LiveList<T>.Listener<T> {
80
+			onInserted(index, value)
81
+				=> listeners.accept(listener => listener.onInserted(a.length + index, value));
82
+			onChanged(index, oldValue, newValue)
83
+				=> listeners.accept(listener => listener.onChanged(a.length + index, oldValue, newValue));
84
+			onRemoved(index, oldValue)
85
+				=> listeners.accept(listener => listener.onRemoved(a.length + index, oldValue));
86
+		}
87
+	}
88
+}*/

+ 15
- 0
src/main/zencode/live/src/LiveEmptyList.zs View File

@@ -0,0 +1,15 @@
1
+import listeners.DummyListenerHandle;
2
+
3
+public class LiveEmptyList<T> {
4
+	public implements LiveList<T> {
5
+		indexOf(value) => null;
6
+		
7
+		get length => 0;
8
+		
9
+		[](index) => panic "No elements in an empty list";
10
+		
11
+		iterate() => Iterator<T>.empty<T>();
12
+		
13
+		addListener(listener) => new DummyListenerHandle<Listener<T>>`unique(listener);
14
+	}
15
+}

+ 9
- 0
src/main/zencode/live/src/LiveFloat.zs View File

@@ -0,0 +1,9 @@
1
+public interface LiveFloat {
2
+	get value as float;
3
+	set value as float;
4
+	
5
+	addListener(listener as Listener) as ListenerHandle`unique;
6
+	
7
+	alias Listener as function(oldValue as float, newValue as float) as void;
8
+	alias ListenerHandle as listeners.ListenerHandle<Listener>;
9
+}

live/src/LiveInt.zs → src/main/zencode/live/src/LiveInt.zs View File


live/src/LiveList.zs → src/main/zencode/live/src/LiveList.zs View File


live/src/LiveObject.zs → src/main/zencode/live/src/LiveObject.zs View File


live/src/LiveString.zs → src/main/zencode/live/src/LiveString.zs View File


live/src/MutableLiveBool.zs → src/main/zencode/live/src/MutableLiveBool.zs View File

@@ -1,3 +1,5 @@
1 1
 public interface MutableLiveBool : LiveBool {
2 2
 	set value as bool;
3
+	
4
+	final toggle() as void => value = !value;
3 5
 }

live/src/MutableLiveInt.zs → src/main/zencode/live/src/MutableLiveInt.zs View File


live/src/MutableLiveList.zs → src/main/zencode/live/src/MutableLiveList.zs View File


live/src/MutableLiveString.zs → src/main/zencode/live/src/MutableLiveString.zs View File


live/src/SimpleLiveBool.zs → src/main/zencode/live/src/SimpleLiveBool.zs View File

@@ -6,7 +6,7 @@ public class SimpleLiveBool {
6 6
 	var value as bool : get;
7 7
 	
8 8
 	public this(value as bool) {
9
-		this.value = value;
9
+		$value = value;
10 10
 	}
11 11
 	
12 12
 	public implements MutableLiveBool {

live/src/SimpleLiveInt.zs → src/main/zencode/live/src/SimpleLiveInt.zs View File

@@ -6,7 +6,7 @@ public class SimpleLiveInt {
6 6
 	var value as int : get;
7 7
 	
8 8
 	public this(value as int) {
9
-		this.value = value;
9
+		$value = value;
10 10
 	}
11 11
 	
12 12
 	public implements MutableLiveInt {

live/src/SimpleLiveString.zs → src/main/zencode/live/src/SimpleLiveString.zs View File

@@ -6,7 +6,7 @@ public class SimpleLiveString {
6 6
 	var value as string : get;
7 7
 	
8 8
 	public this(value as string) {
9
-		this.value = value;
9
+		$value = value;
10 10
 	}
11 11
 	
12 12
 	public implements MutableLiveString {

+ 22
- 0
src/main/zencode/stdlib/java.map View File

@@ -0,0 +1,22 @@
1
+expansion:<T:Comparable<T>>T[]@java.lang.Arrays
2
+:method:sort()void=sort([Ljava/lang/Object;)[Ljava/lang/Object;
3
+:method:sorted()T[]=!ArraysSorted
4
+expansion:<T>T[]@java.lang.Arrays
5
+:method:sort(function(T,T)int)void=sort([Ljava/lang/Object;Ljava/lang/Comparator;)[Ljava/lang/Object;
6
+:method:sorted(function(T,T)T[]=!ArraysSortedWithComparator
7
+:method:copy()=!ArraysCopy
8
+:method:copy(usize)T[]=copyOf([Ljava/lang/Object;I)[Ljava/lang/Object;
9
+:method:copyTo(T[],usize,usize,usize)void=!ArraysCopyTo
10
+expansion:string@java.lang.String
11
+:method:fromAsciiBytes(byte[])string=!StringFromAciiBytes
12
+:method:fromUTF8Bytes(byte[])string=!StringFromUTF8Bytes
13
+:operator:in(char)=!StringContains
14
+:method:indexOf(char)usize?=indexOf(I)I
15
+:method:indexOf(char,usize)usize?=indexOf(II)I
16
+:method:lastIndexOf(char)usize?=lastIndexOf(I)I
17
+:method:lastIndexOf(char,usize)usize?=lastIndexOf(II)I
18
+:method:trim()=trim()Ljava/lang/String;
19
+:method:startsWith(string)bool=startsWith(Ljava/lang/String;)Z
20
+:method:endsWith(string)bool=endsWith(Ljava/lang/String;)Z
21
+:method:toAsciiBytes()byte[]=!StringToAsciiBytes
22
+:method:toUTF8Bytes()byte[]=!StringToUTF8Bytes

stdlib/module.json → src/main/zencode/stdlib/module.json View File


stdlib/src/Arrays.zs → src/main/zencode/stdlib/src/Arrays.zs View File

@@ -48,15 +48,15 @@ public expand <T> T[] {
48 48
 	}*/
49 49
 	
50 50
 	[Native("mapValues")]
51
-	public map<U>(projection as function(value as T`borrow) as U) as U[]
51
+	public map<U>(projection as function(value as T) as U) as U[]
52 52
 		=> new U[]<T>(this, projection);
53 53
 	
54 54
 	[Native("mapKeyValues")]
55
-	public map<U>(projection as function(index as usize, value as T`borrow) as U) as U[]
55
+	public map<U>(projection as function(index as usize, value as T) as U) as U[]
56 56
 		=> new U[]<T>(this, projection);
57 57
 	
58 58
 	[Native("filterValues")]
59
-	public filter(predicate as function(value as T`borrow) as bool) as T[] {
59
+	public filter(predicate as function(value as T) as bool) as T[] {
60 60
 		var values = new List<T>();
61 61
 		for value in this
62 62
 			if predicate(value)

stdlib/src/Assoc.zs → src/main/zencode/stdlib/src/Assoc.zs View File


stdlib/src/Chars.zs → src/main/zencode/stdlib/src/Chars.zs View File


stdlib/src/Comparable.zs → src/main/zencode/stdlib/src/Comparable.zs View File


stdlib/src/EnforcementLevel.zs → src/main/zencode/stdlib/src/EnforcementLevel.zs View File


stdlib/src/EqualsComparable.zs → src/main/zencode/stdlib/src/EqualsComparable.zs View File


stdlib/src/Exception.zs → src/main/zencode/stdlib/src/Exception.zs View File


stdlib/src/Hashable.zs → src/main/zencode/stdlib/src/Hashable.zs View File


stdlib/src/IllegalArgumentException.zs → src/main/zencode/stdlib/src/IllegalArgumentException.zs View File


stdlib/src/Integers.zs → src/main/zencode/stdlib/src/Integers.zs View File


stdlib/src/Iterable.zs → src/main/zencode/stdlib/src/Iterable.zs View File


stdlib/src/Iterator.zs → src/main/zencode/stdlib/src/Iterator.zs View File

@@ -1,7 +1,10 @@
1 1
 [Native("stdlib::Iterator")]
2 2
 public interface Iterator<T> {
3
+	[Native("empty")]
4
+	static empty<T>() as Iterator<T>;
5
+	
3 6
 	[Native("hasNext")]
4
-	hasNext() as bool;
7
+	get hasNext as bool;
5 8
 	
6 9
 	[Native("next")]
7 10
 	next() as T;

stdlib/src/List.zs → src/main/zencode/stdlib/src/List.zs View File

@@ -28,7 +28,7 @@ public class List<T> {
28 28
 	public in(value as T) as bool;
29 29
 	
30 30
 	[Native("toArray")]
31
-	public as T[];
31
+	public implicit as T[];
32 32
 	
33 33
 	[Native("length")]
34 34
 	public get length as usize;

stdlib/src/Result.zs → src/main/zencode/stdlib/src/Result.zs View File


stdlib/src/StringBuildable.zs → src/main/zencode/stdlib/src/StringBuildable.zs View File

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

stdlib/src/StringBuilder.zs → src/main/zencode/stdlib/src/StringBuilder.zs View File

@@ -41,12 +41,12 @@ public class StringBuilder {
41 41
 	[Native("appendString")]
42 42
 	public extern <<(value as string) as StringBuilder;
43 43
 	
44
-	public <<(value as StringBuildable`borrow) as StringBuilder {
44
+	public <<(value as StringBuildable) as StringBuilder {
45 45
 		value.toString(this);
46 46
 		return this;
47 47
 	}
48 48
 	
49
-	public append<T : StringBuildable>(values as T[]`borrow, separator as string) as StringBuilder {
49
+	public append<T : StringBuildable>(values as T[], separator as string) as StringBuilder {
50 50
 		for i, value in values {
51 51
 			if i > 0
52 52
 				this << separator;
@@ -55,7 +55,7 @@ public class StringBuilder {
55 55
 		return this;
56 56
 	}
57 57
 	
58
-	public append<T>(values as T[]`borrow, stringer as function(value as T) as string, separator as string) as StringBuilder {
58
+	public append<T>(values as T[], stringer as function(value as T) as string, separator as string) as StringBuilder {
59 59
 		for i, value in values {
60 60
 			if i > 0
61 61
 				this << separator;

stdlib/src/Strings.zs → src/main/zencode/stdlib/src/Strings.zs View File

@@ -9,6 +9,10 @@ public expand string {
9 9
 	[Native("contains")]
10 10
 	public const in(c as char) as bool
11 11
 		=> indexOf(c) != null;
12
+		
13
+	[Native("containsString")]
14
+	public const in(s as string) as bool
15
+		=> indexOf(s) != null;
12 16
 	
13 17
 	[Native("indexOf")]
14 18
 	public const indexOf(c as char) as usize? {
@@ -30,6 +34,12 @@ public expand string {
30 34
 		return null;
31 35
 	}
32 36
 	
37
+	[Native("indexOfString")]
38
+	public const indexOf(s as string) as usize?;
39
+	
40
+	[Native("indexOfStringFrom")]
41
+	public const indexOf(s as string, from as usize) as usize?;
42
+	
33 43
 	[Native("lastIndexOf")]
34 44
 	public const lastIndexOf(c as char) as usize? {
35 45
 		var i = length;
@@ -54,6 +64,12 @@ public expand string {
54 64
 		return null;
55 65
 	}
56 66
 	
67
+	[Native("lastIndexOfString")]
68
+	public const lastIndexOf(s as string) as usize?;
69
+	
70
+	[Native("lastIndexOfStringFrom")]
71
+	public const lastIndexOf(s as string, until as usize?) as usize?;
72
+	
57 73
 	[Native("split")]
58 74
 	public const split(delimiter as char) as string[] {
59 75
 		val result = new List<string>();
@@ -80,6 +96,14 @@ public expand string {
80 96
 		return to < from ? "" : this[from .. to];
81 97
 	}
82 98
 	
99
+	[Native("startsWith")]
100
+	public const startsWith(head as string) as bool
101
+		=> length >= head.length && this[0 .. head.length] == head;
102
+	
103
+	[Native("endsWith")]
104
+	public const endsWith(tail as string) as bool
105
+		=> length >= tail.length && this[($ - tail.length) .. $] == tail;
106
+	
83 107
 	[Native("lpad")]
84 108
 	public const lpad(length as usize, c as char) as string
85 109
 		=> this.length >= length ? this : c.times(length - this.length) + this;
@@ -87,10 +111,10 @@ public expand string {
87 111
 	[Native("rpad")]
88 112
 	public const rpad(length as usize, c as char) as string
89 113
 		=> this.length >= length ? this : this + c.times(length - this.length);
90
-		
114
+	
91 115
 	[Native("toAsciiBytes")]
92
-	public const toAsciiBytes() as byte[]`unique;
116
+	public const toAsciiBytes() as byte[];
93 117
 	
94 118
 	[Native("toUTF8Bytes")]
95
-	public const toUTF8Bytes() as byte[]`unique;
119
+	public const toUTF8Bytes() as byte[];
96 120
 }

stdlib/src/USize.zs → src/main/zencode/stdlib/src/USize.zs View File


+ 6
- 0
src/main/zencode/uuid/module.json View File

@@ -0,0 +1,6 @@
1
+{
2
+	"package": "live",
3
+	"javaPackage": "org.openzen.zencode.stdlib.uuid",
4
+	"host": "universal",
5
+	"dependencies": []
6
+}

+ 9
- 0
src/main/zencode/uuid/src/uuid.zs View File

@@ -0,0 +1,9 @@
1
+[Native("uuid")]
2
+export class UUID {
3
+	[Native("random")]
4
+	static random() as UUID;
5
+	
6
+	[Native("toString")]
7
+	as string;
8
+}
9
+

Loading…
Cancel
Save