| parrotcode: Parrot and native data types functions | |
| Contents | C |

src/datatypes.c - Parrot and native data types functions

The functions in this file are used in .ops files to access the enum and C string constants for Parrot and native data types defined in include/parrot/datatypes.h.

*/
#include "parrot/parrot.h"
/* HEADER: include/parrot/datatypes.h */
/*
FUNCDOC: Parrot_get_datatype_enum Return datatype enum for STRING* type_name.
*/
PARROT_API INTVAL Parrot_get_datatype_enum(Interp *interp, const STRING *type_name /*NN*/) /* PURE, WARN_UNUSED */ { char * const type = string_to_cstring(interp, type_name); int i;
for (i = enum_first_type; i < enum_last_type; i++) {
if (strcmp(data_types[i - enum_first_type].name, type) == 0) {
string_cstring_free(type);
return i;
}
}
string_cstring_free(type);
return enum_type_undef;
}
/*
FUNCDOC: Return datatype name for type.
*/
PARROT_API STRING * Parrot_get_datatype_name(Interp *interp, INTVAL type) /* WARN_UNUSED */ { const char * const s = (type < enum_first_type || type >= enum_last_type) ? "illegal" : data_types[type - enum_first_type].name;
return string_make(interp, s, strlen(s), NULL, PObj_external_FLAG);
}
/*

include/parrot/datatypes.h.
*/
/* * Local variables: * c-file-style: "parrot" * End: * vim: expandtab shiftwidth=4: */
|
|
|