summaryrefslogtreecommitdiff
path: root/cli_ure
diff options
context:
space:
mode:
authorDaniel Boelzle <dbo@openoffice.org>2003-03-28 09:17:51 +0000
committerDaniel Boelzle <dbo@openoffice.org>2003-03-28 09:17:51 +0000
commit4c937bbdbbfd954936fdc92c4b35d90c2233719e (patch)
treeab66640c46b05347dbcb1ab8d6597267235526f1 /cli_ure
parentdfdc52e7f56a9d48aaca38cd1e5396af1a03b949 (diff)
#107130# new
Diffstat (limited to 'cli_ure')
-rw-r--r--cli_ure/prj/build.lst7
-rw-r--r--cli_ure/prj/d.lst5
-rw-r--r--cli_ure/source/climaker/climaker_app.cxx526
-rw-r--r--cli_ure/source/climaker/climaker_emit.cxx1432
-rw-r--r--cli_ure/source/climaker/climaker_share.h168
-rw-r--r--cli_ure/source/climaker/makefile.mk122
-rw-r--r--cli_ure/source/native/makefile.mk112
-rw-r--r--cli_ure/source/native/msvc.map7
-rw-r--r--cli_ure/source/native/native_bootstrap.cxx148
-rw-r--r--cli_ure/source/native/native_share.h137
-rw-r--r--cli_ure/source/ure/makefile.mk101
-rw-r--r--cli_ure/source/ure/uno/util/DisposeGuard.cs101
-rw-r--r--cli_ure/source/ure/uno/util/WeakAdapter.cs152
-rw-r--r--cli_ure/source/ure/uno/util/WeakBase.cs212
-rw-r--r--cli_ure/source/ure/uno/util/WeakComponentBase.cs143
-rw-r--r--cli_ure/unotypes/makefile.mk95
-rw-r--r--cli_ure/util/makefile.pmk70
-rw-r--r--cli_ure/util/target.pmk87
18 files changed, 3625 insertions, 0 deletions
diff --git a/cli_ure/prj/build.lst b/cli_ure/prj/build.lst
new file mode 100644
index 000000000000..cace8d0612d6
--- /dev/null
+++ b/cli_ure/prj/build.lst
@@ -0,0 +1,7 @@
+ure cli_ure : cppuhelper cppu sal codemaker offapi udkapi NULL
+ure cli_ure usr1 - all tt_mkout NULL
+ure cli_ure\source\climaker nmake - all ure_source_climaker NULL
+ure cli_ure\unotypes nmake - all ure_unotypes ure_source_climaker NULL
+ure cli_ure\source\ure nmake - all ure_source_ure ure_unotypes NULL
+ure cli_ure\source\native nmake - all ure_source_native ure_source_ure ure_unotypes NULL
+#ure cli_ure\util nmake - all ure_util ure_source_ure ure_source_native NULL
diff --git a/cli_ure/prj/d.lst b/cli_ure/prj/d.lst
new file mode 100644
index 000000000000..09c6a1e86cc3
--- /dev/null
+++ b/cli_ure/prj/d.lst
@@ -0,0 +1,5 @@
+..\%__SRC%\bin\climaker.exe %_DEST%\bin%_EXT%\climaker.exe
+..\%__SRC%\bin\climaker.pdb %_DEST%\bin%_EXT%\climaker.pdb
+
+..\%__SRC%\bin\cli_* %_DEST%\bin%_EXT%\cli_*
+..\%__SRC%\bin\cppuhelper* %_DEST%\bin%_EXT%\cppuhelper*
diff --git a/cli_ure/source/climaker/climaker_app.cxx b/cli_ure/source/climaker/climaker_app.cxx
new file mode 100644
index 000000000000..aa5aea2e9e87
--- /dev/null
+++ b/cli_ure/source/climaker/climaker_app.cxx
@@ -0,0 +1,526 @@
+/*************************************************************************
+ *
+ * $RCSfile: climaker_app.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: dbo $ $Date: 2003-03-28 10:17:37 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+#include <vector>
+#include <memory>
+
+#include "climaker_share.h"
+
+#include "osl/process.h"
+#include "osl/file.hxx"
+#include "cppuhelper/shlib.hxx"
+#include "cppuhelper/bootstrap.hxx"
+#include "com/sun/star/lang/XInitialization.hpp"
+#include "com/sun/star/lang/XSingleComponentFactory.hpp"
+#include "com/sun/star/lang/XComponent.hpp"
+#include "com/sun/star/container/XSet.hpp"
+#include "com/sun/star/reflection/XTypeDescriptionEnumerationAccess.hpp"
+
+
+using namespace ::std;
+using namespace ::System::Reflection;
+
+using namespace ::rtl;
+using namespace ::osl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+namespace climaker
+{
+
+bool g_verbose = false;
+
+//--------------------------------------------------------------------------------------------------
+static bool read_option(
+ sal_Unicode copt, OUString const & opt, sal_uInt32 * pIndex )
+{
+ if (osl_getCommandArgCount() <= *pIndex)
+ return false;
+
+ OUString arg;
+ osl_getCommandArg( *pIndex, &arg.pData );
+ sal_Int32 len = arg.getLength();
+
+ if (len < 2 || '-' != arg[ 0 ])
+ return false;
+
+ if (2 == len && copt == arg[ 1 ])
+ {
+ ++(*pIndex);
+ return true;
+ }
+ if ('-' == arg[ 1 ] && 0 == rtl_ustr_compare( arg.pData->buffer + 2, opt.pData->buffer ))
+ {
+ ++(*pIndex);
+ return true;
+ }
+ return false;
+}
+
+//--------------------------------------------------------------------------------------------------
+static bool read_argument(
+ OUString * pValue, sal_Unicode copt, OUString const & opt, sal_uInt32 * pIndex )
+{
+ if (read_option( copt, opt, pIndex ))
+ {
+ if (*pIndex < osl_getCommandArgCount())
+ {
+ osl_getCommandArg( *pIndex, &pValue->pData );
+ ++(*pIndex);
+ return true;
+ }
+ --(*pIndex);
+ }
+ return false;
+}
+
+//--------------------------------------------------------------------------------------------------
+static OUString const & path_get_working_dir()
+{
+ static OUString s_workingDir;
+ if (! s_workingDir.getLength())
+ osl_getProcessWorkingDir( &s_workingDir.pData );
+ return s_workingDir;
+}
+
+//--------------------------------------------------------------------------------------------------
+static OUString path_make_absolute_file_url( OUString const & path )
+{
+ OUString file_url;
+ oslFileError rc = osl_getFileURLFromSystemPath( path.pData, &file_url.pData );
+ if (osl_File_E_None == rc)
+ {
+ OUString abs;
+ rc = osl_getAbsoluteFileURL( path_get_working_dir().pData, file_url.pData, &abs.pData );
+ if (osl_File_E_None == rc)
+ {
+ return abs;
+ }
+ else
+ {
+ throw RuntimeException(
+ OUSTR("cannot make absolute: ") + file_url,
+ Reference< XInterface >() );
+ }
+ }
+ else
+ {
+ throw RuntimeException(
+ OUSTR("cannot get file url from system path: ") + path,
+ Reference< XInterface >() );
+ }
+}
+
+//--------------------------------------------------------------------------------------------------
+Reference< registry::XSimpleRegistry > open_registries(
+ vector< OUString > const & registries,
+ Reference< XComponentContext > xContext )
+{
+ if (registries.empty())
+ {
+ throw RuntimeException(
+ OUSTR("no registries given!"),
+ Reference< XInterface >() );
+ }
+
+ Reference< registry::XSimpleRegistry > xSimReg;
+ for ( size_t nPos = registries.size(); nPos--; )
+ {
+ Reference< registry::XSimpleRegistry > xReg(
+ xContext->getServiceManager()->createInstanceWithContext(
+ OUSTR("com.sun.star.registry.SimpleRegistry"), xContext ),
+ UNO_QUERY_THROW );
+ xReg->open( registries[ nPos ], sal_True, sal_False );
+ if (! xReg->isValid())
+ {
+ throw RuntimeException(
+ OUSTR("invalid registry: ") + registries[ nPos ],
+ Reference< XInterface >() );
+ }
+
+ if (xSimReg.is()) // nest?
+ {
+ Reference< registry::XSimpleRegistry > xNested(
+ xContext->getServiceManager()->createInstanceWithContext(
+ OUSTR("com.sun.star.registry.NestedRegistry"), xContext ),
+ UNO_QUERY_THROW );
+ Reference< lang::XInitialization > xInit( xNested, UNO_QUERY_THROW );
+ Sequence< Any > args( 2 );
+ args[ 0 ] <<= xReg;
+ args[ 1 ] <<= xSimReg;
+ xInit->initialize( args );
+ xSimReg = xNested;
+ }
+ else
+ {
+ xSimReg = xReg;
+ }
+ }
+
+ return xSimReg;
+}
+
+//--------------------------------------------------------------------------------------------------
+static char const s_usingText [] =
+"\n"
+"using: climaker <switches> [registry-file-1 registry-file-2 ...]\n\n"
+"switches:\n"
+" -O <output-file> output assembly (default is unotypes.dll)\n"
+" -T <type1[;type2;...]> types to be generated (if none is given,\n"
+" then all types\n"
+" of given registries are created\n"
+" -X <extra-rdb> extra rdb to saturate referenced types in given\n"
+" registry-file(s)\n"
+" these types will not be generated into\n"
+" output assembly\n"
+" -r, --reference <assembly> reference meta-data from assembly\n"
+" --version <version> sets assembly version\n"
+" --product <name> sets assembly product name\n"
+" --description <text> sets assembly description text\n"
+" -v, --verbose verbose output to stdout\n"
+" -h, --help this message\n\n"
+"example: climaker -O my_types.dll -r udkapi.dll -X udkapi.rdb my_types.rdb\n"
+"\n";
+
+}
+
+using namespace ::climaker;
+
+//##################################################################################################
+extern "C" int SAL_CALL main( int argc, char const * argv [] )
+{
+ sal_uInt32 nCount = osl_getCommandArgCount();
+ if (0 == nCount)
+ {
+ printf( s_usingText );
+ return 0;
+ }
+
+ int ret = 0;
+ Reference< XComponentContext > xContext;
+
+ try
+ {
+ OUString str_help = OUSTR("help");
+ OUString str_verbose = OUSTR("verbose");
+ OUString str_reference = OUSTR("reference");
+ OUString str_version = OUSTR("version");
+ OUString str_product = OUSTR("product");
+ OUString str_description = OUSTR("description");
+ OUString str_empty;
+
+ OUString output;
+ vector< OUString > mandatory_registries;
+ vector< OUString > extra_registries;
+ vector< OUString > extra_assemblies;
+ vector< OUString > explicit_types;
+ OUString version, product, description;
+
+ OUString cmd_arg;
+ for ( sal_uInt32 nPos = 0; nPos < nCount; )
+ {
+ // options
+ if (read_option( 'h', str_help, &nPos ))
+ {
+ printf( s_usingText );
+ return 0;
+ }
+ else if (read_option( 'v', str_verbose, &nPos ))
+ {
+ g_verbose = true;
+ }
+ else if (read_argument( &cmd_arg, 'T', str_empty, &nPos ))
+ {
+ sal_Int32 index = 0;
+ do
+ {
+ explicit_types.push_back( cmd_arg.getToken( 0, ';', index ) );
+ }
+ while (index >= 0);
+ }
+ else if (read_argument( &cmd_arg, 'X', str_empty, &nPos ))
+ {
+ extra_registries.push_back( path_make_absolute_file_url( cmd_arg ) );
+ }
+ else if (read_argument( &cmd_arg, 'r', str_reference, &nPos ))
+ {
+ extra_assemblies.push_back( path_make_absolute_file_url( cmd_arg ) );
+ }
+ else if (!read_argument( &version, '\0', str_version, &nPos ) &&
+ !read_argument( &product, '\0', str_product, &nPos ) &&
+ !read_argument( &description, '\0', str_description, &nPos ) &&
+ !read_argument( &output, 'O', str_empty, &nPos ))
+ {
+ OSL_VERIFY( osl_Process_E_None == osl_getCommandArg( nPos, &cmd_arg.pData ) );
+ ++nPos;
+ if (cmd_arg.getLength() && '-' != cmd_arg[ 0 ]) // no option
+ {
+ mandatory_registries.push_back( path_make_absolute_file_url( cmd_arg ) );
+ }
+ else
+ {
+ throw RuntimeException(
+ OUSTR("unknown option ") + cmd_arg,
+ Reference< XInterface >() );
+ }
+ }
+ }
+
+ // bootstrap uno
+ xContext = ::cppu::bootstrap_InitialComponentContext(
+ Reference< registry::XSimpleRegistry >() );
+ Reference< container::XHierarchicalNameAccess > xTDmgr(
+ xContext->getValueByName(
+ OUSTR("/singletons/com.sun.star.reflection.theTypeDescriptionManager") ),
+ UNO_QUERY_THROW );
+
+ // get rdb tdprovider factory
+ Reference< lang::XSingleComponentFactory > xFac(
+ ::cppu::loadSharedLibComponentFactory(
+ OUSTR("rdbtdp"), OUString(),
+ OUSTR("com.sun.star.comp.stoc.RegistryTypeDescriptionProvider"),
+ Reference< lang::XMultiServiceFactory >(
+ xContext->getServiceManager(), UNO_QUERY ),
+ Reference< registry::XRegistryKey >() ), UNO_QUERY_THROW );
+ // create registry td provider
+ Any arg( makeAny( open_registries( mandatory_registries, xContext ) ) );
+ Reference< XInterface > xTD_provider(
+ xFac->createInstanceWithArgumentsAndContext(
+ Sequence< Any >( &arg, 1 ), xContext ) );
+ // insert provider to tdmgr
+ Reference< container::XSet > xSet( xTDmgr, UNO_QUERY_THROW );
+ Any provider( makeAny( xTD_provider ) );
+ xSet->insert( provider );
+ OSL_ASSERT( xSet->has( provider ) );
+ if (! extra_registries.empty())
+ {
+ arg = makeAny( open_registries( extra_registries, xContext ) );
+ provider = makeAny(
+ xFac->createInstanceWithArgumentsAndContext(
+ Sequence< Any >( &arg, 1 ), xContext ) );
+ xSet->insert( provider );
+ OSL_ASSERT( xSet->has( provider ) );
+ }
+
+ if (0 == output.getLength()) // no output file specified
+ {
+ // if only one rdb has been given, then take rdb name
+ if (1 == mandatory_registries.size())
+ {
+ output = mandatory_registries[ 0 ];
+ output = output.copy( output.lastIndexOf( '/' ) +1 );
+ sal_Int32 dot = output.lastIndexOf( '.' );
+ if (dot > 0)
+ output = output.copy( 0, dot );
+ }
+ else
+ {
+ output = OUSTR("unotypes");
+ }
+ }
+ output = path_make_absolute_file_url( output );
+ sal_Int32 slash = output.lastIndexOf( '/' );
+ OUString sys_output_dir;
+ if (FileBase::E_None != FileBase::getSystemPathFromFileURL(
+ output.copy( 0, slash ), sys_output_dir ))
+ {
+ throw RuntimeException(
+ OUSTR("cannot get system path from file url ") + output.copy( 0, slash ),
+ Reference< XInterface >() );
+ }
+ OUString filename( output.copy( slash +1 ) );
+ sal_Int32 dot = filename.lastIndexOf( '.' );
+ OUString name( filename );
+ if (dot < 0) // has no extension
+ filename += OUSTR(".dll");
+ else
+ name = name.copy( 0, dot );
+ ::System::String * output_dir = ustring_to_String( sys_output_dir );
+ ::System::String * output_file = ustring_to_String( filename );
+
+ // setup assembly info: xxx todo set more? e.g. avoid strong versioning
+ AssemblyName * assembly_name = new AssemblyName();
+ assembly_name->set_CodeBase( output_dir );
+ assembly_name->set_Name( name );
+ if (0 != version.getLength())
+ {
+ assembly_name->set_Version( new ::System::Version( ustring_to_String( version ) ) );
+ }
+
+ // app domain
+ ::System::AppDomain * current_appdomain = ::System::AppDomain::get_CurrentDomain();
+ // target assembly
+ Emit::AssemblyBuilder * assembly_builder =
+ current_appdomain->DefineDynamicAssembly(
+ assembly_name, Emit::AssemblyBuilderAccess::Save, output_dir );
+ if (0 != product.getLength())
+ {
+ ::System::Type * params __gc [] = new ::System::Type * __gc [ 1 ];
+ ::System::Object * args __gc [] = new ::System::Object * __gc [ 1 ];
+ params[ 0 ] = __typeof (::System::String);
+ args[ 0 ] = ustring_to_String( product );
+ assembly_builder->SetCustomAttribute(
+ new Emit::CustomAttributeBuilder(
+ __typeof (AssemblyProductAttribute) ->GetConstructor( params ), args ) );
+ }
+ if (0 != description.getLength())
+ {
+ ::System::Type * params __gc [] = new ::System::Type * __gc [ 1 ];
+ ::System::Object * args __gc [] = new ::System::Object * __gc [ 1 ];
+ params[ 0 ] = __typeof (::System::String);
+ args[ 0 ] = ustring_to_String( description );
+ assembly_builder->SetCustomAttribute(
+ new Emit::CustomAttributeBuilder(
+ __typeof (AssemblyDescriptionAttribute) ->GetConstructor( params ), args ) );
+ }
+
+ // load extra assemblies
+ Assembly * assemblies __gc [] = new Assembly * __gc [ extra_assemblies.size() ];
+ for ( size_t pos = 0; pos < extra_assemblies.size(); ++pos )
+ {
+ assemblies[ pos ] = Assembly::LoadFrom( ustring_to_String( extra_assemblies[ pos ] ) );
+ }
+
+ // type emitter
+ TypeEmitter * type_emitter =
+ new TypeEmitter( assembly_builder->DefineDynamicModule( output_file ), assemblies );
+ // add handler resolving assembly's types
+ ::System::ResolveEventHandler * type_resolver =
+ new ::System::ResolveEventHandler( type_emitter, &TypeEmitter::type_resolve );
+ current_appdomain->add_TypeResolve( type_resolver );
+
+ // and emit types to it
+ if (explicit_types.empty())
+ {
+ Reference< reflection::XTypeDescriptionEnumeration > xTD_enum(
+ Reference< reflection::XTypeDescriptionEnumerationAccess >(
+ xTD_provider, UNO_QUERY_THROW )->createTypeDescriptionEnumeration(
+ OUString() /* all IDL modules */,
+ Sequence< TypeClass >() /* all classes of types */,
+ reflection::TypeDescriptionSearchDepth_INFINITE ) );
+ while (xTD_enum->hasMoreElements())
+ {
+ type_emitter->get_type( xTD_enum->nextTypeDescription() );
+ }
+ }
+ else
+ {
+ Reference< container::XHierarchicalNameAccess > xHNA(
+ xTD_provider, UNO_QUERY_THROW );
+ for ( size_t nPos = explicit_types.size(); nPos--; )
+ {
+ type_emitter->get_type(
+ Reference< reflection::XTypeDescription >(
+ xHNA->getByHierarchicalName( explicit_types[ nPos ] ),
+ UNO_QUERY_THROW ) );
+ }
+ }
+ type_emitter->Dispose();
+
+ if (g_verbose)
+ {
+ ::System::Console::Write(
+ S"> saving assembly {0}{1}{2}...",
+ output_dir,
+ new ::System::String(
+ ::System::IO::Path::DirectorySeparatorChar, 1 ),
+ output_file );
+ }
+ assembly_builder->Save( output_file );
+ if (g_verbose)
+ {
+ ::System::Console::WriteLine( S"ok." );
+ }
+ current_appdomain->remove_TypeResolve( type_resolver );
+ }
+ catch (Exception & exc)
+ {
+ OString msg( OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) );
+ fprintf( stderr, "\n> error: %s\n> dying abnormally...\n", msg.getStr() );
+ ret = 1;
+ }
+ catch (::System::Exception * exc)
+ {
+ OString msg(
+ OUStringToOString( String_to_ustring( exc->ToString() ), RTL_TEXTENCODING_ASCII_US ) );
+ fprintf(
+ stderr, "\n> error: .NET exception occured: %s\n> dying abnormally...", msg.getStr() );
+ ret = 1;
+ }
+
+ try
+ {
+ Reference< lang::XComponent > xComp( xContext, UNO_QUERY );
+ if (xComp.is())
+ xComp->dispose();
+ }
+ catch (Exception & exc)
+ {
+ OString msg( OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) );
+ fprintf(
+ stderr, "\n> error disposing component context: %s\n> dying abnormally...\n",
+ msg.getStr() );
+ ret = 1;
+ }
+
+ return ret;
+}
diff --git a/cli_ure/source/climaker/climaker_emit.cxx b/cli_ure/source/climaker/climaker_emit.cxx
new file mode 100644
index 000000000000..984bfbd5e8dd
--- /dev/null
+++ b/cli_ure/source/climaker/climaker_emit.cxx
@@ -0,0 +1,1432 @@
+/*************************************************************************
+ *
+ * $RCSfile: climaker_emit.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: dbo $ $Date: 2003-03-28 10:17:37 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "climaker_share.h"
+
+#include "rtl/string.hxx"
+#include "rtl/ustrbuf.hxx"
+#include "com/sun/star/reflection/XIndirectTypeDescription.hpp"
+#include "com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp"
+#include "com/sun/star/reflection/XInterfaceAttributeTypeDescription.hpp"
+
+
+using namespace ::System::Reflection;
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+namespace climaker
+{
+
+//------------------------------------------------------------------------------
+static inline ::System::String * to_cts_name(
+ OUString const & uno_name )
+{
+ OUStringBuffer buf( 7 + uno_name.getLength() );
+ buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("unoidl.") );
+ buf.append( uno_name );
+ return ustring_to_String( buf.makeStringAndClear() );
+}
+
+//------------------------------------------------------------------------------
+static inline ::System::Object * to_cli_constant( Any const & value )
+{
+ switch (value.getValueTypeClass())
+ {
+ case TypeClass_CHAR:
+ return __box
+ ((::System::Char) *reinterpret_cast< sal_Unicode const * >( value.getValue() ));
+ case TypeClass_BOOLEAN:
+ return __box
+ ((::System::Boolean)
+ sal_False != *reinterpret_cast< sal_Bool const * >( value.getValue() ));
+ case TypeClass_BYTE:
+ return __box
+ ((::System::Byte) *reinterpret_cast< sal_Int8 const * >( value.getValue() ));
+ case TypeClass_SHORT:
+ return __box
+ ((::System::Int16) *reinterpret_cast< sal_Int16 const * >( value.getValue() ));
+ case TypeClass_UNSIGNED_SHORT:
+ return __box
+ ((::System::UInt16) *reinterpret_cast< sal_uInt16 const * >( value.getValue() ));
+ case TypeClass_LONG:
+ return __box
+ ((::System::Int32) *reinterpret_cast< sal_Int32 const * >( value.getValue() ));
+ case TypeClass_UNSIGNED_LONG:
+ return __box
+ ((::System::UInt32) *reinterpret_cast< sal_uInt32 const * >( value.getValue() ));
+ case TypeClass_HYPER:
+ return __box
+ ((::System::Int64) *reinterpret_cast< sal_Int64 const * >( value.getValue() ));
+ case TypeClass_UNSIGNED_HYPER:
+ return __box
+ ((::System::UInt64) *reinterpret_cast< sal_uInt64 const * >( value.getValue() ));
+ case TypeClass_FLOAT:
+ return __box
+ ((::System::Single) *reinterpret_cast< float const * >( value.getValue() ));
+ case TypeClass_DOUBLE:
+ return __box
+ ((::System::Double) *reinterpret_cast< double const * >( value.getValue() ));
+ default:
+ throw RuntimeException(
+ OUSTR("unexpected constant type ") + value.getValueType().getTypeName(),
+ Reference< XInterface >() );
+ }
+}
+
+//------------------------------------------------------------------------------
+static inline void emit_ldarg( Emit::ILGenerator * code, ::System::Int32 index )
+{
+ switch (index)
+ {
+ case 0:
+ code->Emit( Emit::OpCodes::Ldarg_0 );
+ break;
+ case 1:
+ code->Emit( Emit::OpCodes::Ldarg_1 );
+ break;
+ case 2:
+ code->Emit( Emit::OpCodes::Ldarg_2 );
+ break;
+ case 3:
+ code->Emit( Emit::OpCodes::Ldarg_3 );
+ break;
+ default:
+ if (index < 0x100)
+ code->Emit( Emit::OpCodes::Ldarg_S, (::System::Byte) index );
+ else if (index < 0x8000)
+ code->Emit( Emit::OpCodes::Ldarg_S, (::System::Int16) index );
+ else
+ code->Emit( Emit::OpCodes::Ldarg, index );
+ break;
+ }
+}
+
+//______________________________________________________________________________
+Assembly * TypeEmitter::type_resolve(
+ ::System::Object * sender, ::System::ResolveEventArgs * args )
+{
+ ::System::String * cts_name = args->get_Name();
+ ::System::Type * ret_type = m_module_builder->GetType( cts_name, false );
+ if (0 == ret_type)
+ {
+ iface_entry * entry =
+ dynamic_cast< iface_entry * >( m_incomplete_ifaces->get_Item( cts_name ) );
+ if (0 != entry)
+ ret_type = entry->m_type_builder;
+ }
+ if (0 == ret_type)
+ {
+ sal_Int32 len = m_extra_assemblies->get_Length();
+ for ( sal_Int32 pos = 0; pos < len; ++pos )
+ {
+ ret_type = m_extra_assemblies[ pos ]->GetType( cts_name, false );
+ if (0 != ret_type)
+ {
+ if (g_verbose)
+ {
+ ::System::Console::WriteLine(
+ "> resolving type {0} from {1}.",
+ cts_name, ret_type->get_Assembly()->get_FullName() );
+ }
+ break;
+ }
+ }
+ }
+ if (0 != ret_type)
+ return ret_type->get_Assembly();
+ return 0;
+}
+
+//______________________________________________________________________________
+::System::Type * TypeEmitter::get_type(
+ ::System::String * cts_name, bool throw_exc )
+{
+ ::System::Type * ret_type = m_module_builder->GetType( cts_name, false );
+ if (0 == ret_type)
+ {
+ iface_entry * entry =
+ dynamic_cast< iface_entry * >( m_incomplete_ifaces->get_Item( cts_name ) );
+ if (0 != entry)
+ ret_type = entry->m_type_builder;
+ }
+ if (0 == ret_type)
+ return ::System::Type::GetType( cts_name, throw_exc ); // may call on type_resolve()
+ else
+ return ret_type;
+}
+
+//______________________________________________________________________________
+void TypeEmitter::emit_Any_boxed_ctor(
+ Emit::TypeBuilder * type_builder,
+ Emit::FieldBuilder * field_Type, Emit::FieldBuilder * field_Value,
+ ::System::Type * integral_type )
+{
+ ::System::Type * param_types __gc [] = new ::System::Type * __gc [ 1 ];
+ param_types[ 0 ] = integral_type;
+ Emit::ConstructorBuilder * ctor_builder =
+ type_builder->DefineConstructor(
+ s_ctor_attr, CallingConventions::Standard, param_types );
+ ctor_builder->DefineParameter( 1, ParameterAttributes::In, S"Value" );
+ Emit::ILGenerator * code = ctor_builder->GetILGenerator();
+ code->Emit( Emit::OpCodes::Ldarg_0 );
+ code->Emit( Emit::OpCodes::Ldtoken, integral_type );
+ code->Emit( Emit::OpCodes::Call, m_method_info_Type_GetTypeFromHandle );
+ code->Emit( Emit::OpCodes::Stfld, field_Type );
+ code->Emit( Emit::OpCodes::Ldarg_0 );
+ code->Emit( Emit::OpCodes::Ldarg_1 );
+ code->Emit( Emit::OpCodes::Box, integral_type );
+ code->Emit( Emit::OpCodes::Stfld, field_Value );
+ code->Emit( Emit::OpCodes::Ret );
+}
+//______________________________________________________________________________
+::System::Type * TypeEmitter::get_type_Any()
+{
+ if (0 == m_type_Any)
+ {
+ m_type_Any = get_type( S"uno.Any", false /* no exc */ );
+ if (0 == m_type_Any)
+ {
+ // define hardcoded type uno.Any
+ Emit::TypeBuilder * type_builder =
+ m_module_builder->DefineType(
+ S"uno.Any",
+ (TypeAttributes) (TypeAttributes::Public |
+ TypeAttributes::Sealed |
+ TypeAttributes::SequentialLayout |
+ TypeAttributes::BeforeFieldInit |
+ TypeAttributes::AnsiClass),
+ __typeof (::System::ValueType) );
+ Emit::FieldBuilder * field_Type = type_builder->DefineField(
+ S"Type", __typeof (::System::Type), FieldAttributes::Public );
+ Emit::FieldBuilder * field_Value = type_builder->DefineField(
+ S"Value", __typeof (::System::Object), FieldAttributes::Public );
+ Emit::FieldBuilder * field_VOID = type_builder->DefineField(
+ S"VOID", type_builder,
+ (FieldAttributes) (FieldAttributes::Public |
+ FieldAttributes::Static |
+ FieldAttributes::InitOnly) );
+ // .ctor( System.Type, System.Object )
+ ::System::Type * param_types __gc [] = new ::System::Type * __gc [ 2 ];
+ param_types[ 0 ] = __typeof (::System::Type);
+ param_types[ 1 ] = __typeof (::System::Object);
+ Emit::ConstructorBuilder * ctor_builder =
+ type_builder->DefineConstructor(
+ s_ctor_attr, CallingConventions::Standard, param_types );
+ ctor_builder->DefineParameter( 1, ParameterAttributes::In, S"Type" );
+ ctor_builder->DefineParameter( 2, ParameterAttributes::In, S"Value" );
+ Emit::ILGenerator * code = ctor_builder->GetILGenerator();
+ code->Emit( Emit::OpCodes::Ldarg_0 );
+ code->Emit( Emit::OpCodes::Ldarg_1 );
+ code->Emit( Emit::OpCodes::Stfld, field_Type );
+ code->Emit( Emit::OpCodes::Ldarg_0 );
+ code->Emit( Emit::OpCodes::Ldarg_2 );
+ code->Emit( Emit::OpCodes::Stfld, field_Value );
+ code->Emit( Emit::OpCodes::Ret );
+ // .cctor
+ // xxx todo: potential problem?
+ // DefineTypeInitializer() does not apply the HideBySig attribute!
+ code = type_builder->DefineTypeInitializer()->GetILGenerator();
+ code->Emit( Emit::OpCodes::Ldsflda, field_VOID );
+ code->Emit( Emit::OpCodes::Ldtoken, __typeof (::System::Void) );
+ code->Emit( Emit::OpCodes::Call, m_method_info_Type_GetTypeFromHandle );
+ code->Emit( Emit::OpCodes::Ldnull );
+ code->Emit( Emit::OpCodes::Call, ctor_builder );
+ code->Emit( Emit::OpCodes::Ret );
+
+ // integral .ctors
+ emit_Any_boxed_ctor(
+ type_builder, field_Type, field_Value, __typeof (::System::Char) );
+ emit_Any_boxed_ctor(
+ type_builder, field_Type, field_Value, __typeof (::System::Boolean) );
+ emit_Any_boxed_ctor(
+ type_builder, field_Type, field_Value, __typeof (::System::Byte) );
+ emit_Any_boxed_ctor(
+ type_builder, field_Type, field_Value, __typeof (::System::Int16) );
+ emit_Any_boxed_ctor(
+ type_builder, field_Type, field_Value, __typeof (::System::UInt16) );
+ emit_Any_boxed_ctor(
+ type_builder, field_Type, field_Value, __typeof (::System::Int32) );
+ emit_Any_boxed_ctor(
+ type_builder, field_Type, field_Value, __typeof (::System::UInt32) );
+ emit_Any_boxed_ctor(
+ type_builder, field_Type, field_Value, __typeof (::System::Int64) );
+ emit_Any_boxed_ctor(
+ type_builder, field_Type, field_Value, __typeof (::System::UInt64) );
+ emit_Any_boxed_ctor(
+ type_builder, field_Type, field_Value, __typeof (::System::Single) );
+ emit_Any_boxed_ctor(
+ type_builder, field_Type, field_Value, __typeof (::System::Double) );
+
+ // .ctor( System.Type )
+ param_types = new ::System::Type * __gc [ 1 ];
+ param_types[ 0 ] = __typeof (::System::Type);
+ ctor_builder =
+ type_builder->DefineConstructor(
+ s_ctor_attr, CallingConventions::Standard, param_types );
+ ctor_builder->DefineParameter( 1, ParameterAttributes::In, S"Value" );
+ code = ctor_builder->GetILGenerator();
+ code->Emit( Emit::OpCodes::Ldarg_0 );
+ code->Emit( Emit::OpCodes::Ldtoken, __typeof (::System::Type) );
+ code->Emit( Emit::OpCodes::Call, m_method_info_Type_GetTypeFromHandle );
+ code->Emit( Emit::OpCodes::Stfld, field_Type );
+ code->Emit( Emit::OpCodes::Ldarg_0 );
+ code->Emit( Emit::OpCodes::Ldarg_1 );
+ code->Emit( Emit::OpCodes::Stfld, field_Value );
+ code->Emit( Emit::OpCodes::Ret );
+ // .ctor( System.String )
+ param_types[ 0 ] = __typeof (::System::String);
+ ctor_builder =
+ type_builder->DefineConstructor(
+ s_ctor_attr, CallingConventions::Standard, param_types );
+ ctor_builder->DefineParameter( 1, ParameterAttributes::In, S"Value" );
+ code = ctor_builder->GetILGenerator();
+ code->Emit( Emit::OpCodes::Ldarg_0 );
+ code->Emit( Emit::OpCodes::Ldtoken, __typeof (::System::String) );
+ code->Emit( Emit::OpCodes::Call, m_method_info_Type_GetTypeFromHandle );
+ code->Emit( Emit::OpCodes::Stfld, field_Type );
+ code->Emit( Emit::OpCodes::Ldarg_0 );
+ code->Emit( Emit::OpCodes::Ldarg_1 );
+ code->Emit( Emit::OpCodes::Stfld, field_Value );
+ code->Emit( Emit::OpCodes::Ret );
+
+ if (g_verbose)
+ {
+ ::System::Console::WriteLine( "> emitting integral type uno.Any" );
+ }
+ m_type_Any = type_builder->CreateType();
+ }
+ m_field_Any_VOID = m_type_Any->GetField( S"VOID" );
+ m_type_Any_ref = get_type( S"uno.Any&", true );
+ }
+ return m_type_Any;
+}
+
+//______________________________________________________________________________
+::System::Type * TypeEmitter::get_type_Exception()
+{
+ if (0 == m_type_Exception)
+ {
+ m_type_Exception =
+ get_type( S"unoidl.com.sun.star.uno.Exception", false /* no exc */ );
+ if (0 == m_type_Exception)
+ {
+ // define hardcoded type unoidl.com.sun.star.uno.Exception
+ Emit::TypeBuilder * type_builder =
+ m_module_builder->DefineType(
+ S"unoidl.com.sun.star.uno.Exception",
+ (TypeAttributes) (TypeAttributes::Public |
+ TypeAttributes::BeforeFieldInit |
+ TypeAttributes::AnsiClass),
+ __typeof (::System::Exception) );
+ Emit::FieldBuilder * field_Context = type_builder->DefineField(
+ S"Context", __typeof (::System::Object), FieldAttributes::Public );
+ // default .ctor
+ type_builder->DefineDefaultConstructor( s_ctor_attr );
+ // .ctor
+ ::System::Type * param_types __gc [] = new ::System::Type * __gc [ 2 ];
+ param_types[ 0 ] = __typeof (::System::String);
+ param_types[ 1 ] = __typeof (::System::Object);
+ Emit::ConstructorBuilder * ctor_builder =
+ type_builder->DefineConstructor(
+ s_ctor_attr, CallingConventions::Standard, param_types );
+ ctor_builder->DefineParameter( 1, ParameterAttributes::In, S"Message" );
+ ctor_builder->DefineParameter( 2, ParameterAttributes::In, S"Context" );
+ Emit::ILGenerator * code = ctor_builder->GetILGenerator();
+ code->Emit( Emit::OpCodes::Ldarg_0 );
+ code->Emit( Emit::OpCodes::Ldarg_1 );
+ param_types = new ::System::Type * __gc [ 1 ];
+ param_types[ 0 ] = __typeof (::System::String);
+ code->Emit(
+ Emit::OpCodes::Call,
+ __typeof (::System::Exception) ->GetConstructor( param_types ) );
+ code->Emit( Emit::OpCodes::Ldarg_0 );
+ code->Emit( Emit::OpCodes::Ldarg_2 );
+ code->Emit( Emit::OpCodes::Stfld, field_Context );
+ code->Emit( Emit::OpCodes::Ret );
+
+ if (g_verbose)
+ {
+ ::System::Console::WriteLine(
+ "> emitting exception type unoidl.com.sun.star.uno.Exception" );
+ }
+ m_type_Exception = type_builder->CreateType();
+ }
+ }
+ return m_type_Exception;
+}
+
+//______________________________________________________________________________
+::System::Type * TypeEmitter::get_type_RuntimeException()
+{
+ if (0 == m_type_RuntimeException)
+ {
+ m_type_RuntimeException =
+ get_type( S"unoidl.com.sun.star.uno.RuntimeException", false /* no exc */ );
+ if (0 == m_type_RuntimeException)
+ {
+ // define hardcoded type unoidl.com.sun.star.uno.RuntimeException
+ ::System::Type * type_Exception = get_type_Exception();
+ Emit::TypeBuilder * type_builder =
+ m_module_builder->DefineType(
+ S"unoidl.com.sun.star.uno.RuntimeException",
+ (TypeAttributes) (TypeAttributes::Public |
+ TypeAttributes::BeforeFieldInit |
+ TypeAttributes::AnsiClass),
+ type_Exception );
+ // default .ctor
+ type_builder->DefineDefaultConstructor( s_ctor_attr );
+ // .ctor
+ ::System::Type * param_types __gc [] = new ::System::Type * __gc [ 2 ];
+ param_types[ 0 ] = __typeof (::System::String);
+ param_types[ 1 ] = __typeof (::System::Object);
+ Emit::ConstructorBuilder * ctor_builder =
+ type_builder->DefineConstructor(
+ s_ctor_attr, CallingConventions::Standard, param_types );
+ ctor_builder->DefineParameter( 1, ParameterAttributes::In, S"Message" );
+ ctor_builder->DefineParameter( 2, ParameterAttributes::In, S"Context" );
+ Emit::ILGenerator * code = ctor_builder->GetILGenerator();
+ code->Emit( Emit::OpCodes::Ldarg_0 );
+ code->Emit( Emit::OpCodes::Ldarg_1 );
+ code->Emit( Emit::OpCodes::Ldarg_2 );
+ code->Emit( Emit::OpCodes::Call, type_Exception->GetConstructor( param_types ) );
+ code->Emit( Emit::OpCodes::Ret );
+
+ if (g_verbose)
+ {
+ ::System::Console::WriteLine(
+ "> emitting exception type unoidl.com.sun.star.uno.RuntimeException" );
+ }
+ m_type_RuntimeException = type_builder->CreateType();
+ }
+ }
+ return m_type_RuntimeException;
+}
+
+//______________________________________________________________________________
+ConstructorInfo * TypeEmitter::get_ctor_uno_MethodAttribute()
+{
+ if (0 == m_ctor_uno_MethodAttribute)
+ {
+ ::System::Type * type_MethodAttribute =
+ get_type( S"uno.MethodAttribute", false /* no exc */ );
+ if (0 == type_MethodAttribute)
+ {
+ // define hardcoded type uno.MethodAttribute
+ Emit::TypeBuilder * type_builder =
+ m_module_builder->DefineType(
+ S"uno.MethodAttribute",
+ (TypeAttributes) (TypeAttributes::Public |
+ TypeAttributes::Sealed |
+ TypeAttributes::BeforeFieldInit |
+ TypeAttributes::AnsiClass),
+ __typeof (::System::Attribute) );
+ Emit::FieldBuilder * field_m_raises =
+ type_builder->DefineField(
+ S"m_raises", __typeof (::System::Type * __gc []), FieldAttributes::Private );
+ Emit::FieldBuilder * field_m_oneway =
+ type_builder->DefineField(
+ S"m_oneway", __typeof (bool), FieldAttributes::Private );
+ Emit::FieldBuilder * field_m_attribute_method =
+ type_builder->DefineField(
+ S"m_attribute_method", __typeof (bool), FieldAttributes::Private );
+
+ // apply System.AttributeUsage attribute
+ ::System::Type * params __gc [] = new ::System::Type * __gc [ 1 ];
+ params[ 0 ] = __typeof (::System::AttributeTargets);
+ ::System::Object * args __gc [] = new ::System::Object * __gc [ 1 ];
+ args[ 0 ] = __box (::System::AttributeTargets::Method);
+ PropertyInfo * props __gc [] = new PropertyInfo * __gc [ 1 ];
+ props[ 0 ] = __typeof (::System::AttributeUsageAttribute) ->GetProperty( S"Inherited" );
+ ::System::Object * props_args __gc [] = new ::System::Object * __gc [ 1 ];
+ props_args[ 0 ] = __box (false);
+ type_builder->SetCustomAttribute(
+ new Emit::CustomAttributeBuilder(
+ __typeof (::System::AttributeUsageAttribute) ->GetConstructor( params ), args,
+ props, props_args ) );
+
+ // default .ctor
+ Emit::ConstructorBuilder * ctor_builder =
+ type_builder->DefineConstructor(
+ s_ctor_attr, CallingConventions::Standard,
+ new ::System::Type * __gc [ 0 ] );
+ Emit::ILGenerator * code = ctor_builder->GetILGenerator();
+ code->Emit( Emit::OpCodes::Ldarg_0 );
+ // protected System.Attribute ctor
+ ConstructorInfo * base_ctor =
+ __typeof (::System::Attribute) ->GetConstructor(
+ (BindingFlags) (BindingFlags::Instance | BindingFlags::NonPublic),
+ 0, new ::System::Type * __gc [ 0 ], 0 );
+ code->Emit( Emit::OpCodes::Call, base_ctor );
+ code->Emit( Emit::OpCodes::Ldarg_0 );
+ code->Emit( Emit::OpCodes::Ldnull );
+ code->Emit( Emit::OpCodes::Stfld, field_m_raises );
+ code->Emit( Emit::OpCodes::Ldarg_0 );
+ code->Emit( Emit::OpCodes::Ldc_I4_0 );
+ code->Emit( Emit::OpCodes::Stfld, field_m_oneway );
+ code->Emit( Emit::OpCodes::Ldarg_0 );
+ code->Emit( Emit::OpCodes::Ldc_I4_0 );
+ code->Emit( Emit::OpCodes::Stfld, field_m_attribute_method );
+ code->Emit( Emit::OpCodes::Ret );
+
+ // .ctor
+ ::System::Type * param_types __gc [] = new ::System::Type * __gc [ 3 ];
+ param_types[ 0 ] = __typeof (::System::Type * __gc []);
+ param_types[ 1 ] = __typeof (bool);
+ param_types[ 2 ] = __typeof (bool);
+ ctor_builder =
+ type_builder->DefineConstructor(
+ s_ctor_attr, CallingConventions::Standard, param_types );
+ ctor_builder->DefineParameter( 1, ParameterAttributes::In, S"Raises" );
+ ctor_builder->DefineParameter( 2, ParameterAttributes::In, S"OneWay" );
+ ctor_builder->DefineParameter( 3, ParameterAttributes::In, S"AttributeMethod" );
+ code = ctor_builder->GetILGenerator();
+ code->Emit( Emit::OpCodes::Ldarg_0 );
+ code->Emit( Emit::OpCodes::Call, base_ctor );
+ code->Emit( Emit::OpCodes::Ldarg_0 );
+ code->Emit( Emit::OpCodes::Ldarg_1 );
+ code->Emit( Emit::OpCodes::Stfld, field_m_raises );
+ code->Emit( Emit::OpCodes::Ldarg_0 );
+ code->Emit( Emit::OpCodes::Ldarg_2 );
+ code->Emit( Emit::OpCodes::Stfld, field_m_oneway );
+ code->Emit( Emit::OpCodes::Ldarg_0 );
+ code->Emit( Emit::OpCodes::Ldarg_3 );
+ code->Emit( Emit::OpCodes::Stfld, field_m_attribute_method );
+ code->Emit( Emit::OpCodes::Ret );
+
+ // property Raises
+ ::System::Type * no_params __gc [] = new ::System::Type * __gc [ 0 ];
+ params = new ::System::Type * __gc [ 1 ];
+ MethodAttributes property_method_attr = (MethodAttributes)
+ (MethodAttributes::Public |
+ MethodAttributes::HideBySig |
+ MethodAttributes::SpecialName |
+ MethodAttributes::Instance);
+
+ // property Raises
+ params[ 0 ] = __typeof (::System::Type * __gc []);
+ Emit::PropertyBuilder * property_builder =
+ type_builder->DefineProperty(
+ S"Raises", PropertyAttributes::None,
+ __typeof (::System::Type * __gc []), no_params );
+ // getter
+ Emit::MethodBuilder * method_builder =
+ type_builder->DefineMethod(
+ S"get_Raises", property_method_attr,
+ __typeof (::System::Type * __gc []), no_params );
+ code = method_builder->GetILGenerator();
+// // xxx todo: complex get_Raises()
+ code->Emit( Emit::OpCodes::Ldarg_0 );
+ code->Emit( Emit::OpCodes::Ldfld, field_m_raises );
+ code->Emit( Emit::OpCodes::Ret );
+ property_builder->SetGetMethod( method_builder );
+ // setter
+ method_builder =
+ type_builder->DefineMethod(
+ S"set_Raises", property_method_attr, __typeof (void), params );
+ method_builder->DefineParameter( 1, ParameterAttributes::In, S"value" );
+ code = method_builder->GetILGenerator();
+ code->Emit( Emit::OpCodes::Ldarg_0 );
+ code->Emit( Emit::OpCodes::Ldarg_1 );
+ code->Emit( Emit::OpCodes::Stfld, field_m_raises );
+ code->Emit( Emit::OpCodes::Ret );
+ property_builder->SetSetMethod( method_builder );
+
+ // property OneWay
+ params[ 0 ] = __typeof (bool);
+ property_builder =
+ type_builder->DefineProperty(
+ S"OneWay", PropertyAttributes::None, __typeof (bool), no_params );
+ // getter
+ method_builder =
+ type_builder->DefineMethod(
+ S"get_OneWay", property_method_attr, __typeof (bool), no_params );
+ code = method_builder->GetILGenerator();
+ code->Emit( Emit::OpCodes::Ldarg_0 );
+ code->Emit( Emit::OpCodes::Ldfld, field_m_oneway );
+ code->Emit( Emit::OpCodes::Ret );
+ property_builder->SetGetMethod( method_builder );
+ // setter
+ method_builder =
+ type_builder->DefineMethod(
+ S"set_OneWay", property_method_attr, __typeof (void), params );
+ method_builder->DefineParameter( 1, ParameterAttributes::In, S"value" );
+ code = method_builder->GetILGenerator();
+ code->Emit( Emit::OpCodes::Ldarg_0 );
+ code->Emit( Emit::OpCodes::Ldarg_1 );
+ code->Emit( Emit::OpCodes::Stfld, field_m_oneway );
+ code->Emit( Emit::OpCodes::Ret );
+ property_builder->SetSetMethod( method_builder );
+
+ // property AttributeMethod
+// params[ 0 ] = __typeof (bool);
+ property_builder =
+ type_builder->DefineProperty(
+ S"AttributeMethod", PropertyAttributes::None, __typeof (bool), no_params );
+ // getter
+ method_builder =
+ type_builder->DefineMethod(
+ S"get_AttributeMethod", property_method_attr, __typeof (bool), no_params );
+ code = method_builder->GetILGenerator();
+ code->Emit( Emit::OpCodes::Ldarg_0 );
+ code->Emit( Emit::OpCodes::Ldfld, field_m_attribute_method );
+ code->Emit( Emit::OpCodes::Ret );
+ property_builder->SetGetMethod( method_builder );
+ // setter
+ method_builder =
+ type_builder->DefineMethod(
+ S"set_AttributeMethod", property_method_attr, __typeof (void), params );
+ method_builder->DefineParameter( 1, ParameterAttributes::In, S"value" );
+ code = method_builder->GetILGenerator();
+ code->Emit( Emit::OpCodes::Ldarg_0 );
+ code->Emit( Emit::OpCodes::Ldarg_1 );
+ code->Emit( Emit::OpCodes::Stfld, field_m_attribute_method );
+ code->Emit( Emit::OpCodes::Ret );
+ property_builder->SetSetMethod( method_builder );
+
+ if (g_verbose)
+ {
+ ::System::Console::WriteLine(
+ "> emitting attribute type uno.MethodAttribute" );
+ }
+ type_MethodAttribute = type_builder->CreateType();
+ }
+ // retrieve default .ctor
+ ::System::Type * param_types __gc [] = new ::System::Type * __gc [ 0 ];
+ m_default_ctor_uno_MethodAttribute = type_MethodAttribute->GetConstructor( param_types );
+ OSL_ASSERT( 0 != m_default_ctor_uno_MethodAttribute );
+ // retrieve .ctor
+ param_types = new ::System::Type * __gc [ 3 ];
+ param_types[ 0 ] = __typeof (::System::Type * __gc []);
+ param_types[ 1 ] = __typeof (bool);
+ param_types[ 2 ] = __typeof (bool);
+ m_ctor_uno_MethodAttribute = type_MethodAttribute->GetConstructor( param_types );
+ OSL_ASSERT( 0 != m_ctor_uno_MethodAttribute );
+ }
+ return m_ctor_uno_MethodAttribute;
+}
+
+//______________________________________________________________________________
+::System::Type * TypeEmitter::get_type(
+ Reference< reflection::XConstantTypeDescription > const & xType )
+{
+ ::System::String * cts_name = to_cts_name( xType->getName() );
+ ::System::Type * ret_type = get_type( cts_name, false /* no exc */ );
+ if (0 == ret_type)
+ {
+ Reference< reflection::XConstantTypeDescription > xConstant( xType, UNO_QUERY_THROW );
+ ::System::Object * constant = to_cli_constant( xConstant->getConstantValue() );
+ Emit::TypeBuilder * type_builder =
+ m_module_builder->DefineType(
+ cts_name,
+ (TypeAttributes) (TypeAttributes::Public |
+ TypeAttributes::Sealed |
+ TypeAttributes::BeforeFieldInit |
+ TypeAttributes::AnsiClass) );
+
+ Emit::FieldBuilder * field_builder = type_builder->DefineField(
+ cts_name->Substring( cts_name->LastIndexOf( '.' ) +1 ),
+ constant->GetType(),
+ (FieldAttributes) (FieldAttributes::Public |
+ FieldAttributes::Static |
+ FieldAttributes::Literal) );
+ field_builder->SetConstant( constant );
+
+ if (g_verbose)
+ {
+ ::System::Console::WriteLine( "> emitting constant type {0}", cts_name );
+ }
+ ret_type = type_builder->CreateType();
+ }
+ return ret_type;
+}
+
+//______________________________________________________________________________
+::System::Type * TypeEmitter::get_type(
+ Reference< reflection::XConstantsTypeDescription > const & xType )
+{
+ ::System::String * cts_name = to_cts_name( xType->getName() );
+ ::System::Type * ret_type = get_type( cts_name, false /* no exc */ );
+ if (0 == ret_type)
+ {
+ Emit::TypeBuilder * type_builder =
+ m_module_builder->DefineType(
+ cts_name,
+ (TypeAttributes) (TypeAttributes::Public |
+ TypeAttributes::Sealed |
+ TypeAttributes::BeforeFieldInit |
+ TypeAttributes::AnsiClass) );
+
+ Sequence< Reference< reflection::XConstantTypeDescription > > seq_constants(
+ xType->getConstants() );
+ Reference< reflection::XConstantTypeDescription > const * constants =
+ seq_constants.getConstArray();
+ sal_Int32 constants_length = seq_constants.getLength();
+ for ( sal_Int32 constants_pos = 0; constants_pos < constants_length; ++constants_pos )
+ {
+ Reference< reflection::XConstantTypeDescription > const & xConstant =
+ constants[ constants_pos ];
+ ::System::Object * constant = to_cli_constant( xConstant->getConstantValue() );
+ ::System::String * uno_name = ustring_to_String( xConstant->getName() );
+ Emit::FieldBuilder * field_builder = type_builder->DefineField(
+ uno_name->Substring( uno_name->LastIndexOf( '.' ) +1 ),
+ constant->GetType(),
+ (FieldAttributes) (FieldAttributes::Public |
+ FieldAttributes::Static |
+ FieldAttributes::Literal) );
+ field_builder->SetConstant( constant );
+ }
+
+ if (g_verbose)
+ {
+ ::System::Console::WriteLine( "> emitting constants group type {0}", cts_name );
+ }
+ ret_type = type_builder->CreateType();
+ }
+ return ret_type;
+}
+
+//______________________________________________________________________________
+::System::Type * TypeEmitter::get_type(
+ Reference< reflection::XEnumTypeDescription > const & xType )
+{
+ ::System::String * cts_name = to_cts_name( xType->getName() );
+ ::System::Type * ret_type = get_type( cts_name, false /* no exc */ );
+ if (0 == ret_type)
+ {
+// Emit::EnumBuilder * enum_builder =
+// m_module_builder->DefineEnum(
+// cts_name,
+// (TypeAttributes) (TypeAttributes::Public |
+// // TypeAttributes::Sealed |
+// TypeAttributes::AnsiClass),
+// __typeof (::System::Int32) );
+ // workaround enum builder bug
+ Emit::TypeBuilder * enum_builder =
+ m_module_builder->DefineType(
+ cts_name,
+ (TypeAttributes) (TypeAttributes::Public | TypeAttributes::Sealed),
+ __typeof (::System::Enum) );
+ enum_builder->DefineField(
+ S"value__", __typeof (::System::Int32),
+ (FieldAttributes) (FieldAttributes::Private |
+ FieldAttributes::SpecialName |
+ FieldAttributes::RTSpecialName) );
+ Sequence< OUString > seq_enum_names( xType->getEnumNames() );
+ Sequence< sal_Int32 > seq_enum_values( xType->getEnumValues() );
+ sal_Int32 enum_length = seq_enum_names.getLength();
+ OSL_ASSERT( enum_length == seq_enum_values.getLength() );
+ OUString const * enum_names = seq_enum_names.getConstArray();
+ sal_Int32 const * enum_values = seq_enum_values.getConstArray();
+ for ( sal_Int32 enum_pos = 0; enum_pos < enum_length; ++enum_pos )
+ {
+// enum_builder->DefineLiteral(
+// ustring_to_String( enum_names[ enum_pos ] ),
+// __box ((::System::Int32) enum_values[ enum_pos ]) );
+ Emit::FieldBuilder * field_builder =
+ enum_builder->DefineField(
+ ustring_to_String( enum_names[ enum_pos ] ),
+ enum_builder,
+ (FieldAttributes) (FieldAttributes::Public |
+ FieldAttributes::Static |
+ FieldAttributes::Literal) );
+ field_builder->SetConstant( __box ((::System::Int32) enum_values[ enum_pos ]) );
+ }
+
+ if (g_verbose)
+ {
+ ::System::Console::WriteLine( "> emitting enum type {0}", cts_name );
+ }
+ ret_type = enum_builder->CreateType();
+ }
+ return ret_type;
+}
+
+//______________________________________________________________________________
+::System::Type * TypeEmitter::get_type(
+ Reference< reflection::XCompoundTypeDescription > const & xType )
+{
+ OUString uno_name( xType->getName() );
+ if (TypeClass_EXCEPTION == xType->getTypeClass())
+ {
+ if (uno_name.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("com.sun.star.uno.Exception") ))
+ {
+ return get_type_Exception();
+ }
+ if (uno_name.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("com.sun.star.uno.RuntimeException") ))
+ {
+ return get_type_RuntimeException();
+ }
+ }
+
+ ::System::String * cts_name = to_cts_name( uno_name );
+ ::System::Type * ret_type = get_type( cts_name, false /* no exc */ );
+ if (0 == ret_type)
+ {
+ Reference< reflection::XCompoundTypeDescription > xBaseType(
+ xType->getBaseType(), UNO_QUERY );
+ ::System::Type * base_type =
+ (xBaseType.is() ? get_type( xBaseType ) : __typeof (::System::Object));
+ Emit::TypeBuilder * type_builder =
+ m_module_builder->DefineType(
+ cts_name,
+ (TypeAttributes) (TypeAttributes::Public |
+ TypeAttributes::BeforeFieldInit |
+ TypeAttributes::AnsiClass),
+ base_type );
+
+ // optional: lookup base type whether generated entry of this session
+ struct_entry * base_type_entry = 0;
+ if (0 != base_type)
+ {
+ base_type_entry =
+ dynamic_cast< struct_entry * >(
+ m_generated_structs->get_Item( base_type->get_FullName() ) );
+ }
+
+ // members
+ Sequence< Reference< reflection::XTypeDescription > > seq_members(
+ xType->getMemberTypes() );
+ Sequence< OUString > seq_member_names( xType->getMemberNames() );
+ sal_Int32 members_length = seq_members.getLength();
+ OSL_ASSERT( seq_member_names.getLength() == members_length );
+
+ sal_Int32 all_members_length = 0;
+ sal_Int32 member_pos;
+
+ // collect base types; wrong order
+ ::System::Collections::ArrayList * base_types_list =
+ new ::System::Collections::ArrayList( 3 /* initial capacity */ );
+ for ( ::System::Type * base_type_pos = base_type;
+ ! base_type_pos->Equals( __typeof (::System::Object) );
+ base_type_pos = base_type_pos->get_BaseType() )
+ {
+ base_types_list->Add( base_type_pos );
+ if (base_type_pos->Equals( __typeof (::System::Exception) ))
+ {
+ // special Message member
+ all_members_length += 1;
+ break; // don't include System.Exception base classes
+ }
+ else
+ {
+ all_members_length +=
+ base_type_pos->GetFields(
+ (BindingFlags) (BindingFlags::Instance |
+ BindingFlags::Public |
+ BindingFlags::DeclaredOnly) )->get_Length();
+ }
+ }
+
+ // create all_members arrays; right order
+ ::System::String * all_member_names __gc [] =
+ new ::System::String * __gc [ all_members_length + members_length ];
+ ::System::Type * all_param_types __gc [] =
+ new ::System::Type * __gc [ all_members_length + members_length ];
+ member_pos = 0;
+ for ( sal_Int32 pos = base_types_list->get_Count(); pos--; )
+ {
+ ::System::Type * base_type =
+ __try_cast< ::System::Type * >( base_types_list->get_Item( pos ) );
+ if (base_type->Equals( __typeof (::System::Exception) ))
+ {
+ all_member_names[ member_pos ] = S"Message";
+ all_param_types[ member_pos ] = __typeof (::System::String);
+ ++member_pos;
+ }
+ else
+ {
+ ::System::String * base_type_name = base_type->get_FullName();
+ struct_entry * entry =
+ dynamic_cast< struct_entry * >(
+ m_generated_structs->get_Item( base_type_name ) );
+ if (0 == entry)
+ {
+ // complete type
+ FieldInfo * fields __gc [] =
+ base_type->GetFields(
+ (BindingFlags) (BindingFlags::Instance |
+ BindingFlags::Public |
+ BindingFlags::DeclaredOnly) );
+ sal_Int32 len = fields->get_Length();
+ for ( sal_Int32 pos = 0; pos < len; ++pos )
+ {
+ FieldInfo * field = fields[ pos ];
+ all_member_names[ member_pos ] = field->get_Name();
+ ::System::Type * field_type = field->get_FieldType();
+ if (field_type->get_FullName()->Equals( S"uno.Any" ))
+ field_type = m_type_Any_ref;
+ all_param_types[ member_pos ] = field_type;
+ ++member_pos;
+ }
+ }
+ else // generated during this session: members may be incomplete ifaces
+ {
+ sal_Int32 len = entry->m_member_names->get_Length();
+ for ( sal_Int32 pos = 0; pos < len; ++pos )
+ {
+ all_member_names[ member_pos ] = entry->m_member_names[ pos ];
+ all_param_types[ member_pos ] = entry->m_param_types[ pos ];
+ ++member_pos;
+ }
+ }
+ }
+ }
+ OSL_ASSERT( all_members_length == member_pos );
+
+ // build up entry
+ struct_entry * entry = new struct_entry();
+ entry->m_member_names = new ::System::String * __gc [ members_length ];
+ entry->m_param_types = new ::System::Type * __gc [ members_length ];
+
+ // add members
+ FieldInfo * members __gc [] = new FieldInfo * __gc [ members_length ];
+ Reference< reflection::XTypeDescription > const * pseq_members =
+ seq_members.getConstArray();
+ OUString const * pseq_member_names =
+ seq_member_names.getConstArray();
+ for ( member_pos = 0; member_pos < members_length; ++member_pos )
+ {
+ ::System::String * field_name = ustring_to_String( pseq_member_names[ member_pos ] );
+ ::System::Type * field_type = get_type( pseq_members[ member_pos ] );
+ members[ member_pos ] =
+ type_builder->DefineField( field_name, field_type, FieldAttributes::Public );
+ if (field_type->get_FullName()->Equals( S"uno.Any" ))
+ field_type = m_type_Any_ref;
+ // add to all_members
+ all_member_names[ all_members_length + member_pos ] = field_name;
+ all_param_types[ all_members_length + member_pos ] = field_type;
+ // add to entry
+ entry->m_member_names[ member_pos ] = field_name;
+ entry->m_param_types[ member_pos ] = field_type;
+ }
+ all_members_length += members_length;
+
+ // default .ctor
+ Emit::ConstructorBuilder * ctor_builder =
+ type_builder->DefineConstructor(
+ s_ctor_attr, CallingConventions::Standard, new ::System::Type * __gc [ 0 ] );
+ Emit::ILGenerator * ctor_code = ctor_builder->GetILGenerator();
+ ctor_code->Emit( Emit::OpCodes::Ldarg_0 );
+ ctor_code->Emit(
+ Emit::OpCodes::Call,
+ 0 == base_type_entry
+ ? base_type->GetConstructor( new ::System::Type * __gc [ 0 ] )
+ : base_type_entry->m_default_ctor );
+ // default initialize members
+ for ( member_pos = 0; member_pos < members_length; ++member_pos )
+ {
+ FieldInfo * field = members[ member_pos ];
+ ::System::Type * field_type = field->get_FieldType();
+ // default initialize: string, type, enum, sequence, struct, exception, any
+ if (field_type->Equals( __typeof (::System::String) ))
+ {
+ ctor_code->Emit( Emit::OpCodes::Ldarg_0 );
+ ctor_code->Emit( Emit::OpCodes::Ldstr, S"" );
+ ctor_code->Emit( Emit::OpCodes::Stfld, field );
+ }
+ else if (field_type->Equals( __typeof (::System::Type) ))
+ {
+ ctor_code->Emit( Emit::OpCodes::Ldarg_0 );
+ ctor_code->Emit( Emit::OpCodes::Ldtoken, __typeof (::System::Void) );
+ ctor_code->Emit( Emit::OpCodes::Call, m_method_info_Type_GetTypeFromHandle );
+ ctor_code->Emit( Emit::OpCodes::Stfld, field );
+ }
+ else if (field_type->get_IsArray())
+ {
+ ctor_code->Emit( Emit::OpCodes::Ldarg_0 );
+ ctor_code->Emit( Emit::OpCodes::Ldc_I4_0 );
+ ctor_code->Emit( Emit::OpCodes::Newarr, field_type->GetElementType() );
+ ctor_code->Emit( Emit::OpCodes::Stfld, field );
+ }
+ else if (field_type->get_IsValueType())
+ {
+ if (field_type->get_FullName()->Equals( S"uno.Any" ))
+ {
+ ctor_code->Emit( Emit::OpCodes::Ldarg_0 );
+ ctor_code->Emit( Emit::OpCodes::Ldsfld, m_field_Any_VOID );
+ ctor_code->Emit( Emit::OpCodes::Stfld, field );
+ }
+ }
+ else if (field_type->get_IsClass())
+ {
+ if (! field_type->Equals( __typeof (::System::Object) ) /* my be XInterface */)
+ {
+ // struct, exception
+ ctor_code->Emit( Emit::OpCodes::Ldarg_0 );
+ ctor_code->Emit(
+ Emit::OpCodes::Newobj,
+ field_type->GetConstructor( new ::System::Type * __gc [ 0 ] ) );
+ ctor_code->Emit( Emit::OpCodes::Stfld, field );
+ }
+ }
+ }
+ ctor_code->Emit( Emit::OpCodes::Ret );
+ entry->m_default_ctor = ctor_builder;
+
+ // parameterized .ctor including all base members
+ ctor_builder = type_builder->DefineConstructor(
+ s_ctor_attr, CallingConventions::Standard, all_param_types );
+ for ( member_pos = 0; member_pos < all_members_length; ++member_pos )
+ {
+ ctor_builder->DefineParameter(
+ member_pos +1 /* starts with 1 */, ParameterAttributes::In,
+ all_member_names[ member_pos ] );
+ }
+ ctor_code = ctor_builder->GetILGenerator();
+ // call base .ctor
+ ctor_code->Emit( Emit::OpCodes::Ldarg_0 ); // push this
+ sal_Int32 base_members_length = all_members_length - members_length;
+ ::System::Type * param_types __gc [] = new ::System::Type * __gc [ base_members_length ];
+ for ( member_pos = 0; member_pos < base_members_length; ++member_pos )
+ {
+ emit_ldarg( ctor_code, member_pos +1 );
+ param_types[ member_pos ] = all_param_types[ member_pos ];
+ }
+ ctor_code->Emit(
+ Emit::OpCodes::Call,
+ 0 == base_type_entry
+ ? base_type->GetConstructor( param_types )
+ : base_type_entry->m_ctor );
+ // initialize members
+ for ( member_pos = 0; member_pos < members_length; ++member_pos )
+ {
+ ctor_code->Emit( Emit::OpCodes::Ldarg_0 ); // push this
+ emit_ldarg( ctor_code, member_pos + base_members_length +1 );
+ ::System::Type * type =
+ all_param_types[ all_members_length - members_length + member_pos ];
+ if (type->get_FullName()->Equals( S"uno.Any&" ))
+ ctor_code->Emit( Emit::OpCodes::Ldobj, m_type_Any );
+ ctor_code->Emit( Emit::OpCodes::Stfld, members[ member_pos ] );
+ }
+ ctor_code->Emit( Emit::OpCodes::Ret );
+ entry->m_ctor = ctor_builder;
+
+ if (g_verbose)
+ {
+ ::System::Console::WriteLine(
+ "> emitting {0} type {1}",
+ TypeClass_STRUCT == xType->getTypeClass() ? S"struct" : S"exception",
+ cts_name );
+ }
+ // new entry
+ m_generated_structs->Add( cts_name, entry );
+ ret_type = type_builder->CreateType();
+ }
+ return ret_type;
+}
+
+//______________________________________________________________________________
+::System::Type * TypeEmitter::get_type(
+ Reference< reflection::XInterfaceTypeDescription > const & xType )
+{
+ OUString uno_name( xType->getName() );
+ if (uno_name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.uno.XInterface") ))
+ return __typeof (::System::Object);
+ ::System::String * cts_name = to_cts_name( xType->getName() );
+ ::System::Type * ret_type = get_type( cts_name, false /* no exc */ );
+ if (0 == ret_type)
+ {
+ Emit::TypeBuilder * type_builder;
+
+ TypeAttributes attr = (TypeAttributes) (TypeAttributes::Public |
+ TypeAttributes::Interface |
+ TypeAttributes::Abstract |
+ TypeAttributes::AnsiClass);
+
+ Reference< reflection::XInterfaceTypeDescription > xBaseType(
+ xType->getBaseType(), UNO_QUERY );
+ if (xBaseType.is() &&
+ !xBaseType->getName().equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("com.sun.star.uno.XInterface") ))
+ {
+ ::System::Type * base_interfaces __gc [] = new ::System::Type * __gc [ 1 ];
+ base_interfaces[ 0 ] = get_type( xBaseType );
+ type_builder = m_module_builder->DefineType( cts_name, attr, 0, base_interfaces );
+ }
+ else
+ {
+ if (! xBaseType.is())
+ {
+ ::System::Console::WriteLine(
+ "warning: IDL interface {0} is not derived from com.sun.star.uno.XInterface!",
+ ustring_to_String( uno_name ) );
+ }
+ type_builder = m_module_builder->DefineType( cts_name, attr );
+ }
+
+ // insert to be completed
+ iface_entry * entry = new iface_entry();
+ xType->acquire();
+ entry->m_xType = xType.get();
+ entry->m_type_builder = type_builder;
+ m_incomplete_ifaces->Add( cts_name, entry );
+
+ // type is incomplete
+ ret_type = type_builder;
+ }
+ return ret_type;
+}
+
+//______________________________________________________________________________
+::System::Type * TypeEmitter::complete_iface_type( iface_entry * entry )
+{
+ Emit::TypeBuilder * type_builder = entry->m_type_builder;
+ reflection::XInterfaceTypeDescription * xType = entry->m_xType;
+
+ Reference< reflection::XTypeDescription > xBaseType( xType->getBaseType() );
+ if (xBaseType.is())
+ {
+ ::System::String * basetype_name = to_cts_name( xBaseType->getName() );
+ iface_entry * base_entry =
+ dynamic_cast< iface_entry * >( m_incomplete_ifaces->get_Item( basetype_name ) );
+ if (0 != base_entry)
+ {
+ // complete uncompleted base type first
+ complete_iface_type( base_entry );
+ }
+ }
+
+ ConstructorInfo * ctor_MethodAttribute = get_ctor_uno_MethodAttribute();
+ Emit::CustomAttributeBuilder * default_MethodAttribute_builder =
+ new Emit::CustomAttributeBuilder(
+ m_default_ctor_uno_MethodAttribute, new ::System::Object * __gc [ 0 ] );
+
+ Sequence< Reference< reflection::XInterfaceMemberTypeDescription > > seq_members(
+ xType->getMembers() );
+ Reference< reflection::XInterfaceMemberTypeDescription > const * members =
+ seq_members.getConstArray();
+ sal_Int32 members_length = seq_members.getLength();
+ for ( sal_Int32 members_pos = 0; members_pos < members_length; ++members_pos )
+ {
+ Reference< reflection::XInterfaceMemberTypeDescription > const & xMember =
+ members[ members_pos ];
+ Sequence< Reference< reflection::XTypeDescription > > seq_exceptions;
+ Emit::MethodBuilder * method_builder;
+
+ const MethodAttributes method_attr = (MethodAttributes)
+ (MethodAttributes::Public |
+ MethodAttributes::Abstract |
+ MethodAttributes::Virtual |
+ MethodAttributes::NewSlot |
+ MethodAttributes::HideBySig |
+ MethodAttributes::Instance);
+
+ if (TypeClass_INTERFACE_METHOD == xMember->getTypeClass())
+ {
+ Reference< reflection::XInterfaceMethodTypeDescription > xMethod(
+ xMember, UNO_QUERY_THROW );
+
+ Sequence< Reference< reflection::XMethodParameter > > seq_parameters(
+ xMethod->getParameters() );
+ sal_Int32 params_length = seq_parameters.getLength();
+ ::System::Type * param_types __gc [] = new ::System::Type * __gc [ params_length ];
+ Reference< reflection::XMethodParameter > const * parameters =
+ seq_parameters.getConstArray();
+ // first determine all types
+ sal_Int32 params_pos = 0;
+ for ( ; params_pos < params_length; ++params_pos )
+ {
+ Reference< reflection::XMethodParameter > const & xParam = parameters[ params_pos ];
+ ::System::Type * param_type = get_type( xParam->getType() );
+ ::System::String * param_type_name = param_type->get_FullName();
+ if (xParam->isOut() || param_type_name->Equals( S"uno.Any" ))
+ {
+ param_type = get_type(
+ ::System::String::Concat( param_type_name, S"&" ), true );
+ }
+ param_types[ xParam->getPosition() ] = param_type;
+ }
+ // create method
+ method_builder =
+ type_builder->DefineMethod(
+ ustring_to_String( xMethod->getMemberName() ),
+ method_attr, get_type( xMethod->getReturnType() ), param_types );
+ // then define parameter infos
+ params_pos = 0;
+ for ( ; params_pos < params_length; ++params_pos )
+ {
+ Reference< reflection::XMethodParameter > const & xParam = parameters[ params_pos ];
+ long param_flags = 0;
+ if (xParam->isIn())
+ param_flags |= ParameterAttributes::In;
+ if (xParam->isOut())
+ param_flags |= ParameterAttributes::Out;
+ OSL_ASSERT( 0 != param_flags );
+ method_builder->DefineParameter(
+ xParam->getPosition() +1 /* starts with 1 */,
+ (ParameterAttributes) param_flags,
+ ustring_to_String( xParam->getName() ) );
+ }
+ seq_exceptions = xMethod->getExceptions();
+
+ // uno method attribute
+ Reference< reflection::XTypeDescription > const * exceptions =
+ seq_exceptions.getConstArray();
+ sal_Int32 exc_length = seq_exceptions.getLength();
+ if (0 == exc_length) // opt
+ {
+ method_builder->SetCustomAttribute( default_MethodAttribute_builder );
+ }
+ else
+ {
+ ::System::Type * exception_types __gc [] = new ::System::Type * __gc [ exc_length ];
+ for ( sal_Int32 exc_pos = 0; exc_pos < exc_length; ++exc_pos )
+ {
+ Reference< reflection::XTypeDescription > const & xExc = exceptions[ exc_pos ];
+ exception_types[ exc_pos ] = get_type( xExc );
+ if (xExc->getName().equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("com.sun.star.uno.Exception") ))
+ {
+ // specify only unoidl.com.sun.star.uno.Exception
+ exception_types[ 0 ] = get_type_Exception();
+ exc_length = 1;
+ break;
+ }
+ }
+ if (exc_length != seq_exceptions.getLength())
+ {
+ ::System::Type * temp __gc [] = new ::System::Type * __gc [ exc_length ];
+ ::System::Array::Copy( exception_types, temp, exc_length );
+ exception_types = temp;
+ }
+ ::System::Object * args __gc [] = new ::System::Object * __gc [ 3 ];
+ args[ 0 ] = exception_types;
+ args[ 1 ] = __box (sal_False != xMethod->isOneway());
+ args[ 2 ] = __box (false);
+ method_builder->SetCustomAttribute(
+ new Emit::CustomAttributeBuilder( ctor_MethodAttribute, args ) );
+ }
+ }
+ else // attribute
+ {
+ OSL_ASSERT( TypeClass_INTERFACE_ATTRIBUTE == xMember->getTypeClass() );
+ Reference< reflection::XInterfaceAttributeTypeDescription > xAttribute(
+ xMember, UNO_QUERY_THROW );
+
+ ::System::Type * attribute_type = get_type( xAttribute->getType() );
+ // getter
+ ::System::Type * parameters __gc [] = new ::System::Type * __gc [ 0 ];
+ method_builder =
+ type_builder->DefineMethod(
+ ustring_to_String( OUSTR("get") + xAttribute->getMemberName() ),
+ method_attr, attribute_type, parameters );
+ // exception spec
+ ::System::Object * args __gc [] = new ::System::Object * __gc [ 3 ];
+ args[ 0 ] = 0; // implies com.sun.star.uno.RuntimeException
+ args[ 1 ] = __box (false);
+ args[ 2 ] = __box (true); // is AttributeMethod
+ Emit::CustomAttributeBuilder * attribute_builder =
+ new Emit::CustomAttributeBuilder( ctor_MethodAttribute, args );
+ method_builder->SetCustomAttribute( attribute_builder );
+
+ if (! xAttribute->isReadOnly())
+ {
+ // setter
+ parameters = new ::System::Type * __gc [ 1 ];
+ ::System::String * attribute_type_name = attribute_type->get_FullName();
+ parameters[ 0 ] =
+ (attribute_type_name->Equals( S"uno.Any" ) ? m_type_Any_ref : attribute_type);
+ method_builder =
+ type_builder->DefineMethod(
+ ustring_to_String( OUSTR("set") + xAttribute->getMemberName() ),
+ method_attr, 0, parameters );
+ // define parameter info
+ method_builder->DefineParameter(
+ 1 /* starts with 1 */, ParameterAttributes::In, S"value" );
+ // exception spec
+ method_builder->SetCustomAttribute( attribute_builder );
+ }
+ }
+ }
+
+ // remove from incomplete types map
+ ::System::String * cts_name = type_builder->get_FullName();
+ m_incomplete_ifaces->Remove( cts_name );
+ xType->release();
+
+ if (g_verbose)
+ {
+ ::System::Console::WriteLine( "> emitting interface type {0}", cts_name );
+ }
+ return type_builder->CreateType();
+}
+
+//______________________________________________________________________________
+::System::Type * TypeEmitter::get_type(
+ Reference< reflection::XTypeDescription > const & xType )
+{
+ switch (xType->getTypeClass())
+ {
+ case TypeClass_VOID:
+ return __typeof (::System::Void);
+ case TypeClass_CHAR:
+ return __typeof (::System::Char);
+ case TypeClass_BOOLEAN:
+ return __typeof (::System::Boolean);
+ case TypeClass_BYTE:
+ return __typeof (::System::Byte);
+ case TypeClass_SHORT:
+ return __typeof (::System::Int16);
+ case TypeClass_UNSIGNED_SHORT:
+ return __typeof (::System::UInt16);
+ case TypeClass_LONG:
+ return __typeof (::System::Int32);
+ case TypeClass_UNSIGNED_LONG:
+ return __typeof (::System::UInt32);
+ case TypeClass_HYPER:
+ return __typeof (::System::Int64);
+ case TypeClass_UNSIGNED_HYPER:
+ return __typeof (::System::UInt64);
+ case TypeClass_FLOAT:
+ return __typeof (::System::Single);
+ case TypeClass_DOUBLE:
+ return __typeof (::System::Double);
+ case TypeClass_STRING:
+ return __typeof (::System::String);
+ case TypeClass_TYPE:
+ return __typeof (::System::Type);
+ case TypeClass_ANY:
+ return get_type_Any();
+ case TypeClass_ENUM:
+ return get_type( Reference< reflection::XEnumTypeDescription >( xType, UNO_QUERY_THROW ) );
+ case TypeClass_TYPEDEF:
+ // unwind typedefs
+ return get_type(
+ Reference< reflection::XIndirectTypeDescription >(
+ xType, UNO_QUERY_THROW )->getReferencedType() );
+ case TypeClass_STRUCT:
+ case TypeClass_EXCEPTION:
+ return get_type(
+ Reference< reflection::XCompoundTypeDescription >( xType, UNO_QUERY_THROW ) );
+ case TypeClass_SEQUENCE:
+ {
+ ::System::Type * element_type = get_type(
+ Reference< reflection::XIndirectTypeDescription >(
+ xType, UNO_QUERY_THROW )->getReferencedType() );
+ return get_type(
+ ::System::String::Concat( element_type->get_FullName(), S"[]" ), true );
+ }
+ case TypeClass_INTERFACE:
+ return get_type(
+ Reference< reflection::XInterfaceTypeDescription >( xType, UNO_QUERY_THROW ) );
+ case TypeClass_CONSTANT:
+ return get_type(
+ Reference< reflection::XConstantTypeDescription >( xType, UNO_QUERY_THROW ) );
+ case TypeClass_CONSTANTS:
+ return get_type(
+ Reference< reflection::XConstantsTypeDescription >( xType, UNO_QUERY_THROW ) );
+ case TypeClass_SERVICE:
+ case TypeClass_MODULE:
+ // ignore these
+ return 0;
+ default:
+ throw RuntimeException(
+ OUSTR("unexpected type ") + xType->getName(), Reference< XInterface >() );
+ }
+}
+
+//______________________________________________________________________________
+void TypeEmitter::Dispose()
+{
+ while (true)
+ {
+ ::System::Collections::IDictionaryEnumerator * enumerator =
+ m_incomplete_ifaces->GetEnumerator();
+ if (! enumerator->MoveNext())
+ break;
+ complete_iface_type( __try_cast< iface_entry * >( enumerator->get_Value() ) );
+ }
+ m_incomplete_ifaces = 0;
+}
+//______________________________________________________________________________
+TypeEmitter::TypeEmitter(
+ ::System::Reflection::Emit::ModuleBuilder * module_builder,
+ ::System::Reflection::Assembly * extra_assemblies __gc [] )
+ : s_ctor_attr( (MethodAttributes)
+ (MethodAttributes::Public |
+ MethodAttributes::HideBySig |
+ MethodAttributes::SpecialName |
+ MethodAttributes::RTSpecialName |
+ MethodAttributes::Instance) ),
+ m_module_builder( module_builder ),
+ m_extra_assemblies( extra_assemblies ),
+ m_method_info_Type_GetTypeFromHandle( 0 ),
+ m_type_Exception( 0 ),
+ m_type_RuntimeException( 0 ),
+ m_type_Any( 0 ),
+ m_type_Any_ref( 0 ),
+ m_field_Any_VOID( 0 ),
+ m_ctor_uno_MethodAttribute( 0 ),
+ m_default_ctor_uno_MethodAttribute( 0 ),
+ m_incomplete_ifaces( new ::System::Collections::Hashtable() ),
+ m_generated_structs( new ::System::Collections::Hashtable() )
+{
+ ::System::Type * param_types __gc [] = new ::System::Type * __gc [ 1 ];
+ param_types[ 0 ] = __typeof (::System::RuntimeTypeHandle);
+ m_method_info_Type_GetTypeFromHandle =
+ __typeof (::System::Type) ->GetMethod( "GetTypeFromHandle", param_types );
+}
+
+}
diff --git a/cli_ure/source/climaker/climaker_share.h b/cli_ure/source/climaker/climaker_share.h
new file mode 100644
index 000000000000..bf04c92eb2ea
--- /dev/null
+++ b/cli_ure/source/climaker/climaker_share.h
@@ -0,0 +1,168 @@
+/*************************************************************************
+ *
+ * $RCSfile: climaker_share.h,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: dbo $ $Date: 2003-03-28 10:17:38 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#using <mscorlib.dll>
+#include <vcclr.h>
+
+#include "osl/diagnose.h"
+#include "com/sun/star/reflection/XConstantTypeDescription.hpp"
+#include "com/sun/star/reflection/XConstantsTypeDescription.hpp"
+#include "com/sun/star/reflection/XEnumTypeDescription.hpp"
+#include "com/sun/star/reflection/XInterfaceTypeDescription.hpp"
+#include "com/sun/star/reflection/XCompoundTypeDescription.hpp"
+
+#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
+
+
+namespace css = ::com::sun::star;
+
+namespace climaker
+{
+
+//--------------------------------------------------------------------------------------------------
+extern bool g_verbose;
+
+//--------------------------------------------------------------------------------------------------
+inline ::System::String * ustring_to_String( ::rtl::OUString const & ustr )
+{
+ return new ::System::String( ustr.getStr(), 0, ustr.getLength() );
+}
+//--------------------------------------------------------------------------------------------------
+inline ::rtl::OUString String_to_ustring( ::System::String * str )
+{
+ OSL_ASSERT( sizeof (wchar_t) == sizeof (sal_Unicode) );
+ wchar_t const __pin * chars = PtrToStringChars( str );
+ return ::rtl::OUString( chars, str->get_Length() );
+}
+
+//==================================================================================================
+__gc class TypeEmitter : public ::System::IDisposable
+{
+ const ::System::Reflection::MethodAttributes s_ctor_attr;
+
+ ::System::Reflection::Emit::ModuleBuilder * m_module_builder;
+ ::System::Reflection::Assembly * m_extra_assemblies __gc [];
+
+ ::System::Reflection::MethodInfo * m_method_info_Type_GetTypeFromHandle;
+
+ ::System::Type * m_type_Exception;
+ ::System::Type * get_type_Exception();
+ ::System::Type * m_type_RuntimeException;
+ ::System::Type * get_type_RuntimeException();
+ ::System::Reflection::ConstructorInfo * m_ctor_uno_MethodAttribute;
+ ::System::Reflection::ConstructorInfo * m_default_ctor_uno_MethodAttribute;
+ ::System::Reflection::ConstructorInfo * get_ctor_uno_MethodAttribute();
+ ::System::Type * m_type_Any;
+ ::System::Type * m_type_Any_ref;
+ ::System::Reflection::FieldInfo * m_field_Any_VOID;
+ void emit_Any_boxed_ctor(
+ ::System::Reflection::Emit::TypeBuilder * type_builder,
+ ::System::Reflection::Emit::FieldBuilder * field_Type,
+ ::System::Reflection::Emit::FieldBuilder * field_Value,
+ ::System::Type * integral_type );
+ ::System::Type * get_type_Any();
+
+ __gc class iface_entry
+ {
+ public:
+ css::reflection::XInterfaceTypeDescription * m_xType;
+ ::System::Reflection::Emit::TypeBuilder * m_type_builder;
+ };
+ ::System::Collections::Hashtable * m_incomplete_ifaces;
+ ::System::Type * complete_iface_type( iface_entry * entry );
+
+ __gc class struct_entry
+ {
+ public:
+ ::System::String * m_member_names __gc [];
+ ::System::Type * m_param_types __gc [];
+ ::System::Reflection::ConstructorInfo * m_default_ctor;
+ ::System::Reflection::ConstructorInfo * m_ctor;
+ };
+ ::System::Collections::Hashtable * m_generated_structs;
+
+ ::System::Type * get_type(
+ ::System::String * cli_name, bool throw_exc );
+ ::System::Type * get_type(
+ css::uno::Reference< css::reflection::XConstantTypeDescription > const & xType );
+ ::System::Type * get_type(
+ css::uno::Reference< css::reflection::XConstantsTypeDescription > const & xType );
+ ::System::Type * get_type(
+ css::uno::Reference< css::reflection::XEnumTypeDescription > const & xType );
+ ::System::Type * get_type(
+ css::uno::Reference< css::reflection::XCompoundTypeDescription > const & xType );
+ ::System::Type * get_type(
+ css::uno::Reference< css::reflection::XInterfaceTypeDescription > const & xType );
+public:
+ TypeEmitter(
+ ::System::Reflection::Emit::ModuleBuilder * module_builder,
+ ::System::Reflection::Assembly * assemblies __gc [] );
+ // must be called to finish up uncompleted types
+ void Dispose();
+
+ ::System::Reflection::Assembly * type_resolve(
+ ::System::Object * sender, ::System::ResolveEventArgs * args );
+
+ ::System::Type * get_type(
+ css::uno::Reference< css::reflection::XTypeDescription > const & xType );
+};
+
+}
diff --git a/cli_ure/source/climaker/makefile.mk b/cli_ure/source/climaker/makefile.mk
new file mode 100644
index 000000000000..d8736245b994
--- /dev/null
+++ b/cli_ure/source/climaker/makefile.mk
@@ -0,0 +1,122 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1 $
+#
+# last change: $Author: dbo $ $Date: 2003-03-28 10:17:38 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ = ..$/..
+PRJNAME = cli_ure
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+.IF "$(BUILD_FOR_CLI)" != ""
+
+TARGET = climaker
+TARGETTYPE = CUI
+LIBTARGET = NO
+ENABLE_EXCEPTIONS = TRUE
+
+.INCLUDE : settings.mk
+
+UNOUCRDEP = $(SOLARBINDIR)$/udkapi.rdb
+UNOUCRRDB = $(SOLARBINDIR)$/udkapi.rdb
+CPPUMAKERFLAGS =
+
+UNOTYPES = \
+ com.sun.star.uno.TypeClass \
+ com.sun.star.uno.XAggregation \
+ com.sun.star.uno.XWeak \
+ com.sun.star.uno.XComponentContext \
+ com.sun.star.lang.XTypeProvider \
+ com.sun.star.lang.XInitialization \
+ com.sun.star.lang.XComponent \
+ com.sun.star.lang.XMultiComponentFactory \
+ com.sun.star.container.XSet \
+ com.sun.star.container.XHierarchicalNameAccess \
+ com.sun.star.loader.XImplementationLoader \
+ com.sun.star.registry.XSimpleRegistry \
+ com.sun.star.registry.XRegistryKey \
+ com.sun.star.reflection.XTypeDescriptionEnumerationAccess \
+ com.sun.star.reflection.XConstantTypeDescription \
+ com.sun.star.reflection.XConstantsTypeDescription \
+ com.sun.star.reflection.XIndirectTypeDescription \
+ com.sun.star.reflection.XEnumTypeDescription \
+ com.sun.star.reflection.XInterfaceTypeDescription \
+ com.sun.star.reflection.XInterfaceMethodTypeDescription \
+ com.sun.star.reflection.XInterfaceAttributeTypeDescription \
+ com.sun.star.reflection.XCompoundTypeDescription \
+ com.sun.star.reflection.XEnumTypeDescription
+
+CFLAGS += -clr:noAssembly
+
+CXXFILES = \
+ climaker_emit.cxx \
+ climaker_app.cxx
+
+APP1TARGET = $(TARGET)
+APP1OBJS = $(foreach,i,$(subst,.cxx,.obj $(CXXFILES)) $(OBJ)$/$i)
+
+APP1STDLIBS = \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB) \
+ mscoree.lib
+
+.INCLUDE : target.mk
+
+.ENDIF
diff --git a/cli_ure/source/native/makefile.mk b/cli_ure/source/native/makefile.mk
new file mode 100644
index 000000000000..b65eb1c8ddbb
--- /dev/null
+++ b/cli_ure/source/native/makefile.mk
@@ -0,0 +1,112 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1 $
+#
+# last change: $Author: dbo $ $Date: 2003-03-28 10:17:40 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ = ..$/..
+PRJNAME = cli_ure
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+.IF "$(BUILD_FOR_CLI)" != ""
+
+TARGET = cppuhelper_cli
+NO_BSYMBOLIC = TRUE
+ENABLE_EXCEPTIONS = TRUE
+USE_DEFFILE = TRUE
+
+.INCLUDE : settings.mk
+
+UNOUCRRDB = $(SOLARBINDIR)$/udkapi.rdb
+UNOUCRDEP = $(UNOUCRRDB)
+UNOUCROUT = $(OUT)$/inc
+INCPRE += $(OUT)$/inc
+
+CPPUMAKERFLAGS =
+UNOTYPES = \
+ com.sun.star.lang.XSingleComponentFactory \
+ com.sun.star.loader.CannotActivateFactoryException \
+ com.sun.star.registry.CannotRegisterImplementationException \
+ com.sun.star.registry.XRegistryKey
+
+CFLAGS += -clr -AI $(OUT)$/bin
+
+SLOFILES = \
+ $(SLO)$/native_ure.obj \
+ $(SLO)$/native_bootstrap.obj
+
+SHL1TARGET = $(TARGET)$(UDK_MAJOR)$(COMID)
+
+SHL1STDLIBS = \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB) \
+ mscoree.lib
+
+SHL1VERSIONMAP = msvc.map
+
+SHL1DEPN =
+SHL1IMPLIB = i$(TARGET)
+SHL1LIBS = $(SLB)$/$(TARGET).lib
+SHL1DEF = $(MISC)$/$(SHL1TARGET).def
+DEF1NAME = $(SHL1TARGET)
+
+.INCLUDE : target.mk
+
+.ENDIF
diff --git a/cli_ure/source/native/msvc.map b/cli_ure/source/native/msvc.map
new file mode 100644
index 000000000000..3c77c20eed27
--- /dev/null
+++ b/cli_ure/source/native/msvc.map
@@ -0,0 +1,7 @@
+UDK_3.1 {
+ global:
+ ?ServiceFactory_load@util@uno@@YA?AV?$Reference@VXSingleComponentFactory@lang@star@sun@com@@@2star@sun@com@@ABVOUString@rtl@@@Z;
+ ?ServiceFactory_writeInfo@util@uno@@YAXABVOUString@rtl@@ABV?$Reference@VXRegistryKey@registry@star@sun@com@@@2star@sun@com@@@Z;
+ local:
+ *;
+};
diff --git a/cli_ure/source/native/native_bootstrap.cxx b/cli_ure/source/native/native_bootstrap.cxx
new file mode 100644
index 000000000000..14e5cc5f2724
--- /dev/null
+++ b/cli_ure/source/native/native_bootstrap.cxx
@@ -0,0 +1,148 @@
+/*************************************************************************
+ *
+ * $RCSfile: native_bootstrap.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: dbo $ $Date: 2003-03-28 10:17:40 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "native_share.h"
+
+#include "rtl/bootstrap.hxx"
+#include "cppuhelper/bootstrap.hxx"
+
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+namespace uno
+{
+namespace util
+{
+
+//==============================================================================
+__sealed __gc class Bootstrap
+{
+ inline Bootstrap();
+public:
+
+ /** Bootstraps the initial component context from a native UNO installation.
+
+ @see cppuhelper/defaultBootstrap_InitialComponentContext()
+ */
+ static ::unoidl::com::sun::star::uno::XComponentContext *
+ defaultBootstrap_InitialComponentContext();
+
+ /** Bootstraps the initial component context from a native UNO installation.
+
+ @param ini_file
+ ini_file (may be null: uno.rc besides cppuhelper lib)
+ @param bootstrap_parameters
+ bootstrap parameters (maybe null)
+
+ @see cppuhelper/defaultBootstrap_InitialComponentContext()
+ */
+ static ::unoidl::com::sun::star::uno::XComponentContext *
+ defaultBootstrap_InitialComponentContext(
+ ::System::String * ini_file,
+ ::System::Collections::IDictionaryEnumerator * bootstrap_parameters );
+};
+
+//______________________________________________________________________________
+::unoidl::com::sun::star::uno::XComponentContext *
+Bootstrap::defaultBootstrap_InitialComponentContext()
+{
+ return defaultBootstrap_InitialComponentContext( 0, 0 );
+}
+
+//______________________________________________________________________________
+::unoidl::com::sun::star::uno::XComponentContext *
+Bootstrap::defaultBootstrap_InitialComponentContext(
+ ::System::String * ini_file,
+ ::System::Collections::IDictionaryEnumerator * bootstrap_parameters )
+{
+ bootstrap_parameters->Reset();
+ while (bootstrap_parameters->MoveNext())
+ {
+ OUString key(
+ String_to_ustring(
+ __try_cast< ::System::String * >( bootstrap_parameters->get_Key() ) ) );
+ OUString value(
+ String_to_ustring(
+ __try_cast< ::System::String * >( bootstrap_parameters->get_Value() ) ) );
+// // xxx todo srx644 only
+// ::rtl::Bootstrap::set( key, value );
+ }
+
+ // bootstrap native uno
+ Reference< XComponentContext > xContext;
+ if (0 == ini_file)
+ {
+ xContext = ::cppu::defaultBootstrap_InitialComponentContext();
+ }
+ else
+ {
+ xContext = ::cppu::defaultBootstrap_InitialComponentContext(
+ String_to_ustring( __try_cast< ::System::String * >( ini_file ) ) );
+ }
+
+ return __try_cast< ::unoidl::com::sun::star::uno::XComponentContext * >(
+ to_cli( xContext ) );
+}
+
+}
+}
diff --git a/cli_ure/source/native/native_share.h b/cli_ure/source/native/native_share.h
new file mode 100644
index 000000000000..14f0e3cab528
--- /dev/null
+++ b/cli_ure/source/native/native_share.h
@@ -0,0 +1,137 @@
+/*************************************************************************
+ *
+ * $RCSfile: native_share.h,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: dbo $ $Date: 2003-03-28 10:17:41 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "rtl/ustring.hxx"
+#include "uno/mapping.hxx"
+
+#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
+
+#using <mscorlib.dll>
+#using <cli_ure.dll>
+#using <cli_udkapi.dll>
+#include <vcclr.h>
+
+
+namespace uno
+{
+namespace util
+{
+
+//------------------------------------------------------------------------------
+inline ::System::String * ustring_to_String( ::rtl::OUString const & ustr )
+{
+ return new ::System::String( ustr.getStr(), 0, ustr.getLength() );
+}
+//------------------------------------------------------------------------------
+inline ::rtl::OUString String_to_ustring( ::System::String * str )
+{
+ OSL_ASSERT( sizeof (wchar_t) == sizeof (sal_Unicode) );
+ wchar_t const __pin * chars = PtrToStringChars( str );
+ return ::rtl::OUString( chars, str->get_Length() );
+}
+
+//------------------------------------------------------------------------------
+::com::sun::star::uno::Mapping const & get_uno_to_cli();
+//------------------------------------------------------------------------------
+::com::sun::star::uno::Mapping const & get_cli_to_uno();
+
+template< typename T >
+inline ::System::Object * to_cli(
+ ::com::sun::star::uno::Reference< T > const & x )
+{
+ intptr_t intptr =
+ reinterpret_cast< intptr_t >(
+ get_uno_to_cli().mapInterface( x.get(), ::getCppuType( &x ) ) );
+ ::System::Runtime::InteropServices::GCHandle handle(
+ ::System::Runtime::InteropServices::GCHandle::op_Explicit( intptr ) );
+ ::System::Object * ret = handle.get_Target();
+ handle.Free();
+ return ret;
+}
+
+template< typename T >
+inline void to_uno(
+ ::com::sun::star::uno::Reference< T > * pRet, ::System::Object * x )
+{
+ ::com::sun::star::uno::Mapping const & mapping = get_cli_to_uno();
+ ::System::Runtime::InteropServices::GCHandle handle(
+ ::System::Runtime::InteropServices::GCHandle::Alloc( x ) );
+ T * ret = 0;
+ mapping.mapInterface(
+ reinterpret_cast< void ** >( &ret ),
+ reinterpret_cast< void * >(
+ ::System::Runtime::InteropServices::GCHandle::op_Explicit( handle )
+#if defined _WIN32
+ .ToInt32()
+#elif defined _WIN64
+ .ToInt64()
+#else
+#error ERROR: either _WIN64 or _WIN32 must be defined
+ ERROR: either _WIN64 or _WIN32 must be defined
+#endif
+ ),
+ ::getCppuType( pRet ) );
+ handle.Free();
+ pRet->set( ret, SAL_NO_ACQUIRE /* takeover ownership */ );
+}
+
+}
+}
diff --git a/cli_ure/source/ure/makefile.mk b/cli_ure/source/ure/makefile.mk
new file mode 100644
index 000000000000..ae8c7fc7547f
--- /dev/null
+++ b/cli_ure/source/ure/makefile.mk
@@ -0,0 +1,101 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1 $
+#
+# last change: $Author: dbo $ $Date: 2003-03-28 10:17:42 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ = ..$/..
+PRJNAME = cli_ure
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+.IF "$(BUILD_FOR_CLI)" != ""
+
+# for dummy
+TARGET = cli_ure
+
+.INCLUDE : settings.mk
+
+.INCLUDE : $(PRJ)$/util$/target.pmk
+.INCLUDE : target.mk
+
+CLI_URE = $(OUT)$/bin$/cli_ure.dll
+
+ALLTAR : \
+ $(CLI_URE)
+
+CSFILES = \
+ uno$/QueryInterface.cs \
+ uno$/Runtime.cs \
+ uno$/util$/ServiceImplementationAttribute.cs \
+ uno$/util$/DisposeGuard.cs \
+ uno$/util$/WeakAdapter.cs \
+ uno$/util$/WeakBase.cs \
+ uno$/util$/WeakComponentBase.cs \
+ uno$/util$/ServiceBase.cs \
+ uno$/util$/ServiceFactory.cs
+
+$(CLI_URE) : $(CLI_UDKAPI) $(CSFILES)
+ +csc.exe $(CSCFLAGS) \
+ -target:library \
+ -out:$@ \
+ -reference:$(CLI_UDKAPI) \
+ -reference:System.dll \
+ $(CSFILES)
+
+.ENDIF
diff --git a/cli_ure/source/ure/uno/util/DisposeGuard.cs b/cli_ure/source/ure/uno/util/DisposeGuard.cs
new file mode 100644
index 000000000000..a3c38e828136
--- /dev/null
+++ b/cli_ure/source/ure/uno/util/DisposeGuard.cs
@@ -0,0 +1,101 @@
+/*************************************************************************
+ *
+ * $RCSfile: DisposeGuard.cs,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: dbo $ $Date: 2003-03-28 10:17:44 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+using System;
+using unoidl.com.sun.star.lang;
+
+namespace uno.util
+{
+
+/** Helper class to conveniently auto dispose UNO objects from within
+ managed code.
+*/
+public struct DisposeGuard : IDisposable
+{
+ private XComponent m_xComponent;
+
+ /** ctor.
+
+ @param obj target object
+ */
+ public DisposeGuard( Object obj )
+ {
+ m_xComponent = (XComponent) uno.Runtime.queryInterface_throw( typeof (XComponent), obj );
+ }
+ /** ctor.
+
+ @param obj target object
+ */
+ public DisposeGuard( XComponent obj )
+ {
+ m_xComponent = obj;
+ }
+
+ /** System.IDisposable impl
+ */
+ public void Dispose()
+ {
+ if (null != m_xComponent)
+ m_xComponent.dispose();
+ }
+}
+
+}
diff --git a/cli_ure/source/ure/uno/util/WeakAdapter.cs b/cli_ure/source/ure/uno/util/WeakAdapter.cs
new file mode 100644
index 000000000000..3089cc5f4cac
--- /dev/null
+++ b/cli_ure/source/ure/uno/util/WeakAdapter.cs
@@ -0,0 +1,152 @@
+/*************************************************************************
+ *
+ * $RCSfile: WeakAdapter.cs,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: dbo $ $Date: 2003-03-28 10:17:46 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+using System;
+using unoidl.com.sun.star.uno;
+using unoidl.com.sun.star.lang;
+
+namespace uno.util
+{
+
+/** An XAdapter implementation that holds a weak reference
+ (System.WeakReference) to an object.
+ Clients can register listeners (unoidl.com.sun.star.lang.XReference)
+ which are notified when the object (the one which is kept weak) is
+ being finalized. That is, that object is being destroyed because there
+ are not any hard references to it.
+*/
+public class WeakAdapter : XAdapter
+{
+ // references the XWeak implementation
+ private WeakReference m_weakRef;
+ // contains XReference objects registered by addReference
+ private delegate void XReference_dispose();
+ private XReference_dispose m_XReference_dispose;
+
+ /** ctor.
+
+ @param obj the object that is to be held weakly
+ */
+ public WeakAdapter( Object obj )
+ {
+ m_weakRef = new WeakReference( obj );
+ m_XReference_dispose = null;
+ }
+
+ /** Called by the XWeak implementation (WeakBase) when it is being
+ finalized. It is only being called once.
+ The registererd XReference listeners are notified. On notification
+ they are to unregister themselves. The notification is thread-safe.
+ However, it is possible to add a listener during the notification
+ process, which will never receive a notification.
+ To prevent this, one would have to synchronize this method with
+ the addReference method. But this can result in deadlocks in a
+ multithreaded environment.
+ */
+ internal /* non-virtual */ void referentDying()
+ {
+ XReference_dispose call;
+ lock (this)
+ {
+ call = m_XReference_dispose;
+ m_XReference_dispose = null;
+ }
+ if (null != call)
+ call();
+ }
+
+ // XAdapter impl
+
+ /** Called to obtain a hard reference o the object which is kept weakly
+ by this instance.
+
+ @return hard reference to the object
+ */
+ public Object queryAdapted()
+ {
+ return m_weakRef.Target;
+ }
+ /** Called by clients to register listener which are notified when the
+ weak object is dying.
+
+ @param xReference a listener
+ */
+ public void removeReference( XReference xReference )
+ {
+ lock (this)
+ {
+ m_XReference_dispose -= new XReference_dispose( xReference.dispose );
+ }
+ }
+ /** Called by clients to unregister listeners.
+
+ @param xReference a listener
+ */
+ public void addReference( XReference xReference )
+ {
+ lock (this)
+ {
+ m_XReference_dispose += new XReference_dispose( xReference.dispose );
+ }
+ }
+}
+
+}
diff --git a/cli_ure/source/ure/uno/util/WeakBase.cs b/cli_ure/source/ure/uno/util/WeakBase.cs
new file mode 100644
index 000000000000..28725474a8d9
--- /dev/null
+++ b/cli_ure/source/ure/uno/util/WeakBase.cs
@@ -0,0 +1,212 @@
+/*************************************************************************
+ *
+ * $RCSfile: WeakBase.cs,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $ $Date: 2003-03-28 10:17:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+using System;
+using System.Collections;
+using unoidl.com.sun.star.uno;
+using unoidl.com.sun.star.lang;
+
+namespace uno.util
+{
+
+/** This class can be used as a base class for UNO objects.
+ It implements the capability to be kept weakly
+ (unoidl.com.sun.star.uno.XWeak) and it implements
+ unoidl.com.sun.star.lang.XTypeProvider which is necessary for
+ using the object from StarBasic.
+*/
+public class WeakBase : XWeak, XTypeProvider
+{
+ // Contains all WeakAdapter which have been created in this class
+ // They have to be notified when this object dies
+ private WeakAdapter m_adapter;
+
+ protected static Hashtable s_types = new Hashtable();
+ protected static Hashtable s_impl_ids = new Hashtable();
+
+ // XWeak impl
+ /** The returned XAdapter implementation can be used to keap a
+ weak reference to this object.
+
+ @return a weak adapter
+ */
+ public XAdapter queryAdapter()
+ {
+ if (null == m_adapter)
+ {
+ lock (this)
+ {
+ if (null == m_adapter)
+ m_adapter = new WeakAdapter( this );
+ }
+ }
+ return m_adapter;
+ }
+
+ /** Overrides of Object.Finalize method.
+ When there are no references to this object anymore, then the
+ garbage collector calls this method, thereby causing the adapter
+ object to be notified. The adapter, in turn, notifies all
+ listeners (unoidl.com.sun.star.uno.XReference).
+ */
+ ~WeakBase()
+ {
+ if (null != m_adapter)
+ m_adapter.referentDying();
+ }
+
+ // XTypeProvider impl
+
+ /** Returns an array of Type objects which represent all implemented
+ UNO interfaces of this object.
+
+ @return Type objects of all implemented interfaces.
+ */
+ public Type [] getTypes()
+ {
+ Type [] types;
+ Type type = GetType();
+ lock (s_types)
+ {
+ types = (Type []) s_types[ type ];
+ if (null == types)
+ {
+ Type [] interfaces = type.GetInterfaces();
+ ArrayList list = new ArrayList( interfaces.Length );
+ for ( Int32 pos = 0; pos < interfaces.Length; ++pos )
+ {
+ Type iface = interfaces[ pos ];
+ // xxx todo: as long as the bridge cannot introduce
+ // native CTS types into UNO on the fly
+ if (iface.FullName.StartsWith( "unoidl." ))
+ {
+ list.Add( iface );
+ }
+ }
+ Int32 len = list.Count;
+ Type [] ar = new Type [ len ];
+ for ( Int32 pos = 0; pos < len; ++pos )
+ ar[ pos ] = (Type) list[ pos ];
+ s_types[ type ] = ar;
+ types = ar;
+ }
+ }
+ return types;
+ }
+
+ /** Provides an identifier that represents the set of UNO interfaces
+ implemented by this class. All instances of this class which run
+ in the same CLR return the same array.
+
+ @return identifier as array of bytes
+ */
+ public byte [] getImplementationId()
+ {
+ byte [] id;
+ Type type = GetType();
+ lock (s_impl_ids)
+ {
+ id = (byte []) s_impl_ids[ type ];
+ if (null == id)
+ {
+ Int32 hash = GetHashCode();
+ String name = type.FullName;
+ Int32 len= name.Length;
+
+ id = new byte[ 4 + (2 * len) ];
+ id[ 0 ]= (byte) (hash & 0xff);
+ id[ 1 ]= (byte) ((hash >> 8) & 0xff);
+ id[ 2 ]= (byte) ((hash >> 16) & 0xff);
+ id[ 3 ]= (byte) ((hash >> 24) & 0xff);
+
+ for ( Int32 pos = 0; pos < len; ++pos )
+ {
+ UInt16 c = Convert.ToUInt16( name[ pos ] );
+ id[ 4 + (2 * pos) ] = (byte) (c & 0xff);
+ id[ 4 + (2 * pos) +1 ] = (byte) ((c >> 8) & 0xff);
+ }
+ s_impl_ids[ type ] = id;
+ }
+ }
+ return id;
+ }
+
+ // System.Object
+ //______________________________________________________________________________________________
+ public override String ToString()
+ {
+ System.Text.StringBuilder buf = new System.Text.StringBuilder( base.ToString(), 256 );
+ buf.Append( "\nUNO Object Implementation:\n\tImplementationId: " );
+ buf.Append( getImplementationId() );
+ buf.Append( "\n\tInterfaces: " );
+ Type [] types = getTypes();
+ for ( Int32 pos = 0; pos < types.Length; ++pos )
+ {
+ buf.Append( types[ pos ].FullName );
+ if (pos < (types.Length -1))
+ buf.Append( ", " );
+ }
+ return buf.ToString();
+ }
+}
+
+}
+
diff --git a/cli_ure/source/ure/uno/util/WeakComponentBase.cs b/cli_ure/source/ure/uno/util/WeakComponentBase.cs
new file mode 100644
index 000000000000..ed20c681e180
--- /dev/null
+++ b/cli_ure/source/ure/uno/util/WeakComponentBase.cs
@@ -0,0 +1,143 @@
+/*************************************************************************
+ *
+ * $RCSfile: WeakComponentBase.cs,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: dbo $ $Date: 2003-03-28 10:17:48 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+using System;
+using unoidl.com.sun.star.lang;
+
+namespace uno.util
+{
+
+/** This class can be used as a base class for UNO objects.
+ It implements the capability to be kept weakly
+ (unoidl.com.sun.star.uno.XWeak) and it implements
+ unoidl.com.sun.star.lang.XTypeProvider which is necessary for
+ using the object from StarBasic.
+ In addition, it implements the interface
+ unoidl.com.sun.star.lang.XComponent to be disposed explicitly.
+*/
+public class WeakComponentBase : WeakBase, XComponent, IDisposable
+{
+ private delegate void t_disposing( EventObject evt );
+ private t_disposing m_disposing = null;
+
+ /** Disposing callback called when the object is being disposed.
+ This method has to be implemented by sub classes.
+ */
+ protected virtual void disposing()
+ {
+ }
+
+ // XComponent impl
+ /** This method is called by the owner of this object to explicitly
+ dispose it. This implementation of dispose() first notifies all
+ registered event listeners and finally this object by calling its
+ protected disposing().
+ */
+ public void dispose()
+ {
+ // send disposing notifications to listeners
+ t_disposing call;
+ lock (this)
+ {
+ call = m_disposing;
+ m_disposing = null;
+ }
+ if (null != call)
+ {
+ EventObject evt = new EventObject( this );
+ call( evt );
+ }
+ // call sub class
+ disposing();
+ }
+ /** Registers an event listener being notified when this object is disposed.
+
+ @param xListener event listener
+ */
+ public void addEventListener( XEventListener xListener )
+ {
+ lock (this)
+ {
+ m_disposing += new t_disposing( xListener.disposing );
+ }
+ }
+ /** Revokes an event listener from being notified when this object is disposed.
+
+ @param xListener event listener
+ */
+ public void removeEventListener( XEventListener xListener )
+ {
+ lock (this)
+ {
+ m_disposing -= new t_disposing( xListener.disposing );
+ }
+ }
+
+ /** System.IDisposable implementation to conveniently auto dispose
+ UNO objects within CLI code.
+ */
+ public void Dispose()
+ {
+ dispose();
+ }
+}
+
+}
diff --git a/cli_ure/unotypes/makefile.mk b/cli_ure/unotypes/makefile.mk
new file mode 100644
index 000000000000..72a643d7d775
--- /dev/null
+++ b/cli_ure/unotypes/makefile.mk
@@ -0,0 +1,95 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1 $
+#
+# last change: $Author: dbo $ $Date: 2003-03-28 10:17:50 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ = ..
+PRJNAME = cli_ure
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+.IF "$(BUILD_FOR_CLI)" != ""
+
+# for dummy
+TARGET = cli_ure
+
+.INCLUDE : settings.mk
+
+.INCLUDE : $(PRJ)$/util$/target.pmk
+.INCLUDE : target.mk
+
+ALLTAR : \
+ $(CLI_OFFAPI)
+
+$(CLI_UDKAPI) : $(SOLARBINDIR)$/udkapi.rdb
+ +$(CLIMAKER) -O $@ $(CLIMAKER_FLAGS) \
+ --version "3.1.0.0" \
+ --product "OpenOffice.org SDK" \
+ --description "This assembly contains UNO-API metadata of the OpenOffice.org Software Development Kit (SDK)." \
+ $(SOLARBINDIR)$/udkapi.rdb
+
+$(CLI_OFFAPI) : $(CLI_UDKAPI) $(SOLARBINDIR)$/offapi.rdb
+ +$(CLIMAKER) -O $@ $(CLIMAKER_FLAGS) \
+ --version "1.0.0.0" \
+ --product "OpenOffice.org SDK" \
+ --description "This assembly contains API metadata of the OpenOffice.org Software Development Kit (SDK)." \
+ --reference $(CLI_UDKAPI) \
+ -X $(SOLARBINDIR)$/udkapi.rdb $(SOLARBINDIR)$/offapi.rdb
+
+.ENDIF
diff --git a/cli_ure/util/makefile.pmk b/cli_ure/util/makefile.pmk
new file mode 100644
index 000000000000..b47d3926d3d4
--- /dev/null
+++ b/cli_ure/util/makefile.pmk
@@ -0,0 +1,70 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.pmk,v $
+#
+# $Revision: 1.1 $
+#
+# last change: $Author: dbo $ $Date: 2003-03-28 10:17:51 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+.IF "$(COM)$(COMEX)" == "MSC8"
+BUILD_FOR_CLI = "true"
+.ENDIF
+
+CLIMAKER = $(OUT)$/bin$/climaker.exe
+CLI_UDKAPI = $(OUT)$/bin$/cli_udkapi.dll
+CLI_OFFAPI = $(OUT)$/bin$/cli_offapi.dll
+
diff --git a/cli_ure/util/target.pmk b/cli_ure/util/target.pmk
new file mode 100644
index 000000000000..e443eb5fbd69
--- /dev/null
+++ b/cli_ure/util/target.pmk
@@ -0,0 +1,87 @@
+#*************************************************************************
+#
+# $RCSfile: target.pmk,v $
+#
+# $Revision: 1.1 $
+#
+# last change: $Author: dbo $ $Date: 2003-03-28 10:17:51 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+###### C# ######
+
+CSCFLAGS = -warnaserror+ -incremental-
+
+.IF "$(debug)" == ""
+
+.IF "$(product)" == ""
+CSCFLAGS += -checked+ -define:DEBUG -define:TRACE
+.ELSE
+CSCFLAGS += -o
+.ENDIF
+
+.ELSE # DEBUG
+
+CSCFLAGS += -debug+ -checked+ -define:DEBUG -define:TRACE
+
+.ENDIF
+
+###### climaker ######
+
+CLIMAKER_FLAGS =
+.IF "$(debug)" != ""
+CLIMAKER_FLAGS += --verbose
+.ENDIF
+