2010-10-14 08:30:07 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-13 14:17:57 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2014-04-18 18:25:29 +02:00
|
|
|
#ifndef INCLUDED_CPPU_SOURCE_UNO_PRIM_HXX
|
|
|
|
#define INCLUDED_CPPU_SOURCE_UNO_PRIM_HXX
|
2000-09-18 14:29:57 +00:00
|
|
|
|
2003-03-20 11:30:00 +00:00
|
|
|
#include "typelib/typedescription.h"
|
|
|
|
#include "typelib/typeclass.h"
|
|
|
|
#include "uno/sequence2.h"
|
|
|
|
#include "uno/any2.h"
|
|
|
|
#include "uno/data.h"
|
|
|
|
#include "uno/mapping.h"
|
|
|
|
#include "uno/dispatcher.h"
|
2000-09-18 14:29:57 +00:00
|
|
|
|
2003-03-20 11:30:00 +00:00
|
|
|
#include "osl/interlck.h"
|
|
|
|
#include "osl/diagnose.h"
|
|
|
|
#include "rtl/ustring.hxx"
|
|
|
|
#include "rtl/alloc.h"
|
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
|
|
|
|
2014-02-25 18:01:43 +01: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 )
|
2014-06-05 08:13:49 +02:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
2015-11-10 10:12:56 +01:00
|
|
|
void * pRet = nullptr;
|
2000-09-18 14:29:57 +00:00
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
if (pTypeDescr)
|
|
|
|
{
|
2003-03-20 11:30:00 +00:00
|
|
|
(*mapping->mapInterface)(
|
2015-01-17 18:18:10 +01:00
|
|
|
mapping, &pRet, p, reinterpret_cast<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)(
|
2015-01-17 18:18:10 +01:00
|
|
|
mapping, &pRet, p, reinterpret_cast<typelib_InterfaceTypeDescription *>(pTypeDescr) );
|
2000-09-18 14:29:57 +00:00
|
|
|
TYPELIB_DANGER_RELEASE( pTypeDescr );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
2014-02-25 18:01:43 +01:00
|
|
|
|
2014-06-05 08:13:49 +02:00
|
|
|
inline void _acquire( void * p, uno_AcquireFunc acquire )
|
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
|
|
|
{
|
2015-03-28 19:00:10 +01:00
|
|
|
(*static_cast<uno_Interface *>(p)->acquire)( static_cast<uno_Interface *>(p) );
|
2001-06-29 10:10:47 +00:00
|
|
|
}
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
}
|
2014-02-25 18:01:43 +01:00
|
|
|
|
2014-06-05 08:13:49 +02:00
|
|
|
inline void _release( void * p, uno_ReleaseFunc release )
|
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
|
|
|
{
|
2015-03-28 19:00:10 +01:00
|
|
|
(*static_cast<uno_Interface *>(p)->release)( static_cast<uno_Interface *>(p) );
|
2001-06-29 10:10:47 +00:00
|
|
|
}
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-25 18:01:43 +01: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;
|
|
|
|
}
|
|
|
|
|
2014-02-25 18:01:43 +01:00
|
|
|
|
2014-06-05 08:13:49 +02:00
|
|
|
inline uno_Sequence * createEmptySequence()
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
2012-09-16 02:00:14 -05:00
|
|
|
osl_atomic_increment( &g_emptySeq.nRefCount );
|
2001-08-22 10:03:23 +00:00
|
|
|
return &g_emptySeq;
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
2014-02-25 18:01:43 +01:00
|
|
|
|
2002-08-21 08:19:40 +00:00
|
|
|
inline typelib_TypeDescriptionReference * _getVoidType()
|
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
|
|
|
}
|
|
|
|
|
2015-07-08 20:56:19 +02:00
|
|
|
inline void CONSTRUCT_EMPTY_ANY(uno_Any * pAny) {
|
|
|
|
pAny->pType = _getVoidType();
|
2003-04-15 15:38:04 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 0
|
2016-02-21 08:24:49 -08:00
|
|
|
pAny->pData = reinterpret_cast<void *>((uintptr_t)0xdeadbeef);
|
2000-09-18 14:29:57 +00:00
|
|
|
#else
|
2015-07-08 20:56:19 +02:00
|
|
|
pAny->pData = pAny;
|
2000-09-18 14:29:57 +00:00
|
|
|
#endif
|
2015-07-08 20:56:19 +02:00
|
|
|
}
|
2014-02-25 18:01:43 +01:00
|
|
|
|
2002-08-21 08:19:40 +00:00
|
|
|
#define TYPE_ACQUIRE( pType ) \
|
2012-09-16 02:00:14 -05:00
|
|
|
osl_atomic_increment( &(pType)->nRefCount );
|
2000-09-18 14:29:57 +00:00
|
|
|
|
2014-02-25 18:01:43 +01:00
|
|
|
|
2006-06-19 12:15:15 +00:00
|
|
|
extern "C" void * binuno_queryInterface(
|
|
|
|
void * pUnoI, typelib_TypeDescriptionReference * pDestType );
|
2000-09-18 14:29:57 +00:00
|
|
|
|
2014-02-25 18:01:43 +01:00
|
|
|
|
2014-02-15 17:39:35 +01:00
|
|
|
inline bool _type_equals(
|
2000-12-21 13:39:29 +00:00
|
|
|
typelib_TypeDescriptionReference * pType1, typelib_TypeDescriptionReference * pType2 )
|
2014-06-05 08:13:49 +02:00
|
|
|
|
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
|
2010-10-14 08:30:07 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|