Esempio n. 1
0
gpy_object_t * gpy_obj_string_new (gpy_typedef_t * type,
				   gpy_object_t ** args)
{
  gpy_object_t * retval = NULL_OBJECT;

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

  char * string = gpy_args_lit_parse_string (args [0]);
  struct gpy_object_string * self = (struct gpy_object_string *)
    gpy_malloc (sizeof (struct gpy_object_string));
  self->string = gpy_strdup (string);

  retval = gpy_create_object_state (type, self);

  return retval;
}
Esempio n. 2
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;
}