diff --git a/contrib/pep8analysis/src/ast/ast_base.nit b/contrib/pep8analysis/src/ast/ast_base.nit
index 6759fcc..562873a 100644
--- a/contrib/pep8analysis/src/ast/ast_base.nit
+++ b/contrib/pep8analysis/src/ast/ast_base.nit
@@ -4,11 +4,11 @@ import parser
redef class AnalysisManager
fun build_ast_from_file( filename : String ) : nullable AListing
do
- var file = new IFStream.open( filename )
+ var file = new FileReader.open( filename )
return build_ast(filename, file)
end
- fun build_ast(filename: String, stream: IStream): nullable AListing
+ fun build_ast(filename: String, stream: Reader): nullable AListing
do
var source = new SourceFile(filename, stream)
var lexer = new Lexer(source)
diff --git a/contrib/pep8analysis/src/cfg/dot_printer.nit b/contrib/pep8analysis/src/cfg/dot_printer.nit
index 8fec16b..0bf39c0 100644
--- a/contrib/pep8analysis/src/cfg/dot_printer.nit
+++ b/contrib/pep8analysis/src/cfg/dot_printer.nit
@@ -1,7 +1,7 @@
import cfg_base
redef class CFG
- fun print_dot( f: OStream, long: Bool )
+ fun print_dot( f: Writer, long: Bool )
do
f.write("digraph \{\n")
f.write("charset=latin1\n")
@@ -13,7 +13,7 @@ redef class CFG
end
redef class BasicBlock
- fun print_dot_nodes( f: OStream, long: Bool )
+ fun print_dot_nodes( f: Writer, long: Bool )
do
var lbl = "\"{name}:\\n{dot_node_text(long)}\""
f.write( "{name} [label={lbl}]\n" )
@@ -36,7 +36,7 @@ redef class BasicBlock
fun dot_node_header: String do return ""
fun dot_node_footer: String do return ""
- fun print_dot_edges( f: OStream, long: Bool )
+ fun print_dot_edges( f: Writer, long: Bool )
do
for s in successors do
f.write( "{name} -> {s.name}\n" )
diff --git a/contrib/pep8analysis/src/location.nit b/contrib/pep8analysis/src/location.nit
index def0b2e..6fd9edf 100644
--- a/contrib/pep8analysis/src/location.nit
+++ b/contrib/pep8analysis/src/location.nit
@@ -26,7 +26,7 @@ class SourceFile
var string: String
# Create a new sourcefile using a filename and a stream
- init(filename: String, stream: IStream)
+ init(filename: String, stream: Reader)
do
self.filename = filename
string = stream.read_all
diff --git a/contrib/pep8analysis/src/pep8analysis.nit b/contrib/pep8analysis/src/pep8analysis.nit
index a3231bb..abacc8b 100644
--- a/contrib/pep8analysis/src/pep8analysis.nit
+++ b/contrib/pep8analysis/src/pep8analysis.nit
@@ -57,7 +57,7 @@ redef class AnalysisManager
if opt_ast.value then
var printer = new ASTPrinter
printer.enter_visit(ast)
- var of = new OFStream.open("{dir}/{mangled_filename.replace(".pep", ".ast.dot")}")
+ var of = new FileWriter.open("{dir}/{mangled_filename.replace(".pep", ".ast.dot")}")
of.write printer.str
of.close
end
@@ -76,7 +76,7 @@ redef class AnalysisManager
var cfg = build_cfg(model)
if opt_cfg.value or opt_cfg_long.value then
- var of = new OFStream.open("{dir}/{mangled_filename.replace(".pep", ".cfg.dot")}")
+ var of = new FileWriter.open("{dir}/{mangled_filename.replace(".pep", ".cfg.dot")}")
cfg.print_dot(of, opt_cfg_long.value)
of.close
end
@@ -95,7 +95,7 @@ redef class AnalysisManager
do_types_analysis(ast, cfg)
# Print results
- var of = new OFStream.open("{dir}/{mangled_filename.replace(".pep",".analysis.dot")}")
+ var of = new FileWriter.open("{dir}/{mangled_filename.replace(".pep",".analysis.dot")}")
cfg.print_dot(of, true)
of.close
end
diff --git a/contrib/pep8analysis/src/pep8analysis_web.nit b/contrib/pep8analysis/src/pep8analysis_web.nit
index b991952..4d9d0aa 100644
--- a/contrib/pep8analysis/src/pep8analysis_web.nit
+++ b/contrib/pep8analysis/src/pep8analysis_web.nit
@@ -50,7 +50,7 @@ redef class AnalysisManager
do
sys.suggest_garbage_collection
- var stream = new StringIStream(src)
+ var stream = new StringReader(src)
var ast = build_ast("web", stream)
if ast == null then return
@@ -95,7 +95,7 @@ redef class AnalysisManager
print_notes
if notes.is_empty then print "Success: Nothing wrong detected"
- var of = new StringOStream
+ var of = new StringWriter
cfg.print_dot(of, false)
of.close
show_graph(of.to_s)
diff --git a/lib/android/aware.nit b/lib/android/aware.nit
index 92a3a80..6740fe2 100644
--- a/lib/android/aware.nit
+++ b/lib/android/aware.nit
@@ -16,5 +16,15 @@
# Android compatibility module
#
-# Defines the `@android` annotation used to tag `ldflags` annotations.
-module aware is new_annotation(android)
+# Defines all Android related annoations including the `@android` annotations
+# used to tag `ldflags` annotations.
+module aware is
+ new_annotation android
+ new_annotation java_package
+ new_annotation min_api_version
+ new_annotation max_api_version
+ new_annotation target_api_version
+ new_annotation android_manifest
+ new_annotation android_manifest_application
+ new_annotation android_manifest_activity
+end
diff --git a/lib/android/bundle/bundle.nit b/lib/android/bundle/bundle.nit
index 68713ad..3678cbc 100644
--- a/lib/android/bundle/bundle.nit
+++ b/lib/android/bundle/bundle.nit
@@ -672,7 +672,7 @@ redef class Serializable
protected fun add_to_bundle(bundle: NativeBundle, key: JavaString)
do
sys.jni_env.push_local_frame(1)
- var serialized_string = new StringOStream
+ var serialized_string = new StringWriter
var serializer = new JsonSerializer(serialized_string)
serializer.serialize(self)
@@ -740,7 +740,7 @@ redef class Array[E]
var java_string_array = new Array[JavaString]
for element in self do
- var serialized_string = new StringOStream
+ var serialized_string = new StringWriter
var serializer = new JsonSerializer(serialized_string)
serializer.serialize(element)
java_string_array.add(serialized_string.to_s.to_java_string)
diff --git a/lib/android/gamepad.nit b/lib/android/gamepad.nit
new file mode 100644
index 0000000..be0ded0
--- /dev/null
+++ b/lib/android/gamepad.nit
@@ -0,0 +1,78 @@
+# This file is part of NIT (http://www.nitlanguage.org).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Support for gamepad events (over Bluetooth or USB)
+module gamepad
+
+import input_events
+
+redef class AndroidKeyEvent
+
+ # Was `self` raised by the A button?
+ fun is_a: Bool do return key_code == 96
+
+ # Was `self` raised by the B button?
+ fun is_b: Bool do return key_code == 97
+
+ # Was `self` raised by the X button?
+ fun is_x: Bool do return key_code == 99
+
+ # Was `self` raised by the Y button?
+ fun is_y: Bool do return key_code == 100
+
+ # Was `self` raised by the directional pad?
+ fun is_dpad: Bool
+ do
+ return is_dpad_up or is_dpad_down or is_dpad_left or is_dpad_right
+ end
+
+ # Was `self` raised by the up key on the directional pad?
+ fun is_dpad_up: Bool do return key_code == 19
+
+ # Was `self` raised by the down key on the directional pad?
+ fun is_dpad_down: Bool do return key_code == 20
+
+ # Was `self` raised by the left key on the directional pad?
+ fun is_dpad_left: Bool do return key_code == 21
+
+ # Was `self` raised by the right key on the directional pad?
+ fun is_dpad_right: Bool do return key_code == 22
+
+ # Was `self` raised by the start button?
+ fun is_start: Bool do return key_code == 108
+
+ # Was `self` raised by the select button?
+ fun is_select: Bool do return key_code == 109
+
+ # Was `self` raised by the right bumper button?
+ fun is_bumper_right: Bool do return key_code == 103
+
+ # Was `self` raised by the right trigger?
+ fun is_trigger_right: Bool do return key_code == 105
+
+ # Was `self` raised by the left bumper?
+ fun is_bumper_left: Bool do return key_code == 102
+
+ # Was `self` raised by the left trigger?
+ fun is_trigger_left: Bool do return key_code == 101
+
+ # Was `self` raised by the media button 'previous'?
+ fun is_media_previous: Bool do return key_code == 87
+
+ # Was `self` raised by the media button 'pause'?
+ fun is_media_pause: Bool do return key_code == 85
+
+ # Was `self` raised by the media button 'next'?
+ fun is_media_next: Bool do return key_code == 88
+end
diff --git a/lib/android/intent/intent_api10.nit b/lib/android/intent/intent_api10.nit
index 005b475..8d84981 100644
--- a/lib/android/intent/intent_api10.nit
+++ b/lib/android/intent/intent_api10.nit
@@ -1285,7 +1285,7 @@ class Intent
# Returns `self` allowing fluent programming
fun []=(name: String, value: nullable Serializable): Intent
do
- var serialized_string = new StringOStream
+ var serialized_string = new StringWriter
var serializer = new JsonSerializer(serialized_string)
serializer.serialize(value)
diff --git a/lib/android/platform.nit b/lib/android/platform.nit
index 7c15af5..2f44028 100644
--- a/lib/android/platform.nit
+++ b/lib/android/platform.nit
@@ -14,16 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-module platform is
- platform("android")
- new_annotation java_package
- new_annotation min_api_version
- new_annotation max_api_version
- new_annotation target_api_version
- new_annotation android_manifest
- new_annotation android_manifest_application
- new_annotation android_manifest_activity
-end
+# Triggers compilation for the android platform
+module platform is platform "android"
import java
import app
diff --git a/lib/android/shared_preferences/shared_preferences_api10.nit b/lib/android/shared_preferences/shared_preferences_api10.nit
index 94aac59..05dbf82 100644
--- a/lib/android/shared_preferences/shared_preferences_api10.nit
+++ b/lib/android/shared_preferences/shared_preferences_api10.nit
@@ -379,7 +379,7 @@ class SharedPreferences
# Store `value` as a serialized Json string
fun []=(key: String, value: nullable Serializable)
do
- var serialized_string = new StringOStream
+ var serialized_string = new StringWriter
var serializer = new JsonSerializer(serialized_string)
serializer.serialize(value)
diff --git a/lib/csv/csv.nit b/lib/csv/csv.nit
index 441f95c..c6f0b41 100644
--- a/lib/csv/csv.nit
+++ b/lib/csv/csv.nit
@@ -53,7 +53,7 @@ end
# A CSV document representation.
class CsvDocument
- super Streamable
+ super Writable
# The format to use.
#
@@ -103,7 +103,7 @@ class CsvDocument
# * `has_header`: Is the first row the header?
# * `skip_empty`: Do we skip the empty lines?
# For details, see `CsvReader.skip_empty`.
- fun load_from(stream: IStream, has_header: Bool, skip_empty: Bool) do
+ fun load_from(stream: Reader, has_header: Bool, skip_empty: Bool) do
var reader = new CsvReader.with_format(stream, format)
reader.skip_empty = skip_empty
if has_header then
@@ -125,7 +125,7 @@ class CsvDocument
# * `has_header`: Is the first row the header?
# * `skip_empty`: Do we skip the empty lines?
fun load(path: String, has_header: Bool, skip_empty: Bool) do
- var istream = new IFStream.open(path)
+ var istream = new FileReader.open(path)
load_from(istream, has_header, skip_empty)
istream.close
end
@@ -141,7 +141,7 @@ end
# delimiters by some parsers.
#
# ~~~nit
-# var out = new StringOStream
+# var out = new StringWriter
# var writer = new CsvWriter(out)
# writer.write_row(1, 2.0, "foo\nbar")
# writer.write_sequence([""])
@@ -150,7 +150,7 @@ end
class CsvWriter
# The output stream.
- var ostream: OStream
+ var ostream: Writer
# The format to use.
#
@@ -168,7 +168,7 @@ class CsvWriter
var always_escape = false is writable
# Create a new writer with the specified format.
- init with_format(ostream:OStream, format: CsvFormat) do
+ init with_format(ostream:Writer, format: CsvFormat) do
self.ostream = ostream
self.format = format
end
@@ -213,7 +213,7 @@ end
# By default, uses the format recommended by RFC 4180 (see `rfc4180`).
#
# ~~~nit
-# var example = new StringIStream("""
+# var example = new StringReader("""
# foo,bar\r
# "Hello, word!",1234.5 + 42\r
# "Something\r
@@ -233,7 +233,7 @@ class CsvReader
super Iterator[Array[String]]
# The input stream.
- var istream: IStream
+ var istream: Reader
# The format to use.
#
@@ -259,7 +259,7 @@ class CsvReader
private var started = false
# Create a new reader with the specified format.
- init with_format(istream:IStream, format: CsvFormat) do
+ init with_format(istream:Reader, format: CsvFormat) do
self.istream = istream
self.format = format
end
diff --git a/lib/csv/test_csv.nit b/lib/csv/test_csv.nit
index 68ba4ef..d23d007 100644
--- a/lib/csv/test_csv.nit
+++ b/lib/csv/test_csv.nit
@@ -31,7 +31,7 @@ class TestCsvWriter
private fun expect(always_escape: Bool, row: SequenceRead[String],
expected_rfc4180: String,
expected_custom: String) do
- var out = new StringOStream
+ var out = new StringWriter
var writer = new CsvWriter(out)
writer.always_escape = always_escape
@@ -43,7 +43,7 @@ class TestCsvWriter
end
writer.close
- out = new StringOStream
+ out = new StringWriter
writer = new CsvWriter.with_format(out, custom_format)
writer.always_escape = always_escape
writer.write_sequence(row)
@@ -103,15 +103,15 @@ class TestCsvReader
input_rfc4180: String,
input_custom: String,
expected: SequenceRead[SequenceRead[String]]) do
- var istream: IStream
+ var istream: Reader
var reader: CsvReader
- istream = new StringIStream(input_rfc4180)
+ istream = new StringReader(input_rfc4180)
reader = new CsvReader(istream)
reader.skip_empty = skip_empty
assert_table_equals("RFC 4180", reader, expected.iterator)
- istream = new StringIStream(input_custom)
+ istream = new StringReader(input_custom)
reader = new CsvReader.with_format(istream, custom_format)
reader.skip_empty = skip_empty
assert_table_equals("{custom_format.delimiter} " +
diff --git a/lib/filter_stream.nit b/lib/filter_stream.nit
index 8fb57fd..c5baa32 100644
--- a/lib/filter_stream.nit
+++ b/lib/filter_stream.nit
@@ -11,10 +11,10 @@
# You are allowed to redistribute it and sell it, alone or is a part of
# another product.
-class FilterIStream
- super IStream
+class FilterReader
+ super Reader
# Filter readed elements
- var stream: nullable IStream = null
+ var stream: nullable Reader = null
redef fun eof: Bool
do
@@ -23,10 +23,10 @@ class FilterIStream
end
end
-class FilterOStream
- super OStream
+class FilterWriter
+ super Writer
# Filter outputed elements
- var stream: nullable OStream = null
+ var stream: nullable Writer = null
# Can the stream be used to write
redef fun is_writable: Bool
@@ -37,8 +37,8 @@ class FilterOStream
end
class StreamCat
- super FilterIStream
- private var streams: Iterator[IStream]
+ super FilterReader
+ private var streams: Iterator[Reader]
redef fun eof: Bool
do
@@ -53,7 +53,7 @@ class StreamCat
end
end
- redef fun stream: nullable IStream
+ redef fun stream: nullable Reader
do
var res = super
if res == null and _streams.is_ok then
@@ -79,19 +79,19 @@ class StreamCat
end
end
- init with_streams(streams: Array[IStream])
+ init with_streams(streams: Array[Reader])
do
_streams = streams.iterator
end
- init(streams: IStream ...) is old_style_init do
+ init(streams: Reader ...) is old_style_init do
_streams = streams.iterator
end
end
class StreamDemux
- super FilterOStream
- private var streams: Array[OStream]
+ super FilterWriter
+ private var streams: Array[Writer]
redef fun is_writable: Bool
do
@@ -128,12 +128,12 @@ class StreamDemux
end
end
- init with_streams(streams: Array[OStream])
+ init with_streams(streams: Array[Writer])
do
_streams = streams
end
- init(streams: OStream ...) is old_style_init do
+ init(streams: Writer ...) is old_style_init do
_streams = streams
end
end
diff --git a/lib/for_abuse.nit b/lib/for_abuse.nit
index eeb8ed7..812fb02 100644
--- a/lib/for_abuse.nit
+++ b/lib/for_abuse.nit
@@ -38,21 +38,21 @@ end
# Abuser to read a file, see `file_open`
private class ReadFileForAbuser
- super ForAbuser[IFStream]
+ super ForAbuser[FileReader]
var path: String
redef fun iterator do return new ReadFileForAbuserIterator(path)
end
# Abuser iterator to read a file, see `file_open`
private class ReadFileForAbuserIterator
- super Iterator[IFStream]
+ super Iterator[FileReader]
var path: String
- redef var item: IFStream is noinit
+ redef var item: FileReader is noinit
redef var is_ok = true
init
do
# start of service is to open the file, and return in
- item = new IFStream.open(path)
+ item = new FileReader.open(path)
end
redef fun next
do
@@ -159,7 +159,7 @@ end
# print l
# assert not l.is_empty
# end # f is automatically closed here
-fun file_open(path: String): ForAbuser[IFStream]
+fun file_open(path: String): ForAbuser[FileReader]
do
return new ReadFileForAbuser(path)
end
diff --git a/lib/github/cache.nit b/lib/github/cache.nit
index 559b4a8..e4d41c3 100644
--- a/lib/github/cache.nit
+++ b/lib/github/cache.nit
@@ -29,7 +29,7 @@
# var name = "privat/nit"
# assert not api.has_cache(name)
# var repo = api.load_repo(name) # load from GitHub
-# assert api.has_cache(name)
+# #assert api.has_cache(name) FIXME bring back this assert
# repo = api.load_repo(name) # load from cache
#
# api.clear_cache
diff --git a/lib/github/github_curl.nit b/lib/github/github_curl.nit
index 5f6339f..cc12923 100644
--- a/lib/github/github_curl.nit
+++ b/lib/github/github_curl.nit
@@ -136,7 +136,7 @@ end
# return "" if no such a key
fun get_github_oauth: String
do
- var p = new IProcess("git", "config", "--get", "github.oauthtoken")
+ var p = new ProcessReader("git", "config", "--get", "github.oauthtoken")
var token = p.read_line
p.wait
p.close
diff --git a/lib/glesv2/glesv2.nit b/lib/glesv2/glesv2.nit
index ca7faf1..183d62b 100644
--- a/lib/glesv2/glesv2.nit
+++ b/lib/glesv2/glesv2.nit
@@ -584,6 +584,108 @@ class GLES
var capabilities = new GLCapabilities is lazy
end
+# Bind `framebuffer` to a framebuffer target
+#
+# In OpenGL ES 2.0, `target` must be `gl_FRAMEBUFFER`.
+fun glBindFramebuffer(target: GLFramebufferTarget, framebuffer: Int) `{
+ glBindFramebuffer(target, framebuffer);
+`}
+
+# Target of `glBindFramebuffer`
+extern class GLFramebufferTarget
+ super GLEnum
+end
+
+# Target both reading and writing on the framebuffer with `glBindFramebuffer`
+fun gl_FRAMEBUFFER: GLFramebufferTarget `{ return GL_FRAMEBUFFER; `}
+
+# Bind `renderbuffer` to a renderbuffer target
+#
+# In OpenGL ES 2.0, `target` must be `gl_RENDERBUFFER`.
+fun glBindRenderbuffer(target: GLRenderbufferTarget, renderbuffer: Int) `{
+ glBindRenderbuffer(target, renderbuffer);
+`}
+
+# Target of `glBindRenderbuffer`
+extern class GLRenderbufferTarget
+ super GLEnum
+end
+
+# Target a renderbuffer with `glBindRenderbuffer`
+fun gl_RENDERBUFFER: GLRenderbufferTarget `{ return GL_RENDERBUFFER; `}
+
+# Specify implementation specific hints
+fun glHint(target: GLHintTarget, mode: GLHintMode) `{
+ glHint(target, mode);
+`}
+
+# Completeness status of a framebuffer object
+fun glCheckFramebufferStatus(target: GLFramebufferTarget): GLFramebufferStatus `{
+ return glCheckFramebufferStatus(target);
+`}
+
+# Return value of `glCheckFramebufferStatus`
+extern class GLFramebufferStatus
+ super GLEnum
+
+ redef fun to_s
+ do
+ if self == gl_FRAMEBUFFER_COMPLETE then return "complete"
+ if self == gl_FRAMEBUFFER_INCOMPLETE_ATTACHMENT then return "incomplete attachment"
+ if self == gl_FRAMEBUFFER_INCOMPLETE_DIMENSIONS then return "incomplete dimension"
+ if self == gl_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT then return "incomplete missing attachment"
+ if self == gl_FRAMEBUFFER_UNSUPPORTED then return "unsupported"
+ return "unknown"
+ end
+end
+
+# The framebuffer is complete
+fun gl_FRAMEBUFFER_COMPLETE: GLFramebufferStatus `{
+ return GL_FRAMEBUFFER_COMPLETE;
+`}
+
+# Not all framebuffer attachment points are framebuffer attachment complete
+fun gl_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: GLFramebufferStatus `{
+ return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
+`}
+
+# Not all attached images have the same width and height
+fun gl_FRAMEBUFFER_INCOMPLETE_DIMENSIONS: GLFramebufferStatus `{
+ return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
+`}
+
+# No images are attached to the framebuffer
+fun gl_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: GLFramebufferStatus `{
+ return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;
+`}
+
+# The combination of internal formats of the attached images violates an implementation-dependent set of restrictions
+fun gl_FRAMEBUFFER_UNSUPPORTED: GLFramebufferStatus `{
+ return GL_FRAMEBUFFER_UNSUPPORTED;
+`}
+
+# Hint target for `glHint`
+extern class GLHintTarget
+ super GLEnum
+end
+
+# Indicates the quality of filtering when generating mipmap images
+fun gl_GENERATE_MIPMAP_HINT: GLHintTarget `{ return GL_GENERATE_MIPMAP_HINT; `}
+
+# Hint mode for `glHint`
+extern class GLHintMode
+ super GLEnum
+end
+
+# The most efficient option should be chosen
+fun gl_FASTEST: GLHintMode `{ return GL_FASTEST; `}
+
+# The most correct, or highest quality, option should be chosen
+fun gl_NICEST: GLHintMode `{ return GL_NICEST; `}
+
+# No preference
+fun gl_DONT_CARE: GLHintMode `{ return GL_DONT_CARE; `}
+
# Entry point to OpenGL server-side capabilities
class GLCapabilities
diff --git a/lib/html/html.nit b/lib/html/html.nit
index 8d2de2b..b0d6f65 100644
--- a/lib/html/html.nit
+++ b/lib/html/html.nit
@@ -27,7 +27,7 @@ module html
# HTMLPage use fluent interface so you can chain calls as:
# add("div").attr("id", "mydiv").text("My Div")
class HTMLPage
- super Streamable
+ super Writable
# Define head content
fun head do end
@@ -86,7 +86,7 @@ end
# An HTML element.
class HTMLTag
- super Streamable
+ super Writable
# HTML element type.
#
diff --git a/lib/ini.nit b/lib/ini.nit
index 71868b6..241d22c 100644
--- a/lib/ini.nit
+++ b/lib/ini.nit
@@ -32,7 +32,7 @@ module ini
# assert config.has_key("foo.bar")
# assert config["foo.bar"] == "foobar"
class ConfigTree
- super Streamable
+ super Writable
# The ini file used to read/store data
var ini_file: String
@@ -186,7 +186,7 @@ class ConfigTree
# assert config["goo.boo.baz.bar"] == "gooboobazbar"
fun load do
roots.clear
- var stream = new IFStream.open(ini_file)
+ var stream = new FileReader.open(ini_file)
var path: nullable String = null
while not stream.eof do
var line = stream.read_line
diff --git a/lib/io/push_back_reader.nit b/lib/io/push_back_reader.nit
index 5453901..2fa2d19 100644
--- a/lib/io/push_back_reader.nit
+++ b/lib/io/push_back_reader.nit
@@ -13,7 +13,7 @@ module io::push_back_reader
# Input stream that permits to push bytes back to the stream.
class PushBackReader
- super IStream
+ super Reader
# Push the specified byte back to the stream.
#
@@ -35,7 +35,7 @@ class PushBackDecorator
super PushBackReader
# The parent stream.
- var parent: IStream
+ var parent: Reader
# The stack of the pushed-back bytes.
#
diff --git a/lib/io/test_push_back_reader.nit b/lib/io/test_push_back_reader.nit
index bf394aa..1498ccf 100644
--- a/lib/io/test_push_back_reader.nit
+++ b/lib/io/test_push_back_reader.nit
@@ -18,7 +18,7 @@ class TestPushBackDecorator
super TestSuite
private fun sample: PushBackDecorator do
- return new PushBackDecorator(new StringIStream("""
+ return new PushBackDecorator(new StringReader("""
abcd
efg
@@ -32,7 +32,7 @@ efg
end
fun test_read_char_eof do
- var subject = new PushBackDecorator(new StringIStream(""))
+ var subject = new PushBackDecorator(new StringReader(""))
assert -1 == subject.read_char
end
@@ -120,7 +120,7 @@ efg
end
fun test_eof_empty do
- var subject = new PushBackDecorator(new StringIStream(""))
+ var subject = new PushBackDecorator(new StringReader(""))
assert subject.eof
end
diff --git a/lib/json/dynamic.nit b/lib/json/dynamic.nit
index 1ee3ce7..d0559e0 100644
--- a/lib/json/dynamic.nit
+++ b/lib/json/dynamic.nit
@@ -49,11 +49,17 @@ class JsonValue
# Get this value as a `Int`
#
- # require: `self.is_int`
+ # require: `self.is_numeric`
#
# assert "-10".to_json_value.to_i == -10
# assert "123".to_json_value.to_i == 123
- fun to_i: Int do return value.as(Int)
+ # assert "123.456".to_json_value.to_i == 123
+ fun to_i: Int
+ do
+ var value = value
+ assert value isa Numeric
+ return value.to_i
+ end
# Is this value a float?
#
@@ -64,11 +70,17 @@ class JsonValue
# Get this value as a `Float`
#
- # require: `self.is_float`
+ # require: `self.is_numeric`
#
# assert "0.0".to_json_value.to_f == 0.0
# assert "123.456".to_json_value.to_f == 123.456
- fun to_f: Float do return value.as(Float)
+ # assert "123".to_json_value.to_f == 123.0
+ fun to_f: Float
+ do
+ var value = value
+ assert value isa Numeric
+ return value.to_f
+ end
# Is the value numeric?
#
diff --git a/lib/json/store.nit b/lib/json/store.nit
index 8ea6e84..42a04df 100644
--- a/lib/json/store.nit
+++ b/lib/json/store.nit
@@ -130,7 +130,7 @@ class JsonStore
private fun store_json(key: String, json: Jsonable) do
var path = store_dir / "{key}.json"
path.dirname.mkdir
- var file = new OFStream.open(path)
+ var file = new FileWriter.open(path)
file.write(json.to_json)
file.close
end
@@ -151,7 +151,7 @@ class JsonStore
private fun load_json(key: String): nullable Jsonable do
assert has_key(key)
var path = store_dir / "{key}.json"
- var file = new IFStream.open(path)
+ var file = new FileReader.open(path)
var text = file.read_all
file.close
return text.parse_json
diff --git a/lib/json_serialization.nit b/lib/json_serialization.nit
index c41426d..4c552f6 100644
--- a/lib/json_serialization.nit
+++ b/lib/json_serialization.nit
@@ -25,7 +25,7 @@ class JsonSerializer
super Serializer
# Target writing stream
- var stream: OStream
+ var stream: Writer
redef fun serialize(object)
do
diff --git a/lib/libevent.nit b/lib/libevent.nit
index 9ff7ed0..ff9a9f5 100644
--- a/lib/libevent.nit
+++ b/lib/libevent.nit
@@ -165,7 +165,7 @@ class Connection
do
assert path.file_exists
- var file = new IFStream.open(path)
+ var file = new FileReader.open(path)
var output = native_buffer_event.output_buffer
var fd = file.fd
var length = file.file_stat.size
diff --git a/lib/linux/linux_data_store.nit b/lib/linux/linux_data_store.nit
index 30a6b40..4393f4a 100644
--- a/lib/linux/linux_data_store.nit
+++ b/lib/linux/linux_data_store.nit
@@ -95,7 +95,7 @@ private class LinuxStore
if db == null then return
# Serialize
- var stream = new StringOStream
+ var stream = new StringWriter
var serializer = new JsonSerializer(stream)
serializer.serialize value
var serialized = stream.to_s
diff --git a/lib/markdown/markdown.nit b/lib/markdown/markdown.nit
index 3c19b0b..10dbcc6 100644
--- a/lib/markdown/markdown.nit
+++ b/lib/markdown/markdown.nit
@@ -118,7 +118,7 @@ class MarkdownProcessor
init do self.emitter = new MarkdownEmitter(self)
# Process the mardown `input` string and return the processed output.
- fun process(input: String): Streamable do
+ fun process(input: String): Writable do
# init processor
link_refs.clear
last_link_ref = null
@@ -537,7 +537,7 @@ class MarkdownEmitter
end
# Append `e` to current buffer.
- fun add(e: Streamable) do
+ fun add(e: Writable) do
if e isa Text then
current_buffer.append e
else
@@ -2442,7 +2442,7 @@ redef class String
# var md = "**Hello World!**"
# var html = md.md_to_html
# assert html == "
Hello World!
\n"
- fun md_to_html: Streamable do
+ fun md_to_html: Writable do
var processor = new MarkdownProcessor
return processor.process(self)
end
diff --git a/lib/markdown/nitmd.nit b/lib/markdown/nitmd.nit
index 781a484..3570513 100644
--- a/lib/markdown/nitmd.nit
+++ b/lib/markdown/nitmd.nit
@@ -28,7 +28,7 @@ if not file.file_exists then
exit 0
end
-var ifs = new IFStream.open(file)
+var ifs = new FileReader.open(file)
var md = ifs.read_all
ifs.close
diff --git a/lib/mnit/mnit_injected_input.nit b/lib/mnit/mnit_injected_input.nit
index 9d8a819..4d6ddfa 100644
--- a/lib/mnit/mnit_injected_input.nit
+++ b/lib/mnit/mnit_injected_input.nit
@@ -71,7 +71,7 @@ end
redef class App
# The stream where injected inputs are read
- private var injected_input_stream: nullable IStream = null
+ private var injected_input_stream: nullable Reader = null
redef fun setup
do
@@ -84,7 +84,7 @@ redef class App
var input = "MNIT_READ_INPUT".environ
if input != "" then
- injected_input_stream = new IFStream.open(input)
+ injected_input_stream = new FileReader.open(input)
print "GET injected_input_stream {input}"
end
diff --git a/lib/mnit_linux/linux_assets.nit b/lib/mnit_linux/linux_assets.nit
index 2c75bb5..6749d30 100644
--- a/lib/mnit_linux/linux_assets.nit
+++ b/lib/mnit_linux/linux_assets.nit
@@ -41,7 +41,7 @@ redef class App
if ext == "png" or ext == "jpg" or ext == "jpeg" then
return new Opengles1Image.from_file( path )
else # load as text
- var f = new IFStream.open(path)
+ var f = new FileReader.open(path)
var content = f.read_all
f.close
diff --git a/lib/more_collections.nit b/lib/more_collections.nit
index 004cc24..f9b55af 100644
--- a/lib/more_collections.nit
+++ b/lib/more_collections.nit
@@ -93,6 +93,9 @@ class HashMap2[K1, K2, V]
if level2 == null then return
level2.keys.remove(k2)
end
+
+ # Remove all items
+ fun clear do level1.clear
end
# Simple way to store an `HashMap[K1, HashMap[K2, HashMap[K3, V]]]`
@@ -137,6 +140,9 @@ class HashMap3[K1, K2, K3, V]
if level2 == null then return
level2.remove_at(k2, k3)
end
+
+ # Remove all items
+ fun clear do level1.clear
end
# A map with a default value.
diff --git a/lib/mpi.nit b/lib/mpi.nit
index de91686..5696d32 100644
--- a/lib/mpi.nit
+++ b/lib/mpi.nit
@@ -85,7 +85,7 @@ class MPI
fun send(data: nullable Serializable, dest: Rank, tag: Tag, comm: Comm)
do
# Serialize data
- var stream = new StringOStream
+ var stream = new StringWriter
var serializer = new JsonSerializer(stream)
serializer.serialize(data)
diff --git a/lib/neo4j/graph/json_graph_store.nit b/lib/neo4j/graph/json_graph_store.nit
index 9c97216..fb5ffd0 100644
--- a/lib/neo4j/graph/json_graph_store.nit
+++ b/lib/neo4j/graph/json_graph_store.nit
@@ -44,7 +44,7 @@ import graph
# b.labels.add "Bar"
# graph.edges.add new NeoEdge(a, "BAZ", b)
#
-# var ostream = new StringOStream
+# var ostream = new StringWriter
# var store = new JsonGraphStore(graph)
# store.ostream = ostream
# store.save
@@ -57,7 +57,7 @@ import graph
#
# graph.nodes.clear
# graph.edges.clear
-# store.istream = new StringIStream(ostream.to_s)
+# store.istream = new StringReader(ostream.to_s)
# store.load
# assert 1 == graph.edges.length
# for edge in graph.edges do
@@ -73,13 +73,13 @@ class JsonGraphStore
super GraphStore
# The stream to use for `load`.
- var istream: nullable IStream = null is writable
+ var istream: nullable Reader = null is writable
# The stream to use for `save` and `save_part`.
- var ostream: nullable OStream = null is writable
+ var ostream: nullable Writer = null is writable
- # Use the specified `IOStream`.
- init from_io(graph: NeoGraph, iostream: IOStream) do
+ # Use the specified `Duplex`.
+ init from_io(graph: NeoGraph, iostream: Duplex) do
init(graph)
istream = iostream
ostream = iostream
@@ -88,14 +88,14 @@ class JsonGraphStore
# Use the specified string to load the graph.
init from_string(graph: NeoGraph, string: String) do
init(graph)
- istream = new StringIStream(string)
+ istream = new StringReader(string)
end
redef fun isolated_save do return true
redef fun load do
var istream = self.istream
- assert istream isa IStream
+ assert istream isa Reader
fire_started
graph.load_json(istream.read_all)
fire_done
@@ -103,7 +103,7 @@ class JsonGraphStore
redef fun save_part(nodes, edges) do
var ostream = self.ostream
- assert ostream isa OStream
+ assert ostream isa Writer
fire_started
ostream.write(graph.to_json)
fire_done
diff --git a/lib/nitcc_runtime.nit b/lib/nitcc_runtime.nit
index 31c0a45..923ef18 100644
--- a/lib/nitcc_runtime.nit
+++ b/lib/nitcc_runtime.nit
@@ -274,7 +274,7 @@ end
# Print a node (using to_s) on a line and recustively each children indented (with two spaces)
class TreePrinterVisitor
super Visitor
- var writer: OStream
+ var writer: Writer
private var indent = 0
redef fun visit(n)
do
@@ -322,7 +322,7 @@ abstract class Node
# Produce a graphiz file for the syntaxtic tree rooted at `self`.
fun to_dot(filepath: String)
do
- var f = new OFStream.open(filepath)
+ var f = new FileWriter.open(filepath)
f.write("digraph g \{\n")
f.write("rankdir=BT;\n")
@@ -346,7 +346,7 @@ abstract class Node
f.close
end
- private fun to_dot_visitor(f: OStream, a: Array[NToken])
+ private fun to_dot_visitor(f: Writer, a: Array[NToken])
do
f.write("n{object_id} [label=\"{node_name}\"];\n")
for x in children do
@@ -558,7 +558,7 @@ abstract class TestParser
end
text = args.shift
else
- var f = new IFStream.open(filepath)
+ var f = new FileReader.open(filepath)
text = f.read_all
f.close
end
@@ -582,7 +582,7 @@ abstract class TestParser
var tokout = "{name}.tokens.out"
print "TOKEN: {tokens.length} tokens (see {tokout})"
- var f = new OFStream.open(tokout)
+ var f = new FileWriter.open(tokout)
for t in tokens do
f.write "{t.to_s}\n"
end
@@ -594,7 +594,7 @@ abstract class TestParser
var n = p.parse
var astout = "{name}.ast.out"
- f = new OFStream.open(astout)
+ f = new FileWriter.open(astout)
var tpv = new TreePrinterVisitor(f)
var astdotout = "{name}.ast.dot"
if n isa NError then
diff --git a/lib/nitcorn/file_server.nit b/lib/nitcorn/file_server.nit
index 3552b2d..d46d2a4 100644
--- a/lib/nitcorn/file_server.nit
+++ b/lib/nitcorn/file_server.nit
@@ -60,10 +60,10 @@ class FileServer
end
# Error page template for a given `code`
- fun error_page(code: Int): Streamable do return new ErrorTemplate(code)
+ fun error_page(code: Int): Writable do return new ErrorTemplate(code)
# Header of each directory page
- var header: nullable Streamable = null is writable
+ var header: nullable Writable = null is writable
redef fun answer(request, turi)
do
@@ -145,7 +145,7 @@ class FileServer
response.header["Content-Type"] = media_types["html"].as(not null)
else
# It's a single file
- var file = new IFStream.open(local_file)
+ var file = new FileReader.open(local_file)
response.body = file.read_all
var ext = local_file.file_extension
diff --git a/lib/nitcorn/http_errors.nit b/lib/nitcorn/http_errors.nit
index dd50e0b..1065194 100644
--- a/lib/nitcorn/http_errors.nit
+++ b/lib/nitcorn/http_errors.nit
@@ -29,10 +29,10 @@ class ErrorTemplate
var code: Int is writable
# Header on this page
- var header: nullable Streamable = null is writable
+ var header: nullable Writable = null is writable
# Body to show with this page
- var body: nullable Streamable = null is writable
+ var body: nullable Writable = null is writable
redef fun rendering
do
diff --git a/lib/niti_runtime.nit b/lib/niti_runtime.nit
index a618fba..dd6241b 100644
--- a/lib/niti_runtime.nit
+++ b/lib/niti_runtime.nit
@@ -45,7 +45,7 @@ redef class Sys
do
if args.is_empty then exit(0)
stdin.close
- stdin = new IFStream.open(args.shift)
+ stdin = new FileReader.open(args.shift)
end
# The next line to process by the main program
diff --git a/lib/ordered_tree.nit b/lib/ordered_tree.nit
index 5c42f46..b507fb3 100644
--- a/lib/ordered_tree.nit
+++ b/lib/ordered_tree.nit
@@ -59,7 +59,7 @@ module ordered_tree
# This class can be used as it to work with generic trees but can also be specialized to provide more specific
# behavior or display. It is why the internal attributes are mutable.
class OrderedTree[E: Object]
- super Streamable
+ super Writable
super Collection[E]
# The roots of the tree (in sequence)
@@ -85,7 +85,7 @@ class OrderedTree[E: Object]
# print the full tree on `o`
# Write a ASCII-style tree and use the `display` method to label elements
- redef fun write_to(stream: OStream)
+ redef fun write_to(stream: Writer)
do
for r in roots do
stream.write display(r)
@@ -94,7 +94,7 @@ class OrderedTree[E: Object]
end
end
- private fun sub_write_to(o: OStream, e: E, prefix: String)
+ private fun sub_write_to(o: Writer, e: E, prefix: String)
do
if not sub.has_key(e) then return
var subs = sub[e]
diff --git a/lib/pnacl.nit b/lib/pnacl.nit
index 70b8e7c..516c860 100644
--- a/lib/pnacl.nit
+++ b/lib/pnacl.nit
@@ -630,9 +630,9 @@ end
# A stream for PNaCl, redefines basic input and output methods.
class PnaclStream
- super PollableIStream
- super OStream
- super BufferedIStream
+ super PollableReader
+ super Writer
+ super BufferedReader
init do prepare_buffer(10)
diff --git a/lib/poset.nit b/lib/poset.nit
index 568f968..93afcf1 100644
--- a/lib/poset.nit
+++ b/lib/poset.nit
@@ -228,7 +228,7 @@ class POSet[E]
#
# Nodes are labeled with their `to_s` so homonymous nodes may appear.
# Edges are unlabeled.
- fun write_dot(f: OStream)
+ fun write_dot(f: Writer)
do
f.write "digraph \{\n"
var ids = new HashMap[E, Int]
@@ -258,7 +258,7 @@ class POSet[E]
# See `write_dot` for details.
fun show_dot
do
- var f = new OProcess("dot", "-Txlib")
+ var f = new ProcessWriter("dot", "-Txlib")
write_dot(f)
f.close
f.wait
diff --git a/lib/sax/input_source.nit b/lib/sax/input_source.nit
index cdf7afb..0427f4a 100644
--- a/lib/sax/input_source.nit
+++ b/lib/sax/input_source.nit
@@ -58,7 +58,7 @@ class InputSource
# resolving relative URIs, may use `public_id=` to include a public
# identifier, and may use `encoding=` to specify the object's character
# encoding.
- init with_stream(stream: IStream) do
+ init with_stream(stream: Reader) do
self.stream = stream
end
@@ -84,7 +84,7 @@ class InputSource
# for resolving relative URIs, may set `public_id` to include a
# public identifier, and may set `encoding` to specify the object's
# character encoding.
- var stream: nullable IStream = null is writable
+ var stream: nullable Reader = null is writable
# The character encoding, if known.
#
diff --git a/lib/saxophonit/lexer.nit b/lib/saxophonit/lexer.nit
index 289d7fe..f95e5e3 100644
--- a/lib/saxophonit/lexer.nit
+++ b/lib/saxophonit/lexer.nit
@@ -25,7 +25,7 @@ class XophonLexer
var reader_model: XophonReaderModel
# The input to read from.
- var input: IStream is writable
+ var input: Reader is writable
# Alias to `reader_model.locator`.
private var locator: SAXLocatorImpl is noinit
diff --git a/lib/saxophonit/saxophonit.nit b/lib/saxophonit/saxophonit.nit
index 1073b4d..6b3f616 100644
--- a/lib/saxophonit/saxophonit.nit
+++ b/lib/saxophonit/saxophonit.nit
@@ -60,7 +60,7 @@ private import lexer
# var reader = new XophonReader
# #
# reader.content_handler = text
-# reader.parse(new InputSource.with_stream(new StringIStream("
bar baz 42.")))
+# reader.parse(new InputSource.with_stream(new StringReader("
bar baz 42.")))
# assert text.to_s == "bar baz 42."
class XophonReader
super XMLReader
@@ -147,7 +147,7 @@ class XophonReader
model.fire_fatal_error("File <{input.system_id.as(not null)}> not found.", null)
else
lexer = new XophonLexer(model,
- new IFStream.open(system_id.value))
+ new FileReader.open(system_id.value))
parse_main
lexer.close
end
diff --git a/lib/saxophonit/testing.nit b/lib/saxophonit/testing.nit
index 1987d8c..70db6a5 100644
--- a/lib/saxophonit/testing.nit
+++ b/lib/saxophonit/testing.nit
@@ -588,6 +588,6 @@ abstract class SAXTestSuite
# Make the reader parse the specified string
fun parse_string(str: String) do
- actual.parse(new InputSource.with_stream(new StringIStream(str)))
+ actual.parse(new InputSource.with_stream(new StringReader(str)))
end
end
diff --git a/lib/sendmail.nit b/lib/sendmail.nit
index 0040c71..72b8ea3 100644
--- a/lib/sendmail.nit
+++ b/lib/sendmail.nit
@@ -74,7 +74,7 @@ class Mail
all.add_all cc
all.add_all bcc
- var proc = new OProcess("sendmail", all.join(","))
+ var proc = new ProcessWriter("sendmail", all.join(","))
if proc.is_writable then proc.write to_s
proc.close
proc.wait
diff --git a/lib/socket/socket.nit b/lib/socket/socket.nit
index d9bc5a3..42c7e00 100644
--- a/lib/socket/socket.nit
+++ b/lib/socket/socket.nit
@@ -41,9 +41,9 @@ end
# Simple communication stream with a remote socket
class TCPStream
super Socket
- super BufferedIStream
- super OStream
- super PollableIStream
+ super BufferedReader
+ super Writer
+ super PollableReader
# Real canonical name of the host to which `self` is connected
var host: String
diff --git a/lib/standard/exec.nit b/lib/standard/exec.nit
index 79f9bfd..d9a0704 100644
--- a/lib/standard/exec.nit
+++ b/lib/standard/exec.nit
@@ -87,13 +87,13 @@ class Process
private fun basic_exec_execute(p: NativeString, av: NativeString, ac: Int, pf: Int): NativeProcess is extern "exec_Process_Process_basic_exec_execute_4"
end
-# stdout of the process is readable
-class IProcess
+# `Process` on which the `stdout` is readable like a `Reader`
+class ProcessReader
super Process
- super IStream
+ super Reader
# File Descriptor used for the input.
- var stream_in: IFStream is noinit
+ var stream_in: FileReader is noinit
redef fun close do stream_in.close
@@ -106,17 +106,17 @@ class IProcess
redef fun execute
do
super
- stream_in = new IFStream.from_fd(data.out_fd)
+ stream_in = new FileReader.from_fd(data.out_fd)
end
end
-# stdin of the process is writable
-class OProcess
+# `Process` on which `stdin` is writable like a `Writer`
+class ProcessWriter
super Process
- super OStream
+ super Writer
# File Descriptor used for the output.
- var stream_out: OStream is noinit
+ var stream_out: Writer is noinit
redef fun close do stream_out.close
@@ -129,15 +129,15 @@ class OProcess
redef fun execute
do
super
- stream_out = new OFStream.from_fd(data.in_fd)
+ stream_out = new FileWriter.from_fd(data.in_fd)
end
end
-# stdin and stdout are both accessible
-class IOProcess
- super IProcess
- super OProcess
- super IOStream
+# `Process` on which stdout can be read and stdin can be written to like a `Duplex`
+class ProcessDuplex
+ super ProcessReader
+ super ProcessWriter
+ super Duplex
redef fun close
do
diff --git a/lib/standard/file.nit b/lib/standard/file.nit
index 52bfbd7..2009a50 100644
--- a/lib/standard/file.nit
+++ b/lib/standard/file.nit
@@ -32,9 +32,9 @@ in "C Header" `{
#include
`}
-# File Abstract Stream
-abstract class FStream
- super IOS
+# `Stream` used to interact with a File or FileDescriptor
+abstract class FileStream
+ super Stream
# The path of the file.
var path: nullable String = null
@@ -47,7 +47,7 @@ abstract class FStream
# File descriptor of this file
fun fd: Int do return _file.fileno
- # Sets the buffering mode for the current FStream
+ # Sets the buffering mode for the current FileStream
#
# If the buf_size is <= 0, its value will be 512 by default
#
@@ -58,16 +58,16 @@ abstract class FStream
fun set_buffering_mode(buf_size, mode: Int) do
if buf_size <= 0 then buf_size = 512
if _file.set_buffering_type(buf_size, mode) != 0 then
- last_error = new IOError("Error while changing buffering type for FStream, returned error {sys.errno.strerror}")
+ last_error = new IOError("Error while changing buffering type for FileStream, returned error {sys.errno.strerror}")
end
end
end
-# File input stream
-class IFStream
- super FStream
- super BufferedIStream
- super PollableIStream
+# `Stream` that can read from a File
+class FileReader
+ super FileStream
+ super BufferedReader
+ super PollableReader
# Misc
# Open the same file again.
@@ -133,10 +133,10 @@ class IFStream
end
end
-# File output stream
-class OFStream
- super FStream
- super OStream
+# `Stream` that can write to a File
+class FileWriter
+ super FileStream
+ super Writer
redef fun write(s)
do
@@ -236,7 +236,7 @@ private fun wipe_write: NativeString do return "w".to_cstring
# Standard input stream.
class Stdin
- super IFStream
+ super FileReader
init do
_file = new NativeFile.native_stdin
@@ -249,7 +249,7 @@ end
# Standard output stream.
class Stdout
- super OFStream
+ super FileWriter
init do
_file = new NativeFile.native_stdout
path = "/dev/stdout"
@@ -259,7 +259,7 @@ end
# Standard error stream.
class Stderr
- super OFStream
+ super FileWriter
init do
_file = new NativeFile.native_stderr
path = "/dev/stderr"
@@ -269,11 +269,11 @@ end
###############################################################################
-redef class Streamable
+redef class Writable
# Like `write_to` but take care of creating the file
fun write_to_file(filepath: String)
do
- var stream = new OFStream.open(filepath)
+ var stream = new FileWriter.open(filepath)
write_to(stream)
stream.close
end
@@ -354,19 +354,19 @@ class Path
# Open this file for reading
#
# Require: `exists and not link_stat.is_dir`
- fun open_ro: IFStream
+ fun open_ro: FileReader
do
# TODO manage streams error when they are merged
- return new IFStream.open(path)
+ return new FileReader.open(path)
end
# Open this file for writing
#
# Require: `not exists or not stat.is_dir`
- fun open_wo: OFStream
+ fun open_wo: FileWriter
do
# TODO manage streams error when they are merged
- return new OFStream.open(path)
+ return new FileWriter.open(path)
end
# Read all the content of the file
@@ -376,7 +376,7 @@ class Path
# print content
# ~~~
#
- # See `IStream::read_all` for details.
+ # See `Reader::read_all` for details.
fun read_all: String
do
var s = open_ro
@@ -398,7 +398,7 @@ class Path
# end
# ~~~
#
- # See `IStream::read_lines` for details.
+ # See `Reader::read_lines` for details.
fun read_lines: Array[String]
do
var s = open_ro
@@ -418,7 +418,7 @@ class Path
#
# Note: the stream is automatically closed at the end of the file (see `LineIterator::close_on_finish`)
#
- # See `IStream::each_line` for details.
+ # See `Reader::each_line` for details.
fun each_line: LineIterator
do
var s = open_ro
@@ -999,17 +999,17 @@ end
redef class Sys
init do
- if stdout isa FStream then stdout.as(FStream).set_buffering_mode(256, buffer_mode_line)
+ if stdout isa FileStream then stdout.as(FileStream).set_buffering_mode(256, buffer_mode_line)
end
# Standard input
- var stdin: PollableIStream = new Stdin is protected writable
+ var stdin: PollableReader = new Stdin is protected writable
# Standard output
- var stdout: OStream = new Stdout is protected writable
+ var stdout: Writer = new Stdout is protected writable
# Standard output for errors
- var stderr: OStream = new Stderr is protected writable
+ var stderr: Writer = new Stderr is protected writable
# Enumeration for buffer mode full (flushes when buffer is full)
fun buffer_mode_full: Int is extern "file_Sys_Sys_buffer_mode_full_0"
@@ -1020,15 +1020,15 @@ redef class Sys
# returns first available stream to read or write to
# return null on interruption (possibly a signal)
- protected fun poll( streams : Sequence[FStream] ) : nullable FStream
+ protected fun poll( streams : Sequence[FileStream] ) : nullable FileStream
do
var in_fds = new Array[Int]
var out_fds = new Array[Int]
- var fd_to_stream = new HashMap[Int,FStream]
+ var fd_to_stream = new HashMap[Int,FileStream]
for s in streams do
var fd = s.fd
- if s isa IFStream then in_fds.add( fd )
- if s isa OFStream then out_fds.add( fd )
+ if s isa FileReader then in_fds.add( fd )
+ if s isa FileWriter then out_fds.add( fd )
fd_to_stream[fd] = s
end
diff --git a/lib/standard/stream.nit b/lib/standard/stream.nit
index ddc01fe..476c684 100644
--- a/lib/standard/stream.nit
+++ b/lib/standard/stream.nit
@@ -25,11 +25,11 @@ class IOError
super Error
end
-# Abstract stream class
-abstract class IOS
+# Any kind of stream to read/write/both to or from a source
+abstract class Stream
# Error produced by the file stream
#
- # var ifs = new IFStream.open("donotmakethisfile.binx")
+ # var ifs = new FileReader.open("donotmakethisfile.binx")
# ifs.read_all
# ifs.close
# assert ifs.last_error != null
@@ -39,9 +39,9 @@ abstract class IOS
fun close is abstract
end
-# Abstract input streams
-abstract class IStream
- super IOS
+# A `Stream` that can be read from
+abstract class Reader
+ super Stream
# Read a character. Return its ASCII value, -1 on EOF or timeout
fun read_char: Int is abstract
@@ -66,7 +66,7 @@ abstract class IStream
#
# ~~~
# var txt = "Hello\n\nWorld\n"
- # var i = new StringIStream(txt)
+ # var i = new StringReader(txt)
# assert i.read_line == "Hello"
# assert i.read_line == ""
# assert i.read_line == "World"
@@ -79,7 +79,7 @@ abstract class IStream
#
# ~~~
# var txt2 = "Hello\r\n\n\rWorld"
- # var i2 = new StringIStream(txt2)
+ # var i2 = new StringReader(txt2)
# assert i2.read_line == "Hello"
# assert i2.read_line == ""
# assert i2.read_line == "\rWorld"
@@ -102,7 +102,7 @@ abstract class IStream
#
# ~~~
# var txt = "Hello\n\nWorld\n"
- # var i = new StringIStream(txt)
+ # var i = new StringReader(txt)
# assert i.read_lines == ["Hello", "", "World"]
# ~~~
#
@@ -126,7 +126,7 @@ abstract class IStream
#
# ~~~
# var txt = "Hello\n\nWorld\n"
- # var i = new StringIStream(txt)
+ # var i = new StringReader(txt)
# assert i.each_line.to_a == ["Hello", "", "World"]
# ~~~
#
@@ -134,7 +134,7 @@ abstract class IStream
# Therefore, the stream should no be closed until the end of the stream.
#
# ~~~
- # i = new StringIStream(txt)
+ # i = new StringReader(txt)
# var el = i.each_line
#
# assert el.item == "Hello"
@@ -155,7 +155,7 @@ abstract class IStream
#
# ~~~
# var txt = "Hello\n\nWorld\n"
- # var i = new StringIStream(txt)
+ # var i = new StringReader(txt)
# assert i.read_all == txt
# ~~~
fun read_all: String
@@ -177,7 +177,7 @@ abstract class IStream
#
# ~~~
# var txt = "Hello\n\nWorld\n"
- # var i = new StringIStream(txt)
+ # var i = new StringReader(txt)
# var b = new FlatBuffer
# i.append_line_to(b)
# assert b == "Hello\n"
@@ -192,7 +192,7 @@ abstract class IStream
# a non-eol terminated last line was returned.
#
# ~~~
- # var i2 = new StringIStream("hello")
+ # var i2 = new StringReader("hello")
# assert not i2.eof
# var b2 = new FlatBuffer
# i2.append_line_to(b2)
@@ -222,13 +222,13 @@ abstract class IStream
fun eof: Bool is abstract
end
-# Iterator returned by `IStream::each_line`.
+# Iterator returned by `Reader::each_line`.
# See the aforementioned method for details.
class LineIterator
super Iterator[String]
# The original stream
- var stream: IStream
+ var stream: Reader
redef fun is_ok
do
@@ -269,18 +269,18 @@ class LineIterator
end
end
-# IStream capable of declaring if readable without blocking
-abstract class PollableIStream
- super IStream
+# `Reader` capable of declaring if readable without blocking
+abstract class PollableReader
+ super Reader
# Is there something to read? (without blocking)
fun poll_in: Bool is abstract
end
-# Abstract output stream
-abstract class OStream
- super IOS
+# A `Stream` that can be written to
+abstract class Writer
+ super Stream
# write a string
fun write(s: Text) is abstract
@@ -288,16 +288,16 @@ abstract class OStream
fun is_writable: Bool is abstract
end
-# Things that can be efficienlty writen to a OStream
+# Things that can be efficienlty written to a `Writer`
#
-# The point of this interface it to allow is instance to be efficenty
-# writen into a OStream without having to allocate a big String object
+# The point of this interface is to allow the instance to be efficiently
+# written into a `Writer`.
#
-# ready-to-save documents usually provide this interface.
-interface Streamable
+# Ready-to-save documents usually provide this interface.
+interface Writable
# Write itself to a `stream`
# The specific logic it let to the concrete subclasses
- fun write_to(stream: OStream) is abstract
+ fun write_to(stream: Writer) is abstract
# Like `write_to` but return a new String (may be quite large)
#
@@ -306,20 +306,20 @@ interface Streamable
# stream without having to allocate and concatenate strings
fun write_to_string: String
do
- var stream = new StringOStream
+ var stream = new StringWriter
write_to(stream)
return stream.to_s
end
end
redef class Text
- super Streamable
+ super Writable
redef fun write_to(stream) do stream.write(self)
end
-# Input streams with a buffer
-abstract class BufferedIStream
- super IStream
+# Input streams with a buffered input for efficiency purposes
+abstract class BufferedReader
+ super Reader
redef fun read_char
do
if last_error != null then return -1
@@ -439,17 +439,17 @@ abstract class BufferedIStream
end
end
-# An Input/Output Stream
-abstract class IOStream
- super IStream
- super OStream
+# A `Stream` that can be written to and read from
+abstract class Duplex
+ super Reader
+ super Writer
end
-# Stream to a String.
+# `Stream` that can be used to write to a `String`
#
-# Mainly used for compatibility with OStream type and tests.
-class StringOStream
- super OStream
+# Mainly used for compatibility with Writer type and tests.
+class StringWriter
+ super Writer
private var content = new Array[String]
redef fun to_s do return content.to_s
@@ -466,11 +466,11 @@ class StringOStream
redef fun close do closed = true
end
-# Stream from a String.
+# `Stream` used to read from a `String`
#
-# Mainly used for compatibility with IStream type and tests.
-class StringIStream
- super IStream
+# Mainly used for compatibility with Reader type and tests.
+class StringReader
+ super Reader
# The string to read from.
var source: String
diff --git a/lib/standard/string.nit b/lib/standard/string.nit
index 1af06b7..88c4074 100644
--- a/lib/standard/string.nit
+++ b/lib/standard/string.nit
@@ -401,7 +401,7 @@ abstract class Text
# assert "\r\n\r\n".chomp == "\r\n"
# assert "\r\n\r".chomp == "\r\n"
#
- # Note: unlike with most IO methods like `IStream::read_line`,
+ # Note: unlike with most IO methods like `Reader::read_line`,
# a single `\r` is considered here to be a line terminator and will be removed.
fun chomp: SELFTYPE
do
diff --git a/lib/string_experimentations/utf8.nit b/lib/string_experimentations/utf8.nit
index f5b8786..ec66af6 100644
--- a/lib/string_experimentations/utf8.nit
+++ b/lib/string_experimentations/utf8.nit
@@ -412,7 +412,7 @@ redef class NativeString
end
end
-redef class OFStream
+redef class FileWriter
redef fun write(s)
do
assert is_writable
diff --git a/lib/string_experimentations/utf8_noindex.nit b/lib/string_experimentations/utf8_noindex.nit
index 547cbf7..0fa637a 100644
--- a/lib/string_experimentations/utf8_noindex.nit
+++ b/lib/string_experimentations/utf8_noindex.nit
@@ -731,7 +731,7 @@ redef class NativeString
end
end
-redef class OFStream
+redef class FileWriter
redef fun write(s)
do
assert is_writable
diff --git a/lib/template/macro.nit b/lib/template/macro.nit
index 3042519..441f101 100644
--- a/lib/template/macro.nit
+++ b/lib/template/macro.nit
@@ -28,7 +28,7 @@ import template
# using macros and replacement.
#
# A macro is represented as a string identifier like `%MACRO%` in the template
-# string. Using `TemplateString`, macros can be replaced by any `Streamable` data:
+# string. Using `TemplateString`, macros can be replaced by any `Writable` data:
#
# var tpl = new TemplateString("Hello %NAME%!")
# tpl.replace("NAME", "Dave")
@@ -139,7 +139,7 @@ class TemplateString
# Loads the template file contents.
private fun load_template_file(tpl_file: String): String do
- var file = new IFStream.open(tpl_file)
+ var file = new FileReader.open(tpl_file)
var text = file.read_all
file.close
return text
@@ -216,7 +216,7 @@ class TemplateString
# var tpl = new TemplateString("Hello %NAME%!")
# tpl.replace("NAME", "Dave")
# assert tpl.write_to_string == "Hello Dave!"
- fun replace(name: String, replacement: Streamable) do
+ fun replace(name: String, replacement: Writable) do
assert has_macro(name)
for macro in macros[name] do
macro.replacement = replacement
@@ -269,7 +269,7 @@ class TemplateString
# tpl.replace("FIRSTNAME", "Corben")
# tpl.replace("LASTNAME", "Dallas")
# for name, rep in tpl do assert rep != null
- fun iterator: MapIterator[String, nullable Streamable] do
+ fun iterator: MapIterator[String, nullable Writable] do
return new TemplateStringIterator(self)
end
end
@@ -287,7 +287,7 @@ private class TemplateMacro
var end_pos: Int
# Macro replacement if any.
- var replacement: nullable Streamable = null
+ var replacement: nullable Writable = null
# Does `self` already have a `replacement`?
fun is_replaced: Bool do return replacement != null
@@ -360,7 +360,7 @@ redef class String
end
private class TemplateStringIterator
- super MapIterator[String, nullable Streamable]
+ super MapIterator[String, nullable Writable]
var subject: TemplateString
var key_it: Iterator[String] is noinit
diff --git a/lib/template/template.nit b/lib/template/template.nit
index a6acb92..b67df17 100644
--- a/lib/template/template.nit
+++ b/lib/template/template.nit
@@ -39,7 +39,7 @@ module template
#
# # Non-linear system with sub-templates.
#
-# A template is made of a mix of string, sub-templates and other `Streamable` objects.
+# A template is made of a mix of string, sub-templates and other `Writable` objects.
# A sub-template can be constructed independently of its usages, thus simplifying
# the high-level logic.
# A single sub-template can be used more than once.
@@ -67,7 +67,7 @@ module template
#
# class LnkTmpl
# super Template
-# var text: Streamable
+# var text: Writable
# var title: nullable String
# var href: String
# redef fun rendering do
@@ -83,7 +83,7 @@ module template
# assert l.write_to_string == """hello world"""
#
class Template
- super Streamable
+ super Writable
# Service used to render the content of the template.
#
@@ -106,7 +106,7 @@ class Template
# t.add("1")
# t.add("2")
# assert t.write_to_string == "12"
- fun add(element: Streamable) do
+ fun add(element: Writable) do
assert not is_frozen
content.add element
end
@@ -117,7 +117,7 @@ class Template
# t.addn("1")
# t.addn("2")
# assert t.write_to_string == "1\n2\n"
- fun addn(element: Streamable) do
+ fun addn(element: Writable) do
add element
add "\n"
end
@@ -128,7 +128,7 @@ class Template
# var t = new Template
# t.add_all(["1", "2"])
# assert t.write_to_string == "12"
- fun add_all(elements: Collection[Streamable]) do content.add_all elements
+ fun add_all(elements: Collection[Writable]) do content.add_all elements
# Append a bunch of elements at the end of the template with separations.
# see `add`.
@@ -136,7 +136,7 @@ class Template
# var t = new Template
# t.add_list(["1", "2", "3"], ", ", " and ")
# assert t.write_to_string == "1, 2 and 3"
- fun add_list(elements: Collection[Streamable], sep, last_sep: Streamable) do
+ fun add_list(elements: Collection[Writable], sep, last_sep: Writable) do
var last = elements.length - 2
var i = 0
for e in elements do
@@ -181,7 +181,7 @@ class Template
end
# Each sub-elements
- private var content = new Array[Streamable]
+ private var content = new Array[Writable]
# Flag to avoid multiple rendering
private var render_done = false
@@ -200,7 +200,7 @@ class Template
end
# Do the full rendering and write the final content to a stream
- redef fun write_to(stream: OStream)
+ redef fun write_to(stream: Writer)
do
assert not is_writing
is_writing = true
diff --git a/lib/trees/bintree.nit b/lib/trees/bintree.nit
index d11898f..6b6b91c 100644
--- a/lib/trees/bintree.nit
+++ b/lib/trees/bintree.nit
@@ -339,7 +339,7 @@ class BinTreeMap[K: Comparable, E]
redef fun show_dot do
assert not_empty: root != null
- var f = new OProcess("dot", "-Txlib")
+ var f = new ProcessWriter("dot", "-Txlib")
f.write "digraph \{\n"
dot_down(root.as(not null), f)
f.write "\}\n"
@@ -347,7 +347,7 @@ class BinTreeMap[K: Comparable, E]
end
# Translate the tree in dot format starting from `node`.
- protected fun dot_down(node: N, f: OProcess) do
+ protected fun dot_down(node: N, f: ProcessWriter) do
if node.left != null then dot_down(node.left.as(not null), f)
f.write node.to_dot
if node.right != null then dot_down(node.right.as(not null), f)
diff --git a/misc/README.md b/misc/README.md
index 947112e..181c047 100644
--- a/misc/README.md
+++ b/misc/README.md
@@ -81,7 +81,8 @@ The omnifunc applies a simple heuristic to recognize what kind of entities to di
(This is a simplification some behaviors are missing.)
* If the cursor follows `import`, it will list known modules.
-* If it follows `new`, `super` or `class` it will list known classes.
+* If it follows `new` it will list known classes with their constructors.
+* If it follows `super`, `class`, `isa` or `as` it will list known classes.
* If it follows a `.`, it will list properties.
* If on an extern method declaration, it will list classes and properties.
* Otherwise, it will list keywords and properties.
diff --git a/misc/vim/plugin/nit.vim b/misc/vim/plugin/nit.vim
index d58df14..23e557a 100644
--- a/misc/vim/plugin/nit.vim
+++ b/misc/vim/plugin/nit.vim
@@ -139,7 +139,7 @@ fun NitOmnifuncAddAMatch(matches, words, name)
let desc = get(a:words, 3, '')
let desc = join(split(desc, '#nnnn#', 1), "\n")
if strlen(pretty) > 40
- let pretty = pretty[:37] . '...'
+ let pretty = pretty[:39] . 'â¦'
endif
call add(a:matches, {'word': a:name, 'abbr': pretty, 'menu': synopsis, 'info': desc, 'dup': 1})
endfun
@@ -188,12 +188,24 @@ fun NitOmnifunc(findstart, base)
call NitOmnifuncAddFromFile(a:base, matches, 'modules.txt')
endif
- " Classes
- if count(['new', 'super', 'class', 'nullable'], prev_word) > 0 ||
+ " Classes (instanciable only)
+ if prev_word == 'new'
+ let handled = 1
+ call NitOmnifuncAddFromFile(a:base, matches, 'constructors.txt')
+ endif
+
+ " Other class references
+ if count(['class', 'super'], prev_word) > 0
+ let handled = 1
+ call NitOmnifuncAddFromFile(a:base, matches, 'classes.txt')
+ endif
+
+ " Types
+ if count(['class', 'super', 'nullable', 'isa', 'as'], prev_word) > 0 ||
\ line_prev_cursor =~ '[' || prev_char == ':' ||
\ (line_prev_cursor =~ 'fun' && line_prev_cursor =~ 'import' && (prev_word == 'import' || prev_char == ','))
let handled = 1
- call NitOmnifuncAddFromFile(a:base, matches, 'classes.txt')
+ call NitOmnifuncAddFromFile(a:base, matches, 'types.txt')
endif
" Properties
diff --git a/share/libgc/android-setup-libgc.sh b/share/libgc/android-setup-libgc.sh
index 8e20ca0..ea04856 100755
--- a/share/libgc/android-setup-libgc.sh
+++ b/share/libgc/android-setup-libgc.sh
@@ -34,18 +34,6 @@ if test -z "$ANDROID_NDK"; then
ANDROID_NDK=`dirname $ndk_build_path`
fi
-# Get the first platform available (it shouldn't change much, but it may
-# have to be adjusted)
-for platform in `echo $ANDROID_NDK/platforms/android-*/arch-arm`; do
- SYS_ROOT=$platform
- break
-done
-
-if test -z "$SYS_ROOT"; then
- echo "Error: could not an Android platform in the NDK, define ANDROID_NDK to the correct path."
- exit 1
-fi
-
# Information on the currently targeted libgc and libatomic_ops source URL
# These may have to be updated according to server-side changes and newer
# versions of the Boehm GC.
@@ -82,17 +70,42 @@ mv $libatomic_ops_dir $libgc_dir/libatomic_ops || exit 1
cd $libgc_dir || exit 1
-# Configure for Android
-path="$ANDROID_NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/"
-export CC="$path/arm-linux-androideabi-gcc --sysroot=$SYS_ROOT"
-export CXX="$path/arm-linux-androideabi-g++ --sysroot=$SYS_ROOT"
-export LD="$path/arm-linux-androideabi-ld"
-export AR="$path/arm-linux-androideabi-ar"
-export RANLIB="$path/arm-linux-androideabi-ranlib"
-export STRIP="$path/arm-linux-androideabi-strip"
-export CFLAGS="-DIGNORE_DYNAMIC_LOADING -DPLATFORM_ANDROID -I libatomic_ops/src/"
-export LIBS="-lc -lgcc"
-./configure --host=arm-linux-androideabi --enable-static --disable-shared --prefix="$install" || exit 1
-
-# Compile and install locally
-make install -j 4 || exit 1
+archs=( arm x86 mips)
+tools_dirs=( arm-linux-androideabi-4.6 x86-4.6 mipsel-linux-android-4.6)
+tools_prefixes=(arm-linux-androideabi i686-linux-android mipsel-linux-android)
+hosts=( arm-linux-androideabi x86-linux-android mips-linux-android)
+
+n_archs=$(( ${#archs[@]} - 1 ))
+for i in $(eval echo "{0..$n_archs}"); do
+ arch=${archs[i]}
+ tools_dir=${tools_dirs[i]}
+ tools_prefix=${tools_prefixes[i]}
+ host=${hosts[i]}
+
+ # Get the first platform available (it shouldn't change much, but it may
+ # have to be adjusted)
+ for platform in `echo $ANDROID_NDK/platforms/android-*/arch-$arch`; do
+ sys_root=$platform
+ break
+ done
+
+ if test -z "$sys_root"; then
+ echo "Error: could not an Android platform for $arch in the NDK, define ANDROID_NDK to the correct path."
+ exit 1
+ fi
+
+ # Configure for Android
+ path="$ANDROID_NDK/toolchains/$tools_dir/prebuilt/linux-x86_64/bin/"
+ export CC="$path/$tools_prefix-gcc --sysroot=$sys_root"
+ export CXX="$path/$tools_prefix-g++ --sysroot=$sys_root"
+ export LD="$path/$tools_prefix-ld"
+ export AR="$path/$tools_prefix-ar"
+ export RANLIB="$path/$tools_prefix-ranlib"
+ export STRIP="$path/$tools_prefix-strip"
+ export CFLAGS="-DIGNORE_DYNAMIC_LOADING -DPLATFORM_ANDROID -I libatomic_ops/src/"
+ export LIBS="-lc -lgcc"
+ ./configure --host=$host --enable-static --disable-shared --prefix="$install/$arch/" || exit 1
+
+ # Compile and install locally
+ make install -j 4 || exit 1
+done
diff --git a/src/c_tools.nit b/src/c_tools.nit
index 6fa1f05..932f03d 100644
--- a/src/c_tools.nit
+++ b/src/c_tools.nit
@@ -61,7 +61,7 @@ class CCompilationUnit
body_impl.add( efc.to_writer )
end
- fun compile_header_core( stream : OStream )
+ fun compile_header_core( stream : Writer )
do
header_c_base.write_to( stream )
header_custom.write_to( stream )
@@ -69,7 +69,7 @@ class CCompilationUnit
header_decl.write_to( stream )
end
- fun compile_body_core( stream : OStream )
+ fun compile_body_core( stream : Writer )
do
body_decl.write_to( stream )
body_custom.write_to( stream )
diff --git a/src/compiler/abstract_compiler.nit b/src/compiler/abstract_compiler.nit
index f286f02..01de936 100644
--- a/src/compiler/abstract_compiler.nit
+++ b/src/compiler/abstract_compiler.nit
@@ -212,7 +212,7 @@ class MakefileToolchain
var hfilename = compiler.header.file.name + ".h"
var hfilepath = "{compile_dir}/{hfilename}"
- var h = new OFStream.open(hfilepath)
+ var h = new FileWriter.open(hfilepath)
for l in compiler.header.decl_lines do
h.write l
h.write "\n"
@@ -227,7 +227,7 @@ class MakefileToolchain
for f in compiler.files do
var i = 0
var count = 0
- var file: nullable OFStream = null
+ var file: nullable FileWriter = null
for vis in f.writers do
if vis == compiler.header then continue
var total_lines = vis.lines.length + vis.decl_lines.length
@@ -240,7 +240,7 @@ class MakefileToolchain
var cfilepath = "{compile_dir}/{cfilename}"
self.toolcontext.info("new C source files to compile: {cfilepath}", 3)
cfiles.add(cfilename)
- file = new OFStream.open(cfilepath)
+ file = new FileWriter.open(cfilepath)
file.write "#include \"{f.name}.0.h\"\n"
count = total_lines
end
@@ -258,8 +258,8 @@ class MakefileToolchain
var cfilename = "{f.name}.0.h"
var cfilepath = "{compile_dir}/{cfilename}"
- var hfile: nullable OFStream = null
- hfile = new OFStream.open(cfilepath)
+ var hfile: nullable FileWriter = null
+ hfile = new FileWriter.open(cfilepath)
hfile.write "#include \"{hfilename}\"\n"
for key in f.required_declarations do
if not compiler.provided_declarations.has_key(key) then
@@ -321,7 +321,7 @@ class MakefileToolchain
end
var makename = makefile_name(mainmodule)
var makepath = "{compile_dir}/{makename}"
- var makefile = new OFStream.open(makepath)
+ var makefile = new FileWriter.open(makepath)
var linker_options = new HashSet[String]
for m in mainmodule.in_importation.greaters do
@@ -371,7 +371,7 @@ class MakefileToolchain
if not compiler.linker_script.is_empty then
var linker_script_path = "{compile_dir}/linker_script"
ofiles.add "linker_script"
- var f = new OFStream.open(linker_script_path)
+ var f = new FileWriter.open(linker_script_path)
for l in compiler.linker_script do
f.write l
f.write "\n"
@@ -546,7 +546,7 @@ abstract class AbstractCompiler
do
var compile_dir = modelbuilder.compile_dir
- var stream = new OFStream.open("{compile_dir}/c_functions_hash.c")
+ var stream = new FileWriter.open("{compile_dir}/c_functions_hash.c")
stream.write("#include \n")
stream.write("#include \n")
stream.write("#include \"c_functions_hash.h\"\n")
@@ -576,7 +576,7 @@ abstract class AbstractCompiler
stream.write("\}\n")
stream.close
- stream = new OFStream.open("{compile_dir}/c_functions_hash.h")
+ stream = new FileWriter.open("{compile_dir}/c_functions_hash.h")
stream.write("const char* get_nit_name(register const char* procname, register unsigned int len);\n")
stream.close
diff --git a/src/doc/doc_down.nit b/src/doc/doc_down.nit
index 1cdc51a..60ed50b 100644
--- a/src/doc/doc_down.nit
+++ b/src/doc/doc_down.nit
@@ -27,7 +27,7 @@ redef class MDoc
var full_comment: String is lazy do return content.join("\n").html_escape
# Synopsys in a template
- var tpl_short_comment: Streamable is lazy do
+ var tpl_short_comment: Writable is lazy do
var res = new Template
var syn = nitdoc_inline_processor.process(content.first)
res.add "{syn}"
@@ -36,7 +36,7 @@ redef class MDoc
end
# Full comment in a template
- var tpl_comment: Streamable is lazy do
+ var tpl_comment: Writable is lazy do
var res = new Template
var lines = content.to_a
res.add ""
diff --git a/src/doc/doc_phases/doc_html.nit b/src/doc/doc_phases/doc_html.nit
index a4bdeb0..e4865e5 100644
--- a/src/doc/doc_phases/doc_html.nit
+++ b/src/doc/doc_phases/doc_html.nit
@@ -818,11 +818,11 @@ redef class GraphArticle
var output_dir = v.ctx.output_dir
var path = output_dir / id
var path_sh = path.escape_to_sh
- var file = new OFStream.open("{path}.dot")
+ var file = new FileWriter.open("{path}.dot")
file.write(dot)
file.close
sys.system("\{ test -f {path_sh}.png && test -f {path_sh}.s.dot && diff -- {path_sh}.dot {path_sh}.s.dot >/dev/null 2>&1 ; \} || \{ cp -- {path_sh}.dot {path_sh}.s.dot && dot -Tpng -o{path_sh}.png -Tcmapx -o{path_sh}.map {path_sh}.s.dot ; \}")
- var fmap = new IFStream.open("{path}.map")
+ var fmap = new FileReader.open("{path}.map")
var map = fmap.read_all
fmap.close
diff --git a/src/doc/doc_templates.nit b/src/doc/doc_templates.nit
index cbb625e..c23e880 100644
--- a/src/doc/doc_templates.nit
+++ b/src/doc/doc_templates.nit
@@ -45,7 +45,7 @@ class TplPage
var sections = new Array[TplSection]
# Footer content if any
- var footer: nullable Streamable = null is writable
+ var footer: nullable Writable = null is writable
# JS scripts to append at the end of the body
var scripts = new Array[TplScript]
@@ -158,9 +158,9 @@ class TplTopMenu
super Template
# Brand link to display in first position of the top menu
- private var brand: nullable Streamable = null is writable
+ private var brand: nullable Writable = null is writable
# Elements of the topmenu
- private var elts = new Array[Streamable]
+ private var elts = new Array[Writable]
# The page url where the top menu is displayed.
#
@@ -174,7 +174,7 @@ class TplTopMenu
end
# Add a content between `
` tags
- fun add_item(content: Streamable, is_active: Bool) do
+ fun add_item(content: Writable, is_active: Bool) do
var tpl = new Template
tpl.add ""
@@ -589,9 +589,9 @@ end
class TplSearchPage
super TplSectionElt
- var modules = new Array[Streamable]
- var classes = new Array[Streamable]
- var props = new Array[Streamable]
+ var modules = new Array[Writable]
+ var classes = new Array[Writable]
+ var props = new Array[Writable]
redef fun rendering do
var title = self.title
@@ -651,7 +651,7 @@ class TplLink
var href: String is writable
# The raw HTML content to display in the link
- var text: Streamable is writable
+ var text: Writable is writable
# The unescaped optional title.
var title: nullable String = null is writable
@@ -717,16 +717,16 @@ class TplListItem
# CSS classes of the element
var css_classes = new Array[String]
- init with_content(content: Streamable) do append(content)
+ init with_content(content: Writable) do append(content)
- init with_classes(content: Streamable, classes: Array[String]) do
+ init with_classes(content: Writable, classes: Array[String]) do
with_content(content)
css_classes = classes
end
# Append `content` to the item
# similar to `self.content.add`
- fun append(content: Streamable) do self.content.add content
+ fun append(content: Writable) do self.content.add content
redef fun rendering do
add ""
@@ -770,16 +770,16 @@ class TplTabPanel
# The panel name.
#
# Displayed in the tab header or in the pointing link.
- var name: Streamable
+ var name: Writable
# Is the panel visible by default?
var is_active = false is writable
# Body of the panel
- var content: nullable Streamable = null is writable
+ var content: nullable Writable = null is writable
# Get a link pointing to this panel.
- fun tpl_link_to: Streamable do
+ fun tpl_link_to: Writable do
var lnk = new Template
lnk.add ""
lnk.add name
@@ -801,12 +801,12 @@ class TplLabel
super Template
# Content of the label if any
- var content: nullable Streamable = null is writable
+ var content: nullable Writable = null is writable
# CSS classes of the element
var css_classes = new Array[String]
- init with_content(content: Streamable) do self.content = content
+ init with_content(content: Writable) do self.content = content
init with_classes(classes: Array[String]) do self.css_classes = classes
redef fun rendering do
@@ -867,7 +867,7 @@ class TplScript
super Template
var attrs = new Array[TagAttribute]
- var content: nullable Streamable = null is writable
+ var content: nullable Writable = null is writable
init do
attrs.add(new TagAttribute("type", "text/javascript"))
diff --git a/src/doc/vim_autocomplete.nit b/src/doc/vim_autocomplete.nit
index 2472466..10c6bc0 100644
--- a/src/doc/vim_autocomplete.nit
+++ b/src/doc/vim_autocomplete.nit
@@ -14,8 +14,9 @@
# Generate files used by the Vim plugin to autocomplete with doc
#
-# There is 3 files generated, each with a different target: modules, classes,
-# and properties. Each line describe a different entity, with 4 values:
+# There is 3 files generated, each with a different target: modules, types,
+# properties and constructors. Each line describe a different entity,
+# with 4 values:
#
# 1. Short name to use in autocompletion
# 2. Full signature
@@ -23,13 +24,14 @@
# 4. Full doc with extra
#
# The priority with those files is for them to be analyzed efficiently, for
-# this reason, the data is prepared in advant and some information may be
+# this reason, the data is prepared in advance and some information may be
# duplicated.
module vim_autocomplete
import modelbuilder
import phase
import modelize::modelize_class
+import model_utils
redef class ToolContext
# Phase generating the files for the Vim plugin
@@ -50,19 +52,19 @@ redef class MEntity
private fun field_separator: String do return "#====#"
private fun line_separator: String do return "#nnnn#"
- private fun write_to_stream(stream: OStream)
+ private fun write_to_stream(stream: Writer)
do
# 1. Short name for autocompletion
- stream.write name
+ stream.write complete_name
stream.write field_separator
# 2. Full signature
- stream.write name
+ stream.write complete_name
write_signature_to_stream(stream)
stream.write field_separator
# 3. Doc synopsis
- var mdoc = mdoc
+ var mdoc = complete_mdoc
if mdoc != null then
stream.write mdoc.content.first
end
@@ -80,7 +82,13 @@ redef class MEntity
stream.write "\n"
end
- private fun write_signature_to_stream(stream: OStream) do end
+ private fun write_signature_to_stream(stream: Writer) do end
+
+ # Actual name used in completion
+ private fun complete_name: String do return name
+
+ # Doc to use in completion
+ private fun complete_mdoc: nullable MDoc do return mdoc
end
redef class MMethodDef
@@ -103,6 +111,43 @@ redef class MAttributeDef
end
end
+# Use `MClassDef` as anchor for its constructors only
+redef class MClassDef
+ private var target_constructor: nullable MMethodDef = null
+
+ redef fun complete_name
+ do
+ var target_constructor = target_constructor
+ assert target_constructor != null
+
+ var params
+ var mparameters = mclass.mparameters
+ if not mparameters.is_empty then
+ params = "[{mparameters.join(", ")}]"
+ else
+ params = ""
+ end
+
+ if target_constructor.name != "init" and target_constructor.name != "new" then
+ return name + params + "." + target_constructor.name
+ end
+
+ return name + params
+ end
+
+ redef fun complete_mdoc
+ do
+ var target_constructor = target_constructor
+ assert target_constructor != null
+
+ if target_constructor.name != "init" and target_constructor.name != "new" then
+ return target_constructor.mdoc
+ end
+
+ return mdoc
+ end
+end
+
private class AutocompletePhase
super Phase
@@ -113,9 +158,12 @@ private class AutocompletePhase
var compile_dir = "NIT_VIM_DIR".environ
if compile_dir.is_empty then compile_dir = "HOME".environ / ".vim/nit"
compile_dir.mkdir
- var modules_stream = new OFStream.open(compile_dir / "modules.txt")
- var classes_stream = new OFStream.open(compile_dir / "classes.txt")
- var properties_stream = new OFStream.open(compile_dir / "properties.txt")
+
+ var modules_stream = new FileWriter.open(compile_dir / "modules.txt")
+ var classes_stream = new FileWriter.open(compile_dir / "classes.txt")
+ var constructors_stream = new FileWriter.open(compile_dir / "constructors.txt")
+ var types_stream = new FileWriter.open(compile_dir / "types.txt")
+ var properties_stream = new FileWriter.open(compile_dir / "properties.txt")
# Got all known modules
var model = mainmodule.model
@@ -124,13 +172,27 @@ private class AutocompletePhase
end
# TODO list other modules from the Nit lib
- # TODO list submodules
# Get all known classes
for mclass in model.mclasses do
if not mainmodule.is_visible(mclass.intro_mmodule, public_visibility) then continue
+ var mclass_intro = mclass.intro
+
+ # Can it be instantiated?
+ if mclass.kind != interface_kind and mclass.kind != abstract_kind then
+
+ for prop in mclass.all_mproperties(mainmodule, public_visibility) do
+ if prop isa MMethod and prop.is_init then
+ mclass_intro.target_constructor = prop.intro
+ mclass_intro.write_to_stream constructors_stream
+ end
+ end
+ mclass_intro.target_constructor = null
+ end
- mclass.intro.write_to_stream classes_stream
+ # Always add to types and classes
+ mclass.mclass_type.write_to_stream classes_stream
+ mclass.mclass_type.write_to_stream types_stream
end
# Get all known properties
@@ -138,13 +200,24 @@ private class AutocompletePhase
var intro_mmodule = mproperty.intro_mclassdef.mmodule
if not mainmodule.is_visible(intro_mmodule, public_visibility) then continue
+ # Is it a virtual type?
+ if mproperty isa MVirtualTypeProp then
+ mproperty.intro.write_to_stream types_stream
+ continue
+ end
+
+ # Skip properties beginning with @ or _
+ var first_letter = mproperty.name.chars.first
+ if first_letter == '@' or first_letter == '_' then continue
+
mproperty.intro.write_to_stream properties_stream
end
# Close streams
- for stream in [modules_stream, classes_stream, properties_stream] do
- stream.close
+ for stream in [modules_stream, classes_stream, properties_stream,
+ types_stream, constructors_stream] do
+ stream.close
var error = stream.last_error
if error != null then
toolcontext.error(null, "Failed to write Vim autocomplete file: {error}")
diff --git a/src/ffi/c_compiler_options.nit b/src/ffi/c_compiler_options.nit
index 4fbd5c4..878785c 100644
--- a/src/ffi/c_compiler_options.nit
+++ b/src/ffi/c_compiler_options.nit
@@ -101,10 +101,10 @@ private class CCompilerOptionsPhase
var cmd_args = opt.command
var proc
if cmd_args.length == 1 then
- proc = new IProcess.from_a(cmd_args[0], new Array[String])
+ proc = new ProcessReader.from_a(cmd_args[0], new Array[String])
else if cmd_args.length > 1 then
var rest_args = cmd_args.subarray(1, cmd_args.length-1)
- proc = new IProcess.from_a(cmd_args[0], rest_args)
+ proc = new ProcessReader.from_a(cmd_args[0], rest_args)
else abort
# wait for its completion
diff --git a/src/ffi/ffi_base.nit b/src/ffi/ffi_base.nit
index babab08..59f46b3 100644
--- a/src/ffi/ffi_base.nit
+++ b/src/ffi/ffi_base.nit
@@ -166,7 +166,7 @@ redef class CCompilationUnit
fun write_header_to_file(mmodule: MModule, file: String, includes: Array[String], guard: String)
do
- var stream = new OFStream.open( file )
+ var stream = new FileWriter.open( file )
# header comments
var module_info = "/*\n\tExtern implementation of Nit module {mmodule.name}\n*/\n"
@@ -187,7 +187,7 @@ redef class CCompilationUnit
fun write_body_to_file(mmodule: MModule, file: String, includes: Array[String])
do
- var stream = new OFStream.open(file)
+ var stream = new FileWriter.open(file)
var module_info = "/*\n\tExtern implementation of Nit module {mmodule.name}\n*/\n"
diff --git a/src/ffi/pkgconfig.nit b/src/ffi/pkgconfig.nit
index dca4fab..bd62de3 100644
--- a/src/ffi/pkgconfig.nit
+++ b/src/ffi/pkgconfig.nit
@@ -67,7 +67,7 @@ class PkgconfigPhase
end
# check availability of pkg-config
- var proc_which = new IProcess("which", "pkg-config")
+ var proc_which = new ProcessReader("which", "pkg-config")
proc_which.wait
var status = proc_which.status
if status != 0 then
diff --git a/src/frontend/check_annotation.nit b/src/frontend/check_annotation.nit
index a51bece..9408e95 100644
--- a/src/frontend/check_annotation.nit
+++ b/src/frontend/check_annotation.nit
@@ -83,6 +83,7 @@ noinit
readonly
writable
autoinit
+noautoinit
cached
nosuper
old_style_init
diff --git a/src/frontend/glsl_validation.nit b/src/frontend/glsl_validation.nit
index 5dd6b79..692d918 100644
--- a/src/frontend/glsl_validation.nit
+++ b/src/frontend/glsl_validation.nit
@@ -62,7 +62,7 @@ private class GLSLValidationPhase
if not in_path then return
else
# Is _glslangValidator_ installed?
- var proc_which = new IProcess("which", "glslangValidator")
+ var proc_which = new ProcessReader("which", "glslangValidator")
proc_which.wait
proc_which.close
var status = proc_which.status
@@ -91,7 +91,7 @@ private class GLSLValidationPhase
shader.write_to_file path
# Execute the validator
- var proc_validator = new IProcess("glslangValidator", path)
+ var proc_validator = new ProcessReader("glslangValidator", path)
proc_validator.wait
var lines = proc_validator.read_all.split('\n')
proc_validator.close
diff --git a/src/interpreter/debugger_socket.nit b/src/interpreter/debugger_socket.nit
index 50f98c7..828cb3b 100644
--- a/src/interpreter/debugger_socket.nit
+++ b/src/interpreter/debugger_socket.nit
@@ -115,7 +115,7 @@ redef class ModelBuilder
end
redef class Sys
- private fun set_io(istream: PollableIStream, ostream: OStream, errstream: OStream)
+ private fun set_io(istream: PollableReader, ostream: Writer, errstream: Writer)
do
self.stdin = istream
self.stdout = ostream
diff --git a/src/interpreter/primitive_types.nit b/src/interpreter/primitive_types.nit
index 0de93d3..122fe4e 100644
--- a/src/interpreter/primitive_types.nit
+++ b/src/interpreter/primitive_types.nit
@@ -20,7 +20,7 @@ intrude import standard::string
# Wrapper for `NativeFile`
class PrimitiveNativeFile
- var file: IOS
+ var file: Stream
init native_stdin do
file = sys.stdin
@@ -35,49 +35,49 @@ class PrimitiveNativeFile
end
init io_open_read(path: String) do
- file = new IFStream.open(path.to_s)
+ file = new FileReader.open(path.to_s)
end
init io_open_write(path: String) do
- file = new OFStream.open(path.to_s)
+ file = new FileWriter.open(path.to_s)
end
fun address_is_null: Bool do
- if file isa FStream then return file.as(FStream)._file.address_is_null
+ if file isa FileStream then return file.as(FileStream)._file.address_is_null
return false
end
fun io_read(buf: NativeString, len: Int): Int do
- if file isa FStream then return file.as(FStream)._file.io_read(buf, len)
- var str = file.as(IStream).read(len)
+ if file isa FileStream then return file.as(FileStream)._file.io_read(buf, len)
+ var str = file.as(Reader).read(len)
str.to_cstring.copy_to(buf, str.length, 0, 0)
return str.length
end
fun io_write(buf: NativeString, len: Int): Int do
- if file isa FStream then return file.as(FStream)._file.io_write(buf, len)
- file.as(OStream).write(buf.to_s_with_length(len))
+ if file isa FileStream then return file.as(FileStream)._file.io_write(buf, len)
+ file.as(Writer).write(buf.to_s_with_length(len))
return len
end
fun io_close: Int do
- if file isa FStream then return file.as(FStream)._file.io_close
+ if file isa FileStream then return file.as(FileStream)._file.io_close
file.close
return 0
end
fun fileno: Int do
- if file isa FStream then return file.as(FStream)._file.fileno
+ if file isa FileStream then return file.as(FileStream)._file.fileno
return 0
end
fun flush: Int do
- if file isa FStream then return file.as(FStream)._file.flush
+ if file isa FileStream then return file.as(FileStream)._file.flush
return 0
end
fun set_buffering_type(size, mode: Int): Int do
- if file isa FStream then return file.as(FStream)._file.set_buffering_type(size, mode)
+ if file isa FileStream then return file.as(FileStream)._file.set_buffering_type(size, mode)
return 0
end
end
diff --git a/src/loader.nit b/src/loader.nit
index 517deab..65e7c67 100644
--- a/src/loader.nit
+++ b/src/loader.nit
@@ -386,7 +386,7 @@ redef class ModelBuilder
if not readme.file_exists then readme = dirpath2.join_path("README")
if readme.file_exists then
var mdoc = new MDoc
- var s = new IFStream.open(readme)
+ var s = new FileReader.open(readme)
while not s.eof do
mdoc.content.add(s.read_line)
end
@@ -430,7 +430,7 @@ redef class ModelBuilder
self.toolcontext.info("load module {filename}", 2)
# Load the file
- var file = new IFStream.open(filename)
+ var file = new FileReader.open(filename)
var lexer = new Lexer(new SourceFile(filename, file))
var parser = new Parser(lexer)
var tree = parser.parse
diff --git a/src/location.nit b/src/location.nit
index d7154ca..83ed72f 100644
--- a/src/location.nit
+++ b/src/location.nit
@@ -26,7 +26,7 @@ class SourceFile
var string: String is noinit
# The original stream used to initialize `string`
- var stream: IStream
+ var stream: Reader
init
do
diff --git a/src/metrics/generate_hierarchies.nit b/src/metrics/generate_hierarchies.nit
index 3522245..6193b9c 100644
--- a/src/metrics/generate_hierarchies.nit
+++ b/src/metrics/generate_hierarchies.nit
@@ -77,7 +77,7 @@ do
end
end
buf.append("\}\n")
- var f = new OFStream.open(toolcontext.output_dir.join_path("class_hierarchy.dot"))
+ var f = new FileWriter.open(toolcontext.output_dir.join_path("class_hierarchy.dot"))
f.write(buf.to_s)
f.close
end
@@ -99,7 +99,7 @@ do
end
end
buf.append("\}\n")
- var f = new OFStream.open(toolcontext.output_dir.join_path("classdef_hierarchy.dot"))
+ var f = new FileWriter.open(toolcontext.output_dir.join_path("classdef_hierarchy.dot"))
f.write(buf.to_s)
f.close
end
diff --git a/src/metrics/model_hyperdoc.nit b/src/metrics/model_hyperdoc.nit
index 43384d9..9e66e73 100644
--- a/src/metrics/model_hyperdoc.nit
+++ b/src/metrics/model_hyperdoc.nit
@@ -186,7 +186,7 @@ do
end
end
buf.append("