2000-09-18 14:29:57 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* $RCSfile: prim.hxx,v $
|
|
|
|
*
|
2004-02-04 13:00:50 +00:00
|
|
|
* $Revision: 1.15 $
|
2000-09-18 14:29:57 +00:00
|
|
|
*
|
2004-02-04 13:00:50 +00:00
|
|
|
* last change: $Author: hr $ $Date: 2004-02-04 14:00:50 $
|
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 PRIM_HXX
|
|
|
|
#define PRIM_HXX
|
2000-09-18 14:29:57 +00:00
|
|
|
|
|
|
|
#ifndef _TYPELIB_TYPEDESCRIPTION_H_
|
2003-03-20 11:30:00 +00:00
|
|
|
#include "typelib/typedescription.h"
|
2000-09-18 14:29:57 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _typelib_TypeClass_H_
|
2003-03-20 11:30:00 +00:00
|
|
|
#include "typelib/typeclass.h"
|
2000-09-18 14:29:57 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _UNO_SEQUENCE2_H_
|
2003-03-20 11:30:00 +00:00
|
|
|
#include "uno/sequence2.h"
|
2000-09-18 14:29:57 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _UNO_ANY2_H_
|
2003-03-20 11:30:00 +00:00
|
|
|
#include "uno/any2.h"
|
2000-09-18 14:29:57 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _UNO_DATA_H_
|
2003-03-20 11:30:00 +00:00
|
|
|
#include "uno/data.h"
|
2000-09-18 14:29:57 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _UNO_MAPPING_H_
|
2003-03-20 11:30:00 +00:00
|
|
|
#include "uno/mapping.h"
|
2000-09-18 14:29:57 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _UNO_DISPATCHER_H_
|
2003-03-20 11:30:00 +00:00
|
|
|
#include "uno/dispatcher.h"
|
2000-09-18 14:29:57 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _OSL_INTERLCK_H
|
2003-03-20 11:30:00 +00:00
|
|
|
#include "osl/interlck.h"
|
2000-09-18 14:29:57 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _OSL_DIAGNOSE_H_
|
2003-03-20 11:30:00 +00:00
|
|
|
#include "osl/diagnose.h"
|
2000-09-18 14:29:57 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _RTL_USTRING_HXX
|
2003-03-20 11:30:00 +00:00
|
|
|
#include "rtl/ustring.hxx"
|
2000-09-18 14:29:57 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _RTL_ALLOC_H_
|
2003-03-20 11:30:00 +00:00
|
|
|
#include "rtl/alloc.h"
|
2000-09-18 14:29:57 +00:00
|
|
|
#endif
|
|
|
|
|
2003-04-15 15:38:04 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2003-03-20 11:30:00 +00:00
|
|
|
#include "rtl/ustrbuf.hxx"
|
|
|
|
#include "rtl/string.hxx"
|
|
|
|
#endif
|
2000-09-18 14:29:57 +00:00
|
|
|
|
2002-08-21 08:19:40 +00:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
namespace cppu
|
|
|
|
{
|
|
|
|
|
2001-08-22 10:03:23 +00:00
|
|
|
extern uno_Sequence g_emptySeq;
|
|
|
|
extern typelib_TypeDescriptionReference * g_pVoidType;
|
2001-02-20 09:16:11 +00:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2002-08-21 08:19:40 +00:00
|
|
|
inline void * _map(
|
2000-09-18 14:29:57 +00:00
|
|
|
void * p,
|
2003-03-20 11:30:00 +00:00
|
|
|
typelib_TypeDescriptionReference * pType, typelib_TypeDescription * pTypeDescr,
|
2001-03-09 11:10:57 +00:00
|
|
|
uno_Mapping * mapping )
|
|
|
|
SAL_THROW( () )
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
|
|
|
void * pRet = 0;
|
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
if (pTypeDescr)
|
|
|
|
{
|
2003-03-20 11:30:00 +00:00
|
|
|
(*mapping->mapInterface)(
|
|
|
|
mapping, &pRet, p, (typelib_InterfaceTypeDescription *)pTypeDescr );
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TYPELIB_DANGER_GET( &pTypeDescr, pType );
|
2003-03-20 11:30:00 +00:00
|
|
|
(*mapping->mapInterface)(
|
|
|
|
mapping, &pRet, p, (typelib_InterfaceTypeDescription *)pTypeDescr );
|
2000-09-18 14:29:57 +00:00
|
|
|
TYPELIB_DANGER_RELEASE( pTypeDescr );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2003-03-20 11:30:00 +00:00
|
|
|
inline void _acquire( void * p, uno_AcquireFunc acquire ) SAL_THROW( () )
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
if (acquire)
|
2001-06-29 10:10:47 +00:00
|
|
|
{
|
2000-09-18 14:29:57 +00:00
|
|
|
(*acquire)( p );
|
2001-06-29 10:10:47 +00:00
|
|
|
}
|
2000-09-18 14:29:57 +00:00
|
|
|
else
|
2001-06-29 10:10:47 +00:00
|
|
|
{
|
2000-09-18 14:29:57 +00:00
|
|
|
(*((uno_Interface *)p)->acquire)( (uno_Interface *)p );
|
2001-06-29 10:10:47 +00:00
|
|
|
}
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2003-03-20 11:30:00 +00:00
|
|
|
inline void _release( void * p, uno_ReleaseFunc release ) SAL_THROW( () )
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
2001-06-29 10:10:47 +00:00
|
|
|
if (p)
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
|
|
|
if (release)
|
2001-06-29 10:10:47 +00:00
|
|
|
{
|
|
|
|
(*release)( p );
|
|
|
|
}
|
2000-09-18 14:29:57 +00:00
|
|
|
else
|
2001-06-29 10:10:47 +00:00
|
|
|
{
|
|
|
|
(*((uno_Interface *)p)->release)( (uno_Interface *)p );
|
|
|
|
}
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-04 09:53:33 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
inline sal_uInt32 calcSeqMemSize(
|
|
|
|
sal_Int32 nElementSize, sal_Int32 nElements )
|
|
|
|
{
|
|
|
|
sal_uInt64 nSize =
|
|
|
|
(sal_uInt64) SAL_SEQUENCE_HEADER_SIZE +
|
|
|
|
((sal_uInt64) nElementSize * (sal_uInt64) nElements);
|
|
|
|
if (nSize > 0xffffffffU)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return (sal_uInt32) nSize;
|
|
|
|
}
|
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2003-09-04 09:53:33 +00:00
|
|
|
inline uno_Sequence * createEmptySequence() SAL_THROW( () )
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
2001-08-22 10:03:23 +00:00
|
|
|
::osl_incrementInterlockedCount( &g_emptySeq.nRefCount );
|
|
|
|
return &g_emptySeq;
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2002-08-21 08:19:40 +00:00
|
|
|
inline typelib_TypeDescriptionReference * _getVoidType()
|
2001-03-09 11:10:57 +00:00
|
|
|
SAL_THROW( () )
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
2001-08-22 10:03:23 +00:00
|
|
|
if (! g_pVoidType)
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
2001-08-22 10:03:23 +00:00
|
|
|
g_pVoidType = * ::typelib_static_type_getByTypeClass( typelib_TypeClass_VOID );
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
2001-08-22 10:03:23 +00:00
|
|
|
::typelib_typedescriptionreference_acquire( g_pVoidType );
|
|
|
|
return g_pVoidType;
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2003-04-15 15:38:04 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 0
|
2002-08-21 08:19:40 +00:00
|
|
|
#define CONSTRUCT_EMPTY_ANY( pAny ) \
|
|
|
|
(pAny)->pType = _getVoidType(); \
|
2000-09-18 14:29:57 +00:00
|
|
|
(pAny)->pData = (void *)0xdeadbeef;
|
|
|
|
#else
|
2002-08-21 08:19:40 +00:00
|
|
|
#define CONSTRUCT_EMPTY_ANY( pAny ) \
|
|
|
|
(pAny)->pType = _getVoidType(); \
|
2001-06-25 07:32:01 +00:00
|
|
|
(pAny)->pData = (pAny);
|
2000-09-18 14:29:57 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2002-08-21 08:19:40 +00:00
|
|
|
#define TYPE_ACQUIRE( pType ) \
|
2000-09-18 14:29:57 +00:00
|
|
|
::osl_incrementInterlockedCount( &(pType)->nRefCount );
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2003-03-20 11:30:00 +00:00
|
|
|
void * binuno_queryInterface( void * pUnoI, typelib_TypeDescriptionReference * pDestType );
|
2000-09-18 14:29:57 +00:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2002-08-21 08:19:40 +00:00
|
|
|
inline typelib_TypeDescriptionReference * _unionGetSetType(
|
2001-03-09 11:10:57 +00:00
|
|
|
void * pUnion, typelib_TypeDescription * pTD )
|
|
|
|
SAL_THROW( () )
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
2004-02-04 13:00:50 +00:00
|
|
|
typelib_TypeDescriptionReference * pRet = 0;
|
2003-12-01 15:03:16 +00:00
|
|
|
sal_Int32 nPos;
|
2000-09-18 14:29:57 +00:00
|
|
|
|
|
|
|
sal_Int64 * pDiscr = ((typelib_UnionTypeDescription *)pTD)->pDiscriminants;
|
|
|
|
sal_Int64 nDiscr = *(sal_Int64 *)pUnion;
|
2003-12-01 15:03:16 +00:00
|
|
|
for ( nPos = ((typelib_UnionTypeDescription *)pTD)->nMembers; nPos--; )
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
|
|
|
if (pDiscr[nPos] == nDiscr)
|
|
|
|
{
|
|
|
|
pRet = ((typelib_UnionTypeDescription *)pTD)->ppTypeRefs[nPos];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (nPos >= 0)
|
|
|
|
{
|
|
|
|
// default
|
|
|
|
pRet = ((typelib_UnionTypeDescription *)pTD)->pDefaultTypeRef;
|
|
|
|
}
|
|
|
|
typelib_typedescriptionreference_acquire( pRet );
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2002-08-21 08:19:40 +00:00
|
|
|
inline sal_Bool _type_equals(
|
2000-12-21 13:39:29 +00:00
|
|
|
typelib_TypeDescriptionReference * pType1, typelib_TypeDescriptionReference * pType2 )
|
2001-03-09 11:10:57 +00:00
|
|
|
SAL_THROW( () )
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
|
|
|
return (pType1 == pType2 ||
|
|
|
|
(pType1->eTypeClass == pType2->eTypeClass &&
|
|
|
|
pType1->pTypeName->length == pType2->pTypeName->length &&
|
|
|
|
::rtl_ustr_compare( pType1->pTypeName->buffer, pType2->pTypeName->buffer ) == 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|