From: Lucas Bajolet Date: Tue, 10 Feb 2015 18:18:41 +0000 (-0500) Subject: lib/standard/stream: Renamed streams for more explicit denomination X-Git-Tag: v0.7.2~17^2~1 X-Git-Url: http://nitlanguage.org lib/standard/stream: Renamed streams for more explicit denomination Signed-off-by: Lucas Bajolet --- diff --git a/benchmarks/languages/bench_base.nit b/benchmarks/languages/bench_base.nit index 69590af..9f79133 100644 --- a/benchmarks/languages/bench_base.nit +++ b/benchmarks/languages/bench_base.nit @@ -48,7 +48,7 @@ class Generator middle = (dept + 1) / 2 end - var file: nullable OFStream = null + var file: nullable FileWriter = null fun write(str: String) do file.write(str) @@ -62,7 +62,7 @@ class Generator do dir = "{dir}/nit" dir.mkdir - file = new OFStream.open("{dir}/{name}.nit") + file = new FileWriter.open("{dir}/{name}.nit") write "class Root\n\tfun id: Int do return 0\nend" for c in classes do @@ -117,7 +117,7 @@ class Generator do dir = "{dir}/java" dir.mkdir - file = new OFStream.open("{dir}/{name}.java") + file = new FileWriter.open("{dir}/{name}.java") var cl = "" if interfaces then cl = "X" @@ -183,7 +183,7 @@ class Generator do dir = "{dir}/cs" dir.mkdir - file = new OFStream.open("{dir}/{name}.cs") + file = new FileWriter.open("{dir}/{name}.cs") var cl = "" if interfaces then cl = "X" @@ -248,7 +248,7 @@ class Generator do dir = "{dir}/scala" dir.mkdir - file = new OFStream.open("{dir}/{name}.scala") + file = new FileWriter.open("{dir}/{name}.scala") var cl = "" write "object {name} \{" @@ -316,7 +316,7 @@ class Generator do dir = "{dir}/cpp" dir.mkdir - file = new OFStream.open("{dir}/{name}.cpp") + file = new FileWriter.open("{dir}/{name}.cpp") write "#include " write "#include " @@ -374,7 +374,7 @@ class Generator dir = "{dir}/es/{name}" end dir.mkdir - file = new OFStream.open("{dir}/root.e") + file = new FileWriter.open("{dir}/root.e") var istk = "" if se then istk = " is" @@ -384,7 +384,7 @@ class Generator file.close for c in classes do - file = new OFStream.open("{dir}/{c}.e") + file = new FileWriter.open("{dir}/{c}.e") write "class {c}[E] " if c.supers.is_empty then write "\tinherit ROOT" @@ -398,7 +398,7 @@ class Generator file.close end - file = new OFStream.open("{dir}/app{name}.e") + file = new FileWriter.open("{dir}/app{name}.e") write "class APP{name.to_upper}" if se then write "insert ARGUMENTS" diff --git a/contrib/benitlux/src/benitlux_controller.nit b/contrib/benitlux/src/benitlux_controller.nit index 84ae549..2297bbd 100644 --- a/contrib/benitlux/src/benitlux_controller.nit +++ b/contrib/benitlux/src/benitlux_controller.nit @@ -70,7 +70,7 @@ class BenitluxSubscriptionAction end if sample_email_path.file_exists then - var f = new IFStream.open(sample_email_path) + var f = new FileReader.open(sample_email_path) var lines = new Array[String] for line in f.read_all.split_with("\n") do if not line.is_empty then lines.add line f.close @@ -108,7 +108,7 @@ class BenitluxRESTAction return response end - var stream = new StringOStream + var stream = new StringWriter var serializer = new JsonSerializer(stream) serializer.serialize events var serialized = stream.to_s diff --git a/contrib/benitlux/src/benitlux_daily.nit b/contrib/benitlux/src/benitlux_daily.nit index 64f6e15..35aa64c 100644 --- a/contrib/benitlux/src/benitlux_daily.nit +++ b/contrib/benitlux/src/benitlux_daily.nit @@ -112,7 +112,7 @@ class Benitlux generate_email(beer_events) # Save as sample email to file - var f = new OFStream.open(sample_email_path) + var f = new FileWriter.open(sample_email_path) f.write email_title + "\n" for line in email_content do f.write line + "\n" f.close diff --git a/contrib/brainfuck/brainfuck.nit b/contrib/brainfuck/brainfuck.nit index c35b08a..f7de908 100644 --- a/contrib/brainfuck/brainfuck.nit +++ b/contrib/brainfuck/brainfuck.nit @@ -39,7 +39,7 @@ class BFInterpreter # Create an interpreter for the file located at `path`. init from_file(path: String) do - var ifs = new IFStream.open(path) + var ifs = new FileReader.open(path) init(ifs.read_all) end diff --git a/contrib/inkscape_tools/src/svg_to_png_and_nit.nit b/contrib/inkscape_tools/src/svg_to_png_and_nit.nit index 2a94089..b24cbf5 100644 --- a/contrib/inkscape_tools/src/svg_to_png_and_nit.nit +++ b/contrib/inkscape_tools/src/svg_to_png_and_nit.nit @@ -141,7 +141,7 @@ for drawing in drawings do # Inkscape doesn't give us this information var page_width = -1 var page_height = -1 - var svg_file = new IFStream.open(drawing) + var svg_file = new FileReader.open(drawing) while not svg_file.eof do var line = svg_file.read_line @@ -164,7 +164,7 @@ for drawing in drawings do # Query Inkscape var prog = "inkscape" - var proc = new IProcess.from_a(prog, ["--without-gui", "--query-all", drawing]) + var proc = new ProcessReader.from_a(prog, ["--without-gui", "--query-all", drawing]) var min_x = 1000000 var min_y = 1000000 @@ -240,7 +240,7 @@ for drawing in drawings do end # Output source file - var src_file = new OFStream.open("{src_path}/{drawing_name}.nit") + var src_file = new FileWriter.open("{src_path}/{drawing_name}.nit") nit_src.write_to(src_file) src_file.close diff --git a/contrib/jwrapper/src/code_generator.nit b/contrib/jwrapper/src/code_generator.nit index 917074d..f0be48c 100644 --- a/contrib/jwrapper/src/code_generator.nit +++ b/contrib/jwrapper/src/code_generator.nit @@ -23,14 +23,14 @@ class CodeGenerator var with_attributes: Bool var comment_unknown_types: Bool - var file_out: OFStream + var file_out: FileWriter var java_class: JavaClass var nb_params: Int var module_name: nullable String = null init (file_name: String, jclass: JavaClass, with_attributes, comment: Bool) do - file_out = new OFStream.open(file_name) + file_out = new FileWriter.open(file_name) var nit_ext = ".nit" if file_name.has_suffix(nit_ext) then diff --git a/contrib/jwrapper/src/jwrapper.nit b/contrib/jwrapper/src/jwrapper.nit index 56128b7..dd3f8ef 100644 --- a/contrib/jwrapper/src/jwrapper.nit +++ b/contrib/jwrapper/src/jwrapper.nit @@ -63,7 +63,7 @@ if not "javap".program_is_in_path then exit 1 end -var javap = new IProcess("javap", "-public", dot_class) +var javap = new ProcessReader("javap", "-public", dot_class) var p = new TestParser_javap var tree = p.work(javap.read_all) diff --git a/contrib/jwrapper/src/model.nit b/contrib/jwrapper/src/model.nit index cb99a23..34792c9 100644 --- a/contrib/jwrapper/src/model.nit +++ b/contrib/jwrapper/src/model.nit @@ -176,7 +176,7 @@ class JavaType var regex = "extern class [a-zA-Z1-9]\\\+[ ]\\\+in[ ]\\\+\"Java\"[ ]*`\{[ ]*" + self.to_s + "\\\+[ ]*`\}" var nit_dir = "NIT_DIR".environ - var grep = new IProcess("grep", "-r", regex, nit_dir/"lib/android/", nit_dir/"lib/java/") + var grep = new ProcessReader("grep", "-r", regex, nit_dir/"lib/android/", nit_dir/"lib/java/") var to_eat = ["private", "extern", "class"] var output = grep.read_line diff --git a/contrib/nitcc/src/autom.nit b/contrib/nitcc/src/autom.nit index 1367e0d..f286894 100644 --- a/contrib/nitcc/src/autom.nit +++ b/contrib/nitcc/src/autom.nit @@ -443,7 +443,7 @@ class Automaton ni += 1 end - var f = new OFStream.open(filepath) + var f = new FileWriter.open(filepath) f.write("digraph g \{\n") for s in states do @@ -638,10 +638,10 @@ private class DFAGenerator var automaton: Automaton var parser: nullable String - var out: OStream is noinit + var out: Writer is noinit init do - self.out = new OFStream.open(filepath) + self.out = new FileWriter.open(filepath) end fun add(s: String) do out.write(s) diff --git a/contrib/nitcc/src/grammar.nit b/contrib/nitcc/src/grammar.nit index b9ac2f8..e77f4e9 100644 --- a/contrib/nitcc/src/grammar.nit +++ b/contrib/nitcc/src/grammar.nit @@ -575,7 +575,7 @@ class LRAutomaton # Generate a graphviz file of the automaton fun to_dot(path: String) do - var f = new OFStream.open(path) + var f = new FileWriter.open(path) f.write("digraph g \{\n") f.write("rankdir=LR;\n") f.write("node[shape=Mrecord,height=0];\n") @@ -622,7 +622,7 @@ class LRAutomaton do var gen = new Generator gen.gen_to_nit(self, name) - var f = new OFStream.open(filepath) + var f = new FileWriter.open(filepath) for s in gen.out do f.write(s) f.write("\n") diff --git a/contrib/nitcc/src/nitcc.nit b/contrib/nitcc/src/nitcc.nit index 0cc9d2a..a499217 100644 --- a/contrib/nitcc/src/nitcc.nit +++ b/contrib/nitcc/src/nitcc.nit @@ -27,7 +27,7 @@ var fi = args.first var text if fi != "-" then - var f = new IFStream.open(fi) + var f = new FileReader.open(fi) text = f.read_all f.close else @@ -94,7 +94,7 @@ for prod in gram.prods do nbalts += prod.alts.length print "Concrete grammar: {gram.prods.length} productions, {nbalts} alternatives (see {name}.concrete_grammar.out)" var pretty = gram.pretty -var f = new OFStream.open("{name}.concrete_grammar.out") +var f = new FileWriter.open("{name}.concrete_grammar.out") f.write "// Concrete grammar of {name}\n" f.write pretty f.close @@ -102,7 +102,7 @@ f.close print "LR automaton: {lr.states.length} states (see {name}.lr.dot and {name}.lr.out)" lr.to_dot("{name}.lr.dot") pretty = lr.pretty -f = new OFStream.open("{name}.lr.out") +f = new FileWriter.open("{name}.lr.out") f.write "// LR automaton of {name}\n" f.write pretty f.close @@ -142,7 +142,7 @@ print "Generate {name}_lexer.nit {name}_parser.nit {name}_test_parser.nit" dfa.gen_to_nit("{name}_lexer.nit", name, "{name}_parser") lr.gen_to_nit("{name}_parser.nit", name) -f = new OFStream.open("{name}_test_parser.nit") +f = new FileWriter.open("{name}_test_parser.nit") f.write """# Generated by nitcc for the language {{{name}}} # Standalone parser tester for the language {{{name}}} diff --git a/contrib/nitcc/src/nitcc_parser_gen.nit b/contrib/nitcc/src/nitcc_parser_gen.nit index 65608d0..c15238b 100644 --- a/contrib/nitcc/src/nitcc_parser_gen.nit +++ b/contrib/nitcc/src/nitcc_parser_gen.nit @@ -198,6 +198,6 @@ a.to_dot("nitcc0.lr.dot") a.gen_to_nit("nitcc_parser.nit", "nitcc") -var f = new OFStream.open("nitcc_lexer.nit") +var f = new FileWriter.open("nitcc_lexer.nit") f.write("import nitcc_lexer0\n") f.close diff --git a/contrib/nitester/src/nitester.nit b/contrib/nitester/src/nitester.nit index eed0d4b..11df5b2 100644 --- a/contrib/nitester/src/nitester.nit +++ b/contrib/nitester/src/nitester.nit @@ -180,7 +180,7 @@ abstract class Processor var skip_path = "tests/turing.skip" var skip if skip_path.file_exists then - var skip_file = new IFStream.open(skip_path) + var skip_file = new FileReader.open(skip_path) skip = skip_file.read_lines skip_file.close else @@ -463,7 +463,7 @@ class Worker sys.system cmd # Test results were written to file, read them - var fstream = new IFStream.open(tests_sh_out) + var fstream = new FileReader.open(tests_sh_out) var content = fstream.read_all fstream.close diff --git a/contrib/nitiwiki/src/wiki_base.nit b/contrib/nitiwiki/src/wiki_base.nit index 3dec44f..fa78818 100644 --- a/contrib/nitiwiki/src/wiki_base.nit +++ b/contrib/nitiwiki/src/wiki_base.nit @@ -113,7 +113,7 @@ class Nitiwiki # List markdown source files from a directory. fun list_md_files(dir: String): Array[String] do var files = new Array[String] - var pipe = new IProcess("find", dir, "-name", "*.md") + var pipe = new ProcessReader("find", dir, "-name", "*.md") while not pipe.eof do var file = pipe.read_line if file == "" then break # last line @@ -512,7 +512,7 @@ class WikiArticle # Page content. # # What you want to be displayed in the page. - var content: nullable Streamable = null + var content: nullable Writable = null # Headlines ids and titles. var headlines = new ArrayMap[String, HeadLine] @@ -540,7 +540,7 @@ class WikiArticle # REQUIRE: `has_source`. fun md: String is cached do assert has_source - var file = new IFStream.open(src_full_path.to_s) + var file = new FileReader.open(src_full_path.to_s) var md = file.read_all file.close return md diff --git a/contrib/nitiwiki/src/wiki_html.nit b/contrib/nitiwiki/src/wiki_html.nit index 89546ce..10ab09b 100644 --- a/contrib/nitiwiki/src/wiki_html.nit +++ b/contrib/nitiwiki/src/wiki_html.nit @@ -52,7 +52,7 @@ redef class WikiEntry fun url: String do return wiki.config.root_url.join_path(breadcrumbs.join("/")) # Get a `` template link to `self` - fun tpl_link: Streamable do + fun tpl_link: Writable do return "{title}" end end @@ -215,7 +215,7 @@ redef class WikiArticle end # Generate the HTML header for this article. - fun tpl_header: Streamable do + fun tpl_header: Writable do var file = header_file if not wiki.has_template(file) then return "" return wiki.load_template(file) @@ -237,7 +237,7 @@ redef class WikiArticle # Generate the HTML summary for this article. # # Based on `headlines` - fun tpl_summary: Streamable do + fun tpl_summary: Writable do var headlines = self.headlines var tpl = new Template tpl.add "