~ubuntu-branches/ubuntu/raring/parrot/raring-proposed

« back to all changes in this revision

Viewing changes to src/datatypes.c

  • Committer: Bazaar Package Importer
  • Author(s): Allison Randal
  • Date: 2011-07-30 18:45:03 UTC
  • mfrom: (1.1.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20110730184503-34d4mprtfx6pt5h3
Tags: 3.6.0-1
* New upstream release
* debian/watch:
  - Modified regular expression to capture numbered directory name
    (patch from Dominique Dumont).
* debian/rules:
  - Split build-arch and build-indep, resolving lintian warning.
  - Update path to pbc_disassemble for manpage generation (patch
    from Dominique Dumont).
* debian/patches:
  - Added patch 02_fix_perl_interpreter_path.patch, resolving
    lintian warnings.
* debian/control:
  - Added DM-Upload-Allowed field.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
/*
28
28
 
29
 
=item C<INTVAL Parrot_dt_get_datatype_enum(PARROT_INTERP, const STRING
30
 
*type_name)>
 
29
=item C<INTVAL Parrot_dt_get_datatype_enum(PARROT_INTERP, STRING *type_name)>
31
30
 
32
31
Return datatype C<enum> for C<STRING*> type_name.
33
32
 
38
37
PARROT_EXPORT
39
38
PARROT_WARN_UNUSED_RESULT
40
39
INTVAL
41
 
Parrot_dt_get_datatype_enum(PARROT_INTERP, ARGIN(const STRING *type_name))
 
40
Parrot_dt_get_datatype_enum(PARROT_INTERP, ARGIN(STRING *type_name))
42
41
{
43
42
    ASSERT_ARGS(Parrot_dt_get_datatype_enum)
44
 
    char * const type = Parrot_str_to_cstring(interp, type_name);
 
43
    char *type;
 
44
    int flags = 0;
45
45
    int i;
46
46
 
 
47
    if (STRING_IS_NULL(type_name) || STRING_IS_EMPTY(type_name))
 
48
        return enum_type_undef;
 
49
 
 
50
    if ('&' == Parrot_str_indexed(interp, type_name, Parrot_str_length(interp, type_name) - 1)) {
 
51
        type_name  = Parrot_str_substr(interp, type_name, 0,
 
52
                                        Parrot_str_length(interp, type_name) - 1);
 
53
        flags     |= enum_type_ref_flag;
 
54
    }
 
55
 
 
56
    type = Parrot_str_to_cstring(interp, type_name);
 
57
 
47
58
    for (i = enum_first_type; i < enum_last_type; ++i) {
48
59
        if (STREQ(data_types[i - enum_first_type].name, type)) {
49
60
            Parrot_str_free_cstring(type);
50
 
            return i;
 
61
            return i | flags;
51
62
        }
52
63
    }
53
64
 
73
84
Parrot_dt_get_datatype_name(PARROT_INTERP, INTVAL type)
74
85
{
75
86
    ASSERT_ARGS(Parrot_dt_get_datatype_name)
76
 
    const char * const s =
77
 
        (type < enum_first_type || type >= enum_last_type)
 
87
    const char *s;
 
88
    STRING *str;
 
89
 
 
90
    const int is_ref = type & enum_type_ref_flag;
 
91
 
 
92
    type &= ~enum_type_ref_flag;
 
93
 
 
94
    s = (type < enum_first_type || type >= enum_last_type)
78
95
            ? "illegal"
79
96
            : data_types[type - enum_first_type].name;
80
97
 
81
 
    return Parrot_str_new_init(interp, s, strlen(s),
 
98
    str = Parrot_str_new_init(interp, s, strlen(s),
82
99
            Parrot_default_encoding_ptr, PObj_external_FLAG);
 
100
 
 
101
    return is_ref ? Parrot_str_concat(interp, str, Parrot_str_new(interp, "&", 0)) : str;
83
102
}
84
103
 
85
104
/*