text: /* This is the implementation of the P6num representation, which holds a native
   * floating point number. */
  
  #define PARROT_IN_EXTENSION
  #include "parrot/parrot.h"
  #include "parrot/extend.h"
  #include "../sixmodelobject.h"
  #include "P6num.h"
  
  /* This representation's function pointer table. */
  static REPROps *this_repr;
  
  /* Creates a new type object of this representation, and associates it with
   * the given HOW. */
  static PMC * type_object_for(PARROT_INTERP, PMC *HOW) {
      /* Create new object instance. */
      P6numInstance *obj = mem_allocate_zeroed_typed(P6numInstance);
  
      /* Build an STable. */
      PMC *st_pmc = create_stable(interp, this_repr, HOW);
      STable *st  = STABLE_STRUCT(st_pmc);
  
      /* Create type object and point it back at the STable. */
      obj->common.stable = st_pmc;
      st->WHAT = wrap_object(interp, obj);
      PARROT_GC_WRITE_BARRIER(interp, st_pmc);
  
      /* Flag it as a type object. */
      MARK_AS_TYPE_OBJECT(st->WHAT);
  
      return st->WHAT;
  }
  
  /* Creates a new instance based on the type object. */
  static PMC * allocate(PARROT_INTERP, STable *st) {
      P6numInstance *obj = mem_allocate_zeroed_typed(P6numInstance);
      obj->common.stable = st->stable_pmc;
      return wrap_object(interp, obj);
  }
  
  /* Initialize a new instance. */
  static void initialize(PARROT_INTERP, STable *st, void *data) {
      double x = 0.0;
      ((P6numBody *)data)->value = 0.0/x;
  }
  
  /* Copies to the body of one object to another. */
  static void copy_to(PARROT_INTERP, STable *st, void *src, void *dest) {
      *((FLOATVAL *)dest) = *((FLOATVAL *)src);
  }
  
  /* Used with boxing. Sets an integer value, for representations that can hold
   * one. */
  static void set_int(PARROT_INTERP, STable *st, void *data, INTVAL value) {
      Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
              "P6num cannot box a native int");
  }
  
  /* Used with boxing. Gets an integer value, for representations that can
   * hold one. */
  static INTVAL get_int(PARROT_INTERP, STable *st, void *data) {
      Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
              "P6num cannot unbox to a native int");
  }
  
  /* Used with boxing. Sets a floating point value, for representations that can
   * hold one. */
  static void set_num(PARROT_INTERP, STable *st, void *data, FLOATVAL value) {
      ((P6numBody *)data)->value = value;
  }
  
  /* Used with boxing. Gets a floating point value, for representations that can
   * hold one. */
  static FLOATVAL get_num(PARROT_INTERP, STable *st, void *data) {
      return ((P6numBody *)data)->value;
  }
  
  /* Used with boxing. Sets a string value, for representations that can hold
   * one. */
  static void set_str(PARROT_INTERP, STable *st, void *data, STRING *value) {
      Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
              "P6num cannot box a native string");
  }
  
  /* Used with boxing. Gets a string value, for representations that can hold
   * one. */
  static STRING * get_str(PARROT_INTERP, STable *st, void *data) {
      Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
              "P6num cannot unbox to a native string");
  }
  
  /* Some objects serve primarily as boxes of others, inlining them. This gets
   * gets the reference to such things, using the representation ID to distinguish
   * them. */
  static void * get_boxed_ref(PARROT_INTERP, STable *st, void *data, INTVAL repr_id) {
      Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
              "P6num cannot box other types");
  }
  
  /* This Parrot-specific addition to the API is used to free an object. */
  static void gc_free(PARROT_INTERP, PMC *obj) {
      mem_sys_free(PMC_data(obj));
      PMC_data(obj) = NULL;
  }
  
  /* Gets the storage specification for this representation. */
  static storage_spec get_storage_spec(PARROT_INTERP, STable *st) {
      storage_spec spec;
      spec.inlineable = STORAGE_SPEC_INLINED;
      spec.bits = sizeof(FLOATVAL) * 8;
      spec.boxed_primitive = STORAGE_SPEC_BP_NUM;
      spec.can_box = STORAGE_SPEC_CAN_BOX_NUM;
      return spec;
  }
  
  /* Initializes the P6num representation. */
  REPROps * P6num_initialize(PARROT_INTERP) {
      /* Allocate and populate the representation function table. */
      this_repr = mem_allocate_zeroed_typed(REPROps);
      this_repr->type_object_for = type_object_for;
      this_repr->allocate = allocate;
      this_repr->initialize = initialize;
      this_repr->copy_to = copy_to;
      this_repr->box_funcs = mem_allocate_typed(REPROps_Boxing);
      this_repr->box_funcs->set_int = set_int;
      this_repr->box_funcs->get_int = get_int;
      this_repr->box_funcs->set_num = set_num;
      this_repr->box_funcs->get_num = get_num;
      this_repr->box_funcs->set_str = set_str;
      this_repr->box_funcs->get_str = get_str;
      this_repr->box_funcs->get_boxed_ref = get_boxed_ref;
      this_repr->gc_free = gc_free;
      this_repr->get_storage_spec = get_storage_spec;
      return this_repr;
  }
  