예제 #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
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;
}
예제 #3
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;
}
예제 #4
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;
}
예제 #5
0
파일: time.c 프로젝트: fmutant/scriptorium
static sexp sexp_make_timeval_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1) {
  struct timeval* r;
  sexp_gc_var1(res);
  sexp_gc_preserve1(ctx, res);
  res = sexp_alloc_tagged(ctx, sexp_sizeof(cpointer), sexp_unbox_fixnum(sexp_opcode_return_type(self)));
  sexp_cpointer_value(res) = calloc(1, sizeof(struct timeval));
  r = (struct timeval*) sexp_cpointer_value(res);
  memset(r, 0, sizeof(struct timeval));
  sexp_freep(res) = 1;
  r->tv_sec = sexp_unshift_epoch(sexp_uint_value(arg0));
  r->tv_usec = sexp_sint_value(arg1);
  sexp_gc_release1(ctx);
  return res;
}
예제 #6
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;
}
예제 #7
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;
}
예제 #8
0
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;
}