* docs/pmc.pod:
[parrot.git] / src / datatypes.c
blob6fd5d9425137091817cdf4e854d18d0d5c1a20a4
1 /*
2 Copyright (C) 2002-2005, The Perl Foundation.
3 License: Artistic/GPL, see README and LICENSES for details
4 $Id$
6 =head1 NAME
8 src/datatypes.c - Parrot and native data types functions
10 =head1 DESCRIPTION
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>.
16 =head2 Functions
18 =over 4
20 =cut
24 #include "parrot/parrot.h"
28 =item C<INTVAL
29 Parrot_get_datatype_enum(Interp *interpreter, STRING *typename)>
31 Return datatype C<enum> for C<STRING*> typename.
33 =cut
37 INTVAL
38 Parrot_get_datatype_enum(Interp *interpreter, STRING *typename)
40 char *type = string_to_cstring(interpreter, typename);
41 int i;
43 for (i = enum_first_type; i < enum_last_type; i++) {
44 if (!strcmp(data_types[i - enum_first_type].name, type)) {
45 string_cstring_free(type);
46 return i;
50 string_cstring_free(type);
52 return enum_type_undef;
57 =item C<STRING *
58 Parrot_get_datatype_name(Interp *interpreter, INTVAL type)>
60 Return datatype name for C<type>.
62 =cut
66 STRING *
67 Parrot_get_datatype_name(Interp *interpreter, INTVAL type)
69 const char *s;
70 if (type < enum_first_type || type >= enum_last_type)
71 s = "illegal";
72 else
73 s = data_types[type - enum_first_type].name;
74 return string_make(interpreter, s, strlen(s), NULL, PObj_external_FLAG);
79 =back
81 =head1 SEE ALSO
83 F<include/parrot/datatypes.h>.
85 =cut
91 * Local variables:
92 * c-file-style: "parrot"
93 * End:
94 * vim: expandtab shiftwidth=4: