/* ex: set ro ft=c:
 * !!!!!!!   DO NOT EDIT THIS FILE   !!!!!!!
 *
 * This file is generated automatically from './src/pmc/filehandle.pmc'
 * by tools/build/pmc2c.pl.
 *
 * Any changes made here will be lost!
 *
 */

/* HEADERIZER HFILE: none */
/* HEADERIZER STOP */


#ifndef PARROT_PMC_FILEHANDLE_H_GUARD
#define PARROT_PMC_FILEHANDLE_H_GUARD

PARROT_EXPORT VTABLE* Parrot_FileHandle_update_vtable(ARGMOD(VTABLE*));
PARROT_EXPORT VTABLE* Parrot_FileHandle_ro_update_vtable(ARGMOD(VTABLE*));
PARROT_EXPORT VTABLE* Parrot_FileHandle_get_vtable(PARROT_INTERP);
PARROT_EXPORT VTABLE* Parrot_FileHandle_ro_get_vtable(PARROT_INTERP);
PARROT_EXPORT PMC*    Parrot_FileHandle_get_mro(PARROT_INTERP, ARGMOD(PMC* mro));
PARROT_EXPORT Hash*   Parrot_FileHandle_get_isa(PARROT_INTERP, ARGMOD_NULLOK(Hash* isa));

/* FileHandle PMC's underlying struct. */
typedef struct Parrot_FileHandle_attributes {
    PIOHANDLE os_handle;
    INTVAL record_separator;
    INTVAL flags;
    STRING * filename;
    STRING * mode;
    STRING * encoding;
    INTVAL process_id;
    INTVAL exit_status;
    PIOOFF_T file_pos;
    PIOOFF_T last_pos;
    size_t buffer_size;
    INTVAL buffer_flags;
    unsigned char * buffer_start;
    unsigned char * buffer_end;
    unsigned char * buffer_next;
} Parrot_FileHandle_attributes;

/* Macro to access underlying structure of a FileHandle PMC. */
#define PARROT_FILEHANDLE(o) ((Parrot_FileHandle_attributes *) PMC_data(o))


/* Generated macro accessors for 'os_handle' attribute of FileHandle PMC. */
#define GETATTR_FileHandle_os_handle(interp, pmc, dest) \
    do { \
        if (!PObj_is_object_TEST(pmc)) { \
            (dest) = ((Parrot_FileHandle_attributes *)PMC_data(pmc))->os_handle; \
        } \
        else { \
            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION, \
                "Attributes of type 'PIOHANDLE' cannot be " \
                "subclassed from a high-level PMC."); \
        } \
    } while (0)

#define SETATTR_FileHandle_os_handle(interp, pmc, value) \
    do { \
        if (PObj_is_object_TEST(pmc)) { \
            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION, \
                "Attributes of type 'PIOHANDLE' cannot be " \
                "subclassed from a high-level PMC."); \
        } \
        else \
            ((Parrot_FileHandle_attributes *)PMC_data(pmc))->os_handle = (value); \
    } while (0)


/* Generated macro accessors for 'record_separator' attribute of FileHandle PMC. */
#define GETATTR_FileHandle_record_separator(interp, pmc, dest) \
    do { \
        if (!PObj_is_object_TEST(pmc)) { \
            (dest) = ((Parrot_FileHandle_attributes *)PMC_data(pmc))->record_separator; \
        } \
        else { \
            PMC * const attr_value = VTABLE_get_attr_str(interp, \
                              pmc, Parrot_str_new_constant(interp, "record_separator")); \
            (dest) = (PMC_IS_NULL(attr_value) ? (INTVAL) 0: VTABLE_get_integer(interp, attr_value)); \
        } \
    } while (0)

#define SETATTR_FileHandle_record_separator(interp, pmc, value) \
    do { \
        if (PObj_is_object_TEST(pmc)) { \
            PMC * const attr_value = Parrot_pmc_new_init_int(interp, enum_class_Integer, value); \
            VTABLE_set_attr_str(interp, pmc, \
                              Parrot_str_new_constant(interp, "record_separator"), attr_value); \
        } \
        else \
            ((Parrot_FileHandle_attributes *)PMC_data(pmc))->record_separator = (value); \
    } while (0)


/* Generated macro accessors for 'flags' attribute of FileHandle PMC. */
#define GETATTR_FileHandle_flags(interp, pmc, dest) \
    do { \
        if (!PObj_is_object_TEST(pmc)) { \
            (dest) = ((Parrot_FileHandle_attributes *)PMC_data(pmc))->flags; \
        } \
        else { \
            PMC * const attr_value = VTABLE_get_attr_str(interp, \
                              pmc, Parrot_str_new_constant(interp, "flags")); \
            (dest) = (PMC_IS_NULL(attr_value) ? (INTVAL) 0: VTABLE_get_integer(interp, attr_value)); \
        } \
    } while (0)

#define SETATTR_FileHandle_flags(interp, pmc, value) \
    do { \
        if (PObj_is_object_TEST(pmc)) { \
            PMC * const attr_value = Parrot_pmc_new_init_int(interp, enum_class_Integer, value); \
            VTABLE_set_attr_str(interp, pmc, \
                              Parrot_str_new_constant(interp, "flags"), attr_value); \
        } \
        else \
            ((Parrot_FileHandle_attributes *)PMC_data(pmc))->flags = (value); \
    } while (0)


/* Generated macro accessors for 'filename' attribute of FileHandle PMC. */
#define GETATTR_FileHandle_filename(interp, pmc, dest) \
    do { \
        if (!PObj_is_object_TEST(pmc)) { \
            (dest) = ((Parrot_FileHandle_attributes *)PMC_data(pmc))->filename; \
        } \
        else { \
            PMC * const attr_value = VTABLE_get_attr_str(interp, \
                              pmc, Parrot_str_new_constant(interp, "filename")); \
            (dest) =  (PMC_IS_NULL(attr_value) ? (STRING *)NULL : VTABLE_get_string(interp, attr_value)); \
        } \
    } while (0)

#define SETATTR_FileHandle_filename(interp, pmc, value) \
    do { \
        if (PObj_is_object_TEST(pmc)) { \
            PMC * const attr_value = Parrot_pmc_new(interp, enum_class_String); \
            VTABLE_set_string_native(interp, attr_value, value); \
            VTABLE_set_attr_str(interp, pmc, \
                              Parrot_str_new_constant(interp, "filename"), attr_value); \
        } \
        else \
            ((Parrot_FileHandle_attributes *)PMC_data(pmc))->filename = (value); \
    } while (0)


/* Generated macro accessors for 'mode' attribute of FileHandle PMC. */
#define GETATTR_FileHandle_mode(interp, pmc, dest) \
    do { \
        if (!PObj_is_object_TEST(pmc)) { \
            (dest) = ((Parrot_FileHandle_attributes *)PMC_data(pmc))->mode; \
        } \
        else { \
            PMC * const attr_value = VTABLE_get_attr_str(interp, \
                              pmc, Parrot_str_new_constant(interp, "mode")); \
            (dest) =  (PMC_IS_NULL(attr_value) ? (STRING *)NULL : VTABLE_get_string(interp, attr_value)); \
        } \
    } while (0)

#define SETATTR_FileHandle_mode(interp, pmc, value) \
    do { \
        if (PObj_is_object_TEST(pmc)) { \
            PMC * const attr_value = Parrot_pmc_new(interp, enum_class_String); \
            VTABLE_set_string_native(interp, attr_value, value); \
            VTABLE_set_attr_str(interp, pmc, \
                              Parrot_str_new_constant(interp, "mode"), attr_value); \
        } \
        else \
            ((Parrot_FileHandle_attributes *)PMC_data(pmc))->mode = (value); \
    } while (0)


/* Generated macro accessors for 'encoding' attribute of FileHandle PMC. */
#define GETATTR_FileHandle_encoding(interp, pmc, dest) \
    do { \
        if (!PObj_is_object_TEST(pmc)) { \
            (dest) = ((Parrot_FileHandle_attributes *)PMC_data(pmc))->encoding; \
        } \
        else { \
            PMC * const attr_value = VTABLE_get_attr_str(interp, \
                              pmc, Parrot_str_new_constant(interp, "encoding")); \
            (dest) =  (PMC_IS_NULL(attr_value) ? (STRING *)NULL : VTABLE_get_string(interp, attr_value)); \
        } \
    } while (0)

#define SETATTR_FileHandle_encoding(interp, pmc, value) \
    do { \
        if (PObj_is_object_TEST(pmc)) { \
            PMC * const attr_value = Parrot_pmc_new(interp, enum_class_String); \
            VTABLE_set_string_native(interp, attr_value, value); \
            VTABLE_set_attr_str(interp, pmc, \
                              Parrot_str_new_constant(interp, "encoding"), attr_value); \
        } \
        else \
            ((Parrot_FileHandle_attributes *)PMC_data(pmc))->encoding = (value); \
    } while (0)


/* Generated macro accessors for 'process_id' attribute of FileHandle PMC. */
#define GETATTR_FileHandle_process_id(interp, pmc, dest) \
    do { \
        if (!PObj_is_object_TEST(pmc)) { \
            (dest) = ((Parrot_FileHandle_attributes *)PMC_data(pmc))->process_id; \
        } \
        else { \
            PMC * const attr_value = VTABLE_get_attr_str(interp, \
                              pmc, Parrot_str_new_constant(interp, "process_id")); \
            (dest) = (PMC_IS_NULL(attr_value) ? (INTVAL) 0: VTABLE_get_integer(interp, attr_value)); \
        } \
    } while (0)

#define SETATTR_FileHandle_process_id(interp, pmc, value) \
    do { \
        if (PObj_is_object_TEST(pmc)) { \
            PMC * const attr_value = Parrot_pmc_new_init_int(interp, enum_class_Integer, value); \
            VTABLE_set_attr_str(interp, pmc, \
                              Parrot_str_new_constant(interp, "process_id"), attr_value); \
        } \
        else \
            ((Parrot_FileHandle_attributes *)PMC_data(pmc))->process_id = (value); \
    } while (0)


/* Generated macro accessors for 'exit_status' attribute of FileHandle PMC. */
#define GETATTR_FileHandle_exit_status(interp, pmc, dest) \
    do { \
        if (!PObj_is_object_TEST(pmc)) { \
            (dest) = ((Parrot_FileHandle_attributes *)PMC_data(pmc))->exit_status; \
        } \
        else { \
            PMC * const attr_value = VTABLE_get_attr_str(interp, \
                              pmc, Parrot_str_new_constant(interp, "exit_status")); \
            (dest) = (PMC_IS_NULL(attr_value) ? (INTVAL) 0: VTABLE_get_integer(interp, attr_value)); \
        } \
    } while (0)

#define SETATTR_FileHandle_exit_status(interp, pmc, value) \
    do { \
        if (PObj_is_object_TEST(pmc)) { \
            PMC * const attr_value = Parrot_pmc_new_init_int(interp, enum_class_Integer, value); \
            VTABLE_set_attr_str(interp, pmc, \
                              Parrot_str_new_constant(interp, "exit_status"), attr_value); \
        } \
        else \
            ((Parrot_FileHandle_attributes *)PMC_data(pmc))->exit_status = (value); \
    } while (0)


/* Generated macro accessors for 'file_pos' attribute of FileHandle PMC. */
#define GETATTR_FileHandle_file_pos(interp, pmc, dest) \
    do { \
        if (!PObj_is_object_TEST(pmc)) { \
            (dest) = ((Parrot_FileHandle_attributes *)PMC_data(pmc))->file_pos; \
        } \
        else { \
            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION, \
                "Attributes of type 'PIOOFF_T' cannot be " \
                "subclassed from a high-level PMC."); \
        } \
    } while (0)

#define SETATTR_FileHandle_file_pos(interp, pmc, value) \
    do { \
        if (PObj_is_object_TEST(pmc)) { \
            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION, \
                "Attributes of type 'PIOOFF_T' cannot be " \
                "subclassed from a high-level PMC."); \
        } \
        else \
            ((Parrot_FileHandle_attributes *)PMC_data(pmc))->file_pos = (value); \
    } while (0)


/* Generated macro accessors for 'last_pos' attribute of FileHandle PMC. */
#define GETATTR_FileHandle_last_pos(interp, pmc, dest) \
    do { \
        if (!PObj_is_object_TEST(pmc)) { \
            (dest) = ((Parrot_FileHandle_attributes *)PMC_data(pmc))->last_pos; \
        } \
        else { \
            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION, \
                "Attributes of type 'PIOOFF_T' cannot be " \
                "subclassed from a high-level PMC."); \
        } \
    } while (0)

#define SETATTR_FileHandle_last_pos(interp, pmc, value) \
    do { \
        if (PObj_is_object_TEST(pmc)) { \
            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION, \
                "Attributes of type 'PIOOFF_T' cannot be " \
                "subclassed from a high-level PMC."); \
        } \
        else \
            ((Parrot_FileHandle_attributes *)PMC_data(pmc))->last_pos = (value); \
    } while (0)


/* Generated macro accessors for 'buffer_size' attribute of FileHandle PMC. */
#define GETATTR_FileHandle_buffer_size(interp, pmc, dest) \
    do { \
        if (!PObj_is_object_TEST(pmc)) { \
            (dest) = ((Parrot_FileHandle_attributes *)PMC_data(pmc))->buffer_size; \
        } \
        else { \
            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION, \
                "Attributes of type 'size_t' cannot be " \
                "subclassed from a high-level PMC."); \
        } \
    } while (0)

#define SETATTR_FileHandle_buffer_size(interp, pmc, value) \
    do { \
        if (PObj_is_object_TEST(pmc)) { \
            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION, \
                "Attributes of type 'size_t' cannot be " \
                "subclassed from a high-level PMC."); \
        } \
        else \
            ((Parrot_FileHandle_attributes *)PMC_data(pmc))->buffer_size = (value); \
    } while (0)


/* Generated macro accessors for 'buffer_flags' attribute of FileHandle PMC. */
#define GETATTR_FileHandle_buffer_flags(interp, pmc, dest) \
    do { \
        if (!PObj_is_object_TEST(pmc)) { \
            (dest) = ((Parrot_FileHandle_attributes *)PMC_data(pmc))->buffer_flags; \
        } \
        else { \
            PMC * const attr_value = VTABLE_get_attr_str(interp, \
                              pmc, Parrot_str_new_constant(interp, "buffer_flags")); \
            (dest) = (PMC_IS_NULL(attr_value) ? (INTVAL) 0: VTABLE_get_integer(interp, attr_value)); \
        } \
    } while (0)

#define SETATTR_FileHandle_buffer_flags(interp, pmc, value) \
    do { \
        if (PObj_is_object_TEST(pmc)) { \
            PMC * const attr_value = Parrot_pmc_new_init_int(interp, enum_class_Integer, value); \
            VTABLE_set_attr_str(interp, pmc, \
                              Parrot_str_new_constant(interp, "buffer_flags"), attr_value); \
        } \
        else \
            ((Parrot_FileHandle_attributes *)PMC_data(pmc))->buffer_flags = (value); \
    } while (0)


/* Generated macro accessors for 'buffer_start' attribute of FileHandle PMC. */
#define GETATTR_FileHandle_buffer_start(interp, pmc, dest) \
    do { \
        if (!PObj_is_object_TEST(pmc)) { \
            (dest) = ((Parrot_FileHandle_attributes *)PMC_data(pmc))->buffer_start; \
        } \
        else { \
            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION, \
                "Attributes of type 'unsigned char *' cannot be " \
                "subclassed from a high-level PMC."); \
        } \
    } while (0)

#define SETATTR_FileHandle_buffer_start(interp, pmc, value) \
    do { \
        if (PObj_is_object_TEST(pmc)) { \
            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION, \
                "Attributes of type 'unsigned char *' cannot be " \
                "subclassed from a high-level PMC."); \
        } \
        else \
            ((Parrot_FileHandle_attributes *)PMC_data(pmc))->buffer_start = (value); \
    } while (0)


/* Generated macro accessors for 'buffer_end' attribute of FileHandle PMC. */
#define GETATTR_FileHandle_buffer_end(interp, pmc, dest) \
    do { \
        if (!PObj_is_object_TEST(pmc)) { \
            (dest) = ((Parrot_FileHandle_attributes *)PMC_data(pmc))->buffer_end; \
        } \
        else { \
            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION, \
                "Attributes of type 'unsigned char *' cannot be " \
                "subclassed from a high-level PMC."); \
        } \
    } while (0)

#define SETATTR_FileHandle_buffer_end(interp, pmc, value) \
    do { \
        if (PObj_is_object_TEST(pmc)) { \
            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION, \
                "Attributes of type 'unsigned char *' cannot be " \
                "subclassed from a high-level PMC."); \
        } \
        else \
            ((Parrot_FileHandle_attributes *)PMC_data(pmc))->buffer_end = (value); \
    } while (0)


/* Generated macro accessors for 'buffer_next' attribute of FileHandle PMC. */
#define GETATTR_FileHandle_buffer_next(interp, pmc, dest) \
    do { \
        if (!PObj_is_object_TEST(pmc)) { \
            (dest) = ((Parrot_FileHandle_attributes *)PMC_data(pmc))->buffer_next; \
        } \
        else { \
            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION, \
                "Attributes of type 'unsigned char *' cannot be " \
                "subclassed from a high-level PMC."); \
        } \
    } while (0)

#define SETATTR_FileHandle_buffer_next(interp, pmc, value) \
    do { \
        if (PObj_is_object_TEST(pmc)) { \
            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION, \
                "Attributes of type 'unsigned char *' cannot be " \
                "subclassed from a high-level PMC."); \
        } \
        else \
            ((Parrot_FileHandle_attributes *)PMC_data(pmc))->buffer_next = (value); \
    } while (0)


#endif /* PARROT_PMC_FILEHANDLE_H_GUARD */

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

