コード例 #1
0
ファイル: script.c プロジェクト: metiscus/memoria
static sexp sexp_random_uint_range_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1) {
  sexp res;
  if (! sexp_exact_integerp(arg0))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg0);
  if (! sexp_exact_integerp(arg1))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg1);
  res = sexp_make_unsigned_integer(ctx, random_uint_range(sexp_uint_value(arg0), sexp_uint_value(arg1)));
  return res;
}
コード例 #2
0
ファイル: filesystem.c プロジェクト: fmutant/scriptorium
static sexp sexp_open_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1, sexp arg2) {
  sexp res;
  if (! sexp_stringp(arg0))
    return sexp_type_exception(ctx, self, SEXP_STRING, arg0);
  if (! sexp_exact_integerp(arg1))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg1);
  if (! sexp_exact_integerp(arg2))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg2);
  res = sexp_make_fileno(ctx, sexp_make_fixnum(open(sexp_string_data(arg0), sexp_sint_value(arg1), sexp_sint_value(arg2))), SEXP_FALSE);
  return res;
}
コード例 #3
0
ファイル: script.c プロジェクト: metiscus/memoria
static sexp sexp_player_move_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1, sexp arg2) {
  sexp res;
  if (! (sexp_pointerp(arg0) && (sexp_pointer_tag(arg0) == sexp_unbox_fixnum(sexp_opcode_arg1_type(self)))))
    return sexp_type_exception(ctx, self, sexp_unbox_fixnum(sexp_opcode_arg1_type(self)), arg0);
  if (! sexp_exact_integerp(arg1))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg1);
  if (! sexp_exact_integerp(arg2))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg2);
  res = ((player_move((struct player**)sexp_cpointer_value(arg0), sexp_uint_value(arg1), sexp_uint_value(arg2))), SEXP_VOID);
  return res;
}
コード例 #4
0
ファイル: filesystem.c プロジェクト: fmutant/scriptorium
static sexp sexp_S_ISREG_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0) {
  sexp res;
  if (! sexp_exact_integerp(arg0))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg0);
  res = sexp_make_boolean(S_ISREG(sexp_uint_value(arg0)));
  return res;
}
コード例 #5
0
ファイル: script.c プロジェクト: metiscus/memoria
static sexp sexp_sleep_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0) {
  sexp res;
  if (! sexp_exact_integerp(arg0))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg0);
  res = ((io_sleep(sexp_uint_value(arg0))), SEXP_VOID);
  return res;
}
コード例 #6
0
ファイル: filesystem.c プロジェクト: fmutant/scriptorium
static sexp sexp_file_truncate_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1) {
  sexp res;
  if (! (sexp_portp(arg0) || sexp_filenop(arg0) || sexp_fixnump(arg0)))
    return sexp_xtype_exception(ctx, self, "not a port or file descriptor",arg0);
  if (! sexp_exact_integerp(arg1))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg1);
  res = sexp_make_integer(ctx, ftruncate((sexp_portp(arg0) ? sexp_port_fileno(arg0) : sexp_filenop(arg0) ? sexp_fileno_fd(arg0) : sexp_unbox_fixnum(arg0)), sexp_uint_value(arg1)));
  return res;
}
コード例 #7
0
ファイル: filesystem.c プロジェクト: fmutant/scriptorium
static sexp sexp_file_access_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1) {
  sexp res;
  if (! sexp_stringp(arg0))
    return sexp_type_exception(ctx, self, SEXP_STRING, arg0);
  if (! sexp_exact_integerp(arg1))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg1);
  res = sexp_make_integer(ctx, access(sexp_string_data(arg0), sexp_sint_value(arg1)));
  return res;
}
コード例 #8
0
ファイル: filesystem.c プロジェクト: fmutant/scriptorium
static sexp sexp_set_file_descriptor_flags_x_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg2) {
  int err;
  sexp res;
  if (! (sexp_portp(arg0) || sexp_filenop(arg0) || sexp_fixnump(arg0)))
    return sexp_xtype_exception(ctx, self, "not a port or file descriptor",arg0);
  if (! sexp_exact_integerp(arg2))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg2);
  err = fcntl((sexp_portp(arg0) ? sexp_port_fileno(arg0) : sexp_filenop(arg0) ? sexp_fileno_fd(arg0) : sexp_unbox_fixnum(arg0)), F_SETFD, sexp_sint_value(arg2));
  if (err) {
  res = SEXP_FALSE;
  } else {
  res = SEXP_TRUE;
  }
  return res;
}
コード例 #9
0
ファイル: filesystem.c プロジェクト: fmutant/scriptorium
static sexp sexp_create_directory_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1) {
  int err;
  sexp res;
  if (! sexp_stringp(arg0))
    return sexp_type_exception(ctx, self, SEXP_STRING, arg0);
  if (! sexp_exact_integerp(arg1))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg1);
  err = mkdir(sexp_string_data(arg0), sexp_sint_value(arg1));
  if (err) {
  res = SEXP_FALSE;
  } else {
  res = SEXP_TRUE;
  }
  return res;
}
コード例 #10
0
ファイル: filesystem.c プロジェクト: fmutant/scriptorium
static sexp sexp_fstat_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0) {
  int err;
  struct stat* tmp1;
  sexp res;
  sexp_gc_var1(res1);
  if (! sexp_exact_integerp(arg0))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg0);
  sexp_gc_preserve1(ctx, res1);
  tmp1 = (struct stat*) calloc(1, 1 + sizeof(tmp1[0]));
  err = fstat(sexp_sint_value(arg0), tmp1);
  if (err) {
  res = SEXP_FALSE;
  } else {
  res1 = sexp_make_cpointer(ctx, sexp_unbox_fixnum(sexp_opcode_arg2_type(self)), tmp1, SEXP_FALSE, 1);
  res = res1;
  }
  sexp_gc_release1(ctx);
  return res;
}
コード例 #11
0
ファイル: time.c プロジェクト: fmutant/scriptorium
static sexp sexp_seconds_3e_string_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0) {
  char *err;
  char tmp1[64];
  time_t tmp0;
  sexp res;
  sexp_gc_var1(res1);
  if (! sexp_exact_integerp(arg0))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg0);
  sexp_gc_preserve1(ctx, res1);
  tmp0 = sexp_unshift_epoch(sexp_uint_value(arg0));
  err = ctime_r(&tmp0, tmp1);
  if (!err) {
  res = SEXP_FALSE;
  } else {
  res1 = sexp_c_string(ctx, tmp1, -1);
  res = res1;
  }
  sexp_gc_release1(ctx);
  return res;
}
コード例 #12
0
ファイル: time.c プロジェクト: fmutant/scriptorium
static sexp sexp_seconds_3e_time_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0) {
  void *err;
  struct tm* tmp1;
  time_t tmp0;
  sexp res;
  sexp_gc_var1(res1);
  if (! sexp_exact_integerp(arg0))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg0);
  sexp_gc_preserve1(ctx, res1);
  tmp0 = sexp_unshift_epoch(sexp_uint_value(arg0));
  tmp1 = (struct tm*) calloc(1, 1 + sizeof(tmp1[0]));
  err = localtime_r(&tmp0, tmp1);
  if (!err) {
  res = SEXP_FALSE;
  } else {
  res1 = sexp_make_cpointer(ctx, sexp_unbox_fixnum(sexp_opcode_arg2_type(self)), tmp1, SEXP_FALSE, 1);
  res = res1;
  }
  sexp_gc_release1(ctx);
  return res;
}