diff options
author | Daniel Boelzle <dbo@openoffice.org> | 2001-06-29 10:10:47 +0000 |
---|---|---|
committer | Daniel Boelzle <dbo@openoffice.org> | 2001-06-29 10:10:47 +0000 |
commit | 22a7af51d17143b648d102749fef5e3ac0bc7c8a (patch) | |
tree | 83e5ba00c762768631231104b05d7d99feca2d7a | |
parent | e215f15bcd277ee7380e0b703a896eea1d03935f (diff) |
#88593# any opt: avoiding heap allocation for any sizeof(type) <= sizeof(void *)
-rw-r--r-- | bridges/source/remote/static/helper.cxx | 7 | ||||
-rw-r--r-- | bridges/source/remote/urp/urp_unmarshal.cxx | 48 | ||||
-rw-r--r-- | cppu/inc/com/sun/star/uno/Any.hxx | 93 | ||||
-rw-r--r-- | cppu/inc/com/sun/star/uno/Reference.hxx | 8 | ||||
-rw-r--r-- | cppu/inc/com/sun/star/uno/genfunc.hxx | 8 | ||||
-rw-r--r-- | cppu/inc/uno/any2.h | 25 | ||||
-rw-r--r-- | cppu/source/uno/assign.hxx | 12 | ||||
-rw-r--r-- | cppu/source/uno/constr.hxx | 12 | ||||
-rw-r--r-- | cppu/source/uno/copy.hxx | 214 | ||||
-rw-r--r-- | cppu/source/uno/data.cxx | 168 | ||||
-rw-r--r-- | cppu/source/uno/destr.hxx | 127 | ||||
-rw-r--r-- | cppu/source/uno/eq.hxx | 36 | ||||
-rw-r--r-- | cppu/source/uno/prim.hxx | 21 | ||||
-rw-r--r-- | cppu/source/uno/sequence.cxx | 27 |
14 files changed, 486 insertions, 320 deletions
diff --git a/bridges/source/remote/static/helper.cxx b/bridges/source/remote/static/helper.cxx index 8c1b67de7..e6168a72c 100644 --- a/bridges/source/remote/static/helper.cxx +++ b/bridges/source/remote/static/helper.cxx @@ -2,9 +2,9 @@ * * $RCSfile: helper.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: jbu $ $Date: 2001-05-02 15:38:05 $ + * last change: $Author: dbo $ $Date: 2001-06-29 11:10:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -209,8 +209,7 @@ void SAL_CALL remote_sendQueryInterface( // set out parameter if( typelib_TypeClass_INTERFACE == anyInterface.pType->eTypeClass ) { - *ppRemoteI = *( remote_Interface ** ) anyInterface.pData; - rtl_freeMemory( anyInterface.pData ); + *ppRemoteI = ( remote_Interface * ) anyInterface.pReserved; } typelib_typedescriptionreference_release( anyInterface.pType ); } diff --git a/bridges/source/remote/urp/urp_unmarshal.cxx b/bridges/source/remote/urp/urp_unmarshal.cxx index 249ab263d..0d201cc94 100644 --- a/bridges/source/remote/urp/urp_unmarshal.cxx +++ b/bridges/source/remote/urp/urp_unmarshal.cxx @@ -2,9 +2,9 @@ * * $RCSfile: urp_unmarshal.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jbu $ $Date: 2001-05-02 14:01:28 $ + * last change: $Author: dbo $ $Date: 2001-06-29 11:10:47 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -289,7 +289,49 @@ sal_Bool Unmarshal::unpackAny( void *pDest ) if( pType ) { - pAny->pData = rtl_allocateMemory( pType->nSize ); + switch (pType->eTypeClass) + { + case typelib_TypeClass_HYPER: + case typelib_TypeClass_UNSIGNED_HYPER: + if (sizeof(void *) < sizeof(sal_Int64)) + { + pAny->pData = rtl_allocateMemory( sizeof(sal_Int64) ); + } + else + { + pAny->pData = &pAny->pReserved; + } + break; + case typelib_TypeClass_FLOAT: + if (sizeof(void *) < sizeof(float)) + { + pAny->pData = rtl_allocateMemory( sizeof(float) ); + } + else + { + pAny->pData = &pAny->pReserved; + } + break; + case typelib_TypeClass_DOUBLE: + if (sizeof(void *) < sizeof(double)) + { + pAny->pData = rtl_allocateMemory( sizeof(double) ); + } + else + { + pAny->pData = &pAny->pReserved; + } + break; + case typelib_TypeClass_STRUCT: + case typelib_TypeClass_UNION: + case typelib_TypeClass_EXCEPTION: + case typelib_TypeClass_ARRAY: + pAny->pData = rtl_allocateMemory( pType->nSize ); + break; + default: + pAny->pData = &pAny->pReserved; + } + bReturn = unpack( pAny->pData , pType ); } } diff --git a/cppu/inc/com/sun/star/uno/Any.hxx b/cppu/inc/com/sun/star/uno/Any.hxx index f461ee99d..57c724d8d 100644 --- a/cppu/inc/com/sun/star/uno/Any.hxx +++ b/cppu/inc/com/sun/star/uno/Any.hxx @@ -2,9 +2,9 @@ * * $RCSfile: Any.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: dbo $ $Date: 2001-03-16 16:34:33 $ + * last change: $Author: dbo $ $Date: 2001-06-29 11:06:53 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -218,7 +218,7 @@ inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, inline sal_Bool SAL_CALL operator == ( const Any & rAny, const sal_Bool & value ) SAL_THROW( () ) { return (typelib_TypeClass_BOOLEAN == rAny.pType->eTypeClass && - (value != sal_False) == (* reinterpret_cast< const sal_Bool * >( rAny.pData ) != sal_False)); + (value != sal_False) == (* reinterpret_cast< const sal_Bool * >( &rAny.pReserved ) != sal_False)); } // byte //__________________________________________________________________________________________________ @@ -226,7 +226,7 @@ inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, { if (typelib_TypeClass_BYTE == rAny.pType->eTypeClass) { - value = * reinterpret_cast< const sal_Int8 * >( rAny.pData ); + value = * reinterpret_cast< const sal_Int8 * >( &rAny.pReserved ); return sal_True; } return sal_False; @@ -238,11 +238,11 @@ inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int16 & value ) SA switch (rAny.pType->eTypeClass) { case typelib_TypeClass_BYTE: - value = * reinterpret_cast< const sal_Int8 * >( rAny.pData ); + value = * reinterpret_cast< const sal_Int8 * >( &rAny.pReserved ); return sal_True; case typelib_TypeClass_SHORT: case typelib_TypeClass_UNSIGNED_SHORT: - value = * reinterpret_cast< const sal_Int16 * >( rAny.pData ); + value = * reinterpret_cast< const sal_Int16 * >( &rAny.pReserved ); return sal_True; } return sal_False; @@ -253,11 +253,11 @@ inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt16 & value ) S switch (rAny.pType->eTypeClass) { case typelib_TypeClass_BYTE: - value = * reinterpret_cast< const sal_Int8 * >( rAny.pData ); + value = * reinterpret_cast< const sal_Int8 * >( &rAny.pReserved ); return sal_True; case typelib_TypeClass_SHORT: case typelib_TypeClass_UNSIGNED_SHORT: - value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData ); + value = * reinterpret_cast< const sal_uInt16 * >( &rAny.pReserved ); return sal_True; } return sal_False; @@ -269,17 +269,17 @@ inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int32 & value ) SA switch (rAny.pType->eTypeClass) { case typelib_TypeClass_BYTE: - value = * reinterpret_cast< const sal_Int8 * >( rAny.pData ); + value = * reinterpret_cast< const sal_Int8 * >( &rAny.pReserved ); return sal_True; case typelib_TypeClass_SHORT: - value = * reinterpret_cast< const sal_Int16 * >( rAny.pData ); + value = * reinterpret_cast< const sal_Int16 * >( &rAny.pReserved ); return sal_True; case typelib_TypeClass_UNSIGNED_SHORT: - value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData ); + value = * reinterpret_cast< const sal_uInt16 * >( &rAny.pReserved ); return sal_True; case typelib_TypeClass_LONG: case typelib_TypeClass_UNSIGNED_LONG: - value = * reinterpret_cast< const sal_Int32 * >( rAny.pData ); + value = * reinterpret_cast< const sal_Int32 * >( &rAny.pReserved ); return sal_True; } return sal_False; @@ -290,17 +290,17 @@ inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt32 & value ) S switch (rAny.pType->eTypeClass) { case typelib_TypeClass_BYTE: - value = * reinterpret_cast< const sal_Int8 * >( rAny.pData ); + value = * reinterpret_cast< const sal_Int8 * >( &rAny.pReserved ); return sal_True; case typelib_TypeClass_SHORT: - value = * reinterpret_cast< const sal_Int16 * >( rAny.pData ); + value = * reinterpret_cast< const sal_Int16 * >( &rAny.pReserved ); return sal_True; case typelib_TypeClass_UNSIGNED_SHORT: - value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData ); + value = * reinterpret_cast< const sal_uInt16 * >( &rAny.pReserved ); return sal_True; case typelib_TypeClass_LONG: case typelib_TypeClass_UNSIGNED_LONG: - value = * reinterpret_cast< const sal_uInt32 * >( rAny.pData ); + value = * reinterpret_cast< const sal_uInt32 * >( &rAny.pReserved ); return sal_True; } return sal_False; @@ -312,23 +312,24 @@ inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int64 & value ) SA switch (rAny.pType->eTypeClass) { case typelib_TypeClass_BYTE: - value = * reinterpret_cast< const sal_Int8 * >( rAny.pData ); + value = * reinterpret_cast< const sal_Int8 * >( &rAny.pReserved ); return sal_True; case typelib_TypeClass_SHORT: - value = * reinterpret_cast< const sal_Int16 * >( rAny.pData ); + value = * reinterpret_cast< const sal_Int16 * >( &rAny.pReserved ); return sal_True; case typelib_TypeClass_UNSIGNED_SHORT: - value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData ); + value = * reinterpret_cast< const sal_uInt16 * >( &rAny.pReserved ); return sal_True; case typelib_TypeClass_LONG: - value = * reinterpret_cast< const sal_Int32 * >( rAny.pData ); + value = * reinterpret_cast< const sal_Int32 * >( &rAny.pReserved ); return sal_True; case typelib_TypeClass_UNSIGNED_LONG: - value = * reinterpret_cast< const sal_uInt32 * >( rAny.pData ); + value = * reinterpret_cast< const sal_uInt32 * >( &rAny.pReserved ); return sal_True; case typelib_TypeClass_HYPER: case typelib_TypeClass_UNSIGNED_HYPER: - value = * reinterpret_cast< const sal_Int64 * >( rAny.pData ); + value = * reinterpret_cast< const sal_Int64 * >( + (sizeof(void *) >= sizeof(sal_Int64)) ? (void *)&rAny.pReserved : rAny.pData ); return sal_True; } return sal_False; @@ -339,23 +340,24 @@ inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt64 & value ) S switch (rAny.pType->eTypeClass) { case typelib_TypeClass_BYTE: - value = * reinterpret_cast< const sal_Int8 * >( rAny.pData ); + value = * reinterpret_cast< const sal_Int8 * >( &rAny.pReserved ); return sal_True; case typelib_TypeClass_SHORT: - value = * reinterpret_cast< const sal_Int16 * >( rAny.pData ); + value = * reinterpret_cast< const sal_Int16 * >( &rAny.pReserved ); return sal_True; case typelib_TypeClass_UNSIGNED_SHORT: - value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData ); + value = * reinterpret_cast< const sal_uInt16 * >( &rAny.pReserved ); return sal_True; case typelib_TypeClass_LONG: - value = * reinterpret_cast< const sal_Int32 * >( rAny.pData ); + value = * reinterpret_cast< const sal_Int32 * >( &rAny.pReserved ); return sal_True; case typelib_TypeClass_UNSIGNED_LONG: - value = * reinterpret_cast< const sal_uInt32 * >( rAny.pData ); + value = * reinterpret_cast< const sal_uInt32 * >( &rAny.pReserved ); return sal_True; case typelib_TypeClass_HYPER: case typelib_TypeClass_UNSIGNED_HYPER: - value = * reinterpret_cast< const sal_uInt64 * >( rAny.pData ); + value = * reinterpret_cast< const sal_uInt64 * >( + (sizeof(void *) >= sizeof(sal_uInt64)) ? (void *)&rAny.pReserved : rAny.pData ); return sal_True; } return sal_False; @@ -367,16 +369,17 @@ inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, float & value ) SAL_TH switch (rAny.pType->eTypeClass) { case typelib_TypeClass_BYTE: - value = * reinterpret_cast< const sal_Int8 * >( rAny.pData ); + value = * reinterpret_cast< const sal_Int8 * >( &rAny.pReserved ); return sal_True; case typelib_TypeClass_SHORT: - value = * reinterpret_cast< const sal_Int16 * >( rAny.pData ); + value = * reinterpret_cast< const sal_Int16 * >( &rAny.pReserved ); return sal_True; case typelib_TypeClass_UNSIGNED_SHORT: - value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData ); + value = * reinterpret_cast< const sal_uInt16 * >( &rAny.pReserved ); return sal_True; case typelib_TypeClass_FLOAT: - value = * reinterpret_cast< const float * >( rAny.pData ); + value = * reinterpret_cast< const float * >( + (sizeof(void *) >= sizeof(float)) ? (void *)&rAny.pReserved : rAny.pData ); return sal_True; } return sal_False; @@ -388,25 +391,27 @@ inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, double & value ) SAL_T switch (rAny.pType->eTypeClass) { case typelib_TypeClass_BYTE: - value = * reinterpret_cast< const sal_Int8 * >( rAny.pData ); + value = * reinterpret_cast< const sal_Int8 * >( &rAny.pReserved ); return sal_True; case typelib_TypeClass_SHORT: - value = * reinterpret_cast< const sal_Int16 * >( rAny.pData ); + value = * reinterpret_cast< const sal_Int16 * >( &rAny.pReserved ); return sal_True; case typelib_TypeClass_UNSIGNED_SHORT: - value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData ); + value = * reinterpret_cast< const sal_uInt16 * >( &rAny.pReserved ); return sal_True; case typelib_TypeClass_LONG: - value = * reinterpret_cast< const sal_Int32 * >( rAny.pData ); + value = * reinterpret_cast< const sal_Int32 * >( &rAny.pReserved ); return sal_True; case typelib_TypeClass_UNSIGNED_LONG: - value = * reinterpret_cast< const sal_uInt32 * >( rAny.pData ); + value = * reinterpret_cast< const sal_uInt32 * >( &rAny.pReserved ); return sal_True; case typelib_TypeClass_FLOAT: - value = * reinterpret_cast< const float * >( rAny.pData ); + value = * reinterpret_cast< const float * >( + (sizeof(void *) >= sizeof(float)) ? (void *)&rAny.pReserved : rAny.pData ); return sal_True; case typelib_TypeClass_DOUBLE: - value = * reinterpret_cast< const double * >( rAny.pData ); + value = * reinterpret_cast< const double * >( + (sizeof(void *) >= sizeof(double)) ? (void *)&rAny.pReserved : rAny.pData ); return sal_True; } return sal_False; @@ -417,7 +422,7 @@ inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, ::rtl::OUString & valu { if (typelib_TypeClass_STRING == rAny.pType->eTypeClass) { - value = * reinterpret_cast< const ::rtl::OUString * >( rAny.pData ); + value = * reinterpret_cast< const ::rtl::OUString * >( &rAny.pReserved ); return sal_True; } return sal_False; @@ -426,7 +431,7 @@ inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, ::rtl::OUString & valu inline sal_Bool SAL_CALL operator == ( const Any & rAny, const ::rtl::OUString & value ) SAL_THROW( () ) { return (typelib_TypeClass_STRING == rAny.pType->eTypeClass && - value == * reinterpret_cast< const ::rtl::OUString * >( rAny.pData )); + value.equals( * reinterpret_cast< const ::rtl::OUString * >( &rAny.pReserved ) )); } // type //__________________________________________________________________________________________________ @@ -434,7 +439,7 @@ inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, Type & value ) SAL_THR { if (typelib_TypeClass_TYPE == rAny.pType->eTypeClass) { - value = * reinterpret_cast< const Type * >( rAny.pData ); + value = * reinterpret_cast< const Type * >( &rAny.pReserved ); return sal_True; } return sal_False; @@ -443,7 +448,7 @@ inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, Type & value ) SAL_THR inline sal_Bool SAL_CALL operator == ( const Any & rAny, const Type & value ) SAL_THROW( () ) { return (typelib_TypeClass_TYPE == rAny.pType->eTypeClass && - value == * reinterpret_cast< const Type * >( rAny.pData )); + value.equals( * reinterpret_cast< const Type * >( &rAny.pReserved ) )); } // any //__________________________________________________________________________________________________ @@ -462,7 +467,7 @@ inline sal_Bool SAL_CALL operator == ( const Any & rAny, const BaseReference & v { if (typelib_TypeClass_INTERFACE == rAny.pType->eTypeClass) { - return reinterpret_cast< BaseReference const * >( rAny.pData )->operator == ( value ); + return reinterpret_cast< const BaseReference * >( &rAny.pReserved )->operator == ( value ); } return sal_False; } diff --git a/cppu/inc/com/sun/star/uno/Reference.hxx b/cppu/inc/com/sun/star/uno/Reference.hxx index 2086b4216..28ff2fc76 100644 --- a/cppu/inc/com/sun/star/uno/Reference.hxx +++ b/cppu/inc/com/sun/star/uno/Reference.hxx @@ -2,9 +2,9 @@ * * $RCSfile: Reference.hxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: dbo $ $Date: 2001-03-21 12:42:59 $ + * last change: $Author: dbo $ $Date: 2001-06-29 11:06:53 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -123,8 +123,8 @@ inline interface_type * Reference< interface_type >::__query( Any aRet( pInterface->queryInterface( rType ) ); if (typelib_TypeClass_INTERFACE == aRet.pType->eTypeClass) { - interface_type * pRet = * reinterpret_cast< interface_type ** >( aRet.pData ); - * reinterpret_cast< interface_type ** >( aRet.pData ) = 0; + interface_type * pRet = reinterpret_cast< interface_type * >( aRet.pReserved ); + aRet.pReserved = 0; return pRet; } } diff --git a/cppu/inc/com/sun/star/uno/genfunc.hxx b/cppu/inc/com/sun/star/uno/genfunc.hxx index e35ada7ea..c9658620a 100644 --- a/cppu/inc/com/sun/star/uno/genfunc.hxx +++ b/cppu/inc/com/sun/star/uno/genfunc.hxx @@ -2,9 +2,9 @@ * * $RCSfile: genfunc.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: dbo $ $Date: 2001-03-09 12:10:55 $ + * last change: $Author: dbo $ $Date: 2001-06-29 11:06:53 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -110,8 +110,8 @@ inline void * SAL_CALL cpp_queryInterface( void * pCppI, typelib_TypeDescription * reinterpret_cast< const Type * >( &pType ) ) ); if (typelib_TypeClass_INTERFACE == aRet.pType->eTypeClass) { - XInterface * pRet = * reinterpret_cast< XInterface ** >( aRet.pData ); - * reinterpret_cast< XInterface ** >( aRet.pData ) = 0; + XInterface * pRet = reinterpret_cast< XInterface * >( aRet.pReserved ); + aRet.pReserved = 0; return pRet; } #ifndef EXCEPTIONS_OFF diff --git a/cppu/inc/uno/any2.h b/cppu/inc/uno/any2.h index 019d292cd..b0229eca4 100644 --- a/cppu/inc/uno/any2.h +++ b/cppu/inc/uno/any2.h @@ -2,9 +2,9 @@ * * $RCSfile: any2.h,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: dbo $ $Date: 2001-04-17 13:29:24 $ + * last change: $Author: dbo $ $Date: 2001-06-29 11:06:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -88,12 +88,15 @@ struct _uno_Mapping; */ typedef struct _uno_Any { - /** type of value<br> + /** type of value */ struct _typelib_TypeDescriptionReference * pType; - /** pointer to value<br> + /** pointer to value */ void * pData; + /** reserved space for storing value + */ + void * pReserved; } uno_Any; #ifdef SAL_W32 @@ -104,7 +107,7 @@ typedef struct _uno_Any /** Assign an any with a given value. Interfaces are acquired or released by the given callback functions. - <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 @@ -118,7 +121,7 @@ void SAL_CALL uno_any_assign( SAL_THROW_EXTERN_C(); /** Assign an any with a given value. Interfaces are acquired or released by the given callback functions. - <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 @@ -133,7 +136,7 @@ void SAL_CALL uno_type_any_assign( /** 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 @@ -146,7 +149,7 @@ void SAL_CALL uno_any_construct( SAL_THROW_EXTERN_C(); /** 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 @@ -159,7 +162,7 @@ void SAL_CALL uno_type_any_construct( SAL_THROW_EXTERN_C(); /** 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 @@ -171,7 +174,7 @@ void SAL_CALL uno_any_constructAndConvert( struct _uno_Mapping * mapping ) SAL_THROW_EXTERN_C(); /** 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 @@ -184,7 +187,7 @@ void SAL_CALL uno_type_any_constructAndConvert( SAL_THROW_EXTERN_C(); /** 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 */ diff --git a/cppu/source/uno/assign.hxx b/cppu/source/uno/assign.hxx index 284914789..66985d937 100644 --- a/cppu/source/uno/assign.hxx +++ b/cppu/source/uno/assign.hxx @@ -2,9 +2,9 @@ * * $RCSfile: assign.hxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: dbo $ $Date: 2001-06-25 08:32:01 $ + * last change: $Author: dbo $ $Date: 2001-06-29 11:06:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -243,7 +243,7 @@ inline sal_Bool __assignArray( for (i=0; i < nTotalElements; i++) { ::typelib_typedescriptionreference_release( *((typelib_TypeDescriptionReference **)pDest + i) ); - TYPE_ACQUIRE( + __TYPE_ACQUIRE( *((typelib_TypeDescriptionReference **)pDest + i) = *((typelib_TypeDescriptionReference **)pSource + i) ); } @@ -261,7 +261,7 @@ inline sal_Bool __assignArray( case typelib_TypeClass_ENUM: for (i=0; i < nTotalElements; i++) { - *((int *)pDest + i) = *((int *)pSource + i); + *((sal_Int32 *)pDest + i) = *((sal_Int32 *)pSource + i); } bRet = sal_True; break; @@ -540,7 +540,7 @@ inline sal_Bool __assignData( { case typelib_TypeClass_TYPE: ::typelib_typedescriptionreference_release( *(typelib_TypeDescriptionReference **)pDest ); - TYPE_ACQUIRE( + __TYPE_ACQUIRE( *(typelib_TypeDescriptionReference **)pDest = *(typelib_TypeDescriptionReference **)pSource ); return sal_True; } @@ -552,7 +552,7 @@ inline sal_Bool __assignData( case typelib_TypeClass_ENUM: if (__type_equals( pDestType, pSourceType )) { - *(int *)pDest = *(int *)pSource; + *(sal_Int32 *)pDest = *(sal_Int32 *)pSource; return sal_True; } return sal_False; diff --git a/cppu/source/uno/constr.hxx b/cppu/source/uno/constr.hxx index e3b09443a..a11232726 100644 --- a/cppu/source/uno/constr.hxx +++ b/cppu/source/uno/constr.hxx @@ -2,9 +2,9 @@ * * $RCSfile: constr.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: pl $ $Date: 2001-05-10 20:12:55 $ + * last change: $Author: dbo $ $Date: 2001-06-29 11:06:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -158,7 +158,7 @@ inline void __defaultConstructArray( case typelib_TypeClass_ENUM: for (i=0; i < nTotalElements; i++) { - *((int *)pMem + i) = ((typelib_EnumTypeDescription *)pElementType)->nDefaultEnumValue; + *((sal_Int32 *)pMem + i) = ((typelib_EnumTypeDescription *)pElementType)->nDefaultEnumValue; } break; #ifdef CPPU_ASSERTIONS @@ -228,7 +228,7 @@ inline void __defaultConstructData( break; case typelib_TypeClass_STRING: *(rtl_uString **)pMem = 0; - rtl_uString_new( (rtl_uString **)pMem ); + ::rtl_uString_new( (rtl_uString **)pMem ); break; case typelib_TypeClass_TYPE: *(typelib_TypeDescriptionReference **)pMem = __getVoidType(); @@ -239,12 +239,12 @@ inline void __defaultConstructData( case typelib_TypeClass_ENUM: if (pTypeDescr) { - *(int *)pMem = ((typelib_EnumTypeDescription *)pTypeDescr)->nDefaultEnumValue; + *(sal_Int32 *)pMem = ((typelib_EnumTypeDescription *)pTypeDescr)->nDefaultEnumValue; } else { TYPELIB_DANGER_GET( &pTypeDescr, pType ); - *(int *)pMem = ((typelib_EnumTypeDescription *)pTypeDescr)->nDefaultEnumValue; + *(sal_Int32 *)pMem = ((typelib_EnumTypeDescription *)pTypeDescr)->nDefaultEnumValue; TYPELIB_DANGER_RELEASE( pTypeDescr ); } break; diff --git a/cppu/source/uno/copy.hxx b/cppu/source/uno/copy.hxx index d108e40c2..d12b55683 100644 --- a/cppu/source/uno/copy.hxx +++ b/cppu/source/uno/copy.hxx @@ -2,9 +2,9 @@ * * $RCSfile: copy.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: pl $ $Date: 2001-05-10 20:12:55 $ + * last change: $Author: dbo $ $Date: 2001-06-29 11:06:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -101,18 +101,20 @@ inline void __copyConstructStruct( { while (nDescr--) { - ::uno_type_copyAndConvertData( (char *)pDest + pMemberOffsets[nDescr], - (char *)pSource + pMemberOffsets[nDescr], - ppTypeRefs[nDescr], mapping ); + ::uno_type_copyAndConvertData( + (char *)pDest + pMemberOffsets[nDescr], + (char *)pSource + pMemberOffsets[nDescr], + ppTypeRefs[nDescr], mapping ); } } else { while (nDescr--) { - ::uno_type_copyData( (char *)pDest + pMemberOffsets[nDescr], - (char *)pSource + pMemberOffsets[nDescr], - ppTypeRefs[nDescr], acquire ); + ::uno_type_copyData( + (char *)pDest + pMemberOffsets[nDescr], + (char *)pSource + pMemberOffsets[nDescr], + ppTypeRefs[nDescr], acquire ); } } } @@ -133,18 +135,20 @@ inline void __copyConstructArray( { for(sal_Int32 i = 0; i < nTotalElements; i++) { - ::uno_type_copyAndConvertData( (sal_Char *)pDest + i * nElementSize, - (sal_Char *)pSource + i * nElementSize, - pElementTypeRef, mapping ); + ::uno_type_copyAndConvertData( + (sal_Char *)pDest + i * nElementSize, + (sal_Char *)pSource + i * nElementSize, + pElementTypeRef, mapping ); } } else { for(sal_Int32 i = 0; i < nTotalElements; i++) { - ::uno_type_copyData( (sal_Char *)pDest + (i * nElementSize), - (sal_Char *)pSource + (i * nElementSize), - pElementTypeRef, acquire ); + ::uno_type_copyData( + (sal_Char *)pDest + (i * nElementSize), + (sal_Char *)pSource + (i * nElementSize), + pElementTypeRef, acquire ); } } } @@ -186,55 +190,79 @@ inline void __copyConstructAnyFromData( uno_AcquireFunc acquire, uno_Mapping * mapping ) SAL_THROW ( () ) { - TYPE_ACQUIRE( pType ); + __TYPE_ACQUIRE( pType ); pDestAny->pType = pType; switch (pType->eTypeClass) { case typelib_TypeClass_CHAR: - pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Unicode) ); - *(sal_Unicode *)pDestAny->pData = *(sal_Unicode *)pSource; + pDestAny->pData = &pDestAny->pReserved; + *(sal_Unicode *)&pDestAny->pReserved = *(sal_Unicode *)pSource; break; case typelib_TypeClass_BOOLEAN: - pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Bool) ); - *(sal_Bool *)pDestAny->pData = (*(sal_Bool *)pSource != sal_False); + pDestAny->pData = &pDestAny->pReserved; + *(sal_Bool *)&pDestAny->pReserved = (*(sal_Bool *)pSource != sal_False); break; case typelib_TypeClass_BYTE: - pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int8) ); - *(sal_Int8 *)pDestAny->pData = *(sal_Int8 *)pSource; + pDestAny->pData = &pDestAny->pReserved; + *(sal_Int8 *)&pDestAny->pReserved = *(sal_Int8 *)pSource; break; case typelib_TypeClass_SHORT: case typelib_TypeClass_UNSIGNED_SHORT: - pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int16) ); - *(sal_Int16 *)pDestAny->pData = *(sal_Int16 *)pSource; + pDestAny->pData = &pDestAny->pReserved; + *(sal_Int16 *)&pDestAny->pReserved = *(sal_Int16 *)pSource; break; case typelib_TypeClass_LONG: case typelib_TypeClass_UNSIGNED_LONG: - pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int32) ); - *(sal_Int32 *)pDestAny->pData = *(sal_Int32 *)pSource; + pDestAny->pData = &pDestAny->pReserved; + *(sal_Int32 *)&pDestAny->pReserved = *(sal_Int32 *)pSource; break; case typelib_TypeClass_HYPER: case typelib_TypeClass_UNSIGNED_HYPER: - pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int64) ); - *(sal_Int64 *)pDestAny->pData = *(sal_Int64 *)pSource; + if (sizeof(void *) >= sizeof(sal_Int64)) + { + pDestAny->pData = &pDestAny->pReserved; + *(sal_Int64 *)&pDestAny->pReserved = *(sal_Int64 *)pSource; + } + else + { + pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int64) ); + *(sal_Int64 *)pDestAny->pData = *(sal_Int64 *)pSource; + } break; case typelib_TypeClass_FLOAT: - pDestAny->pData = ::rtl_allocateMemory( sizeof(float) ); - *(float *)pDestAny->pData = *(float *)pSource; + if (sizeof(void *) >= sizeof(float)) + { + pDestAny->pData = &pDestAny->pReserved; + *(float *)&pDestAny->pReserved = *(float *)pSource; + } + else + { + pDestAny->pData = ::rtl_allocateMemory( sizeof(float) ); + *(float *)pDestAny->pData = *(float *)pSource; + } break; case typelib_TypeClass_DOUBLE: - pDestAny->pData = ::rtl_allocateMemory( sizeof(double) ); - *(double *)pDestAny->pData = *(double *)pSource; + if (sizeof(void *) >= sizeof(double)) + { + pDestAny->pData = &pDestAny->pReserved; + *(double *)&pDestAny->pReserved = *(double *)pSource; + } + else + { + pDestAny->pData = ::rtl_allocateMemory( sizeof(double) ); + *(double *)pDestAny->pData = *(double *)pSource; + } break; case typelib_TypeClass_STRING: ::rtl_uString_acquire( *(rtl_uString **)pSource ); - pDestAny->pData = ::rtl_allocateMemory( sizeof(rtl_uString *) ); - *(rtl_uString **)pDestAny->pData = *(rtl_uString **)pSource; + pDestAny->pData = &pDestAny->pReserved; + *(rtl_uString **)&pDestAny->pReserved = *(rtl_uString **)pSource; break; case typelib_TypeClass_TYPE: - TYPE_ACQUIRE( *(typelib_TypeDescriptionReference **)pSource ); - pDestAny->pData = ::rtl_allocateMemory( sizeof(typelib_TypeDescriptionReference *) ); - *(typelib_TypeDescriptionReference **)pDestAny->pData = *(typelib_TypeDescriptionReference **)pSource; + __TYPE_ACQUIRE( *(typelib_TypeDescriptionReference **)pSource ); + pDestAny->pData = &pDestAny->pReserved; + *(typelib_TypeDescriptionReference **)&pDestAny->pReserved = *(typelib_TypeDescriptionReference **)pSource; break; #ifdef CPPU_ASSERTIONS case typelib_TypeClass_ANY: @@ -242,8 +270,9 @@ inline void __copyConstructAnyFromData( break; #endif case typelib_TypeClass_ENUM: - pDestAny->pData = ::rtl_allocateMemory( sizeof(int) ); - *(int *)pDestAny->pData = *(int *)pSource; + pDestAny->pData = &pDestAny->pReserved; + // enum is forced to 32bit long + *(sal_Int32 *)&pDestAny->pReserved = *(sal_Int32 *)pSource; break; #ifdef CPPU_ASSERTIONS case typelib_TypeClass_TYPEDEF: @@ -306,11 +335,11 @@ inline void __copyConstructAnyFromData( } break; case typelib_TypeClass_SEQUENCE: - pDestAny->pData = ::rtl_allocateMemory( sizeof(uno_Sequence *) ); + pDestAny->pData = &pDestAny->pReserved; if (pTypeDescr) { copyConstructSequence( - (uno_Sequence **)pDestAny->pData, *(uno_Sequence **)pSource, + (uno_Sequence **)&pDestAny->pReserved, *(uno_Sequence **)pSource, ((typelib_IndirectTypeDescription *)pTypeDescr)->pType, acquire, mapping ); } @@ -318,21 +347,21 @@ inline void __copyConstructAnyFromData( { TYPELIB_DANGER_GET( &pTypeDescr, pType ); copyConstructSequence( - (uno_Sequence **)pDestAny->pData, *(uno_Sequence **)pSource, + (uno_Sequence **)&pDestAny->pReserved, *(uno_Sequence **)pSource, ((typelib_IndirectTypeDescription *)pTypeDescr)->pType, acquire, mapping ); TYPELIB_DANGER_RELEASE( pTypeDescr ); } break; case typelib_TypeClass_INTERFACE: - pDestAny->pData = ::rtl_allocateMemory( sizeof(void *) ); + pDestAny->pData = &pDestAny->pReserved; if (mapping) { - *(void **)pDestAny->pData = __map( *(void **)pSource, pType, pTypeDescr, mapping ); + pDestAny->pReserved = __map( *(void **)pSource, pType, pTypeDescr, mapping ); } else { - __acquire( *(void **)pDestAny->pData = *(void **)pSource, acquire ); + __acquire( pDestAny->pReserved = *(void **)pSource, acquire ); } break; } @@ -375,64 +404,88 @@ inline void __copyConstructAny( } else // default construct { - TYPE_ACQUIRE( pType ); + __TYPE_ACQUIRE( pType ); pDestAny->pType = pType; switch (pType->eTypeClass) { case typelib_TypeClass_CHAR: - pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Unicode) ); - *(sal_Unicode *)pDestAny->pData = '\0'; + pDestAny->pData = &pDestAny->pReserved; + *(sal_Unicode *)&pDestAny->pReserved = '\0'; break; case typelib_TypeClass_BOOLEAN: - pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Bool) ); - *(sal_Bool *)pDestAny->pData = sal_False; + pDestAny->pData = &pDestAny->pReserved; + *(sal_Bool *)&pDestAny->pReserved = sal_False; break; case typelib_TypeClass_BYTE: - pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int8) ); - *(sal_Int8 *)pDestAny->pData = 0; + pDestAny->pData = &pDestAny->pReserved; + *(sal_Int8 *)&pDestAny->pReserved = 0; break; case typelib_TypeClass_SHORT: case typelib_TypeClass_UNSIGNED_SHORT: - pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int16) ); - *(sal_Int16 *)pDestAny->pData = 0; + pDestAny->pData = &pDestAny->pReserved; + *(sal_Int16 *)&pDestAny->pReserved = 0; break; case typelib_TypeClass_LONG: case typelib_TypeClass_UNSIGNED_LONG: - pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int32) ); - *(sal_Int32 *)pDestAny->pData = 0; + pDestAny->pData = &pDestAny->pReserved; + *(sal_Int32 *)&pDestAny->pReserved = 0; break; case typelib_TypeClass_HYPER: case typelib_TypeClass_UNSIGNED_HYPER: - pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int64) ); - *(sal_Int64 *)pDestAny->pData = 0; + if (sizeof(void *) >= sizeof(sal_Int64)) + { + pDestAny->pData = &pDestAny->pReserved; + *(sal_Int64 *)&pDestAny->pReserved = 0; + } + else + { + pDestAny->pData = ::rtl_allocateMemory( sizeof(sal_Int64) ); + *(sal_Int64 *)pDestAny->pData = 0; + } break; case typelib_TypeClass_FLOAT: - pDestAny->pData = ::rtl_allocateMemory( sizeof(float) ); - *(float *)pDestAny->pData = 0.0; + if (sizeof(void *) >= sizeof(float)) + { + pDestAny->pData = &pDestAny->pReserved; + *(float *)&pDestAny->pReserved = 0.0; + } + else + { + pDestAny->pData = ::rtl_allocateMemory( sizeof(float) ); + *(float *)pDestAny->pData = 0.0; + } break; case typelib_TypeClass_DOUBLE: - pDestAny->pData = ::rtl_allocateMemory( sizeof(double) ); - *(double *)pDestAny->pData = 0.0; + if (sizeof(void *) >= sizeof(double)) + { + pDestAny->pData = &pDestAny->pReserved; + *(double *)&pDestAny->pReserved = 0.0; + } + else + { + pDestAny->pData = ::rtl_allocateMemory( sizeof(double) ); + *(double *)pDestAny->pData = 0.0; + } break; case typelib_TypeClass_STRING: - pDestAny->pData = ::rtl_allocateMemory( sizeof(rtl_uString *) ); - *(rtl_uString **)pDestAny->pData = 0; - rtl_uString_new( (rtl_uString **)pDestAny->pData ); + pDestAny->pData = &pDestAny->pReserved; + *(rtl_uString **)&pDestAny->pReserved = 0; + ::rtl_uString_new( (rtl_uString **)&pDestAny->pReserved ); break; case typelib_TypeClass_TYPE: - pDestAny->pData = ::rtl_allocateMemory( sizeof(typelib_TypeDescriptionReference *) ); - *(typelib_TypeDescriptionReference **)pDestAny->pData = __getVoidType(); + pDestAny->pData = &pDestAny->pReserved; + *(typelib_TypeDescriptionReference **)&pDestAny->pReserved = __getVoidType(); break; case typelib_TypeClass_ENUM: - pDestAny->pData = ::rtl_allocateMemory( sizeof(int) ); + pDestAny->pData = &pDestAny->pReserved; if (pTypeDescr) { - *(int *)pDestAny->pData = ((typelib_EnumTypeDescription *)pTypeDescr)->nDefaultEnumValue; + *(sal_Int32 *)&pDestAny->pReserved = ((typelib_EnumTypeDescription *)pTypeDescr)->nDefaultEnumValue; } else { TYPELIB_DANGER_GET( &pTypeDescr, pType ); - *(int *)pDestAny->pData = ((typelib_EnumTypeDescription *)pTypeDescr)->nDefaultEnumValue; + *(sal_Int32 *)&pDestAny->pReserved = ((typelib_EnumTypeDescription *)pTypeDescr)->nDefaultEnumValue; TYPELIB_DANGER_RELEASE( pTypeDescr ); } break; @@ -489,12 +542,12 @@ inline void __copyConstructAny( } break; case typelib_TypeClass_SEQUENCE: - pDestAny->pData = ::rtl_allocateMemory( sizeof(uno_Sequence *) ); - *(uno_Sequence **)pDestAny->pData = __getEmptySequence(); + pDestAny->pData = &pDestAny->pReserved; + *(uno_Sequence **)&pDestAny->pReserved = __getEmptySequence(); break; case typelib_TypeClass_INTERFACE: - pDestAny->pData = ::rtl_allocateMemory( sizeof(void *) ); - *(void **)pDestAny->pData = 0; // either cpp or c-uno interface + pDestAny->pData = &pDestAny->pReserved; + pDestAny->pReserved = 0; // either cpp or c-uno interface break; } } @@ -508,8 +561,7 @@ inline void __copyConstructSequence( SAL_THROW ( () ) { typelib_TypeClass eTypeClass = pElementType->eTypeClass; - if (!mapping || - (eTypeClass <= typelib_TypeClass_ENUM && eTypeClass != typelib_TypeClass_ANY)) + if (!mapping || (eTypeClass <= typelib_TypeClass_ENUM && eTypeClass != typelib_TypeClass_ANY)) { ::osl_incrementInterlockedCount( &pSource->nRefCount ); *ppDest = pSource; @@ -601,9 +653,11 @@ inline void __copyConstructSequence( char * pDest = pElements + (nPos * nElementSize); char * pSource = pSourceElements + (nPos * nElementSize); - typelib_TypeDescriptionReference * pSetType = __unionGetSetType( pSource, pElementTypeDescr ); - ::uno_type_copyAndConvertData( pDest + nValueOffset, pSource + nValueOffset, - pSetType, mapping ); + typelib_TypeDescriptionReference * pSetType = __unionGetSetType( + pSource, pElementTypeDescr ); + ::uno_type_copyAndConvertData( + pDest + nValueOffset, pSource + nValueOffset, + pSetType, mapping ); *(sal_Int64 *)pDest = *(sal_Int64 *)pSource; ::typelib_typedescriptionreference_release( pSetType ); } @@ -723,7 +777,7 @@ inline void __copyConstructData( *(rtl_uString **)pDest = *(rtl_uString **)pSource; break; case typelib_TypeClass_TYPE: - TYPE_ACQUIRE( *(typelib_TypeDescriptionReference **)pSource ); + __TYPE_ACQUIRE( *(typelib_TypeDescriptionReference **)pSource ); *(typelib_TypeDescriptionReference **)pDest = *(typelib_TypeDescriptionReference **)pSource; break; case typelib_TypeClass_ANY: @@ -733,7 +787,7 @@ inline void __copyConstructData( acquire, mapping ); break; case typelib_TypeClass_ENUM: - *(int *)pDest = *(int *)pSource; + *(sal_Int32 *)pDest = *(sal_Int32 *)pSource; break; #ifdef CPPU_ASSERTIONS case typelib_TypeClass_TYPEDEF: diff --git a/cppu/source/uno/data.cxx b/cppu/source/uno/data.cxx index 92247fbe7..2b9df950a 100644 --- a/cppu/source/uno/data.cxx +++ b/cppu/source/uno/data.cxx @@ -2,9 +2,9 @@ * * $RCSfile: data.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: dbo $ $Date: 2001-03-28 10:46:10 $ + * last change: $Author: dbo $ $Date: 2001-06-29 11:06:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -144,7 +144,9 @@ void destructSequence( { if (pSequence->nElements) { - __destructElements( pSequence->elements, pElementType, 0, pSequence->nElements, release ); + __destructElements( + pSequence->elements, pElementType, + 0, pSequence->nElements, release ); } ::rtl_freeMemory( pSequence ); } @@ -235,9 +237,10 @@ sal_Bool SAL_CALL uno_type_equalData( uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release ) SAL_THROW_EXTERN_C() { - return __equalData( pVal1, pVal1Type, 0, - pVal2, pVal2Type, 0, - queryInterface, release ); + return __equalData( + pVal1, pVal1Type, 0, + pVal2, pVal2Type, 0, + queryInterface, release ); } //################################################################################################## sal_Bool SAL_CALL uno_equalData( @@ -246,9 +249,10 @@ sal_Bool SAL_CALL uno_equalData( uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release ) SAL_THROW_EXTERN_C() { - return __equalData( pVal1, pVal1TD->pWeakRef, pVal1TD, - pVal2, pVal2TD->pWeakRef, pVal2TD, - queryInterface, release ); + return __equalData( + pVal1, pVal1TD->pWeakRef, pVal1TD, + pVal2, pVal2TD->pWeakRef, pVal2TD, + queryInterface, release ); } //################################################################################################## sal_Bool SAL_CALL uno_type_assignData( @@ -257,9 +261,10 @@ sal_Bool SAL_CALL uno_type_assignData( uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release ) SAL_THROW_EXTERN_C() { - return __assignData( pDest, pDestType, 0, - pSource, pSourceType, 0, - queryInterface, acquire, release ); + return __assignData( + pDest, pDestType, 0, + pSource, pSourceType, 0, + queryInterface, acquire, release ); } //################################################################################################## sal_Bool SAL_CALL uno_assignData( @@ -268,9 +273,10 @@ sal_Bool SAL_CALL uno_assignData( uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release ) SAL_THROW_EXTERN_C() { - return __assignData( pDest, pDestTD->pWeakRef, pDestTD, - pSource, pSourceTD->pWeakRef, pSourceTD, - queryInterface, acquire, release ); + return __assignData( + pDest, pDestTD->pWeakRef, pDestTD, + pSource, pSourceTD->pWeakRef, pSourceTD, + queryInterface, acquire, release ); } } @@ -320,67 +326,87 @@ struct second : public empty class BinaryCompatible_Impl { public: - BinaryCompatible_Impl() + BinaryCompatible_Impl(); +}; +BinaryCompatible_Impl::BinaryCompatible_Impl() +{ + // sequence + if ((SAL_SEQUENCE_HEADER_SIZE % 8) != 0) { - if ((SAL_SEQUENCE_HEADER_SIZE % 8) != 0) - abort(); - - /* - If the feature failed search FEATURE_ and correct it. - */ - // the sizeof enum must be the size of an integer - // FEATURE_ENUM - if( sizeof( TypeClass ) != sizeof( int ) ) - abort(); - - // the sizeof any must be sizeof( void * ) * 2, - // the first is a pointer to typelib_TypeDescription, the second is the pointer to the data - // FEATURE_ANY - if( sizeof( Any ) != sizeof( uno_Any ) ) - abort(); - if( sizeof( Any ) != sizeof( void * ) * 2 ) - abort(); - if( (sal_Int32)&((Any *) 16)->pType != 16 ) - abort(); - if( (sal_Int32)&((Any *) 16)->pData != 16 + sizeof( void * ) ) - abort(); - - // All types can moved from one one memory location to another - // without calling the copy constructor and the destructor. - // FEATURE_MEMORYMOVE_INVARIANT - - // All types can moved from one one memory location to another - // without calling the copy constructor and the destructor. - // FEATURE_ZEROCONSTRUCTOR - - // The reference class must be a pointer to XInterface or a subclass of XInterface - // FEATURE_INTERFACE - if( sizeof( Reference< XInterface > ) != sizeof( XInterface * ) ) - abort(); - - // The reference class must be a pointer to XInterface or a subclass of XInterface - // FEATURE_WSTRING - if( sizeof( OUString ) != sizeof( rtl_uString * ) ) - abort(); - - // The reference class must be a pointer to XInterface or a subclass of XInterface - // FEATURE_ALIGN - if( sizeof( M ) != 8 || sizeof( N ) != 12 || sizeof( O ) != 16 ) - abort(); - + OSL_ENSURE( 0, "### sal sequence header size not aligned to 8?!" ); + abort(); + } + // enum + if( sizeof( TypeClass ) != sizeof( sal_Int32 ) ) + { + OSL_ENSURE( 0, "### enum not 32bit?!" ); + abort(); + } + // any + if (sizeof(void *) < sizeof(sal_Int32)) + { + OSL_ENSURE( 0, "### size of pointer less than 32bit?!" ); + abort(); + } + if( sizeof( Any ) != sizeof( uno_Any ) ) + { + OSL_ENSURE( 0, "### Any inheritance adds space to uno_Any?!" ); + abort(); + } + if( sizeof( Any ) != sizeof( void * ) * 3 ) + { + OSL_ENSURE( 0, "### sizeof( Any ) != sizeof( void * ) * 3 ?!" ); + abort(); + } + if( (sal_Int32)&((Any *) 16)->pType != 16 ) + { + OSL_ENSURE( 0, "### (sal_Int32)&((Any *) 16)->pType != 16 ?!" ); + abort(); + } + if( (sal_Int32)&((Any *) 16)->pData != 16 + sizeof( void * ) ) + { + OSL_ENSURE( 0, "### (sal_Int32)&((Any *) 16)->pData != 16 + sizeof( void * ) ?!" ); + abort(); + } + if( (sal_Int32)&((Any *) 16)->pReserved != 16 + (2* sizeof( void * )) ) + { + OSL_ENSURE( 0, "### (sal_Int32)&((Any *) 16)->pReserved != 16 + (2* sizeof( void * )) ?!" ); + abort(); + } + // interface + if( sizeof( Reference< XInterface > ) != sizeof( XInterface * ) ) + { + OSL_ENSURE( 0, "### unexpected size of interface reference?!" ); + abort(); + } + // string + if( sizeof( OUString ) != sizeof( rtl_uString * ) ) + { + OSL_ENSURE( 0, "### unexpected size of string?!" ); + abort(); + } + // struct + if( sizeof( M ) != 8 || sizeof( N ) != 12 || sizeof( O ) != 16 ) + { + OSL_ENSURE( 0, "### unexpected struct alignment?!" ); + abort(); + } #ifdef SAL_W32 - if( sizeof( P ) != 24 ) - abort(); + if( sizeof( P ) != 24 ) + { + OSL_ENSURE( 0, "### [win] unexpected struct alignment?!" ); + abort(); + } #endif - #ifndef __GNUC__ - // An empty superclass have a size of 0 except for gcc - // FEATURE_EMPTYCLASS - if( sizeof( second ) != sizeof( int ) ) - abort(); -#endif + if( sizeof( second ) != sizeof( int ) ) + { + OSL_ENSURE( 0, "### unexpected struct size?!" ); + abort(); } -}; +#endif +} + #ifdef SAL_W32 # pragma pack(pop) #elif defined(SAL_OS2) diff --git a/cppu/source/uno/destr.hxx b/cppu/source/uno/destr.hxx index e0932fc4a..9b440ffc6 100644 --- a/cppu/source/uno/destr.hxx +++ b/cppu/source/uno/destr.hxx @@ -2,9 +2,9 @@ * * $RCSfile: destr.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: jsc $ $Date: 2001-03-30 13:41:39 $ + * last change: $Author: dbo $ $Date: 2001-06-29 11:06:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -109,7 +109,8 @@ inline void __destructStruct( while (nDescr--) { ::uno_type_destructData( - (char *)pValue + pMemberOffsets[nDescr], ppTypeRefs[nDescr], release ); + (char *)pValue + pMemberOffsets[nDescr], + ppTypeRefs[nDescr], release ); } } //-------------------------------------------------------------------------------------------------- @@ -127,7 +128,8 @@ inline void __destructArray( sal_Int32 nTotalElements = pTypeDescr->nTotalElements; for(sal_Int32 i=0; i < nTotalElements; i++) { - ::uno_type_destructData((sal_Char *)pValue + i * nElementSize, + ::uno_type_destructData( + (sal_Char *)pValue + i * nElementSize, ((typelib_IndirectTypeDescription *)pTypeDescr)->pType, release ); } @@ -147,62 +149,81 @@ inline void __destructAny( { typelib_TypeDescriptionReference * pType = pAny->pType; - if (typelib_TypeClass_VOID != pType->eTypeClass) + switch (pType->eTypeClass) { - switch (pType->eTypeClass) - { - case typelib_TypeClass_STRING: - ::rtl_uString_release( *(rtl_uString **)pAny->pData ); - break; - case typelib_TypeClass_TYPE: - ::typelib_typedescriptionreference_release( *(typelib_TypeDescriptionReference **)pAny->pData ); - break; - case typelib_TypeClass_ANY: - OSL_ENSURE( sal_False, "### unexpected nested any!" ); - ::uno_any_destruct( (uno_Any *)pAny->pData, release ); - break; -#ifdef CPPU_ASSERTIONS - case typelib_TypeClass_TYPEDEF: - OSL_ENSURE( sal_False, "### unexpected typedef!" ); - break; -#endif - case typelib_TypeClass_STRUCT: - case typelib_TypeClass_EXCEPTION: + case typelib_TypeClass_HYPER: + case typelib_TypeClass_UNSIGNED_HYPER: + if (sizeof(void *) < sizeof(sal_Int64)) { - typelib_TypeDescription * pTypeDescr = 0; - TYPELIB_DANGER_GET( &pTypeDescr, pType ); - __destructStruct( pAny->pData, (typelib_CompoundTypeDescription *)pTypeDescr, release ); - TYPELIB_DANGER_RELEASE( pTypeDescr ); - break; + ::rtl_freeMemory( pAny->pData ); } - case typelib_TypeClass_UNION: + break; + case typelib_TypeClass_FLOAT: + if (sizeof(void *) < sizeof(float)) { - typelib_TypeDescription * pTypeDescr = 0; - TYPELIB_DANGER_GET( &pTypeDescr, pType ); - __destructUnion( pAny->pData, pTypeDescr, release ); - TYPELIB_DANGER_RELEASE( pTypeDescr ); - break; + ::rtl_freeMemory( pAny->pData ); } - case typelib_TypeClass_SEQUENCE: + break; + case typelib_TypeClass_DOUBLE: + if (sizeof(void *) < sizeof(double)) { - typelib_TypeDescription * pTypeDescr = 0; - TYPELIB_DANGER_GET( &pTypeDescr, pType ); - destructSequence( - (uno_Sequence **)pAny->pData, - ((typelib_IndirectTypeDescription *)pTypeDescr)->pType, - release ); - TYPELIB_DANGER_RELEASE( pTypeDescr ); - break; - } - case typelib_TypeClass_INTERFACE: - __releaseRef( (void **)pAny->pData, release ); - break; + ::rtl_freeMemory( pAny->pData ); } + break; + case typelib_TypeClass_STRING: + ::rtl_uString_release( (rtl_uString *)pAny->pReserved ); + break; + case typelib_TypeClass_TYPE: + ::typelib_typedescriptionreference_release( + (typelib_TypeDescriptionReference *)pAny->pReserved ); + break; + case typelib_TypeClass_ANY: + OSL_ENSURE( sal_False, "### unexpected nested any!" ); + ::uno_any_destruct( (uno_Any *)pAny->pData, release ); ::rtl_freeMemory( pAny->pData ); -#ifdef _DEBUG - pAny->pData = (void *)0xdeadbeef; + break; +#ifdef CPPU_ASSERTIONS + case typelib_TypeClass_TYPEDEF: + OSL_ENSURE( sal_False, "### unexpected typedef!" ); + break; #endif + case typelib_TypeClass_STRUCT: + case typelib_TypeClass_EXCEPTION: + { + typelib_TypeDescription * pTypeDescr = 0; + TYPELIB_DANGER_GET( &pTypeDescr, pType ); + __destructStruct( pAny->pData, (typelib_CompoundTypeDescription *)pTypeDescr, release ); + TYPELIB_DANGER_RELEASE( pTypeDescr ); + ::rtl_freeMemory( pAny->pData ); + break; } + case typelib_TypeClass_UNION: + { + typelib_TypeDescription * pTypeDescr = 0; + TYPELIB_DANGER_GET( &pTypeDescr, pType ); + __destructUnion( pAny->pData, pTypeDescr, release ); + TYPELIB_DANGER_RELEASE( pTypeDescr ); + ::rtl_freeMemory( pAny->pData ); + break; + } + case typelib_TypeClass_SEQUENCE: + { + typelib_TypeDescription * pTypeDescr = 0; + TYPELIB_DANGER_GET( &pTypeDescr, pType ); + destructSequence( + (uno_Sequence **)&pAny->pReserved, + ((typelib_IndirectTypeDescription *)pTypeDescr)->pType, + release ); + TYPELIB_DANGER_RELEASE( pTypeDescr ); + break; + } + case typelib_TypeClass_INTERFACE: + __releaseRef( &pAny->pReserved, release ); + break; + } +#ifdef _DEBUG + pAny->pData = (void *)0xdeadbeef; +#endif ::typelib_typedescriptionreference_release( pType ); } @@ -263,7 +284,7 @@ inline sal_Int32 __destructElements( return sizeof(uno_Any); } case typelib_TypeClass_ENUM: - return sizeof(int); + return sizeof(sal_Int32); #ifdef CPPU_ASSERTIONS case typelib_TypeClass_TYPEDEF: OSL_ENSURE( sal_False, "### unexpected typedef!" ); @@ -330,7 +351,9 @@ inline sal_Int32 __destructElements( { void * p = ((void **)pElements)[nPos]; if (p) + { (*release)( p ); + } } } else @@ -339,7 +362,9 @@ inline sal_Int32 __destructElements( { uno_Interface * p = ((uno_Interface **)pElements)[nPos]; if (p) + { (*p->release)( p ); + } } } return sizeof(void *); diff --git a/cppu/source/uno/eq.hxx b/cppu/source/uno/eq.hxx index bd1963a80..330d091e3 100644 --- a/cppu/source/uno/eq.hxx +++ b/cppu/source/uno/eq.hxx @@ -2,9 +2,9 @@ * * $RCSfile: eq.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: jl $ $Date: 2001-03-12 13:27:08 $ + * last change: $Author: dbo $ $Date: 2001-06-29 11:06:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -189,11 +189,11 @@ inline sal_Bool __equalStruct( while (nDescr--) { sal_Int32 nOffset = pMemberOffsets[nDescr]; - if (! uno_type_equalData( (char *)pDest + nOffset, - ppTypeRefs[nDescr], - (char *)pSource + nOffset, - ppTypeRefs[nDescr], - queryInterface, release )) + if (! ::uno_type_equalData( (char *)pDest + nOffset, + ppTypeRefs[nDescr], + (char *)pSource + nOffset, + ppTypeRefs[nDescr], + queryInterface, release )) { return sal_False; } @@ -306,7 +306,7 @@ inline sal_Bool __equalSequence( return sal_True; } case typelib_TypeClass_ENUM: - return (0 == ::rtl_compareMemory( pDestElements, pSourceElements, sizeof(int) * nElements )); + return (0 == ::rtl_compareMemory( pDestElements, pSourceElements, sizeof(sal_Int32) * nElements )); case typelib_TypeClass_STRUCT: case typelib_TypeClass_EXCEPTION: { @@ -338,9 +338,10 @@ inline sal_Bool __equalSequence( char * pDest = (char *)pDestElements + (nPos * nElementSize); char * pSource = (char *)pSourceElements + (nPos * nElementSize); typelib_TypeDescriptionReference * pSetType = __unionGetSetType( pDest, pElementTypeDescr ); - sal_Bool bRet = uno_type_equalData( pDest + nValueOffset, pSetType, - pSource + nValueOffset, pSetType, - queryInterface, release ); + sal_Bool bRet = ::uno_type_equalData( + pDest + nValueOffset, pSetType, + pSource + nValueOffset, pSetType, + queryInterface, release ); ::typelib_typedescriptionreference_release( pSetType ); if (! bRet) { @@ -658,20 +659,21 @@ inline sal_Bool __equalData( switch (eSourceTypeClass) { case typelib_TypeClass_STRING: - return ((::rtl::OUString *)pDest)->equals( *(::rtl::OUString *)pSource ); + return ((::rtl::OUString *)pDest)->equals( *(::rtl::OUString const *)pSource ); } return sal_False; case typelib_TypeClass_TYPE: switch (eSourceTypeClass) { case typelib_TypeClass_TYPE: - return __type_equals( *(typelib_TypeDescriptionReference **)pDest, - *(typelib_TypeDescriptionReference **)pSource ); + return __type_equals( + *(typelib_TypeDescriptionReference **)pDest, + *(typelib_TypeDescriptionReference **)pSource ); } return sal_False; case typelib_TypeClass_ENUM: return (__type_equals( pDestType, pSourceType ) && - *(int *)pDest == *(int *)pSource); + *(sal_Int32 *)pDest == *(sal_Int32 *)pSource); #ifdef CPPU_ASSERTIONS case typelib_TypeClass_TYPEDEF: OSL_ENSURE( sal_False, "### unexpected typedef!" ); @@ -706,7 +708,7 @@ inline sal_Bool __equalData( if (pDestTypeDescr) { typelib_TypeDescriptionReference * pSetType = __unionGetSetType( pDest, pDestTypeDescr ); - bRet = uno_type_equalData( + bRet = ::uno_type_equalData( (char *)pDest + ((typelib_UnionTypeDescription *)pDestTypeDescr)->nValueOffset, pSetType, (char *)pSource + ((typelib_UnionTypeDescription *)pDestTypeDescr)->nValueOffset, pSetType, queryInterface, release ); @@ -716,7 +718,7 @@ inline sal_Bool __equalData( { TYPELIB_DANGER_GET( &pDestTypeDescr, pDestType ); typelib_TypeDescriptionReference * pSetType = __unionGetSetType( pDest, pDestTypeDescr ); - bRet = uno_type_equalData( + bRet = ::uno_type_equalData( (char *)pDest + ((typelib_UnionTypeDescription *)pDestTypeDescr)->nValueOffset, pSetType, (char *)pSource + ((typelib_UnionTypeDescription *)pDestTypeDescr)->nValueOffset, pSetType, queryInterface, release ); diff --git a/cppu/source/uno/prim.hxx b/cppu/source/uno/prim.hxx index f0357d3f9..c268348ae 100644 --- a/cppu/source/uno/prim.hxx +++ b/cppu/source/uno/prim.hxx @@ -2,9 +2,9 @@ * * $RCSfile: prim.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: dbo $ $Date: 2001-06-25 08:32:01 $ + * last change: $Author: dbo $ $Date: 2001-06-29 11:06:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -138,21 +138,30 @@ inline void __acquire( void * p, uno_AcquireFunc acquire ) if (p) { if (acquire) + { (*acquire)( p ); + } else + { (*((uno_Interface *)p)->acquire)( (uno_Interface *)p ); + } } } //-------------------------------------------------------------------------------------------------- inline void __releaseRef( void ** pRef, uno_ReleaseFunc release ) SAL_THROW( () ) { - if (*pRef) + void * p = *pRef; + if (p) { if (release) - (*release)( *pRef ); + { + (*release)( p ); + } else - (*((uno_Interface *)*pRef)->release)( (uno_Interface *)*pRef ); + { + (*((uno_Interface *)p)->release)( (uno_Interface *)p ); + } } } @@ -200,7 +209,7 @@ inline typelib_TypeDescriptionReference * __getVoidType() #endif //-------------------------------------------------------------------------------------------------- -#define TYPE_ACQUIRE( pType ) \ +#define __TYPE_ACQUIRE( pType ) \ ::osl_incrementInterlockedCount( &(pType)->nRefCount ); //-------------------------------------------------------------------------------------------------- diff --git a/cppu/source/uno/sequence.cxx b/cppu/source/uno/sequence.cxx index bdd058e36..a998b1b9a 100644 --- a/cppu/source/uno/sequence.cxx +++ b/cppu/source/uno/sequence.cxx @@ -2,9 +2,9 @@ * * $RCSfile: sequence.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: pl $ $Date: 2001-05-10 20:12:55 $ + * last change: $Author: dbo $ $Date: 2001-06-29 11:06:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -217,14 +217,14 @@ static inline void __defaultConstructElements( } case typelib_TypeClass_ENUM: { - allocSeq( ppSequence, sizeof(int), nAlloc ); + allocSeq( ppSequence, sizeof(sal_Int32), nAlloc ); typelib_TypeDescription * pElementTypeDescr = 0; TYPELIB_DANGER_GET( &pElementTypeDescr, pElementType ); - int eEnum = ((typelib_EnumTypeDescription *)pElementTypeDescr)->nDefaultEnumValue; + sal_Int32 eEnum = ((typelib_EnumTypeDescription *)pElementTypeDescr)->nDefaultEnumValue; TYPELIB_DANGER_RELEASE( pElementTypeDescr ); - int * pElements = (int *)(*ppSequence)->elements; + sal_Int32 * pElements = (sal_Int32 *)(*ppSequence)->elements; for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos ) { pElements[nPos] = eEnum; @@ -390,11 +390,11 @@ static inline void __copyConstructElements( sizeof(double) * (nStopIndex - nStartIndex) ); break; case typelib_TypeClass_ENUM: - allocSeq( ppSequence, sizeof(int), nAlloc ); + allocSeq( ppSequence, sizeof(sal_Int32), nAlloc ); ::rtl_copyMemory( - (*ppSequence)->elements + (sizeof(int) * nStartIndex), - (char *)pSourceElements + (sizeof(int) * nStartIndex), - sizeof(int) * (nStopIndex - nStartIndex) ); + (*ppSequence)->elements + (sizeof(sal_Int32) * nStartIndex), + (char *)pSourceElements + (sizeof(sal_Int32) * nStartIndex), + sizeof(sal_Int32) * (nStopIndex - nStartIndex) ); break; case typelib_TypeClass_STRING: { @@ -416,7 +416,7 @@ static inline void __copyConstructElements( (typelib_TypeDescriptionReference **)(*ppSequence)->elements; for ( sal_Int32 nPos = nStartIndex; nPos < nStopIndex; ++nPos ) { - TYPE_ACQUIRE( ((typelib_TypeDescriptionReference **)pSourceElements)[nPos] ); + __TYPE_ACQUIRE( ((typelib_TypeDescriptionReference **)pSourceElements)[nPos] ); pDestElements[nPos] = ((typelib_TypeDescriptionReference **)pSourceElements)[nPos]; } break; @@ -498,9 +498,10 @@ static inline void __copyConstructElements( char * pSource = (char *)pSourceElements + (nElementSize * nPos); typelib_TypeDescriptionReference * pSetType = __unionGetSetType( pSource, pElementTypeDescr ); - uno_type_copyData( pDest + nValueOffset, - pSource + nValueOffset, - pSetType, acquire ); + ::uno_type_copyData( + pDest + nValueOffset, + pSource + nValueOffset, + pSetType, acquire ); *(sal_Int64 *)pDest = *(sal_Int64 *)pSource; typelib_typedescriptionreference_release( pSetType ); } |