update dev300-m58
[ooovba.git] / cli_ure / source / mono_bridge / mono_bridge.h
blobf511190c39e4ec442d59c265eb6c5b2f60ff3159
1 /*************************************************************************
3 * $RCSfile: $
5 * $Revision: $
7 * last change: $Author: $ $Date: $
9 * The Contents of this file are made available subject to the terms of
10 * either of the following licenses
12 * - GNU Lesser General Public License Version 2.1
13 * - Sun Industry Standards Source License Version 1.1
15 * Sun Microsystems Inc., October, 2000
17 * GNU Lesser General Public License Version 2.1
18 * =============================================
19 * Copyright 2000 by Sun Microsystems, Inc.
20 * 901 San Antonio Road, Palo Alto, CA 94303, USA
22 * This library is free software; you can redistribute it and/or
23 * modify it under the terms of the GNU Lesser General Public
24 * License version 2.1, as published by the Free Software Foundation.
26 * This library is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 * Lesser General Public License for more details.
31 * You should have received a copy of the GNU Lesser General Public
32 * License along with this library; if not, write to the Free Software
33 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34 * MA 02111-1307 USA
37 * Sun Industry Standards Source License Version 1.1
38 * =================================================
39 * The contents of this file are subject to the Sun Industry Standards
40 * Source License Version 1.1 (the "License"); You may not use this file
41 * except in compliance with the License. You may obtain a copy of the
42 * License at http://www.openoffice.org/license.html.
44 * Software provided under this License is provided on an "AS IS" basis,
45 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
46 * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
47 * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
48 * See the License for the specific provisions governing your rights and
49 * obligations concerning the Software.
51 * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
53 * Copyright: 2000 by Sun Microsystems, Inc.
55 * All Rights Reserved.
57 * Contributor(s): _______________________________________
60 ************************************************************************/
62 #if ! defined INCLUDED_MONO_BRIDGE_H
63 #define INCLUDED_MONO_BRIDGE_H
65 #include "glib/gtypes.h"
66 #include "osl/interlck.h"
67 #include "rtl/ustring.hxx"
68 #include "typelib/typedescription.hxx"
69 #include "uno/dispatcher.h"
70 #include "uno/mapping.h"
72 extern "C" {
73 #include "mono/metadata/appdomain.h"
74 #include "mono/metadata/debug-helpers.h"
75 #include "mono/metadata/object.h"
76 #include "mono/metadata/threads.h"
79 namespace cssu = com::sun::star::uno;
81 typedef struct _uno_ExtEnvironment uno_ExtEnvironment;
82 typedef struct _uno_Environment uno_Environment;
83 typedef struct _typelib_TypeDescription typelib_TypeDescription;
85 namespace mono_uno
88 MonoObject* runtime_invoke (MonoMethod *method, void *obj, void **params,
89 MonoObject **exc, MonoDomain *domain);
91 //==== holds environments and mappings =========================================
92 struct Bridge;
93 struct Mapping : public uno_Mapping
95 Bridge * m_bridge;
98 //==============================================================================
99 struct Bridge
101 mutable oslInterlockedCount m_ref;
102 MonoObject * m_managedBridge;
104 uno_ExtEnvironment * m_uno_env;
105 uno_Environment * m_mono_env;
107 Mapping m_mono2uno;
108 Mapping m_uno2mono;
109 bool m_registered_mono2uno;
111 MonoMethod * m_mapUnoToManagedMethod;
112 MonoMethod * m_mapManagedToUnoMethod;
114 ~Bridge() SAL_THROW( () );
115 explicit Bridge(
116 uno_Environment * mono_env, uno_ExtEnvironment * uno_env,
117 bool registered_mono2uno );
119 void acquire() const;
120 void release() const;
122 void * map_to_mono(
123 uno_Interface * pUnoI, typelib_TypeDescription * pTD ) const;
125 uno_Interface * map_to_uno(
126 void * pMonoI, typelib_TypeDescription * pTD ) const;
129 struct MonoProxy : public uno_Interface
131 mutable oslInterlockedCount m_ref;
132 guint32 m_managedProxy;
133 uno_ExtEnvironment * m_unoEnv;
134 const cssu::TypeDescription m_unoType;
135 const rtl::OUString m_Oid;
136 MonoMethod * m_managedDispatch;
138 void acquire() const;
139 void release() const;
140 void dispatch(typelib_TypeDescription const * member_td, void * uno_ret,
141 void * uno_args [], uno_Any ** uno_exc);
143 MonoProxy(uno_ExtEnvironment * pUnoEnv, guint32 managedProxy,
144 rtl_uString * pOid, typelib_TypeDescription * pTD);
147 struct BridgeRuntimeError
149 ::rtl::OUString m_message;
151 inline BridgeRuntimeError( ::rtl::OUString const & message )
152 : m_message( message )
158 #endif