~ubuntu-branches/ubuntu/vivid/nqp/vivid

« back to all changes in this revision

Viewing changes to src/6model/sixmodelobject.h

  • Committer: Package Import Robot
  • Author(s): Alessandro Ghedini
  • Date: 2012-06-08 14:57:52 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120608145752-ziumy2rhxboeuf3r
Tags: 0.1~2012.04.1-1
* New upstream release
* Bump required parrot version
* Refresh patches
* Bump upstream copyright years for dyncall
* Use dh_parrot debhelper plugin

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
#define SIXMODELOBJECT_H_GUARD
6
6
 
7
7
#include "storage_spec.h"
 
8
#include "serialization.h"
8
9
 
9
10
/* The commonalities shared between all 6model objects, no matter what the
10
11
 * REPR is. This struct should be placed as the first thing in the object
69
70
/* S-Tables (short for Shared Table) contains the commonalities shared between
70
71
 * a (HOW, REPR) pairing (for example, (HOW for the class Dog, P6Opaque). */
71
72
typedef struct SixModel_REPROps REPROps;
72
 
typedef struct {
 
73
struct SixModel_STable {
73
74
    /* The representation operation table. */
74
75
    REPROps *REPR;
75
76
    
126
127
    
127
128
    /* The underlying package stash. */
128
129
    PMC *WHO;
 
130
    
 
131
    /* Serialization context that this s-table belongs to. */
 
132
    PMC *sc;
129
133
 
130
134
    /* Parrot-specific set of v-table to method mappings, for overriding
131
135
     * of Parrot v-table functions. */
136
140
    
137
141
    /* The PMC that wraps this s-table. */
138
142
    PMC *stable_pmc;
139
 
} STable;
 
143
};
140
144
 
141
145
/* A representation is what controls the layout of an object and access and
142
146
 * manipulation of the memory it manages. This includes attribute storage
291
295
     * thread safety requirements. */
292
296
    void (*change_type) (PARROT_INTERP, PMC *Object, PMC *NewType);
293
297
    
 
298
    /* Object serialization. Writes the objects body out using the passed
 
299
     * serialization writer. */
 
300
    void (*serialize) (PARROT_INTERP, STable *st, void *data, SerializationWriter *writer);
 
301
    
 
302
    /* Object deserialization. Reads the objects body in using the passed
 
303
     * serialization reader. */
 
304
    void (*deserialize) (PARROT_INTERP, STable *st, void *data, SerializationReader *reader);
 
305
    
 
306
    /* REPR data serialization. Seserializes the per-type representation data that
 
307
     * is attached to the supplied STable. */
 
308
    void (*serialize_repr_data) (PARROT_INTERP, STable *st, SerializationWriter *writer);
 
309
    
 
310
    /* REPR data deserialization. Deserializes the per-type representation data and
 
311
     * attaches it to the supplied STable. */
 
312
    void (*deserialize_repr_data) (PARROT_INTERP, STable *st, SerializationReader *reader);
 
313
    
294
314
    /* This Parrot-specific addition to the API is used to mark an object. */
295
315
    void (*gc_mark) (PARROT_INTERP, STable *st, void *data);
296
316
 
330
350
#define IS_CONCRETE(o)         (!PObj_flag_TEST(private0, (o)))
331
351
#define MARK_AS_TYPE_OBJECT(o) PObj_flag_SET(private0, (o))
332
352
 
 
353
/* Write barriers for noticing changes to objects or STables with an SC. */
 
354
typedef void (* obj_sc_barrier_func) (PARROT_INTERP, PMC *obj);
 
355
typedef void (* st_sc_barrier_func) (PARROT_INTERP, STable *st);
 
356
#define OBJ_SC_WRITE_BARRIER(o) \
 
357
    if (SC_PMC(o)) { \
 
358
        ((obj_sc_barrier_func) \
 
359
        D2FPTR(VTABLE_get_pointer(interp, \
 
360
            VTABLE_get_pmc_keyed_str(interp, interp->root_namespace, \
 
361
                Parrot_str_new_constant(interp, "_OBJ_SC_BARRIER")))))(interp, o); \
 
362
    }
 
363
#define ST_SC_WRITE_BARRIER(st) \
 
364
    if ((st)->sc) { \
 
365
        ((st_sc_barrier_func) \
 
366
        D2FPTR(VTABLE_get_pointer(interp, \
 
367
            VTABLE_get_pmc_keyed_str(interp, interp->root_namespace, \
 
368
                Parrot_str_new_constant(interp, "_ST_SC_BARRIER")))))(interp, st); \
 
369
    }
 
370
 
333
371
/* Object model initialization. */
334
372
void SixModelObject_initialize(PARROT_INTERP, PMC **knowhow, PMC **knowhow_attribute);
335
373
 
336
374
/* Some utility functions. */
 
375
void set_wrapping_object(PMC *wrapper);
337
376
PMC * wrap_object(PARROT_INTERP, void *obj);
338
377
PMC * create_stable(PARROT_INTERP, REPROps *REPR, PMC *HOW);
339
378
PMC * decontainerize(PARROT_INTERP, PMC *var);