add svn:ignore (*.str)
[parrot.git] / include / parrot / datatypes.h
blobcdb93417c1a35e3ed999b3534371e76fbf80ca4a
1 /*
2 * datatypes.h
3 * Copyright (C) 2002-2008, Parrot Foundation.
4 * License: Artistic 2.0, see README and LICENSE for details
5 * SVN Info
6 * $Id$
7 * Overview:
8 * Parrot and native data types enums and type names.
10 * Caveat:
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) */
19 typedef enum {
20 enum_type_undef, /* illegal */
21 enum_first_type = -100,
23 enum_type_INTVAL = -100, /* parrot types */
24 enum_type_FLOATVAL,
25 enum_type_STRING,
26 enum_type_PMC, /* actual PMCs have positive class numbers */
27 enum_type_BIGINT,
28 enum_type_DPOINTER,
30 enum_type_char, /* native integer types */
31 enum_type_short,
32 enum_type_int,
33 enum_type_long,
34 enum_type_longlong,
36 enum_type_uchar, /* native unsigned types */
37 enum_type_ushort,
38 enum_type_uint,
39 enum_type_ulong,
40 enum_type_ulonglong,
42 enum_type_float, /* native float types */
43 enum_type_double,
44 enum_type_longdouble,
46 enum_type_bit, /* fixed size types */
47 enum_type_int1 = enum_type_bit,
48 enum_type_int4,
49 enum_type_int8,
50 enum_type_int16,
51 enum_type_int32,
52 enum_type_int64,
54 enum_type_uint8, /* unsigned variants */
55 enum_type_uint16,
56 enum_type_uint32,
57 enum_type_uint64,
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 */
68 } PARROT_DATA_TYPE;
70 /* &end_gen */
71 struct _data_types {
72 PARROT_OBSERVER const char *name;
73 int size;
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 */
103 { "int4", 0 },
104 { "int8", 1 },
105 { "int16", 2 },
106 { "int32", 4 },
107 { "int64", 8 },
109 { "uint8", 1 }, /* unsigned variants */
110 { "uint16", 2 },
111 { "uint32", 4 },
112 { "uint64", 8 },
114 { "ptr", sizeof (void*) },
115 { "cstr", sizeof (char *) },
116 { "struct_ptr", sizeof (void*) },
117 { "struct", 0 },
118 { "func_ptr", sizeof (void (*)(void)) },
120 { "sized", 0 },
122 { "illegal", 0 }
124 #endif /* INSIDE_GLOBAL_SETUP */
126 #if defined(__NetBSD__) && defined(__alpha__)
127 # include <math.h>
128 # define PARROT_FLOATVAL_INF_POSITIVE INFINITY
129 # define PARROT_FLOATVAL_INF_NEGATIVE -INFINITY
130 # define PARROT_FLOATVAL_NAN_QUIET NAN
131 #else
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)
135 #endif
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. */
145 PARROT_EXPORT
146 FLOATVAL floatval_divide_by_zero(SHIM_INTERP, FLOATVAL num);
148 PARROT_EXPORT
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);
155 PARROT_EXPORT
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 */
173 * Local variables:
174 * c-file-style: "parrot"
175 * End:
176 * vim: expandtab shiftwidth=4: