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