MCPcopy Create free account
hub / github.com/Tablecruncher/tablecruncher / internalPrintln

Method internalPrintln

src/macro.cpp:258–274  ·  view source on GitHub ↗

* Prints the given arguments to stdout */

Source from the content-addressed store, hash-verified

256 * Prints the given arguments to stdout
257 */
258duk_ret_t Macro::internalPrintln(duk_context *context) {
259 std::string str;
260 duk_idx_t numArgs = duk_get_top(context);
261 for( int i = 0; i < numArgs; ++i ) {
262 if( duk_get_type(context, i) == DUK_TYPE_STRING ) {
263 str = duk_safe_to_string(context, i);
264 } else if( duk_get_type(context, i) == DUK_TYPE_NUMBER ) {
265 str = std::to_string(duk_to_number(context, i));
266 str.erase(str.find_last_not_of("0")+1);
267 str.erase(str.find_last_not_of(".")+1);
268 } else {
269 str = "";
270 }
271 printf("%s\n", str.c_str()); fflush(stdout);
272 }
273 return 0;
274}
275
276
277void Macro::fatalErrorHandler(void *, const char *) {

Callers

nothing calls this directly

Calls 1

to_stringFunction · 0.85

Tested by

no test coverage detected