2000-09-18 14:29:57 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* $RCSfile: assign.hxx,v $
|
|
|
|
*
|
2003-09-04 09:52:45 +00:00
|
|
|
* $Revision: 1.14 $
|
2000-09-18 14:29:57 +00:00
|
|
|
*
|
2003-09-04 09:52:45 +00:00
|
|
|
* last change: $Author: obo $ $Date: 2003-09-04 10:52:45 $
|
2000-09-18 14:29:57 +00:00
|
|
|
*
|
|
|
|
* 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): _______________________________________
|
|
|
|
*
|
|
|
|
*
|
|
|
|
************************************************************************/
|
2002-08-21 08:19:40 +00:00
|
|
|
#ifndef ASSIGN_HXX
|
|
|
|
#define ASSIGN_HXX
|
2000-09-18 14:29:57 +00:00
|
|
|
|
|
|
|
#include "prim.hxx"
|
|
|
|
#include "destr.hxx"
|
|
|
|
#include "constr.hxx"
|
|
|
|
#include "copy.hxx"
|
|
|
|
|
2002-08-21 08:19:40 +00:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
namespace cppu
|
|
|
|
{
|
|
|
|
|
|
|
|
//##################################################################################################
|
|
|
|
//#### assignment ##################################################################################
|
|
|
|
//##################################################################################################
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2002-08-21 08:19:40 +00:00
|
|
|
inline void _assignInterface(
|
2000-09-18 14:29:57 +00:00
|
|
|
void ** ppDest, void * pSource,
|
|
|
|
uno_AcquireFunc acquire, uno_ReleaseFunc release )
|
2001-03-09 11:10:57 +00:00
|
|
|
SAL_THROW( () )
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
|
|
|
void * pDest = *ppDest;
|
2003-03-20 11:28:27 +00:00
|
|
|
_acquire( pSource, acquire );
|
|
|
|
_release( *ppDest, release );
|
2000-09-18 14:29:57 +00:00
|
|
|
*ppDest = pSource;
|
|
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2002-08-21 08:19:40 +00:00
|
|
|
inline sal_Bool _queryAndAssignInterface(
|
2000-09-18 14:29:57 +00:00
|
|
|
void ** ppDest, void * pSource,
|
|
|
|
typelib_TypeDescriptionReference * pDestType,
|
|
|
|
uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release )
|
2001-03-09 11:10:57 +00:00
|
|
|
SAL_THROW( () )
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
|
|
|
if (pSource)
|
|
|
|
{
|
2003-03-20 11:28:27 +00:00
|
|
|
if (0 == queryInterface)
|
|
|
|
queryInterface = binuno_queryInterface;
|
|
|
|
pSource = (*queryInterface)( pSource, pDestType );
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
2003-03-20 11:28:27 +00:00
|
|
|
_release( *ppDest, release );
|
2000-09-18 14:29:57 +00:00
|
|
|
*ppDest = pSource;
|
|
|
|
return (pSource != 0);
|
|
|
|
}
|
|
|
|
//==================================================================================================
|
|
|
|
sal_Bool assignStruct(
|
|
|
|
void * pDest, void * pSource,
|
|
|
|
typelib_CompoundTypeDescription * pTypeDescr,
|
2000-12-21 13:39:29 +00:00
|
|
|
uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release )
|
2001-03-09 11:10:57 +00:00
|
|
|
SAL_THROW( () );
|
2000-09-18 14:29:57 +00:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2002-08-21 08:19:40 +00:00
|
|
|
inline sal_Bool _assignStruct(
|
2000-09-18 14:29:57 +00:00
|
|
|
void * pDest, void * pSource,
|
|
|
|
typelib_CompoundTypeDescription * pTypeDescr,
|
|
|
|
uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release )
|
2001-03-09 11:10:57 +00:00
|
|
|
SAL_THROW( () )
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
|
|
|
if (pTypeDescr->pBaseTypeDescription)
|
|
|
|
{
|
|
|
|
// copy base value
|
|
|
|
if (! assignStruct( pDest, pSource, pTypeDescr->pBaseTypeDescription,
|
|
|
|
queryInterface, acquire, release ))
|
|
|
|
{
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// then copy members
|
|
|
|
typelib_TypeDescriptionReference ** ppTypeRefs = pTypeDescr->ppTypeRefs;
|
|
|
|
sal_Int32 * pMemberOffsets = pTypeDescr->pMemberOffsets;
|
|
|
|
sal_Int32 nDescr = pTypeDescr->nMembers;
|
|
|
|
while (nDescr--)
|
|
|
|
{
|
|
|
|
if (! ::uno_type_assignData( (char *)pDest + pMemberOffsets[nDescr],
|
|
|
|
ppTypeRefs[nDescr],
|
|
|
|
(char *)pSource + pMemberOffsets[nDescr],
|
|
|
|
ppTypeRefs[nDescr],
|
|
|
|
queryInterface, acquire, release ))
|
|
|
|
{
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2002-08-21 08:19:40 +00:00
|
|
|
inline sal_Bool _assignArray(
|
2001-03-30 12:41:39 +00:00
|
|
|
void * pDest, void * pSource,
|
|
|
|
typelib_ArrayTypeDescription * pTypeDescr,
|
|
|
|
uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release )
|
|
|
|
{
|
2003-03-20 11:28:27 +00:00
|
|
|
typelib_TypeDescriptionReference * pElementTypeRef =
|
|
|
|
((typelib_IndirectTypeDescription *)pTypeDescr)->pType;
|
2001-03-30 12:41:39 +00:00
|
|
|
typelib_TypeDescription * pElementTypeDescr = NULL;
|
|
|
|
TYPELIB_DANGER_GET( &pElementTypeDescr, pElementTypeRef );
|
|
|
|
sal_Int32 nTotalElements = pTypeDescr->nTotalElements;
|
|
|
|
sal_Int32 nElementSize = pElementTypeDescr->nSize;
|
|
|
|
sal_Int32 i;
|
|
|
|
sal_Bool bRet = sal_False;
|
|
|
|
|
|
|
|
switch ( pElementTypeRef->eTypeClass )
|
|
|
|
{
|
|
|
|
case typelib_TypeClass_CHAR:
|
|
|
|
case typelib_TypeClass_BOOLEAN:
|
|
|
|
case typelib_TypeClass_BYTE:
|
|
|
|
case typelib_TypeClass_SHORT:
|
|
|
|
case typelib_TypeClass_UNSIGNED_SHORT:
|
|
|
|
case typelib_TypeClass_LONG:
|
|
|
|
case typelib_TypeClass_UNSIGNED_LONG:
|
|
|
|
case typelib_TypeClass_HYPER:
|
|
|
|
case typelib_TypeClass_UNSIGNED_HYPER:
|
|
|
|
case typelib_TypeClass_FLOAT:
|
|
|
|
case typelib_TypeClass_DOUBLE:
|
|
|
|
for (i=0; i < nTotalElements; i++)
|
|
|
|
{
|
|
|
|
::rtl_copyMemory((sal_Char *)pDest + i * nElementSize,
|
|
|
|
(sal_Char *)pSource + i * nElementSize,
|
|
|
|
nElementSize);
|
|
|
|
}
|
|
|
|
bRet = sal_True;
|
|
|
|
break;
|
|
|
|
case typelib_TypeClass_STRING:
|
|
|
|
for (i=0; i < nTotalElements; i++)
|
|
|
|
{
|
|
|
|
::rtl_uString_assign( (rtl_uString **)pDest + i,
|
|
|
|
((rtl_uString **)pSource)[i] );
|
|
|
|
}
|
|
|
|
bRet = sal_True;
|
|
|
|
break;
|
|
|
|
case typelib_TypeClass_TYPE:
|
|
|
|
for (i=0; i < nTotalElements; i++)
|
|
|
|
{
|
2003-03-20 11:28:27 +00:00
|
|
|
typelib_TypeDescriptionReference ** pp = (typelib_TypeDescriptionReference **)pDest + i;
|
|
|
|
::typelib_typedescriptionreference_release( *pp );
|
|
|
|
*pp = *((typelib_TypeDescriptionReference **)pSource + i);
|
|
|
|
TYPE_ACQUIRE( *pp );
|
2001-03-30 12:41:39 +00:00
|
|
|
}
|
|
|
|
bRet = sal_True;
|
|
|
|
break;
|
|
|
|
case typelib_TypeClass_ANY:
|
|
|
|
for (i=0; i < nTotalElements; i++)
|
|
|
|
{
|
2002-08-21 08:19:40 +00:00
|
|
|
_destructAny( (uno_Any *)pDest + i, release );
|
|
|
|
_copyConstructAny( (uno_Any *)pDest + i, (uno_Any *)pSource + i,
|
|
|
|
pElementTypeRef, pElementTypeDescr, acquire, 0 );
|
2001-03-30 12:41:39 +00:00
|
|
|
}
|
|
|
|
bRet = sal_True;
|
|
|
|
break;
|
|
|
|
case typelib_TypeClass_ENUM:
|
|
|
|
for (i=0; i < nTotalElements; i++)
|
|
|
|
{
|
2001-06-29 10:10:47 +00:00
|
|
|
*((sal_Int32 *)pDest + i) = *((sal_Int32 *)pSource + i);
|
2001-03-30 12:41:39 +00:00
|
|
|
}
|
|
|
|
bRet = sal_True;
|
|
|
|
break;
|
|
|
|
case typelib_TypeClass_TYPEDEF:
|
2003-03-20 11:28:27 +00:00
|
|
|
OSL_ENSURE( 0, "### unexpected typedef!" );
|
2001-03-30 12:41:39 +00:00
|
|
|
break;
|
|
|
|
case typelib_TypeClass_STRUCT:
|
|
|
|
case typelib_TypeClass_EXCEPTION:
|
|
|
|
for (i=0; i < nTotalElements; i++)
|
|
|
|
{
|
2002-08-21 08:19:40 +00:00
|
|
|
bRet = _assignStruct( (sal_Char *)pDest + i * nElementSize,
|
|
|
|
(sal_Char *)pSource + i * nElementSize,
|
|
|
|
(typelib_CompoundTypeDescription *)pElementTypeDescr,
|
|
|
|
queryInterface, acquire, release );
|
|
|
|
if (! bRet)
|
2001-03-30 12:41:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
bRet = sal_True;
|
|
|
|
break;
|
|
|
|
case typelib_TypeClass_UNION:
|
|
|
|
for (i=0; i < nTotalElements; i++)
|
|
|
|
{
|
2002-08-21 08:19:40 +00:00
|
|
|
_destructUnion( (sal_Char*)pDest + i * nElementSize, pElementTypeDescr, release );
|
|
|
|
_copyConstructUnion( (sal_Char*)pDest + i * nElementSize,
|
|
|
|
(sal_Char*)pSource + i * nElementSize,
|
|
|
|
pElementTypeDescr, acquire, 0 );
|
2001-03-30 12:41:39 +00:00
|
|
|
}
|
|
|
|
bRet = sal_True;
|
|
|
|
break;
|
|
|
|
case typelib_TypeClass_SEQUENCE:
|
|
|
|
for (i=0; i < nTotalElements; i++)
|
|
|
|
{
|
2003-09-04 09:52:45 +00:00
|
|
|
::osl_incrementInterlockedCount(
|
|
|
|
&(*((uno_Sequence **)pSource + i))->nRefCount );
|
|
|
|
idestructSequence(
|
|
|
|
*((uno_Sequence **)pDest + i),
|
|
|
|
pElementTypeRef, pElementTypeDescr, release );
|
2001-03-30 12:41:39 +00:00
|
|
|
*((uno_Sequence **)pDest + i) = *((uno_Sequence **)pSource + i);
|
|
|
|
}
|
|
|
|
bRet = sal_True;
|
|
|
|
break;
|
|
|
|
case typelib_TypeClass_INTERFACE:
|
|
|
|
for (i=0; i < nTotalElements; i++)
|
|
|
|
{
|
2003-09-04 09:52:45 +00:00
|
|
|
_assignInterface(
|
|
|
|
(void **)((sal_Char*)pDest + i * nElementSize),
|
|
|
|
*(void **)((sal_Char*)pSource + i * nElementSize),
|
|
|
|
acquire, release );
|
2001-03-30 12:41:39 +00:00
|
|
|
}
|
|
|
|
bRet = sal_True;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
TYPELIB_DANGER_RELEASE( pElementTypeDescr );
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2002-08-21 08:19:40 +00:00
|
|
|
inline sal_Bool _assignData(
|
2000-09-18 14:29:57 +00:00
|
|
|
void * pDest,
|
|
|
|
typelib_TypeDescriptionReference * pDestType, typelib_TypeDescription * pDestTypeDescr,
|
|
|
|
void * pSource,
|
|
|
|
typelib_TypeDescriptionReference * pSourceType, typelib_TypeDescription * pSourceTypeDescr,
|
|
|
|
uno_QueryInterfaceFunc queryInterface, uno_AcquireFunc acquire, uno_ReleaseFunc release )
|
2001-03-09 11:10:57 +00:00
|
|
|
SAL_THROW( () )
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
|
|
|
if (pDest == pSource)
|
|
|
|
return sal_True;
|
|
|
|
|
|
|
|
if (! pSource)
|
|
|
|
{
|
2002-08-21 08:19:40 +00:00
|
|
|
_destructData( pDest, pDestType, pDestTypeDescr, release );
|
|
|
|
_defaultConstructData( pDest, pDestType, pDestTypeDescr );
|
2001-06-25 07:32:01 +00:00
|
|
|
return sal_True;
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
while (typelib_TypeClass_ANY == pSourceType->eTypeClass)
|
|
|
|
{
|
|
|
|
pSourceTypeDescr = 0;
|
|
|
|
pSourceType = ((uno_Any *)pSource)->pType;
|
|
|
|
pSource = ((uno_Any *)pSource)->pData;
|
2000-09-25 13:47:41 +00:00
|
|
|
if (pDest == pSource)
|
|
|
|
return sal_True;
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (pDestType->eTypeClass)
|
|
|
|
{
|
|
|
|
case typelib_TypeClass_VOID:
|
|
|
|
switch (pSourceType->eTypeClass)
|
|
|
|
{
|
|
|
|
case typelib_TypeClass_VOID:
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
return sal_False;
|
|
|
|
case typelib_TypeClass_CHAR:
|
|
|
|
switch (pSourceType->eTypeClass)
|
|
|
|
{
|
|
|
|
case typelib_TypeClass_CHAR:
|
|
|
|
*(sal_Unicode *)pDest = *(sal_Unicode *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
return sal_False;
|
|
|
|
case typelib_TypeClass_BOOLEAN:
|
|
|
|
switch (pSourceType->eTypeClass)
|
|
|
|
{
|
|
|
|
case typelib_TypeClass_BOOLEAN:
|
2001-03-12 11:03:40 +00:00
|
|
|
*(sal_Bool *)pDest = (*(sal_Bool *)pSource != sal_False);
|
2000-09-18 14:29:57 +00:00
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
return sal_False;
|
|
|
|
case typelib_TypeClass_BYTE:
|
|
|
|
switch (pSourceType->eTypeClass)
|
|
|
|
{
|
|
|
|
case typelib_TypeClass_BYTE:
|
|
|
|
*(sal_Int8 *)pDest = *(sal_Int8 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
return sal_False;
|
|
|
|
case typelib_TypeClass_SHORT:
|
|
|
|
switch (pSourceType->eTypeClass)
|
|
|
|
{
|
|
|
|
case typelib_TypeClass_BYTE:
|
|
|
|
*(sal_Int16 *)pDest = *(sal_Int8 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
case typelib_TypeClass_SHORT:
|
|
|
|
case typelib_TypeClass_UNSIGNED_SHORT:
|
|
|
|
*(sal_Int16 *)pDest = *(sal_Int16 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
return sal_False;
|
|
|
|
case typelib_TypeClass_UNSIGNED_SHORT:
|
|
|
|
switch (pSourceType->eTypeClass)
|
|
|
|
{
|
|
|
|
case typelib_TypeClass_BYTE:
|
|
|
|
*(sal_uInt16 *)pDest = *(sal_Int8 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
case typelib_TypeClass_SHORT:
|
|
|
|
case typelib_TypeClass_UNSIGNED_SHORT:
|
|
|
|
*(sal_uInt16 *)pDest = *(sal_uInt16 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
return sal_False;
|
|
|
|
case typelib_TypeClass_LONG:
|
|
|
|
switch (pSourceType->eTypeClass)
|
|
|
|
{
|
|
|
|
case typelib_TypeClass_BYTE:
|
|
|
|
*(sal_Int32 *)pDest = *(sal_Int8 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
case typelib_TypeClass_SHORT:
|
|
|
|
*(sal_Int32 *)pDest = *(sal_Int16 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
case typelib_TypeClass_UNSIGNED_SHORT:
|
|
|
|
*(sal_Int32 *)pDest = *(sal_uInt16 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
case typelib_TypeClass_LONG:
|
|
|
|
case typelib_TypeClass_UNSIGNED_LONG:
|
|
|
|
*(sal_Int32 *)pDest = *(sal_Int32 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
return sal_False;
|
|
|
|
case typelib_TypeClass_UNSIGNED_LONG:
|
|
|
|
switch (pSourceType->eTypeClass)
|
|
|
|
{
|
|
|
|
case typelib_TypeClass_BYTE:
|
|
|
|
*(sal_uInt32 *)pDest = *(sal_Int8 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
case typelib_TypeClass_SHORT:
|
|
|
|
*(sal_uInt32 *)pDest = *(sal_Int16 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
case typelib_TypeClass_UNSIGNED_SHORT:
|
|
|
|
*(sal_uInt32 *)pDest = *(sal_uInt16 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
case typelib_TypeClass_LONG:
|
|
|
|
case typelib_TypeClass_UNSIGNED_LONG:
|
|
|
|
*(sal_uInt32 *)pDest = *(sal_uInt32 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
return sal_False;
|
|
|
|
case typelib_TypeClass_HYPER:
|
|
|
|
switch (pSourceType->eTypeClass)
|
|
|
|
{
|
|
|
|
case typelib_TypeClass_BYTE:
|
|
|
|
*(sal_Int64 *)pDest = *(sal_Int8 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
case typelib_TypeClass_SHORT:
|
|
|
|
*(sal_Int64 *)pDest = *(sal_Int16 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
case typelib_TypeClass_UNSIGNED_SHORT:
|
|
|
|
*(sal_Int64 *)pDest = *(sal_uInt16 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
case typelib_TypeClass_LONG:
|
|
|
|
*(sal_Int64 *)pDest = *(sal_Int32 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
case typelib_TypeClass_UNSIGNED_LONG:
|
|
|
|
*(sal_Int64 *)pDest = *(sal_uInt32 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
case typelib_TypeClass_HYPER:
|
|
|
|
case typelib_TypeClass_UNSIGNED_HYPER:
|
|
|
|
*(sal_Int64 *)pDest = *(sal_Int64 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
return sal_False;
|
|
|
|
case typelib_TypeClass_UNSIGNED_HYPER:
|
|
|
|
switch (pSourceType->eTypeClass)
|
|
|
|
{
|
|
|
|
case typelib_TypeClass_BYTE:
|
|
|
|
*(sal_uInt64 *)pDest = *(sal_Int8 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
case typelib_TypeClass_SHORT:
|
|
|
|
*(sal_uInt64 *)pDest = *(sal_Int16 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
case typelib_TypeClass_UNSIGNED_SHORT:
|
|
|
|
*(sal_uInt64 *)pDest = *(sal_uInt16 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
case typelib_TypeClass_LONG:
|
|
|
|
*(sal_uInt64 *)pDest = *(sal_Int32 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
case typelib_TypeClass_UNSIGNED_LONG:
|
|
|
|
*(sal_uInt64 *)pDest = *(sal_uInt32 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
case typelib_TypeClass_HYPER:
|
|
|
|
case typelib_TypeClass_UNSIGNED_HYPER:
|
|
|
|
*(sal_uInt64 *)pDest = *(sal_uInt64 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
return sal_False;
|
|
|
|
case typelib_TypeClass_FLOAT:
|
|
|
|
switch (pSourceType->eTypeClass)
|
|
|
|
{
|
|
|
|
case typelib_TypeClass_BYTE:
|
|
|
|
*(float *)pDest = *(sal_Int8 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
case typelib_TypeClass_SHORT:
|
|
|
|
*(float *)pDest = *(sal_Int16 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
case typelib_TypeClass_UNSIGNED_SHORT:
|
|
|
|
*(float *)pDest = *(sal_uInt16 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
case typelib_TypeClass_FLOAT:
|
|
|
|
*(float *)pDest = *(float *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
return sal_False;
|
|
|
|
case typelib_TypeClass_DOUBLE:
|
|
|
|
switch (pSourceType->eTypeClass)
|
|
|
|
{
|
|
|
|
case typelib_TypeClass_BYTE:
|
|
|
|
*(double *)pDest = *(sal_Int8 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
case typelib_TypeClass_SHORT:
|
|
|
|
*(double *)pDest = *(sal_Int16 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
case typelib_TypeClass_UNSIGNED_SHORT:
|
|
|
|
*(double *)pDest = *(sal_uInt16 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
case typelib_TypeClass_LONG:
|
|
|
|
*(double *)pDest = *(sal_Int32 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
case typelib_TypeClass_UNSIGNED_LONG:
|
|
|
|
*(double *)pDest = *(sal_uInt32 *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
case typelib_TypeClass_FLOAT:
|
|
|
|
*(double *)pDest = *(float *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
case typelib_TypeClass_DOUBLE:
|
|
|
|
*(double *)pDest = *(double *)pSource;
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
return sal_False;
|
|
|
|
case typelib_TypeClass_STRING:
|
|
|
|
switch (pSourceType->eTypeClass)
|
|
|
|
{
|
|
|
|
case typelib_TypeClass_STRING:
|
|
|
|
::rtl_uString_assign( (rtl_uString **)pDest, *(rtl_uString **)pSource );
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
return sal_False;
|
|
|
|
case typelib_TypeClass_TYPE:
|
|
|
|
switch (pSourceType->eTypeClass)
|
|
|
|
{
|
|
|
|
case typelib_TypeClass_TYPE:
|
2003-03-20 11:28:27 +00:00
|
|
|
{
|
|
|
|
typelib_TypeDescriptionReference ** pp = (typelib_TypeDescriptionReference **)pDest;
|
|
|
|
::typelib_typedescriptionreference_release( *pp );
|
|
|
|
*pp = *(typelib_TypeDescriptionReference **)pSource;
|
|
|
|
TYPE_ACQUIRE( *pp );
|
2000-09-18 14:29:57 +00:00
|
|
|
return sal_True;
|
|
|
|
}
|
2003-03-20 11:28:27 +00:00
|
|
|
}
|
2000-09-18 14:29:57 +00:00
|
|
|
return sal_False;
|
|
|
|
case typelib_TypeClass_ANY:
|
2002-08-21 08:19:40 +00:00
|
|
|
_destructAny( (uno_Any *)pDest, release );
|
|
|
|
_copyConstructAny( (uno_Any *)pDest, pSource, pSourceType, pSourceTypeDescr, acquire, 0 );
|
2000-09-18 14:29:57 +00:00
|
|
|
return sal_True;
|
|
|
|
case typelib_TypeClass_ENUM:
|
2002-08-21 08:19:40 +00:00
|
|
|
if (_type_equals( pDestType, pSourceType ))
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
2001-06-29 10:10:47 +00:00
|
|
|
*(sal_Int32 *)pDest = *(sal_Int32 *)pSource;
|
2000-09-18 14:29:57 +00:00
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
return sal_False;
|
|
|
|
case typelib_TypeClass_TYPEDEF:
|
2003-03-20 11:28:27 +00:00
|
|
|
OSL_ENSURE( 0, "### unexpected typedef!" );
|
2000-09-18 14:29:57 +00:00
|
|
|
return sal_False;
|
|
|
|
case typelib_TypeClass_STRUCT:
|
|
|
|
case typelib_TypeClass_EXCEPTION:
|
|
|
|
if (typelib_TypeClass_STRUCT == pSourceType->eTypeClass ||
|
|
|
|
typelib_TypeClass_EXCEPTION == pSourceType->eTypeClass)
|
|
|
|
{
|
|
|
|
sal_Bool bRet = sal_False;
|
|
|
|
if (pSourceTypeDescr)
|
|
|
|
{
|
|
|
|
typelib_CompoundTypeDescription * pTypeDescr =
|
|
|
|
(typelib_CompoundTypeDescription *)pSourceTypeDescr;
|
2002-08-21 08:19:40 +00:00
|
|
|
while (pTypeDescr &&
|
2003-03-20 11:28:27 +00:00
|
|
|
!_type_equals(
|
|
|
|
((typelib_TypeDescription *)pTypeDescr)->pWeakRef, pDestType ))
|
2002-08-21 08:19:40 +00:00
|
|
|
{
|
2000-09-18 14:29:57 +00:00
|
|
|
pTypeDescr = pTypeDescr->pBaseTypeDescription;
|
2002-08-21 08:19:40 +00:00
|
|
|
}
|
2000-09-18 14:29:57 +00:00
|
|
|
if (pTypeDescr)
|
2002-08-21 08:19:40 +00:00
|
|
|
{
|
|
|
|
bRet = _assignStruct(
|
|
|
|
pDest, pSource, pTypeDescr, queryInterface, acquire, release );
|
|
|
|
}
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TYPELIB_DANGER_GET( &pSourceTypeDescr, pSourceType );
|
|
|
|
typelib_CompoundTypeDescription * pTypeDescr =
|
|
|
|
(typelib_CompoundTypeDescription *)pSourceTypeDescr;
|
2002-08-21 08:19:40 +00:00
|
|
|
while (pTypeDescr &&
|
2003-03-20 11:28:27 +00:00
|
|
|
!_type_equals(
|
|
|
|
((typelib_TypeDescription *)pTypeDescr)->pWeakRef, pDestType ))
|
2002-08-21 08:19:40 +00:00
|
|
|
{
|
2000-09-18 14:29:57 +00:00
|
|
|
pTypeDescr = pTypeDescr->pBaseTypeDescription;
|
2002-08-21 08:19:40 +00:00
|
|
|
}
|
2000-09-18 14:29:57 +00:00
|
|
|
if (pTypeDescr)
|
2002-08-21 08:19:40 +00:00
|
|
|
{
|
|
|
|
bRet = _assignStruct(
|
|
|
|
pDest, pSource, pTypeDescr, queryInterface, acquire, release );
|
|
|
|
}
|
2000-09-18 14:29:57 +00:00
|
|
|
TYPELIB_DANGER_RELEASE( pSourceTypeDescr );
|
|
|
|
}
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
return sal_False;
|
2001-03-30 12:41:39 +00:00
|
|
|
case typelib_TypeClass_ARRAY:
|
|
|
|
{
|
|
|
|
sal_Bool bRet = sal_False;
|
|
|
|
if (pSourceTypeDescr)
|
|
|
|
{
|
|
|
|
typelib_ArrayTypeDescription * pTypeDescr =
|
2003-03-20 11:28:27 +00:00
|
|
|
(typelib_ArrayTypeDescription *)pSourceTypeDescr;
|
2002-08-21 08:19:40 +00:00
|
|
|
bRet = _assignArray( pDest, pSource, pTypeDescr, queryInterface, acquire, release );
|
2001-03-30 12:41:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TYPELIB_DANGER_GET( &pSourceTypeDescr, pSourceType );
|
|
|
|
typelib_ArrayTypeDescription * pTypeDescr =
|
|
|
|
(typelib_ArrayTypeDescription *)pSourceTypeDescr;
|
|
|
|
if ( pTypeDescr )
|
2002-08-21 08:19:40 +00:00
|
|
|
{
|
|
|
|
bRet = _assignArray(
|
|
|
|
pDest, pSource, pTypeDescr, queryInterface, acquire, release );
|
|
|
|
}
|
2001-03-30 12:41:39 +00:00
|
|
|
TYPELIB_DANGER_RELEASE( pSourceTypeDescr );
|
|
|
|
}
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
return sal_False;
|
2000-09-18 14:29:57 +00:00
|
|
|
case typelib_TypeClass_UNION:
|
2002-08-21 08:19:40 +00:00
|
|
|
if (_type_equals( pDestType, pSourceType ))
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
|
|
|
if (pDestTypeDescr)
|
|
|
|
{
|
2002-08-21 08:19:40 +00:00
|
|
|
_destructUnion( pDest, pDestTypeDescr, release );
|
|
|
|
_copyConstructUnion( pDest, pSource, pDestTypeDescr, acquire, 0 );
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TYPELIB_DANGER_GET( &pDestTypeDescr, pDestType );
|
2002-08-21 08:19:40 +00:00
|
|
|
_destructUnion( pDest, pDestTypeDescr, release );
|
|
|
|
_copyConstructUnion( pDest, pSource, pDestTypeDescr, acquire, 0 );
|
2000-09-18 14:29:57 +00:00
|
|
|
TYPELIB_DANGER_RELEASE( pDestTypeDescr );
|
|
|
|
}
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
return sal_False;
|
|
|
|
case typelib_TypeClass_SEQUENCE:
|
2000-09-25 13:47:41 +00:00
|
|
|
if (typelib_TypeClass_SEQUENCE != pSourceType->eTypeClass)
|
|
|
|
return sal_False;
|
2003-09-04 09:52:45 +00:00
|
|
|
// self assignment:
|
|
|
|
if (*(uno_Sequence **)pSource == *(uno_Sequence **)pDest)
|
2000-09-18 14:29:57 +00:00
|
|
|
return sal_True;
|
2002-08-21 08:19:40 +00:00
|
|
|
if (_type_equals( pDestType, pSourceType ))
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
2003-09-04 09:52:45 +00:00
|
|
|
::osl_incrementInterlockedCount(
|
|
|
|
&(*(uno_Sequence **)pSource)->nRefCount );
|
|
|
|
idestructSequence(
|
|
|
|
*(uno_Sequence **)pDest, pDestType, pDestTypeDescr, release );
|
2000-09-18 14:29:57 +00:00
|
|
|
*(uno_Sequence **)pDest = *(uno_Sequence **)pSource;
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
return sal_False;
|
|
|
|
case typelib_TypeClass_INTERFACE:
|
|
|
|
if (typelib_TypeClass_INTERFACE != pSourceType->eTypeClass)
|
|
|
|
return sal_False;
|
2002-08-21 08:19:40 +00:00
|
|
|
if (_type_equals( pDestType, pSourceType ))
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
2002-08-21 08:19:40 +00:00
|
|
|
_assignInterface( (void **)pDest, *(void **)pSource, acquire, release );
|
2000-09-18 14:29:57 +00:00
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sal_Bool bRet;
|
|
|
|
if (pSourceTypeDescr)
|
|
|
|
{
|
|
|
|
typelib_TypeDescription * pTD = pSourceTypeDescr;
|
2002-08-21 08:19:40 +00:00
|
|
|
while (pTD && !_type_equals( pTD->pWeakRef, pDestType ))
|
2003-03-20 11:28:27 +00:00
|
|
|
{
|
|
|
|
pTD = (typelib_TypeDescription *)
|
|
|
|
((typelib_InterfaceTypeDescription *)pTD)->pBaseTypeDescription;
|
|
|
|
}
|
2000-09-18 14:29:57 +00:00
|
|
|
if (pTD) // is base of dest
|
|
|
|
{
|
2002-08-21 08:19:40 +00:00
|
|
|
_assignInterface( (void **)pDest, *(void **)pSource, acquire, release );
|
2000-09-18 14:29:57 +00:00
|
|
|
bRet = sal_True;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// query for interface
|
2002-08-21 08:19:40 +00:00
|
|
|
bRet = _queryAndAssignInterface(
|
2000-09-18 14:29:57 +00:00
|
|
|
(void **)pDest, *(void **)pSource, pDestType, queryInterface, release );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-08-21 08:19:40 +00:00
|
|
|
if (_type_equals( pSourceType, pDestType ))
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
2002-08-21 08:19:40 +00:00
|
|
|
_assignInterface( (void **)pDest, *(void **)pSource, acquire, release );
|
2000-09-18 14:29:57 +00:00
|
|
|
bRet = sal_True;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// query for interface
|
2002-08-21 08:19:40 +00:00
|
|
|
bRet = _queryAndAssignInterface(
|
2000-09-18 14:29:57 +00:00
|
|
|
(void **)pDest, *(void **)pSource, pDestType, queryInterface, release );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|