Skip to content

Commit

Permalink
Add 'flush' function. kuina#146
Browse files Browse the repository at this point in the history
  • Loading branch information
kuina committed Apr 24, 2020
1 parent cb1931c commit ecd26f9
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions package/sys/cui.kn
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ end func
+func [d0002.knd, _print] print(str: []char)
end func

+func [d0002.knd, _flush] flush()
end func

+func [d0002.knd, _inputLetter] inputLetter(): char
end func

Expand Down
3 changes: 3 additions & 0 deletions package/sys/file.kn
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ end class
+func [d0000.knd, _writerWriteStr] writeStr(n: []char)
end func

+func [d0000.knd, _writerFlush] flush()
end func

var handle: int
end class

Expand Down
7 changes: 7 additions & 0 deletions src/lib_common/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,13 @@ EXPORT void _writerWriteStr(SClass* me_, const U8* n)
}
}

EXPORT void _writerFlush(SClass* me_)
{
SWriter* me2 = (SWriter*)me_;
THROWDBG(me2->Handle == NULL, EXCPT_DBG_INOPERABLE_STATE);
fflush(me2->Handle);
}

EXPORT Bool _makeDir(const U8* path)
{
THROWDBG(path == NULL, EXCPT_ACCESS_VIOLATION);
Expand Down
1 change: 1 addition & 0 deletions src/lib_common/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ EXPORT void _writerWriteInt(SClass* me_, S64 n);
EXPORT void _writerWriteFloat(SClass* me_, double n);
EXPORT void _writerWriteChar(SClass* me_, Char n);
EXPORT void _writerWriteStr(SClass* me_, const U8* n);
EXPORT void _writerFlush(SClass* me_);
EXPORT Bool _makeDir(const U8* path);
EXPORT Bool _forEachDir(const U8* path, Bool recursion, void* callback, void* data);
EXPORT Bool _existPath(const U8* path);
Expand Down
5 changes: 5 additions & 0 deletions src/lib_cui/cui.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ EXPORT void _print(const U8* str)
#endif
}

EXPORT void _flush(void)
{
fflush(stdout);
}

EXPORT Char _inputLetter(void)
{
Char c = fgetwc(stdin);
Expand Down
1 change: 1 addition & 0 deletions src/lib_cui/cui.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// 'cui'
EXPORT void _delimiter(const U8* delimiters);
EXPORT void _print(const U8* str);
EXPORT void _flush(void);
EXPORT Char _inputLetter(void);
EXPORT S64 _inputInt(void);
EXPORT double _inputFloat(void);
Expand Down

0 comments on commit ecd26f9

Please sign in to comment.