Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update sixmodelobject.h.
  • Loading branch information
arnsholt committed Feb 2, 2013
1 parent 3b135f5 commit 80dc914
Showing 1 changed file with 31 additions and 21 deletions.
52 changes: 31 additions & 21 deletions src/binder/sixmodelobject.h
Expand Up @@ -42,6 +42,20 @@ typedef struct {
PMC * method;
} BoolificationSpec;

/* Defines and struct we use to access inlined members. */
#define NATIVE_VALUE_INT 1
#define NATIVE_VALUE_FLOAT 2
#define NATIVE_VALUE_STRING 3

typedef struct {
union {
INTVAL intval;
FLOATVAL floatval;
STRING *stringval;
} value;
INTVAL type;
} NativeValue;

/* Boolification mode flags. */
#define BOOL_MODE_CALL_METHOD 0
#define BOOL_MODE_UNBOX_INT 1
Expand Down Expand Up @@ -157,12 +171,12 @@ typedef struct SixModel_REPROps_Attribute {
PMC * (*get_attribute_boxed) (PARROT_INTERP, STable *st, void *data,
PMC *class_handle, STRING *name, INTVAL hint);

/* Gets a reference to the memory location of an attribute. Note
* that this is only valid so long as the object itself is alive. If
* bits is a non-NULL pointer, the pointed-to INTVAL will contain the
* bit-width of the attribute. */
void * (*get_attribute_ref) (PARROT_INTERP, STable *st, void *data,
PMC *class_handle, STRING *name, INTVAL *bits, INTVAL hint);
/* Fetch the value of the attribute into the value struct. The caller sets
* the type field of value to the type requested, and it's the caller's
* responsibility to make sure this is compatible with the stored
* attribute. */
void (*get_attribute_native) (PARROT_INTERP, STable *st, void *data,
PMC *class_handle, STRING *name, INTVAL hint, NativeValue *value);

/* Binds the given object value to the specified attribute. If it's
* a reference type attribute, this just simply sets the value in
Expand All @@ -171,12 +185,11 @@ typedef struct SixModel_REPROps_Attribute {
void (*bind_attribute_boxed) (PARROT_INTERP, STable *st, void *data,
PMC *class_handle, STRING *name, INTVAL hint, PMC *value);

/* Binds a flattened in attribute to the value at the passed reference.
* Like with the get_attribute_ref function, presumably the thing calling
* this knows about the type of the attribute it is supplying data for.
* copy_to will be used to copy the data in to place. */
void (*bind_attribute_ref) (PARROT_INTERP, STable *st, void *data,
PMC *class_handle, STRING *name, INTVAL hint, void *value);
/* Set the value of a flattened attribute. It is the caller's
* responsibility to set value to a type compatible with the type of the
* attribute being set. */
void (*bind_attribute_native) (PARROT_INTERP, STable *st, void *data,
PMC *class_handle, STRING *name, INTVAL hint, NativeValue *value);

/* Gets the hint for the given attribute ID. */
INTVAL (*hint_for) (PARROT_INTERP, STable *st, PMC *class_handle, STRING *name);
Expand Down Expand Up @@ -216,20 +229,17 @@ typedef struct SixModel_REPROps_Boxing {
void * (*get_boxed_ref) (PARROT_INTERP, STable *st, void *data, INTVAL repr_id);
} REPROps_Boxing;
typedef struct SixModel_REPROps_Indexing {
/* Get the address of the element at the specified position. May return null if
* nothing is there, or throw to indicate out of bounds, or vivify. If
* bits is a non-NULL pointer, the pointed-to INTVAL will contain the
* bit-width of the attribute. */
/*void * (*at_pos_ref) (PARROT_INTERP, STable *st, void *data, INTVAL index, INTVAL *bits);*/
void * (*at_pos_ref) (PARROT_INTERP, STable *st, void *data, INTVAL index);
/* Get a flattened native value, of the type specified in value->type. It
* is the caller's responsibility to make sure the stored data is of the
* appropriate type. May throw to indicate out of bounds, or vivify. */
void (*at_pos_native) (PARROT_INTERP, STable *st, void *data, INTVAL index, NativeValue *value);

/* Get a boxed object representing the element at the specified position. If the
* object is already a reference type, simply returns that. */
PMC * (*at_pos_boxed) (PARROT_INTERP, STable *st, void *data, INTVAL index);

/* Binds the value at the specified address into the array at the specified index.
* may auto-vivify or throw. */
void (*bind_pos_ref) (PARROT_INTERP, STable *st, void *data, INTVAL index, void *addr);
/* Sets the value at the specified index of the array. May auto-vivify or throw. */
void (*bind_pos_native) (PARROT_INTERP, STable *st, void *data, INTVAL index, NativeValue *value);

/* Binds the object at the specified address into the array at the specified index.
* For arrays of non-reference types, expects a compatible type. */
Expand Down

0 comments on commit 80dc914

Please sign in to comment.