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

« back to all changes in this revision

Viewing changes to src/6model/reprs/CArray.h

  • Committer: Package Import Robot
  • Author(s): Alessandro Ghedini
  • Date: 2013-11-01 12:09:18 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20131101120918-kx51sl0sxl3exsxi
Tags: 2013.10-1
* New upstream release
* Bump versioned (Build-)Depends on parrot
* Update patches
* Install new README.pod
* Fix vcs-field-not-canonical
* Do not install rubyish examples
* Do not Depends on parrot-devel anymore
* Add 07_disable-serialization-tests.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef CARRAY_H_GUARD
2
 
#define CARRAY_H_GUARD
3
 
 
4
 
/* Body of a CArray. */
5
 
typedef struct {
6
 
    /* The storage of C-land elements. */
7
 
    void *storage;
8
 
 
9
 
    /* The storage of Perl-land elements */
10
 
    PMC **child_objs;
11
 
 
12
 
    /* Are we managing the memory for this array ourselves, or does it come
13
 
     * from C? */
14
 
    INTVAL managed;
15
 
 
16
 
    /* The number of elements we've allocated. If we do not know,
17
 
     * because the array was returned to us from elsewhere and we
18
 
     * are not managing it's memory, this is 0. */
19
 
    INTVAL allocated;
20
 
 
21
 
    /* The number of elements we have, if known. Invalid if we
22
 
     * are not managing the array. */
23
 
    INTVAL elems;
24
 
} CArrayBody;
25
 
 
26
 
/* This is how an instance with the CArray representation looks. */
27
 
typedef struct {
28
 
    SixModelObjectCommonalities common;
29
 
    CArrayBody body;
30
 
} CArrayInstance;
31
 
 
32
 
/* What kind of element do we have? */
33
 
#define CARRAY_ELEM_KIND_NUMERIC    1
34
 
#define CARRAY_ELEM_KIND_STRING     2
35
 
#define CARRAY_ELEM_KIND_CPOINTER   3
36
 
#define CARRAY_ELEM_KIND_CARRAY     4
37
 
#define CARRAY_ELEM_KIND_CSTRUCT    5
38
 
 
39
 
/* The CArray REPR data contains a little info about the type of array
40
 
 * that we have. */
41
 
typedef struct {
42
 
    /* The number of bytes in size that an element is. */
43
 
    INTVAL elem_size;
44
 
 
45
 
    /* The type of an element. */
46
 
    PMC *elem_type;
47
 
    
48
 
    /* What kind of element is it (lets us quickly know how to handle access
49
 
     * to it). */
50
 
    INTVAL elem_kind;
51
 
} CArrayREPRData;
52
 
 
53
 
/* Initializes the CArray REPR. */
54
 
REPROps * CArray_initialize(PARROT_INTERP,
55
 
        PMC * (* wrap_object_func_ptr) (PARROT_INTERP, void *obj),
56
 
        PMC * (* create_stable_func_ptr) (PARROT_INTERP, REPROps *REPR, PMC *HOW));
57
 
 
58
 
#endif