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

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


#ifndef PARROT_PMC_PTROBJ_H_GUARD
#define PARROT_PMC_PTROBJ_H_GUARD

typedef PMC *(*ptrobj_clone_func_t)(PARROT_INTERP, ARGIN(PMC *), ARGIN(void *));
typedef void (*ptrobj_mark_func_t)(PARROT_INTERP, ARGIN(PMC *), ARGIN(void *));
typedef void (*ptrobj_destroy_func_t)(PARROT_INTERP, ARGIN(PMC *), ARGIN(void *));

#define PTROBJ_SET_CLONE(i, p, c) do { \
    SETATTR_PtrObj_clone((i), (p), (c)); \
} while (0)

#define PTROBJ_SET_MARK(i, p, m) do { \
    SETATTR_PtrObj_mark((i), (p), (m)); \
    if (m) \
        PObj_custom_mark_SET(p); \
    else \
        PObj_custom_mark_CLEAR(p); \
} while (0)

#define PTROBJ_SET_DESTROY(i, p, d) do { \
    SETATTR_PtrObj_destroy((i), (p), (d)); \
    if (d) \
        PObj_custom_destroy_SET(p); \
    else \
        PObj_custom_destroy_CLEAR(p); \
} while (0)
PARROT_EXPORT VTABLE* Parrot_PtrObj_update_vtable(ARGMOD(VTABLE*));
PARROT_EXPORT VTABLE* Parrot_PtrObj_ro_update_vtable(ARGMOD(VTABLE*));
PARROT_EXPORT VTABLE* Parrot_PtrObj_get_vtable(PARROT_INTERP);
PARROT_EXPORT VTABLE* Parrot_PtrObj_ro_get_vtable(PARROT_INTERP);
PARROT_EXPORT PMC*    Parrot_PtrObj_get_mro(PARROT_INTERP, ARGIN_NULLOK(PMC* mro));
PARROT_EXPORT Hash*   Parrot_PtrObj_get_isa(PARROT_INTERP, ARGIN_NULLOK(Hash* isa));

/* PtrObj PMC's underlying struct. */
typedef struct Parrot_PtrObj_attributes {
    void * ptr;
    UINTVAL size;
    ptrobj_clone_func_t clone;
    ptrobj_mark_func_t mark;
    ptrobj_destroy_func_t destroy;
} Parrot_PtrObj_attributes;

/* Macro to access underlying structure of a PtrObj PMC. */
#define PARROT_PTROBJ(o) ((Parrot_PtrObj_attributes *) PMC_data(o))


/* Generated macro accessors for 'ptr' attribute of PtrObj PMC. */
#define GETATTR_PtrObj_ptr(interp, pmc, dest) \
    do { \
        if (!PObj_is_object_TEST(pmc)) { \
            (dest) = ((Parrot_PtrObj_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_PtrObj_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_PtrObj_attributes *)PMC_data(pmc))->ptr = (value); \
    } while (0)


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

#define SETATTR_PtrObj_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 'UINTVAL' cannot be " \
                "subclassed from a high-level PMC."); \
        } \
        else \
            ((Parrot_PtrObj_attributes *)PMC_data(pmc))->size = (value); \
    } while (0)


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

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


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

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


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

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


#endif /* PARROT_PMC_PTROBJ_H_GUARD */

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

