2 Copyright (C) 2002-2009, Parrot Foundation.
3 License: Artistic 2.0, see README and LICENSE for details
8 src/datatypes.c - Parrot and native data types functions
12 The functions in this file are used in .ops files to access the C<enum>
13 and C string constants for Parrot and native data types defined in
14 F<include/parrot/datatypes.h>.
24 #include "parrot/parrot.h"
26 /* HEADERIZER HFILE: include/parrot/datatypes.h */
30 =item C<INTVAL Parrot_get_datatype_enum(PARROT_INTERP, const STRING *type_name)>
32 Return datatype C<enum> for C<STRING*> type_name.
39 PARROT_WARN_UNUSED_RESULT
41 Parrot_get_datatype_enum(PARROT_INTERP
, ARGIN(const STRING
*type_name
))
43 ASSERT_ARGS(Parrot_get_datatype_enum
)
44 char * const type
= Parrot_str_to_cstring(interp
, type_name
);
47 for (i
= enum_first_type
; i
< enum_last_type
; ++i
) {
48 if (STREQ(data_types
[i
- enum_first_type
].name
, type
)) {
49 Parrot_str_free_cstring(type
);
54 Parrot_str_free_cstring(type
);
56 return enum_type_undef
;
61 =item C<STRING * Parrot_get_datatype_name(PARROT_INTERP, INTVAL type)>
63 Return datatype name for C<type>.
70 PARROT_WARN_UNUSED_RESULT
71 PARROT_CANNOT_RETURN_NULL
73 Parrot_get_datatype_name(PARROT_INTERP
, INTVAL type
)
75 ASSERT_ARGS(Parrot_get_datatype_name
)
76 const char * const s
=
77 (type
< enum_first_type
|| type
>= enum_last_type
)
79 : data_types
[type
- enum_first_type
].name
;
81 return string_make(interp
, s
, strlen(s
), NULL
, PObj_external_FLAG
);
86 =item C<FLOATVAL floatval_divide_by_zero(PARROT_INTERP, FLOATVAL num)>
88 Only used to generate Infinity and NaN constants in our corresponding
97 floatval_divide_by_zero(SHIM_INTERP
, FLOATVAL num
)
99 ASSERT_ARGS(floatval_divide_by_zero
)
100 const FLOATVAL zero
= 0.0;
111 F<include/parrot/datatypes.h>.
120 * c-file-style: "parrot"
122 * vim: expandtab shiftwidth=4: