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

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


#ifndef PARROT_PMC_MANAGEDSTRUCT_H_GUARD
#define PARROT_PMC_MANAGEDSTRUCT_H_GUARD

PARROT_EXPORT VTABLE* Parrot_ManagedStruct_update_vtable(ARGMOD(VTABLE*));
PARROT_EXPORT VTABLE* Parrot_ManagedStruct_ro_update_vtable(ARGMOD(VTABLE*));
PARROT_EXPORT VTABLE* Parrot_ManagedStruct_get_vtable(PARROT_INTERP);
PARROT_EXPORT VTABLE* Parrot_ManagedStruct_ro_get_vtable(PARROT_INTERP);
PARROT_EXPORT PMC*    Parrot_ManagedStruct_get_mro(PARROT_INTERP, ARGMOD(PMC* mro));
PARROT_EXPORT Hash*   Parrot_ManagedStruct_get_isa(PARROT_INTERP, ARGMOD_NULLOK(Hash* isa));

/* ManagedStruct PMC's underlying struct. */
typedef struct Parrot_ManagedStruct_attributes {
    void   * ptr;
    PMC    * init;
    INTVAL size;
    void (*custom_free_func)(PARROT_INTERP, void *, void *);
    void * custom_free_priv;
    PMC * (*custom_clone_func)(PARROT_INTERP, PMC *ptr, void *priv);
    void * custom_clone_priv;
} Parrot_ManagedStruct_attributes;

/* Macro to access underlying structure of a ManagedStruct PMC. */
#define PARROT_MANAGEDSTRUCT(o) ((Parrot_ManagedStruct_attributes *) PMC_data(o))


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

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


/* Generated macro accessors for 'init' attribute of ManagedStruct PMC. */
#define GETATTR_ManagedStruct_init(interp, pmc, dest) \
    do { \
        if (!PObj_is_object_TEST(pmc)) { \
            (dest) = ((Parrot_ManagedStruct_attributes *)PMC_data(pmc))->init; \
        } \
        else { \
            (dest) = VTABLE_get_attr_str(interp, \
                              pmc, Parrot_str_new_constant(interp, "init")); \
        } \
    } while (0)

#define SETATTR_ManagedStruct_init(interp, pmc, value) \
    do { \
        if (PObj_is_object_TEST(pmc)) { \
            VTABLE_set_attr_str(interp, pmc, \
                              Parrot_str_new_constant(interp, "init"), value); \
        } \
        else \
            ((Parrot_ManagedStruct_attributes *)PMC_data(pmc))->init = (value); \
    } while (0)


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

#define SETATTR_ManagedStruct_size(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, "size"), attr_value); \
        } \
        else \
            ((Parrot_ManagedStruct_attributes *)PMC_data(pmc))->size = (value); \
    } while (0)


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

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


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

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


/* Generated macro accessors for 'custom_clone_func' attribute of ManagedStruct PMC. */
#define GETATTR_ManagedStruct_custom_clone_func(interp, pmc, dest) \
    do { \
        if (!PObj_is_object_TEST(pmc)) { \
            (dest) = ((Parrot_ManagedStruct_attributes *)PMC_data(pmc))->custom_clone_func; \
        } \
        else { \
            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION, \
                "Attributes of type 'PMC * (*)(PARROT_INTERP, PMC *ptr, void *priv)' cannot be " \
                "subclassed from a high-level PMC."); \
        } \
    } while (0)

#define SETATTR_ManagedStruct_custom_clone_func(interp, pmc, value) \
    do { \
        if (PObj_is_object_TEST(pmc)) { \
            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION, \
                "Attributes of type 'PMC * (*)(PARROT_INTERP, PMC *ptr, void *priv)' cannot be " \
                "subclassed from a high-level PMC."); \
        } \
        else \
            ((Parrot_ManagedStruct_attributes *)PMC_data(pmc))->custom_clone_func = (value); \
    } while (0)


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

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


#endif /* PARROT_PMC_MANAGEDSTRUCT_H_GUARD */

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

