Exemplo n.º 1
0
gpy_object_t * gpy_obj_list_new (gpy_typedef_t * type,
				 gpy_object_t ** args)
{
  gpy_object_t * retval = NULL_OBJECT;

  bool check = gpy_args_check_fmt (args, "i,V.");
  gpy_assert (check);

  int len = gpy_args_lit_parse_int (args [0]);
  gpy_object_t ** vec = gpy_args_lit_parse_vec (args [1]);

  struct gpy_object_list * self = (struct gpy_object_list *)
    gpy_malloc (sizeof (struct gpy_object_list));

  int size = gpy_threshold_alloc (len);
  self->vector = (gpy_object_t **)
    gpy_calloc (size, sizeof (gpy_object_t *));

  self->length = len;
  self->size = size;

  int i;
  for (i = 0; i < len; ++i)
    self->vector[i] = vec [i];
  retval = gpy_create_object_state (type, self);

  return retval;
}
Exemplo n.º 2
0
gpy_object_t * gpy_obj_integer_new (gpy_typedef_t * type,
				    gpy_object_t * args)
{
  gpy_object_t * retval = NULL_OBJECT;

  bool check = gpy_args_check_fmt (args, "i.");
  gpy_assert (check);

  int val = gpy_args_lit_parse_int (&args[0]);
  struct gpy_obj_integer_t * self = (struct gpy_obj_integer_t *)
    gpy_malloc (sizeof (struct gpy_obj_integer_t));
  self->Int = val;

  retval = gpy_create_object_state (type, self);
  return retval;
}
Exemplo n.º 3
0
/* args = code addr/nargs */
gpy_object_t * gpy_object_func_new (gpy_typedef_t * type,
				    gpy_object_t * args)
{
  gpy_object_t * retval = NULL_OBJECT;

  bool check = gpy_args_check_fmt (args, "s,p,i.");
  gpy_assert (check);

  char * id = gpy_args_lit_parse_string (&args[0]);
  unsigned char * code_addr = gpy_args_lit_parse_pointer (&args[1]);
  int nargs = gpy_args_lit_parse_int (&args[2]);

  struct gpy_object_func_t * self = gpy_malloc (type->state_size);
  self->identifier = id;
  self->code = (GPY_CFUNC) code_addr;
  self->nargs = nargs;

  retval = gpy_create_object_decl (type, self);

  return retval;
}