/**
 * Copyright (c) 2021 Dominic Masters
 * 
 * This software is released under the MIT License.
 * https://opensource.org/licenses/MIT
 */

#include "io.h"

scripterreturn_t _scriptPrint(scriptercontext_t *ctx) {
  duk_push_string(ctx, " ");
  duk_insert(ctx, 0);
  duk_join(ctx, duk_get_top(ctx) - 1);
  printf("%s\n", duk_safe_to_string(ctx, -1));
  return 0;
}

void scriptsApiIo(scripter_t *scripter) {
  scripterDefineMethod(scripter,
    SCRIPT_IO_PRINT_NAME,
    SCRIPT_IO_PRINT_ARGS,
    &_scriptPrint
  );
}