/*
 * Portions of this file Copyright 1999-2005 University of Chicago
 * Portions of this file Copyright 1999-2005 The University of Southern California.
 *
 * This file or a portion of this file is licensed under the
 * terms of the Globus Toolkit Public License, found at
 * http://www.globus.org/toolkit/download/license.html.
 * If you redistribute this file, with or without
 * modifications, you must include this notice in the file.
 */

#ifndef _GLOBUS_XSD_PRIMITIVES_H_
#define _GLOBUS_XSD_PRIMITIVES_H_

#define GLOBUS_XSD_DECLARE_SERIALIZE(_TYPE_NAME_)               \
    globus_result_t                                             \
    _TYPE_NAME_##_serialize(                                    \
        xsd_QName *                         element_name,       \
        _TYPE_NAME_ *                       val,                \
        globus_soap_message_handle_t        message_handle,     \
        globus_xsd_element_options_t        options)

#define GLOBUS_XSD_DECLARE_ATTR_SERIALIZE(_TYPE_NAME_)  \
    globus_result_t                                     \
    _TYPE_NAME_##_serialize_attribute(                  \
    xsd_QName *                     attr_qname,         \
    _TYPE_NAME_ *                   val,                \
    globus_soap_message_handle_t    handle,             \
    globus_xsd_element_options_t    options)

#define GLOBUS_XSD_DECLARE_DESERIALIZE(_TYPE_NAME_)             \
    globus_result_t                                             \
    _TYPE_NAME_##_deserialize(                                  \
        xsd_QName *                         element_name,       \
        _TYPE_NAME_ *                       val,                \
        globus_soap_message_handle_t        message_handle,     \
        globus_xsd_element_options_t        options)

#define GLOBUS_XSD_DECLARE_LIST_SERIALIZE(_TYPE_NAME_)  \
    globus_result_t                                     \
    _TYPE_NAME_##_list_serialize(                       \
        xsd_QName *                     element_name,   \
        _TYPE_NAME_##_array *           inst,           \
        globus_soap_message_handle_t    message_handle, \
        globus_xsd_element_options_t    options)

#define GLOBUS_XSD_DECLARE_LIST_SERIALIZE_CONTENTS(_TYPE_NAME_) \
    globus_result_t                                             \
    _TYPE_NAME_##_list_serialize_contents(                      \
        _TYPE_NAME_##_array *           inst,                   \
        globus_soap_message_handle_t    message_handle,         \
        globus_xsd_element_options_t    options)

#define GLOBUS_XSD_DECLARE_LIST_SERIALIZE_ATTR(_TYPE_NAME_)     \
    globus_result_t                                             \
    _TYPE_NAME_##_list_serialize_attribute(                     \
        xsd_QName *                     attr_qname,             \
        _TYPE_NAME_##_array *           inst,                   \
        globus_soap_message_handle_t    message_handle,         \
        globus_xsd_element_options_t    options)

#define GLOBUS_XSD_DECLARE_DESERIALIZE_POINTER(_TYPE_NAME_)     \
    globus_result_t                                             \
    _TYPE_NAME_##_deserialize_pointer(                          \
        xsd_QName *                         element_name,       \
        _TYPE_NAME_ **                      instance,           \
        globus_soap_message_handle_t        message_handle,     \
        globus_xsd_element_options_t        options)

#define GLOBUS_XSD_DECLARE_ATTR_DESERIALIZE(_TYPE_NAME_)        \
    globus_result_t                                             \
    _TYPE_NAME_##_deserialize_attribute(                        \
        xsd_QName *                     attr_qname,             \
        _TYPE_NAME_ *                   instance,               \
        globus_soap_message_handle_t    message,                \
        globus_xsd_element_options_t    options)

#define GLOBUS_XSD_DECLARE_ATTR_DESERIALIZE_POINTER(_TYPE_NAME_)        \
    globus_result_t                                                     \
    _TYPE_NAME_##_deserialize_attribute_pointer(                        \
        xsd_QName *                     attr_qname,                     \
        _TYPE_NAME_ **                  instance,                       \
        globus_soap_message_handle_t    message,                        \
        globus_xsd_element_options_t    options)

#define GLOBUS_XSD_DECLARE_LIST_DESERIALIZE(_TYPE_NAME_)        \
    globus_result_t                                             \
    _TYPE_NAME_##_list_deserialize(                             \
        xsd_QName *                     element_qname,          \
        _TYPE_NAME_##_array *           ip,                     \
        globus_soap_message_handle_t    message_handle,         \
        globus_xsd_element_options_t    options)

#define GLOBUS_XSD_DECLARE_LIST_DESERIALIZE_CONTENTS(_TYPE_NAME_)       \
    globus_result_t                                                     \
    _TYPE_NAME_##_list_deserialize_contents(                            \
        _TYPE_NAME_##_array *           ip,                             \
        globus_soap_message_handle_t    message_handle,                 \
        globus_xsd_element_options_t    options)

#define GLOBUS_XSD_DECLARE_LIST_DESERIALIZE_ATTR(_TYPE_NAME_)   \
    globus_result_t                                             \
    _TYPE_NAME_##_list_deserialize_attribute(                   \
        xsd_QName *                     attr_qname,             \
        _TYPE_NAME_##_array *           ip,                     \
        globus_soap_message_handle_t    message_handle,         \
        globus_xsd_element_options_t    options)

#define GLOBUS_XSD_DECLARE_INIT(_TYPE_NAME_)    \
    globus_result_t                             \
    _TYPE_NAME_##_init(                         \
        _TYPE_NAME_ **                  inst)

#define GLOBUS_XSD_DECLARE_INIT_CONTENTS(_TYPE_NAME_)   \
    globus_result_t                                     \
    _TYPE_NAME_##_init_contents(                        \
        _TYPE_NAME_ *                   instance)

#define GLOBUS_XSD_DECLARE_COPY(_TYPE_NAME_)    \
    globus_result_t                             \
    _TYPE_NAME_##_copy(                         \
        _TYPE_NAME_ **                  dest,   \
        const _TYPE_NAME_ *             src)

#define GLOBUS_XSD_DECLARE_COPY_CONTENTS(_TYPE_NAME_)   \
    globus_result_t                                     \
    _TYPE_NAME_##_copy_contents(                        \
        _TYPE_NAME_ *                   dest,           \
        const _TYPE_NAME_ *             src)

#define GLOBUS_XSD_DECLARE_DESTROY(_TYPE_NAME_) \
    void                                        \
    _TYPE_NAME_##_destroy(                      \
        _TYPE_NAME_ *                   inst)

#define GLOBUS_XSD_DECLARE_DESTROY_CONTENTS(_TYPE_NAME_)        \
    void                                                        \
    _TYPE_NAME_##_destroy_contents(                             \
        _TYPE_NAME_ *                   inst)

#define GLOBUS_XSD_DECLARE_SERIALIZE_CONTENTS(_TYPE_NAME_)      \
    globus_result_t                                             \
    _TYPE_NAME_##_serialize_contents(                           \
        xsd_QName *                     element,                \
        _TYPE_NAME_ *                   instance,               \
        globus_soap_message_handle_t    message_handle,         \
        globus_xsd_element_options_t    options)

#define GLOBUS_XSD_DECLARE_DESERIALIZE_CONTENTS(_TYPE_NAME_)    \
    globus_result_t                                             \
    _TYPE_NAME_##_deserialize_contents(                         \
        xsd_QName *                     eqn,                    \
        _TYPE_NAME_ *                   instance,               \
        globus_soap_message_handle_t    message_handle,         \
        globus_xsd_element_options_t    options)

#define GLOBUS_XSD_DECLARE_TYPE_POINTER(_TYPE_NAME_)            \
    typedef _TYPE_NAME_ *                   _TYPE_NAME_##_o

#define GLOBUS_XSD_DECLARE_TYPE_ARRAY(_TYPE_NAME_)              \
    typedef struct _TYPE_NAME_##_array_s                        \
    {                                                           \
        _TYPE_NAME_ *                       elements;           \
        int                                 length;             \
    } _TYPE_NAME_##_array

#define GLOBUS_XSD_DECLARE_SERIALIZE_ARRAY(_TYPE_NAME_)         \
    globus_result_t                                             \
    _TYPE_NAME_##_array_serialize(                              \
        xsd_QName *                         element,            \
        _TYPE_NAME_##_array *               array_instance,     \
        globus_soap_message_handle_t        message_handle,     \
        globus_xsd_element_options_t        options)
    
#define GLOBUS_XSD_DECLARE_DESERIALIZE_ARRAY(_TYPE_NAME_)       \
    globus_result_t                                             \
    _TYPE_NAME_##_array_deserialize(                            \
        xsd_QName *                         element,            \
        _TYPE_NAME_##_array *               array_instance,     \
        globus_soap_message_handle_t        message_handle,     \
        globus_xsd_element_options_t        options)

#define GLOBUS_XSD_DECLARE_INIT_ARRAY(_TYPE_NAME_)      \
    globus_result_t                                     \
    _TYPE_NAME_##_array_init(                           \
        _TYPE_NAME_##_array **              inst)

#define GLOBUS_XSD_DECLARE_INIT_ARRAY_CONTENTS(_TYPE_NAME_)     \
    globus_result_t                                             \
    _TYPE_NAME_##_array_init_contents(                          \
        _TYPE_NAME_##_array *              inst)

#define GLOBUS_XSD_DECLARE_DESTROY_ARRAY(_TYPE_NAME_)   \
    void                                                \
    _TYPE_NAME_##_array_destroy(                        \
        _TYPE_NAME_##_array *               inst)

#define GLOBUS_XSD_DECLARE_DESTROY_ARRAY_CONTENTS(_TYPE_NAME_)  \
    void                                                        \
    _TYPE_NAME_##_array_destroy_contents(                       \
        _TYPE_NAME_##_array *               inst)

#define GLOBUS_XSD_DECLARE_COPY_ARRAY(_TYPE_NAME_)      \
    globus_result_t                                     \
    _TYPE_NAME_##_array_copy(                           \
        _TYPE_NAME_##_array **                  dest,   \
        const _TYPE_NAME_##_array *             src)

#define GLOBUS_XSD_DECLARE_COPY_ARRAY_CONTENTS(_TYPE_NAME_)     \
    globus_result_t                                             \
    _TYPE_NAME_##_array_copy_contents(                          \
        _TYPE_NAME_##_array *                   dest,           \
        const _TYPE_NAME_##_array *             src)

#define GLOBUS_XSD_DECLARE_ARRAY_PUSH(_TYPE_NAME_)      \
    _TYPE_NAME_ *                                       \
    _TYPE_NAME_##_array_push(                           \
        _TYPE_NAME_##_array *           array)

#define GLOBUS_XSD_DECLARE_WRAPPERS(type)                       \
    globus_result_t                                             \
    type##_init_wrapper(void **object);                         \
    void                                                        \
    type##_destroy_wrapper(                                     \
        void *                          object);                \
    globus_result_t                                             \
    type##_copy_wrapper(                                        \
        void **                         dest_obj,               \
        void *                          src_obj);               \
    globus_result_t                                             \
    type##_init_contents_wrapper(void *object);                 \
    void                                                        \
    type##_destroy_contents_wrapper(void * object);             \
    globus_result_t                                             \
    type##_copy_contents_wrapper(                               \
        void *                          dest_obj,               \
        void *                          src_obj);               \
    globus_result_t                                             \
    type##_serialize_wrapper(                                   \
        xsd_QName *                         element_qname,      \
        void *                              instance,           \
        globus_soap_message_handle_t        message_handle,     \
        globus_xsd_element_options_t        options);           \
    globus_result_t                                             \
    type##_serialize_contents_wrapper(                          \
        xsd_QName *                         element_qname,      \
        void *                              instance,           \
        globus_soap_message_handle_t        message_handle,     \
        globus_xsd_element_options_t        options);           \
    globus_result_t                                             \
    type##_deserialize_contents_wrapper(                        \
        xsd_QName *                         element_qname,      \
        void **                             instance,           \
        globus_soap_message_handle_t        message_handle,     \
        globus_xsd_element_options_t        options);           \
    globus_result_t                                             \
    type##_array_serialize_wrapper(                             \
        xsd_QName *                     element,                \
        void *                          instance,               \
        globus_soap_message_handle_t    message,                \
        globus_xsd_element_options_t    options);               \
    globus_result_t                                             \
    type##_array_deserialize_wrapper(                           \
        xsd_QName *                         element_qname,      \
        void **                             inst,               \
        globus_soap_message_handle_t        message,            \
        globus_xsd_element_options_t        options);           \
    globus_result_t                                             \
    type##_array_init_wrapper(                                  \
        void **                             arr);               \
    void                                                        \
    type##_array_destroy_wrapper(                               \
        void *                              arr);               \
    globus_result_t                                             \
    type##_array_copy_wrapper(                                  \
        void **                             dest_arr,           \
        void *                              src_arr);           \
    globus_result_t                                             \
    type##_array_init_contents_wrapper(                         \
        void *                              arr);               \
    void                                                        \
    type##_array_destroy_contents_wrapper(                      \
        void *                              arr);               \
    globus_result_t                                             \
    type##_array_copy_contents_wrapper(                         \
        void *                              dest_arr,           \
        void *                              src_arr);           \
    globus_result_t                                             \
    type##_deserialize_pointer_wrapper(                         \
        xsd_QName *                         element_qname,      \
        void **                             ip,                 \
        globus_soap_message_handle_t        message_handle,     \
        globus_xsd_element_options_t        options);           \
    void *                                                      \
    type##_array_push_wrapper(                                  \
        void *                          array)

#define GLOBUS_XSD_DECLARE_EXTERN_VARS(_TYPE_NAME_)                     \
    extern xsd_QName                    _TYPE_NAME_##_qname;            \
    extern struct globus_xsd_type_info_s _TYPE_NAME_##_info;            \
    extern struct globus_xsd_type_info_s _TYPE_NAME_##_array_info;      \
    extern struct globus_xsd_type_info_s _TYPE_NAME_##_contents_info

#define GLOBUS_XSD_DECLARE_ATTR_FUNCTIONS(_TYPE_NAME_)          \
    GLOBUS_XSD_DECLARE_ATTR_SERIALIZE(_TYPE_NAME_);             \
    GLOBUS_XSD_DECLARE_ATTR_DESERIALIZE(_TYPE_NAME_);           \
    GLOBUS_XSD_DECLARE_ATTR_DESERIALIZE_POINTER(_TYPE_NAME_)

#define GLOBUS_XSD_DECLARE_LIST_FUNCTIONS(_TYPE_NAME_)          \
    GLOBUS_XSD_DECLARE_LIST_SERIALIZE(_TYPE_NAME_);             \
    GLOBUS_XSD_DECLARE_LIST_SERIALIZE_CONTENTS(_TYPE_NAME_);    \
    GLOBUS_XSD_DECLARE_LIST_SERIALIZE(_TYPE_NAME_);             \
    GLOBUS_XSD_DECLARE_LIST_SERIALIZE_ATTR(_TYPE_NAME_);        \
    GLOBUS_XSD_DECLARE_LIST_DESERIALIZE(_TYPE_NAME_);           \
    GLOBUS_XSD_DECLARE_LIST_DESERIALIZE_CONTENTS(_TYPE_NAME_);  \
    GLOBUS_XSD_DECLARE_LIST_DESERIALIZE(_TYPE_NAME_);           \
    GLOBUS_XSD_DECLARE_LIST_DESERIALIZE_ATTR(_TYPE_NAME_)

#define GLOBUS_XSD_DECLARE_LIST_ATTR_FUNCTIONS(_TYPE_NAME_)     \
    GLOBUS_XSD_DECLARE_LIST_SERIALIZE_ATTR(_TYPE_NAME_);        \
    GLOBUS_XSD_DECLARE_LIST_DESERIALIZE_ATTR(_TYPE_NAME_)

#define GLOBUS_XSD_DECLARE_TYPE_FUNCTIONS(_TYPE_NAME_)          \
    GLOBUS_XSD_DECLARE_WRAPPERS(_TYPE_NAME_);                   \
    GLOBUS_XSD_DECLARE_EXTERN_VARS(_TYPE_NAME_);                \
    GLOBUS_XSD_DECLARE_TYPE_POINTER(_TYPE_NAME_);               \
    GLOBUS_XSD_DECLARE_TYPE_ARRAY(_TYPE_NAME_);                 \
    GLOBUS_XSD_DECLARE_SERIALIZE(_TYPE_NAME_);                  \
    GLOBUS_XSD_DECLARE_DESERIALIZE(_TYPE_NAME_);                \
    GLOBUS_XSD_DECLARE_DESERIALIZE_POINTER(_TYPE_NAME_);        \
    GLOBUS_XSD_DECLARE_INIT(_TYPE_NAME_);                       \
    GLOBUS_XSD_DECLARE_INIT_CONTENTS(_TYPE_NAME_);              \
    GLOBUS_XSD_DECLARE_DESTROY(_TYPE_NAME_);                    \
    GLOBUS_XSD_DECLARE_DESTROY_CONTENTS(_TYPE_NAME_);           \
    GLOBUS_XSD_DECLARE_COPY(_TYPE_NAME_);                       \
    GLOBUS_XSD_DECLARE_COPY_CONTENTS(_TYPE_NAME_);              \
    GLOBUS_XSD_DECLARE_SERIALIZE_CONTENTS(_TYPE_NAME_);         \
    GLOBUS_XSD_DECLARE_DESERIALIZE_CONTENTS(_TYPE_NAME_);       \
    GLOBUS_XSD_DECLARE_SERIALIZE_ARRAY(_TYPE_NAME_);            \
    GLOBUS_XSD_DECLARE_DESERIALIZE_ARRAY(_TYPE_NAME_);          \
    GLOBUS_XSD_DECLARE_INIT_ARRAY(_TYPE_NAME_);                 \
    GLOBUS_XSD_DECLARE_INIT_ARRAY_CONTENTS(_TYPE_NAME_);        \
    GLOBUS_XSD_DECLARE_DESTROY_ARRAY(_TYPE_NAME_);              \
    GLOBUS_XSD_DECLARE_DESTROY_ARRAY_CONTENTS(_TYPE_NAME_);     \
    GLOBUS_XSD_DECLARE_COPY_ARRAY(_TYPE_NAME_);                 \
    GLOBUS_XSD_DECLARE_COPY_ARRAY_CONTENTS(_TYPE_NAME_);        \
    GLOBUS_XSD_DECLARE_ARRAY_PUSH(_TYPE_NAME_)

#endif /* _GLOBUS_I_XSD_PRIMITIVES_H_ */
