Kaydet (Commit) 0f73faeb authored tarafından Petr Mladek's avatar Petr Mladek

[mono] cli_ure-mono-bridge.diff: add mono support

merged with mono-bridge-version.diff: add mono support

Conflicts:
	cli_ure/prj/build.lst
	cli_ure/source/mono_bridge/makefile.mk

Change-Id: Ia0663f44d9e2cc7b8d19baa19e05b060a8967fcd
üst b4b026c2
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# 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/.
#
include $(SRCDIR)/cli_ure/version/version.txt
$(eval $(call gb_CliLibrary_CliLibrary,cli_uno_bridge))
# FIXME: The original code did not use config file at all; How to do this in gbuild
$(eval $(call gb_CliLibrary_set_configfile,cli_uno_bridge,cli_ure/source/basetypes/cli_basetypes_config))
$(eval $(call gb_CliLibrary_set_keyfile,cli_uno_bridge,$(SRCDIR)/cli_ure/source/cliuno.snk))
# FIXME: the original code did not use the policy assembly; there is someting similar in cli_ure/source/mono_bridge/assemblyinfo
# How to do this in gbuild?
$(eval $(call gb_CliLibrary_set_policy,cli_uno_bridge,$(CLI_BASETYPES_POLICY_ASSEMBLY),$(CLI_BASETYPES_POLICY_VERSION)))
$(eval $(call gb_CliLibrary_add_csfiles,cli_uno_bridge,\
cli_ure/source/mono_bridge/assemblyinfo \
cli_ure/source/mono_bridge/binaryuno \
cli_ure/source/mono_bridge/bridge \
cli_ure/source/mono_bridge/cli_environment \
cli_ure/source/mono_bridge/managed_proxy \
cli_ure/source/mono_bridge/rtl_ustring \
cli_ure/source/mono_bridge/typeclass \
cli_ure/source/mono_bridge/typedescription \
cli_ure/source/mono_bridge/uik \
cli_ure/source/mono_bridge/uno_proxy \
))
$(eval $(call gb_CliLibrary_add_csflags,cli_uno_bridge,\
-unsafe \
))
$(eval $(call gb_CliLibrary_use_assemblies,cli_uno_bridge,\
cli_basetypes \
cli_uretypes \
))
# vim: set noet sw=4 ts=4:
......@@ -16,6 +16,7 @@ $(eval $(call gb_CustomTarget_CustomTarget,cli_ure/source))
$(call gb_CustomTarget_get_target,cli_ure/source) : \
$(call gb_CustomTarget_get_workdir,cli_ure/source)/basetypes/assembly.cs \
$(call gb_CustomTarget_get_workdir,cli_ure/source)/native/assembly.cxx \
$(call gb_CustomTarget_get_workdir,cli_ure/source)/bootstrap/assembly.cs \
$(call gb_CustomTarget_get_workdir,cli_ure/source)/ure/assembly.cs
$(call gb_CustomTarget_get_workdir,cli_ure/source)/basetypes/assembly.cs : \
......@@ -30,6 +31,12 @@ $(call gb_CustomTarget_get_workdir,cli_ure/source)/native/assembly.cxx : \
$(cli_ure_source_MAKEFILE) \
| $(call gb_CustomTarget_get_workdir,cli_ure/source)/native/.dir
$(call gb_CustomTarget_get_workdir,cli_ure/source)/bootstrap/assembly.cs : \
$(SRCDIR)/cli_ure/source/bootstrap/assembly.cs \
$(SRCDIR)/cli_ure/version/version.txt \
$(cli_ure_source_MAKEFILE) \
| $(call gb_CustomTarget_get_workdir,cli_ure/source)/bootstrap/.dir
$(call gb_CustomTarget_get_workdir,cli_ure/source)/ure/assembly.cs : \
$(SRCDIR)/cli_ure/source/ure/assembly.cs \
$(SRCDIR)/cli_ure/version/version.txt \
......@@ -47,6 +54,11 @@ $(call gb_CustomTarget_get_workdir,cli_ure/source)/native/assembly.cxx :
echo '[assembly:System::Reflection::AssemblyVersion( "$(CLI_CPPUHELPER_NEW_VERSION)" )];' >> $@.tmp && \
mv $@.tmp $@
$(call gb_CustomTarget_get_workdir,cli_ure/source)/bootstrap/assembly.cs :
$(GNUCOPY) $< $@.tmp && \
echo '[assembly:System.Reflection.AssemblyVersion( "$(CLI_CPPUHELPER_NEW_VERSION)" )]' >> $@.tmp && \
mv $@.tmp $@
$(call gb_CustomTarget_get_workdir,cli_ure/source)/ure/assembly.cs :
$(GNUCOPY) $< $@.tmp && \
echo '[assembly:System.Reflection.AssemblyVersion( "$(CLI_URE_NEW_VERSION)" )]' >> $@.tmp && \
......
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# 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/.
#
$(eval $(call gb_Library_Library,cli_uno))
$(eval $(call gb_Library_add_cxxflags,cli_uno,\
$(MONO_CFLAGS) \
-fvisibility=default \
))
$(eval $(call gb_Library_use_udk_api,cli_uno))
$(eval $(call gb_Library_add_ldflags,cli_uno,\
$(MONO_LIBS) \
))
$(eval $(call gb_Library_use_libraries,cli_uno,\
sal \
cppu \
cppuhelper \
))
$(eval $(call gb_Library_add_exception_objects,cli_uno,\
cli_ure/source/mono_bridge/mono_bridge \
cli_ure/source/mono_bridge/mono_proxy \
cli_ure/source/mono_bridge/uno_glue \
))
# vim: set noet sw=4 ts=4:
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly: AssemblyVersion("1.0.0.0")]
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org 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 version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
namespace uno.Binary {
using System;
using System.Runtime.InteropServices;
using uno.Typelib;
using uno.rtl;
[ StructLayout(LayoutKind.Sequential) ]
public unsafe struct Any
{
/** type of value
*/
public uno.Typelib.TypeDescriptionReference *pType;
/** pointer to value; this may point to pReserved and thus the uno_Any is not anytime
mem-copyable! You may have to correct the pData pointer to pReserved. Otherwise you need
not, because the data is stored in heap space.
*/
public void *pData;
/** reserved space for storing value
*/
public void *pReserved;
[ DllImport("uno_cppu", EntryPoint="uno_any_construct") ]
public static unsafe extern void Construct(/* Any */ void *dest,
void *source,
/* uno.Typelib.TypeDescriptionReference */ void *type,
void *acquireFunction);
[ DllImport("uno_cppu", EntryPoint="uno_any_destruct") ]
public static unsafe extern void Destroy(/* Any */ void *value, void *releaseFunction);
}
// FIXME wrap this nicely
public struct Interface
{
[ DllImport("cli_uno", EntryPoint="cli_uno_interface_acquire") ]
public static extern void Acquire(IntPtr unoInterface);
[ DllImport("cli_uno", EntryPoint="cli_uno_interface_release") ]
public static extern void Release(IntPtr unoInterface);
[ DllImport("cli_uno", EntryPoint="cli_uno_interface_dispatch") ]
public static unsafe extern void Dispatch(IntPtr unoInterface,
/* uno.Typelib.TypeDescription */ void *memberTD,
void *result,
void **args,
uno.Binary.Any **exception);
}
// FIXME and this
public class Environment
{
[ DllImport("cli_uno", EntryPoint="cli_uno_environment_getObjectIdentifier") ]
public static unsafe extern void GetObjectIdentifier(IntPtr unoEnvironment,
UString** oid,
IntPtr unoInterface);
[ DllImport("cli_uno", EntryPoint="cli_uno_environment_registerInterface") ]
public static unsafe extern void RegisterInterface(
IntPtr unoEnvironment,
ref IntPtr ppInterface,
/* UString */ void* oid,
/* InterfaceTypeDescription */ void *td);
[ DllImport("cli_uno", EntryPoint="cli_uno_environment_getRegisteredInterface") ]
public static unsafe extern void GetRegisteredInterface(
IntPtr unoEnvironment,
ref IntPtr ppInterface,
/* UString */ void* oid,
/* InterfaceTypeDescription */ void *td);
}
public struct Data
{
[ DllImport("uno_cppu", EntryPoint="uno_type_destructData") ]
public static unsafe extern void Destroy(void *data,
/* uno.Typelib.TypeDescription */ void *td,
// FIXME is this okay? release is a function pointer
void *release);
}
public unsafe struct SequencePtr
{
int *sal_Sequence;
// sal_Int32 nRefCount;
// sal_Int32 nElements;
// char elements[1];
/** element count<br>
*/
/** elements array<br>
*/
/** reference count of sequence<br>
*/
private unsafe int nRefCount
{
get { return *(sal_Sequence); }
set { *(sal_Sequence) = value; }
}
public unsafe int nElements
{
get { return *(sal_Sequence + 1); }
set { *(sal_Sequence + 1) = value; }
}
public unsafe IntPtr elementsPtr
{
get { return new IntPtr((void *)(sal_Sequence + 2)); }
}
private unsafe SequencePtr(void *mem)
{
sal_Sequence = (int*)mem;
}
private const int HEADER_SIZE = 8; // FIXME alignment
public static SequencePtr Allocate(int length, int elementSize)
{
void *rtlPtr = uno.rtl.Mem.Allocate(HEADER_SIZE + (length * elementSize));
SequencePtr seqPtr = new SequencePtr(rtlPtr);
seqPtr.nRefCount = 1;
seqPtr.nElements = length;
return seqPtr;
}
}
}
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org 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 version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
namespace cli_uno
{
using System;
using System.Collections;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Proxies;
using System.Text;
using com.sun.star.bridges.mono_uno;
public class Cli_environment
{
static string sOidPart = ";cli[0];";
static Hashtable m_objects = Hashtable.Synchronized(new Hashtable());
static string createKey(string oid, Type t)
{
return oid + t.FullName;
}
// FIXME setup debugging info here
// public Cli_environment()
// {
// }
// FIXME assert there are no more registered objects
// public ~Cli_environment()
// {
// }
/**
Registers an UNO object as being mapped by this bridge. The resulting
cli object is represents all interfaces of the UNO object. Therefore the
object can be registered only with its OID; a type is not necessary.
*/
public object registerInterface(object obj, string oid)
{
// FIXME debugging stuff
m_objects.Add(oid, obj); // new WeakReference(obj));
return obj;
}
/**
Registers a CLI object as being mapped by this bridge. The resulting
object represents exactly one UNO interface.
*/
public object registerInterface(object obj, string oid, Type type)
{
// FIXME debugging stuff
string key = createKey(oid, type);
m_objects.Add(key, obj); // new WeakReference(obj));
return obj;
}
/**
By revoking an interface it is declared that the respective interface has
not been mapped. The proxy implementations call revoke interface in their
destructors.
*/
public void revokeInterface(string oid)
{
revokeInterface(oid, null);
}
public void revokeInterface(string oid, Type type)
{
// FIXME debugging stuff
string key = type != null ? createKey(oid, type) : oid;
m_objects.Remove(key);
}
/**
* Retrieves an interface identified by its object id and type from this
* environment.
*
* @param oid object id of interface to be retrieved
* @param type the type description of the interface to be retrieved
* @see com.sun.star.uno.IEnvironment#getRegisteredInterface
*/
public object getRegisteredInterface(string oid, Type type)
{
// try if it is a UNO interface
object ret = null;
ret = m_objects[oid];
if (ret == null)
{
// try if it is a proxy for a cli object
oid = createKey(oid, type);
ret = m_objects[oid];
}
/* if (ret != null)
{
WeakReference weakIface = (WeakReference)ret;
ret = weakIface.Target;
} */
if (ret == null)
m_objects.Remove(oid);
return ret;
}
/**
* Generates a worldwide unique object identifier (oid) for the given object. It is
* guaranteed, that subsequent calls to the method with the same object
* will give the same id.
* <p>
* @return the generated oid.
* @param object the object for which a Oid should be generated.
*/
public static string getObjectIdentifier(object obj)
{
string oid = null;
RealProxy realProxy = null;
if (RemotingServices.IsTransparentProxy(obj))
realProxy = RemotingServices.GetRealProxy(obj);
if (realProxy != null)
{
UnoInterfaceProxy proxyImpl = realProxy as UnoInterfaceProxy;
if (proxyImpl != null)
oid = proxyImpl.Oid;
}
if (oid == null)
{
Guid gd = typeof(Cli_environment).GUID; // FIXME apparently not a good idea with mono
StringBuilder buf = new StringBuilder(128);
buf.Append(obj.GetHashCode());
buf.Append(sOidPart);
buf.Append(gd);
oid = buf.ToString();
}
return oid;
}
}
}
This diff is collapsed.
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org 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 version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#if ! defined INCLUDED_MONO_BRIDGE_H
#define INCLUDED_MONO_BRIDGE_H
#include "glib/gtypes.h"
#include "osl/interlck.h"
#include "rtl/ustring.hxx"
#include "typelib/typedescription.hxx"
#include "uno/dispatcher.h"
#include "uno/mapping.h"
extern "C" {
#include "mono/metadata/appdomain.h"
#include "mono/metadata/debug-helpers.h"
#include "mono/metadata/object.h"
#include "mono/metadata/threads.h"
}
namespace cssu = com::sun::star::uno;
typedef struct _uno_ExtEnvironment uno_ExtEnvironment;
typedef struct _uno_Environment uno_Environment;
typedef struct _typelib_TypeDescription typelib_TypeDescription;
namespace mono_uno
{
MonoObject* runtime_invoke (MonoMethod *method, void *obj, void **params,
MonoObject **exc, MonoDomain *domain);
//==== holds environments and mappings =========================================
struct Bridge;
struct Mapping : public uno_Mapping
{
Bridge * m_bridge;
};
//==============================================================================
struct Bridge
{
mutable oslInterlockedCount m_ref;
MonoObject * m_managedBridge;
uno_ExtEnvironment * m_uno_env;
uno_Environment * m_mono_env;
Mapping m_mono2uno;
Mapping m_uno2mono;
bool m_registered_mono2uno;
MonoMethod * m_mapUnoToManagedMethod;
MonoMethod * m_mapManagedToUnoMethod;
~Bridge() SAL_THROW( () );
explicit Bridge(
uno_Environment * mono_env, uno_ExtEnvironment * uno_env,
bool registered_mono2uno );
void acquire() const;
void release() const;
void * map_to_mono(
uno_Interface * pUnoI, typelib_TypeDescription * pTD ) const;
uno_Interface * map_to_uno(
void * pMonoI, typelib_TypeDescription * pTD ) const;
};
struct MonoProxy : public uno_Interface
{
mutable oslInterlockedCount m_ref;
guint32 m_managedProxy;
uno_ExtEnvironment * m_unoEnv;
const cssu::TypeDescription m_unoType;
const rtl::OUString m_Oid;
MonoMethod * m_managedDispatch;
void acquire() const;
void release() const;
void dispatch(typelib_TypeDescription const * member_td, void * uno_ret,
void * uno_args [], uno_Any ** uno_exc);
MonoProxy(uno_ExtEnvironment * pUnoEnv, guint32 managedProxy,
rtl_uString * pOid, typelib_TypeDescription * pTD);
};
struct BridgeRuntimeError
{
::rtl::OUString m_message;
inline BridgeRuntimeError( ::rtl::OUString const & message )
: m_message( message )
{}
};
}
#endif
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org 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 version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#include "mono_bridge.h"
#include "rtl/ustring.h"
#include "uno/dispatcher.h"
#include "uno/environment.h"
#include "typelib/typedescription.h"
extern "C" {
#include "mono/metadata/threads.h"
}
using namespace mono_uno;
extern "C" {
static void SAL_CALL mono_proxy_free( uno_ExtEnvironment * /* env */, void * proxy)
{
MonoProxy * monoProxy = reinterpret_cast< MonoProxy * >( proxy );
delete monoProxy;
}
uno_Interface * SAL_CALL cli_uno_environment_createMonoProxyAndRegister(
uno_ExtEnvironment *pUnoEnv, void *pMonoProxy, rtl_uString *pOid,
typelib_TypeDescription *pTD )
SAL_THROW_EXTERN_C()
{
uno_Interface * proxy = static_cast< uno_Interface * >(
new MonoProxy( pUnoEnv,
static_cast< guint32 >( reinterpret_cast< sal_IntPtr >( pMonoProxy ) ),
pOid, pTD ) );
pUnoEnv->registerProxyInterface(
pUnoEnv,
reinterpret_cast< void ** >( &proxy ),
mono_proxy_free,
pOid,
(typelib_InterfaceTypeDescription*) pTD );
return proxy;
}
static void SAL_CALL mono_proxy_acquire( uno_Interface * pUnoI )
{
MonoProxy const * that = static_cast< MonoProxy const * >( pUnoI );
that->acquire();
}
static void SAL_CALL mono_proxy_release( uno_Interface * pUnoI )
{
MonoProxy const * that = static_cast< MonoProxy const * >( pUnoI );
that->release();
}
static void SAL_CALL mono_proxy_dispatch(
uno_Interface * pUnoI, typelib_TypeDescription const * member_td,
void * uno_ret, void * uno_args [], uno_Any ** uno_exc )
SAL_THROW_EXTERN_C()
{
MonoProxy * that = static_cast< MonoProxy * >( pUnoI );
that->dispatch( member_td, uno_ret, uno_args, uno_exc );
}
} // extern "C"
namespace mono_uno
{
MonoProxy::MonoProxy(uno_ExtEnvironment * pUnoEnv, guint32 managedProxy,
rtl_uString *pOid, typelib_TypeDescription * pTD):
m_ref(1),
m_managedProxy(managedProxy), // FIXME free this in the destructor?
m_unoEnv(pUnoEnv),
m_unoType(pTD),
m_Oid(pOid)
{
uno_Interface::acquire = mono_proxy_acquire;
uno_Interface::release = mono_proxy_release;
uno_Interface::pDispatcher = mono_proxy_dispatch;
MonoObject * pObj = mono_gchandle_get_target( m_managedProxy );
MonoClass * pClass = mono_object_get_class( pObj );
MonoMethodDesc * pMethodDesc = mono_method_desc_new( "ManagedProxy:Dispatch", FALSE );
m_managedDispatch = mono_method_desc_search_in_class( pMethodDesc, pClass );
mono_method_desc_free( pMethodDesc );
OSL_ASSERT( 0 != m_managedDispatch );
}
inline void MonoProxy::acquire() const
{
if (1 == osl_incrementInterlockedCount( &m_ref ))
{
// rebirth of proxy zombie
void * that = const_cast< MonoProxy * >( this );
// register at uno env
(*m_unoEnv->registerProxyInterface)(
m_unoEnv, &that,
mono_proxy_free, m_Oid.pData,
(typelib_InterfaceTypeDescription *)m_unoType.get() );
#if OSL_DEBUG_LEVEL >= 2
OSL_ASSERT( this == (void const * const)that );
#endif
}
}
inline void MonoProxy::release() const
{
if (0 == osl_decrementInterlockedCount( &m_ref ))
{
// revoke from uno env on last release,
// The proxy can be resurrected if acquire is called before the uno
// environment calls mono_proxy_free. mono_proxy_free will
//delete the proxy. The environment does not acquire a registered
//proxy.
(*m_unoEnv->revokeInterface)(
m_unoEnv, const_cast< MonoProxy * >( this ) );
}
}
inline void MonoProxy::dispatch( typelib_TypeDescription const * member_td,
void * uno_ret, void * uno_args [], uno_Any ** uno_exc )
{
OSL_ASSERT( m_managedDispatch != 0 );
gpointer pMonoParams[4];
pMonoParams[0] = const_cast< typelib_TypeDescription * >(member_td);
pMonoParams[1] = uno_ret;
pMonoParams[2] = uno_args;
pMonoParams[3] = uno_exc;
MonoObject *obj = mono_gchandle_get_target( m_managedProxy );
mono_uno::runtime_invoke( m_managedDispatch,
obj, pMonoParams, NULL,
mono_object_get_domain( obj ) );
}
}
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org 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 version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
namespace uno.rtl {
using System;
using System.Runtime.InteropServices;
using System.Text;
public unsafe struct UString
{
public int RefCount;
public int Length;
public char FirstChar;
[DllImport("sal")]
private static extern void rtl_uString_acquire(void* data);
[DllImport("sal")]
private static unsafe extern void rtl_uString_release(void* data);
[DllImport("sal")]
private static unsafe extern void rtl_uString_new(void* data);
[DllImport("sal")]
private static unsafe extern void rtl_uString_newFromStr_WithLength(
void* data,
// this should pass a pointer to the original string's char[]
[MarshalAs(UnmanagedType.LPWStr)] string value,
int len);
[DllImport("sal")]
private static unsafe extern void rtl_uString_newFromStr_WithLength(
void* data,
// this should pass a pointer to the stringbuilder's internal char[]
[MarshalAs(UnmanagedType.LPWStr)] StringBuilder buffer,
int len);
public static unsafe void Acquire(UString* us)
{
rtl_uString_acquire(us);
}
public static unsafe void Release(UString* us)
{
rtl_uString_release(us);
}
public static unsafe void New(UString** p)
{
rtl_uString_new(p);
}
public static unsafe void NewFromString(UString **p, string s)
{
rtl_uString_newFromStr_WithLength(p, s, s.Length);
}
public static unsafe void NewFromStringBuilder(UString **p, StringBuilder sb)
{
rtl_uString_newFromStr_WithLength(p, sb, sb.Length);
}
public static unsafe string UStringToString(UString *p)
{
return new String(&(p->FirstChar), 0, p->Length);
}
}
// FIXME move this to its own file or rename this file to e.g. sal
public unsafe struct Mem
{
// FIXME parameter is a sal_Size which is unsigned and has the
// size of a native long. Thus this is not 64bit safe. Might have
// to write a glue function that always takes 32bit.
[DllImport("sal", EntryPoint="rtl_allocateMemory")]
public static unsafe extern void *Allocate(int bytes);
}
}
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org 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 version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
namespace uno.Typelib {
public class TypeClass
{
/** type class of void */
public const int VOID = 0;
/** type class of char */
public const int CHAR = 1;
/** type class of boolean */
public const int BOOLEAN = 2;
/** type class of byte */
public const int BYTE = 3;
/** type class of short */
public const int SHORT = 4;
/** type class of unsigned short */
public const int UNSIGNED_SHORT = 5;
/** type class of long */
public const int LONG = 6;
/** type class of unsigned long */
public const int UNSIGNED_LONG = 7;
/** type class of hyper */
public const int HYPER = 8;
/** type class of unsigned hyper */
public const int UNSIGNED_HYPER = 9;
/** type class of float */
public const int FLOAT = 10;
/** type class of double */
public const int DOUBLE = 11;
/** type class of string */
public const int STRING = 12;
/** type class of type */
public const int TYPE = 13;
/** type class of any */
public const int ANY = 14;
/** type class of enum */
public const int ENUM = 15;
/** type class of typedef */
public const int TYPEDEF = 16;
/** type class of struct */
public const int STRUCT = 17;
/** type class of union (not implemented) */
public const int UNION = 18;
/** type class of exception */
public const int EXCEPTION = 19;
/** type class of sequence */
public const int SEQUENCE = 20;
/** type class of array (not implemented) */
public const int ARRAY = 21;
/** type class of interface */
public const int INTERFACE = 22;
/** type class of service (not implemented) */
public const int SERVICE = 23;
/** type class of module (not implemented) */
public const int MODULE = 24;
/** type class of interface method */
public const int INTERFACE_METHOD = 25;
/** type class of interface attribute */
public const int INTERFACE_ATTRIBUTE = 26;
/** type class of unknown type */
public const int UNKNOWN = 27;
/** type class of properties */
public const int PROPERTY = 28;
/** type class of constants */
public const int CONSTANT = 29;
/** type class of constants groups */
public const int CONSTANTS = 30;
/** type class of singletons */
public const int SINGLETON = 31;
}
}
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org 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 version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
namespace uno.Typelib {
using System.Runtime.InteropServices;
/** Binary typelib uik struct. Internally not used anymore.
*/
[ StructLayout(LayoutKind.Sequential) ]
public struct Uik
{
int m_Data1;
short m_Data2;
short m_Data3;
int m_Data4;
int m_Data5;
}
}
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org 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 version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#include "rtl/ustring.h"
#include "uno/dispatcher.h"
#include "uno/environment.h"
#include <stdio.h>
extern "C" {
/* uno_Interface */
void SAL_CALL cli_uno_interface_acquire( uno_Interface *pInterface )
SAL_THROW_EXTERN_C()
{
(*pInterface->acquire)( pInterface );
}
void SAL_CALL cli_uno_interface_release( uno_Interface *pInterface )
SAL_THROW_EXTERN_C()
{
(*pInterface->release)( pInterface );
}
void SAL_CALL cli_uno_interface_dispatch(
uno_Interface *pInterface, const struct _typelib_TypeDescription *pMemberType,
void *pReturn, void *pArgs[], uno_Any **ppException )
SAL_THROW_EXTERN_C()
{
(*pInterface->pDispatcher)( pInterface, pMemberType, pReturn, pArgs, ppException );
}
/* uno_ExtEnvironment */
void SAL_CALL cli_uno_environment_getObjectIdentifier(
uno_ExtEnvironment *pUnoEnv, rtl_uString **ppOId, uno_Interface *pUnoI )
SAL_THROW_EXTERN_C()
{
(*pUnoEnv->getObjectIdentifier)( pUnoEnv, ppOId, pUnoI );
}
void SAL_CALL cli_uno_environment_registerInterface(
uno_ExtEnvironment *pUnoEnv, void **ppInterface, rtl_uString *pOId,
struct _typelib_InterfaceTypeDescription *pTypeDescr )
SAL_THROW_EXTERN_C()
{
(*pUnoEnv->registerInterface)( pUnoEnv, ppInterface, pOId, pTypeDescr );
}
void SAL_CALL cli_uno_environment_getRegisteredInterface(
uno_ExtEnvironment *pUnoEnv, void **ppInterface, rtl_uString *pOId,
struct _typelib_InterfaceTypeDescription *pTypeDescr )
SAL_THROW_EXTERN_C()
{
(*pUnoEnv->getRegisteredInterface)( pUnoEnv, ppInterface, pOId, pTypeDescr );
}
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment