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