neo_doxygen: Force the standard output to flush.
authorJean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Mon, 24 Nov 2014 01:41:37 +0000 (20:41 -0500)
committerJean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Tue, 25 Nov 2014 17:01:05 +0000 (12:01 -0500)
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

contrib/neo_doxygen/src/flush_stdout.nit [new file with mode: 0644]
contrib/neo_doxygen/src/graph_store.nit
contrib/neo_doxygen/src/neo_doxygen.nit

diff --git a/contrib/neo_doxygen/src/flush_stdout.nit b/contrib/neo_doxygen/src/flush_stdout.nit
new file mode 100644 (file)
index 0000000..30be3fc
--- /dev/null
@@ -0,0 +1,25 @@
+# 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.
+
+# Add the ability to flush the standard output.
+module flush_stdout
+
+in "C Header" `{
+       #include <stdio.h>
+`}
+
+# Flush the standard output.
+fun flush_stdout in "C" `{
+       fflush(stdout);
+`}
index cc0eaec..b15ae4f 100644 (file)
@@ -17,6 +17,7 @@ module graph_store
 
 import neo4j
 import console
+import flush_stdout
 
 # A storage medium for a graph.
 #
@@ -41,6 +42,7 @@ abstract class GraphStore
        # `show_done`.
        protected fun prepare_display do
                printn "{term_save_cursor} "
+               flush_stdout
        end
 
        # Show the progress, in percentage.
@@ -48,6 +50,7 @@ abstract class GraphStore
        # For use in the implementation of `save_all` only.
        protected fun show_progress(progress: Int) do
                printn "{term_rewind} {progress}% "
+               flush_stdout
        end
 
        # Show a message to indicate that the task finished with success.
@@ -55,6 +58,7 @@ abstract class GraphStore
        # For use in the implementation of `save_all` only.
        protected fun show_done do
                print "{term_rewind} Done."
+               flush_stdout
        end
 end
 
index 3b160ad..161eddc 100644 (file)
@@ -22,6 +22,7 @@ import model
 import doxml
 import graph_store
 import console
+import flush_stdout
 import opts
 
 # An importation task.
@@ -59,6 +60,7 @@ class NeoDoxygenJob
                else
                        printn "Reading {dir}... "
                end
+               flush_stdout
                loop
                        for f in dir.files do
                                var path = dir/f
@@ -78,6 +80,7 @@ class NeoDoxygenJob
                else
                        print "{file_count} files read."
                end
+               flush_stdout
        end
 
        # Check the project’s name.
@@ -95,6 +98,7 @@ class NeoDoxygenJob
        # Save the graph.
        fun save do
                sys.stdout.write "Linking nodes...{term_save_cursor} "
+               flush_stdout
                model.put_edges
                print "{term_rewind} Done."
                var nodes = model.all_nodes