Kaydet (Commit) 4b56d82c authored tarafından Peter Foley's avatar Peter Foley Kaydeden (comit) David Tardon

convert uno_bridge to new syntax

Change-Id: Iac5e9a860f7ef68104c4cfc19abe686b754190af
üst b5bc7757
......@@ -11,7 +11,7 @@ $(eval $(call gb_Library_Library,cli_uno))
$(eval $(call gb_Library_add_cxxflags,cli_uno,\
-AI $(gb_Helper_OUTDIRLIBDIR) \
-clr:oldSyntax \
-clr \
-wd4339 \
))
......
......@@ -32,78 +32,77 @@ struct _oslMutexImpl
#include "rtl/ustring.hxx"
#include "typelib/typedescription.hxx"
#using <mscorlib.dll>
#using <system.dll>
#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
namespace cli_uno
{
System::Type* loadCliType(System::String * typeName);
System::Type* mapUnoType(typelib_TypeDescription const * pTD);
System::Type* mapUnoType(typelib_TypeDescriptionReference const * pTD);
typelib_TypeDescriptionReference* mapCliType(System::Type* cliType);
rtl::OUString mapCliString(System::String const * data);
System::String* mapUnoString(rtl_uString const * data);
System::String* mapUnoTypeName(rtl_uString const * typeName);
__gc struct Constants
System::Type^ loadCliType(System::String ^ typeName);
System::Type^ mapUnoType(typelib_TypeDescription const * pTD);
System::Type^ mapUnoType(typelib_TypeDescriptionReference const * pTD);
typelib_TypeDescriptionReference* mapCliType(System::Type^ cliType);
rtl::OUString mapCliString(System::String const ^ data);
System::String^ mapUnoString(rtl_uString const * data);
System::String^ mapUnoTypeName(rtl_uString const * typeName);
ref struct Constants
{
static const System::String* sXInterfaceName= new System::String(
S"unoidl.com.sun.star.uno.XInterface");
static const System::String* sObject= new System::String(S"System.Object");
static const System::String* sType= new System::String(S"System.Type");
static const System::String* sUnoidl= new System::String(S"unoidl.");
static const System::String* sVoid= new System::String(S"System.Void");
static const System::String* sAny= new System::String(S"uno.Any");
static const System::String* sArArray= new System::String(S"System.Array[]");
static const System::String* sBoolean= new System::String(S"System.Boolean");
static const System::String* sChar= new System::String(S"System.Char");
static const System::String* sByte= new System::String(S"System.Byte");
static const System::String* sInt16= new System::String(S"System.Int16");
static const System::String* sUInt16= new System::String(S"System.UInt16");
static const System::String* sInt32= new System::String(S"System.Int32");
static const System::String* sUInt32= new System::String(S"System.UInt32");
static const System::String* sInt64= new System::String(S"System.Int64");
static const System::String* sUInt64= new System::String(S"System.UInt64");
static const System::String* sString= new System::String(S"System.String");
static const System::String* sSingle= new System::String(S"System.Single");
static const System::String* sDouble= new System::String(S"System.Double");
static const System::String* sArBoolean= new System::String(S"System.Boolean[]");
static const System::String* sArChar= new System::String(S"System.Char[]");
static const System::String* sArByte= new System::String(S"System.Byte[]");
static const System::String* sArInt16= new System::String(S"System.Int16[]");
static const System::String* sArUInt16= new System::String(S"System.UInt16[]");
static const System::String* sArInt32= new System::String(S"System.Int32[]");
static const System::String* sArUInt32= new System::String(S"System.UInt32[]");
static const System::String* sArInt64= new System::String(S"System.Int64[]");
static const System::String* sArUInt64= new System::String(S"System.UInt64[]");
static const System::String* sArString= new System::String(S"System.String[]");
static const System::String* sArSingle= new System::String(S"System.Single[]");
static const System::String* sArDouble= new System::String(S"System.Double[]");
static const System::String* sArType= new System::String(S"System.Type[]");
static const System::String* sArObject= new System::String(S"System.Object[]");
static const System::String* sBrackets= new System::String(S"[]");
static const System::String* sAttributeSet= new System::String(S"set_");
static const System::String* sAttributeGet= new System::String(S"get_");
static const System::String* usXInterface = S"com.sun.star.uno.XInterface";
static const System::String* usVoid = S"void";
static const System::String* usType = S"type";
static const System::String* usAny = S"any";
static const System::String* usBrackets = S"[]";
static const System::String* usBool = S"boolean";
static const System::String* usByte = S"byte";
static const System::String* usChar = S"char";
static const System::String* usShort = S"short";
static const System::String* usUShort = S"unsigned short";
static const System::String* usLong = S"long";
static const System::String* usULong = S"unsigned long";
static const System::String* usHyper = S"hyper";
static const System::String* usUHyper = S"unsigned hyper";
static const System::String* usString = S"string";
static const System::String* usFloat = S"float";
static const System::String* usDouble = S"double";
static const System::String^ sXInterfaceName= gcnew System::String(
"unoidl.com.sun.star.uno.XInterface");
static const System::String^ sObject= gcnew System::String("System.Object");
static const System::String^ sType= gcnew System::String("System.Type");
static const System::String^ sUnoidl= gcnew System::String("unoidl.");
static const System::String^ sVoid= gcnew System::String("System.Void");
static const System::String^ sAny= gcnew System::String("uno.Any");
static const System::String^ sArArray= gcnew System::String("System.Array[]");
static const System::String^ sBoolean= gcnew System::String("System.Boolean");
static const System::String^ sChar= gcnew System::String("System.Char");
static const System::String^ sByte= gcnew System::String("System.Byte");
static const System::String^ sInt16= gcnew System::String("System.Int16");
static const System::String^ sUInt16= gcnew System::String("System.UInt16");
static const System::String^ sInt32= gcnew System::String("System.Int32");
static const System::String^ sUInt32= gcnew System::String("System.UInt32");
static const System::String^ sInt64= gcnew System::String("System.Int64");
static const System::String^ sUInt64= gcnew System::String("System.UInt64");
static const System::String^ sString= gcnew System::String("System.String");
static const System::String^ sSingle= gcnew System::String("System.Single");
static const System::String^ sDouble= gcnew System::String("System.Double");
static const System::String^ sArBoolean= gcnew System::String("System.Boolean[]");
static const System::String^ sArChar= gcnew System::String("System.Char[]");
static const System::String^ sArByte= gcnew System::String("System.Byte[]");
static const System::String^ sArInt16= gcnew System::String("System.Int16[]");
static const System::String^ sArUInt16= gcnew System::String("System.UInt16[]");
static const System::String^ sArInt32= gcnew System::String("System.Int32[]");
static const System::String^ sArUInt32= gcnew System::String("System.UInt32[]");
static const System::String^ sArInt64= gcnew System::String("System.Int64[]");
static const System::String^ sArUInt64= gcnew System::String("System.UInt64[]");
static const System::String^ sArString= gcnew System::String("System.String[]");
static const System::String^ sArSingle= gcnew System::String("System.Single[]");
static const System::String^ sArDouble= gcnew System::String("System.Double[]");
static const System::String^ sArType= gcnew System::String("System.Type[]");
static const System::String^ sArObject= gcnew System::String("System.Object[]");
static const System::String^ sBrackets= gcnew System::String("[]");
static const System::String^ sAttributeSet= gcnew System::String("set_");
static const System::String^ sAttributeGet= gcnew System::String("get_");
static const System::String^ usXInterface = "com.sun.star.uno.XInterface";
static const System::String^ usVoid = "void";
static const System::String^ usType = "type";
static const System::String^ usAny = "any";
static const System::String^ usBrackets = "[]";
static const System::String^ usBool = "boolean";
static const System::String^ usByte = "byte";
static const System::String^ usChar = "char";
static const System::String^ usShort = "short";
static const System::String^ usUShort = "unsigned short";
static const System::String^ usLong = "long";
static const System::String^ usULong = "unsigned long";
static const System::String^ usHyper = "hyper";
static const System::String^ usUHyper = "unsigned hyper";
static const System::String^ usString = "string";
static const System::String^ usFloat = "float";
static const System::String^ usDouble = "double";
};
struct BridgeRuntimeError
......
......@@ -31,7 +31,6 @@
#include "cli_bridge.h"
#include "cli_proxy.h"
#using <mscorlib.dll>
#if defined(_MSC_VER) && (_MSC_VER < 1400)
#include <_vcclrit.h>
#endif
......@@ -85,7 +84,7 @@ void SAL_CALL Mapping_cli2uno(
if (0 != cliI)
{
System::Object* cliObj= sri::GCHandle::op_Explicit(cliI).Target;
System::Object^ cliObj= sri::GCHandle::FromIntPtr(IntPtr(cliI)).Target;
(*ppOut)= bridge->map_cli2uno(cliObj, (typelib_TypeDescription*) td);
}
}
......@@ -130,16 +129,16 @@ void SAL_CALL Mapping_uno2cli(
if (0 != *ppDNetI)
{
sri::GCHandle::op_Explicit(ppDNetI).Free();
sri::GCHandle::FromIntPtr(IntPtr(ppDNetI)).Free();
}
if (0 != pUnoI)
{
System::Object* cliI= bridge->map_uno2cli(pUnoI, td);
System::Object^ cliI= bridge->map_uno2cli(pUnoI, td);
intptr_t ptr= NULL;
if(cliI)
{
ptr= sri::GCHandle::op_Explicit(sri::GCHandle::Alloc(cliI))
ptr= sri::GCHandle::ToIntPtr(sri::GCHandle::Alloc(cliI))
#ifdef _WIN32
.ToInt32();
#else /* defined(_WIN64) */ .ToInt64();
......@@ -288,7 +287,7 @@ SAL_DLLPUBLIC_EXPORT void SAL_CALL uno_initEnvironment( uno_Environment * uno_cl
//where g_cli_env is accessed.
//When we compile the bridge with .NET 2 then we can again hold g_cli_env as a static gcroot
//member in a unmanaged class, such as Bridge.
CliEnvHolder::g_cli_env = new Cli_environment();
CliEnvHolder::g_cli_env = gcnew Cli_environment();
}
//##################################################################################################
SAL_DLLPUBLIC_EXPORT void SAL_CALL uno_ext_getMapping(
......
......@@ -26,7 +26,6 @@
#include "uno/dispatcher.h"
#include "cli_base.h"
#include "cli_environment.h"
#using <mscorlib.dll>
//#using <cli_uretypes.dll>
#using <cli_basetypes.dll>
#using <system.dll>
......@@ -47,8 +46,8 @@ struct Mapping : public uno_Mapping
// The environment will be created in uno_initEnvironment. See also the remarks there
//Managed cli environment for cli objects an UNO proxies (which are cli
//objects. The uno_Environment is not used for cli objects.
__gc struct CliEnvHolder {
static Cli_environment * g_cli_env = NULL;
ref struct CliEnvHolder {
static Cli_environment ^ g_cli_env = nullptr;
};
//==================================================================================================
......@@ -72,7 +71,7 @@ struct Bridge
void release() const;
void map_to_uno(
void * uno_data, System::Object* cli_data,
void * uno_data, System::Object^ cli_data,
typelib_TypeDescriptionReference * type,
bool assign) const;
......@@ -81,28 +80,28 @@ struct Bridge
the type of the converted data. It may be a byref type.
*/
void map_to_cli(
System::Object* *cli_data, void const * uno_data,
typelib_TypeDescriptionReference * type, System::Type* info /* maybe 0 */,
System::Object^ *cli_data, void const * uno_data,
typelib_TypeDescriptionReference * type, System::Type^ info /* maybe 0 */,
bool bDontCreateObj) const;
System::Object* map_uno2cli(uno_Interface * pUnoI, typelib_InterfaceTypeDescription* pTD) const;
System::Object^ map_uno2cli(uno_Interface * pUnoI, typelib_InterfaceTypeDescription* pTD) const;
System::Object* call_uno(uno_Interface * pUnoI,
System::Object^ call_uno(uno_Interface * pUnoI,
typelib_TypeDescription* member_td,
typelib_TypeDescriptionReference * return_type,
sal_Int32 nParams, typelib_MethodParameter const * pParams,
System::Object * args[], System::Type* argTypes[],
System::Object** pException) const;
array<System::Object^>^ args, array<System::Type^>^ argTypes,
System::Object^* pException) const;
void call_cli(
System::Object* cliI, sr::MethodInfo* method,
System::Object^ cliI, sr::MethodInfo^ method,
typelib_TypeDescriptionReference * return_type,
typelib_MethodParameter * params, int nParams,
void * uno_ret, void * uno_args [], uno_Any ** uno_exc ) const;
uno_Interface * map_cli2uno(
System::Object* cliI, typelib_TypeDescription* pTD) const;
System::Object^ cliI, typelib_TypeDescription* pTD) const;
};
......
......@@ -19,7 +19,6 @@
#include "Cli_environment.h"
#using <mscorlib.dll>
#using <cli_ure.dll>
#using <system.dll>
#include "osl/diagnose.h"
......@@ -35,9 +34,9 @@ using namespace System::Threading;
namespace cli_uno
{
inline System::String* Cli_environment::createKey(System::String* oid, System::Type* t)
inline System::String^ Cli_environment::createKey(System::String^ oid, System::Type^ t)
{
return System::String::Concat(oid, t->get_FullName());
return System::String::Concat(oid, t->FullName);
}
......@@ -55,8 +54,8 @@ Cli_environment::~Cli_environment()
}
System::Object* Cli_environment::registerInterface(
System::Object* obj, System::String* oid)
System::Object^ Cli_environment::registerInterface(
System::Object^ obj, System::String^ oid)
{
#if OSL_DEBUG_LEVEL >= 1
//obj must be a transparent proxy
......@@ -64,27 +63,27 @@ System::Object* Cli_environment::registerInterface(
_numRegisteredObjects ++;
#endif
OSL_ASSERT( ! m_objects->ContainsKey(oid));
m_objects->Add(oid, new WeakReference(obj));
m_objects->Add(oid, gcnew WeakReference(obj));
return obj;
}
System::Object* Cli_environment::registerInterface (
System::Object* obj, System::String* oid, System::Type* type)
System::Object^ Cli_environment::registerInterface (
System::Object^ obj, System::String^ oid, System::Type^ type)
{
#if OSL_DEBUG_LEVEL >= 1
//obj must be a real cli object
OSL_ASSERT( ! RemotingServices::IsTransparentProxy(obj));
_numRegisteredObjects ++;
#endif
System::String* key = createKey(oid, type);
System::String^ key = createKey(oid, type);
//see synchronization in map_uno2cli in cli_data.cxx
OSL_ASSERT( ! m_objects->ContainsKey(key));
m_objects->Add(key, new WeakReference(obj));
m_objects->Add(key, gcnew WeakReference(obj));
return obj;
}
void Cli_environment::revokeInterface(System::String* oid, System::Type* type)
void Cli_environment::revokeInterface(System::String^ oid, System::Type^ type)
{
System::String* key = type != NULL ? createKey(oid, type) : oid;
System::String^ key = type != nullptr ? createKey(oid, type) : oid;
#if OSL_DEBUG_LEVEL >= 1
_numRegisteredObjects --;
#endif
......@@ -103,55 +102,55 @@ void Cli_environment::revokeInterface(System::String* oid, System::Type* type)
m_objects->Remove(key);
}
inline void Cli_environment::revokeInterface(System::String* oid)
inline void Cli_environment::revokeInterface(System::String^ oid)
{
return revokeInterface(oid, NULL);
return revokeInterface(oid, nullptr);
}
System::Object* Cli_environment::getRegisteredInterface(System::String* oid,
System::Type* type)
System::Object^ Cli_environment::getRegisteredInterface(System::String^ oid,
System::Type^ type)
{
//try if it is a UNO interface
System::Object* ret = NULL;
ret = m_objects->get_Item(oid);
System::Object^ ret = nullptr;
ret = m_objects[oid];
if (! ret)
{
//try if if it is a proxy for a cli object
oid = createKey(oid, type);
ret = m_objects->get_Item( oid );
ret = m_objects[ oid ];
}
if (ret != 0)
if (ret != nullptr)
{
System::WeakReference* weakIface =
static_cast< System::WeakReference * >( ret );
System::WeakReference^ weakIface =
static_cast< System::WeakReference ^ >( ret );
ret = weakIface->Target;
}
if (ret == 0)
if (ret == nullptr)
m_objects->Remove( oid );
return ret;
}
System::String* Cli_environment::getObjectIdentifier(System::Object* obj)
System::String^ Cli_environment::getObjectIdentifier(System::Object^ obj)
{
System::String* oId= 0;
RealProxy* aProxy= RemotingServices::GetRealProxy(obj);
System::String^ oId= nullptr;
RealProxy^ aProxy= RemotingServices::GetRealProxy(obj);
if (aProxy)
{
UnoInterfaceProxy* proxyImpl= dynamic_cast<UnoInterfaceProxy*>(aProxy);
UnoInterfaceProxy^ proxyImpl= dynamic_cast<UnoInterfaceProxy^>(aProxy);
if (proxyImpl)
oId= proxyImpl->getOid();
}
if (oId == 0)
if (oId == nullptr)
{
StringBuilder * buf= new StringBuilder(256);
bool bFirst = false;
System::Threading::Monitor::Enter(__typeof(Cli_environment));
StringBuilder ^ buf= gcnew StringBuilder(256);
bool bFirst = new bool(false);
System::Threading::Monitor::Enter(Cli_environment::typeid);
try {
buf->Append(m_IDGen->GetId(obj, & bFirst));
} __finally
buf->Append(m_IDGen->GetId(obj, bFirst));
} finally
{
System::Threading::Monitor::Exit(__typeof(Cli_environment));
System::Threading::Monitor::Exit(Cli_environment::typeid);
}
buf->Append(sOidPart);
......
......@@ -21,7 +21,6 @@
#define INCLUDED_CLI_ENVIRONMENT_H
#include "cli_base.h"
#using <mscorlib.dll>
using namespace System;
using namespace System::Collections;
......@@ -30,12 +29,12 @@ using namespace System::Runtime::Serialization;
namespace cli_uno
{
public __gc class Cli_environment
public ref class Cli_environment
{
static System::String* sOidPart;
static Hashtable* m_objects;
static System::Runtime::Serialization::ObjectIDGenerator* m_IDGen;
inline static System::String* createKey(System::String* oid, System::Type* t);
static System::String^ sOidPart;
static Hashtable^ m_objects;
static System::Runtime::Serialization::ObjectIDGenerator^ m_IDGen;
inline static System::String^ createKey(System::String^ oid, System::Type^ t);
#if OSL_DEBUG_LEVEL >= 1
int _numRegisteredObjects;
......@@ -45,11 +44,11 @@ public:
static Cli_environment()
{
m_objects = Hashtable::Synchronized(new Hashtable());
m_IDGen = new System::Runtime::Serialization::ObjectIDGenerator();
System::Text::StringBuilder* buffer = new System::Text::StringBuilder(256);
m_objects = Hashtable::Synchronized(gcnew Hashtable());
m_IDGen = gcnew System::Runtime::Serialization::ObjectIDGenerator();
System::Text::StringBuilder^ buffer = gcnew System::Text::StringBuilder(256);
Guid gd = Guid::NewGuid();
buffer->Append(S";cli[0];");
buffer->Append(";cli[0];");
buffer->Append(gd.ToString());
sOidPart = buffer->ToString();
}
......@@ -63,21 +62,21 @@ public:
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.
*/
Object* registerInterface(Object* obj, System::String* oid);
Object^ registerInterface(Object^ obj, System::String^ oid);
/**
Registers a CLI object as being mapped by this bridge. The resulting
object represents exactly one UNO interface.
*/
Object* registerInterface(Object* obj, System::String* oid, System::Type* type);
Object^ registerInterface(Object^ obj, System::String^ oid, System::Type^ type);
/**
By revoking an interface it is declared that the respective interface has
not been mapped. The proxy implementations call revoke interface in their
destructors.
*/
inline void revokeInterface(System::String* oid);
inline void revokeInterface(System::String^ oid);
void revokeInterface(System::String* oid, System::Type* type);
void revokeInterface(System::String^ oid, System::Type^ type);
/**
* Retrieves an interface identified by its object id and type from this
* environment.
......@@ -86,7 +85,7 @@ public:
* @param type the type description of the interface to be retrieved
* @see com.sun.star.uno.IEnvironment#getRegisteredInterface
*/
Object* getRegisteredInterface(System::String* oid, System::Type* type);
Object^ getRegisteredInterface(System::String^ oid, System::Type^ type);
/**
* Generates a worldwide unique object identifier (oid) for the given object. It is
......@@ -96,7 +95,7 @@ public:
* @return the generated oid.
* @param object the object for which a Oid should be generated.
*/
static System::String* getObjectIdentifier(Object* obj);
static System::String^ getObjectIdentifier(Object^ obj);
};
......
......@@ -28,7 +28,6 @@
#include "cli_bridge.h"
#include "cli_environment.h"
#using <mscorlib.dll>
#using <cli_ure.dll>
namespace srrp = System::Runtime::Remoting::Proxies;
......@@ -41,30 +40,30 @@ using namespace uno;
namespace cli_uno
{
public __gc class UnoInterfaceInfo
public ref class UnoInterfaceInfo
{
public:
UnoInterfaceInfo(Bridge const * bridge, uno_Interface* unoI,
typelib_InterfaceTypeDescription* td);
~UnoInterfaceInfo();
uno_Interface * m_unoI; // wrapped interface
System::Type * m_type;
System::Type ^ m_type;
typelib_InterfaceTypeDescription* m_typeDesc;
Bridge const* m_bridge;
};
public __gc class UnoInterfaceProxy: public srrp::RealProxy,
public ref class UnoInterfaceProxy: public srrp::RealProxy,
public srr::IRemotingTypeInfo
{
/** used for IRemotingTypeInfo.TypeName
*/
System::String* m_sTypeName;
System::String^ m_sTypeName;
/** The list is filled with UnoInterfaceInfo objects. The list can only
grow and elements are never changed. If an element was added it
must not be changed!
*/
sc::ArrayList* m_listIfaces;
sc::ArrayList^ m_listIfaces;
/** The number of UNO interfaces this proxy represents. It corresponds
to the the number of elements in m_listIfaces.
*/
......@@ -73,13 +72,13 @@ public __gc class UnoInterfaceProxy: public srrp::RealProxy,
to aggregation via bridges. Though the latter is strongly
discouraged, this has to be supported.
*/
sc::ArrayList* m_listAdditionalProxies;
sc::ArrayList^ m_listAdditionalProxies;
int m_nlistAdditionalProxies;
UnoInterfaceInfo * findInfo( ::System::Type * type );
UnoInterfaceInfo ^ findInfo( ::System::Type ^ type );
Bridge const* m_bridge;
System::String* m_oid;
System::String^ m_oid;
#if OSL_DEBUG_LEVEL >= 2
/** The string contains all names of UNO interfaces which are
......@@ -97,13 +96,13 @@ public:
/** Creates a proxy and registers it on the dot NET side.
*/
static System::Object* create(Bridge * bridge,
static System::Object^ create(Bridge * bridge,
uno_Interface * pUnoI,
typelib_InterfaceTypeDescription* pTd,
const rtl::OUString& oid);
/** RealProxy::Invoke */
srrm::IMessage* Invoke(srrm::IMessage* msg);
virtual srrm::IMessage^ Invoke(srrm::IMessage^ msg) override;
/** Must be called from within a synchronized section.
Add only the interface if it is not already contained.
......@@ -116,19 +115,22 @@ public:
/**
*/
inline System::String * getOid()
inline System::String ^ getOid()
{ return m_oid; }
//IRemotingTypeInfo ----------------------------------------------
bool CanCastTo(System::Type* fromType, System::Object* o);
virtual bool CanCastTo(System::Type^ fromType, System::Object^ o);
__property System::String* get_TypeName()
virtual property System::String^ TypeName
{
return m_sTypeName;
}
__property void set_TypeName(System::String* name)
{
m_sTypeName = name;
System::String^ get()
{
return m_sTypeName;
};
void set(System::String^ name)
{
m_sTypeName = name;
};
}
......@@ -139,31 +141,31 @@ private:
typelib_InterfaceTypeDescription* pTD,
const rtl::OUString& oid );
static srrm::IMessage* constructReturnMessage(System::Object* retVal,
System::Object* outArgs[],
static srrm::IMessage^ constructReturnMessage(System::Object^ retVal,
array<System::Object^>^ outArgs,
typelib_InterfaceMethodTypeDescription* mtd,
srrm::IMessage* msg, System::Object* exc);
static System::String* m_methodNameString =
new System::String("__MethodName");
static System::String* m_typeNameString = new System::String("__TypeName");
static System::String* m_ArgsString = new System::String("__Args");
static System::String* m_CallContextString =
new System::String("__CallContext");
static System::String* m_system_Object_String =
new System::String("System.Object");
static System::String* m_methodSignatureString =
new System::String("__MethodSignature");
static System::String* m_Equals_String = new System::String("Equals");
static System::String* m_GetHashCode_String =
new System::String("GetHashCode");
static System::String* m_GetType_String = new System::String("GetType");
static System::String* m_ToString_String = new System::String("ToString");
srrm::IMessage^ msg, System::Object^ exc);
static System::String^ m_methodNameString =
gcnew System::String("__MethodName");
static System::String^ m_typeNameString = gcnew System::String("__TypeName");
static System::String^ m_ArgsString = gcnew System::String("__Args");
static System::String^ m_CallContextString =
gcnew System::String("__CallContext");
static System::String^ m_system_Object_String =
gcnew System::String("System.Object");
static System::String^ m_methodSignatureString =
gcnew System::String("__MethodSignature");
static System::String^ m_Equals_String = gcnew System::String("Equals");
static System::String^ m_GetHashCode_String =
gcnew System::String("GetHashCode");
static System::String^ m_GetType_String = gcnew System::String("GetType");
static System::String^ m_ToString_String = gcnew System::String("ToString");
protected:
srrm::IMessage* invokeObject(sc::IDictionary* properties,
srrm::LogicalCallContext* context,
srrm::IMethodCallMessage* mcm);
srrm::IMessage^ invokeObject(sc::IDictionary^ properties,
srrm::LogicalCallContext^ context,
srrm::IMethodCallMessage^ mcm);
};
......@@ -172,10 +174,10 @@ struct CliProxy: public uno_Interface
{
mutable oslInterlockedCount m_ref;
const Bridge* m_bridge;
const gcroot<System::Object*> m_cliI;
gcroot<System::Type*> m_type;
const gcroot<System::Object^> m_cliI;
gcroot<System::Type^> m_type;
const com::sun::star::uno::TypeDescription m_unoType;
const gcroot<System::String*> m_oid;
const gcroot<System::String^> m_oid;
const rtl::OUString m_usOid;
enum MethodKind {MK_METHOD = 0, MK_SET, MK_GET};
......@@ -200,7 +202,7 @@ struct CliProxy: public uno_Interface
This is becaus, the cli interface does not contain the XInterface
methods.
*/
gcroot<sr::MethodInfo*[]> m_arMethodInfos;
gcroot<array<sr::MethodInfo^>^> m_arMethodInfos;
/** This array is similar to m_arMethodInfos but it contains the MethodInfo
objects of the interface (not the object). When a call is made from uno
......@@ -209,7 +211,7 @@ struct CliProxy: public uno_Interface
array. The name of the actual implemented method may not be the same as
the interface method.
*/
gcroot<sr::MethodInfo*[]> m_arInterfaceMethodInfos;
gcroot<array<sr::MethodInfo^>^> m_arInterfaceMethodInfos;
/** Maps the position of the method in the UNO interface to the position of
the corresponding MethodInfo in m_arMethodInfos. The Uno position must
......@@ -222,22 +224,22 @@ struct CliProxy: public uno_Interface
arUnoPosToCliPos[pos] contains the index for m_arMethodInfos.
*/
gcroot<System::Int32[]> m_arUnoPosToCliPos;
gcroot<array<System::Int32>^> m_arUnoPosToCliPos;
/** Count of inherited interfaces of the cli interface.
*/
int m_nInheritedInterfaces;
/** Contains the number of methods of each interface.
*/
gcroot<System::Int32[]> m_arInterfaceMethodCount;
gcroot<array<System::Int32^>^> m_arInterfaceMethodCount;
CliProxy( Bridge const* bridge, System::Object* cliI,
CliProxy( Bridge const* bridge, System::Object^ cliI,
typelib_TypeDescription const* pTD,
const rtl::OUString& usOid);
~CliProxy();
static uno_Interface* create(Bridge const * bridge,
System::Object* cliI,
System::Object^ cliI,
typelib_TypeDescription const * TD,
rtl::OUString const & usOid );
......@@ -273,7 +275,7 @@ struct CliProxy: public uno_Interface
@param nUnoFunctionPos
Position of the method in the uno interface.
*/
sr::MethodInfo* getMethodInfo(int nUnoFunctionPos,
sr::MethodInfo^ getMethodInfo(int nUnoFunctionPos,
const rtl::OUString & usMethodName,
MethodKind mk);
......
......@@ -38,12 +38,12 @@ union largest
uno_Any a;
};
System::Object* Bridge::call_uno(uno_Interface * pUnoI,
System::Object^ Bridge::call_uno(uno_Interface * pUnoI,
typelib_TypeDescription* member_td,
typelib_TypeDescriptionReference * return_type,
sal_Int32 nParams, typelib_MethodParameter const * pParams,
System::Object * args[], System::Type* argTypes[],
System::Object** ppExc) const
array<System::Object^>^ args, array<System::Type^>^ argTypes,
System::Object^* ppExc) const
{
// return mem
sal_Int32 return_size = sizeof (largest);
......@@ -133,9 +133,10 @@ System::Object* Bridge::call_uno(uno_Interface * pUnoI,
{
try
{
pin_ptr<System::Object^> ptr = &args[nPos];
map_to_cli(
&args[nPos], uno_args[nPos], param.pTypeRef,
argTypes != NULL ? argTypes[nPos] : NULL, false );
ptr, uno_args[nPos], param.pTypeRef,
argTypes != nullptr ? argTypes[nPos] : nullptr, false );
}
catch (...)
{
......@@ -163,9 +164,9 @@ System::Object* Bridge::call_uno(uno_Interface * pUnoI,
// convert uno return value
try
{
System::Object* cli_ret;
System::Object^ cli_ret;
map_to_cli(
&cli_ret, uno_ret, return_type, 0, false);
&cli_ret, uno_ret, return_type, nullptr, false);
uno_type_destructData(uno_ret, return_type, 0);
return cli_ret;
}
......@@ -175,7 +176,7 @@ System::Object* Bridge::call_uno(uno_Interface * pUnoI,
throw;
}
}
return 0; // void return
return nullptr; // void return
}
else // exception occurred
{
......@@ -189,36 +190,37 @@ System::Object* Bridge::call_uno(uno_Interface * pUnoI,
}
}
map_to_cli(ppExc, uno_exc_holder.pData,
uno_exc_holder.pType, NULL, false);
return 0;
uno_exc_holder.pType, nullptr, false);
return nullptr;
}
}
void Bridge::call_cli(
System::Object* cliI,
sr::MethodInfo* method,
System::Object^ cliI,
sr::MethodInfo^ method,
typelib_TypeDescriptionReference * return_type,
typelib_MethodParameter * params, int nParams,
void * uno_ret, void * uno_args [], uno_Any ** uno_exc ) const
{
System::Object *args[]= new System::Object*[nParams];
array<System::Object^>^ args= gcnew array<System::Object^>(nParams);
for (int nPos= 0; nPos < nParams; nPos++)
{
typelib_MethodParameter const & param= params[nPos];
if (param.bIn)
{
map_to_cli( &args[nPos],
uno_args[nPos], param.pTypeRef, 0, false);
pin_ptr<System::Object^> ptr = &args[nPos];
map_to_cli( ptr,
uno_args[nPos], param.pTypeRef, nullptr, false);
}
}
System::Object* retInvoke= NULL;
System::Object^ retInvoke= nullptr;
try
{
retInvoke= method->Invoke(cliI, args);
}
catch (sr::TargetInvocationException* e)
catch (sr::TargetInvocationException^ e)
{
System::Exception* exc= e->get_InnerException();
System::Exception^ exc= e->InnerException;
css::uno::TypeDescription td(mapCliType(exc->GetType()));
// memory for exception
std::auto_ptr< rtl_mem > memExc(rtl_mem::allocate(td.get()->nSize));
......@@ -227,13 +229,13 @@ void Bridge::call_cli(
(*uno_exc)->pData= memExc.release();
return;
}
catch (System::Exception* e)
catch (System::Exception^ e)
{
OUStringBuffer buf( 128 );
buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(
"Unexspected exception during invocation of cli object. "
"Original message is: \n") );
buf.append(mapCliString(e->get_Message()));
buf.append(mapCliString(e->Message));
throw BridgeRuntimeError( buf.makeStringAndClear() );
}
......
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