diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2000-09-18 14:29:57 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2000-09-18 14:29:57 +0000 |
commit | b525a3115f54576017a576ff842dede5e2e3545d (patch) | |
tree | c534b95a9e572b63896467624293a5ca1887d3a3 /cppu/inc | |
parent | 9399c662f36c385b0c705eb34e636a9aec450282 (diff) |
initial import
Diffstat (limited to 'cppu/inc')
25 files changed, 6426 insertions, 0 deletions
diff --git a/cppu/inc/com/sun/star/uno/Any.h b/cppu/inc/com/sun/star/uno/Any.h new file mode 100644 index 000000000000..788031178b4b --- /dev/null +++ b/cppu/inc/com/sun/star/uno/Any.h @@ -0,0 +1,376 @@ +/************************************************************************* + * + * $RCSfile: Any.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:25:50 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _COM_SUN_STAR_UNO_ANY_H_ +#define _COM_SUN_STAR_UNO_ANY_H_ + +#ifndef _CPPU_MACROS_HXX_ +#include <cppu/macros.hxx> +#endif + +#ifndef _UNO_ANY2_H_ +#include <uno/any2.h> +#endif +#ifndef _TYPELIB_TYPEDESCRIPTION_H_ +#include <typelib/typedescription.h> +#endif +#ifndef _COM_SUN_STAR_UNO_TYPE_H_ +#include <com/sun/star/uno/Type.h> +#endif + +#ifndef _RTL_ALLOC_H_ +#include <rtl/alloc.h> +#endif + +class BinaryCompatible_Impl; + +/** */ //for docpp +namespace com +{ +/** */ //for docpp +namespace sun +{ +/** */ //for docpp +namespace star +{ +/** */ //for docpp +namespace uno +{ + +/** C++ class representing an IDL any. + This class is used to transport any type defined in IDL. + The class inherits from the binary C representation + of <b>uno_Any</b>.<br> + You can insert a value by either using the <<= operators + or the template function makeAny(). No any can hold an any.<br> + You can extract values from an any by using the >>= operators + which return true if the any contains an assignable value + (no data loss), e.g. the any contains a short and you >>= it + into a long variable. + <br> +*/ +class Any : public uno_Any +{ +public: + // these are here to force memory de/allocation to sal lib. + inline static void * SAL_CALL operator new( size_t nSize ) throw() + { return ::rtl_allocateMemory( nSize ); } + inline static void SAL_CALL operator delete( void * pMem ) throw() + { ::rtl_freeMemory( pMem ); } + inline static void * SAL_CALL operator new( size_t, void * pMem ) throw() + { return pMem; } + inline static void SAL_CALL operator delete( void *, void * ) throw() + {} + + /** Default constructor: + Any holds no value; its type is void. + <br> + */ + inline Any(); + + /** Copy constructor: + Sets value of the given any. + <br> + @param rAny another any + */ + inline Any( const Any & rAny ); + + /** Constructor: + Sets a copy of the given data. + <br> + @param pData value + @param rType type of value + */ + inline Any( const void * pData, const Type & rType ); + + /** Constructor: + Sets a copy of the given data. + <br> + @param pData value + @param pTypeDescr type of value + */ + inline Any( const void * pData, typelib_TypeDescription * pTypeDescr ); + + /** Constructor: + Sets a copy of the given data. + <br> + @param pData value + @param pType type of value + */ + inline Any( const void * pData, typelib_TypeDescriptionReference * pType ); + + /** Destructor: + Destructs any content and frees memory. + <br> + */ + inline ~Any(); + + /** Assignment operator: + Sets the value of the given any. + <br> + @param rAny another any (right side) + @return this any + */ + inline Any & SAL_CALL operator = ( const Any & rAny ); + + /** Gets the type of the set value. + <br> + @return a Type object of the set value + */ + inline const Type & SAL_CALL getValueType() const + { return * reinterpret_cast< const Type * >( &pType ); } + /** Gets the type of the set value. + <br> + @return the <b>un</b>acquired type description reference of the set value + */ + inline typelib_TypeDescriptionReference * SAL_CALL getValueTypeRef() const + { return pType; } + + /** Gets the type description of the set value.<br> + Provides <b>ownership</b> of the type description! + Call an explicit typelib_typedescription_release() to release. + <br> + @param a pointer to type description pointer + */ + inline void SAL_CALL getValueTypeDescription( typelib_TypeDescription ** ppTypeDescr ) const + { ::typelib_typedescriptionreference_getDescription( ppTypeDescr, getValueTypeRef() ); } + + /** Gets the type class of the set value. + <br> + @return the type class of the set value + */ + inline TypeClass SAL_CALL getValueTypeClass() const + { return (TypeClass)pType->eTypeClass; } + + /** Gets the type name of the set value. + <br> + @return the type name of the set value + */ + inline ::rtl::OUString SAL_CALL getValueTypeName() const + { return ::rtl::OUString( pType->pTypeName ); } + + /** Tests if any contains a value. + <br> + @return true if any has a value, false otherwise + */ + inline sal_Bool SAL_CALL hasValue() const + { return (TypeClass_VOID != getValueTypeClass()); } + + /** Gets a pointer to the set value. + <br> + @return a pointer to the set value + */ + inline const void * SAL_CALL getValue() const + { return pData; } + + /** Sets a value. If the any already contains a value, that value will be destructed + and its memory freed. + <br> + @param pData pointer to value + @param rType type of value + */ + inline void SAL_CALL setValue( const void * pData, const Type & rType ); + /** Sets a value. If the any already contains a value, that value will be destructed + and its memory freed. + <br> + @param pData pointer to value + @param pType type of value + */ + inline void SAL_CALL setValue( const void * pData, typelib_TypeDescriptionReference * pType ); + /** Sets a value. If the any already contains a value, that value will be destructed + and its memory freed. + <br> + @param pData pointer to value + @param pTypeDescr type description of value + */ + inline void SAL_CALL setValue( const void * pData, typelib_TypeDescription * pTypeDescr ); + + /** Clears this any. If the any already contains a value, that value will be destructed + and its memory freed. After this has been called, the any does not contain a value. + <br> + */ + inline void SAL_CALL clear(); + + /** Equality operator: compares two anys.<br> + The values need not be of equal type, e.g. a short integer is compared to + a long integer. + <br> + @param rAny another any (right side) + @return true if both any contains equal values + */ + inline sal_Bool SAL_CALL operator == ( const Any & rAny ) const; + /** Unequality operator: compares two anys.<br> + The values need not be of equal type, e.g. a short integer is compared to + a long integer. + <br> + @param rAny another any (right side) + @return true if both any contains unequal values + */ + inline sal_Bool SAL_CALL operator != ( const Any & rAny ) const + { return (! operator == ( rAny )); } + + // test the binary compatibility + friend class BinaryCompatible_Impl; +}; + +/** Template function to generically construct an any from a C++ value. + <br> + @param value a value + @return an any + */ +template< class C > +inline Any SAL_CALL makeAny( const C & value ); + +class BaseReference; +class Type; + +/** Template binary <<= operator to set the value of an any. + <br> + @param rAny destination any (left side) + @param value source value (right side) + */ +template< class C > +inline void SAL_CALL operator <<= ( ::com::sun::star::uno::Any & rAny, const C & value ); +/** Template binary >>= operator to assign a value from an any.<br> + If the any does not contain a value that can be assigned <b>without</b> + data loss, this operation will fail returning false. + <br> + @param rAny source any (left side) + @param value destination value (right side) + @return true if assignment was possible without data loss + */ +template< class C > +inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, C & value ); + +/** Template equality operator: compares set value of left side any to right side value.<br> + The values need not be of equal type, e.g. a short integer is compared to + a long integer.<br> + This operator can be implemented as template member function, if + all supported compilers can cope with template member functions. + <br> + @param rAny another any (left side) + @param value a value (right side) + @return true if values are equal, false otherwise +*/ +template< class C > +inline sal_Bool SAL_CALL operator == ( const ::com::sun::star::uno::Any & rAny, const C & value ); +/** Template unequality operator: compares set value of left side any to right side value.<br> + The values need not be of equal type, e.g. a short integer is compared to + a long integer.<br> + This operator can be implemented as template member function, if + all supported compilers can cope with template member functions. + <br> + @param rAny another any (left side) + @param value a value (right side) + @return true if values are unequal, false otherwise +*/ +template< class C > +inline sal_Bool SAL_CALL operator != ( const ::com::sun::star::uno::Any & rAny, const C & value ) +{ + return (! operator == ( rAny, value )); +} + +// additional specialized >>= and == operators +// bool +inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Bool & value ); +inline sal_Bool SAL_CALL operator == ( const ::com::sun::star::uno::Any & rAny, const sal_Bool & value ); +// byte +inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Int8 & value ); +// short +inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Int16 & value ); +inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_uInt16 & value ); +// long +inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Int32 & value ); +inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_uInt32 & value ); +// hyper +inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Int64 & value ); +inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_uInt64 & value ); +// float +inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, float & value ); +// double +inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, double & value ); +// string +inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, ::rtl::OUString & value ); +inline sal_Bool SAL_CALL operator == ( const ::com::sun::star::uno::Any & rAny, const ::rtl::OUString & value ); +// type +inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, ::com::sun::star::uno::Type & value ); +inline sal_Bool SAL_CALL operator == ( const ::com::sun::star::uno::Any & rAny, const ::com::sun::star::uno::Type & value ); +// any +inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, ::com::sun::star::uno::Any & value ); +// interface +inline sal_Bool SAL_CALL operator == ( const ::com::sun::star::uno::Any & rAny, const ::com::sun::star::uno::BaseReference & value ); + +} +} +} +} + +/** Gets the meta type of IDL type <b>any</b>. + <br> + @param dummy typed pointer for function signature + @return type of IDL type <b>any</b> +*/ +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const ::com::sun::star::uno::Any * ) +{ + return * reinterpret_cast< const ::com::sun::star::uno::Type * >( + ::typelib_static_type_getByTypeClass( typelib_TypeClass_ANY ) ); +} + +#endif diff --git a/cppu/inc/com/sun/star/uno/Any.hxx b/cppu/inc/com/sun/star/uno/Any.hxx new file mode 100644 index 000000000000..f73cfdf28b08 --- /dev/null +++ b/cppu/inc/com/sun/star/uno/Any.hxx @@ -0,0 +1,487 @@ +/************************************************************************* + * + * $RCSfile: Any.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:25:50 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _COM_SUN_STAR_UNO_ANY_HXX_ +#define _COM_SUN_STAR_UNO_ANY_HXX_ + +#ifndef _COM_SUN_STAR_UNO_ANY_H_ +#include <com/sun/star/uno/Any.h> +#endif +#ifndef _UNO_DATA_H_ +#include <uno/data.h> +#endif +#ifndef _UNO_ANY2_H_ +#include <uno/any2.h> +#endif +#ifndef _COM_SUN_STAR_UNO_TYPE_HXX_ +#include <com/sun/star/uno/Type.hxx> +#endif +#ifndef _COM_SUN_STAR_UNO_XINTERFACE_HPP_ +#include <com/sun/star/uno/XInterface.hpp> +#endif +#ifndef _COM_SUN_STAR_UNO_GENFUNC_HXX_ +#include <com/sun/star/uno/genfunc.hxx> +#endif + + +/** */ //for docpp +namespace com +{ +/** */ //for docpp +namespace sun +{ +/** */ //for docpp +namespace star +{ +/** */ //for docpp +namespace uno +{ + +//__________________________________________________________________________________________________ +inline Any::Any() +{ + ::uno_any_construct( this, 0, 0, cpp_acquire ); +} +//__________________________________________________________________________________________________ +inline Any::Any( const Any & rAny ) +{ + ::uno_type_any_construct( this, rAny.pData, rAny.getValueTypeRef(), cpp_acquire ); +} +//__________________________________________________________________________________________________ +inline Any::Any( const void * pData, const Type & rType ) +{ + ::uno_type_any_construct( this, const_cast< void * >( pData ), rType.getTypeLibType(), cpp_acquire ); +} +//__________________________________________________________________________________________________ +inline Any::Any( const void * pData, typelib_TypeDescription * pTypeDescr ) +{ + ::uno_any_construct( this, const_cast< void * >( pData ), pTypeDescr, cpp_acquire ); +} +//__________________________________________________________________________________________________ +inline Any::Any( const void * pData, typelib_TypeDescriptionReference * pType ) +{ + ::uno_type_any_construct( this, const_cast< void * >( pData ), pType, cpp_acquire ); +} +//__________________________________________________________________________________________________ +inline Any::~Any() +{ + ::uno_any_destruct( this, cpp_release ); +} +//__________________________________________________________________________________________________ +inline Any & Any::operator = ( const Any & rAny ) +{ + if (this != &rAny) + setValue( rAny.getValue(), rAny.getValueTypeRef() ); + return *this; +} +//__________________________________________________________________________________________________ +inline void Any::setValue( const void * pData, const Type & rType ) +{ + ::uno_any_destruct( this, cpp_release ); + ::uno_type_any_construct( this, const_cast< void * >( pData ), rType.getTypeLibType(), cpp_acquire ); +} +//__________________________________________________________________________________________________ +inline void Any::setValue( const void * pData, typelib_TypeDescriptionReference * pType ) +{ + ::uno_any_destruct( this, cpp_release ); + ::uno_type_any_construct( this, const_cast< void * >( pData ), pType, cpp_acquire ); +} +//__________________________________________________________________________________________________ +inline void Any::setValue( const void * pData, typelib_TypeDescription * pTypeDescr ) +{ + ::uno_any_destruct( this, cpp_release ); + ::uno_any_construct( this, const_cast< void * >( pData ), pTypeDescr, cpp_acquire ); +} +//__________________________________________________________________________________________________ +inline void Any::clear() +{ + ::uno_any_destruct( this, cpp_release ); + ::uno_any_construct( this, 0, 0, cpp_acquire ); +} +//__________________________________________________________________________________________________ +inline sal_Bool Any::operator == ( const Any & rAny ) const +{ + const Type & rType = ::getCppuType( this ); + return ::uno_type_equalData( + const_cast< void * >( getValue() ), getValueTypeRef(), + const_cast< void * >( rAny.getValue() ), rAny.getValueTypeRef(), + cpp_queryInterface, cpp_release ); +} + +//__________________________________________________________________________________________________ +template< class C > +inline Any SAL_CALL makeAny( const C & value ) +{ + return Any( &value, ::getCppuType( &value ) ); +} + +//__________________________________________________________________________________________________ +template< class C > +inline void SAL_CALL operator <<= ( ::com::sun::star::uno::Any & rAny, const C & value ) +{ + rAny.setValue( &value, ::getCppuType( &value ) ); +} + +//__________________________________________________________________________________________________ +template< class C > +inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, C & value ) +{ + const ::com::sun::star::uno::Type & rType = ::getCppuType( &value ); + return ::uno_type_assignData( + &value, rType.getTypeLibType(), + const_cast< void * >( rAny.getValue() ), rAny.getValueTypeRef(), + ::com::sun::star::uno::cpp_queryInterface, + ::com::sun::star::uno::cpp_acquire, + ::com::sun::star::uno::cpp_release ); +} + +// bool +//__________________________________________________________________________________________________ +inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Bool & value ) +{ + if (::com::sun::star::uno::TypeClass_BOOLEAN == rAny.getValueTypeClass()) + { + value = (* reinterpret_cast< const sal_Bool * >( rAny.getValue() ) != sal_False); + return sal_True; + } + return sal_False; +} +//__________________________________________________________________________________________________ +inline sal_Bool SAL_CALL operator == ( const ::com::sun::star::uno::Any & rAny, const sal_Bool & value ) +{ + return (::com::sun::star::uno::TypeClass_BOOLEAN == rAny.getValueTypeClass() && + (value != sal_False) == (* reinterpret_cast< const sal_Bool * >( rAny.getValue() ) != sal_False)); +} +// byte +//__________________________________________________________________________________________________ +inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Int8 & value ) +{ + if (::com::sun::star::uno::TypeClass_BYTE == rAny.getValueTypeClass()) + { + value = * reinterpret_cast< const sal_Int8 * >( rAny.getValue() ); + return sal_True; + } + return sal_False; +} +// short +//__________________________________________________________________________________________________ +inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Int16 & value ) +{ + switch (rAny.getValueTypeClass()) + { + case ::com::sun::star::uno::TypeClass_BYTE: + value = * reinterpret_cast< const sal_Int8 * >( rAny.getValue() ); + return sal_True; + case ::com::sun::star::uno::TypeClass_SHORT: + case ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT: + value = * reinterpret_cast< const sal_Int16 * >( rAny.getValue() ); + return sal_True; + } + return sal_False; +} +//__________________________________________________________________________________________________ +inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_uInt16 & value ) +{ + switch (rAny.getValueTypeClass()) + { + case ::com::sun::star::uno::TypeClass_BYTE: + value = * reinterpret_cast< const sal_Int8 * >( rAny.getValue() ); + return sal_True; + case ::com::sun::star::uno::TypeClass_SHORT: + case ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT: + value = * reinterpret_cast< const sal_uInt16 * >( rAny.getValue() ); + return sal_True; + } + return sal_False; +} +// long +//__________________________________________________________________________________________________ +inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Int32 & value ) +{ + switch (rAny.getValueTypeClass()) + { + case ::com::sun::star::uno::TypeClass_BYTE: + value = * reinterpret_cast< const sal_Int8 * >( rAny.getValue() ); + return sal_True; + case ::com::sun::star::uno::TypeClass_SHORT: + value = * reinterpret_cast< const sal_Int16 * >( rAny.getValue() ); + return sal_True; + case ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT: + value = * reinterpret_cast< const sal_uInt16 * >( rAny.getValue() ); + return sal_True; + case ::com::sun::star::uno::TypeClass_LONG: + case ::com::sun::star::uno::TypeClass_UNSIGNED_LONG: + value = * reinterpret_cast< const sal_Int32 * >( rAny.getValue() ); + return sal_True; + } + return sal_False; +} +//__________________________________________________________________________________________________ +inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_uInt32 & value ) +{ + switch (rAny.getValueTypeClass()) + { + case ::com::sun::star::uno::TypeClass_BYTE: + value = * reinterpret_cast< const sal_Int8 * >( rAny.getValue() ); + return sal_True; + case ::com::sun::star::uno::TypeClass_SHORT: + value = * reinterpret_cast< const sal_Int16 * >( rAny.getValue() ); + return sal_True; + case ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT: + value = * reinterpret_cast< const sal_uInt16 * >( rAny.getValue() ); + return sal_True; + case ::com::sun::star::uno::TypeClass_LONG: + case ::com::sun::star::uno::TypeClass_UNSIGNED_LONG: + value = * reinterpret_cast< const sal_uInt32 * >( rAny.getValue() ); + return sal_True; + } + return sal_False; +} +// hyper +//__________________________________________________________________________________________________ +inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Int64 & value ) +{ + switch (rAny.getValueTypeClass()) + { + case ::com::sun::star::uno::TypeClass_BYTE: + value = * reinterpret_cast< const sal_Int8 * >( rAny.getValue() ); + return sal_True; + case ::com::sun::star::uno::TypeClass_SHORT: + value = * reinterpret_cast< const sal_Int16 * >( rAny.getValue() ); + return sal_True; + case ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT: + value = * reinterpret_cast< const sal_uInt16 * >( rAny.getValue() ); + return sal_True; + case ::com::sun::star::uno::TypeClass_LONG: + value = * reinterpret_cast< const sal_Int32 * >( rAny.getValue() ); + return sal_True; + case ::com::sun::star::uno::TypeClass_UNSIGNED_LONG: + value = * reinterpret_cast< const sal_uInt32 * >( rAny.getValue() ); + return sal_True; + case ::com::sun::star::uno::TypeClass_HYPER: + case ::com::sun::star::uno::TypeClass_UNSIGNED_HYPER: + value = * reinterpret_cast< const sal_Int64 * >( rAny.getValue() ); + return sal_True; + } + return sal_False; +} +//__________________________________________________________________________________________________ +inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_uInt64 & value ) +{ + switch (rAny.getValueTypeClass()) + { + case ::com::sun::star::uno::TypeClass_BYTE: + value = * reinterpret_cast< const sal_Int8 * >( rAny.getValue() ); + return sal_True; + case ::com::sun::star::uno::TypeClass_SHORT: + value = * reinterpret_cast< const sal_Int16 * >( rAny.getValue() ); + return sal_True; + case ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT: + value = * reinterpret_cast< const sal_uInt16 * >( rAny.getValue() ); + return sal_True; + case ::com::sun::star::uno::TypeClass_LONG: + value = * reinterpret_cast< const sal_Int32 * >( rAny.getValue() ); + return sal_True; + case ::com::sun::star::uno::TypeClass_UNSIGNED_LONG: + value = * reinterpret_cast< const sal_uInt32 * >( rAny.getValue() ); + return sal_True; + case ::com::sun::star::uno::TypeClass_HYPER: + case ::com::sun::star::uno::TypeClass_UNSIGNED_HYPER: + value = * reinterpret_cast< const sal_uInt64 * >( rAny.getValue() ); + return sal_True; + } + return sal_False; +} +// float +//__________________________________________________________________________________________________ +inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, float & value ) +{ + switch (rAny.getValueTypeClass()) + { + case ::com::sun::star::uno::TypeClass_BYTE: + value = * reinterpret_cast< const sal_Int8 * >( rAny.getValue() ); + return sal_True; + case ::com::sun::star::uno::TypeClass_SHORT: + value = * reinterpret_cast< const sal_Int16 * >( rAny.getValue() ); + return sal_True; + case ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT: + value = * reinterpret_cast< const sal_uInt16 * >( rAny.getValue() ); + return sal_True; + case ::com::sun::star::uno::TypeClass_FLOAT: + value = * reinterpret_cast< const float * >( rAny.getValue() ); + return sal_True; + } + return sal_False; +} +// double +//__________________________________________________________________________________________________ +inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, double & value ) +{ + switch (rAny.getValueTypeClass()) + { + case ::com::sun::star::uno::TypeClass_BYTE: + value = * reinterpret_cast< const sal_Int8 * >( rAny.getValue() ); + return sal_True; + case ::com::sun::star::uno::TypeClass_SHORT: + value = * reinterpret_cast< const sal_Int16 * >( rAny.getValue() ); + return sal_True; + case ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT: + value = * reinterpret_cast< const sal_uInt16 * >( rAny.getValue() ); + return sal_True; + case ::com::sun::star::uno::TypeClass_LONG: + value = * reinterpret_cast< const sal_Int32 * >( rAny.getValue() ); + return sal_True; + case ::com::sun::star::uno::TypeClass_UNSIGNED_LONG: + value = * reinterpret_cast< const sal_uInt32 * >( rAny.getValue() ); + return sal_True; + case ::com::sun::star::uno::TypeClass_FLOAT: + value = * reinterpret_cast< const float * >( rAny.getValue() ); + return sal_True; + case ::com::sun::star::uno::TypeClass_DOUBLE: + value = * reinterpret_cast< const double * >( rAny.getValue() ); + return sal_True; + } + return sal_False; +} +// string +//__________________________________________________________________________________________________ +inline sal_Bool SAL_CALL operator >>= ( + const ::com::sun::star::uno::Any & rAny, ::rtl::OUString & value ) +{ + if (::com::sun::star::uno::TypeClass_STRING == rAny.getValueTypeClass()) + { + value = * reinterpret_cast< const ::rtl::OUString * >( rAny.getValue() ); + return sal_True; + } + return sal_False; +} +//__________________________________________________________________________________________________ +inline sal_Bool SAL_CALL operator == ( + const ::com::sun::star::uno::Any & rAny, const ::rtl::OUString & value ) +{ + return (::com::sun::star::uno::TypeClass_STRING == rAny.getValueTypeClass() && + value == * reinterpret_cast< const ::rtl::OUString * >( rAny.getValue() )); +} +// type +//__________________________________________________________________________________________________ +inline sal_Bool SAL_CALL operator >>= ( + const ::com::sun::star::uno::Any & rAny, ::com::sun::star::uno::Type & value ) +{ + if (::com::sun::star::uno::TypeClass_TYPE == rAny.getValueTypeClass()) + { + value = * reinterpret_cast< const ::com::sun::star::uno::Type * >( rAny.getValue() ); + return sal_True; + } + return sal_False; +} +//__________________________________________________________________________________________________ +inline sal_Bool SAL_CALL operator == ( + const ::com::sun::star::uno::Any & rAny, const ::com::sun::star::uno::Type & value ) +{ + return (::com::sun::star::uno::TypeClass_TYPE == rAny.getValueTypeClass() && + value == * reinterpret_cast< const ::com::sun::star::uno::Type * >( rAny.getValue() )); +} +// any +//__________________________________________________________________________________________________ +inline sal_Bool SAL_CALL operator >>= ( + const ::com::sun::star::uno::Any & rAny, ::com::sun::star::uno::Any & value ) +{ + value = rAny; + return sal_True; +} +// interface +//__________________________________________________________________________________________________ +inline sal_Bool SAL_CALL operator == ( + const ::com::sun::star::uno::Any & rAny, const ::com::sun::star::uno::BaseReference & value ) +{ + if (::com::sun::star::uno::TypeClass_INTERFACE == rAny.getValueTypeClass()) + { + ::com::sun::star::uno::XInterface * p1 = + * reinterpret_cast< ::com::sun::star::uno::XInterface * const * >( rAny.getValue() ); + if (p1 && p1 == value.get()) + return sal_True; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xI1( + p1, ::com::sun::star::uno::UNO_QUERY ); + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xI2( + value.get(), ::com::sun::star::uno::UNO_QUERY ); + return (xI1.is() && xI1.get() == xI2.get()); + } + return sal_False; +} + +// operator to compare to an any. +//__________________________________________________________________________________________________ +template< class C > +inline sal_Bool SAL_CALL operator == ( const ::com::sun::star::uno::Any & rAny, const C & value ) +{ + const ::com::sun::star::uno::Type & rType = ::getCppuType( &value ); + return ::uno_type_equalData( + const_cast< void * >( rAny.getValue() ), rAny.getValueTypeRef(), + const_cast< C * >( &value ), rType.getTypeLibType(), + ::com::sun::star::uno::cpp_queryInterface, + ::com::sun::star::uno::cpp_release ); +} + +} +} +} +} + +#endif diff --git a/cppu/inc/com/sun/star/uno/Reference.h b/cppu/inc/com/sun/star/uno/Reference.h new file mode 100644 index 000000000000..4db47ad47402 --- /dev/null +++ b/cppu/inc/com/sun/star/uno/Reference.h @@ -0,0 +1,342 @@ +/************************************************************************* + * + * $RCSfile: Reference.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_ +#define _COM_SUN_STAR_UNO_REFERENCE_H_ + +#ifndef _RTL_ALLOC_H_ +#include <rtl/alloc.h> +#endif + + +/** */ //for docpp +namespace com +{ +/** */ //for docpp +namespace sun +{ +/** */ //for docpp +namespace star +{ +/** */ //for docpp +namespace uno +{ + +class XInterface; + +/** Enum defining UNO_REF_NO_ACQUIRE for setting reference without acquiring a given interface. + <br> +*/ +enum __UnoReference_NoAcquire +{ + /** This enum value can be used for creating a reference granting a given + interface, i.e. transferring ownership to it. + <br> + */ + UNO_REF_NO_ACQUIRE = 0xbebeef +}; + +/** Base reference class holding/ acquiring an interface.<br> + Constructors acquire an interface while the destructor releases it. + This class serves as a base class for all template reference classes and + has been introduced due to compiler problems with templated operators ==, =!. + <br> +*/ +class BaseReference +{ + /** the interface pointer<br> + */ + XInterface * _pInterface; + +protected: + /** Default Constructor: + Sets null reference. + <br> + */ + inline BaseReference(); + /** Constructor: + Sets given interface pointer. + <br> + @param pInterface an interface pointer + */ + inline BaseReference( XInterface * pInterface ); + /** Constructor: + Sets reference to given interface pointer without acquiring it. + <br> + @param pInterface interface pointer + @param dummy UNO_REF_NO_ACQUIRE to force obvious distinction to other constructors + */ + inline BaseReference( XInterface * pInterface, __UnoReference_NoAcquire ); + /** Copy constructor: + Copies interface reference. + <br> + @param rRef another reference + */ + inline BaseReference( const BaseReference & rRef ); + /** Destructor: + Releases interface reference. + <br> + */ + inline ~BaseReference(); + +public: + // these are here to force memory de/allocation to sal lib. + inline static void * SAL_CALL operator new( size_t nSize ) throw() + { return ::rtl_allocateMemory( nSize ); } + inline static void SAL_CALL operator delete( void * pMem ) throw() + { ::rtl_freeMemory( pMem ); } + inline static void * SAL_CALL operator new( size_t, void * pMem ) throw() + { return pMem; } + inline static void SAL_CALL operator delete( void *, void * ) throw() + {} + + /** Sets interface pointer. An interface already set will be released. + <br> + @param pInterface an interface pointer + */ + inline void SAL_CALL set( XInterface * pInterface ); + /** Clears reference, i.e. releases interface. + Reference is null after clear() call. + <br> + */ + inline void SAL_CALL clear(); + /** Gets interface pointer. + This call does <b>not</b> acquire the interface. + <br> + @return <b>un</b>acquired interface pointer + */ + inline XInterface * SAL_CALL get() const + { return _pInterface; } + /** Checks if reference is null. + <br> + @return true if reference acquires an interface, i.e. is not null + */ + inline sal_Bool SAL_CALL is() const + { return (_pInterface != 0); } + /** Equality operator: compares two interfaces<br> + Checks if both references are null or refer to the same object. + <br> + @param rRef another reference + @return true if both references are null or refer to the same object, false otherwise + */ + inline sal_Bool SAL_CALL operator == ( const BaseReference & rRef ) const; + /** Unequality operator: compares two interfaces<br> + Checks if both references are null or refer to the same object. + <br> + @param rRef another reference + @return false if both references are null or refer to the same object, true otherwise + */ + inline sal_Bool SAL_CALL operator != ( const BaseReference & rRef ) const + { return (! operator == ( rRef )); } + + // needed for stl container operations, though this makes no sense on pointers + inline sal_Bool SAL_CALL operator < ( const BaseReference& rRef ) const + { return (_pInterface < rRef._pInterface); } +}; + +/** Enum defining UNO_QUERY and UNO_REF_NO_ACQUIRE for query interface constructor + of reference template. + <br> +*/ +enum __UnoReference_Query +{ + /** This enum value can be used for querying interface constructor of reference template. + <br> + */ + UNO_REF_QUERY = 0xdb0e121e, + UNO_QUERY = 0xdb0 +}; + +/** Template reference class for interface type derived from BaseReference. + A special constructor given the UNO_QUERY or UNO_REF_QUERY identifier queries interfaces + for reference type. + <br> +*/ +template< class interface_type > +class Reference : public BaseReference +{ +public: + // these are here to force memory de/allocation to sal lib. + static void * SAL_CALL operator new( size_t nSize ) throw() + { return ::rtl_allocateMemory( nSize ); } + static void SAL_CALL operator delete( void * pMem ) throw() + { ::rtl_freeMemory( pMem ); } + static void * SAL_CALL operator new( size_t, void * pMem ) throw() + { return pMem; } + static void SAL_CALL operator delete( void *, void * ) throw() + {} + + /** Default Constructor: + Sets null reference. + <br> + */ + inline Reference() + : BaseReference() + {} + /** Copy constructor: + Copies interface reference. + <br> + @param rRef another reference + */ + inline Reference( const Reference< interface_type > & rRef ) + : BaseReference( rRef ) + {} + /** Constructor: + Sets given interface pointer. + <br> + @param pInterface an interface pointer + */ + inline Reference( interface_type * pInterface ) + : BaseReference( pInterface ) + {} + + /** Constructor: + Sets given interface pointer without acquiring it. + <br> + @param pInterface another reference + @param dummy UNO_REF_NO_ACQUIRE to force obvious distinction to other constructors + */ + inline Reference( XInterface * pInterface, __UnoReference_NoAcquire ) + : BaseReference( pInterface, UNO_REF_NO_ACQUIRE ) + {} + + /** Constructor: + Queries given interface for reference interface type (<b>interface_type</b>). + <br> + @param rRef another reference + @param dummy UNO_QUERY or UNO_REF_QUERY to force obvious distinction to other constructors + */ + inline Reference( const BaseReference & rRef, __UnoReference_Query ) + : BaseReference( query( rRef ) ) + {} + /** Constructor: + Queries given interface for reference interface type (<b>interface_type</b>). + <br> + @param pInterface an interface pointer + @param dummy UNO_QUERY to force obvious distinction to other constructors + */ + inline Reference( XInterface * pInterface, __UnoReference_Query ) + : BaseReference( query( pInterface ) ) + {} + + /** Assignment operator: + Acquires given interface pointer and sets reference. + An interface already set will be released. + <br> + @param pInterface an interface pointer + @return this reference + */ + inline Reference< interface_type > & SAL_CALL operator = ( interface_type * pInterface ); + /** Assignment operator: + Acquires given interface reference and sets reference. + An interface already set will be released. + <br> + @param rRef an interface reference + @return this reference + */ + inline Reference< interface_type > & SAL_CALL operator = ( const Reference< interface_type > & rRef ) + { return operator = ( rRef.get() ); } + + /** Queries given interface for type <b>interface_type</b>. + <br> + @param pInterface interface pointer + @return interface reference of demanded type (may be null) + */ + inline static Reference< interface_type > SAL_CALL query( XInterface * pInterface ); + /** Queries given interface reference for type <b>interface_type</b>. + <br> + @param rRef interface reference + @return interface reference of demanded type (may be null) + */ + inline static Reference< interface_type > SAL_CALL query( const BaseReference & rRef ) + { return query( rRef.get() ); } + + /** Cast operatory to Reference< XInterface >: + Reference objects are binary compatible and any interface must be derived + from com.sun.star.uno.XInterface. + This a useful direct cast possibility. + <br> + */ + inline SAL_CALL operator const Reference< XInterface > & () const + { return * reinterpret_cast< const Reference< XInterface > * >( this ); } + + /** Dereference operator: + Used to call interface methods. + <br> + @return <b>un</b>acquired interface pointer + */ + interface_type * SAL_CALL operator -> () const + { return static_cast< interface_type * >( BaseReference::get() ); } + + /** Gets interface pointer. + This call does <b>not</b> acquire the interface. + <br> + @return <b>un</b>acquired interface pointer + */ + interface_type * SAL_CALL get() const + { return static_cast< interface_type * >( BaseReference::get() ); } +}; + +} +} +} +} + +#endif diff --git a/cppu/inc/com/sun/star/uno/Reference.hxx b/cppu/inc/com/sun/star/uno/Reference.hxx new file mode 100644 index 000000000000..adcc32fd493f --- /dev/null +++ b/cppu/inc/com/sun/star/uno/Reference.hxx @@ -0,0 +1,170 @@ +/************************************************************************* + * + * $RCSfile: Reference.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_ +#define _COM_SUN_STAR_UNO_REFERENCE_HXX_ + +#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_ +#include <com/sun/star/uno/Reference.h> +#endif +#ifndef _COM_SUN_STAR_UNO_XINTERFACE_HDL_ +#include <com/sun/star/uno/XInterface.hdl> +#endif +#ifndef _COM_SUN_STAR_UNO_GENFUNC_HXX_ +#include <com/sun/star/uno/genfunc.hxx> +#endif + +/** */ //for docpp +namespace com +{ +/** */ //for docpp +namespace sun +{ +/** */ //for docpp +namespace star +{ +/** */ //for docpp +namespace uno +{ + +//__________________________________________________________________________________________________ +inline BaseReference::BaseReference() + : _pInterface( 0 ) +{ +} +//__________________________________________________________________________________________________ +inline BaseReference::BaseReference( XInterface * pInterface ) + : _pInterface( pInterface ) +{ + if (_pInterface) + _pInterface->acquire(); +} +//__________________________________________________________________________________________________ +inline BaseReference::BaseReference( XInterface * pInterface, __UnoReference_NoAcquire ) + : _pInterface( pInterface ) +{ +} +//__________________________________________________________________________________________________ +inline BaseReference::BaseReference( const BaseReference & rRef ) + : _pInterface( rRef._pInterface ) +{ + if (_pInterface) + _pInterface->acquire(); +} +//__________________________________________________________________________________________________ +inline BaseReference::~BaseReference() +{ + if (_pInterface) + _pInterface->release(); +} +//__________________________________________________________________________________________________ +inline sal_Bool BaseReference::operator == ( const BaseReference & rRef ) const +{ + if (_pInterface == rRef._pInterface) + return sal_True; + // only the query to XInterface must return the same pointer if they belong to same objects + Reference< XInterface > x1( _pInterface, UNO_QUERY ); + Reference< XInterface > x2( rRef, UNO_QUERY ); + return (x1.get() == x2.get()); +} +//__________________________________________________________________________________________________ +inline void BaseReference::set( XInterface * pInterface ) +{ + if (pInterface != _pInterface) + { + if (pInterface) + pInterface->acquire(); + if (_pInterface) + _pInterface->release(); + _pInterface = pInterface; + } +} +//__________________________________________________________________________________________________ +inline void BaseReference::clear() +{ + if (_pInterface) + { + _pInterface->release(); + _pInterface = 0; + } +} + +//__________________________________________________________________________________________________ +template< class interface_type > +inline Reference< interface_type > & Reference< interface_type >::operator = ( interface_type * pInterface ) +{ + BaseReference::set( pInterface ); + return *this; +} +//__________________________________________________________________________________________________ +template< class interface_type > +inline Reference< interface_type > Reference< interface_type >::query( XInterface * pInterface ) +{ + const Type & rType = ::getCppuType( (const Reference< interface_type > *)0 ); + return Reference< interface_type >( reinterpret_cast< XInterface * >( + cpp_queryInterface( pInterface, rType.getTypeLibType() ) ), UNO_REF_NO_ACQUIRE ); +} + +} +} +} +} + +#endif diff --git a/cppu/inc/com/sun/star/uno/Sequence.h b/cppu/inc/com/sun/star/uno/Sequence.h new file mode 100644 index 000000000000..f87e78122e74 --- /dev/null +++ b/cppu/inc/com/sun/star/uno/Sequence.h @@ -0,0 +1,291 @@ +/************************************************************************* + * + * $RCSfile: Sequence.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_ +#define _COM_SUN_STAR_UNO_SEQUENCE_H_ + +#ifndef _CPPU_MACROS_HXX_ +#include <cppu/macros.hxx> +#endif + +#ifndef _TYPELIB_TYPEDESCRIPTION_H_ +#include <typelib/typedescription.h> +#endif +#ifndef _UNO_SEQUENCE2_H_ +#include <uno/sequence2.h> +#endif +#ifndef _COM_SUN_STAR_UNO_TYPE_H_ +#include <com/sun/star/uno/Type.h> +#endif + +#ifndef _RTL_ALLOC_H_ +#include <rtl/alloc.h> +#endif + + +namespace rtl +{ +class ByteSequence; +} + +/** */ //for docpp +namespace com +{ +/** */ //for docpp +namespace sun +{ +/** */ //for docpp +namespace star +{ +/** */ //for docpp +namespace uno +{ + +/** Template C++ class representing an IDL sequence<>. Template argument is + sequence element type<br> + C++ Sequences are reference counted and shared, so the sequence keeps a handle + to its data. + To keep value semantics, copies are only generated if the sequence is to be modified + (new handle). + <br> +*/ +template< class E > +class Sequence +{ + /** sequence handle<br> + */ + uno_Sequence * _pSequence; + +public: + // these are here to force memory de/allocation to sal lib. + inline static void * SAL_CALL operator new( size_t nSize ) throw() + { return ::rtl_allocateMemory( nSize ); } + inline static void SAL_CALL operator delete( void * pMem ) throw() + { ::rtl_freeMemory( pMem ); } + inline static void * SAL_CALL operator new( size_t, void * pMem ) throw() + { return pMem; } + inline static void SAL_CALL operator delete( void *, void * ) throw() + {} + + /** typedefs the element type of the sequence + <br> + */ + typedef E ElementType; + + /** Default constructor: + Creates an empty sequence. + <br> + */ + inline Sequence< E >(); + /** Copy constructor: + Creates a copy of given sequence. + <br> + @param rSeq another sequence of same type + */ + inline Sequence< E >( const Sequence< E > & rSeq ); + /** Constructor: + Creates a copy of given elements. + <br> + @param pElement an array of elements + @param len length of array + */ + inline Sequence< E >( const E * pElements, sal_Int32 len ); + /** Constructor: + Creates a default constructed sequence of given length. + <br> + @param len initial sequence length + */ + inline Sequence< E >( sal_Int32 len ); + /** Destructor: + Releases sequence handle. Last handle will destruct elements and free memory. + <br> + */ + inline ~Sequence< E >(); + + /** Assignment operator: + Acquires given sequence handle and releases previously set handle. + <br> + @param rSeq another sequence of same type + @return this sequence + */ + inline Sequence< E > & SAL_CALL operator = ( const Sequence< E > & rSeq ); + + /** Gets type of elements. + <br> + @return type of element + */ + inline const Type & getElementType() const + { return ::getCppuType( (const ElementType *)0 ); } + /** Gets length of sequence. + <br> + @return length of sequence + */ + inline sal_Int32 SAL_CALL getLength() const + { return _pSequence->nElements; } + + /** Gets a pointer to elements array for <b>reading</b>. + If the sequence has a length of 0, then the returned pointer is undefined. + <br> + @return pointer to elements array + */ + inline const E * SAL_CALL getConstArray() const + { return reinterpret_cast< const E * >( _pSequence->elements ); } + /** Gets a pointer to elements array for <b>reading and writing</b>.<br> + In general if the sequence has a handle acquired by other sequences + (reference count > 1), then a new sequence is created copy constructing + all elements to keep value semantics!<br> + If the sequence has a length of 0, then the returned pointer is undefined. + <br> + @return pointer to elements array + */ + inline E * SAL_CALL getArray(); + + /** Non-const index operator: + Obtains a reference to element indexed at given position.<br> + The implementation does <b>not</b> check for array bounds!<br> + In general if the sequence has a handle acquired by other sequences + (reference count > 1), then a new sequence is created copy constructing + all elements to keep value semantics! + <br> + @param nIndex index + @return non-const C++ reference to element + */ + inline E & SAL_CALL operator [] ( sal_Int32 nIndex ) + { return getArray()[ nIndex ]; } + /** Const index operator: + Obtains a reference to element indexed at given position.<br> + The implementation does <b>not</b> check for array bounds!<br> + <br> + @param nIndex index + @return const C++ reference to element + */ + inline const E & SAL_CALL operator [] ( sal_Int32 nIndex ) const + { return getConstArray()[ nIndex ]; } + + /** Equality operator: + Compares two sequences. + <br> + @param rSeq another sequence of same type (right side) + @return true if both sequences are equal, false otherwise + */ + inline sal_Bool SAL_CALL operator == ( const Sequence< E > & rSeq ) const; + /** Unequality operator: + Compares two sequences. + <br> + @param rSeq another sequence of same type (right side) + @return false if both sequences are equal, true otherwise + */ + inline sal_Bool SAL_CALL operator != ( const Sequence< E > & rSeq ) const + { return (! operator == ( rSeq )); } + + /** Reallocates sequence to new length. + If the new length is smaller than the former, then upper elements + will be destructed (and their memory freed). + If the new length is greater than the former, then upper (new) elements + are default constructed.<br> + If the sequence has a handle acquired by other sequences + (reference count > 1), then the remaining elements are copy constructed + to a new sequence handle to keep value semantics! + <br> + @param nSize new size of sequence + */ + inline void SAL_CALL realloc( sal_Int32 nSize ); +}; + +/** Creates an UNO byte sequence from a SAL byte sequence. + <br> + @param rByteSequence a byte sequence + @return an UNO byte sequence +*/ +inline ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL toUnoSequence( + const ::rtl::ByteSequence & rByteSequence ); + +} +} +} +} + +/** Gets the meta type of IDL sequence. + <br> + @param dummy typed pointer for function signature + @return type of IDL sequence +*/ +template< class S > +#if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)) +inline const ::com::sun::star::uno::Type +#else +inline const ::com::sun::star::uno::Type & +#endif +SAL_CALL getCppuType( const ::com::sun::star::uno::Sequence< S > * ); + +/** Gets the meta type of IDL <b>sequence< char ></b>. + This function has been introduced due to ambiguities with unsigned short. + <br> + @param dummy typed pointer for function signature + @return type of IDL <b>sequence< char ></b> +*/ +#if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)) +inline const ::com::sun::star::uno::Type +#else +inline const ::com::sun::star::uno::Type & +#endif +SAL_CALL getCharSequenceCppuType(); + +#endif diff --git a/cppu/inc/com/sun/star/uno/Sequence.hxx b/cppu/inc/com/sun/star/uno/Sequence.hxx new file mode 100644 index 000000000000..7b9e3065571e --- /dev/null +++ b/cppu/inc/com/sun/star/uno/Sequence.hxx @@ -0,0 +1,236 @@ +/************************************************************************* + * + * $RCSfile: Sequence.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_ +#define _COM_SUN_STAR_UNO_SEQUENCE_HXX_ + +#ifndef _CPPU_MACROS_HXX_ +#include <cppu/macros.hxx> +#endif + +#ifndef _OSL_INTERLCK_H_ +#include <osl/interlck.h> +#endif +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_ +#include <com/sun/star/uno/Sequence.h> +#endif +#ifndef _TYPELIB_TYPEDESCRIPTION_H_ +#include <typelib/typedescription.h> +#endif +#ifndef _UNO_DATA_H_ +#include <uno/data.h> +#endif +#ifndef _COM_SUN_STAR_UNO_GENFUNC_HXX_ +#include <com/sun/star/uno/genfunc.hxx> +#endif + + +/** */ //for docpp +namespace com +{ +/** */ //for docpp +namespace sun +{ +/** */ //for docpp +namespace star +{ +/** */ //for docpp +namespace uno +{ + +//__________________________________________________________________________________________________ +template< class E > +inline Sequence< E >::Sequence() +{ + const Type & rType = ::getCppuType( this ); + ::uno_type_sequence_construct( &_pSequence, rType.getTypeLibType(), 0, 0, cpp_acquire ); +} +//__________________________________________________________________________________________________ +template< class E > +inline Sequence< E >::Sequence( const Sequence< E > & rSeq ) +{ + ::osl_incrementInterlockedCount( &rSeq._pSequence->nRefCount ); + _pSequence = rSeq._pSequence; +} +//__________________________________________________________________________________________________ +template< class E > +inline Sequence< E >::Sequence( const E * pElements, sal_Int32 len ) + : _pSequence( 0 ) +{ + const Type & rType = ::getCppuType( this ); + ::uno_type_sequence_construct( &_pSequence, rType.getTypeLibType(), + const_cast< E * >( pElements ), len, cpp_acquire ); +} +//__________________________________________________________________________________________________ +template< class E > +inline Sequence< E >::Sequence( sal_Int32 len ) + : _pSequence( 0 ) +{ + const Type & rType = ::getCppuType( this ); + ::uno_type_sequence_construct( &_pSequence, rType.getTypeLibType(), 0, len, cpp_acquire ); +} +//__________________________________________________________________________________________________ +template< class E > +inline Sequence< E >::~Sequence() +{ + const Type & rType = ::getCppuType( this ); + ::uno_type_destructData( this, rType.getTypeLibType(), cpp_release ); +} +//__________________________________________________________________________________________________ +template< class E > +inline Sequence< E > & Sequence< E >::operator = ( const Sequence< E > & rSeq ) +{ + const Type & rType = ::getCppuType( this ); + ::uno_type_sequence_assign( &_pSequence, rSeq._pSequence, rType.getTypeLibType(), cpp_release ); + return *this; +} +//__________________________________________________________________________________________________ +template< class E > +inline sal_Bool Sequence< E >::operator == ( const Sequence< E > & rSeq ) const +{ + if (_pSequence == rSeq._pSequence) + return sal_True; + const Type & rType = ::getCppuType( this ); + return ::uno_type_equalData( const_cast< Sequence< E > * >( this ), rType.getTypeLibType(), + const_cast< Sequence< E > * >( &rSeq ), rType.getTypeLibType(), + cpp_queryInterface, cpp_release ); +} +//__________________________________________________________________________________________________ +template< class E > +inline E * Sequence< E >::getArray() +{ + const Type & rType = ::getCppuType( this ); + ::uno_type_sequence_reference2One( &_pSequence, rType.getTypeLibType(), cpp_acquire, cpp_release ); + return reinterpret_cast< E * >( _pSequence->elements ); +} +//__________________________________________________________________________________________________ +template< class E > +inline void Sequence< E >::realloc( sal_Int32 nSize ) +{ + const Type & rType = ::getCppuType( this ); + ::uno_type_sequence_realloc( &_pSequence, rType.getTypeLibType(), nSize, cpp_acquire, cpp_release ); +} + +//-------------------------------------------------------------------------------------------------- +inline ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL toUnoSequence( + const ::rtl::ByteSequence & rByteSequence ) +{ + return ::com::sun::star::uno::Sequence< sal_Int8 >( + * reinterpret_cast< const ::com::sun::star::uno::Sequence< sal_Int8 > * >( &rByteSequence ) ); +} + +} +} +} +} + +// generic sequence template +template< class S > +#if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)) +inline const ::com::sun::star::uno::Type +#else +inline const ::com::sun::star::uno::Type & +#endif +SAL_CALL getCppuType( const ::com::sun::star::uno::Sequence< S > * ) +{ +#if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)) + typelib_TypeDescriptionReference * s_pType = 0; +#else + static typelib_TypeDescriptionReference * s_pType = 0; + if (! s_pType) + { +#endif + const ::com::sun::star::uno::Type & rElementType = ::getCppuType( + (::com::sun::star::uno::Sequence< S >::ElementType *)0 ); + ::typelib_static_sequence_type_init( &s_pType, rElementType.getTypeLibType() ); +#if !( (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__))) + } + return * reinterpret_cast< const ::com::sun::star::uno::Type * >( &s_pType ); +#else + return ::com::sun::star::uno::Type( s_pType ); +#endif +} + +// char sequence +#if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)) +inline const ::com::sun::star::uno::Type +#else +inline const ::com::sun::star::uno::Type & +#endif +SAL_CALL getCharSequenceCppuType() +{ +#if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)) + typelib_TypeDescriptionReference * s_pType = 0; +#else + static typelib_TypeDescriptionReference * s_pType = 0; + if (! s_pType) + { +#endif + const ::com::sun::star::uno::Type & rElementType = ::getCharCppuType(); + ::typelib_static_sequence_type_init( &s_pType, rElementType.getTypeLibType() ); +#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__))) + } + return * reinterpret_cast< const ::com::sun::star::uno::Type * >( &s_pType ); +#else + return ::com::sun::star::uno::Type( s_pType ); +#endif +} + +#endif diff --git a/cppu/inc/com/sun/star/uno/Type.h b/cppu/inc/com/sun/star/uno/Type.h new file mode 100644 index 000000000000..7765d4e910ce --- /dev/null +++ b/cppu/inc/com/sun/star/uno/Type.h @@ -0,0 +1,364 @@ +/************************************************************************* + * + * $RCSfile: Type.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _COM_SUN_STAR_UNO_TYPE_H_ +#define _COM_SUN_STAR_UNO_TYPE_H_ + +#ifndef _TYPELIB_TYPEDESCRIPTION_H_ +#include <typelib/typedescription.h> +#endif +#ifndef _COM_SUN_STAR_UNO_TYPECLASS_HDL_ +#include <com/sun/star/uno/TypeClass.hdl> +#endif +#ifndef _CPPU_MACROS_HXX_ +#include <cppu/macros.hxx> +#endif +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif + +#ifndef _RTL_ALLOC_H_ +#include <rtl/alloc.h> +#endif + + +/** */ //for docpp +namespace com +{ +/** */ //for docpp +namespace sun +{ +/** */ //for docpp +namespace star +{ +/** */ //for docpp +namespace uno +{ + +/** Enum defining UNO_TYPE_NO_ACQUIRE for type description reference transfer. + <br> +*/ +enum __UnoType_NoAcquire +{ + /** This enum value can be used for creating a Type object granting a given + type description reference, i.e. transferring ownership to it. + <br> + */ + UNO_TYPE_NO_ACQUIRE = 0xbebeef1e +}; + +/** C++ class representing an IDL meta type. + This class is used to represent a a type, i.e. a type name and its type class.<br> + Internally the type holds a C type description reference of the runtime. + You can obtain a full type description of a type by calling member function + getDescription(). + <br> +*/ +class Type +{ + /** the C typelib reference pointer<br> + */ + typelib_TypeDescriptionReference * _pType; + +public: + // these are here to force memory de/allocation to sal lib. + inline static void * SAL_CALL operator new( size_t nSize ) throw() + { return ::rtl_allocateMemory( nSize ); } + inline static void SAL_CALL operator delete( void * pMem ) throw() + { ::rtl_freeMemory( pMem ); } + inline static void * SAL_CALL operator new( size_t, void * pMem ) throw() + { return pMem; } + inline static void SAL_CALL operator delete( void *, void * ) throw() + {} + + /** Default Constructor: + Type is set to void. + <br> + */ + inline Type(); + + /** Constructor: + Type is constructed by given name and type class. + <br> + @param eTypeClass type class of type + @param rTypeName name of type + */ + inline Type( TypeClass eTypeClass, const ::rtl::OUString & rTypeName ); + + /** Constructor: + Type is constructed by given name and type class. + <br> + @param eTypeClass type class of type + @param pTypeName name of type + */ + inline Type( TypeClass eTypeClass, const sal_Char * pTypeName ); + + /** Constructor: + Type is (copy) constructed by given C type description reference. + <br> + @param pType C type description reference + */ + inline Type( typelib_TypeDescriptionReference * pType ); + + /** Constructor: + Type is (copy) constructed by given C type description reference without acquiring it. + <br> + @param pType C type description reference + @param dummy UNO_TYPE_NO_ACQUIRE to force obvious distinction to other constructors + */ + inline Type( typelib_TypeDescriptionReference * pType, __UnoType_NoAcquire ); + + /** Copy constructor: + Type is copy constructed by given type. + <br> + @param rType another type + */ + inline Type( const Type & rType ); + + /** Destructor: + Releases acquired C type description reference. + <br> + */ + inline ~Type() + { ::typelib_typedescriptionreference_release( _pType ); } + + /** Assignment operator: + Acquires right side type and releases previously set type. + <br> + @param rType another type (right side) + @return this type + */ + inline Type & SAL_CALL operator = ( const Type & rType ); + + /** Gets the type class of set type. + <br> + @return type class of set type + */ + inline TypeClass SAL_CALL getTypeClass() const + { return (TypeClass)_pType->eTypeClass; } + + /** Gets the name of the set type. + <br> + @return name of the set type + */ + inline ::rtl::OUString SAL_CALL getTypeName() const + { return ::rtl::OUString( _pType->pTypeName ); } + + /** Obtains a full type description of set type. + <br> + @param ppDescr [inout] type description + */ + inline void SAL_CALL getDescription( typelib_TypeDescription ** ppDescr ) const + { ::typelib_typedescriptionreference_getDescription( ppDescr, _pType ); } + + /** Gets the C typelib type description reference pointer. + Does <b>not</b> acquire the reference! + <br> + @return <b>un</b>acquired type description reference + */ + inline typelib_TypeDescriptionReference * SAL_CALL getTypeLibType() const + { return _pType; } + + /** Compares two types. + <br> + @param rType another type + @return true if both types refer the same type, false otherwise + */ + inline sal_Bool SAL_CALL equals( const Type & rType ) const + { return ::typelib_typedescriptionreference_equals( _pType, rType._pType ); } + /** Equality operator: + Compares two types. + <br> + @param rType another type + @return true if both types refer the same type, false otherwise + */ + inline sal_Bool SAL_CALL operator == ( const Type & rType ) const + { return equals( rType ); } + /** Unequality operator: + Compares two types. + <br> + @param rType another type + @return false if both types refer the same type, true otherwise + */ + inline sal_Bool SAL_CALL operator != ( const Type & rType ) const + { return (! equals( rType )); } +}; + +} +} +} +} + +/** Gets the meta type of IDL type <b>type</b>. + <br> + @param dummy typed pointer for function signature + @return type of IDL type <b>type</b> +*/ +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const ::com::sun::star::uno::Type * ); + +/** Gets the meta type of IDL type <b>void</b>. + @return type of IDL type <b>void</b> +*/ +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuVoidType(); +/** Gets the meta type of IDL type <b>void</b>. + <br> + @return type of IDL type <b>void</b> +*/ +inline const ::com::sun::star::uno::Type & SAL_CALL getVoidCppuType(); + +/** Gets the meta type of IDL type <b>boolean</b>. + <br> + @return type of IDL type <b>boolean</b> +*/ +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuBooleanType(); +/** Gets the meta type of IDL type <b>boolean</b>. + <br> + @return type of IDL type <b>boolean</b> +*/ +inline const ::com::sun::star::uno::Type & SAL_CALL getBooleanCppuType(); +/** Gets the meta type of IDL type <b>boolean</b>. + <br> + @param dummy typed pointer for function signature + @return type of IDL type <b>boolean</b> +*/ +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Bool * ); + +/** Gets the meta type of IDL type <b>char</b>. + <br> + @return type of IDL type <b>char</b> +*/ +inline const ::com::sun::star::uno::Type & SAL_CALL getCharCppuType(); +/** Gets the meta type of IDL type <b>char</b>. + <br> + @return type of IDL type <b>char</b> +*/ +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuCharType(); + +/** Gets the meta type of IDL type <b>byte</b>. + <br> + @param dummy typed pointer for function signature + @return type of IDL type <b>byte</b> +*/ +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int8 * ); + +/** Gets the meta type of IDL type <b>string</b>. + <br> + @param dummy typed pointer for function signature + @return type of IDL type <b>string</b> +*/ +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const ::rtl::OUString * ); + +/** Gets the meta type of IDL type <b>short</b>. + <br> + @param dummy typed pointer for function signature + @return type of IDL type <b>short</b> +*/ +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int16 * ); + +/** Gets the meta type of IDL type <b>unsigned short</b>. + <br> + @param dummy typed pointer for function signature + @return type of IDL type <b>unsigned short</b> +*/ +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_uInt16 * ); + +/** Gets the meta type of IDL type <b>long</b>. + <br> + @param dummy typed pointer for function signature + @return type of IDL type <b>long</b> +*/ +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int32 * ); + +/** Gets the meta type of IDL type <b>unsigned long</b>. + <br> + @param dummy typed pointer for function signature + @return type of IDL type <b>unsigned long</b> +*/ +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_uInt32 * ); + +/** Gets the meta type of IDL type <b>hyper</b>. + <br> + @param dummy typed pointer for function signature + @return type of IDL type <b>hyper</b> +*/ +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int64 * ); + +/** Gets the meta type of IDL type <b>unsigned hyper</b>. + <br> + @param dummy typed pointer for function signature + @return type of IDL type <b>unsigned hyper</b> +*/ +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_uInt64 * ); + +/** Gets the meta type of IDL type <b>float</b>. + <br> + @param dummy typed pointer for function signature + @return type of IDL type <b>float</b> +*/ +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const float * ); + +/** Gets the meta type of IDL type <b>double</b>. + <br> + @param dummy typed pointer for function signature + @return type of IDL type <b>double</b> +*/ +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const double * ); + +#endif diff --git a/cppu/inc/com/sun/star/uno/Type.hxx b/cppu/inc/com/sun/star/uno/Type.hxx new file mode 100644 index 000000000000..f40eb7fb602d --- /dev/null +++ b/cppu/inc/com/sun/star/uno/Type.hxx @@ -0,0 +1,238 @@ +/************************************************************************* + * + * $RCSfile: Type.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _COM_SUN_STAR_UNO_TYPE_HXX_ +#define _COM_SUN_STAR_UNO_TYPE_HXX_ + +#ifndef _OSL_MUTEX_HXX_ +#include <osl/mutex.hxx> +#endif + +#ifndef _COM_SUN_STAR_UNO_TYPE_H_ +#include <com/sun/star/uno/Type.h> +#endif + + +/** */ //for docpp +namespace com +{ +/** */ //for docpp +namespace sun +{ +/** */ //for docpp +namespace star +{ +/** */ //for docpp +namespace uno +{ + +//__________________________________________________________________________________________________ +inline Type::Type() +{ + _pType = reinterpret_cast< const ::com::sun::star::uno::Type * >( + ::typelib_static_type_getByTypeClass( typelib_TypeClass_VOID ) )->getTypeLibType(); + ::typelib_typedescriptionreference_acquire( _pType ); +} +//__________________________________________________________________________________________________ +inline Type::Type( TypeClass eTypeClass, const ::rtl::OUString & rTypeName ) + : _pType( 0 ) +{ + ::typelib_typedescriptionreference_new( &_pType, (typelib_TypeClass)eTypeClass, rTypeName.pData ); +} +//__________________________________________________________________________________________________ +inline Type::Type( TypeClass eTypeClass, const sal_Char * pTypeName ) + : _pType( 0 ) +{ + ::typelib_typedescriptionreference_newByAsciiName( &_pType, (typelib_TypeClass)eTypeClass, pTypeName ); +} +//__________________________________________________________________________________________________ +inline Type::Type( typelib_TypeDescriptionReference * pType ) + : _pType( pType ) +{ + ::typelib_typedescriptionreference_acquire( _pType ); +} +//__________________________________________________________________________________________________ +inline Type::Type( typelib_TypeDescriptionReference * pType, __UnoType_NoAcquire ) + : _pType( pType ) +{ +} +//__________________________________________________________________________________________________ +inline Type::Type( const Type & rType ) + : _pType( rType._pType ) +{ + ::typelib_typedescriptionreference_acquire( _pType ); +} +//__________________________________________________________________________________________________ +inline Type & Type::operator = ( const Type & rType ) +{ + ::typelib_typedescriptionreference_assign( &_pType, rType._pType ); + return *this; +} + +} +} +} +} + +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const ::com::sun::star::uno::Type * ) +{ + return * reinterpret_cast< const ::com::sun::star::uno::Type * >( + ::typelib_static_type_getByTypeClass( typelib_TypeClass_TYPE ) ); +} + +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuVoidType() +{ + return * reinterpret_cast< const ::com::sun::star::uno::Type * >( + ::typelib_static_type_getByTypeClass( typelib_TypeClass_VOID ) ); +} +inline const ::com::sun::star::uno::Type & SAL_CALL getVoidCppuType() +{ + return * reinterpret_cast< const ::com::sun::star::uno::Type * >( + ::typelib_static_type_getByTypeClass( typelib_TypeClass_VOID ) ); +} + +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuBooleanType() +{ + return * reinterpret_cast< const ::com::sun::star::uno::Type * >( + ::typelib_static_type_getByTypeClass( typelib_TypeClass_BOOLEAN ) ); +} +inline const ::com::sun::star::uno::Type & SAL_CALL getBooleanCppuType() +{ + return * reinterpret_cast< const ::com::sun::star::uno::Type * >( + ::typelib_static_type_getByTypeClass( typelib_TypeClass_BOOLEAN ) ); +} +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Bool * ) +{ + return * reinterpret_cast< const ::com::sun::star::uno::Type * >( + ::typelib_static_type_getByTypeClass( typelib_TypeClass_BOOLEAN ) ); +} + +inline const ::com::sun::star::uno::Type & SAL_CALL getCharCppuType() +{ + return * reinterpret_cast< const ::com::sun::star::uno::Type * >( + ::typelib_static_type_getByTypeClass( typelib_TypeClass_CHAR ) ); +} +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuCharType() +{ + return * reinterpret_cast< const ::com::sun::star::uno::Type * >( + ::typelib_static_type_getByTypeClass( typelib_TypeClass_CHAR ) ); +} + +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int8 * ) +{ + return * reinterpret_cast< const ::com::sun::star::uno::Type * >( + ::typelib_static_type_getByTypeClass( typelib_TypeClass_BYTE ) ); +} + +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const ::rtl::OUString * ) +{ + return * reinterpret_cast< const ::com::sun::star::uno::Type * >( + ::typelib_static_type_getByTypeClass( typelib_TypeClass_STRING ) ); +} + +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int16 * ) +{ + return * reinterpret_cast< const ::com::sun::star::uno::Type * >( + ::typelib_static_type_getByTypeClass( typelib_TypeClass_SHORT ) ); +} + +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_uInt16 * ) +{ + return * reinterpret_cast< const ::com::sun::star::uno::Type * >( + ::typelib_static_type_getByTypeClass( typelib_TypeClass_UNSIGNED_SHORT ) ); +} + +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int32 * ) +{ + return * reinterpret_cast< const ::com::sun::star::uno::Type * >( + ::typelib_static_type_getByTypeClass( typelib_TypeClass_LONG ) ); +} + +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_uInt32 * ) +{ + return * reinterpret_cast< const ::com::sun::star::uno::Type * >( + ::typelib_static_type_getByTypeClass( typelib_TypeClass_UNSIGNED_LONG ) ); +} + +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_Int64 * ) +{ + return * reinterpret_cast< const ::com::sun::star::uno::Type * >( + ::typelib_static_type_getByTypeClass( typelib_TypeClass_HYPER ) ); +} + +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const sal_uInt64 * ) +{ + return * reinterpret_cast< const ::com::sun::star::uno::Type * >( + ::typelib_static_type_getByTypeClass( typelib_TypeClass_UNSIGNED_HYPER ) ); +} + +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const float * ) +{ + return * reinterpret_cast< const ::com::sun::star::uno::Type * >( + ::typelib_static_type_getByTypeClass( typelib_TypeClass_FLOAT ) ); +} + +inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( const double * ) +{ + return * reinterpret_cast< const ::com::sun::star::uno::Type * >( + ::typelib_static_type_getByTypeClass( typelib_TypeClass_DOUBLE ) ); +} + +#endif diff --git a/cppu/inc/com/sun/star/uno/genfunc.h b/cppu/inc/com/sun/star/uno/genfunc.h new file mode 100644 index 000000000000..853fb6828020 --- /dev/null +++ b/cppu/inc/com/sun/star/uno/genfunc.h @@ -0,0 +1,105 @@ +/************************************************************************* + * + * $RCSfile: genfunc.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _COM_SUN_STAR_UNO_GENFUNC_H_ +#define _COM_SUN_STAR_UNO_GENFUNC_H_ + +typedef struct _typelib_TypeDescriptionReference typelib_TypeDescriptionReference; + +/** */ //for docpp +namespace com +{ +/** */ //for docpp +namespace sun +{ +/** */ //for docpp +namespace star +{ +/** */ //for docpp +namespace uno +{ + +extern "C" +{ +/** C function to acquire a C++ interface. + <br> + @param pCppI C++ interface pointer +*/ +inline void SAL_CALL cpp_acquire( void * pCppI ); +/** C function to release a C++ interface. + <br> + @param pCppI C++ interface pointer +*/ +inline void SAL_CALL cpp_release( void * pCppI ); +/** C function to query for a C++ interface. + <br> + @param pCppI C++ interface pointer + @param pType demanded interface type + @return acquired C++ interface pointer or null +*/ +inline void * SAL_CALL cpp_queryInterface( void * pCppI, typelib_TypeDescriptionReference * pType ); +} + +} +} +} +} + +#endif diff --git a/cppu/inc/com/sun/star/uno/genfunc.hxx b/cppu/inc/com/sun/star/uno/genfunc.hxx new file mode 100644 index 000000000000..e392126a76c9 --- /dev/null +++ b/cppu/inc/com/sun/star/uno/genfunc.hxx @@ -0,0 +1,120 @@ +/************************************************************************* + * + * $RCSfile: genfunc.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _COM_SUN_STAR_UNO_GENFUNC_HXX_ +#define _COM_SUN_STAR_UNO_GENFUNC_HXX_ + +#ifndef _COM_SUN_STAR_UNO_GENFUNC_H_ +#include <com/sun/star/uno/genfunc.h> +#endif +#ifndef _COM_SUN_STAR_UNO_ANY_HXX_ +#include <com/sun/star/uno/Any.hxx> +#endif + + +/** */ //for docpp +namespace com +{ +/** */ //for docpp +namespace sun +{ +/** */ //for docpp +namespace star +{ +/** */ //for docpp +namespace uno +{ + +extern "C" +{ +//================================================================================================== +inline void SAL_CALL cpp_acquire( void * pCppI ) +{ + reinterpret_cast< XInterface * >( pCppI )->acquire(); +} +//================================================================================================== +inline void SAL_CALL cpp_release( void * pCppI ) +{ + reinterpret_cast< XInterface * >( pCppI )->release(); +} +//================================================================================================== +inline void * SAL_CALL cpp_queryInterface( void * pCppI, typelib_TypeDescriptionReference * pType ) +{ + if (pCppI) + { + Any aRet( reinterpret_cast< XInterface * >( pCppI )->queryInterface( + * reinterpret_cast< const Type * >( &pType ) ) ); + if (aRet.hasValue()) + { + XInterface * pRet = * reinterpret_cast< XInterface * const * >( aRet.getValue() ); + pRet->acquire(); + return pRet; + } + } + return 0; +} +} + +} +} +} +} + +#endif diff --git a/cppu/inc/cppu/macros.hxx b/cppu/inc/cppu/macros.hxx new file mode 100644 index 000000000000..5c9f6f62b9d0 --- /dev/null +++ b/cppu/inc/cppu/macros.hxx @@ -0,0 +1,160 @@ +/************************************************************************* + * + * $RCSfile: macros.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _CPPU_MACROS_HXX_ +#define _CPPU_MACROS_HXX_ + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif +#ifndef _UNO_LBNAMES_H_ +#include <uno/lbnames.h> +#endif + + +// Microsoft Visual C++ 4.x, 5.0, 6.0 +#if defined(_MSC_VER) +# if ( _MSC_VER < 1000 ) +# define CPPU_COMPILER_ERROR "msc version must be between 4.2 and 6.x" +# elif (_MSC_VER < 1100) // MSVC 4.x +# pragma warning( disable: 4290 ) +# define CPPU_CLBN_TMP UNO_LB_MSCI +# define CPPU_CLBN_NS_TMP UNO_LB_MSCI_NAMESPACE +# elif(_MSC_VER < 1200) // MSVC 5.0 +# define CPPU_CLBN_TMP UNO_LB_MSCI +# define CPPU_CLBN_NS_TMP UNO_LB_MSCI_NAMESPACE +# elif(_MSC_VER < 1300) // MSVC 6.0 +# define CPPU_CLBN_TMP UNO_LB_MSCI +# define CPPU_CLBN_NS_TMP UNO_LB_MSCI_NAMESPACE +# else +# define CPPU_COMPILER_ERROR "msc version must be between 4.2 and 6.x" +# endif + +// AIX xlC 3.1 , 3.0.1 ==0x301 +// Visual Age C++ 3.x +#elif ( defined (__xlC__) && __xlC__ < 0x400 ) || \ + ( defined ( __IBMCPP__ ) && ( __IBMCPP__ < 400 ) ) +# define CPPU_COMPILER_ERROR "visual age on aix not supported" + +// Borland C++ ( 5.x ) +#elif defined (BC50) +# define CPPU_COMPILER_ERROR "borland compiler not supported" + +#elif defined(__SUNPRO_CC) +# if ( __SUNPRO_CC < 0x500 ) +# define CPPU_COMPILER_ERROR "sunpro cc version must be 5.x" +# elif( __SUNPRO_CC < 0x600 ) +# define CPPU_CLBN_TMP UNO_LB_SUNPRO5 +# define CPPU_CLBN_NS_TMP UNO_LB_SUNPRO5_NAMESPACE +# else +# define CPPU_COMPILER_ERROR "sunpro cc version must be 5.x" +# endif + +// g++ 2.7.x +#elif defined __GNUC__ +// cygnus have a lot of version, let's assume the best. +// no specific definitions known except this one +# if ( __GNUC__ == 2 && __GNUC_MINOR__ == 7 ) +# define CPPU_COMPILER_ERROR "gcc 2.7 compiler not supported" +# elif ( __GNUC__ == 2 && __GNUC_MINOR__ == 91 ) +# define CPPU_CLBN_TMP UNO_LB_GCC2 +# define CPPU_CLBN_NS_TMP UNO_LB_GCC2_NAMESPACE +# elif ( __GNUC__ == 2 && __GNUC_MINOR__ == 95 ) +# define CPPU_CLBN_TMP UNO_LB_GCC2 +# define CPPU_CLBN_NS_TMP UNO_LB_GCC2_NAMESPACE +# else +# define CPPU_COMPILER_ERROR "gcc unknown version" +# endif + +#elif defined (__WATCOM_CPLUSPLUS__) +# define CPPU_COMPILER_ERROR "watcom compiler not supported" + +// Symantec 7.5 +#elif defined (__SC__) +# define CPPU_COMPILER_ERROR "symantec compiler not supported" + +// HP-UX und aCC +#elif defined(HPUX) && !defined(__GNUC__) +# define CPPU_COMPILER_ERROR "HP-UX compiler not supported" + +// MAC Metrowerks +#elif defined (__MWERKS__) +# define CPPU_COMPILER_ERROR "Metroworks compiler not supported" +#else +# define CPPU_COMPILER_ERROR "unknown compiler" +#endif + +#ifdef CPPU_COMPILER_ERROR +// set to unknown +# error CPPU_COMPILER_ERROR +#endif + +/** + The compiler and systems defines to identify compatibilities + use to mark an unknown system, processor or compiler +*/ +#define CPPU_CURRENT_LANGUAGE_BINDING_NAME CPPU_CLBN_TMP +#define CPPU_CURRENT_NAMESPACE CPPU_CLBN_NS_TMP + +#endif // _USR_MACROS_HXX_ + + + diff --git a/cppu/inc/typelib/typeclass.h b/cppu/inc/typelib/typeclass.h new file mode 100644 index 000000000000..7cace8fe0a6a --- /dev/null +++ b/cppu/inc/typelib/typeclass.h @@ -0,0 +1,133 @@ +/************************************************************************* + * + * $RCSfile: typeclass.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _TYPELIB_TYPECLASS_H_ +#define _TYPELIB_TYPECLASS_H_ + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +/** This type class enum is binary compatible with the IDL enum + com.sun.star.uno.TypeClass. + <br> +*/ +enum typelib_TypeClass +{ + /** type class of void<br> */ + typelib_TypeClass_VOID = 0, + /** type class of char<br> */ + typelib_TypeClass_CHAR = 1, + /** type class of boolean<br> */ + typelib_TypeClass_BOOLEAN = 2, + /** type class of byte<br> */ + typelib_TypeClass_BYTE = 3, + /** type class of short<br> */ + typelib_TypeClass_SHORT = 4, + /** type class of unsigned short<br> */ + typelib_TypeClass_UNSIGNED_SHORT = 5, + /** type class of long<br> */ + typelib_TypeClass_LONG = 6, + /** type class of unsigned long<br> */ + typelib_TypeClass_UNSIGNED_LONG = 7, + /** type class of hyper<br> */ + typelib_TypeClass_HYPER = 8, + /** type class of unsigned hyper<br> */ + typelib_TypeClass_UNSIGNED_HYPER = 9, + /** type class of float<br> */ + typelib_TypeClass_FLOAT = 10, + /** type class of double<br> */ + typelib_TypeClass_DOUBLE = 11, + /** type class of string<br> */ + typelib_TypeClass_STRING = 12, + /** type class of type<br> */ + typelib_TypeClass_TYPE = 13, + /** type class of any<br> */ + typelib_TypeClass_ANY = 14, + /** type class of enum<br> */ + typelib_TypeClass_ENUM = 15, + /** type class of typedef<br> */ + typelib_TypeClass_TYPEDEF = 16, + /** type class of struct<br> */ + typelib_TypeClass_STRUCT = 17, + /** type class of union<br> */ + typelib_TypeClass_UNION = 18, + /** type class of exception<br> */ + typelib_TypeClass_EXCEPTION = 19, + /** type class of sequence<br> */ + typelib_TypeClass_SEQUENCE = 20, + /** type class of array (not impl)<br> */ + typelib_TypeClass_ARRAY = 21, + /** type class of interface<br> */ + typelib_TypeClass_INTERFACE = 22, + /** type class of service (not impl)<br> */ + typelib_TypeClass_SERVICE = 23, + /** type class of module (not impl)<br> */ + typelib_TypeClass_MODULE = 24, + /** type class of interface method<br> */ + typelib_TypeClass_INTERFACE_METHOD = 25, + /** type class of interface attribute<br> */ + typelib_TypeClass_INTERFACE_ATTRIBUTE = 26, + /** type class of unknown<br> */ + typelib_TypeClass_UNKNOWN = 27, + typelib_TypeClass_MAKE_FIXED_SIZE = SAL_MAX_ENUM +}; + +#endif diff --git a/cppu/inc/typelib/typedescription.h b/cppu/inc/typelib/typedescription.h new file mode 100644 index 000000000000..81244f0d5158 --- /dev/null +++ b/cppu/inc/typelib/typedescription.h @@ -0,0 +1,910 @@ +/************************************************************************* + * + * $RCSfile: typedescription.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _TYPELIB_TYPEDESCRIPTION_H_ +#define _TYPELIB_TYPEDESCRIPTION_H_ + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif +#ifndef _TYPELIB_UIK_H_ +#include <typelib/uik.h> +#endif +#ifndef _TYPELIB_TYPECLASS_H_ +#include <typelib/typeclass.h> +#endif +#ifndef _RTL_USTRING_H_ +#include <rtl/ustring.h> +#endif + +typedef struct _typelib_TypeDescription typelib_TypeDescription; + +#ifdef __cplusplus +extern "C" +{ +#endif + +#ifdef SAL_W32 +#pragma pack(push, 8) +#elif defined(SAL_OS2) +#pragma pack(8) +#endif + +/** Holds a weak reference to a type description. + <br> +*/ +typedef struct _typelib_TypeDescriptionReference +{ + /** reference count of reference; + don't ever modify this by yourself, use + typelib_typedescriptionreference_acquire() and + typelib_typedescriptionreference_release() + <br> + */ + sal_Int32 nRefCount; + /** type class of type<br> + */ + typelib_TypeClass eTypeClass; + /** fully qualified name of type<br> + */ + rtl_uString * pTypeName; + /** pointer to full typedescription; this value is only valid if + the type is never swapped out<br> + */ + typelib_TypeDescription * pType; + /** pointer to optimize the runtime; not for public use<br> + */ + void * pUniqueIdentifier; + /** reserved for future use; 0 if not used<br> + */ + void * pReserved; +} typelib_TypeDescriptionReference; + +/** Full type description of a type. Memory layout of this struct + is identical to the typelib_TypeDescriptionReference for the first six members. + So a typedescription can be used as type reference. + <br> +*/ +typedef struct _typelib_TypeDescription +{ + /** reference count; + don't ever modify this by yourself, use + typelib_typedescription_acquire() and + typelib_typedescription_release() + <br> + */ + sal_Int32 nRefCount; + /** type class of type<br> + */ + typelib_TypeClass eTypeClass; + /** fully qualified name of type<br> + */ + rtl_uString * pTypeName; + /** pointer to self to distinguish reference from description; + for internal use only<br> + */ + typelib_TypeDescription * pSelf; + /** pointer to optimize the runtime; not for public use<br> + */ + void * pUniqueIdentifier; + /** reserved for future use; 0 if not used<br> + */ + void * pReserved; + + /** flag to determine whether the description is complete: + compound and union types lack of member names, + enums lack of member types and names, + interfaces lack of members and table init. + Call typelib_typedescription_complete() if false. + <br> + */ + sal_Bool bComplete; + /** size of type<br> + */ + sal_Int32 nSize; + /** alignment of type<br> + */ + sal_Int32 nAlignment; + /** pointer to weak reference<br> + */ + typelib_TypeDescriptionReference * pWeakRef; + /** determines, if type can be unloaded (and it is possible to reloaded it)<br> + */ + sal_Bool bOnDemand; +} typelib_TypeDescription; + +typedef struct _typelib_CompoundTypeDescription typelib_CompoundTypeDescription; + +/** Type description of a struct or exception. + <br> +*/ +typedef struct _typelib_CompoundTypeDescription +{ + /** inherits all members of typelib_TypeDescription<br> + */ + typelib_TypeDescription aBase; + + /** pointer to base type description, else 0<br> + */ + typelib_CompoundTypeDescription * pBaseTypeDescription; + + /** number of members<br> + */ + sal_Int32 nMembers; + /** byte offsets of each member including the size the base type<br> + */ + sal_Int32 * pMemberOffsets; + /** members of the struct or exception<br> + */ + typelib_TypeDescriptionReference ** ppTypeRefs; + /** member names of the struct or exception<br> + */ + rtl_uString ** ppMemberNames; +} typelib_CompoundTypeDescription; + +/** Type description of a union.<br> + The type class of this description is typelib_TypeClass_UNION. + <br> +*/ +typedef struct _typelib_UnionTypeDescription +{ + /** inherits all members of typelib_TypeDescription<br> + */ + typelib_TypeDescription aBase; + + /** type of the discriminant<br> + */ + typelib_TypeDescriptionReference * pDiscriminantTypeRef; + + /** union default descriminant<br> + */ + sal_Int64 nDefaultDiscriminant; + /** union default member type (may be 0)<br> + */ + typelib_TypeDescriptionReference * pDefaultTypeRef; + /** number of union member types<br> + */ + sal_Int32 nMembers; + /** union member discriminant values (same order as idl declaration)<br> + */ + sal_Int64 * pDiscriminants; + /** union member value types (same order as idl declaration)<br> + */ + typelib_TypeDescriptionReference ** ppTypeRefs; + /** union member value names (same order as idl declaration)<br> + */ + rtl_uString ** ppMemberNames; + /** union value offset for data access<br> + */ + sal_Int32 nValueOffset; +} typelib_UnionTypeDescription; + +/** Type description of an array or sequence. + <br> +*/ +typedef struct _typelib_IndirectTypeDescription +{ + /** inherits all members of typelib_TypeDescription<br> + */ + typelib_TypeDescription aBase; + + /** array, sequence: pointer to element type<br> + */ + typelib_TypeDescriptionReference * pType; +} typelib_IndirectTypeDescription; + +/** Type description of an enum.<br> + The type class of this description is typelib_TypeClass_ENUM. + <br> +*/ +typedef struct _typelib_EnumTypeDescription +{ + /** inherits all members of typelib_TypeDescription<br> + */ + typelib_TypeDescription aBase; + + /** first value of the enum<br> + */ + sal_Int32 nDefaultEnumValue; + /** number of enum values<br> + */ + sal_Int32 nEnumValues; + /** names of enum values<br> + */ + rtl_uString ** ppEnumNames; + /** values of enum (corresponding to names in similar order)<br> + */ + sal_Int32 * pEnumValues; +} typelib_EnumTypeDescription; + +/** Description of an interface method parameter. + <br> +*/ +typedef struct _typelib_MethodParameter +{ + /** name of parameter<br> + */ + rtl_uString * pName; + /** type of parameter<br> + */ + typelib_TypeDescriptionReference * pTypeRef; + /** true: the call type of this parameter is [in] or [inout] + false: the call type of this parameter is [out]<br> + */ + sal_Bool bIn; + /** true: the call type of this parameter is [out] or [inout] + false: the call type of this parameter is [in]<br> + */ + sal_Bool bOut; +} typelib_MethodParameter; + +/** Common base type description of + typelib_InterfaceMemberTypeDescription and + typelib_InterfaceAttributeTypeDescription. + <br> +*/ +typedef struct _typelib_InterfaceMemberTypeDescription +{ + /** inherits all members of typelib_TypeDescription<br> + */ + typelib_TypeDescription aBase; + + /** position of member in the interface including the number of members + of the base interface<br> + */ + sal_Int32 nPosition; + /** name of member<br> + */ + rtl_uString * pMemberName; +} typelib_InterfaceMemberTypeDescription; + +/** Type description of an interface method.<br> + The type class of this description is typelib_TypeClass_INTERFACE_METHOD. + The size and the alignment are 0. + <br> +*/ +typedef struct _typelib_InterfaceMethodTypeDescription +{ + /** inherits all members of typelib_InterfaceMemberTypeDescription<br> + */ + typelib_InterfaceMemberTypeDescription aBase; + + /** type of the return value<br> + */ + typelib_TypeDescriptionReference * pReturnTypeRef; + /** number of parameters<br> + */ + sal_Int32 nParams; + /** array of parameters<br> + */ + typelib_MethodParameter * pParams; + /** number of exceptions<br> + */ + sal_Int32 nExceptions; + /** array of exception types<br> + */ + typelib_TypeDescriptionReference ** ppExceptions; + /** determines whether method is declared oneway<br> + */ + sal_Bool bOneWay; +} typelib_InterfaceMethodTypeDescription; + +/** The description of an interface attribute.<br> + The type class of this description is typelib_TypeClass_INTERFACE_ATTRIBUTE. + The size and the alignment are 0. + <br> +*/ +typedef struct _typelib_InterfaceAttributeTypeDescription +{ + /** inherits all members of typelib_InterfaceMemberTypeDescription<br> + */ + typelib_InterfaceMemberTypeDescription aBase; + + /** determines whether attribute is read only<br> + */ + sal_Bool bReadOnly; + /** type of the attribute<br> + */ + typelib_TypeDescriptionReference * pAttributeTypeRef; +} typelib_InterfaceAttributeTypeDescription; + +typedef struct _typelib_InterfaceTypeDescription typelib_InterfaceTypeDescription; + +/** Type description of an interface. + <br> +*/ +typedef struct _typelib_InterfaceTypeDescription +{ + /** inherits all members of typelib_TypeDescription<br> + */ + typelib_TypeDescription aBase; + + /** pointer to base type description, else 0<br> + */ + typelib_InterfaceTypeDescription * pBaseTypeDescription; + /** unique identifier of interface<br> + */ + typelib_Uik aUik; + /** number of members<br> + */ + sal_Int32 nMembers; + /** array of members; references attributes or methods<br> + */ + typelib_TypeDescriptionReference ** ppMembers; + /** number of members including members of base interface<br> + */ + sal_Int32 nAllMembers; + /** array of members including members of base interface; + references attributes or methods<br> + */ + typelib_TypeDescriptionReference ** ppAllMembers; + /** array mapping index of the member description to an index + doubling for read-write attributes (called function index); + size of array is nAllMembers<br> + */ + sal_Int32 * pMapMemberIndexToFunctionIndex; + /** number of members plus number of read-write attributes<br> + */ + sal_Int32 nMapFunctionIndexToMemberIndex; + /** array mapping function index to member index; + size of arry is nMapFunctionIndexToMemberIndex<br> + */ + sal_Int32 * pMapFunctionIndexToMemberIndex; +} typelib_InterfaceTypeDescription; + +/** Init struct of compound members for typelib_typedescription_new(). + <br> +*/ +typedef struct _typelib_CompoundMember_Init +{ + /** type class of compound member<br> + */ + typelib_TypeClass eTypeClass; + /** name of type of compound member<br> + */ + rtl_uString * pTypeName; + /** name of compound member<br> + */ + rtl_uString * pMemberName; +} typelib_CompoundMember_Init; + +/** Init struct of interface methods for typelib_typedescription_new(). + <br> +*/ +typedef struct _typelib_Parameter_Init +{ + /** type class of parameter<br> + */ + typelib_TypeClass eTypeClass; + /** name of parameter<br> + */ + rtl_uString * pTypeName; + /** name of parameter<br> + */ + rtl_uString * pParamName; + /** true, if parameter is [in] or [inout]<br> + */ + sal_Bool bIn; + /** true, if parameter is [out] or [inout]<br> + */ + sal_Bool bOut; +} typelib_Parameter_Init; + +/** Init struct of union types for typelib_typedescription_newUnion(). + <br> +*/ +typedef struct _typelib_Union_Init +{ + /** union member discriminant<br> + */ + sal_Int64 nDiscriminant; + /** union member name<br> + */ + rtl_uString * pMemberName; + /** union member type<br> + */ + typelib_TypeDescriptionReference* pTypeRef; +} typelib_Union_Init; + +#ifdef SAL_W32 +#pragma pack(pop) +#elif defined(SAL_OS2) +#pragma pack() +#endif + + +/** Creates a union type description.<br> + All discriminants are handled as int64 values. + The pDiscriminantTypeRef must be of type byte, short, ..., up to hyper. + <br> + @param ppRet inout union type description + @param pTypeName name of union type + @param pDiscriminantTypeRef discriminant type + @param nDefaultDiscriminant default discriminant + @param pDefaultTypeRef default value type of union + @param nMembers number of union members + @param pMembers init members +*/ +SAL_DLLEXPORT void SAL_CALL typelib_typedescription_newUnion( + typelib_TypeDescription ** ppRet, + rtl_uString * pTypeName, + typelib_TypeDescriptionReference * pDiscriminantTypeRef, + sal_Int64 nDefaultDiscriminant, + typelib_TypeDescriptionReference * pDefaultTypeRef, + sal_Int32 nMembers, + typelib_Union_Init * pMembers ); + +/** Creates an enum type description. + <br> + @param ppRet inout enum type description + @param pTypeName name of enum + @param nDefaultEnumValue default enum value + @param nEnumValues number of enum values + @param ppEnumNames names of enum values + @param pEnumValues enum values +*/ +SAL_DLLEXPORT void SAL_CALL typelib_typedescription_newEnum( + typelib_TypeDescription ** ppRet, + rtl_uString * pTypeName, + sal_Int32 nDefaultValue, + sal_Int32 nEnumValues, + rtl_uString ** ppEnumNames, + sal_Int32 * pEnumValues ); + +/** Creates a new type description. + <br> + @param ppRet inout type description + @param eTypeClass type class + @param pTypeName name of type + @param pType sequence, array: element type; + struct, Exception: base type; + @param nMembers number of members if struct, exception + @param pMember array of members if struct, exception +*/ +SAL_DLLEXPORT void SAL_CALL typelib_typedescription_new( + typelib_TypeDescription ** ppRet, + typelib_TypeClass eTypeClass, + rtl_uString * pTypeName, + typelib_TypeDescriptionReference * pType, + sal_Int32 nMembers, + typelib_CompoundMember_Init * pMembers ); + +/** Creates an interface type description. + <br> + @param ppRet inout interface type description + @param pTypeName the fully qualified name of the interface. + @param nUik1 uik part + @param nUik2 uik part + @param nUik3 uik part + @param nUik4 uik part + @param nUik5 uik part + @param pBaseInterface base interface type, else 0 + @param nMembers number of members + @param ppMembers members; attributes or methods +*/ +SAL_DLLEXPORT void SAL_CALL typelib_typedescription_newInterface( + typelib_InterfaceTypeDescription ** ppRet, + rtl_uString * pTypeName, + sal_uInt32 nUik1, sal_uInt16 nUik2, sal_uInt16 nUik3, sal_uInt32 nUik4, sal_uInt32 nUik5, + typelib_TypeDescriptionReference * pBaseInterface, + sal_Int32 nMembers, + typelib_TypeDescriptionReference ** ppMembers ); + +/** Creates an interface method type description. + <br> + @param ppRet inout method type description + @param nAbsolutePosition position of member including all members of base interfaces + @param bOneWay determines whether method is declared oneway + @param pTypeName fully qualified name of method including interface name + @param eReturnTypeClass type class of return type + @param pReturnTypeName type name of the return type + @param nParams number of parameters + @param pParams parameter types + @param nExceptions number of exceptions + @param ppExceptionNames type names of exceptions +*/ +SAL_DLLEXPORT void SAL_CALL typelib_typedescription_newInterfaceMethod( + typelib_InterfaceMethodTypeDescription ** ppRet, + sal_Int32 nAbsolutePosition, + sal_Bool bOneWay, + rtl_uString * pMethodName, + typelib_TypeClass eReturnTypeClass, + rtl_uString * pReturnTypeName, + sal_Int32 nParams, + typelib_Parameter_Init * pParams, + sal_Int32 nExceptions, + rtl_uString ** ppExceptionNames ); + +/** Creates an interface attribute type description. + <br> + @param ppRet inout attribute type description + @param nAbsolutePosition position of this attribute including all members of base interfaces + @param pTypeName fully qualified name of attribute including interface name + @param eAttributeTypeClass type class of attribute type + @param pAttributeTypeName type name of attribute type +*/ +SAL_DLLEXPORT void SAL_CALL typelib_typedescription_newInterfaceAttribute( + typelib_InterfaceAttributeTypeDescription ** ppRet, + sal_Int32 nAbsolutePosition, + rtl_uString * pAttributeName, + typelib_TypeClass eAttributeTypeClass, + rtl_uString * pAttributeTypeName, + sal_Bool bReadOnly ); + +/** Increments reference count of given type description. + <br> + @param pDesc type description +*/ +SAL_DLLEXPORT void SAL_CALL typelib_typedescription_acquire( typelib_TypeDescription * pDesc ); + +/** Decrements reference count of given type.<br> + If reference count reaches 0, the trype description is deleted. + <br> + @param pDesc type description +*/ +SAL_DLLEXPORT void SAL_CALL typelib_typedescription_release( typelib_TypeDescription * pDesc ); + +/** Registers a type description and creates a type description reference.<br> + Type descriptions will be registered automatically if they are provided + via the callback chain. + @param ppNewDescription inout description to be registered; +*/ +SAL_DLLEXPORT void SAL_CALL typelib_typedescription_register( + typelib_TypeDescription ** ppNewDescription ); + +/** Tests whether two types descriptions are equal, i.e. type class and names are equal. + <br> + @param p1 a type description + @param p2 another type description + @return true, if type descriptions are equal +*/ +SAL_DLLEXPORT sal_Bool SAL_CALL typelib_typedescription_equals( + const typelib_TypeDescription * p1, const typelib_TypeDescription * p2 ); + +/** Retrieves a type description via its fully qualified name. + <br> + @param ppRet inout type description; *ppRet is 0, if type description was not found + @param pName name demanded type description +*/ +SAL_DLLEXPORT void SAL_CALL typelib_typedescription_getByName( + typelib_TypeDescription ** ppRet, rtl_uString * pName ); + +/** Sets size of type description cache. + <br> + @param nNewSize new size of cache +*/ +SAL_DLLEXPORT void SAL_CALL typelib_setCacheSize( sal_Int32 nNewSize ); + +/** Function pointer declaration of callback function get additional descriptions. + Callbacks <b>must</b> provide <b>complete</b> type descriptions! + <br> + @param pContext callback context + @param ppRet inout type description + @param pTypeName name of demanded type description +*/ +typedef void (SAL_CALL * typelib_typedescription_Callback)( + void * pContext, typelib_TypeDescription ** ppRet, rtl_uString * pTypeName ); + +/** Registers callback function providing additional type descriptions. + <br> + @param pContext callback context + @param pCallback callback function +*/ +SAL_DLLEXPORT void SAL_CALL typelib_typedescription_registerCallback( + void * pContext, typelib_typedescription_Callback pCallback ); + +/** Revokes a previously registered callback function. + <br> + @param pContext callback context + @param pCallback registered callback function +*/ +SAL_DLLEXPORT void SAL_CALL typelib_typedescription_revokeCallback( + void * pContext, typelib_typedescription_Callback pCallback ); + + +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ + +/* Returns true, if the type description reference may lose the type + description. Otherwise pType is a valid pointer and cannot + be discarded through the lifetime of this reference. + Remark: If the pWeakObj of the type is set too, you can avoid + the call of ...getDescription(...) and use the description + direct. pWeakObj == 0 means, that the description is not + initialized. +*/ +#define TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK( eTypeClass ) \ + ((eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || \ + (eTypeClass) == typelib_TypeClass_INTERFACE_ATTRIBUTE) + +/* Gets a description from the reference. The description may not be locked + by this call. You must use the TYPELIB_DANGER_RELEASE macro to release + the description fetched with this macro. +*/ +#define TYPELIB_DANGER_GET( ppDescription, pTypeRef ) \ +{ \ + typelib_TypeDescriptionReference * __pMacroTypeRef = (pTypeRef); \ + if (TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK( __pMacroTypeRef->eTypeClass )) \ + { \ + typelib_typedescriptionreference_getDescription( ppDescription, __pMacroTypeRef ); \ + } \ + else if (! __pMacroTypeRef->pType->pWeakRef) \ + { \ + typelib_typedescriptionreference_getDescription( ppDescription, __pMacroTypeRef ); \ + typelib_typedescription_release( *(ppDescription) ); \ + } \ + else \ + { \ + *(ppDescription) = __pMacroTypeRef->pType; \ + } \ +} + +/* Releases the description previouse fetched by TYPELIB_DANGER_GET. +*/ +#define TYPELIB_DANGER_RELEASE( pDescription ) \ +{ \ + if (TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK( (pDescription)->eTypeClass )) \ + typelib_typedescription_release( pDescription ); \ +} + +/** Creates a type description reference.<br> + This is a weak reference <b>not</b> holding the description. + If the description is already registered, the previous one is returned. + <br> + @param ppTDR inout type description reference + @param eTypeClass type class of type + @param pTypeName name of type +*/ +SAL_DLLEXPORT void SAL_CALL typelib_typedescriptionreference_new( + typelib_TypeDescriptionReference ** ppTDR, + typelib_TypeClass eTypeClass, + rtl_uString * pTypeName ); + +/** Creates a type description reference.<br> + This is a weak reference <b>not</b> holding the description. + If the description is already registered, the previous one is returned. + <br> + @param ppTDR inout type description reference + @param eTypeClass type class of type + @param pTypeName ascii name of type +*/ +SAL_DLLEXPORT void SAL_CALL typelib_typedescriptionreference_newByAsciiName( + typelib_TypeDescriptionReference ** ppTDR, + typelib_TypeClass eTypeClass, + const sal_Char * pTypeName ); + +/** Increments reference count of type description reference. + <br> + @param pRef type description reference +*/ +SAL_DLLEXPORT void SAL_CALL typelib_typedescriptionreference_acquire( + typelib_TypeDescriptionReference * pRef ); + +/** Increments reference count of type description reference. + If the reference count reaches 0, the reference is deleted. + <br> + @param pRef type description reference +*/ +SAL_DLLEXPORT void SAL_CALL typelib_typedescriptionreference_release( + typelib_TypeDescriptionReference * pRef ); + +/** Retrieves the type description for a given reference.<br> + If it is not possible to resolve the reference, null is returned. + <br> + @param ppRet inout type description +*/ +SAL_DLLEXPORT void SAL_CALL typelib_typedescriptionreference_getDescription( + typelib_TypeDescription ** ppRet, typelib_TypeDescriptionReference * pRef ); + +/** Tests whether two types description references are equal, i.e. type class and names are equal. + <br> + @param p1 a type description reference + @param p2 another type description reference + @return true, if type description references are equal +*/ +SAL_DLLEXPORT sal_Bool SAL_CALL typelib_typedescriptionreference_equals( + const typelib_TypeDescriptionReference * p1, const typelib_TypeDescriptionReference * p2 ); + +/** Assigns a type. + <br> + @param ppDest destination type + @param pSource source type +*/ +SAL_DLLEXPORT void SAL_CALL typelib_typedescriptionreference_assign( + typelib_TypeDescriptionReference ** ppDest, + typelib_TypeDescriptionReference * pSource ); + +/** Tests if values of type pAssignable can be assigned by values of type pFrom. + This includes widening conversion (e.g., long assignable from short), as long + as there is <b>no</b> data loss. + <br> + @param pAssignable type description of value to be assigned + @param pFrom type description of value +*/ +SAL_DLLEXPORT sal_Bool SAL_CALL typelib_typedescription_isAssignableFrom( + typelib_TypeDescription * pAssignable, + typelib_TypeDescription * pFrom ); + +/** Tests if values of type pAssignable can be assigned by values of type pFrom. + This includes widening conversion (e.g., long assignable from short), as long + as there is <b>no</b> data loss. + <br> + @param pAssignable type of value to be assigned + @param pFrom type of value +*/ +SAL_DLLEXPORT sal_Bool SAL_CALL typelib_typedescriptionreference_isAssignableFrom( + typelib_TypeDescriptionReference * pAssignable, + typelib_TypeDescriptionReference * pFrom ); + +/** Gets static type reference of standard types by type class. + ==OPTIMIZATION HACK==: + provides Type com.sun.star.uno.Exception for typelib_TypeClass_EXCEPTION + and com.sun.star.uno.XInterface for typelib_TypeClass_INTERFACE. + <br> + Thread synchronizes on typelib mutex. + <br> + @param eTypeClass type class of basic type + @return pointer to type reference pointer +*/ +SAL_DLLEXPORT typelib_TypeDescriptionReference ** SAL_CALL typelib_static_type_getByTypeClass( + typelib_TypeClass eTypeClass ); + +/** Inits static type reference. + Thread synchronizes on typelib init mutex. + <br> + @param ppRef pointer to type reference pointer + @param eTypeClass type class of type + @param pTypeName ascii name of type +*/ +SAL_DLLEXPORT void SAL_CALL typelib_static_type_init( + typelib_TypeDescriptionReference ** ppRef, + typelib_TypeClass eTypeClass, const sal_Char * pTypeName ); + +/** Inits static sequence type reference. + Thread synchronizes on typelib init mutex. + <br> + @param ppRef pointer to type reference pointer + @param pElementType element type of sequence +*/ +SAL_DLLEXPORT void SAL_CALL typelib_static_sequence_type_init( + typelib_TypeDescriptionReference ** ppRef, + typelib_TypeDescriptionReference * pElementType ); + +/** Inits <b>in</b>complete static compound type reference. + Thread synchronizes on typelib init mutex. + <br> + @param ppRef pointer to type reference pointer + @param eTypeClass typelib_TypeClass_STRUCT or typelib_TypeClass_EXCEPTION + @param pTypeName name of type + @param pBaseType base type + @param nMembers number of members + @param ppMembers member types +*/ +SAL_DLLEXPORT void SAL_CALL typelib_static_compound_type_init( + typelib_TypeDescriptionReference ** ppRef, + typelib_TypeClass eTypeClass, const sal_Char * pTypeName, + typelib_TypeDescriptionReference * pBaseType, + sal_Int32 nMembers, typelib_TypeDescriptionReference ** ppMembers ); + +/** Inits <b>in</b>complete static interface type reference. + Thread synchronizes on typelib init mutex. + <br> + @param ppRef pointer to type reference pointer + @param pTypeName name of interface + @param pBaseType base type +*/ +SAL_DLLEXPORT void SAL_CALL typelib_static_interface_type_init( + typelib_TypeDescriptionReference ** ppRef, + const sal_Char * pTypeName, + typelib_TypeDescriptionReference * pBaseType ); + +/** Inits <b>in</b>complete static enum type reference. + Thread synchronizes on typelib init mutex. + <br> + @param ppRef pointer to type reference pointer + @param pTypeName name of enum + @param nDefaultEnumValue default enum value +*/ +SAL_DLLEXPORT void SAL_CALL typelib_static_enum_type_init( + typelib_TypeDescriptionReference ** ppRef, + const sal_Char * pTypeName, + sal_Int32 nDefaultValue ); + +/** Inits <b>in</b>complete static compound type reference. + Thread synchronizes on typelib init mutex. + All discriminants are handled as int64 values. + The pDiscriminantTypeRef must be of type byte, short, ..., up to hyper. + <br> + @param ppRef pointer to type reference pointer + @param pTypeName name of union type + @param pDiscriminantType discriminant type + @param nDefaultDiscriminant default discriminant + @param pDefaultType default value type of union + @param nMembers number of union members + @param pDiscriminants member discriminants + @param pMemberTypes member types +*/ +SAL_DLLEXPORT void SAL_CALL typelib_static_union_type_init( + typelib_TypeDescriptionReference ** ppRef, + const sal_Char * pTypeName, + typelib_TypeDescriptionReference * pDiscriminantType, + sal_Int64 nDefaultDiscriminant, + typelib_TypeDescriptionReference * pDefaultType, + sal_Int32 nMembers, + sal_Int64 * pDiscriminants, + typelib_TypeDescriptionReference ** pMemberTypes ); + +/** Completes a typedescription to be used for, e.g., marshalling values. + COMPOUND, UNION, INTERFACE and ENUM type descriptions may be partly + initialized (see typelib_static_...(), typelib_TypeDescription::bComplete). + For interface type descriptions, this will also init index tables. + <br> + @param ppTypeDescr [inout] type description to be completed (may be exchanged!) + @return true, if type description is complete +*/ +SAL_DLLEXPORT sal_Bool SAL_CALL typelib_typedescription_complete( + typelib_TypeDescription ** ppTypeDescr ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cppu/inc/typelib/typedescription.hxx b/cppu/inc/typelib/typedescription.hxx new file mode 100644 index 000000000000..305e54b59acc --- /dev/null +++ b/cppu/inc/typelib/typedescription.hxx @@ -0,0 +1,256 @@ +/************************************************************************* + * + * $RCSfile: typedescription.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _TYPELIB_TYPEDESCRIPTION_HXX_ +#define _TYPELIB_TYPEDESCRIPTION_HXX_ + +#ifndef _RTL_USTRING_ +#include <rtl/ustring> +#endif +#ifndef _COM_SUN_STAR_UNO_TYPE_H_ +#include <com/sun/star/uno/Type.h> +#endif +#ifndef _TYPELIB_TYPEDESCRIPTION_H +#include <typelib/typedescription.h> +#endif + +/** */ //for docpp +namespace com +{ +/** */ //for docpp +namespace sun +{ +/** */ //for docpp +namespace star +{ +/** */ //for docpp +namespace uno +{ + +/** C++ wrapper for typelib_TypeDescription. + Constructors by name, type, type description reference will get + the full type description. + <br> +*/ +class TypeDescription +{ + /** C typelib type description<br> + */ + mutable typelib_TypeDescription * _pTypeDescr; + +public: + /** Constructor: + <br> + @param pTypeDescr a type description + */ + inline TypeDescription( typelib_TypeDescription * pTypeDescr = 0 ); + /** Constructor: + <br> + @param pTypeDescrRef a type description reference + */ + inline TypeDescription( typelib_TypeDescriptionReference * pTypeDescrRef ); + /** Constructor: + <br> + @param rType a type + */ + inline TypeDescription( const ::com::sun::star::uno::Type & rType ); + /** Copy constructor: + <br> + @param rDescr another TypeDescription + */ + inline TypeDescription( const TypeDescription & rDescr ); + /** Constructor: + <br> + @param pTypeName a type name + */ + inline TypeDescription( rtl_uString * pTypeName ); + /** Constructor: + <br> + @param rTypeName a type name + */ + inline TypeDescription( const ::rtl::OUString & rTypeName ); + /** Destructor: + <br> + releases type description + */ + inline ~TypeDescription(); + + /** Assignment operator: + acquires given type description and releases a set one. + <br> + @param pTypeDescr another type description + @return this TypeDescription + */ + inline TypeDescription & operator = ( typelib_TypeDescription * pTypeDescr ); + /** Assignment operator: + acquires given type description and releases a set one. + <br> + @param rTypeDescr another type description + @return this TypeDescription + */ + inline TypeDescription & operator =( const TypeDescription & rTypeDescr ) + { return this->operator =( rTypeDescr.get() ); } + + /** Tests if two type descriptions are equal. + <br> + @param pTypeDescr another type description + @return true, if both type descriptions are equal, false otherwise + */ + inline sal_Bool equals( const typelib_TypeDescription * pTypeDescr ) const; + /** Tests if two type descriptions are equal. + <br> + @param rTypeDescr another type description + @return true, if both type descriptions are equal, false otherwise + */ + inline sal_Bool equals( const TypeDescription & rTypeDescr ) const + { return equals( rTypeDescr._pTypeDescr ); } + + /** Makes stored type description complete. + <br> + */ + inline void makeComplete() const; + + /** Gets the <b>un</b>acquired type description pointer. + <br> + @return stored pointer of type description + */ + inline typelib_TypeDescription * get() const + { return _pTypeDescr; } + /** Tests if a type description is set. + <br> + @return true, if a type description is set, false otherwise + */ + inline sal_Bool is() const + { return (_pTypeDescr != 0); } +}; +//__________________________________________________________________________________________________ +inline TypeDescription::TypeDescription( typelib_TypeDescription * pTypeDescr ) + : _pTypeDescr( pTypeDescr ) +{ + if (_pTypeDescr) + typelib_typedescription_acquire( _pTypeDescr ); +} +//__________________________________________________________________________________________________ +inline TypeDescription::TypeDescription( typelib_TypeDescriptionReference * pTypeDescrRef ) + : _pTypeDescr( 0 ) +{ + if (pTypeDescrRef) + typelib_typedescriptionreference_getDescription( &_pTypeDescr, pTypeDescrRef ); +} +//__________________________________________________________________________________________________ +inline TypeDescription::TypeDescription( const ::com::sun::star::uno::Type & rType ) + : _pTypeDescr( 0 ) +{ + if (rType.getTypeLibType()) + typelib_typedescriptionreference_getDescription( &_pTypeDescr, rType.getTypeLibType() ); +} +//__________________________________________________________________________________________________ +inline TypeDescription::TypeDescription( const TypeDescription & rTypeDescr ) + : _pTypeDescr( rTypeDescr._pTypeDescr ) +{ + if (_pTypeDescr) + typelib_typedescription_acquire( _pTypeDescr ); +} +//__________________________________________________________________________________________________ +inline TypeDescription::TypeDescription( rtl_uString * pTypeName ) + : _pTypeDescr( 0 ) +{ + typelib_typedescription_getByName( &_pTypeDescr , pTypeName ); +} +//__________________________________________________________________________________________________ +inline TypeDescription::TypeDescription( const ::rtl::OUString & rTypeName ) + : _pTypeDescr( 0 ) +{ + typelib_typedescription_getByName( &_pTypeDescr , rTypeName.pData ); +} +//__________________________________________________________________________________________________ +inline TypeDescription::~TypeDescription() +{ + if (_pTypeDescr) + typelib_typedescription_release( _pTypeDescr ); +} +//__________________________________________________________________________________________________ +inline TypeDescription & TypeDescription::operator =( typelib_TypeDescription * pTypeDescr ) +{ + if (_pTypeDescr) + typelib_typedescription_release( _pTypeDescr ); + if (_pTypeDescr = pTypeDescr) + typelib_typedescription_acquire( _pTypeDescr ); + return *this; +} +//__________________________________________________________________________________________________ +inline sal_Bool TypeDescription::equals( const typelib_TypeDescription * pTypeDescr ) const +{ + return (_pTypeDescr && pTypeDescr && + typelib_typedescription_equals( _pTypeDescr, pTypeDescr )); +} +//__________________________________________________________________________________________________ +inline void TypeDescription::makeComplete() const +{ + if (_pTypeDescr && !_pTypeDescr->bComplete) + ::typelib_typedescription_complete( &_pTypeDescr ); +} + +} +} +} +} + +#endif diff --git a/cppu/inc/typelib/uik.h b/cppu/inc/typelib/uik.h new file mode 100644 index 000000000000..7012817625f9 --- /dev/null +++ b/cppu/inc/typelib/uik.h @@ -0,0 +1,92 @@ +/************************************************************************* + * + * $RCSfile: uik.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _TYPELIB_UIK_H_ +#define _TYPELIB_UIK_H_ + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifdef SAL_W32 +# pragma pack(push, 8) +#elif defined(SAL_OS2) +# pragma pack(8) +#endif + +/** Binary typelib uik struct. + <br> +*/ +struct typelib_Uik +{ + sal_uInt32 m_Data1; + sal_uInt16 m_Data2; + sal_uInt16 m_Data3; + sal_uInt32 m_Data4; + sal_uInt32 m_Data5; +}; + +#ifdef SAL_W32 +# pragma pack(pop) +#elif defined(SAL_OS2) +# pragma pack() +#endif + +#endif diff --git a/cppu/inc/uno/any2.h b/cppu/inc/uno/any2.h new file mode 100644 index 000000000000..2cab2d06a446 --- /dev/null +++ b/cppu/inc/uno/any2.h @@ -0,0 +1,162 @@ +/************************************************************************* + * + * $RCSfile: any2.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _UNO_ANY2_H_ +#define _UNO_ANY2_H_ + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif +#ifndef _UNO_DATA_H_ +#include <uno/data.h> +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif +#ifdef SAL_W32 +#pragma pack(push, 8) +#elif defined(SAL_OS2) +#pragma pack(8) +#endif + +typedef struct _typelib_TypeDescription typelib_TypeDescription; + +/** This is the binary specification of an UNO any. + <br> +*/ +typedef struct _uno_Any +{ + /** type of value<br> + */ + typelib_TypeDescriptionReference * pType; + /** pointer to value<br> + */ + void * pData; +} uno_Any; + +#ifdef SAL_W32 +#pragma pack(pop) +#elif defined(SAL_OS2) +#pragma pack() +#endif + +/** Constructs an any with a given value. + Interfaces are acquired by the given callback function. + <br> + @param pDest pointer memory of destination any + @param pSource pointer to source value; defaults (0) to default constructed value + @param pTypeDescr type description of value; defaults (0) to void + @param acquire function called each time an interface needs to be acquired; defaults (0) to uno +*/ +SAL_DLLEXPORT void SAL_CALL uno_any_construct( + uno_Any * pDest, void * pSource, + typelib_TypeDescription * pTypeDescr, + uno_AcquireFunc acquire ); +/** Constructs an any with a given value. + Interfaces are acquired by the given callback function. + <br> + @param pDest pointer memory of destination any + @param pSource pointer to source value; defaults (0) to default constructed value + @param pType type of value; defaults (0) to void + @param acquire function called each time an interface needs to be acquired; defaults (0) to uno +*/ +SAL_DLLEXPORT void SAL_CALL uno_type_any_construct( + uno_Any * pDest, void * pSource, + typelib_TypeDescriptionReference * pType, + uno_AcquireFunc acquire ); + +/** Constructs an any with a given value and converts/ maps interfaces. + <br> + @param pDest pointer memory of destination any + @param pSource pointer to source value; defaults (0) to default constructed value + @param pTypeDescr type description of value; defaults (0) to void + @param mapping mapping to convert/ map interfaces +*/ +SAL_DLLEXPORT void SAL_CALL uno_any_constructAndConvert( + uno_Any * pDest, void * pSource, + typelib_TypeDescription * pTypeDescr, + uno_Mapping * mapping ); +/** Constructs an any with a given value and converts/ maps interfaces. + <br> + @param pDest pointer memory of destination any + @param pSource pointer to source value; defaults (0) to default constructed value + @param pType type of value; defaults (0) to void + @param mapping mapping to convert/ map interfaces +*/ +SAL_DLLEXPORT void SAL_CALL uno_type_any_constructAndConvert( + uno_Any * pDest, void * pSource, + typelib_TypeDescriptionReference * pType, + uno_Mapping * mapping ); + +/** Destructs an any. + <br> + @param pValue pointer to any + @param release function called each time an interface needs to be released. defaults (0) to uno +*/ +SAL_DLLEXPORT void SAL_CALL uno_any_destruct( + uno_Any * pValue, uno_ReleaseFunc release ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cppu/inc/uno/data.h b/cppu/inc/uno/data.h new file mode 100644 index 000000000000..83fd327fa9a1 --- /dev/null +++ b/cppu/inc/uno/data.h @@ -0,0 +1,245 @@ +/************************************************************************* + * + * $RCSfile: data.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _UNO_DATA_H_ +#define _UNO_DATA_H_ + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef struct _uno_Mapping uno_Mapping; +typedef struct _typelib_TypeDescription typelib_TypeDescription; +typedef struct _typelib_TypeDescriptionReference typelib_TypeDescriptionReference; +typedef struct _typelib_InterfaceTypeDescription typelib_InterfaceTypeDescription; + +/** Generic function pointer declaration to query for an interface. + <br> + @param pInterface interface + @param pTypedemanded interface type + @return interface pointer +*/ +typedef void * (SAL_CALL * uno_QueryInterfaceFunc)( + void * pInterface, typelib_TypeDescriptionReference * pType ); +/** Generic function pointer declaration to acquire an interface. + <br> + @param pInterface interface to be acquired +*/ +typedef void (SAL_CALL * uno_AcquireFunc)( void * pInterface ); +/** Generic function pointer declaration to release an interface. + <br> + @param pInterface interface to be release +*/ +typedef void (SAL_CALL * uno_ReleaseFunc)( void * pInterface ); + +/** Tests if two values are equal. May compare different types (e.g., short to long). + <br> + @param pVal1 pointer to a value + @param pVal1TypeDescr type description of pVal1 + @param pVal2 pointer to another value + @param pVal2TypeDescr type description of pVal2 + @param queryInterface function called each time two interfaces are tested whether they belong + to the same object; defaults (0) to uno + @param release function to release queried interfaces; defaults (0) to uno + @return true if values are equal +*/ +SAL_DLLEXPORT sal_Bool SAL_CALL uno_equalData( + void * pVal1, typelib_TypeDescription * pVal1TypeDescr, + void * pVal2, typelib_TypeDescription * pVal2TypeDescr, + uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release ); +/** Tests if two values are equal. May compare different types (e.g., short to long). + <br> + @param pVal1 pointer to a value + @param pVal1Type type of pVal1 + @param pVal2 pointer to another value + @param pVal2Type type of pVal2 + @param queryInterface function called each time two interfaces are tested whether they belong + to the same object; defaults (0) to uno + @param release function to release queried interfaces; defaults (0) to uno + @return true if values are equal +*/ +SAL_DLLEXPORT sal_Bool SAL_CALL uno_type_equalData( + void * pVal1, typelib_TypeDescriptionReference * pVal1Type, + void * pVal2, typelib_TypeDescriptionReference * pVal2Type, + uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release ); + +/** Copy construct memory with given value. + The size of the destination value must be larger or equal to the size of the source value. + <br> + @param pDest pointer to destination value memory + @param pSource pointer to source value + @param pTypeDescr type description of source + @param acquire function called each time an interface needs to be acquired; defaults (0) to uno +*/ +SAL_DLLEXPORT void SAL_CALL uno_copyData( + void * pDest, void * pSource, typelib_TypeDescription * pTypeDescr, uno_AcquireFunc acquire ); +/** Copy construct memory with given value. + The size of the destination value must be larger or equal to the size of the source value. + <br> + @param pDest pointer to destination value memory + @param pSource pointer to source value + @param pType type of source + @param acquire function called each time an interface needs to be acquired; defaults (0) to uno +*/ +SAL_DLLEXPORT void SAL_CALL uno_type_copyData( + void * pDest, void * pSource, typelib_TypeDescriptionReference * pType, uno_AcquireFunc acquire ); + +/** Copy construct memory with given value. + The size of the destination value must be larger or equal to the size of the source value.<br> + Interfaces are converted/ mapped by mapping parameter. + <br> + @param pDest pointer to destination value memory + @param pSource pointer to source value + @param pTypeDescr type description of source + @param mapping mapping to convert/ map interfaces +*/ +SAL_DLLEXPORT void SAL_CALL uno_copyAndConvertData( + void * pDest, void * pSource, typelib_TypeDescription * pTypeDescr, uno_Mapping * mapping ); +/** Copy construct memory with given value. + The size of the destination value must be larger or equal to the size of the source value.<br> + Interfaces are converted/ mapped by mapping parameter. + <br> + @param pDest pointer to destination value memory + @param pSource pointer to source value + @param pType type of source + @param mapping mapping to convert/ map interfaces +*/ +SAL_DLLEXPORT void SAL_CALL uno_type_copyAndConvertData( + void * pDest, void * pSource, typelib_TypeDescriptionReference * pType, uno_Mapping * mapping ); + +/** Destructs a given value; does <b>not</b> free its memory! + <br> + @param pValue value to be destructed + @param pTypeDescr type description of value + @param release function called each time an interface pointer needs to be released; defaults (0) to uno +*/ +SAL_DLLEXPORT void SAL_CALL uno_destructData( + void * pValue, typelib_TypeDescription * pTypeDescr, uno_ReleaseFunc release ); +/** Destructs a given value; does <b>not</b> free its memory! + <br> + @param pValue value to be destructed + @param pType type of value + @param release function called each time an interface pointer needs to be released; defaults (0) to uno +*/ +SAL_DLLEXPORT void SAL_CALL uno_type_destructData( + void * pValue, typelib_TypeDescriptionReference * pType, uno_ReleaseFunc release ); + +/** Default constructs a value. All simple types are set to 0, enums are set to their default + value. + <br> + @param pMem pointer to memory of value to be constructed + @param pTypeDescr type description of value to be constructed +*/ +SAL_DLLEXPORT void SAL_CALL uno_constructData( + void * pMem, typelib_TypeDescription * pTypeDescr ); +/** Default constructs a value. All simple types are set to 0, enums are set to their default + value. + <br> + @param pMem pointer to memory of value to be constructed + @param pType type of value to be constructed +*/ +SAL_DLLEXPORT void SAL_CALL uno_type_constructData( + void * pMem, typelib_TypeDescriptionReference * pType ); + +/** Assigns a destination value with a source value. Widening conversion + <b>without</b> data loss is allowed (e.g., assigning a long with a short). + Assignment from any value to a value of type Any and vice versa is allowed. + <br> + @param pDest pointer to destination value + @param pDestTypeDescr type description of destination value + @param pSource pointer to source value; if 0, then destination value will be assigned to default value + @param pSourceTypeDescr type destination of source value + @param queryInterface function called each time an interface needs to be queried; defaults (0) to uno + @param acquire function called each time an interface needs to be acquired; defaults (0) to uno + @param release function called each time an interface needs to be released; defaults (0) to uno + @return true if destination has been successfully assigned +*/ +SAL_DLLEXPORT sal_Bool SAL_CALL uno_assignData( + void * pDest, typelib_TypeDescription * pDestTypeDescr, + void * pSource, typelib_TypeDescription * pSourceTypeDescr, + uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release ); +/** Assigns a destination value with a source value. Widening conversion + <b>without</b> data loss is allowed (e.g., assigning a long with a short). + Assignment from any value to a value of type Any and vice versa is allowed. + <br> + @param pDest pointer to destination value + @param pDestType type of destination value + @param pSource pointer to source value; if 0, then destination value will be assigned to default value + @param pSourceType type of source value + @param queryInterface function called each time an interface needs to be queried; defaults (0) to uno + @param acquire function called each time an interface needs to be acquired; defaults (0) to uno + @param release function called each time an interface needs to be released; defaults (0) to uno + @return true if destination has been successfully assigned +*/ +SAL_DLLEXPORT sal_Bool SAL_CALL uno_type_assignData( + void * pDest, typelib_TypeDescriptionReference * pDestType, + void * pSource, typelib_TypeDescriptionReference * pSourceType, + uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cppu/inc/uno/dispatcher.h b/cppu/inc/uno/dispatcher.h new file mode 100644 index 000000000000..bfdf1ad4bfb7 --- /dev/null +++ b/cppu/inc/uno/dispatcher.h @@ -0,0 +1,134 @@ +/************************************************************************* + * + * $RCSfile: dispatcher.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _UNO_DISPATCHER_H_ +#define _UNO_DISPATCHER_H_ + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif +#ifndef _RTL_USTRING_H_ +#include <rtl/ustring.h> +#endif + +#ifndef _UNO_ANY2_H_ +#include <uno/any2.h> +#endif + +typedef struct _typelib_TypeDescription typelib_TypeDescription; +typedef struct _typelib_InterfaceTypeDescription typelib_InterfaceTypeDescription; +typedef struct _uno_Interface uno_Interface; + +/** Function pointer declaration for the binary C uno dispatch function.<br> + Any pure out or return value will be constructed by the callee, iff + no exception is signalled.<br> + If an exception is signalled, the any *ppException is properly constructed + by the callee, otherwise the pointer *ppException is set to 0.<br> + An attribute <b>get</b> call is indicated by a non-null return pointer. + <br> + @param pUnoI uno interface the call is performed on + @param pMemberType member type description of a method or attribute + @param pReturn pointer to return value memory; + pointer may be undefined if void method, null if attribute set call. + @param pArgs an array of pointers to arguments values. + (remark: the value of an interface reference stores a + uno_interface *, so you get it by *(uno_Interface **)pArgs[n]) + @param ppException pointer to pointer to unconstructed any to signal an exception. +*/ +typedef void (SAL_CALL * uno_DispatchMethod)( + uno_Interface * pUnoI, + const typelib_TypeDescription * pMemberType, + void * pReturn, + void * pArgs[], + uno_Any ** ppException ); + +#ifdef SAL_W32 +#pragma pack(push, 8) +#elif defined(SAL_OS2) +#pragma pack(8) +#endif + +/** The binary C uno interface description. + <br> +*/ +typedef struct _uno_Interface +{ + /** Acquires uno interface. + <br> + @param pInterface uno interface + */ + void (SAL_CALL * acquire)( uno_Interface * pInterface ); + /** Releases uno interface. + <br> + @param pInterface uno interface + */ + void (SAL_CALL * release)( uno_Interface * pInterface ); + /** dispatch function<br> + */ + uno_DispatchMethod pDispatcher; +} uno_Interface; + +#ifdef SAL_W32 +#pragma pack(pop) +#elif defined(SAL_OS2) +#pragma pack() +#endif + +#endif diff --git a/cppu/inc/uno/environment.h b/cppu/inc/uno/environment.h new file mode 100644 index 000000000000..552b1bb919b9 --- /dev/null +++ b/cppu/inc/uno/environment.h @@ -0,0 +1,344 @@ +/************************************************************************* + * + * $RCSfile: environment.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _UNO_ENVIRONMENT_H_ +#define _UNO_ENVIRONMENT_H_ + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif +#ifndef _RTL_USTRING_H_ +#include <rtl/ustring.h> +#endif + +typedef struct _uno_Environment uno_Environment; +typedef struct _uno_ExtEnvironment uno_ExtEnvironment; +typedef struct _typelib_InterfaceTypeDescription typelib_InterfaceTypeDescription; + +#ifdef SAL_W32 +#pragma pack(push, 8) +#elif defined(SAL_OS2) +#pragma pack(8) +#endif + +/** The binary specification of an UNO environment. + <br> +*/ +typedef struct _uno_Environment +{ + /** reserved for future use (0 if not used)<br> + */ + void * pReserved; + + /** type name of environment<br> + */ + rtl_uString * pTypeName; + + /** free context pointer to be used for specific classes of environments + (e.g., a jvm pointer)<br> + */ + void * pContext; + + /** pointer to extended environment (interface registration functionality), if supported<br> + */ + uno_ExtEnvironment * pExtEnv; + + /** Acquires this environment. + <br> + @param pEnv this environment + */ + void (SAL_CALL * acquire)( uno_Environment * pEnv ); + + /** Releases this environment; + last release of environment will revoke the environment from runtime. + <br> + @param pEnv this environment + */ + void (SAL_CALL * release)( uno_Environment * pEnv ); + + /** Call this function to <b>explicitly</b> dispose this environment + (e.g., release all interfaces).<br> + You might want to call this function before shutting down due to a runtime error. + <br> + @param pEnv this environment + */ + void (SAL_CALL * dispose)( uno_Environment * pEnv ); + + /* ===== the following part will be late initialized by a matching bridge ===== * + * ===== and is NOT for public use. ===== */ + + /** <b>CALLBACK</b><br> + Disposing callback function pointer that can be set to get signalled before the environment + is destroyed. + <br> + @param pEnv environment that is being disposed + */ + void (SAL_CALL * environmentDisposing)( uno_Environment * pEnv ); +} uno_Environment; + +/** Generic function pointer declaration to free a proxy object if it is not needed + by the environment anymore.<br> + Any proxy object must register itself on first acquire() call and revoke + itself on last release() call. + This can happen several times because the environment caches proxy objects + until the environment <b>explicitly</b> frees the proxy object calling this function. + <br> + @param pEnv environment + @param pProxy proxy pointer +*/ +typedef void (SAL_CALL * uno_freeProxyFunc)( uno_ExtEnvironment * pEnv, void * pProxy ); + +/** Generic function pointer declaration to allocate memory. Used with getRegisteredInterfaces(). + <br> + @param nBytes amount of memory in bytes + @return pointer to allocated memory +*/ +typedef void * (SAL_CALL * uno_memAlloc)( sal_uInt32 nBytes ); + +/** The binary specification of an UNO environment supporting interface registration. + <br> +*/ +typedef struct _uno_ExtEnvironment +{ + /** inherits all members of an uno_Environment<br> + */ + uno_Environment aBase; + + /** Registers an interface of this environment. + <br> + @param pEnv this environment + @param ppInterface inout parameter of interface to be registered + @param pOId object id of interface + @param pTypeDescr type description of interface + */ + void (SAL_CALL * registerInterface)( + uno_ExtEnvironment * pEnv, + void ** ppInterface, + rtl_uString * pOId, + typelib_InterfaceTypeDescription * pTypeDescr ); + + /** Registers a proxy interface of this environment that can be reanimated and is + freed <b>explicitly</b> by this environment. + <br> + @param pEnv this environment + @param ppInterface inout parameter of interface to be registered + @param freeProxy function to free proxy object + @param pOId object id of interface + @param pTypeDescr type description of interface + */ + void (SAL_CALL * registerProxyInterface)( + uno_ExtEnvironment * pEnv, + void ** ppProxy, + uno_freeProxyFunc freeProxy, + rtl_uString * pOId, + typelib_InterfaceTypeDescription * pTypeDescr ); + + /** Revokes an interface from this environment.<br> + You have to revoke <b>any</b> interface that has been registered via this method. + <br> + @param pEnv this environment + @param pInterface interface to be revoked + */ + void (SAL_CALL * revokeInterface)( + uno_ExtEnvironment * pEnv, + void * pInterface ); + + /** Provides the object id of a given interface. + <br> + @param ppOut inout oid + @param pInterface interface of object + */ + void (SAL_CALL * getObjectIdentifier)( + uno_ExtEnvironment * pEnv, + rtl_uString ** ppOId, + void * pInterface ); + + /** Retrieves an interface identified by its object id and type from this environment. + Interfaces are retrieved in the same order as they are registered. + <br> + @param pEnv this environment + @param ppInterface inout parameter for the registered interface; (0) if none was found + @param pOId object id of interface to be retrieved + @param pTypeDescr type description of interface to be retrieved + */ + void (SAL_CALL * getRegisteredInterface)( + uno_ExtEnvironment * pEnv, + void ** ppInterface, + rtl_uString * pOId, + typelib_InterfaceTypeDescription * pTypeDescr ); + + /** Returns all currently registered interfaces of this environment. + The memory block allocated might be slightly larger than (*pnLen * sizeof(void *)). + <br> + @param pEnv this environment + @param pppInterfaces out param; pointer to array of interface pointers + @param pnLen out param; length of array + @param memAlloc function for allocating memory that is passed back + */ + void (SAL_CALL * getRegisteredInterfaces)( + uno_ExtEnvironment * pEnv, + void *** pppInterfaces, + sal_Int32 * pnLen, + uno_memAlloc memAlloc ); + + + /* ===== the following part will be late initialized by a matching bridge ===== * + * ===== and is NOT for public use. ===== */ + + /** Computes an object id of the given interface; is called by the environment + implementation. + <br> + @param pEnv corresponding environment + @param ppOId out param: computed id + @param pInterface an interface + */ + void (SAL_CALL * computeObjectIdentifier)( + uno_ExtEnvironment * pEnv, + rtl_uString ** ppOId, void * pInterface ); + + /** Function to acquire an interface. + <br> + @param pEnv corresponding environment + @param pInterface an interface + */ + void (SAL_CALL * acquireInterface)( uno_ExtEnvironment * pEnv, void * pInterface ); + + /** Function to release an interface. + <br> + @param pEnv corresponding environment + @param pInterface an interface + */ + void (SAL_CALL * releaseInterface)( uno_ExtEnvironment * pEnv, void * pInterface ); +} uno_ExtEnvironment; + +#ifdef SAL_W32 +#pragma pack(pop) +#elif defined(SAL_OS2) +#pragma pack() +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** Function exported by some bridge library providing + acquireInterface(), releaseInterface(); may set a disposing callback. + <br> + @param pEnv environment to be initialized +*/ +typedef void (SAL_CALL * uno_initEnvironmentFunc)( uno_Environment * pEnv ); +#define UNO_INIT_ENVIRONMENT "uno_initEnvironment" + +/** Gets a specific environment. If the specified environment does + not exist, then a default one is created and registered. + The environment revokes itself on last release() call. + <br> + @param ppEnv inout parameter of environment; given environment will be released + @param pEnvTypeName type name of environment + @param pContext some context pointer (e.g., to distinguish java vm; set 0 if not needed) +*/ +SAL_DLLEXPORT void SAL_CALL uno_getEnvironment( + uno_Environment ** ppEnv, rtl_uString * pEnvTypeName, void * pContext ); + +/** Gets all specified environments. Caller has to release returned environments and + free allocated memory. + <br> + @param pppEnvs out param; pointer to array of environments + @param pnLen out param; length of array + @param memAlloc function for allocating memory that is passed back + @param pEnvTypeName type name of environments; 0 defaults to all +*/ +SAL_DLLEXPORT void SAL_CALL uno_getRegisteredEnvironments( + uno_Environment *** pppEnvs, sal_Int32 * pnLen, uno_memAlloc memAlloc, + rtl_uString * pEnvTypeName ); + +/** Creates an environment. The new environment is anonymous + (<b>NOT</b> publicly registered/ accessible). + <br> + @param ppEnv out parameter of environment; given environment will be released + @param pEnvTypeName name of environment + @param pContext context pointer (e.g., to distinguish java vm); set 0 if not needed +*/ +SAL_DLLEXPORT void SAL_CALL uno_createEnvironment( + uno_Environment ** ppEnv, rtl_uString * pEnvTypeName, void * pContext ); + +/** Dumps out environment information, i.e. registered interfaces. + <br> + @param stream output stream (FILE *) + @param pEnv environment to be dumped + @param pFilter if not null, filters output +*/ +SAL_DLLEXPORT void SAL_CALL uno_dumpEnvironment( + void * stream, uno_Environment * pEnv, const sal_Char * pFilter ); +/** Dumps out environment information, i.e. registered interfaces. + <br> + @param stream output stream (FILE *) + @param pEnvTypeName type name of environment to be dumped + @param pFilter if not null, filters output +*/ +SAL_DLLEXPORT void SAL_CALL uno_dumpEnvironmentByName( + void * stream, rtl_uString * pEnvTypeName, const sal_Char * pFilter ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cppu/inc/uno/environment.hxx b/cppu/inc/uno/environment.hxx new file mode 100644 index 000000000000..f8aa6ae3f6d7 --- /dev/null +++ b/cppu/inc/uno/environment.hxx @@ -0,0 +1,205 @@ +/************************************************************************* + * + * $RCSfile: environment.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _UNO_ENVIRONMENT_HXX_ +#define _UNO_ENVIRONMENT_HXX_ + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif +#ifndef _UNO_ENVIRONMENT_H_ +#include <uno/environment.h> +#endif + + +/** */ //for docpp +namespace com +{ +/** */ //for docpp +namespace sun +{ +/** */ //for docpp +namespace star +{ +/** */ //for docpp +namespace uno +{ + +/** C++ wrapper for binary C uno_Environment. + <br> +*/ +class Environment +{ + /** binary C uno_Environment<br> + */ + uno_Environment * _pEnv; + +public: + /** Constructor: acquires given environment + <br> + @param pEnv environment + */ + inline Environment( uno_Environment * pEnv = 0 ); + + /** Copy constructor: acquires given environment + <br> + @param rEnv another environment + */ + inline Environment( const Environment & rEnv ); + + /** Destructor: + <br> + Releases a set environment. + */ + inline ~Environment(); + + /** Sets a given environment, i.e. acquires given one and releases a set one. + <br> + @param pEnv another environment + @return this environment + */ + inline Environment & SAL_CALL operator = ( uno_Environment * pEnv ); + /** Sets a given environment, i.e. acquires given one and releases a set one. + <br> + @param rEnv another environment + @return this environment + */ + inline Environment & SAL_CALL operator = ( const Environment & rEnv ) + { return operator = ( rEnv._pEnv ); } + + /** Provides <b>un</b>acquired pointer to the set C environment. + <br> + @return <b>un</b>acquired pointer to the C environment struct + */ + inline uno_Environment * SAL_CALL get() const + { return _pEnv; } + + /** Gets type name of set environment. + <br> + @return type name of set environment + */ + inline ::rtl::OUString SAL_CALL getTypeName() const + { return _pEnv->pTypeName; } + + /** Gets free context pointer of set environment. + <br> + @return free context pointer of set environment + */ + inline void * SAL_CALL getContext() const + { return _pEnv->pContext; } + + /** Tests if a environment is set. + <br> + @return true, if a environment is set, false otherwise + */ + inline sal_Bool SAL_CALL is() const + { return (_pEnv != 0); } + + /** Releases a set environment. + <br> + */ + inline void SAL_CALL clear(); +}; +//__________________________________________________________________________________________________ +inline Environment::Environment( uno_Environment * pEnv ) + : _pEnv( pEnv ) +{ + if (_pEnv) + (*_pEnv->acquire)( _pEnv ); +} +//__________________________________________________________________________________________________ +inline Environment::Environment( const Environment & rEnv ) + : _pEnv( rEnv._pEnv ) +{ + if (_pEnv) + (*_pEnv->acquire)( _pEnv ); +} +//__________________________________________________________________________________________________ +inline Environment::~Environment() +{ + if (_pEnv) + (*_pEnv->release)( _pEnv ); +} +//__________________________________________________________________________________________________ +inline void Environment::clear() +{ + if (_pEnv) + { + (*_pEnv->release)( _pEnv ); + _pEnv = 0; + } +} +//__________________________________________________________________________________________________ +inline Environment & Environment::operator = ( uno_Environment * pEnv ) +{ + if (pEnv) + (*pEnv->acquire)( pEnv ); + if (_pEnv) + (*_pEnv->release)( _pEnv ); + _pEnv = pEnv; + return *this; +} + +} +} +} +} + +#endif diff --git a/cppu/inc/uno/lbnames.h b/cppu/inc/uno/lbnames.h new file mode 100644 index 000000000000..5ef7c0899c6d --- /dev/null +++ b/cppu/inc/uno/lbnames.h @@ -0,0 +1,86 @@ +/************************************************************************* + * + * $RCSfile: lbnames.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:25:51 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _UNO_LBNAMES_H_ +#define _UNO_LBNAMES_H_ + +/** A java 1.1 compatible virtual machine<br> +*/ +#define UNO_LB_JAVA_NAMESPACE java +#define UNO_LB_JAVA "java" +/** Miscrosoft VC++ 4.2 - 6.0 compiler; RTTI is not supported<br> +*/ +#define UNO_LB_MSCI_NAMESPACE msci +#define UNO_LB_MSCI "msci" +/** GCC 2 with RTTI or compatible; RTTI is not supported<br> +*/ +#define UNO_LB_GCC2_NAMESPACE gcc2 +#define UNO_LB_GCC2 "gcc2" +/** WorkShop Compiler 5.0 or compatible; RTTI is not supported<br> +*/ +#define UNO_LB_SUNPRO5_NAMESPACE sunpro5 +#define UNO_LB_SUNPRO5 "sunpro5" + +/** Binary C UNO<br> +*/ +#define UNO_LB_UNO_NAMESPACE uno +#define UNO_LB_UNO "uno" + +#endif diff --git a/cppu/inc/uno/mapping.h b/cppu/inc/uno/mapping.h new file mode 100644 index 000000000000..68937cfcdff6 --- /dev/null +++ b/cppu/inc/uno/mapping.h @@ -0,0 +1,233 @@ +/************************************************************************* + * + * $RCSfile: mapping.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:25:52 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _UNO_MAPPING_H_ +#define _UNO_MAPPING_H_ + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif +#ifndef _RTL_USTRING_H_ +#include <rtl/ustring.h> +#endif + +typedef struct _typelib_InterfaceTypeDescription typelib_InterfaceTypeDescription; +typedef struct _uno_Mapping uno_Mapping; +typedef struct _uno_Environment uno_Environment; + +/** Function pointer declaration to map an interface from one environment to another. + <br> + @param pMapping mapping + @param ppOut [inout] destination interface; existing interfaces are released + @param pInterface source interface + @param pInterfaceTypeDescr type description of the interface +*/ +typedef void (SAL_CALL * uno_MapInterfaceFunc)( + uno_Mapping * pMapping, + void ** ppOut, void * pInterface, + typelib_InterfaceTypeDescription * pInterfaceTypeDescr ); + + +#ifdef SAL_W32 +#pragma pack(push, 8) +#elif defined(SAL_OS2) +#pragma pack(8) +#endif + +/** This is the binary specification of a mapping. + <br> +*/ +typedef struct _uno_Mapping +{ + /** Acquires mapping + <br> + @param pMapping mapping + */ + void (SAL_CALL * acquire)( uno_Mapping * pMapping ); + /** Releases mapping. + The last release may unload bridges. + <br> + @param pMapping mapping + */ + void (SAL_CALL * release)( uno_Mapping * pMapping ); + + /** mapping function<br> + */ + uno_MapInterfaceFunc mapInterface; +} uno_Mapping; + +#ifdef SAL_W32 +#pragma pack(pop) +#elif defined(SAL_OS2) +#pragma pack() +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** Gets an interface mapping from one environment to another. + <br> + @param ppMapping [inout] mapping; existing mapping will be released + @param pFrom source environment + @param pTo destination environment + (interfaces resulting in mapInterface() call can be used + in this language environment) + @param pAddPurpose additional purpose of mapping (e.g., protocolling); defaults to 0 (none) +*/ +SAL_DLLEXPORT void SAL_CALL uno_getMapping( + uno_Mapping ** ppMapping, + uno_Environment * pFrom, + uno_Environment * pTo, + rtl_uString * pAddPurpose ); + +/** Callback function pointer declaration to get a mapping. + <br> + @param ppMapping inout mapping + @param pFrom source environment + @param pTo destination environment + @param pAddPurpose additional purpose +*/ +typedef void (SAL_CALL * uno_getMappingFunc)( + uno_Mapping ** ppMapping, + uno_Environment * pFrom, + uno_Environment * pTo, + rtl_uString * pAddPurpose ); + +/** Registers a callback being called each time a mapping is demanded. + <br> + @param pCallback callback function +*/ +SAL_DLLEXPORT void SAL_CALL uno_registerMappingCallback( + uno_getMappingFunc pCallback ); + +/** Revokes a mapping callback registration. + <br> + @param pCallback callback function +*/ +SAL_DLLEXPORT void SAL_CALL uno_revokeMappingCallback( + uno_getMappingFunc pCallback ); + +/** Function pointer declaration to free a mapping. + <br> + @param pMapping mapping to be freed +*/ +typedef void (SAL_CALL * uno_freeMappingFunc)( uno_Mapping * pMapping ); + +/** Registers a mapping.<br> + A mapping registers itself on first acquire and revokes itself on last release. + The given freeMapping function is called by the runtime to cleanup + any resources. + <br> + @param ppMapping inout mapping to be registered + @param freeMapping called by runtime to delete mapping + @param pFrom source environment + @param pTo destination environment + @param pAddPurpose additional purpose string; defaults to 0 +*/ +SAL_DLLEXPORT void SAL_CALL uno_registerMapping( + uno_Mapping ** ppMapping, uno_freeMappingFunc freeMapping, + uno_Environment * pFrom, uno_Environment * pTo, rtl_uString * pAddPurpose ); + +/** Revokes a mapping.<br> + A mapping registers itself on first acquire and revokes itself on last release. + <br> + @param pMapping mapping to be revoked +*/ +SAL_DLLEXPORT void SAL_CALL uno_revokeMapping( + uno_Mapping * pMapping ); + +/** Gets an interface mapping from one language environment to another by + corresponding environment type names. + <br> + @param ppMapping [inout] mapping; existing mapping will be released + @param pFrom source environment type name + @param pTo destination environment type name + (interfaces resulting in mapInterface() call can be used + in this language environment) + @param pAddPurpose additional purpose of mapping (e.g., protocolling); defaults to 0 (none) +*/ +SAL_DLLEXPORT void SAL_CALL uno_getMappingByName( + uno_Mapping ** ppMapping, + rtl_uString * pFrom, + rtl_uString * pTo, + rtl_uString * pAddPurpose ); + +/* symbol exported by each language binding library */ +#define UNO_EXT_GETMAPPING "uno_ext_getMapping" + +/** Function pointer declaration to get a mapping from a loaded bridge.<br> + Bridges export a function called <b>uno_ext_getMapping</b> of this signature. + <br> + @param ppMapping [inout] mapping; existing mapping will be released + @pFrom source environment + @pTo destination environment +*/ +typedef void (SAL_CALL * uno_ext_getMappingFunc)( + uno_Mapping ** ppMapping, + uno_Environment * pFrom, + uno_Environment * pTo ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cppu/inc/uno/mapping.hxx b/cppu/inc/uno/mapping.hxx new file mode 100644 index 000000000000..1b784cbb595d --- /dev/null +++ b/cppu/inc/uno/mapping.hxx @@ -0,0 +1,333 @@ +/************************************************************************* + * + * $RCSfile: mapping.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:25:52 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _UNO_MAPPING_HXX_ +#define _UNO_MAPPING_HXX_ + +#ifndef _CPPU_MACROS_HXX_ +#include <cppu/macros.hxx> +#endif +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif +#ifndef _UNO_MAPPING_H_ +#include <uno/mapping.h> +#endif +#ifndef _COM_SUN_STAR_UNO_TYPE_HXX_ +#include <com/sun/star/uno/Type.hxx> +#endif +#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_ +#include <com/sun/star/uno/Reference.hxx> +#endif + +typedef struct _typelib_TypeDescription typelib_TypeDescription; +typedef struct _typelib_InterfaceTypeDescription typelib_InterfaceTypeDescription; +typedef struct _uno_Interface uno_Interface; + +/** */ //for docpp +namespace com +{ +/** */ //for docpp +namespace sun +{ +/** */ //for docpp +namespace star +{ +/** */ //for docpp +namespace uno +{ + +/** C++ wrapper for C uno_Mapping. + <br> +*/ +class Mapping +{ + uno_Mapping * _pMapping; + +public: + /** Holds a mapping from the specified source to the specified destination by + environment type names. + <br> + @param rFrom type name of source environment + @param rTo type name of destination environment + @param rAddPurpose additional purpose + */ + inline Mapping( const ::rtl::OUString & rFrom, const ::rtl::OUString & rTo, + const ::rtl::OUString & rAddPurpose = ::rtl::OUString() ); + + /** Holds a mapping from the specified source to the specified destination. + <br> + @param pFrom source environment + @param pTo destination environment + @param rAddPurpose additional purpose + */ + inline Mapping( uno_Environment * pFrom, uno_Environment * pTo, + const ::rtl::OUString & rAddPurpose = ::rtl::OUString() ); + + /** Constructor. + <br> + @param pMapping another mapping + */ + inline Mapping( uno_Mapping * pMapping = 0 ); + + /** Copy constructor. + <br> + @param rMapping another mapping + */ + inline Mapping( const Mapping & rMapping ); + + /** Destructor. + <br> + */ + inline ~Mapping(); + + /** Sets a given mapping. + <br> + @param pMapping another mapping + @return this mapping + */ + inline Mapping & SAL_CALL operator = ( uno_Mapping * pMapping ); + /** Sets a given mapping. + <br> + @param rMapping another mapping + @return this mapping + */ + inline Mapping & SAL_CALL operator = ( const Mapping & rMapping ) + { return operator = ( rMapping._pMapping ); } + + /** Provides a pointer to the C mapping. The returned mapping is <b>not</b> acquired! + <br> + @return <b>un</b>acquired C mapping + */ + inline uno_Mapping * SAL_CALL get() const + { return _pMapping; } + + /** Tests if a mapping is set. + <br> + @return true if a mapping is set + */ + inline sal_Bool SAL_CALL is() const + { return (_pMapping != 0); } + + /** Releases a set mapping. + <br> + */ + inline void SAL_CALL clear(); + + /** Maps an interface from one environment to another. + <br> + @param pInterface source interface + @param pTypeDescr type description of interface + @return mapped interface + */ + inline void * SAL_CALL mapInterface( void * pInterface, typelib_InterfaceTypeDescription * pTypeDescr ) const; + /** Maps an interface from one environment to another. + <br> + @param pInterface source interface + @param pTypeDescr type description of interface + @return mapped interface + */ + inline void * SAL_CALL mapInterface( void * pInterface, typelib_TypeDescription * pTypeDescr ) const + { return mapInterface( pInterface, (typelib_InterfaceTypeDescription *)pTypeDescr ); } + + /** Maps an interface from one environment to another. + <br> + @param pInterface source interface + @param rType type of interface + @return mapped interface + */ + inline void * SAL_CALL mapInterface( void * pInterface, const ::com::sun::star::uno::Type & rType ) const; + + /** Maps an interface from one environment to another. + <br> + @param ppOut inout mapped interface + @param pInterface source interface + @param pTypeDescr type description of interface + */ + inline void SAL_CALL mapInterface( void ** ppOut, void * pInterface, typelib_InterfaceTypeDescription * pTypeDescr ) const + { (*_pMapping->mapInterface)( _pMapping, ppOut, pInterface, pTypeDescr ); } + /** Maps an interface from one environment to another. + <br> + @param ppOut inout mapped interface + @param pInterface source interface + @param pTypeDescr type description of interface + */ + inline void SAL_CALL mapInterface( void ** ppOut, void * pInterface, typelib_TypeDescription * pTypeDescr ) const + { (*_pMapping->mapInterface)( _pMapping, ppOut, pInterface, (typelib_InterfaceTypeDescription *)pTypeDescr ); } + + /** Maps an interface from one environment to another. + <br> + @param ppOut inout mapped interface + @param pInterface source interface + @param rType type of interface to be mapped + */ + inline void SAL_CALL mapInterface( void ** ppOut, void * pInterface, const ::com::sun::star::uno::Type & rType ) const; +}; +//__________________________________________________________________________________________________ +inline Mapping::Mapping( const ::rtl::OUString & rFrom, const ::rtl::OUString & rTo, + const ::rtl::OUString & rAddPurpose ) + : _pMapping( 0 ) +{ + uno_getMappingByName( &_pMapping, rFrom.pData, rTo.pData, rAddPurpose.pData ); +} +//__________________________________________________________________________________________________ +inline Mapping::Mapping( uno_Environment * pFrom, uno_Environment * pTo, + const ::rtl::OUString & rAddPurpose ) + : _pMapping( 0 ) +{ + uno_getMapping( &_pMapping, pFrom, pTo, rAddPurpose.pData ); +} +//__________________________________________________________________________________________________ +inline Mapping::Mapping( uno_Mapping * pMapping ) + : _pMapping( pMapping ) +{ + if (_pMapping) + (*_pMapping->acquire)( _pMapping ); +} +//__________________________________________________________________________________________________ +inline Mapping::Mapping( const Mapping & rMapping ) + : _pMapping( rMapping._pMapping ) +{ + if (_pMapping) + (*_pMapping->acquire)( _pMapping ); +} +//__________________________________________________________________________________________________ +inline Mapping::~Mapping() +{ + if (_pMapping) + (*_pMapping->release)( _pMapping ); +} +//__________________________________________________________________________________________________ +inline void Mapping::clear() +{ + if (_pMapping) + { + (*_pMapping->release)( _pMapping ); + _pMapping = 0; + } +} +//__________________________________________________________________________________________________ +inline Mapping & Mapping::operator = ( uno_Mapping * pMapping ) +{ + if (pMapping) + (*pMapping->acquire)( pMapping ); + if (_pMapping) + (*_pMapping->release)( _pMapping ); + _pMapping = pMapping; + return *this; +} +//__________________________________________________________________________________________________ +inline void Mapping::mapInterface( void ** ppOut, void * pInterface, + const ::com::sun::star::uno::Type & rType ) const +{ + typelib_TypeDescription * pTD = 0; + TYPELIB_DANGER_GET( &pTD, rType.getTypeLibType() ); + if (pTD) + { + (*_pMapping->mapInterface)( _pMapping, ppOut, pInterface, (typelib_InterfaceTypeDescription *)pTD ); + TYPELIB_DANGER_RELEASE( pTD ); + } +} +//__________________________________________________________________________________________________ +inline void * Mapping::mapInterface( void * pInterface, + typelib_InterfaceTypeDescription * pTypeDescr ) const +{ + void * pOut = 0; + (*_pMapping->mapInterface)( _pMapping, &pOut, pInterface, pTypeDescr ); + return pOut; +} +//__________________________________________________________________________________________________ +inline void * Mapping::mapInterface( void * pInterface, + const ::com::sun::star::uno::Type & rType ) const +{ + void * pOut = 0; + mapInterface( &pOut, pInterface, rType ); + return pOut; +} + +//-------------------------------------------------------------------------------------------------- +template< class C > +inline sal_Bool mapToCpp( Reference< C > * ppRet, uno_Interface * pUnoI ) +{ + Mapping aMapping( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO) ), + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) ) ); + OSL_ASSERT( aMapping.is() ); + aMapping.mapInterface( (void **)ppRet, pUnoI, ::getCppuType( ppRet ) ); + return (0 != *ppRet); +} +//-------------------------------------------------------------------------------------------------- +template< class C > +inline sal_Bool mapToUno( uno_Interface ** ppRet, const Reference< C > & x ) +{ + Mapping aMapping( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) ), + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO) ) ); + OSL_ASSERT( aMapping.is() ); + aMapping.mapInterface( (void **)ppRet, x.get(), ::getCppuType( &x ) ); + return (0 != *ppRet); +} + +} +} +} +} + +#endif diff --git a/cppu/inc/uno/sequence2.h b/cppu/inc/uno/sequence2.h new file mode 100644 index 000000000000..828db39c9106 --- /dev/null +++ b/cppu/inc/uno/sequence2.h @@ -0,0 +1,192 @@ +/************************************************************************* + * + * $RCSfile: sequence2.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:25:52 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _UNO_SEQUENCE2_H_ +#define _UNO_SEQUENCE2_H_ + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif +#ifndef _UNO_DATA_H_ +#include <uno/data.h> +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef sal_Sequence uno_Sequence; + +/** Assign a sequence. + <br> + @param ppDest destinstaion sequence + @param pSource source sequence + @param pTypeDescr type description of the <B>sequence</B> and <b>not</b> of an element + @param release function called each time an interface needs to be released; defaults (0) to uno +*/ +SAL_DLLEXPORT void SAL_CALL uno_sequence_assign( + uno_Sequence ** ppDest, + uno_Sequence * pSource, + typelib_TypeDescription * pTypeDescr, + uno_ReleaseFunc release ); +/** Assign a sequence. + <br> + @param ppDest destinstaion sequence + @param pSource source sequence + @param pType type of the <B>sequence</B> and <b>not</b> of an element + @param release function called each time an interface needs to be released; defaults (0) to uno +*/ +SAL_DLLEXPORT void SAL_CALL uno_type_sequence_assign( + uno_Sequence ** ppDest, + uno_Sequence * pSource, + typelib_TypeDescriptionReference * pType, + uno_ReleaseFunc release ); + +/** Constructs a new sequence with given elements. + <br> + @param ppSequence <b>out</b> parameter sequence + @param pTypeDescr type description of the <B>sequence</B> and <b>not</b> of an element + @param pElements if 0, then all elements are default constructed + @param len number of elements + @param acquire function called each time an interface needs to be acquired; defaults (0) to uno +*/ +SAL_DLLEXPORT void SAL_CALL uno_sequence_construct( + uno_Sequence ** ppSequence, + typelib_TypeDescription * pTypeDescr, + void * pElements, sal_Int32 len, + uno_AcquireFunc acquire ); +/** Constructs a new sequence with given elements. + <br> + @param ppSequence <b>out</b> parameter sequence + @param pType type of the <B>sequence</B> and <b>not</b> of an element + @param pElements if 0, then all elements are default constructed + @param len number of elements + @param acquire function called each time an interface needs to be acquired; defaults (0) to uno +*/ +SAL_DLLEXPORT void SAL_CALL uno_type_sequence_construct( + uno_Sequence ** ppSequence, + typelib_TypeDescriptionReference * pType, + void * pElements, sal_Int32 len, + uno_AcquireFunc acquire ); + +/** Assures that the reference count of the given sequence is one. + Otherwise a new copy of the sequence is created with a reference count of one. + <br> + @param ppSequence sequence + @param pTypeDescr type description of sequence + @param acquire function called each time an interface needs to be acquired; defaults (0) to uno + @param release function called each time an interface needs to be released; defaults (0) to uno +*/ +SAL_DLLEXPORT void SAL_CALL uno_sequence_reference2One( + uno_Sequence ** ppSequence, + typelib_TypeDescription * pTypeDescr, + uno_AcquireFunc acquire, + uno_ReleaseFunc release ); +/** Assures that the reference count of the given sequence is one. + Otherwise a new copy of the sequence is created with a reference count of one. + <br> + @param ppSequence sequence + @param pType type of sequence + @param acquire function called each time an interface needs to be acquired; defaults (0) to uno + @param release function called each time an interface needs to be released; defaults (0) to uno +*/ +SAL_DLLEXPORT void SAL_CALL uno_type_sequence_reference2One( + uno_Sequence ** ppSequence, + typelib_TypeDescriptionReference * pType, + uno_AcquireFunc acquire, + uno_ReleaseFunc release ); + +/** Reallocates length of a sequence. This truncates a sequence or enlarges it + default constructing appended elements. + <br> + @param ppSequence sequence + @param pTypeDescr type description of sequence + @param nSize new size of sequence + @param acquire function called each time an interface needs to be acquired; defaults (0) to uno + @param release function called each time an interface needs to be released; defaults (0) to uno +*/ +SAL_DLLEXPORT void SAL_CALL uno_sequence_realloc( + uno_Sequence ** ppSequence, + typelib_TypeDescription * pTypeDescr, + sal_Int32 nSize, + uno_AcquireFunc acquire, + uno_ReleaseFunc release ); +/** Reallocates length of a sequence. This truncates a sequence or enlarges it + default constructing appended elements. + <br> + @param ppSequence sequence + @param pType type of sequence + @param nSize new size of sequence + @param acquire function called each time an interface needs to be acquired; defaults (0) to uno + @param release function called each time an interface needs to be released; defaults (0) to uno +*/ +SAL_DLLEXPORT void SAL_CALL uno_type_sequence_realloc( + uno_Sequence ** ppSequence, + typelib_TypeDescriptionReference * pType, + sal_Int32 nSize, + uno_AcquireFunc acquire, + uno_ReleaseFunc release ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cppu/inc/uno/threadpool.h b/cppu/inc/uno/threadpool.h new file mode 100644 index 000000000000..f27564607287 --- /dev/null +++ b/cppu/inc/uno/threadpool.h @@ -0,0 +1,212 @@ +/************************************************************************* + * + * $RCSfile: threadpool.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 15:25:52 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <sal/types.h> +#include <rtl/byteseq.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/*** + * Thread identifier administration. + ***/ +/** + * Establishs an association between the current thread an the given thread identifier. + * There can be only one association at a time. The association must be broken by + * uno_releaseIdFromCurrentThread. + * This method is in general called by a bridge, that wants to bind a remote threadId + * to a new thread. + * + * @param pThreadId a byte sequence, that contains the identifier of the current thread. + * @return true, when the identifier was registered. <br> + * false, when the thread has already an identifier. The identifier was not + * altered. ( This is in general a bug ). <br> + **/ +SAL_DLLEXPORT sal_Bool SAL_CALL uno_bindIdToCurrentThread( sal_Sequence *pThreadId ); + + +/** + * Get the identifier of the current thread. + * If no id has been bound for the thread before, a new one is generated and bound + * to the thread. + * For each call to uno_getIdOfCurrentThread, a call to uno_releaseIdFromCurrentThread + * must be done. + * + * @param ppThreadId [out] Contains the (acquired) ThreadId. + **/ +SAL_DLLEXPORT void SAL_CALL uno_getIdOfCurrentThread( sal_Sequence **ppThreadId ); + + +/** + * If the internal refcount drops to zero, the association betwen threadId and + * thread is broken. + **/ +SAL_DLLEXPORT void SAL_CALL uno_releaseIdFromCurrentThread(); + + + + + + + +/** + * The threadpool + **/ +struct uno_threadpool_Handle; +/** + * Create a handle for the current thread before entering waiting pool. This method must be + * called, BEFORE the request is sent (to avoid a race between this thread and an incoming + * reply). + * This method shall only be called for synchronous requests. + * + * @param nDisposeId An ID, that uniquely identifies a bridge within the + * local process. The pointer to the bridge object should be used. + * @see uno_threadpool_disposeThreads + ***/ +SAL_DLLEXPORT struct uno_threadpool_Handle * SAL_CALL +uno_threadpool_createHandle( sal_Int64 nDisposeId ); + +/** + * This method is called to wait for a reply of a previously sent request. This is a + * blocking method. + * + * @param pHandle the handle that was previously created by uno_threadpool_createHandle. + * @param ppThreadSpecificData [out] the pointer, that was given by uno_threadpool_reply. + * If the threads for this bridge were disposed, + * *ppThreadSpecificData is null. + **/ +SAL_DLLEXPORT void SAL_CALL +uno_threadpool_enter( struct uno_threadpool_Handle * pHandle , void **ppThreadSpecificData ); + + +/** + * A request is put into a queue of waiting requests. This method is non-blocking. + * + * If the request is synchronous, it is first looked up, + * if there exists a handle with the given + * identifier. If this is the case, the thread is woken up and the doRequest + * function is called with the given pThreadSpecificData. If no handle exists, + * a new thread is created and the given threadId is bound to the new thread. + * + * If the request is asynchronous, it is put into the queue of asynchronous + * requests for the current threadid. The requests are always executed in a new + * thread, even if the thread with the given Id waiting in the pool. No Id is bound + * to the newly created thread. The responsibilty is left to the bridge ( if it + * wishes to bind a name). + * + * @param pThreadId The Id of thread, that initialized this request. (In general a + * remote threadid). + * @param pThreadSpecificData The argument, that doRequest will get. + * @param doRequest The function, that shall be called to execute the request. + * @param bIsOneway True, if the request is asynchrons. False, if it is synchronous + * + **/ +SAL_DLLEXPORT void SAL_CALL +uno_threadpool_putRequest( sal_Sequence *pThreadId, + void *pThreadSpecificData, + void ( SAL_CALL * doRequest ) ( void *pThreadSpecificData ), + sal_Bool bIsOneway ); + + +/** + * A reply is put into the threadpool. There MUST be a thread with the given threadId waiting + * for this reply. This method is non-blocking. + * + * @param pThreadSpecificData The pointer, that is returned by uno_threadpool_enter. + **/ +SAL_DLLEXPORT void SAL_CALL +uno_threadpool_putReply( sal_Sequence *pThreadId, void *pThreadSpecificData ); + + +/** + * All threads, that are waiting on handles, that were created with + * nDisposeId, are forced out of the pool. + * (@see uno_threadpool_createTicket) These threads will return from + * uno_threadpool_enter with 0 == *ppThreadSpecificData. + * Later calls to uno_threadpool_enter with the given disposeId also + * return immeadiatly. + * + * @param nDisposeId Identfies the caller of uno_threadpool_createTicket + * + * This function is called i.e. by a bridge, that is forced to dispose itself. + * When disposing of the bridge has finished, the bridge MUST call + * uno_threadpool_stopDisposeThreads. + **/ +SAL_DLLEXPORT void SAL_CALL +uno_threadpool_disposeThreads( sal_Int64 nDisposeId ); + + +/** + * Informs the threadpool, that no special treatment is needed for the given nDisposeId. + * This allows the threadpool to release internal resources + * and must be called after all threads originated from this bridge have returned. + * (This can in general be done in the bridge destructor). + * + * @param nDisposeId Identifies the caller of uno_threadpool_createTicket + * @see uno_threadpool_disposeThreads + **/ +SAL_DLLEXPORT void SAL_CALL +uno_threadpool_stopDisposeThreads( sal_Int64 nDisposeId ); + +#ifdef __cplusplus +} +#endif |