NAME ^

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

DESCRIPTION ^

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.

Functions ^

*/

#include "parrot/parrot.h"

/* HEADERIZER HFILE: include/parrot/datatypes.h */

/*

FUNCDOC: Parrot_get_datatype_enum Return datatype enum for STRING* type_name.

*/

PARROT_API PARROT_WARN_UNUSED_RESULT INTVAL Parrot_get_datatype_enum(PARROT_INTERP, NOTNULL(const STRING *type_name)) { 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 PARROT_WARN_UNUSED_RESULT PARROT_CANNOT_RETURN_NULL STRING * Parrot_get_datatype_name(PARROT_INTERP, INTVAL type) { 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);
}

/*

SEE ALSO ^

include/parrot/datatypes.h.

*/

/* * Local variables: * c-file-style: "parrot" * End: * vim: expandtab shiftwidth=4: */


parrot