1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #if ! defined INCLUDED_CLI_BRIDGE_H 29*cdf0e10cSrcweir #define INCLUDED_CLI_BRIDGE_H 30*cdf0e10cSrcweir #include <vcclr.h> 31*cdf0e10cSrcweir #include "osl/interlck.h" 32*cdf0e10cSrcweir #include "uno/mapping.h" 33*cdf0e10cSrcweir #include "uno/environment.h" 34*cdf0e10cSrcweir #include "uno/dispatcher.h" 35*cdf0e10cSrcweir #include "cli_base.h" 36*cdf0e10cSrcweir #include "cli_environment.h" 37*cdf0e10cSrcweir #using <mscorlib.dll> 38*cdf0e10cSrcweir //#using <cli_uretypes.dll> 39*cdf0e10cSrcweir #using <cli_basetypes.dll> 40*cdf0e10cSrcweir #using <system.dll> 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir namespace sr = System::Reflection; 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir namespace cli_uno 45*cdf0e10cSrcweir { 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir //==== holds environments and mappings ============================================================= 49*cdf0e10cSrcweir struct Bridge; 50*cdf0e10cSrcweir struct Mapping : public uno_Mapping 51*cdf0e10cSrcweir { 52*cdf0e10cSrcweir Bridge* m_bridge; 53*cdf0e10cSrcweir }; 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir // The environment will be created in uno_initEnvironment. See also the remarks there 56*cdf0e10cSrcweir //Managed cli environment for cli objects an UNO proxies (which are cli 57*cdf0e10cSrcweir //objects. The uno_Environment is not used for cli objects. 58*cdf0e10cSrcweir __gc struct CliEnvHolder { 59*cdf0e10cSrcweir static Cli_environment * g_cli_env = NULL; 60*cdf0e10cSrcweir }; 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir //================================================================================================== 63*cdf0e10cSrcweir /** An instance of Bridge represents exactly one mapping therefore either 64*cdf0e10cSrcweir m_cli2uno or m_uno2cli is valid. 65*cdf0e10cSrcweir */ 66*cdf0e10cSrcweir struct Bridge 67*cdf0e10cSrcweir { 68*cdf0e10cSrcweir mutable oslInterlockedCount m_ref; 69*cdf0e10cSrcweir uno_ExtEnvironment * m_uno_env; 70*cdf0e10cSrcweir uno_Environment * m_uno_cli_env; 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir Mapping m_cli2uno; 73*cdf0e10cSrcweir Mapping m_uno2cli; 74*cdf0e10cSrcweir bool m_registered_cli2uno; 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir ~Bridge() SAL_THROW( () ); 77*cdf0e10cSrcweir Bridge( uno_Environment * java_env, uno_ExtEnvironment * uno_env, bool registered_java2uno ); 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir void acquire() const; 80*cdf0e10cSrcweir void release() const; 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir void map_to_uno( 83*cdf0e10cSrcweir void * uno_data, System::Object* cli_data, 84*cdf0e10cSrcweir typelib_TypeDescriptionReference * type, 85*cdf0e10cSrcweir bool assign) const; 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir /** 88*cdf0e10cSrcweir @param info 89*cdf0e10cSrcweir the type of the converted data. It may be a byref type. 90*cdf0e10cSrcweir */ 91*cdf0e10cSrcweir void map_to_cli( 92*cdf0e10cSrcweir System::Object* *cli_data, void const * uno_data, 93*cdf0e10cSrcweir typelib_TypeDescriptionReference * type, System::Type* info /* maybe 0 */, 94*cdf0e10cSrcweir bool bDontCreateObj) const; 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir System::Object* map_uno2cli(uno_Interface * pUnoI, typelib_InterfaceTypeDescription* pTD) const; 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir System::Object* Bridge::call_uno(uno_Interface * pUnoI, 99*cdf0e10cSrcweir typelib_TypeDescription* member_td, 100*cdf0e10cSrcweir typelib_TypeDescriptionReference * return_type, 101*cdf0e10cSrcweir sal_Int32 nParams, typelib_MethodParameter const * pParams, 102*cdf0e10cSrcweir System::Object * args[], System::Type* argTypes[], 103*cdf0e10cSrcweir System::Object** pException) const; 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir void call_cli( 107*cdf0e10cSrcweir System::Object* cliI, sr::MethodInfo* method, 108*cdf0e10cSrcweir typelib_TypeDescriptionReference * return_type, 109*cdf0e10cSrcweir typelib_MethodParameter * params, int nParams, 110*cdf0e10cSrcweir void * uno_ret, void * uno_args [], uno_Any ** uno_exc ) const; 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir uno_Interface * map_cli2uno( 113*cdf0e10cSrcweir System::Object* cliI, typelib_TypeDescription* pTD) const; 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir }; 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir } //namespace cli_uno 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir #endif 121