"IO" -> "System".
Get rid of the separate opt-in IO class and replace it with a core System class. - Remove wren_io.c, wren_io.h, and io.wren. - Remove the flags that disable it. - Remove the overloads for print() with different arity. (It was an experiment, but I don't think it's that useful.) - Remove IO.read(). That will reappear using libuv in the CLI at some point. - Remove IO.time. Doesn't seem to have been used. - Update all of the tests, docs, etc. I'm sorry for all the breakage this causes, but I think "System" is a better name for this class (it makes it natural to add things like "System.gc()") and frees up "IO" for referring to the CLI's IO module.
This commit is contained in:
+13
-13
@@ -11,27 +11,27 @@ foreign class Counter {
|
||||
}
|
||||
|
||||
var counter = Counter.new()
|
||||
IO.print(counter.value) // expect: 0
|
||||
System.print(counter.value) // expect: 0
|
||||
counter.increment(3.1)
|
||||
IO.print(counter.value) // expect: 3.1
|
||||
System.print(counter.value) // expect: 3.1
|
||||
counter.increment(1.2)
|
||||
IO.print(counter.value) // expect: 4.3
|
||||
System.print(counter.value) // expect: 4.3
|
||||
|
||||
// Foreign classes can inherit a class as long as it has no fields.
|
||||
class PointBase {
|
||||
inherited() {
|
||||
IO.print("inherited method")
|
||||
System.print("inherited method")
|
||||
}
|
||||
}
|
||||
|
||||
// Class with non-default constructor.
|
||||
foreign class Point is PointBase {
|
||||
construct new() {
|
||||
IO.print("default")
|
||||
System.print("default")
|
||||
}
|
||||
|
||||
construct new(x, y, z) {
|
||||
IO.print(x, ", ", y, ", ", z)
|
||||
System.print(x.toString + ", " + y.toString + ", " + z.toString)
|
||||
}
|
||||
|
||||
foreign translate(x, y, z)
|
||||
@@ -39,19 +39,19 @@ foreign class Point is PointBase {
|
||||
}
|
||||
|
||||
var p = Point.new(1, 2, 3) // expect: 1, 2, 3
|
||||
IO.print(p) // expect: (1, 2, 3)
|
||||
System.print(p) // expect: (1, 2, 3)
|
||||
p.translate(3, 4, 5)
|
||||
IO.print(p) // expect: (4, 6, 8)
|
||||
System.print(p) // expect: (4, 6, 8)
|
||||
|
||||
p = Point.new() // expect: default
|
||||
IO.print(p) // expect: (0, 0, 0)
|
||||
System.print(p) // expect: (0, 0, 0)
|
||||
|
||||
p.inherited() // expect: inherited method
|
||||
|
||||
var error = Fiber.new {
|
||||
class Subclass is Point {}
|
||||
}.try()
|
||||
IO.print(error) // expect: Class 'Subclass' cannot inherit from foreign class 'Point'.
|
||||
System.print(error) // expect: Class 'Subclass' cannot inherit from foreign class 'Point'.
|
||||
|
||||
// Class with a finalizer.
|
||||
foreign class Resource {
|
||||
@@ -65,14 +65,14 @@ var resources = [
|
||||
]
|
||||
|
||||
Api.gc()
|
||||
IO.print(Api.finalized) // expect: 0
|
||||
System.print(Api.finalized) // expect: 0
|
||||
|
||||
resources.removeAt(-1)
|
||||
|
||||
Api.gc()
|
||||
IO.print(Api.finalized) // expect: 1
|
||||
System.print(Api.finalized) // expect: 1
|
||||
|
||||
resources.clear()
|
||||
|
||||
Api.gc()
|
||||
IO.print(Api.finalized) // expect: 3
|
||||
System.print(Api.finalized) // expect: 3
|
||||
|
||||
@@ -8,10 +8,10 @@ class Api {
|
||||
foreign static returnFalse
|
||||
}
|
||||
|
||||
IO.print(Api.implicitNull == null) // expect: true
|
||||
System.print(Api.implicitNull == null) // expect: true
|
||||
|
||||
IO.print(Api.returnInt) // expect: 123456
|
||||
IO.print(Api.returnFloat) // expect: 123.456
|
||||
System.print(Api.returnInt) // expect: 123456
|
||||
System.print(Api.returnFloat) // expect: 123.456
|
||||
|
||||
IO.print(Api.returnTrue) // expect: true
|
||||
IO.print(Api.returnFalse) // expect: false
|
||||
System.print(Api.returnTrue) // expect: true
|
||||
System.print(Api.returnFalse) // expect: false
|
||||
|
||||
+1
-1
@@ -11,4 +11,4 @@ for (i in 1...10) {
|
||||
s = s + " more"
|
||||
}
|
||||
|
||||
IO.print(Api.value) // expect: [list, of, strings]
|
||||
System.print(Api.value) // expect: [list, of, strings]
|
||||
|
||||
Reference in New Issue
Block a user