3 * Copyright (C) 2002-2008, Parrot Foundation.
4 * License: Artistic 2.0, see README and LICENSE for details
8 * Parrot and native data types enums and type names.
11 * Changing types here might break some tests.
12 * Though appending a type and a name should be safe.
15 #ifndef PARROT_DATATYPES_H_GUARD
16 #define PARROT_DATATYPES_H_GUARD
18 /* &gen_from_enum(datatypes.pasm) subst(s/enum_type_(\w+)/uc("DATATYPE_$1")/e) */
20 enum_type_undef
, /* illegal */
21 enum_first_type
= -100,
23 enum_type_INTVAL
= -100, /* parrot types */
26 enum_type_PMC
, /* actual PMCs have positive class numbers */
30 enum_type_char
, /* native integer types */
36 enum_type_uchar
, /* native unsigned types */
42 enum_type_float
, /* native float types */
46 enum_type_bit
, /* fixed size types */
47 enum_type_int1
= enum_type_bit
,
54 enum_type_uint8
, /* unsigned variants */
59 enum_type_ptr
, /* native pointer */
60 enum_type_cstr
, /* c string */
61 enum_type_struct_ptr
, /* pointer to another struct */
62 enum_type_struct
, /* a nested struct */
63 enum_type_func_ptr
, /* a function pointer */
65 enum_type_sized
, /* arbitrary size type for list_new */
66 enum_last_type
/* + one */
72 PARROT_OBSERVER
const char *name
;
76 extern const struct _data_types data_types
[];
77 #if defined(INSIDE_GLOBAL_SETUP)
78 const struct _data_types data_types
[] = {
79 { "INTVAL", INTVAL_SIZE
}, /* parrot types */
80 { "FLOATVAL", NUMVAL_SIZE
},
81 { "STRING", sizeof (void *) },
82 { "PMC", sizeof (void *) }, /* actual PMCs have positive class numbers */
83 { "BIGINT", sizeof (void *) },
84 { "DPOINTER", sizeof (void *) },
86 { "char", sizeof (char) }, /* native integer types */
87 { "short", sizeof (short) },
88 { "int", sizeof (int) },
89 { "long", sizeof (long) },
90 { "longlong", 0 }, /* TODO */
92 { "uchar", sizeof (char) }, /* native unsigned types */
93 { "ushort", sizeof (short)},
94 { "uint", sizeof (int) },
95 { "ulong", sizeof (long) },
96 { "ulonglong", 0 }, /* TODO */
98 { "float", sizeof (float) }, /* native float types */
99 { "double", sizeof (double) },
100 { "longdouble", 0 }, /* TODO */
102 { "int1", 0 }, /* = bit */
109 { "uint8", 1 }, /* unsigned variants */
114 { "ptr", sizeof (void*) },
115 { "cstr", sizeof (char *) },
116 { "struct_ptr", sizeof (void*) },
118 { "func_ptr", sizeof (void (*)(void)) },
124 #endif /* INSIDE_GLOBAL_SETUP */
126 #if defined(__NetBSD__) && defined(__alpha__)
128 # define PARROT_FLOATVAL_INF_POSITIVE INFINITY
129 # define PARROT_FLOATVAL_INF_NEGATIVE -INFINITY
130 # define PARROT_FLOATVAL_NAN_QUIET NAN
132 # define PARROT_FLOATVAL_INF_POSITIVE floatval_divide_by_zero(interp, 1.0)
133 # define PARROT_FLOATVAL_INF_NEGATIVE floatval_divide_by_zero(interp, -1.0)
134 # define PARROT_FLOATVAL_NAN_QUIET floatval_divide_by_zero(interp, 0.0)
137 #define PARROT_CSTRING_INF_POSITIVE "Inf"
138 #define PARROT_CSTRING_INF_NEGATIVE "-Inf"
139 #define PARROT_CSTRING_NAN_QUIET "NaN"
142 /* HEADERIZER BEGIN: src/datatypes.c */
143 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
146 FLOATVAL
floatval_divide_by_zero(SHIM_INTERP
, FLOATVAL num
);
149 PARROT_WARN_UNUSED_RESULT
150 INTVAL
Parrot_get_datatype_enum(PARROT_INTERP
,
151 ARGIN(const STRING
*type_name
))
152 __attribute__nonnull__(1)
153 __attribute__nonnull__(2);
156 PARROT_WARN_UNUSED_RESULT
157 PARROT_CANNOT_RETURN_NULL
158 STRING
* Parrot_get_datatype_name(PARROT_INTERP
, INTVAL type
)
159 __attribute__nonnull__(1);
161 #define ASSERT_ARGS_floatval_divide_by_zero __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
162 #define ASSERT_ARGS_Parrot_get_datatype_enum __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
163 PARROT_ASSERT_ARG(interp) \
164 , PARROT_ASSERT_ARG(type_name))
165 #define ASSERT_ARGS_Parrot_get_datatype_name __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
166 PARROT_ASSERT_ARG(interp))
167 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
168 /* HEADERIZER END: src/datatypes.c */
170 #endif /* PARROT_DATATYPES_H_GUARD */
174 * c-file-style: "parrot"
176 * vim: expandtab shiftwidth=4: