summaryrefslogtreecommitdiff
path: root/cppu/inc
diff options
context:
space:
mode:
authorDaniel Boelzle <dbo@openoffice.org>2001-06-29 10:10:47 +0000
committerDaniel Boelzle <dbo@openoffice.org>2001-06-29 10:10:47 +0000
commitcf0cf8d73af9d0071500dfa98e26c55732cc4add (patch)
treed7e9e378091c996da8fd374a8edf9c52c3043b18 /cppu/inc
parent824d65702a9946d3952ce57af1a288eaacc2bf1e (diff)
#88593# any opt: avoiding heap allocation for any sizeof(type) <= sizeof(void *)
Diffstat (limited to 'cppu/inc')
-rw-r--r--cppu/inc/com/sun/star/uno/Any.hxx93
-rw-r--r--cppu/inc/com/sun/star/uno/Reference.hxx8
-rw-r--r--cppu/inc/com/sun/star/uno/genfunc.hxx8
-rw-r--r--cppu/inc/uno/any2.h25
4 files changed, 71 insertions, 63 deletions
diff --git a/cppu/inc/com/sun/star/uno/Any.hxx b/cppu/inc/com/sun/star/uno/Any.hxx
index a7dcdd455f22..2ed3e59da5de 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 e83ff3c7532a..9d6252215cca 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 13af9082c255..3604629ebe93 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 a72ef5fff160..66c139a387c3 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
*/