LibreOffice Module cli_ure (master) 1
cli_proxy.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#ifndef INCLUDED_CLI_URE_SOURCE_UNO_BRIDGE_CLI_PROXY_H
21#define INCLUDED_CLI_URE_SOURCE_UNO_BRIDGE_CLI_PROXY_H
22
23#include "uno/environment.hxx"
24#include "uno/mapping.hxx"
25#include "uno/dispatcher.h"
26#include "cli_bridge.h"
27#include "cli_environment.h"
28
29#using <cli_ure.dll>
30
31namespace srrp = System::Runtime::Remoting::Proxies;
32namespace srrm = System::Runtime::Remoting::Messaging;
33namespace srr = System::Runtime::Remoting;
34namespace sr = System::Reflection;
35namespace sc = System::Collections;
36using namespace uno;
37
38namespace cli_uno
39{
40
41public ref class UnoInterfaceInfo
42{
43public:
44 UnoInterfaceInfo(Bridge const * bridge, uno_Interface* unoI,
45 typelib_InterfaceTypeDescription* td);
48
49 uno_Interface * m_unoI; // wrapped interface
50 System::Type ^ m_type;
51 typelib_InterfaceTypeDescription* m_typeDesc;
52
54};
55
56public ref class UnoInterfaceProxy: public srrp::RealProxy,
57 public srr::IRemotingTypeInfo
58{
61 System::String^ m_sTypeName;
66 sc::ArrayList^ m_listIfaces;
77
78 UnoInterfaceInfo ^ findInfo( ::System::Type ^ type );
79
81 System::String^ m_oid;
82
83#if OSL_DEBUG_LEVEL >= 2
89 rtl_uString * _sInterfaces;
90// /** Count of interfaces. Used in conjunction with _sInterfaces.
91// */
93#endif
94
95public:
96
99 static System::Object^ create(Bridge * bridge,
100 uno_Interface * pUnoI,
101 typelib_InterfaceTypeDescription* pTd,
102 const OUString& oid);
103
105 virtual srrm::IMessage^ Invoke(srrm::IMessage^ msg) override;
106
112 void addUnoInterface(uno_Interface* pUnoI,
113 typelib_InterfaceTypeDescription* pTd);
116
117 inline System::String ^ getOid()
118 { return m_oid; }
119
120 //IRemotingTypeInfo ----------------------------------------------
121 virtual bool CanCastTo(System::Type^ fromType, System::Object^ o);
122
123 virtual property System::String^ TypeName
124 {
125 System::String^ get()
126 {
127 return m_sTypeName;
128 };
129 void set(System::String^ name)
130 {
132 };
133 }
134
135
136private:
138 Bridge * bridge,
139 uno_Interface * pUnoI,
140 typelib_InterfaceTypeDescription* pTD,
141 const OUString& oid );
142
143 static srrm::IMessage^ constructReturnMessage(System::Object^ retVal,
144 array<System::Object^>^ outArgs,
145 typelib_InterfaceMethodTypeDescription* mtd,
146 srrm::IMessage^ msg, System::Object^ exc);
147
148 static System::String^ m_methodNameString =
149 gcnew System::String("__MethodName");
150 static System::String^ m_typeNameString = gcnew System::String("__TypeName");
151 static System::String^ m_ArgsString = gcnew System::String("__Args");
152 static System::String^ m_CallContextString =
153 gcnew System::String("__CallContext");
154 static System::String^ m_system_Object_String =
155 gcnew System::String("System.Object");
156 static System::String^ m_methodSignatureString =
157 gcnew System::String("__MethodSignature");
158 static System::String^ m_Equals_String = gcnew System::String("Equals");
159 static System::String^ m_GetHashCode_String =
160 gcnew System::String("GetHashCode");
161 static System::String^ m_GetType_String = gcnew System::String("GetType");
162 static System::String^ m_ToString_String = gcnew System::String("ToString");
163
164protected:
165 srrm::IMessage^ invokeObject(sc::IDictionary^ properties,
166 srrm::LogicalCallContext^ context,
167 srrm::IMethodCallMessage^ mcm);
168};
169
170
171//Cannot make this __gc because a managed type cannot derive from unmanaged type
172struct CliProxy: public uno_Interface
173{
174 mutable oslInterlockedCount m_ref;
176 const gcroot<System::Object^> m_cliI;
177 gcroot<System::Type^> m_type;
178 const css::uno::TypeDescription m_unoType;
179 const gcroot<System::String^> m_oid;
180 const OUString m_usOid;
181
204 gcroot<array<sr::MethodInfo^>^> m_arMethodInfos;
205
213 gcroot<array<sr::MethodInfo^>^> m_arInterfaceMethodInfos;
214
226 gcroot<array<System::Int32>^> m_arUnoPosToCliPos;
227
233 gcroot<array<System::Int32^>^> m_arInterfaceMethodCount;
234
235 CliProxy( Bridge const* bridge, System::Object^ cliI,
236 typelib_TypeDescription const* pTD,
237 const OUString& usOid);
238 ~CliProxy();
239
240 static uno_Interface* create(Bridge const * bridge,
241 System::Object^ cliI,
242 typelib_TypeDescription const * TD,
243 OUString const & usOid );
244
255 void makeMethodInfos();
256
277 sr::MethodInfo^ getMethodInfo(int nUnoFunctionPos,
278 const OUString & usMethodName,
279 MethodKind mk);
280
281 void SAL_CALL uno_DispatchMethod(
282 struct _uno_Interface * pUnoI,
283 const struct _typelib_TypeDescription * pMemberType,
284 void * pReturn,
285 void * pArgs[],
286 uno_Any ** ppException );
287
288 inline void acquire() const;
289 inline void release() const;
290};
291}
292#endif
293
294/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
UnoInterfaceInfo(Bridge const *bridge, uno_Interface *unoI, typelib_InterfaceTypeDescription *td)
Definition: cli_proxy.cxx:65
Bridge const * m_bridge
Definition: cli_proxy.h:53
uno_Interface * m_unoI
Definition: cli_proxy.h:49
typelib_InterfaceTypeDescription * m_typeDesc
Definition: cli_proxy.h:51
sc::ArrayList m_listAdditionalProxies
The list is filled with additional UnoInterfaceProxy object due to aggregation via bridges.
Definition: cli_proxy.h:75
int m_numUnoIfaces
The number of UNO interfaces this proxy represents.
Definition: cli_proxy.h:70
static System::String m_GetType_String
Definition: cli_proxy.h:161
virtual srrm::IMessage Invoke(srrm::IMessage^ msg) override
RealProxy::Invoke.
Definition: cli_proxy.cxx:398
static System::String m_methodNameString
Definition: cli_proxy.h:148
System::String m_oid
Definition: cli_proxy.h:81
static System::String m_CallContextString
Definition: cli_proxy.h:152
virtual property System::String TypeName
Definition: cli_proxy.h:124
static srrm::IMessage constructReturnMessage(System::Object^ retVal, array< System::Object^>^ outArgs, typelib_InterfaceMethodTypeDescription *mtd, srrm::IMessage^ msg, System::Object^ exc)
If the argument args is NULL then this function is called for an attribute method (either setXXX or g...
Definition: cli_proxy.cxx:586
srrm::IMessage invokeObject(sc::IDictionary^ properties, srrm::LogicalCallContext^ context, srrm::IMethodCallMessage^ mcm)
Definition: cli_proxy.cxx:313
virtual bool CanCastTo(System::Type^ fromType, System::Object^ o)
Definition: cli_proxy.cxx:210
static System::String m_methodSignatureString
Definition: cli_proxy.h:156
rtl_uString * _sInterfaces
The string contains all names of UNO interfaces which are represented by this proxy.
Definition: cli_proxy.h:89
Bridge const * m_bridge
Definition: cli_proxy.h:80
static System::Object create(Bridge *bridge, uno_Interface *pUnoI, typelib_InterfaceTypeDescription *pTd, const OUString &oid)
Creates a proxy and registers it on the dot NET side.
Definition: cli_proxy.cxx:150
static System::String m_GetHashCode_String
Definition: cli_proxy.h:159
static System::String m_typeNameString
Definition: cli_proxy.h:150
System::String m_sTypeName
used for IRemotingTypeInfo.TypeName
Definition: cli_proxy.h:61
void set(System::String^ name)
Definition: cli_proxy.h:129
sc::ArrayList m_listIfaces
The list is filled with UnoInterfaceInfo objects.
Definition: cli_proxy.h:66
void addUnoInterface(uno_Interface *pUnoI, typelib_InterfaceTypeDescription *pTd)
Must be called from within a synchronized section.
Definition: cli_proxy.cxx:164
static System::String m_ToString_String
Definition: cli_proxy.h:162
static System::String m_ArgsString
Definition: cli_proxy.h:151
UnoInterfaceInfo findInfo(::System::Type ^ type)
Definition: cli_proxy.cxx:377
static System::String m_system_Object_String
Definition: cli_proxy.h:154
System::String getOid()
Definition: cli_proxy.h:117
UnoInterfaceProxy(Bridge *bridge, uno_Interface *pUnoI, typelib_InterfaceTypeDescription *pTD, const OUString &oid)
Definition: cli_proxy.cxx:104
static System::String m_Equals_String
Definition: cli_proxy.h:158
const char * name
struct _typelib_TypeDescription typelib_TypeDescription
struct _uno_Any uno_Any
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
An instance of Bridge represents exactly one mapping therefore either m_cli2uno or m_uno2cli is valid...
Definition: cli_bridge.h:58
gcroot< array< sr::MethodInfo^>^> m_arInterfaceMethodInfos
This array is similar to m_arMethodInfos but it contains the MethodInfo objects of the interface (not...
Definition: cli_proxy.h:213
gcroot< System::Type^> m_type
Definition: cli_proxy.h:177
const OUString m_usOid
Definition: cli_proxy.h:180
sr::MethodInfo getMethodInfo(int nUnoFunctionPos, const OUString &usMethodName, MethodKind mk)
Obtains a MethodInfo which can be used to invoke the cli object.
Definition: cli_proxy.cxx:743
void acquire() const
Definition: cli_proxy.cxx:855
const gcroot< System::Object^> m_cliI
Definition: cli_proxy.h:176
void SAL_CALL uno_DispatchMethod(struct _uno_Interface *pUnoI, const struct _typelib_TypeDescription *pMemberType, void *pReturn, void *pArgs[], uno_Any **ppException)
Definition: cli_proxy.cxx:847
const gcroot< System::String^> m_oid
Definition: cli_proxy.h:179
static uno_Interface * create(Bridge const *bridge, System::Object^ cliI, typelib_TypeDescription const *TD, OUString const &usOid)
Definition: cli_proxy.cxx:825
void release() const
Definition: cli_proxy.cxx:872
gcroot< array< sr::MethodInfo^>^> m_arMethodInfos
The array contains MethodInfos of the cli object.
Definition: cli_proxy.h:204
const css::uno::TypeDescription m_unoType
Definition: cli_proxy.h:178
int m_nInheritedInterfaces
Count of inherited interfaces of the cli interface.
Definition: cli_proxy.h:230
void makeMethodInfos()
Prepares an array (m_arMethoInfos) containing MethodInfo object of the interface and all inherited in...
Definition: cli_proxy.cxx:661
const Bridge * m_bridge
Definition: cli_proxy.h:175
gcroot< array< System::Int32 >^> m_arUnoPosToCliPos
Maps the position of the method in the UNO interface to the position of the corresponding MethodInfo ...
Definition: cli_proxy.h:226
gcroot< array< System::Int32^>^> m_arInterfaceMethodCount
Contains the number of methods of each interface.
Definition: cli_proxy.h:233
oslInterlockedCount m_ref
Definition: cli_proxy.h:174
CliProxy(Bridge const *bridge, System::Object^ cliI, typelib_TypeDescription const *pTD, const OUString &usOid)
Definition: cli_proxy.cxx:633