2 +++ cli_ure/source/bootstrap/native_glue.cxx
4 +/*************************************************************************
10 + * last change: $Author: $ $Date: $
12 + * The Contents of this file are made available subject to the terms of
13 + * either of the following licenses
15 + * - GNU Lesser General Public License Version 2.1
16 + * - Sun Industry Standards Source License Version 1.1
18 + * Sun Microsystems Inc., October, 2000
20 + * GNU Lesser General Public License Version 2.1
21 + * =============================================
22 + * Copyright 2000 by Sun Microsystems, Inc.
23 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
25 + * This library is free software; you can redistribute it and/or
26 + * modify it under the terms of the GNU Lesser General Public
27 + * License version 2.1, as published by the Free Software Foundation.
29 + * This library is distributed in the hope that it will be useful,
30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32 + * Lesser General Public License for more details.
34 + * You should have received a copy of the GNU Lesser General Public
35 + * License along with this library; if not, write to the Free Software
36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
40 + * Sun Industry Standards Source License Version 1.1
41 + * =================================================
42 + * The contents of this file are subject to the Sun Industry Standards
43 + * Source License Version 1.1 (the "License"); You may not use this file
44 + * except in compliance with the License. You may obtain a copy of the
45 + * License at http://www.openoffice.org/license.html.
47 + * Software provided under this License is provided on an "AS IS" basis,
48 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
49 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
50 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
51 + * See the License for the specific provisions governing your rights and
52 + * obligations concerning the Software.
54 + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
56 + * Copyright: 2000 by Sun Microsystems, Inc.
58 + * All Rights Reserved.
60 + * Contributor(s): _______________________________________
63 + ************************************************************************/
65 +#ifndef _RTL_USTRING_HXX_
66 +#include "rtl/ustring.hxx"
68 +#ifndef _RTL_BOOTSTRAP_HXX_
69 +#include "rtl/bootstrap.hxx"
71 +#ifndef _CPPUHELPER_BOOTSTRAP_HXX_
72 +#include "cppuhelper/bootstrap.hxx"
74 +#ifndef _UNO_MAPPING_HXX_
75 +#include "uno/mapping.hxx"
78 +#include "mono/metadata/object.h"
81 +#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
83 +using namespace com::sun::star::uno;
85 +static void * to_cli( Reference< XInterface > const & context )
87 + Mapping mapping( OUSTR( CPPU_CURRENT_LANGUAGE_BINDING_NAME ), OUSTR( UNO_LB_CLI ) );
88 + OSL_ASSERT( mapping.is() );
89 + if (! mapping.is() )
91 + // FIXME do something
95 + return (void *)mono_gchandle_new( (MonoObject *)mapping.mapInterface( context.get(), ::getCppuType( &context ) ), sal_False );
100 +void SAL_CALL native_bootstrap_set( const sal_Unicode* pName, sal_Int32 nNameLength,
101 + const sal_Unicode* pValue, sal_Int32 nValueLength )
102 + SAL_THROW_EXTERN_C()
104 + ::rtl::OUString const name( pName, nNameLength );
105 + ::rtl::OUString const value( pValue, nValueLength );
107 + ::rtl::Bootstrap::set( name, value );
110 +void * SAL_CALL native_defaultBootstrap_InitialComponentContext()
111 + SAL_THROW_EXTERN_C()
114 + Reference< XComponentContext > xContext = ::cppu::defaultBootstrap_InitialComponentContext();
116 + return to_cli( xContext );
117 + } catch (const Exception &ex) {
118 + fprintf( stderr, "Exception bootstrapping '%s'\n",
119 + (const sal_Char *) rtl::OUStringToOString( ex.Message, RTL_TEXTENCODING_UTF8 ) );
124 +void * SAL_CALL native_defaultBootstrap_InitialComponentContext_iniFile( const sal_Unicode *pIniFile, sal_Int32 nNameLength )
125 + SAL_THROW_EXTERN_C()
127 + ::rtl::OUString sFileName( pIniFile, nNameLength );
130 + Reference< XComponentContext > xContext = ::cppu::defaultBootstrap_InitialComponentContext( sFileName );
131 + if (!xContext.is())
132 + fprintf( stderr, "Bootstrap context is in fact NULL\n" );
134 + return to_cli( xContext );
135 + } catch (const Exception &ex) {
136 + rtl::OString aIni = rtl::OUStringToOString( sFileName, RTL_TEXTENCODING_UTF8 );
137 + fprintf( stderr, "Exception bootstrapping from ini '%s' (%d) '%s'\n", (const sal_Char *) aIni, nNameLength,
138 + (const sal_Char *) rtl::OUStringToOString( ex.Message, RTL_TEXTENCODING_UTF8 ) );
143 +void * SAL_CALL native_bootstrap()
144 + SAL_THROW_EXTERN_C()
146 + Reference< XComponentContext > xContext = ::cppu::bootstrap();
148 + return to_cli( xContext );