Skip to content

Commit

Permalink
Added -ln print methods for outputting text.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed May 16, 2024
1 parent 2026f79 commit 9bcce5f
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
41 changes: 40 additions & 1 deletion sdk/librishka/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ class IO final {
*/
static void print(const string text);

/**
* @brief Print text to the output stream.
*
* This method prints the specified text to the output
* stream followed by a new line.
*
* @param text The text to be printed.
*/
static void println(const string text);

/**
* @brief Print an integer number to the output stream.
*
Expand All @@ -57,15 +67,44 @@ class IO final {
*/
static void print(i64 number);

/**
* @brief Print an integer number to the output stream.
*
* This method prints the specified integer number to
* the output stream followed by a new line.
*
* @param number The integer number to be printed.
*/
static void println(i64 number);

/**
* @brief Print a floating-point number to the output stream.
*
* This method prints the specified floating-point number to the output stream.
* This method prints the specified floating-point number
* to the output stream.
*
* @param number The floating-point number to be printed.
*/
static void print(double number);

/**
* @brief Print a floating-point number to the output stream.
*
* This method prints the specified floating-point number
* to the output stream followed by a new line.
*
* @param number The floating-point number to be printed.
*/
static void println(double number);

/**
* @brief Prints a new line to the output stream.
*
* THis method prints a new line to the current
* output stream.
*/
static void println();

/**
* @brief Check if there is data available to read from the input stream.
*
Expand Down
19 changes: 19 additions & 0 deletions sdk/librishka_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,33 @@ void IO::print(const string text) {
rishka_sc_1(RISHKA_SC_IO_PRINTS, (i64) text);
}

void IO::println(const string text) {
rishka_sc_1(RISHKA_SC_IO_PRINTS, (i64) text);
IO::println();
}

void IO::print(i64 number) {
rishka_sc_1(RISHKA_SC_IO_PRINTN, (i64) number);
}

void IO::println(i64 number) {
rishka_sc_1(RISHKA_SC_IO_PRINTN, (i64) number);
IO::println();
}

void IO::print(double number) {
rishka_sc_1(RISHKA_SC_IO_PRINTD, double_to_long(number));
}

void IO::println(double number) {
rishka_sc_1(RISHKA_SC_IO_PRINTD, double_to_long(number));
IO::println();
}

void IO::println() {
IO::print(F("\r\n"));
}

rune IO::readch() {
return (rune) rishka_sc_0(RISHKA_SC_IO_READCH);
}
Expand Down

0 comments on commit 9bcce5f

Please sign in to comment.