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