1*2123d757SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2123d757SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2123d757SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2123d757SAndrew Rist * distributed with this work for additional information 6*2123d757SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2123d757SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2123d757SAndrew Rist * "License"); you may not use this file except in compliance 9*2123d757SAndrew Rist * with the License. You may obtain a copy of the License at 10*2123d757SAndrew Rist * 11*2123d757SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*2123d757SAndrew Rist * 13*2123d757SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2123d757SAndrew Rist * software distributed under the License is distributed on an 15*2123d757SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2123d757SAndrew Rist * KIND, either express or implied. See the License for the 17*2123d757SAndrew Rist * specific language governing permissions and limitations 18*2123d757SAndrew Rist * under the License. 19*2123d757SAndrew Rist * 20*2123d757SAndrew Rist *************************************************************/ 21*2123d757SAndrew Rist 22*2123d757SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #if ! defined INCLUDED_CLI_BRIDGE_H 25cdf0e10cSrcweir #define INCLUDED_CLI_BRIDGE_H 26cdf0e10cSrcweir #include <vcclr.h> 27cdf0e10cSrcweir #include "osl/interlck.h" 28cdf0e10cSrcweir #include "uno/mapping.h" 29cdf0e10cSrcweir #include "uno/environment.h" 30cdf0e10cSrcweir #include "uno/dispatcher.h" 31cdf0e10cSrcweir #include "cli_base.h" 32cdf0e10cSrcweir #include "cli_environment.h" 33cdf0e10cSrcweir #using <mscorlib.dll> 34cdf0e10cSrcweir //#using <cli_uretypes.dll> 35cdf0e10cSrcweir #using <cli_basetypes.dll> 36cdf0e10cSrcweir #using <system.dll> 37cdf0e10cSrcweir 38cdf0e10cSrcweir namespace sr = System::Reflection; 39cdf0e10cSrcweir 40cdf0e10cSrcweir namespace cli_uno 41cdf0e10cSrcweir { 42cdf0e10cSrcweir 43cdf0e10cSrcweir 44cdf0e10cSrcweir //==== holds environments and mappings ============================================================= 45cdf0e10cSrcweir struct Bridge; 46cdf0e10cSrcweir struct Mapping : public uno_Mapping 47cdf0e10cSrcweir { 48cdf0e10cSrcweir Bridge* m_bridge; 49cdf0e10cSrcweir }; 50cdf0e10cSrcweir 51cdf0e10cSrcweir // The environment will be created in uno_initEnvironment. See also the remarks there 52cdf0e10cSrcweir //Managed cli environment for cli objects an UNO proxies (which are cli 53cdf0e10cSrcweir //objects. The uno_Environment is not used for cli objects. 54cdf0e10cSrcweir __gc struct CliEnvHolder { 55cdf0e10cSrcweir static Cli_environment * g_cli_env = NULL; 56cdf0e10cSrcweir }; 57cdf0e10cSrcweir 58cdf0e10cSrcweir //================================================================================================== 59cdf0e10cSrcweir /** An instance of Bridge represents exactly one mapping therefore either 60cdf0e10cSrcweir m_cli2uno or m_uno2cli is valid. 61cdf0e10cSrcweir */ 62cdf0e10cSrcweir struct Bridge 63cdf0e10cSrcweir { 64cdf0e10cSrcweir mutable oslInterlockedCount m_ref; 65cdf0e10cSrcweir uno_ExtEnvironment * m_uno_env; 66cdf0e10cSrcweir uno_Environment * m_uno_cli_env; 67cdf0e10cSrcweir 68cdf0e10cSrcweir Mapping m_cli2uno; 69cdf0e10cSrcweir Mapping m_uno2cli; 70cdf0e10cSrcweir bool m_registered_cli2uno; 71cdf0e10cSrcweir 72cdf0e10cSrcweir ~Bridge() SAL_THROW( () ); 73cdf0e10cSrcweir Bridge( uno_Environment * java_env, uno_ExtEnvironment * uno_env, bool registered_java2uno ); 74cdf0e10cSrcweir 75cdf0e10cSrcweir void acquire() const; 76cdf0e10cSrcweir void release() const; 77cdf0e10cSrcweir 78cdf0e10cSrcweir void map_to_uno( 79cdf0e10cSrcweir void * uno_data, System::Object* cli_data, 80cdf0e10cSrcweir typelib_TypeDescriptionReference * type, 81cdf0e10cSrcweir bool assign) const; 82cdf0e10cSrcweir 83cdf0e10cSrcweir /** 84cdf0e10cSrcweir @param info 85cdf0e10cSrcweir the type of the converted data. It may be a byref type. 86cdf0e10cSrcweir */ 87cdf0e10cSrcweir void map_to_cli( 88cdf0e10cSrcweir System::Object* *cli_data, void const * uno_data, 89cdf0e10cSrcweir typelib_TypeDescriptionReference * type, System::Type* info /* maybe 0 */, 90cdf0e10cSrcweir bool bDontCreateObj) const; 91cdf0e10cSrcweir 92cdf0e10cSrcweir System::Object* map_uno2cli(uno_Interface * pUnoI, typelib_InterfaceTypeDescription* pTD) const; 93cdf0e10cSrcweir 94cdf0e10cSrcweir System::Object* Bridge::call_uno(uno_Interface * pUnoI, 95cdf0e10cSrcweir typelib_TypeDescription* member_td, 96cdf0e10cSrcweir typelib_TypeDescriptionReference * return_type, 97cdf0e10cSrcweir sal_Int32 nParams, typelib_MethodParameter const * pParams, 98cdf0e10cSrcweir System::Object * args[], System::Type* argTypes[], 99cdf0e10cSrcweir System::Object** pException) const; 100cdf0e10cSrcweir 101cdf0e10cSrcweir 102cdf0e10cSrcweir void call_cli( 103cdf0e10cSrcweir System::Object* cliI, sr::MethodInfo* method, 104cdf0e10cSrcweir typelib_TypeDescriptionReference * return_type, 105cdf0e10cSrcweir typelib_MethodParameter * params, int nParams, 106cdf0e10cSrcweir void * uno_ret, void * uno_args [], uno_Any ** uno_exc ) const; 107cdf0e10cSrcweir 108cdf0e10cSrcweir uno_Interface * map_cli2uno( 109cdf0e10cSrcweir System::Object* cliI, typelib_TypeDescription* pTD) const; 110cdf0e10cSrcweir 111cdf0e10cSrcweir }; 112cdf0e10cSrcweir 113cdf0e10cSrcweir } //namespace cli_uno 114cdf0e10cSrcweir 115cdf0e10cSrcweir 116cdf0e10cSrcweir #endif 117