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

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


#ifndef PARROT_PMC_SOCKET_H_GUARD
#define PARROT_PMC_SOCKET_H_GUARD

PARROT_EXPORT VTABLE* Parrot_Socket_update_vtable(ARGMOD(VTABLE*));
PARROT_EXPORT VTABLE* Parrot_Socket_ro_update_vtable(ARGMOD(VTABLE*));
PARROT_EXPORT VTABLE* Parrot_Socket_get_vtable(PARROT_INTERP);
PARROT_EXPORT VTABLE* Parrot_Socket_ro_get_vtable(PARROT_INTERP);
PARROT_EXPORT PMC*    Parrot_Socket_get_mro(PARROT_INTERP, ARGMOD(PMC* mro));
PARROT_EXPORT Hash*   Parrot_Socket_get_isa(PARROT_INTERP, ARGMOD_NULLOK(Hash* isa));

/* Socket PMC's underlying struct. */
typedef struct Parrot_Socket_attributes {
    PIOHANDLE os_handle;
    STRING    * record_separator;
    IO_VTABLE * io_vtable;
    IO_BUFFER * read_buffer;
    IO_BUFFER * write_buffer;
    STRING    * encoding;
    PMC * local;
    PMC * remote;
    INTVAL family;
    INTVAL type;
    INTVAL protocol;
} Parrot_Socket_attributes;

/* Macro to access underlying structure of a Socket PMC. */
#define PARROT_SOCKET(o) ((Parrot_Socket_attributes *) PMC_data(o))


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


/* Generated macro accessors for 'record_separator' attribute of Socket PMC. */
#define GETATTR_Socket_record_separator(interp, pmc, dest) \
    do { \
        if (!PObj_is_object_TEST(pmc)) { \
            (dest) = ((Parrot_Socket_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) ? (STRING *)NULL : VTABLE_get_string(interp, attr_value)); \
        } \
    } while (0)
#define SETATTR_Socket_record_separator(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, "record_separator"), attr_value); \
        } \
        else \
            ((Parrot_Socket_attributes *)PMC_data(pmc))->record_separator = (value); \
    } while (0)


/* Generated macro accessors for 'io_vtable' attribute of Socket PMC. */
#define GETATTR_Socket_io_vtable(interp, pmc, dest) \
    do { \
        if (!PObj_is_object_TEST(pmc)) { \
            (dest) = ((Parrot_Socket_attributes *)PMC_data(pmc))->io_vtable; \
        } \
        else { \
            Parrot_ex_throw_from_c_noargs(interp, EXCEPTION_INVALID_OPERATION, \
                "Attributes of type 'IO_VTABLE *' cannot be " \
                "subclassed from a high-level PMC."); \
        } \
    } while (0)
#define SETATTR_Socket_io_vtable(interp, pmc, value) \
    do { \
        if (PObj_is_object_TEST(pmc)) { \
            Parrot_ex_throw_from_c_noargs(interp, EXCEPTION_INVALID_OPERATION, \
                "Attributes of type 'IO_VTABLE *' cannot be " \
                "subclassed from a high-level PMC."); \
        } \
        else \
            ((Parrot_Socket_attributes *)PMC_data(pmc))->io_vtable = (value); \
    } while (0)


/* Generated macro accessors for 'read_buffer' attribute of Socket PMC. */
#define GETATTR_Socket_read_buffer(interp, pmc, dest) \
    do { \
        if (!PObj_is_object_TEST(pmc)) { \
            (dest) = ((Parrot_Socket_attributes *)PMC_data(pmc))->read_buffer; \
        } \
        else { \
            Parrot_ex_throw_from_c_noargs(interp, EXCEPTION_INVALID_OPERATION, \
                "Attributes of type 'IO_BUFFER *' cannot be " \
                "subclassed from a high-level PMC."); \
        } \
    } while (0)
#define SETATTR_Socket_read_buffer(interp, pmc, value) \
    do { \
        if (PObj_is_object_TEST(pmc)) { \
            Parrot_ex_throw_from_c_noargs(interp, EXCEPTION_INVALID_OPERATION, \
                "Attributes of type 'IO_BUFFER *' cannot be " \
                "subclassed from a high-level PMC."); \
        } \
        else \
            ((Parrot_Socket_attributes *)PMC_data(pmc))->read_buffer = (value); \
    } while (0)


/* Generated macro accessors for 'write_buffer' attribute of Socket PMC. */
#define GETATTR_Socket_write_buffer(interp, pmc, dest) \
    do { \
        if (!PObj_is_object_TEST(pmc)) { \
            (dest) = ((Parrot_Socket_attributes *)PMC_data(pmc))->write_buffer; \
        } \
        else { \
            Parrot_ex_throw_from_c_noargs(interp, EXCEPTION_INVALID_OPERATION, \
                "Attributes of type 'IO_BUFFER *' cannot be " \
                "subclassed from a high-level PMC."); \
        } \
    } while (0)
#define SETATTR_Socket_write_buffer(interp, pmc, value) \
    do { \
        if (PObj_is_object_TEST(pmc)) { \
            Parrot_ex_throw_from_c_noargs(interp, EXCEPTION_INVALID_OPERATION, \
                "Attributes of type 'IO_BUFFER *' cannot be " \
                "subclassed from a high-level PMC."); \
        } \
        else \
            ((Parrot_Socket_attributes *)PMC_data(pmc))->write_buffer = (value); \
    } while (0)


/* Generated macro accessors for 'encoding' attribute of Socket PMC. */
#define GETATTR_Socket_encoding(interp, pmc, dest) \
    do { \
        if (!PObj_is_object_TEST(pmc)) { \
            (dest) = ((Parrot_Socket_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_Socket_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_Socket_attributes *)PMC_data(pmc))->encoding = (value); \
    } while (0)


/* Generated macro accessors for 'local' attribute of Socket PMC. */
#define GETATTR_Socket_local(interp, pmc, dest) \
    do { \
        if (!PObj_is_object_TEST(pmc)) { \
            (dest) = ((Parrot_Socket_attributes *)PMC_data(pmc))->local; \
        } \
        else { \
            (dest) = VTABLE_get_attr_str(interp, \
                              pmc, Parrot_str_new_constant(interp, "local")); \
        } \
    } while (0)
#define SETATTR_Socket_local(interp, pmc, value) \
    do { \
        if (PObj_is_object_TEST(pmc)) { \
            VTABLE_set_attr_str(interp, pmc, \
                              Parrot_str_new_constant(interp, "local"), value); \
        } \
        else \
            ((Parrot_Socket_attributes *)PMC_data(pmc))->local = (value); \
    } while (0)


/* Generated macro accessors for 'remote' attribute of Socket PMC. */
#define GETATTR_Socket_remote(interp, pmc, dest) \
    do { \
        if (!PObj_is_object_TEST(pmc)) { \
            (dest) = ((Parrot_Socket_attributes *)PMC_data(pmc))->remote; \
        } \
        else { \
            (dest) = VTABLE_get_attr_str(interp, \
                              pmc, Parrot_str_new_constant(interp, "remote")); \
        } \
    } while (0)
#define SETATTR_Socket_remote(interp, pmc, value) \
    do { \
        if (PObj_is_object_TEST(pmc)) { \
            VTABLE_set_attr_str(interp, pmc, \
                              Parrot_str_new_constant(interp, "remote"), value); \
        } \
        else \
            ((Parrot_Socket_attributes *)PMC_data(pmc))->remote = (value); \
    } while (0)


/* Generated macro accessors for 'family' attribute of Socket PMC. */
#define GETATTR_Socket_family(interp, pmc, dest) \
    do { \
        if (!PObj_is_object_TEST(pmc)) { \
            (dest) = ((Parrot_Socket_attributes *)PMC_data(pmc))->family; \
        } \
        else { \
            PMC * const attr_value = VTABLE_get_attr_str(interp, \
                              pmc, Parrot_str_new_constant(interp, "family")); \
            (dest) = (PMC_IS_NULL(attr_value) ? (INTVAL) 0: VTABLE_get_integer(interp, attr_value)); \
        } \
    } while (0)
#define SETATTR_Socket_family(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, "family"), attr_value); \
        } \
        else \
            ((Parrot_Socket_attributes *)PMC_data(pmc))->family = (value); \
    } while (0)


/* Generated macro accessors for 'type' attribute of Socket PMC. */
#define GETATTR_Socket_type(interp, pmc, dest) \
    do { \
        if (!PObj_is_object_TEST(pmc)) { \
            (dest) = ((Parrot_Socket_attributes *)PMC_data(pmc))->type; \
        } \
        else { \
            PMC * const attr_value = VTABLE_get_attr_str(interp, \
                              pmc, Parrot_str_new_constant(interp, "type")); \
            (dest) = (PMC_IS_NULL(attr_value) ? (INTVAL) 0: VTABLE_get_integer(interp, attr_value)); \
        } \
    } while (0)
#define SETATTR_Socket_type(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, "type"), attr_value); \
        } \
        else \
            ((Parrot_Socket_attributes *)PMC_data(pmc))->type = (value); \
    } while (0)


/* Generated macro accessors for 'protocol' attribute of Socket PMC. */
#define GETATTR_Socket_protocol(interp, pmc, dest) \
    do { \
        if (!PObj_is_object_TEST(pmc)) { \
            (dest) = ((Parrot_Socket_attributes *)PMC_data(pmc))->protocol; \
        } \
        else { \
            PMC * const attr_value = VTABLE_get_attr_str(interp, \
                              pmc, Parrot_str_new_constant(interp, "protocol")); \
            (dest) = (PMC_IS_NULL(attr_value) ? (INTVAL) 0: VTABLE_get_integer(interp, attr_value)); \
        } \
    } while (0)
#define SETATTR_Socket_protocol(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, "protocol"), attr_value); \
        } \
        else \
            ((Parrot_Socket_attributes *)PMC_data(pmc))->protocol = (value); \
    } while (0)


#endif /* PARROT_PMC_SOCKET_H_GUARD */

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

