summaryrefslogtreecommitdiff
path: root/codemaker
diff options
context:
space:
mode:
authorJens-Heiner Rechtien <hr@openoffice.org>2000-09-18 14:29:57 +0000
committerJens-Heiner Rechtien <hr@openoffice.org>2000-09-18 14:29:57 +0000
commitb525a3115f54576017a576ff842dede5e2e3545d (patch)
treec534b95a9e572b63896467624293a5ca1887d3a3 /codemaker
parent9399c662f36c385b0c705eb34e636a9aec450282 (diff)
initial import
Diffstat (limited to 'codemaker')
-rw-r--r--codemaker/inc/codemaker/global.hxx152
-rw-r--r--codemaker/inc/codemaker/options.hxx141
-rw-r--r--codemaker/inc/codemaker/typemanager.hxx212
-rw-r--r--codemaker/prj/d.lst8
-rw-r--r--codemaker/source/codemaker/global.cxx377
-rw-r--r--codemaker/source/codemaker/makefile.mk92
-rw-r--r--codemaker/source/codemaker/options.cxx138
-rw-r--r--codemaker/source/codemaker/typemanager.cxx322
-rw-r--r--codemaker/source/cppumaker/cppumaker.cxx222
-rw-r--r--codemaker/source/cppumaker/cppuoptions.cxx340
-rw-r--r--codemaker/source/cppumaker/cppuoptions.hxx85
-rw-r--r--codemaker/source/cppumaker/cpputype.cxx3838
-rw-r--r--codemaker/source/cppumaker/cpputype.hxx325
-rw-r--r--codemaker/source/cppumaker/makefile.mk104
-rw-r--r--codemaker/source/javamaker/javamaker.cxx222
-rw-r--r--codemaker/source/javamaker/javaoptions.cxx246
-rw-r--r--codemaker/source/javamaker/javaoptions.hxx85
-rw-r--r--codemaker/source/javamaker/javatype.cxx1977
-rw-r--r--codemaker/source/javamaker/javatype.hxx342
-rw-r--r--codemaker/source/javamaker/makefile.mk104
20 files changed, 9332 insertions, 0 deletions
diff --git a/codemaker/inc/codemaker/global.hxx b/codemaker/inc/codemaker/global.hxx
new file mode 100644
index 000000000000..6eeb66576a78
--- /dev/null
+++ b/codemaker/inc/codemaker/global.hxx
@@ -0,0 +1,152 @@
+/*************************************************************************
+ *
+ * $RCSfile: global.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:26 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CODEMAKER_GLOBAL_HXX_
+#define _CODEMAKER_GLOBAL_HXX_
+
+#include <list>
+#include <vector>
+#include <set>
+
+#include <fstream.h>
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#ifndef _VOS_MACROS_HXX_
+#include <vos/macros.hxx>
+#endif
+
+
+struct EqualString
+{
+ sal_Bool operator()(const ::rtl::OString& str1, const ::rtl::OString& str2) const
+ {
+ return (str1 == str2);
+ }
+};
+
+struct HashString
+{
+ size_t operator()(const ::rtl::OString& str) const
+ {
+ return str.hashCode();
+ }
+};
+
+struct LessString
+{
+ sal_Bool operator()(const ::rtl::OString& str1, const ::rtl::OString& str2) const
+ {
+ return (str1 < str2);
+ }
+};
+
+#if defined(_MSC_VER) && _MSC_VER < 1200
+typedef NAMESPACE_STD(new_alloc) NewAlloc;
+#endif
+
+
+typedef NAMESPACE_STD(list) < ::rtl::OString > StringList;
+typedef NAMESPACE_STD(vector)< ::rtl::OString > StringVector;
+typedef NAMESPACE_STD(set) < ::rtl::OString, LessString > StringSet;
+
+::rtl::OString makeTempName(sal_Char* prefix);
+
+::rtl::OString createFileNameFromType(const ::rtl::OString& destination,
+ const ::rtl::OString type,
+ const ::rtl::OString postfix,
+ sal_Bool bLowerCase=sal_False,
+ const ::rtl::OString prefix="");
+
+sal_Bool fileExists(const ::rtl::OString& fileName);
+sal_Bool checkFileContent(const ::rtl::OString& targetFileName, const ::rtl::OString& tmpFileName);
+
+const ::rtl::OString inGlobalSet(const ::rtl::OUString & r);
+inline const ::rtl::OString inGlobalSet(sal_Char* p)
+{
+ return inGlobalSet( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(p) ) );
+}
+
+//*************************************************************************
+// FileStream
+//*************************************************************************
+class FileStream : public ofstream
+{
+public:
+ FileStream();
+ FileStream(const ::rtl::OString& name, sal_Int32 nMode = ios::out | ios::trunc);
+ virtual ~FileStream();
+
+ sal_Bool isValid();
+
+ void openFile(const ::rtl::OString& name, sal_Int32 nMode = ios::out | ios::trunc);
+ void closeFile();
+
+ sal_Int32 getSize();
+ ::rtl::OString getName() { return m_name; }
+protected:
+ ::rtl::OString m_name;
+};
+
+#endif // _CODEMAKER_GLOBAL_HXX_
+
diff --git a/codemaker/inc/codemaker/options.hxx b/codemaker/inc/codemaker/options.hxx
new file mode 100644
index 000000000000..e7553f9fcd33
--- /dev/null
+++ b/codemaker/inc/codemaker/options.hxx
@@ -0,0 +1,141 @@
+/*************************************************************************
+ *
+ * $RCSfile: options.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:26 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CODEMAKER_OPTIONS_HXX_
+#define _CODEMAKER_OPTIONS_HXX_
+
+#include <hash_map>
+
+#ifndef _CODEMAKER_GLOBAL_HXX_
+#include <codemaker/global.hxx>
+#endif
+
+#if defined( _MSC_VER ) && ( _MSC_VER < 1200 )
+typedef NAMESPACE_STD(__hash_map__)
+<
+ ::rtl::OString,
+ ::rtl::OString,
+ HashString,
+ EqualString,
+ NewAlloc
+> OptionMap;
+#else
+typedef NAMESPACE_STD(hash_map)
+<
+ ::rtl::OString,
+ ::rtl::OString,
+ HashString,
+ EqualString
+> OptionMap;
+#endif
+
+class CannotDumpException
+{
+public:
+ CannotDumpException(const ::rtl::OString& msg)
+ : m_message(msg) {}
+
+ ::rtl::OString m_message;
+};
+
+
+class IllegalArgument
+{
+public:
+ IllegalArgument(const ::rtl::OString& msg)
+ : m_message(msg) {}
+
+ ::rtl::OString m_message;
+};
+
+
+class Options
+{
+public:
+ Options();
+ ~Options();
+
+ virtual sal_Bool initOptions(int ac, char* av[], sal_Bool bCmdFile=sal_False)
+ throw( IllegalArgument ) = 0;
+
+ virtual ::rtl::OString prepareHelp() = 0;
+
+ const ::rtl::OString& getProgramName() const;
+ sal_uInt16 getNumberOfOptions() const;
+ sal_Bool isValid(const ::rtl::OString& option);
+ const ::rtl::OString getOption(const ::rtl::OString& option)
+ throw( IllegalArgument );
+ const OptionMap& getOptions();
+
+ sal_uInt16 getNumberOfInputFiles() const;
+ const ::rtl::OString getInputFile(sal_uInt16 index)
+ throw( IllegalArgument );
+
+ const StringVector& getInputFiles();
+
+protected:
+ ::rtl::OString m_program;
+ StringVector m_inputFiles;
+ OptionMap m_options;
+};
+
+#endif // _CODEMAKER_OPTIONS_HXX_
+
diff --git a/codemaker/inc/codemaker/typemanager.hxx b/codemaker/inc/codemaker/typemanager.hxx
new file mode 100644
index 000000000000..593e432c8ae9
--- /dev/null
+++ b/codemaker/inc/codemaker/typemanager.hxx
@@ -0,0 +1,212 @@
+/*************************************************************************
+ *
+ * $RCSfile: typemanager.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:26 $
+ *
+ * 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 <hash_map>
+
+#ifndef _CODEMAKER_TYPEMANAGER_HXX_
+#define _CODEMAKER_TYPEMANAGER_HXX_
+
+#ifndef _CODEMAKER_REGISTRY_HXX_
+#include <codemaker/registry.hxx>
+#endif
+
+RegistryTypeReaderLoader & getRegistryTypeReaderLoader();
+
+
+typedef NAMESPACE_STD(list) <Registry*> RegistryList;
+
+#if defined( _MSC_VER ) && ( _MSC_VER < 1200 )
+typedef NAMESPACE_STD(__hash_map__)
+<
+ ::rtl::OString, // Typename
+ RTTypeClass, // TypeClass
+ HashString,
+ EqualString,
+ NewAlloc
+> T2TypeClassMap;
+#else
+typedef NAMESPACE_STD(hash_map)
+<
+ ::rtl::OString, // Typename
+ RTTypeClass, // TypeClass
+ HashString,
+ EqualString
+> T2TypeClassMap;
+#endif
+
+struct TypeManagerImpl
+{
+ TypeManagerImpl()
+ : m_refCount(0)
+ {}
+
+ sal_Int32 m_refCount;
+};
+
+class TypeManager
+{
+public:
+ TypeManager();
+ ~TypeManager();
+
+ TypeManager( const TypeManager& value )
+ : m_pImpl( value.m_pImpl )
+ {
+ acquire();
+ }
+
+ TypeManager& operator = ( const TypeManager& value )
+ {
+ release();
+ m_pImpl = value.m_pImpl;
+ acquire();
+ return *this;
+ }
+
+ virtual sal_Bool init(sal_Bool bMerge, const StringVector& regFiles)
+ { return sal_False; }
+ virtual sal_Bool init(const ::rtl::OString& registryName)
+ { return sal_False; }
+
+ virtual sal_Bool isValidType(const ::rtl::OString& name)
+ { return sal_False; }
+
+ virtual RegistryKey getTypeKey(const ::rtl::OString& name)
+ { return RegistryKey(); }
+ virtual TypeReader getTypeReader(const ::rtl::OString& name)
+ { return TypeReader(); }
+ virtual RTTypeClass getTypeClass(const ::rtl::OString& name)
+ { return RT_TYPE_INVALID; }
+
+ virtual void setBase(const ::rtl::OString& base) {}
+ virtual ::rtl::OString getBase() { return ::rtl::OString(); }
+
+ virtual sal_Int32 getSize() { return 0; }
+
+protected:
+ sal_Int32 acquire();
+ sal_Int32 release();
+
+protected:
+ TypeManagerImpl* m_pImpl;
+};
+
+struct RegistryTypeManagerImpl
+{
+ RegistryTypeManagerImpl()
+ : m_pMergedRegistry(NULL)
+ , m_isMerged(sal_False)
+ , m_base("/")
+ {}
+
+ T2TypeClassMap m_t2TypeClass;
+ RegistryList m_registries;
+ Registry* m_pMergedRegistry;
+ ::rtl::OString m_base;
+ sal_Bool m_isMerged;
+};
+
+class RegistryTypeManager : public TypeManager
+{
+public:
+ RegistryTypeManager();
+ ~RegistryTypeManager();
+
+ RegistryTypeManager( const RegistryTypeManager& value )
+ : TypeManager(value)
+ , m_pImpl( value.m_pImpl )
+ {
+ acquire();
+ }
+/*
+ RegistryTypeManager& operator = ( const RegistryTypeManager& value )
+ {
+ release();
+ m_pImpl = value.m_pImpl;
+ acquire();
+ return *this;
+ }
+*/
+ sal_Bool init(sal_Bool bMerge, const StringVector& regFiles);
+
+ sal_Bool isValidType(const ::rtl::OString& name)
+ { return searchTypeKey(name).isValid(); }
+ RegistryKey getTypeKey(const ::rtl::OString& name)
+ { return searchTypeKey(name); }
+ TypeReader getTypeReader(const ::rtl::OString& name);
+ RTTypeClass getTypeClass(const ::rtl::OString& name);
+
+ void setBase(const ::rtl::OString& base);
+ ::rtl::OString getBase() { return m_pImpl->m_base; }
+
+ sal_Int32 getSize() { return m_pImpl->m_t2TypeClass.size(); }
+protected:
+ RegistryKey searchTypeKey(const ::rtl::OString& name);
+ void freeRegistries();
+
+ void acquire();
+ void release();
+
+protected:
+ RegistryTypeManagerImpl* m_pImpl;
+};
+
+#endif // _CODEMAKER_TYPEMANAGER_HXX_
diff --git a/codemaker/prj/d.lst b/codemaker/prj/d.lst
new file mode 100644
index 000000000000..4c6d45c5d177
--- /dev/null
+++ b/codemaker/prj/d.lst
@@ -0,0 +1,8 @@
+..\%__SRC%\bin\cppumaker.exe %_DEST%\bin%_EXT%\cppumaker.exe
+..\%__SRC%\bin\cppumaker.pdb %_DEST%\bin%_EXT%\cppumaker.pdb
+..\%__SRC%\bin\javamaker.exe %_DEST%\bin%_EXT%\javamaker.exe
+..\%__SRC%\bin\javamaker.pdb %_DEST%\bin%_EXT%\javamaker.pdb
+
+..\%__SRC%\bin\cppumaker %_DEST%\bin%_EXT%\cppumaker
+..\%__SRC%\bin\javamaker %_DEST%\bin%_EXT%\javamaker
+
diff --git a/codemaker/source/codemaker/global.cxx b/codemaker/source/codemaker/global.cxx
new file mode 100644
index 000000000000..83d0366dffaa
--- /dev/null
+++ b/codemaker/source/codemaker/global.cxx
@@ -0,0 +1,377 @@
+/*************************************************************************
+ *
+ * $RCSfile: global.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _VOS_PROCESS_HXX_
+#include <vos/process.hxx>
+#endif
+#ifndef _RTL_OSTRINGBUFFER_HXX_
+#include <rtl/strbuf.hxx>
+#endif
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#if defined(SAL_W32) || defined(SAL_OS2)
+#include <io.h>
+#include <direct.h>
+#include <errno.h>
+#endif
+
+#ifdef UNX
+#include <sys/stat.h>
+#include <errno.h>
+#include <unistd.h>
+#endif
+
+#ifndef _CODEMAKER_GLOBAL_HXX_
+#include <codemaker/global.hxx>
+#endif
+
+using namespace vos;
+using namespace rtl;
+
+OString makeTempName(sal_Char* prefix)
+{
+ static OUString uTMP( RTL_CONSTASCII_USTRINGPARAM("TMP") );
+ static OUString uTEMP( RTL_CONSTASCII_USTRINGPARAM("TEMP") );
+ OUString uPrefix( RTL_CONSTASCII_USTRINGPARAM("cmk_") );
+ OUString uPattern;
+
+ sal_Char* pPrefix = "cmk_";
+ sal_Char tmpPattern[512];
+ sal_Char *pTmpName = NULL;
+
+ if (prefix)
+ pPrefix = prefix;
+
+ OStartupInfo StartupInfo;
+
+ if (StartupInfo.getEnvironment(uTMP, uPattern) != OStartupInfo::E_None)
+ {
+ if (StartupInfo.getEnvironment(uTEMP, uPattern) != OStartupInfo::E_None)
+ {
+#if defined(WIN32) || defined(WNT) || defined(OS2)
+ strcpy(tmpPattern, ".");
+#else
+ strcpy(tmpPattern, "/tmp");
+#endif
+ }
+ }
+
+ if (uPattern.getLength())
+ {
+ strcpy(tmpPattern, OUStringToOString(uPattern, RTL_TEXTENCODING_UTF8).getStr());
+ }
+
+#ifdef SAL_W32
+ strcat(tmpPattern, "\\");
+ strcat(tmpPattern, pPrefix);
+ strcat(tmpPattern, "XXXXXX");
+ pTmpName = mktemp(tmpPattern);
+#endif
+
+#ifdef SAL_OS2
+ strcpy(tmpPattern, tempnam(NULL, prefix);
+ pTmpName = tmpPattern;
+#endif
+
+#ifdef SAL_UNX
+ strcat(tmpPattern, "\\");
+ strcat(tmpPattern, pPrefix);
+ strcat(tmpPattern, "XXXXXX");
+ pTmpName = mktemp(tmpPattern);
+#endif
+
+ return OString(pTmpName);
+}
+
+OString createFileNameFromType( const OString& destination,
+ const OString typeName,
+ const OString postfix,
+ sal_Bool bLowerCase,
+ const OString prefix )
+{
+ OString type(typeName);
+
+ if (bLowerCase)
+ {
+ type = typeName.toLowerCase();
+ }
+
+ sal_uInt32 length = destination.getLength();
+
+ sal_Bool withPoint = sal_False;
+ if (length == 0)
+ {
+ length++;
+ withPoint = sal_True;
+ }
+
+ length += prefix.getLength() + type.getLength() + postfix.getLength();
+
+ sal_Bool withSeperator = sal_False;
+ if (destination.getStr()[destination.getLength()] != '\\' &&
+ destination.getStr()[destination.getLength()] != '/' &&
+ type.getStr()[0] != '\\' &&
+ type.getStr()[0] != '/')
+ {
+ length++;
+ withSeperator = sal_True;
+ }
+
+ OStringBuffer nameBuffer(length);
+
+ if (withPoint)
+ nameBuffer.append('.');
+ else
+ nameBuffer.append(destination.getStr(), destination.getLength());
+
+ if (withSeperator)
+ nameBuffer.append("/", 1);
+
+ OString tmpStr(type);
+ if (prefix.getLength() > 0)
+ {
+ tmpStr = type.replaceAt(type.lastIndexOf('/')+1, 0, prefix);
+ }
+
+ nameBuffer.append(tmpStr.getStr(), tmpStr.getLength());
+ nameBuffer.append(postfix.getStr(), postfix.getLength());
+
+ OString fileName(nameBuffer);
+
+ sal_Char token;
+#ifdef SAL_UNX
+ fileName = fileName.replace('\\', '/');
+ token = '/';
+#else
+ fileName = fileName.replace('/', '\\');
+ token = '\\';
+#endif
+
+ sal_Int32 count = fileName.getTokenCount(token) - 1;
+
+ nameBuffer = OStringBuffer(length);
+
+ for (int i=0; i < count; i++)
+ {
+ nameBuffer.append(fileName.getToken(i, token).getStr());
+
+ if (nameBuffer.getLength() == 0 || OString(".") == nameBuffer.getStr())
+ {
+ nameBuffer.append(token);
+ continue;
+ }
+
+#ifdef SAL_UNX
+ if (mkdir((char*)nameBuffer.getStr(), 0777) == -1)
+#else
+ if (mkdir((char*)nameBuffer.getStr()) == -1)
+#endif
+ {
+// #if __SUNPRO_CC >= 0x500
+// if( * ::___errno() == ENOENT )
+// #else
+ if ( errno == ENOENT )
+// #endif
+ return OString();
+ }
+
+ nameBuffer.append(token);
+ }
+
+ return fileName;
+}
+
+sal_Bool fileExists(const OString& fileName)
+{
+ FILE *f= fopen(fileName.getStr(), "r");
+
+ if (f != NULL)
+ {
+ fclose(f);
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+sal_Bool checkFileContent(const OString& targetFileName, const OString& tmpFileName)
+{
+ FILE *target = fopen(targetFileName.getStr(), "r");
+ FILE *tmp = fopen(tmpFileName.getStr(), "r");
+ sal_Bool ret = sal_False;
+
+ if (target != NULL && tmp != NULL)
+ {
+ sal_Bool bFindChanges = sal_False;
+ sal_Char buffer1[1024+1];
+ sal_Char buffer2[1024+1];
+ sal_Int32 n1 = 0;
+ sal_Int32 n2 = 0;
+
+ while ( !bFindChanges && !feof(target) && !feof(tmp))
+ {
+ n1 = fread(buffer1, sizeof(sal_Char), 1024, target);
+ n2 = fread(buffer2, sizeof(sal_Char), 1024, tmp);
+
+ if ( n1 != n2 )
+ {
+ bFindChanges = sal_True;
+ }
+ else
+ {
+ if ( rtl_compareMemory(buffer1, buffer2, n2) != 0 )
+ bFindChanges = sal_True;
+ }
+ }
+
+ fclose(target);
+ fclose(tmp);
+
+ if ( bFindChanges )
+ {
+ if ( !unlink(targetFileName.getStr()) )
+ if ( !rename(targetFileName.getStr(), tmpFileName.getStr()) )
+ ret = sal_True;
+ }
+ else
+ {
+ if ( !unlink(tmpFileName.getStr()) )
+ ret = sal_True;
+ }
+ }
+
+ return ret;
+}
+
+const OString inGlobalSet(const OUString & rValue)
+{
+ OString sValue( OUStringToOString(rValue, RTL_TEXTENCODING_UTF8) );
+ static StringSet aGlobalMap;
+ StringSet::iterator iter = aGlobalMap.find( sValue );
+ if( iter != aGlobalMap.end() )
+ return *iter;
+ return *(aGlobalMap.insert( sValue ).first);
+}
+
+
+//*************************************************************************
+// FileStream
+//*************************************************************************
+FileStream::FileStream()
+{
+}
+
+FileStream::FileStream(const OString& name, sal_Int32 nMode)
+ : ofstream(name, nMode)
+ , m_name(name)
+{
+}
+
+FileStream::~FileStream()
+{
+ flush();
+ close();
+}
+
+sal_Bool FileStream::isValid()
+{
+#if defined(SAL_UNX) || defined(SAL_OS2)
+ if(rdbuf()->fd() < 0)
+#else
+ if(fd() < 0)
+#endif
+ {
+ return sal_False;
+ }
+
+ return sal_True;
+}
+
+void FileStream::openFile(const OString& name, sal_Int32 nMode)
+{
+ if ( name.getLength() > 0 )
+ m_name = name;
+
+ if ( m_name.getLength() > 0 )
+ open(m_name, nMode);
+}
+
+void FileStream::closeFile()
+{
+ flush();
+ close();
+}
+
+sal_Int32 FileStream::getSize()
+{
+ flush();
+
+ FILE* f = fopen(m_name, "r");
+ sal_Int32 size = 0;
+ if (!fseek(f, 0, SEEK_END))
+ size = ftell(f);
+ fclose(f);
+ return size;
+}
+
diff --git a/codemaker/source/codemaker/makefile.mk b/codemaker/source/codemaker/makefile.mk
new file mode 100644
index 000000000000..e226fee6cdeb
--- /dev/null
+++ b/codemaker/source/codemaker/makefile.mk
@@ -0,0 +1,92 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $
+#
+# 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=codemaker
+TARGET=$(PRJNAME)
+
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# ------------------------------------------------------------------
+
+CXXFILES= \
+ global.cxx \
+ options.cxx \
+ typemanager.cxx \
+ dependency.cxx
+
+OBJFILES= \
+ $(OBJ)$/global.obj \
+ $(OBJ)$/options.obj \
+ $(OBJ)$/typemanager.obj \
+ $(OBJ)$/dependency.obj
+
+# ------------------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/codemaker/source/codemaker/options.cxx b/codemaker/source/codemaker/options.cxx
new file mode 100644
index 000000000000..0ef959c45e71
--- /dev/null
+++ b/codemaker/source/codemaker/options.cxx
@@ -0,0 +1,138 @@
+/*************************************************************************
+ *
+ * $RCSfile: options.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CODEMAKER_OPTIONS_HXX_
+#include <codemaker/options.hxx>
+#endif
+
+using namespace rtl;
+
+Options::Options()
+{
+}
+
+Options::~Options()
+{
+
+}
+
+const OString& Options::getProgramName() const
+{
+ return m_program;
+}
+
+sal_uInt16 Options::getNumberOfOptions() const
+{
+ return m_options.size();
+}
+
+sal_Bool Options::isValid(const OString& option)
+{
+ return (m_options.count(option) > 0);
+}
+
+const OString Options::getOption(const OString& option)
+ throw( IllegalArgument )
+{
+ const OString ret;
+
+ if (m_options.count(option) > 0)
+ {
+ return m_options[option];
+ } else
+ {
+ throw IllegalArgument("Option is not valid or currently not set.");
+ }
+
+ return ret;
+}
+
+const OptionMap& Options::getOptions()
+{
+ return m_options;
+}
+
+sal_uInt16 Options::getNumberOfInputFiles() const
+{
+ return m_inputFiles.size();
+}
+
+const OString Options::getInputFile(sal_uInt16 index)
+ throw( IllegalArgument )
+{
+ const OString ret;
+
+ if (index < m_inputFiles.size())
+ {
+ return m_inputFiles[index];
+ } else
+ {
+ throw IllegalArgument("index is out of bound.");
+ }
+
+ return ret;
+}
+
+const StringVector& Options::getInputFiles()
+{
+ return m_inputFiles;
+}
+
diff --git a/codemaker/source/codemaker/typemanager.cxx b/codemaker/source/codemaker/typemanager.cxx
new file mode 100644
index 000000000000..2e8e37cb36b4
--- /dev/null
+++ b/codemaker/source/codemaker/typemanager.cxx
@@ -0,0 +1,322 @@
+/*************************************************************************
+ *
+ * $RCSfile: typemanager.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+
+#ifndef _CODEMAKER_TYPEMANAGER_HXX_
+#include <codemaker/typemanager.hxx>
+#endif
+
+using namespace rtl;
+
+RegistryTypeReaderLoader & getRegistryTypeReaderLoader()
+{
+ static RegistryTypeReaderLoader aLoader;
+ return aLoader;
+}
+
+TypeManager::TypeManager()
+{
+ m_pImpl = new TypeManagerImpl();
+ acquire();
+}
+
+TypeManager::~TypeManager()
+{
+ release();
+}
+
+sal_Int32 TypeManager::acquire()
+{
+ return osl_incrementInterlockedCount(&m_pImpl->m_refCount);
+}
+
+sal_Int32 TypeManager::release()
+{
+ sal_Int32 refCount = 0;
+ if (0 == (refCount = osl_decrementInterlockedCount(&m_pImpl->m_refCount)) )
+ {
+ delete m_pImpl;
+ }
+ return refCount;;
+}
+
+RegistryTypeManager::RegistryTypeManager()
+{
+ m_pImpl = new RegistryTypeManagerImpl();
+ acquire();
+}
+
+RegistryTypeManager::~RegistryTypeManager()
+{
+ release();
+}
+
+void RegistryTypeManager::acquire()
+{
+ TypeManager::acquire();
+}
+
+void RegistryTypeManager::release()
+{
+ if (0 == TypeManager::release())
+ {
+ if (m_pImpl->m_pMergedRegistry)
+ {
+ if (m_pImpl->m_pMergedRegistry->isValid())
+ {
+ m_pImpl->m_pMergedRegistry->destroy(OUString());
+ }
+
+ delete m_pImpl->m_pMergedRegistry;
+ }
+
+ if (m_pImpl->m_registries.size() > 0)
+ {
+ freeRegistries();
+ }
+
+ delete m_pImpl;
+ }
+}
+
+sal_Bool RegistryTypeManager::init(sal_Bool bMerged, const StringVector& regFiles)
+{
+ m_pImpl->m_isMerged = bMerged && (regFiles.size() > 1);
+
+ if (regFiles.empty())
+ return sal_False;
+
+ StringVector::const_iterator iter = regFiles.begin();
+
+ RegistryLoader loader;
+ Registry tmpReg(loader);
+ while (iter != regFiles.end())
+ {
+ if (!tmpReg.open( OStringToOUString(*iter, RTL_TEXTENCODING_UTF8), REG_READONLY))
+ m_pImpl->m_registries.push_back(new Registry(tmpReg));
+ else
+ {
+ freeRegistries();
+ return sal_False;
+ }
+ iter++;
+ }
+
+ if (m_pImpl->m_isMerged)
+ {
+ Registry *pTmpReg = new Registry(loader);
+ OString tmpName(makeTempName(NULL));
+
+ if (!pTmpReg->create( OStringToOUString(tmpName, RTL_TEXTENCODING_UTF8) ) )
+ {
+ RegistryKey rootKey;
+ RegError ret = REG_NO_ERROR;
+ OUString aRoot( RTL_CONSTASCII_USTRINGPARAM("/") );
+ iter = regFiles.begin();
+ pTmpReg->openRootKey(rootKey);
+
+ while (iter != regFiles.end())
+ {
+ if ( ret = pTmpReg->mergeKey(rootKey, aRoot, OUString::createFromAscii( *iter )) )
+ {
+ if (ret != REG_MERGE_CONFLICT)
+ {
+ freeRegistries();
+ rootKey.closeKey();
+ pTmpReg->destroy( OUString() );
+ delete pTmpReg;
+ return sal_False;
+ }
+ }
+ iter++;
+ }
+
+ m_pImpl->m_pMergedRegistry = pTmpReg;
+ freeRegistries();
+ } else
+ {
+ delete pTmpReg;
+ freeRegistries();
+ return sal_False;
+ }
+ }
+
+ return sal_True;
+}
+
+TypeReader RegistryTypeManager::getTypeReader(const OString& name)
+{
+ TypeReader reader;
+ RegistryKey key(searchTypeKey(name));
+
+ if (key.isValid())
+ {
+ RegValueType valueType;
+ sal_uInt32 valueSize;
+
+ if (!key.getValueInfo(OUString(), &valueType, &valueSize))
+ {
+ sal_uInt8* pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize);
+ if (!key.getValue(OUString(), pBuffer))
+ {
+ RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader();
+
+ reader = TypeReader(rReaderLoader, pBuffer, valueSize, sal_True);
+ }
+ rtl_freeMemory(pBuffer);
+ }
+ }
+ return reader;
+}
+
+RTTypeClass RegistryTypeManager::getTypeClass(const OString& name)
+{
+ if (m_pImpl->m_t2TypeClass.count(name) > 0)
+ {
+ return m_pImpl->m_t2TypeClass[name];
+ } else
+ {
+ RegistryKey key(searchTypeKey(name));
+
+ if (key.isValid())
+ {
+ RegValueType valueType;
+ sal_uInt32 valueSize;
+
+ if (!key.getValueInfo(OUString(), &valueType, &valueSize))
+ {
+ sal_uInt8* pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize);
+ if (!key.getValue(OUString(), pBuffer))
+ {
+ RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader();
+
+ TypeReader reader(rReaderLoader, pBuffer, valueSize, sal_False);
+
+ RTTypeClass ret = reader.getTypeClass();
+
+ rtl_freeMemory(pBuffer);
+
+ m_pImpl->m_t2TypeClass[name] = ret;
+ return ret;
+ }
+ rtl_freeMemory(pBuffer);
+ }
+ }
+ }
+
+ return RT_TYPE_INVALID;
+}
+
+void RegistryTypeManager::setBase(const OString& base)
+{
+ m_pImpl->m_base = base;
+
+ if (base.lastIndexOf('/') != (base.getLength() - 1))
+ {
+ m_pImpl->m_base += "/";
+ }
+}
+
+void RegistryTypeManager::freeRegistries()
+{
+ RegistryList::const_iterator iter = m_pImpl->m_registries.begin();
+
+ while (iter != m_pImpl->m_registries.end())
+ {
+ delete *iter;
+
+ iter++;
+ }
+
+}
+
+RegistryKey RegistryTypeManager::searchTypeKey(const OString& name)
+{
+ RegistryKey key, rootKey;
+
+ if (m_pImpl->m_isMerged)
+ {
+ if (!m_pImpl->m_pMergedRegistry->openRootKey(rootKey))
+ {
+ rootKey.openKey(OStringToOUString(m_pImpl->m_base + name, RTL_TEXTENCODING_UTF8), key);
+ }
+ } else
+ {
+ RegistryList::const_iterator iter = m_pImpl->m_registries.begin();
+
+ while (iter != m_pImpl->m_registries.end())
+ {
+ if (!(*iter)->openRootKey(rootKey))
+ {
+ if (!rootKey.openKey(OStringToOUString(m_pImpl->m_base + name, RTL_TEXTENCODING_UTF8), key))
+ break;
+ }
+
+ iter++;
+ }
+ }
+
+ return key;
+}
+
diff --git a/codemaker/source/cppumaker/cppumaker.cxx b/codemaker/source/cppumaker/cppumaker.cxx
new file mode 100644
index 000000000000..92084608d216
--- /dev/null
+++ b/codemaker/source/cppumaker/cppumaker.cxx
@@ -0,0 +1,222 @@
+/*************************************************************************
+ *
+ * $RCSfile: cppumaker.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $
+ *
+ * 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>
+
+#ifndef _CODEMAKER_TYPEMANAGER_HXX_
+#include <codemaker/typemanager.hxx>
+#endif
+#ifndef _CODEMAKER_DEPENDENCY_HXX_
+#include <codemaker/dependency.hxx>
+#endif
+
+#include "cppuoptions.hxx"
+#include "cpputype.hxx"
+
+using namespace rtl;
+
+sal_Bool produceAllTypes(const OString& typeName,
+ TypeManager& typeMgr,
+ TypeDependency& typeDependencies,
+ CppuOptions* pOptions,
+ sal_Bool bFullScope)
+ throw( CannotDumpException )
+{
+ if (!produceType(typeName, typeMgr, typeDependencies, pOptions))
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ pOptions->getProgramName().getStr(),
+ OString("cannot dump Type '" + typeName + "'").getStr());
+ exit(99);
+ }
+
+ RegistryKey typeKey = typeMgr.getTypeKey(typeName);
+ RegistryKeyNames subKeys;
+
+ if (typeKey.getKeyNames(OUString(), subKeys))
+ return sal_False;
+
+ OString tmpName;
+ for (sal_uInt32 i=0; i < subKeys.getLength(); i++)
+ {
+ tmpName = OUStringToOString(subKeys.getElement(i), RTL_TEXTENCODING_UTF8);
+
+ if (pOptions->isValid("-B"))
+ tmpName = tmpName.copy(tmpName.indexOf('/', 1) + 1);
+ else
+ tmpName = tmpName.copy(1);
+
+ if (bFullScope)
+ {
+ if (!produceAllTypes(tmpName, typeMgr, typeDependencies, pOptions, sal_True))
+ return sal_False;
+ } else
+ {
+ if (!produceType(tmpName, typeMgr, typeDependencies, pOptions))
+ return sal_False;
+ }
+ }
+
+ return sal_True;
+}
+
+#if (defined UNX) || (defined OS2)
+int main( int argc, char * argv[] )
+#else
+int _cdecl main( int argc, char * argv[] )
+#endif
+{
+ CppuOptions options;
+
+ try
+ {
+ if (!options.initOptions(argc, argv))
+ {
+ exit(1);
+ }
+ }
+ catch( IllegalArgument& e)
+ {
+ fprintf(stderr, "Illegal option: %s\n", e.m_message.getStr());
+ exit(99);
+ }
+
+ RegistryTypeManager typeMgr;
+ TypeDependency typeDependencies;
+
+ if (!typeMgr.init(!options.isValid("-T"), options.getInputFiles()))
+ {
+ fprintf(stderr, "%s : init registries failed, check your registry files.\n", options.getProgramName().getStr());
+ exit(99);
+ }
+
+ if (options.isValid("-B"))
+ {
+ typeMgr.setBase(options.getOption("-B"));
+ }
+
+ try
+ {
+ if (options.isValid("-T"))
+ {
+ OString tOption(options.getOption("-T"));
+ sal_uInt32 count = tOption.getTokenCount(';');
+
+ OString typeName, tmpName;
+ sal_Bool ret = sal_False;
+ for (sal_uInt32 i = 0; i < count; i++)
+ {
+ typeName = tOption.getToken(i, ';');
+
+ tmpName = typeName.getToken(typeName.getTokenCount('.') - 1, '.');
+ if (tmpName == "*")
+ {
+ // produce this type and his scope, but the scope is not recursively generated.
+ if (typeName.equals("*"))
+ {
+ tmpName = "/";
+ } else
+ {
+ tmpName = typeName.copy(0, typeName.lastIndexOf('.')).replace('.', '/');
+ if (tmpName.getLength() == 0)
+ tmpName = "/";
+ else
+ tmpName.replace('.', '/');
+ }
+ ret = produceAllTypes(tmpName, typeMgr, typeDependencies, &options, sal_False);
+ } else
+ {
+ // produce only this type
+ ret = produceType(typeName.replace('.', '/'), typeMgr, typeDependencies, &options);
+ }
+
+ if (!ret)
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ options.getProgramName().getStr(),
+ OString("cannot dump Type '" + typeName + "'").getStr());
+ exit(99);
+ }
+ }
+ } else
+ {
+ // produce all types
+ if (!produceAllTypes("/", typeMgr, typeDependencies, &options, sal_True))
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ options.getProgramName().getStr(),
+ "an error occurs while dumping all types.");
+ exit(99);
+ }
+ }
+ }
+ catch( CannotDumpException& e)
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ options.getProgramName().getStr(),
+ e.m_message.getStr());
+ exit(99);
+ }
+
+ return 0;
+}
+
+
diff --git a/codemaker/source/cppumaker/cppuoptions.cxx b/codemaker/source/cppumaker/cppuoptions.cxx
new file mode 100644
index 000000000000..dc025cb0a0c7
--- /dev/null
+++ b/codemaker/source/cppumaker/cppuoptions.cxx
@@ -0,0 +1,340 @@
+/*************************************************************************
+ *
+ * $RCSfile: cppuoptions.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $
+ *
+ * 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 "cppuoptions.hxx"
+
+using namespace rtl;
+
+sal_Bool CppuOptions::initOptions(int ac, char* av[], sal_Bool bCmdFile)
+ throw( IllegalArgument )
+{
+ sal_Bool ret = sal_True;
+ sal_uInt16 i=0;
+
+ if (!bCmdFile)
+ {
+ bCmdFile = sal_True;
+
+ m_program = av[0];
+
+ if (ac < 2)
+ {
+ fprintf(stderr, "%s", prepareHelp().getStr());
+ ret = sal_False;
+ }
+
+ i = 1;
+ } else
+ {
+ i = 0;
+ }
+
+ char *s=NULL;
+ for (i; i < ac; i++)
+ {
+ if (av[i][0] == '-')
+ {
+ switch (av[i][1])
+ {
+ case 'O':
+ if (av[i][2] == '\0')
+ {
+ if (i < ac - 1 && av[i+1][0] != '-')
+ {
+ i++;
+ s = av[i];
+ } else
+ {
+ OString tmp("'-O', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i+1]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+ } else
+ {
+ s = av[i] + 2;
+ }
+
+ m_options["-O"] = OString(s);
+ break;
+ case 'B':
+ if (av[i][2] == '\0')
+ {
+ if (i < ac - 1 && av[i+1][0] != '-')
+ {
+ i++;
+ s = av[i];
+ } else
+ {
+ OString tmp("'-B', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i+1]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+ } else
+ {
+ s = av[i] + 2;
+ }
+
+ m_options["-B"] = OString(s);
+ break;
+ case 'T':
+ if (av[i][2] == '\0')
+ {
+ if (i < ac - 1 && av[i+1][0] != '-')
+ {
+ i++;
+ s = av[i];
+ } else
+ {
+ OString tmp("'-T', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i+1]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+ } else
+ {
+ s = av[i] + 2;
+ }
+
+ if (m_options.count("-T") > 0)
+ {
+ OString tmp(m_options["-T"]);
+ tmp = tmp + ";" + s;
+ m_options["-T"] = tmp;
+ } else
+ {
+ m_options["-T"] = OString(s);
+ }
+ break;
+ case 'L':
+ if (av[i][2] != '\0')
+ {
+ OString tmp("'-C', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+
+ if (isValid("-C") || isValid("-CS"))
+ {
+ OString tmp("'-L' could not be combined with '-C' or '-CS' option");
+ throw IllegalArgument(tmp);
+ }
+ m_options["-L"] = OString("");
+ break;
+ case 'C':
+ if (av[i][2] == 'S')
+ {
+ if (av[i][3] != '\0')
+ {
+ OString tmp("'-CS', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+
+ if (isValid("-L") || isValid("-C"))
+ {
+ OString tmp("'-CS' could not be combined with '-L' or '-C' option");
+ throw IllegalArgument(tmp);
+ }
+ m_options["-CS"] = OString("");
+ break;
+ } else
+ if (av[i][2] != '\0')
+ {
+ OString tmp("'-C', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+
+ if (isValid("-L") || isValid("-CS"))
+ {
+ OString tmp("'-C' could not be combined with '-L' or '-CS' option");
+ throw IllegalArgument(tmp);
+ }
+ m_options["-C"] = OString("");
+ break;
+ case 'G':
+ if (av[i][2] == 'c')
+ {
+ if (av[i][3] != '\0')
+ {
+ OString tmp("'-Gc', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+
+ m_options["-Gc"] = OString("");
+ break;
+ } else
+ if (av[i][2] != '\0')
+ {
+ OString tmp("'-G', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+
+ m_options["-G"] = OString("");
+ break;
+ default:
+ throw IllegalArgument("the option is unknown" + OString(av[i]));
+ break;
+ }
+ } else
+ {
+ if (av[i][0] == '@')
+ {
+ FILE* cmdFile = fopen(av[i]+1, "r");
+ if( cmdFile == NULL )
+ {
+ fprintf(stderr, "%s", prepareHelp().getStr());
+ ret = sal_False;
+ } else
+ {
+ int rargc=0;
+ char* rargv[512];
+ char buffer[512];
+
+ while ( fscanf(cmdFile, "%s", buffer) != EOF )
+ {
+ rargv[rargc]= strdup(buffer);
+ rargc++;
+ }
+ fclose(cmdFile);
+
+ ret = initOptions(rargc, rargv, bCmdFile);
+
+ for (long i=0; i < rargc; i++)
+ {
+ free(rargv[i]);
+ }
+ }
+ } else
+ {
+ m_inputFiles.push_back(av[i]);
+ }
+ }
+ }
+
+ return ret;
+}
+
+OString CppuOptions::prepareHelp()
+{
+ OString help("\nusing: ");
+ help += m_program + " [-options] file_1 ... file_n\nOptions:\n";
+ help += " -O<path> = path describes the root directory for the generated output.\n";
+ help += " The output directory tree is generated under this directory.\n";
+ help += " -T<name> = name specifies a type or a list of types. The output for this\n";
+ help += " [t1;...] type is generated. If no '-T' option is specified,\n";
+ help += " then output for all types is generated.\n";
+ help += " Example: 'com.sun.star.uno.XInterface' is a valid type.\n";
+ help += " -B<name> = name specifies the base node. All types are searched under this\n";
+ help += " node. Default is the root '/' of the registry files.\n";
+ help += " -L = getCppuType function with a known leak.\n";
+ help += " -C = getCppuType function keeps comprehensive type information.\n";
+ help += " -CS = getCppuType function keeps comprehensive type information (static version).\n";
+ help += " -G = generate only target files which does not exists.\n";
+ help += " -Gc = generate only target files which content will be changed.\n";
+ help += prepareVersion();
+
+ return help;
+}
+
+OString CppuOptions::prepareVersion()
+{
+ OString version("\nSun Microsystems (R) ");
+ version += m_program + " Version 2.0\n\n";
+
+ return version;
+}
+
+
diff --git a/codemaker/source/cppumaker/cppuoptions.hxx b/codemaker/source/cppumaker/cppuoptions.hxx
new file mode 100644
index 000000000000..ee7744a6944e
--- /dev/null
+++ b/codemaker/source/cppumaker/cppuoptions.hxx
@@ -0,0 +1,85 @@
+/*************************************************************************
+ *
+ * $RCSfile: cppuoptions.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CPPUMAKER_CPPUOPTIONS_HXX_
+#define _CPPUMAKER_CPPUOPTIONS_HXX_
+
+#include <codemaker/options.hxx>
+
+class CppuOptions : public Options
+{
+public:
+ CppuOptions()
+ : Options() {}
+
+ ~CppuOptions() {}
+
+ sal_Bool initOptions(int ac, char* av[], sal_Bool bCmdFile=sal_False)
+ throw( IllegalArgument );
+
+ ::rtl::OString prepareHelp();
+
+ ::rtl::OString prepareVersion();
+
+protected:
+};
+
+#endif // _CPPUMAKER_CPPUOPTIONS_HXX_
diff --git a/codemaker/source/cppumaker/cpputype.cxx b/codemaker/source/cppumaker/cpputype.cxx
new file mode 100644
index 000000000000..3fdcc1e72c11
--- /dev/null
+++ b/codemaker/source/cppumaker/cpputype.cxx
@@ -0,0 +1,3838 @@
+/*************************************************************************
+ *
+ * $RCSfile: cpputype.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $
+ *
+ * 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>
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#ifndef _RTL_STRBUF_HXX_
+#include <rtl/strbuf.hxx>
+#endif
+
+#include "cpputype.hxx"
+#include "cppuoptions.hxx"
+
+using namespace rtl;
+
+//*************************************************************************
+// CppuType
+//*************************************************************************
+CppuType::CppuType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : m_inheritedMemberCount(0)
+ , m_cppuTypeLeak(sal_False)
+ , m_cppuTypeDynamic(sal_True)
+ , m_cppuTypeStatic(sal_False)
+ , m_indentLength(0)
+ , m_typeName(typeName)
+ , m_name(typeName.getToken(typeName.getTokenCount('/') - 1, '/'))
+ , m_reader(typeReader)
+ , m_typeMgr((TypeManager&)typeMgr)
+ , m_dependencies(typeDependencies)
+{
+}
+
+CppuType::~CppuType()
+{
+
+}
+
+sal_Bool CppuType::dump(CppuOptions* pOptions)
+ throw( CannotDumpException )
+{
+ sal_Bool ret = sal_False;
+
+ if (pOptions->isValid("-L"))
+ m_cppuTypeLeak = sal_True;
+ if (pOptions->isValid("-C"))
+ m_cppuTypeDynamic = sal_False;
+ if (pOptions->isValid("-CS"))
+ {
+ m_cppuTypeDynamic = sal_False;
+ m_cppuTypeStatic = sal_True;
+ }
+
+ OString outPath;
+ if (pOptions->isValid("-O"))
+ outPath = pOptions->getOption("-O");
+
+ OString tmpFileName;
+ OString hFileName = createFileNameFromType(outPath, m_typeName, ".hdl");
+
+ sal_Bool bFileExists = sal_False;
+ sal_Bool bFileCheck = sal_False;
+
+ if ( pOptions->isValid("-G") || pOptions->isValid("-Gc") )
+ {
+ bFileExists = fileExists( hFileName );
+ ret = sal_True;
+ }
+
+ if ( bFileExists && pOptions->isValid("-Gc") )
+ {
+ tmpFileName = createFileNameFromType(outPath, m_typeName, ".tml");
+ bFileCheck = sal_True;
+ }
+
+ if ( !bFileExists || bFileCheck )
+ {
+ FileStream hFile;
+
+ if ( bFileCheck )
+ hFile.openFile(tmpFileName);
+ else
+ hFile.openFile(hFileName);
+
+ if(!hFile.isValid())
+ {
+ OString message("cannot open ");
+ message += hFileName + " for writing";
+ throw CannotDumpException(message);
+ }
+
+ ret = dumpHFile(hFile);
+
+ hFile.closeFile();
+ if (ret && bFileCheck)
+ {
+ ret = checkFileContent(hFileName, tmpFileName);
+ }
+ }
+
+ OString hxxFileName = createFileNameFromType(outPath, m_typeName, ".hpp");
+
+ if ( pOptions->isValid("-G") || pOptions->isValid("-Gc") )
+ {
+ bFileExists = fileExists( hFileName );
+ ret = sal_True;
+ }
+
+ if ( bFileExists && pOptions->isValid("-Gc") )
+ {
+ tmpFileName = createFileNameFromType(outPath, m_typeName, ".tmp");
+ bFileCheck = sal_True;
+ }
+
+ if ( !bFileExists || bFileCheck )
+ {
+ FileStream hxxFile;
+
+ if ( bFileCheck )
+ hxxFile.openFile(tmpFileName);
+ else
+ hxxFile.openFile(hxxFileName);
+
+ if(!hxxFile.isValid())
+ {
+ OString message("cannot open ");
+ message += hxxFileName + " for writing";
+ throw CannotDumpException(message);
+ }
+
+ ret = dumpHxxFile(hxxFile);
+
+ hxxFile.closeFile();
+ if (ret && bFileCheck)
+ {
+ ret = checkFileContent(hFileName, tmpFileName);
+ }
+ }
+
+ return ret;
+}
+sal_Bool CppuType::dumpDependedTypes(CppuOptions* pOptions)
+ throw( CannotDumpException )
+{
+ sal_Bool ret = sal_True;
+
+ TypeUsingSet usingSet(m_dependencies.getDependencies(m_typeName));
+
+ TypeUsingSet::const_iterator iter = usingSet.begin();
+ OString typeName;
+ sal_uInt32 index = 0;
+ while (iter != usingSet.end())
+ {
+ typeName = (*iter).m_type;
+ if ((index = typeName.lastIndexOf(']')) > 0)
+ typeName = typeName.copy(index + 1);
+
+ if (getBaseType(typeName).getLength() == 0)
+ {
+ if (!produceType(typeName,
+ m_typeMgr,
+ m_dependencies,
+ pOptions))
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ pOptions->getProgramName().getStr(),
+ OString("cannot dump Type '" + typeName + "'").getStr());
+ exit(99);
+ }
+ }
+ iter++;
+ }
+
+ return ret;
+}
+
+OString CppuType::dumpHeaderDefine(FileStream& o, sal_Char* prefix, sal_Bool bExtended)
+{
+ if (m_typeName.equals("/"))
+ {
+ bExtended = sal_False;
+ m_typeName = "global";
+ }
+
+ sal_uInt32 length = 3 + m_typeName.getLength() + strlen(prefix);
+
+ if (bExtended)
+ length += m_name.getLength() + 1;
+
+ OStringBuffer tmpBuf(length);
+
+ tmpBuf.append('_');
+ tmpBuf.append(m_typeName);
+ tmpBuf.append('_');
+ if (bExtended)
+ {
+ tmpBuf.append(m_name);
+ tmpBuf.append('_');
+ }
+ tmpBuf.append(prefix);
+ tmpBuf.append('_');
+
+ OString tmp(tmpBuf.makeStringAndClear().replace('/', '_').toUpperCase());
+
+ o << "#ifndef " << tmp << "\n#define " << tmp << endl;
+
+ return tmp;
+}
+
+void CppuType::dumpDefaultHIncludes(FileStream& o)
+{
+ o << "#ifndef _CPPU_MACROS_HXX_\n"
+ << "#include <cppu/macros.hxx>\n"
+ << "#endif\n";
+
+ if (m_typeMgr.getTypeClass(m_typeName) == RT_TYPE_INTERFACE)
+ {
+ o << "#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_\n"
+ << "#include <com/sun/star/uno/Reference.h>\n"
+ << "#endif\n";
+ }
+}
+
+void CppuType::dumpDefaultHxxIncludes(FileStream& o)
+{
+ o << "#ifndef _OSL_MUTEX_HXX_\n"
+ << "#include <osl/mutex.hxx>\n"
+ << "#endif\n\n";
+
+ o << "#ifndef _COM_SUN_STAR_UNO_TYPE_HXX_\n"
+ << "#include <com/sun/star/uno/Type.hxx>\n"
+ << "#endif\n";
+
+ if (m_typeMgr.getTypeClass(m_typeName) == RT_TYPE_INTERFACE)
+ {
+ o << "#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_\n"
+ << "#include <com/sun/star/uno/Reference.hxx>\n"
+ << "#endif\n";
+ }
+}
+
+void CppuType::dumpInclude(FileStream& o, const OString& typeName, sal_Char* prefix, sal_Bool bExtended, sal_Bool bCaseSensitive)
+{
+ sal_uInt32 length = 3+ m_typeName.getLength() + strlen(prefix);
+
+ if (bExtended)
+ length += m_name.getLength() + 1;
+
+ OStringBuffer tmpBuf(length);
+
+ tmpBuf.append('_');
+ tmpBuf.append(typeName);
+ tmpBuf.append('_');
+ if (bExtended)
+ {
+ tmpBuf.append(m_name);
+ tmpBuf.append('_');
+ }
+ tmpBuf.append(prefix);
+ tmpBuf.append('_');
+
+ OString tmp(tmpBuf.makeStringAndClear().replace('/', '_').toUpperCase());
+
+ length = 1 + typeName.getLength() + strlen(prefix);
+ if (bExtended)
+ length += m_name.getLength() + 1;
+
+ tmpBuf.ensureCapacity(length);
+ tmpBuf.append(typeName);
+ if (bExtended)
+ {
+ tmpBuf.append('/');
+ tmpBuf.append(m_name);
+ }
+ tmpBuf.append('.');
+ tmpBuf.append(prefix);
+
+ o << "#ifndef " << tmp << "\n#include <";
+ if (bCaseSensitive)
+ {
+ o << tmpBuf.makeStringAndClear();
+ } else
+ {
+ o << tmpBuf.makeStringAndClear();
+ }
+ o << ">\n#endif\n";
+}
+
+void CppuType::dumpDepIncludes(FileStream& o, const OString& typeName, sal_Char* prefix)
+{
+ TypeUsingSet usingSet(m_dependencies.getDependencies(typeName));
+
+ TypeUsingSet::const_iterator iter = usingSet.begin();
+
+ OString sPrefix(OString(prefix).toUpperCase());
+ sal_Bool bSequenceDumped = sal_False;
+ sal_Bool bInterfaceDumped = sal_False;
+ sal_uInt32 index = 0;
+ sal_uInt32 seqNum = 0;
+ OString relType;
+ while (iter != usingSet.end())
+ {
+ index = (*iter).m_type.lastIndexOf(']');
+ seqNum = (index > 0 ? ((index+1) / 2) : 0);
+
+ relType = (*iter).m_type;
+ if (index > 0)
+ relType = relType.copy(index+1);
+
+ OString defPrefix("HXX");
+ if (sPrefix.equals("HDL"))
+ defPrefix = "H";
+
+ if (seqNum > 0 && !bSequenceDumped)
+ {
+ bSequenceDumped = sal_True;
+ o << "#ifndef _COM_SUN_STAR_UNO_SEQUENCE_" << defPrefix
+ << "_\n#include <com/sun/star/uno/Sequence." << defPrefix.toLowerCase()
+ << ">\n#endif\n";
+ }
+
+ if (getBaseType(relType).getLength() == 0 &&
+ m_typeName != relType)
+ {
+ if (m_typeMgr.getTypeClass(relType) == RT_TYPE_INTERFACE
+ && sPrefix.equals("HDL"))
+ {
+ if (!bInterfaceDumped)
+ {
+ bInterfaceDumped = sal_True;
+ o << "#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_\n"
+ << "#include <com/sun/star/uno/Reference.h>\n"
+ << "#endif\n";
+ }
+
+ if (!((*iter).m_use & TYPEUSE_SUPER))
+ {
+ o << endl;
+ dumpNameSpace(o, sal_True, sal_False, relType);
+ o << "\nclass " << scopedName(m_typeName, relType, sal_True) << ";\n";
+ dumpNameSpace(o, sal_False, sal_False, relType);
+ o << "\n\n";
+ } else
+ {
+ dumpInclude(o, relType, prefix);
+ }
+ } else
+ {
+ dumpInclude(o, relType, prefix);
+ }
+ } else
+ if (relType == "any")
+ {
+ o << "#ifndef _COM_SUN_STAR_UNO_ANY_" << defPrefix
+ << "_\n#include <com/sun/star/uno/Any." << defPrefix.toLowerCase()
+ << ">\n#endif\n";
+ } else
+ if (relType == "type")
+ {
+ o << "#ifndef _COM_SUN_STAR_UNO_TYPE_" << defPrefix
+ << "_\n#include <com/sun/star/uno/Type." << defPrefix.toLowerCase()
+ << ">\n#endif\n";
+ } else
+ if (relType == "string" && sPrefix.equals("HDL"))
+ {
+ o << "#ifndef _RTL_USTRING_HXX_\n"
+ << "#include <rtl/ustring.hxx>\n"
+ << "#endif\n";
+ }
+
+ iter++;
+ }
+}
+
+void CppuType::dumpNameSpace(FileStream& o, sal_Bool bOpen, sal_Bool bFull, const OString& type)
+{
+ OString typeName(type);
+ sal_Bool bOneLine = sal_True;
+ if (typeName.getLength() == 0)
+ {
+ typeName = m_typeName;
+ bOneLine = sal_False;
+ }
+
+ if (typeName == "/")
+ return;
+
+ sal_uInt32 count = typeName.getTokenCount('/');
+
+ if (count == 1 && !bFull)
+ return;
+
+ if (!bFull) count--;
+
+ if (bOpen)
+ {
+ for (int i=0; i < count; i++)
+ {
+ o << "namespace " << typeName.getToken(i, '/');
+ if (bOneLine)
+ o << " { ";
+ else
+ o << "\n{\n";
+ }
+ } else
+ {
+ for (int i=count-1; i >= 0; i--)
+ {
+ o << "}";
+ if (bOneLine)
+ o << " ";
+ else
+ o << " // " << typeName.getToken(i, '/') << "\n";
+ }
+ }
+}
+
+void CppuType::dumpLGetCppuType(FileStream& o)
+{
+ OString typeName(m_typeName.replace('/', '_'));
+
+ o << "#if ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n"
+ << "#endif\n\n";
+
+ if (m_reader.getTypeClass() == RT_TYPE_TYPEDEF)
+ {
+ o << "inline const ::com::sun::star::uno::Type& SAL_CALL get_" << typeName << "_Type( )\n{\n";
+ } else
+ {
+ o << "inline const ::com::sun::star::uno::Type& SAL_CALL getCppuType( ";
+ dumpType(o, m_typeName, sal_True, sal_False);
+ o << "* )\n{\n";
+ }
+ inc();
+
+ o << indent() << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << indent() << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n"
+ << indent() << "#endif\n\n";
+
+ o << indent() << "if ( !s_pType_" << typeName << " )\n" << indent() << "{\n";
+ inc();
+ o << indent() << "typelib_static_type_init( &s_pType_" << typeName << ", "
+ << getTypeClass(m_typeName, sal_True) << ", \"" << m_typeName.replace('/', '.') << "\" );\n";
+ dec();
+ o << indent() << "}\n";
+ o << indent() << "return * reinterpret_cast< ::com::sun::star::uno::Type * >( &s_pType_"
+ << typeName <<" );\n";
+ dec();
+ o << indent() << "}\n";
+
+ return;
+}
+
+void CppuType::dumpGetCppuType(FileStream& o)
+{
+ OString typeName(m_typeName.replace('/', '_'));
+
+ if ( m_cppuTypeLeak )
+ {
+ dumpLGetCppuType(o);
+ return;
+ }
+ if ( !m_cppuTypeDynamic )
+ {
+ dumpCGetCppuType(o);
+ return;
+ }
+
+ if ( !m_typeName.equals("com/sun/star/uno/Exception") )
+ {
+ o << "#if ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n"
+ << "#endif\n\n";
+ }
+
+ o << "inline const ::com::sun::star::uno::Type& SAL_CALL getCppuType( ";
+ dumpType(o, m_typeName, sal_True, sal_False);
+ o << "* )\n{\n";
+ inc();
+
+ if ( m_typeName.equals("com/sun/star/uno/Exception") )
+ {
+ o << indent() << "return * reinterpret_cast< const ::com::sun::star::uno::Type * >( ::typelib_static_type_getByTypeClass("
+ << " typelib_TypeClass_EXCEPTION ) );\n";
+ } else
+ {
+ o << indent() << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << indent() << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n"
+ << indent() << "#endif\n\n";
+
+ o << indent() << "if ( !s_pType_" << typeName << " )\n" << indent() << "{\n";
+ inc();
+
+ OString superType(m_reader.getSuperTypeName());
+ sal_Bool bIsBaseException = sal_False;
+ if (superType.getLength() > 0)
+ {
+ if ( superType.equals("com/sun/star/uno/Exception") )
+ {
+ bIsBaseException = sal_True;
+ } else
+ {
+ o << indent() << "const ::com::sun::star::uno::Type& rBaseType = getCppuType( ( ";
+ dumpType(o, superType, sal_True, sal_False);
+ o << " *)0 );\n\n";
+ }
+ }
+
+ sal_uInt32 count = getMemberCount();
+ if (count)
+ {
+ o << indent() << "typelib_TypeDescriptionReference * aMemberRefs[" << count << "];\n";
+// << indent() << "const sal_Char * aMemberNames[" << count << "];\n";
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldType, fieldName;
+ OString scope = m_typeName.replace('/', '.');
+ sal_Bool bWithScope = sal_True;
+ OString modFieldType;
+ StringSet generatedTypeSet;
+ StringSet::iterator findIter;
+
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = checkRealBaseType(m_reader.getFieldType(i), sal_True);
+
+ modFieldType = typeToIdentifier(fieldType);
+
+ findIter = generatedTypeSet.find(fieldType);
+ if ( findIter == generatedTypeSet.end() )
+ {
+ generatedTypeSet.insert(fieldType);
+ o << indent() << "const ::com::sun::star::uno::Type& rMemberType_"
+ << modFieldType/*i*/ << " = getCppuType( ( ";
+ dumpType(o, fieldType, sal_True, sal_False);
+ o << " *)0 );\n";
+ }
+
+ o << indent() << "aMemberRefs[" << i << "] = rMemberType_"
+ << modFieldType/*i*/ << ".getTypeLibType();\n";
+ }
+ o << endl;
+ }
+
+ o << indent() << "typelib_static_compound_type_init( &s_pType_" << typeName << ", "
+ << getTypeClass(m_typeName, sal_True) << ", \"" << m_typeName.replace('/', '.') << "\", ";
+ if ( superType.getLength() > 0 || bIsBaseException )
+ {
+ if ( bIsBaseException )
+ {
+ o << "* ::typelib_static_type_getByTypeClass( typelib_TypeClass_EXCEPTION ), "
+ << count << ", ";
+ } else
+ {
+ o << "rBaseType.getTypeLibType(), " << count << ", ";
+ }
+ } else
+ {
+ o << "0, " << count << ", ";
+ }
+
+ if (count)
+ {
+ o << " aMemberRefs );\n";
+ } else
+ {
+ o << " 0 );\n";
+ }
+ dec();
+ o << indent() << "}\n";
+ o << indent() << "return * reinterpret_cast< const ::com::sun::star::uno::Type * >( &s_pType_"
+ << typeName <<" );\n";
+ }
+ dec();
+ o << indent() << "}\n";
+
+ return;
+}
+
+void CppuType::dumpCGetCppuType(FileStream& o)
+{
+ OString typeName(m_typeName.replace('/', '_'));
+
+ o << "#if ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << "static ::com::sun::star::uno::Type * pType_" << typeName << " = 0;\n"
+ << "#endif\n\n";
+
+ if (m_cppuTypeStatic)
+ o << "static";
+ else
+ o << "inline";
+ o << " const ::com::sun::star::uno::Type& SAL_CALL getCppuType( ";
+ dumpType(o, m_typeName, sal_True, sal_False);
+ o << "* )\n"
+ << "{\n";
+ inc();
+
+ o << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << indent() << "static ::com::sun::star::uno::Type * pType_" << typeName << " = 0;\n"
+ << "#endif\n\n";
+
+ o << indent() << "if ( !pType_" << typeName << " )\n" << indent() << "{\n";
+ inc();
+ o << indent() << "::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );\n";
+
+ o << indent() << "if ( !pType_" << typeName << " )\n" << indent() << "{\n";
+ inc();
+ o << indent() << "::rtl::OUString sTypeName( RTL_CONSTASCII_USTRINGPARAM(\""
+ << m_typeName.replace('/', '.') << "\") );\n\n";
+
+ if ( m_cppuTypeDynamic )
+ {
+ o << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n";
+ o << indent() << "static ::com::sun::star::uno::Type aType_" << typeName << "( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << indent() << "pType_" << typeName << " = &aType_" << typeName << ";\n";
+ o << "#else\n";
+ o << indent() << "pType_" << typeName << " = new ::com::sun::star::uno::Type( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << "#endif\n";
+ } else
+ {
+ o << indent() << "// Start inline typedescription generation\n"
+ << indent() << "typelib_TypeDescription * pTD = 0;\n";
+
+ OString superType(m_reader.getSuperTypeName());
+ if (superType.getLength() > 0)
+ {
+ o << indent() << "const ::com::sun::star::uno::Type& rSuperType = getCppuType( ( ";
+ dumpType(o, superType, sal_True, sal_False);
+ o << " *)0 );\n";
+ }
+
+ dumpCppuGetTypeMemberDecl(o, CPPUTYPEDECL_ALLTYPES);
+
+ sal_uInt32 count = getMemberCount();
+ if (count)
+ {
+ o << "\n" << indent() << "typelib_CompoundMember_Init aMembers["
+ << count << "];\n";
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldType, fieldName;
+ OString scope = m_typeName.replace('/', '.');
+ sal_Bool bWithScope = sal_True;
+
+ if ( m_reader.getTypeClass() == RT_TYPE_STRUCT ||
+ m_reader.getTypeClass() == RT_TYPE_ENUM )
+ {
+ bWithScope = sal_False;
+ }
+
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = checkRealBaseType(m_reader.getFieldType(i), sal_True);
+
+ o << indent() << "::rtl::OUString sMemberType" << i << "( RTL_CONSTASCII_USTRINGPARAM(\""
+ << fieldType.replace('/', '.') << "\") );\n";
+ o << indent() << "::rtl::OUString sMemberName" << i << "( RTL_CONSTASCII_USTRINGPARAM(\"";
+ if (bWithScope)
+ o << scope << "::";
+ o << fieldName << "\") );\n";
+ o << indent() << "aMembers[" << i << "].eTypeClass = "
+ << "(typelib_TypeClass)" << getTypeClass(fieldType) << ";\n"
+ << indent() << "aMembers[" << i << "].pTypeName = sMemberType" << i << ".pData;\n"
+ << indent() << "aMembers[" << i << "].pMemberName = sMemberName" << i << ".pData;\n";
+ }
+ }
+
+ o << "\n" << indent() << "typelib_typedescription_new(\n";
+ inc();
+ o << indent() << "&pTD,\n" << indent() << "(typelib_TypeClass)"
+ << getTypeClass() << ", sTypeName.pData,\n";
+
+ if (superType.getLength() > 0)
+ o << indent() << "rSuperType.getTypeLibType(),\n";
+ else
+ o << indent() << "0,\n";
+
+ if ( count )
+ {
+ o << indent() << count << ",\n" << indent() << "aMembers );\n\n";
+ } else
+ {
+ o << indent() << count << ",\n" << indent() << "0 );\n\n";
+ }
+
+ dec();
+ o << indent() << "typelib_typedescription_register( (typelib_TypeDescription**)&pTD );\n\n";
+
+ o << indent() << "typelib_typedescription_release( pTD );\n"
+ << indent() << "// End inline typedescription generation\n\n";
+
+ o << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n";
+ o << indent() << "static ::com::sun::star::uno::Type aType_" << typeName << "( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << indent() << "pType_" << typeName << " = &aType_" << typeName << ";\n";
+ o << "#else\n";
+ o << indent() << "pType_" << typeName << " = new ::com::sun::star::uno::Type( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << "#endif\n";
+ }
+
+ dec();
+ o << indent() << "}\n";
+ dec();
+ o << indent() << "}\n\n";
+ o << indent() << "return *pType_" << typeName << ";\n";
+ dec();
+ o << "}\n";
+}
+
+void CppuType::dumpCppuGetTypeMemberDecl(FileStream& o, CppuTypeDecl eDeclFlag)
+{
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+
+ StringSet aFinishedTypes;
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ if (aFinishedTypes.count(m_reader.getFieldType(i)) == 0)
+ {
+ aFinishedTypes.insert(m_reader.getFieldType(i));
+ dumpCppuGetType(o, m_reader.getFieldType(i), sal_True, eDeclFlag);
+ }
+ }
+}
+
+sal_uInt32 CppuType::getMemberCount()
+{
+ sal_uInt32 count = m_reader.getMethodCount();
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access != RT_ACCESS_CONST && access != RT_ACCESS_INVALID)
+ count++;
+ }
+ return count;
+}
+
+sal_uInt32 CppuType::checkInheritedMemberCount(const TypeReader* pReader)
+{
+ sal_Bool bSelfCheck = sal_True;
+ if (!pReader)
+ {
+ bSelfCheck = sal_False;
+ pReader = &m_reader;
+ }
+
+ sal_uInt32 count = 0;
+ OString superType(pReader->getSuperTypeName());
+ if (superType.getLength() > 0)
+ {
+ TypeReader aSuperReader(m_typeMgr.getTypeReader(superType));
+ if ( aSuperReader.isValid() )
+ {
+ count = checkInheritedMemberCount(&aSuperReader);
+ }
+ }
+
+ if (bSelfCheck)
+ {
+ count += pReader->getMethodCount();
+ sal_uInt32 fieldCount = pReader->getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = pReader->getFieldAccess(i);
+
+ if (access != RT_ACCESS_CONST && access != RT_ACCESS_INVALID)
+ {
+ count++;
+ }
+ }
+ }
+
+ return count;
+}
+
+sal_uInt32 CppuType::getInheritedMemberCount()
+{
+ if (m_inheritedMemberCount == 0)
+ {
+ m_inheritedMemberCount = checkInheritedMemberCount(0);
+ }
+
+ return m_inheritedMemberCount;
+}
+
+OString CppuType::getTypeClass(const OString& type, sal_Bool bCStyle)
+{
+ OString typeName = (type.getLength() > 0 ? type : m_typeName);
+ RTTypeClass rtTypeClass = RT_TYPE_INVALID;
+
+ if (type.getLength() > 0)
+ {
+ typeName = type;
+ rtTypeClass = m_typeMgr.getTypeClass(typeName);
+ } else
+ {
+ typeName = m_typeName;
+ rtTypeClass = m_reader.getTypeClass();
+ }
+
+ if (typeName.lastIndexOf(']') > 0)
+ return bCStyle ? "typelib_TypeClass_SEQUENCE" : "::com::sun::star::uno::TypeClass_SEQUENCE";
+
+ switch (rtTypeClass)
+ {
+ case RT_TYPE_INTERFACE:
+ return bCStyle ? "typelib_TypeClass_INTERFACE" : "::com::sun::star::uno::TypeClass_INTERFACE";
+ break;
+ case RT_TYPE_MODULE:
+ return bCStyle ? "typelib_TypeClass_MODULE" : "::com::sun::star::uno::TypeClass_MODULE";
+ break;
+ case RT_TYPE_STRUCT:
+ return bCStyle ? "typelib_TypeClass_STRUCT" : "::com::sun::star::uno::TypeClass_STRUCT";
+ break;
+ case RT_TYPE_ENUM:
+ return bCStyle ? "typelib_TypeClass_ENUM" : "::com::sun::star::uno::TypeClass_ENUM";
+ break;
+ case RT_TYPE_EXCEPTION:
+ return bCStyle ? "typelib_TypeClass_EXCEPTION" : "::com::sun::star::uno::TypeClass_EXCEPTION";
+ break;
+ case RT_TYPE_TYPEDEF:
+ {
+ OString realType = checkRealBaseType( typeName );
+ return getTypeClass( realType, bCStyle );
+ }
+// return bCStyle ? "typelib_TypeClass_TYPEDEF" : "::com::sun::star::uno::TypeClass_TYPEDEF";
+ break;
+ case RT_TYPE_SERVICE:
+ return bCStyle ? "typelib_TypeClass_SERVICE" : "::com::sun::star::uno::TypeClass_SERVICE";
+ break;
+ case RT_TYPE_INVALID:
+ {
+ if (type.equals("long"))
+ return bCStyle ? "typelib_TypeClass_LONG" : "::com::sun::star::uno::TypeClass_LONG";
+ if (type.equals("short"))
+ return bCStyle ? "typelib_TypeClass_SHORT" : "::com::sun::star::uno::TypeClass_SHORT";
+ if (type.equals("hyper"))
+ return bCStyle ? "typelib_TypeClass_HYPER" : "::com::sun::star::uno::TypeClass_HYPER";
+ if (type.equals("string"))
+ return bCStyle ? "typelib_TypeClass_STRING" : "::com::sun::star::uno::TypeClass_STRING";
+ if (type.equals("boolean"))
+ return bCStyle ? "typelib_TypeClass_BOOLEAN" : "::com::sun::star::uno::TypeClass_BOOLEAN";
+ if (type.equals("char"))
+ return bCStyle ? "typelib_TypeClass_CHAR" : "::com::sun::star::uno::TypeClass_CHAR";
+ if (type.equals("byte"))
+ return bCStyle ? "typelib_TypeClass_BYTE" : "::com::sun::star::uno::TypeClass_BYTE";
+ if (type.equals("any"))
+ return bCStyle ? "typelib_TypeClass_ANY" : "::com::sun::star::uno::TypeClass_ANY";
+ if (type.equals("type"))
+ return bCStyle ? "typelib_TypeClass_TYPE" : "::com::sun::star::uno::TypeClass_TYPE";
+ if (type.equals("float"))
+ return bCStyle ? "typelib_TypeClass_FLOAT" : "::com::sun::star::uno::TypeClass_FLOAT";
+ if (type.equals("double"))
+ return bCStyle ? "typelib_TypeClass_DOUBLE" : "::com::sun::star::uno::TypeClass_DOUBLE";
+ if (type.equals("void"))
+ return bCStyle ? "typelib_TypeClass_VOID" : "::com::sun::star::uno::TypeClass_VOID";
+ if (type.equals("unsigned long"))
+ return bCStyle ? "typelib_TypeClass_UNSIGNED_LONG" : "::com::sun::star::uno::TypeClass_UNSIGNED_LONG";
+ if (type.equals("unsigned short"))
+ return bCStyle ? "typelib_TypeClass_UNSIGNED_SHORT" : "::com::sun::star::uno::TypeClass_UNSIGNED_SHORT";
+ if (type.equals("unsigned hyper"))
+ return bCStyle ? "typelib_TypeClass_UNSIGNED_HYPER" : "::com::sun::star::uno::TypeClass_UNSIGNED_HYPER";
+ }
+ break;
+ }
+
+ return bCStyle ? "typelib_TypeClass_UNKNOWN" : "::com::sun::star::uno::TypeClass_UNKNOWN";
+}
+
+void CppuType::dumpType(FileStream& o, const OString& type,
+ sal_Bool bConst, sal_Bool bRef, sal_Bool bNative)
+ throw( CannotDumpException )
+{
+ OString sType(checkRealBaseType(type, sal_True));
+ sal_uInt32 index = sType.lastIndexOf(']');
+ sal_uInt32 seqNum = (index > 0 ? ((index+1) / 2) : 0);
+
+ OString relType = (index > 0 ? (sType).copy(index+1) : type);
+
+ RTTypeClass typeClass = m_typeMgr.getTypeClass(relType);
+
+ if (bConst) o << "const ";
+
+ int i;
+ for (i=0; i < seqNum; i++)
+ {
+ o << "::com::sun::star::uno::Sequence< ";
+ }
+
+ switch (typeClass)
+ {
+ case RT_TYPE_INTERFACE:
+ if (bNative)
+ o << scopedName(m_typeName, relType);
+ else
+ o << "::com::sun::star::uno::Reference< " << scopedName(m_typeName, relType) << " >";
+ break;
+ case RT_TYPE_INVALID:
+ {
+ OString tmp(getBaseType(relType));
+ if (tmp.getLength() > 0)
+ {
+ o << getBaseType(relType);
+ } else
+ throw CannotDumpException("Unknown type '" + relType + "', incomplete type library.");
+ }
+ break;
+ case RT_TYPE_STRUCT:
+ case RT_TYPE_ENUM:
+ case RT_TYPE_TYPEDEF:
+ case RT_TYPE_EXCEPTION:
+ o << scopedName(m_typeName, relType);
+ break;
+ }
+
+ for (i=0; i < seqNum; i++)
+ {
+ o << " >";
+ }
+
+ if (bRef) o << "&";
+}
+
+OString CppuType::getBaseType(const OString& type)
+{
+ if (type.equals("long"))
+ return "sal_Int32";
+ if (type.equals("short"))
+ return "sal_Int16";
+ if (type.equals("hyper"))
+ return "sal_Int64";
+ if (type.equals("string"))
+ return "::rtl::OUString";
+ if (type.equals("boolean"))
+ return "sal_Bool";
+ if (type.equals("char"))
+ return "sal_Unicode";
+ if (type.equals("byte"))
+ return "sal_Int8";
+ if (type.equals("any"))
+ return "::com::sun::star::uno::Any";
+ if (type.equals("type"))
+ return "::com::sun::star::uno::Type";
+ if (type.equals("float"))
+ return "float";
+ if (type.equals("double"))
+ return "double";
+ if (type.equals("octet"))
+ return "sal_Int8";
+ if (type.equals("void"))
+ return type;
+ if (type.equals("unsigned long"))
+ return "sal_uInt32";
+ if (type.equals("unsigned short"))
+ return "sal_uInt16";
+ if (type.equals("unsigned hyper"))
+ return "sal_uInt64";
+
+ return OString();
+}
+
+void CppuType::dumpCppuGetType(FileStream& o, const OString& type, sal_Bool bDecl, CppuTypeDecl eDeclFlag)
+{
+ OString sType( checkRealBaseType(type, sal_True) );
+ sal_uInt32 index = sType.lastIndexOf(']');
+ OString relType = (index > 0 ? (sType).copy(index+1) : type);
+
+ if (eDeclFlag == CPPUTYPEDECL_ONLYINTERFACES)
+ {
+ if (m_typeMgr.getTypeClass(relType) == RT_TYPE_INTERFACE)
+ {
+ o << indent() << "getCppuType( (";
+ dumpType(o, type, sal_True, sal_False);
+ o << "*)0 )";
+
+ if (bDecl)
+ o << ";\n";
+ }
+ } else
+ {
+ if (isBaseType(type))
+ {
+ return;
+ } else
+ {
+ if (eDeclFlag == CPPUTYPEDECL_NOINTERFACES &&
+ m_typeMgr.getTypeClass(relType) == RT_TYPE_INTERFACE)
+ return;
+
+// if (m_typeMgr.getTypeClass(type) == RT_TYPE_TYPEDEF)
+// {
+// o << indent() << "get_" << type.replace('/', '_') << "_Type()";
+// } else
+// {
+ o << indent() << "getCppuType( (";
+ dumpType(o, type, sal_True, sal_False);
+ o << "*)0 )";
+// }
+ }
+ if (bDecl)
+ o << ";\n";
+ }
+}
+
+void CppuType::dumpTypeInit(FileStream& o, const OString& typeName)
+{
+ OString type(checkSpecialCppuType(typeName));
+
+ BASETYPE baseType = isBaseType(type);
+
+ switch (baseType)
+ {
+ case BT_BOOLEAN:
+ o << "(sal_False)";
+ return;
+ break;
+ case BT_ANY:
+ case BT_STRING:
+ o << "()";
+ return;
+ break;
+ case BT_INVALID:
+ break;
+ default:
+ o << "((";
+ dumpType(o, type);
+ o << ")" << "0)";
+ return;
+ }
+
+ RTTypeClass typeClass = m_typeMgr.getTypeClass(type);
+
+ if (typeClass == RT_TYPE_ENUM)
+ {
+ RegistryTypeReaderLoader aReaderLoader;
+
+ if (aReaderLoader.isLoaded())
+ {
+ TypeReader reader(m_typeMgr.getTypeReader(type));
+
+ if ( reader.isValid() )
+ {
+ o << "(" << shortScopedName("", type, sal_False)
+ << "::" << type.getToken(type.getTokenCount('/') - 1, '/')
+ << "_" << reader.getFieldName(0) << ")";
+ return;
+ }
+ }
+ }
+
+ o << "()";
+}
+
+BASETYPE CppuType::isBaseType(const OString& type)
+{
+ if (type.equals("long"))
+ return BT_LONG;
+ if (type.equals("short"))
+ return BT_SHORT;
+ if (type.equals("hyper"))
+ return BT_HYPER;
+ if (type.equals("string"))
+ return BT_STRING;
+ if (type.equals("boolean"))
+ return BT_BOOLEAN;
+ if (type.equals("char"))
+ return BT_CHAR;
+ if (type.equals("byte"))
+ return BT_BYTE;
+ if (type.equals("any"))
+ return BT_ANY;
+ if (type.equals("float"))
+ return BT_FLOAT;
+ if (type.equals("double"))
+ return BT_DOUBLE;
+ if (type.equals("void"))
+ return BT_VOID;
+ if (type.equals("unsigned long"))
+ return BT_UNSIGNED_LONG;
+ if (type.equals("unsigned short"))
+ return BT_UNSIGNED_SHORT;
+ if (type.equals("unsigned hyper"))
+ return BT_UNSIGNED_HYPER;
+
+ return BT_INVALID;
+}
+
+OString CppuType::typeToIdentifier(const OString& type)
+{
+ sal_uInt32 index = type.lastIndexOf(']');
+ sal_uInt32 seqNum = (index > 0 ? ((index+1) / 2) : 0);
+
+ OString relType = (index > 0 ? ((OString)type).copy(index+1) : type);
+ OString sIdentifier;
+
+ while( seqNum > 0 )
+ {
+ sIdentifier += OString("seq");
+
+ if ( --seqNum == 0 )
+ {
+ sIdentifier += OString("_");
+ }
+ }
+
+ if ( isBaseType(relType) )
+ {
+ sIdentifier += relType.replace(' ', '_');
+ } else
+ {
+ sIdentifier += relType.replace('/', '_');
+ }
+
+
+ return sIdentifier;
+}
+
+OString CppuType::checkSpecialCppuType(const OString& type)
+{
+ OString baseType(type);
+
+ RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader();
+
+ RegistryKey key;
+ sal_uInt8* pBuffer=NULL;
+ RTTypeClass typeClass;
+ sal_Bool isTypeDef = (m_typeMgr.getTypeClass(baseType) == RT_TYPE_TYPEDEF);
+ TypeReader reader;
+
+ while (isTypeDef)
+ {
+ reader = m_typeMgr.getTypeReader(baseType);
+
+ if (reader.isValid())
+ {
+ typeClass = reader.getTypeClass();
+
+ if (typeClass == RT_TYPE_TYPEDEF)
+ baseType = reader.getSuperTypeName();
+ else
+ isTypeDef = sal_False;
+ } else
+ {
+ break;
+ }
+ }
+
+ return baseType;
+}
+
+OString CppuType::checkRealBaseType(const OString& type, sal_Bool bResolveTypeOnly)
+{
+ sal_uInt32 index = type.lastIndexOf(']');
+ OString baseType = (index > 0 ? ((OString)type).copy(index+1) : type);
+ OString seqPrefix = (index > 0 ? ((OString)type).copy(0, index+1) : OString());
+
+ RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader();
+
+ RegistryKey key;
+ sal_uInt8* pBuffer=NULL;
+ RTTypeClass typeClass;
+ sal_Bool mustBeChecked = (m_typeMgr.getTypeClass(baseType) == RT_TYPE_TYPEDEF);
+ TypeReader reader;
+
+ while (mustBeChecked)
+ {
+ reader = m_typeMgr.getTypeReader(baseType);
+
+ if (reader.isValid())
+ {
+ typeClass = reader.getTypeClass();
+
+ if (typeClass == RT_TYPE_TYPEDEF)
+ {
+ baseType = reader.getSuperTypeName();
+ index = baseType.lastIndexOf(']');
+ if (index > 0)
+ {
+ seqPrefix += baseType.copy(0, index+1);
+ baseType = baseType.copy(index+1);
+ }
+ } else
+ mustBeChecked = sal_False;
+ } else
+ {
+ break;
+ }
+ }
+
+ if ( bResolveTypeOnly )
+ baseType = seqPrefix + baseType;
+
+ return baseType;
+}
+
+void CppuType::dumpConstantValue(FileStream& o, sal_uInt16 index)
+{
+ RTConstValue constValue = m_reader.getFieldConstValue(index);
+
+ switch (constValue.m_type)
+ {
+ case RT_TYPE_BOOL:
+ if (constValue.m_value.aBool)
+ o << "sal_True";
+ else
+ o << "sal_False";
+ break;
+ case RT_TYPE_BYTE:
+ {
+ char tmp[16];
+ sprintf(tmp, "0x%x", (sal_Int8)constValue.m_value.aByte);
+ o << "(sal_Int8)" << tmp;
+ }
+ break;
+ case RT_TYPE_INT16:
+ o << "(sal_Int16)" << constValue.m_value.aShort;
+ break;
+ case RT_TYPE_UINT16:
+ o << "(sal_uInt16)" << constValue.m_value.aUShort;
+ break;
+ case RT_TYPE_INT32:
+ o << "(sal_Int32)" << constValue.m_value.aLong;
+ break;
+ case RT_TYPE_UINT32:
+ o << "(sal_uInt32)" << constValue.m_value.aULong;
+ break;
+ case RT_TYPE_FLOAT:
+ o << "(float)" << constValue.m_value.aFloat;
+ break;
+ case RT_TYPE_DOUBLE:
+ o << "(double)" << constValue.m_value.aDouble;
+ break;
+ case RT_TYPE_STRING:
+ {
+ ::rtl::OUString aUStr(constValue.m_value.aString);
+ ::rtl::OString aStr = ::rtl::OUStringToOString(aUStr, RTL_TEXTENCODING_ASCII_US);
+ o << "::rtl::OUString::createFromAscii(\"" << aStr.getStr() << "\")";
+ }
+ break;
+ }
+}
+
+void CppuType::inc(sal_uInt32 num)
+{
+ m_indentLength += num;
+}
+
+void CppuType::dec(sal_uInt32 num)
+{
+ if (m_indentLength - num < 0)
+ m_indentLength = 0;
+ else
+ m_indentLength -= num;
+}
+
+OString CppuType::indent()
+{
+ OStringBuffer tmp(m_indentLength);
+
+ for (int i=0; i < m_indentLength; i++)
+ {
+ tmp.append(' ');
+ }
+ return tmp.makeStringAndClear();
+}
+
+OString CppuType::indent(sal_uInt32 num)
+{
+ OStringBuffer tmp(m_indentLength + num);
+
+ for (int i=0; i < m_indentLength + num; i++)
+ {
+ tmp.append(' ');
+ }
+ return tmp.makeStringAndClear();
+}
+
+//*************************************************************************
+// InterfaceType
+//*************************************************************************
+InterfaceType::InterfaceType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : CppuType(typeReader, typeName, typeMgr, typeDependencies)
+{
+ m_inheritedMemberCount = 0;
+ m_hasAttributes = sal_False;
+ m_hasMethods = sal_False;
+}
+
+InterfaceType::~InterfaceType()
+{
+
+}
+
+sal_Bool InterfaceType::dumpHFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ OString headerDefine(dumpHeaderDefine(o, "HDL"));
+ o << endl;
+
+ dumpDefaultHIncludes(o);
+ o << endl;
+ dumpDepIncludes(o, m_typeName, "hdl");
+ o << endl;
+ dumpNameSpace(o);
+ o << "\nclass " << m_name;
+
+ OString superType(m_reader.getSuperTypeName());
+ if (superType.getLength() > 0)
+ o << " : public " << scopedName(m_typeName, superType);
+
+ o << "\n{\npublic:\n";
+ inc();
+
+ dumpAttributes(o);
+ dumpMethods(o);
+
+ dec();
+ o << "};\n\n";
+
+ dumpNameSpace(o, sal_False);
+
+ o << "\nnamespace com { namespace sun { namespace star { namespace uno {\n"
+ << "class Type;\n} } } }\n\n";
+
+ if (m_cppuTypeStatic)
+ o << "static";
+ else
+ o << "inline";
+ o << " const ::com::sun::star::uno::Type& SAL_CALL getCppuType( ";
+ dumpType(o, m_typeName, sal_True, sal_False);
+ o << "* );\n\n";
+
+ o << "#endif // "<< headerDefine << endl;
+ return sal_True;
+}
+
+sal_Bool InterfaceType::dumpHxxFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ OString headerDefine(dumpHeaderDefine(o, "HPP"));
+ o << endl;
+
+ dumpInclude(o, m_typeName, "hdl");
+ o << endl;
+
+ dumpDefaultHxxIncludes(o);
+ o << endl;
+
+ dumpDepIncludes(o, m_typeName, "hpp");
+ o << endl;
+
+ dumpGetCppuType(o);
+
+ o << "\n#endif // "<< headerDefine << endl;
+ return sal_True;
+}
+
+void InterfaceType::dumpAttributes(FileStream& o)
+{
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ sal_Bool first=sal_True;
+
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ if (first)
+ {
+ first = sal_False;
+ o << "\n" << indent() << "// Attributes\n";
+ }
+
+ o << indent() << "virtual ";
+ dumpType(o, fieldType);
+ o << " SAL_CALL get" << fieldName << "() throw(::com::sun::star::uno::RuntimeException) = 0;\n";
+
+ if (access != RT_ACCESS_READONLY)
+ {
+ OString relType = checkSpecialCppuType(fieldType);
+ sal_Bool bRef = sal_False;
+ sal_Bool bConst = sal_False;
+
+ if (m_typeMgr.getTypeClass(relType) == RT_TYPE_ENUM ||
+ (isBaseType(relType) && !relType.equals("string") && !relType.equals("any")))
+ {
+ bConst = sal_False;
+ bRef = sal_False;
+ } else
+ {
+ bConst = sal_True;
+ bRef = sal_True;
+ }
+
+ o << indent() << "virtual void SAL_CALL set" << fieldName << "( ";
+ dumpType(o, fieldType, bConst, bRef);
+ o << " _" << fieldName.toLowerCase() << " ) throw(::com::sun::star::uno::RuntimeException) = 0;\n";
+ }
+ }
+}
+
+void InterfaceType::dumpMethods(FileStream& o)
+{
+ sal_uInt32 methodCount = m_reader.getMethodCount();
+ sal_Bool first=sal_True;
+
+ OString methodName, returnType, paramType, paramName;
+ sal_uInt32 paramCount = 0;
+ sal_uInt32 excCount = 0;
+ RTMethodMode methodMode = RT_MODE_INVALID;
+ RTParamMode paramMode = RT_PARAM_INVALID;
+
+ sal_Bool bRef = sal_False;
+ sal_Bool bConst = sal_False;
+ sal_Bool bWithRunTimeExcp = sal_True;
+
+ for (sal_uInt16 i=0; i < methodCount; i++)
+ {
+ methodName = m_reader.getMethodName(i);
+ returnType = m_reader.getMethodReturnType(i);
+ paramCount = m_reader.getMethodParamCount(i);
+ excCount = m_reader.getMethodExcCount(i);
+ methodMode = m_reader.getMethodMode(i);
+
+ if ( methodName.equals("acquire") || methodName.equals("release") )
+ {
+ bWithRunTimeExcp = sal_False;
+ }
+
+ if (first)
+ {
+ first = sal_False;
+ o << "\n" << indent() << "// Methods\n";
+ }
+
+ o << indent() << "virtual ";
+ dumpType(o, returnType);
+ o << " SAL_CALL " << methodName << "( ";
+ sal_uInt16 j;
+ for (j=0; j < paramCount; j++)
+ {
+ paramName = m_reader.getMethodParamName(i, j);
+ paramType = m_reader.getMethodParamType(i, j);
+ paramMode = m_reader.getMethodParamMode(i, j);
+
+ switch (paramMode)
+ {
+ case RT_PARAM_IN:
+ {
+ OString relType = checkSpecialCppuType(paramType);
+ if (m_typeMgr.getTypeClass(relType) == RT_TYPE_ENUM ||
+ (isBaseType(relType) && !relType.equals("string") && !relType.equals("any")))
+ {
+ bConst = sal_False;
+ bRef = sal_False;
+ } else
+ {
+ bConst = sal_True;
+ bRef = sal_True;
+ }
+ break;
+ }
+ case RT_PARAM_OUT:
+ case RT_PARAM_INOUT:
+ bConst = sal_False;
+ bRef = sal_True;
+ break;
+ }
+
+ dumpType(o, paramType, bConst, bRef);
+ o << " " << paramName;
+
+ if (j+1 < paramCount) o << ", ";
+ }
+ o << " )";
+
+ o << " throw(";
+ OString excpName;
+ for (j=0; j < excCount; j++)
+ {
+ excpName = m_reader.getMethodExcType(i, j);
+ if (excpName != "com/sun/star/uno/RuntimeException")
+ o << scopedName(m_typeName, excpName);
+ if (bWithRunTimeExcp)
+ o << ", ";
+ }
+
+ if ( bWithRunTimeExcp )
+ {
+ o << "::com::sun::star::uno::RuntimeException";
+ }
+
+ o << ") = 0;\n";
+ }
+}
+
+void InterfaceType::dumpGetCppuType(FileStream& o)
+{
+ OString typeName(m_typeName.replace('/', '_'));
+
+ if ( m_cppuTypeLeak )
+ {
+ dumpLGetCppuType(o);
+ return;
+ }
+ if ( !m_cppuTypeDynamic )
+ {
+ dumpCGetCppuType(o);
+ return;
+ }
+
+ if ( !m_typeName.equals("com/sun/star/uno/XInterface") )
+ {
+ o << "#if ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n"
+ << "#endif\n\n";
+ }
+
+ o << "inline const ::com::sun::star::uno::Type& SAL_CALL getCppuType( ";
+ dumpType(o, m_typeName, sal_True, sal_False);
+ o << "* )\n{\n";
+ inc();
+
+ if ( m_typeName.equals("com/sun/star/uno/XInterface") )
+ {
+ o << indent() << "return * reinterpret_cast< const ::com::sun::star::uno::Type * >( ::typelib_static_type_getByTypeClass("
+ << " typelib_TypeClass_INTERFACE ) );\n";
+ } else
+ {
+ o << indent() << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << indent() << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n"
+ << indent() << "#endif\n\n";
+
+ o << indent() << "if ( !s_pType_" << typeName << " )\n" << indent() << "{\n";
+ inc();
+ OString superType(m_reader.getSuperTypeName());
+ sal_Bool bWithBase = sal_False;
+ if (superType.getLength() > 0 && !superType.equals("com/sun/star/uno/XInterface"))
+ {
+ bWithBase = sal_True;
+ o << indent() << "const ::com::sun::star::uno::Type& rSuperType = getCppuType( ( ";
+ dumpType(o, superType, sal_True, sal_False);
+ o << " *)0 );\n";
+ }
+
+ o << indent() << "typelib_static_interface_type_init( &s_pType_" << typeName
+ << ", \"" << m_typeName.replace('/', '.') << "\", ";
+
+ if ( bWithBase )
+ {
+ o << "rSuperType.getTypeLibType() );\n";
+ } else
+ {
+ o << "0 );\n";
+ }
+
+ dec();
+ o << indent() << "}\n";
+ o << indent() << "return * reinterpret_cast< ::com::sun::star::uno::Type * >( &s_pType_"
+ << typeName <<" );\n";
+ }
+ dec();
+ o << indent() << "}\n";
+
+ return;
+}
+
+void InterfaceType::dumpCGetCppuType(FileStream& o)
+{
+ OString typeName(m_typeName.replace('/', '_'));
+
+ o << "#if ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << "static ::com::sun::star::uno::Type * pType_" << typeName << " = 0;\n"
+ << "#endif\n\n";
+
+ if (m_cppuTypeStatic)
+ o << "static";
+ else
+ o << "inline";
+ o << " const ::com::sun::star::uno::Type& SAL_CALL getCppuType( ";
+ dumpType(o, m_typeName, sal_True, sal_False);
+ o << "* )\n{\n";
+ inc();
+
+ o << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << indent() << "static ::com::sun::star::uno::Type * pType_" << typeName << " = 0;\n"
+ << "#endif\n\n";
+
+ o << indent() << "if ( !pType_" << typeName << " )\n" << indent() << "{\n";
+ inc();
+ o << indent() << "::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );\n";
+
+ o << indent() << "if ( !pType_" << typeName << " )\n" << indent() << "{\n";
+ inc();
+ o << indent() << "::rtl::OUString sTypeName( RTL_CONSTASCII_USTRINGPARAM(\""
+ << m_typeName.replace('/', '.') << "\") );\n\n";
+
+ if ( m_cppuTypeDynamic )
+ {
+ o << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n";
+ o << indent() << "static ::com::sun::star::uno::Type aType_" << typeName << "( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << indent() << "pType_" << typeName << " = &aType_" << typeName << ";\n";
+ o << "#else\n";
+ o << indent() << "pType_" << typeName << " = new ::com::sun::star::uno::Type( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << "#endif\n";
+ } else
+ {
+ o << indent() << "// Start inline typedescription generation\n"
+ << indent() << "typelib_InterfaceTypeDescription * pTD = 0;\n\n";
+
+ OString superType(m_reader.getSuperTypeName());
+ if (superType.getLength() > 0)
+ {
+ o << indent() << "const ::com::sun::star::uno::Type& rSuperType = getCppuType( ( ";
+ dumpType(o, superType, sal_True, sal_False);
+ o << " *)0 );\n";
+ }
+
+ sal_uInt32 count = getMemberCount();
+ if (count)
+ {
+ o << indent() << "typelib_TypeDescriptionReference * pMembers[" << count << "] = { ";
+ for (sal_uInt16 i = 0; i < count; i++)
+ {
+ o << "0";
+ if (i+1 < count)
+ o << ",";
+ else
+ o << " };\n";
+ }
+
+ sal_uInt32 index = 0;
+ dumpCppuAttributeRefs(o, index);
+ dumpCppuMethodRefs(o, index);
+ }
+
+ o << "\n" << indent() << "typelib_typedescription_newInterface(\n";
+ inc();
+ o << indent() << "&pTD,\n"
+ << indent() << "sTypeName.pData, ";
+
+ RTUik uik;
+ m_reader.getUik(uik);
+ sal_Char buffer[53];
+ sprintf(buffer, "0x%.8x, 0x%.4x, 0x%.4x, 0x%.8x, 0x%.8x,\n",
+ uik.m_Data1, uik.m_Data2, uik.m_Data3, uik.m_Data4, uik.m_Data5);
+ o << buffer;
+
+ if (superType.getLength() > 0)
+ o << indent() << "rSuperType.getTypeLibType(),\n";
+ else
+ o << indent() << "0,\n";
+
+ if ( count )
+ {
+ o << indent() << count << ",\n" << indent() << "pMembers );\n\n";
+ } else
+ {
+ o << indent() << count << ",\n" << indent() << "0 );\n\n";
+ }
+ dec();
+
+ o << indent() << "typelib_typedescription_register( (typelib_TypeDescription**)&pTD );\n";
+ if ( count )
+ {
+ for (sal_uInt16 i=0; i < count; i++)
+ {
+ o << indent() << "typelib_typedescriptionreference_release( pMembers["
+ << i << "] );\n";
+ }
+ }
+ o << indent() << "typelib_typedescription_release( (typelib_TypeDescription*)pTD );\n\n";
+
+// if (superType.getLength() > 0)
+// o << indent() << "typelib_typedescription_release( pSuperTD );\n\n";
+// else
+// o << endl;
+
+ o << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n";
+ o << indent() << "static ::com::sun::star::uno::Type aType_" << typeName << "( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << indent() << "pType_" << typeName << " = &aType_" << typeName << ";\n";
+ o << "#else\n";
+ o << indent() << "pType_" << typeName << " = new ::com::sun::star::uno::Type( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << "#endif\n";
+
+ StringSet aTypes;
+ // type for RuntimeException is always needed
+ OString sRunTimeExceptionType("com/sun/star/uno/RuntimeException");
+ aTypes.insert(sRunTimeExceptionType);
+ dumpCppuGetType(o, sRunTimeExceptionType, sal_True, CPPUTYPEDECL_ALLTYPES);
+
+ dumpAttributesCppuDecl(o, &aTypes, CPPUTYPEDECL_ALLTYPES);
+ dumpMethodsCppuDecl(o, &aTypes, CPPUTYPEDECL_ALLTYPES);
+
+ if (count)
+ {
+ sal_uInt32 index = getInheritedMemberCount();
+ dumpCppuAttributes(o, index);
+ dumpCppuMethods(o, index);
+ }
+
+ o << indent() << "// End inline typedescription generation\n";
+ }
+
+ dec();
+ o << indent() << "}\n";
+ dec();
+ o << indent() << "}\n\n"
+ << indent() << "return *pType_" << typeName << ";\n";
+
+ dec();
+ o << "}\n";
+}
+
+void InterfaceType::dumpCppuAttributeRefs(FileStream& o, sal_uInt32& index)
+{
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString scope = m_typeName.replace('/', '.');
+
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+
+ o << indent() << "::rtl::OUString sAttributeName" << i << "( RTL_CONSTASCII_USTRINGPARAM(\""
+ << scope.replace('/', '.') << "::" << fieldName << "\") );\n";
+ o << indent() << "typelib_typedescriptionreference_new( &pMembers["
+ << index << "],\n";
+ inc(38);
+ o << indent() << "(typelib_TypeClass)::com::sun::star::uno::TypeClass_INTERFACE_ATTRIBUTE,\n"
+ << indent() << "sAttributeName" << i << ".pData );\n";
+ dec(38);
+ index++;
+ }
+}
+
+void InterfaceType::dumpCppuMethodRefs(FileStream& o, sal_uInt32& index)
+{
+ sal_uInt32 methodCount = m_reader.getMethodCount();
+ OString methodName; //, returnType, paramType, paramName;
+ OString scope = m_typeName.replace('/', '.');
+
+ for (sal_uInt16 i = 0; i < methodCount; i++)
+ {
+ methodName = m_reader.getMethodName(i);
+
+ o << indent() << "::rtl::OUString sMethodName" << i << "( RTL_CONSTASCII_USTRINGPARAM(\""
+ << scope.replace('/', '.') << "::" << methodName << "\") );\n";
+ o << indent() << "typelib_typedescriptionreference_new( &pMembers["
+ << index << "],\n";
+ inc(38);
+ o << indent() << "(typelib_TypeClass)::com::sun::star::uno::TypeClass_INTERFACE_METHOD,\n"
+ << indent() << "sMethodName" << i << ".pData );\n";
+ dec(38);
+ index++;
+ }
+}
+
+sal_uInt32 InterfaceType::getMemberCount()
+{
+ sal_uInt32 count = m_reader.getMethodCount();
+
+ if (count)
+ m_hasMethods = sal_True;
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access != RT_ACCESS_CONST && access != RT_ACCESS_INVALID)
+ {
+ m_hasAttributes = sal_True;
+ count++;
+ }
+ }
+ return count;
+}
+
+sal_uInt32 InterfaceType::checkInheritedMemberCount(const TypeReader* pReader)
+{
+ sal_uInt32 cout = 0;
+ sal_Bool bSelfCheck = sal_True;
+ if (!pReader)
+ {
+ bSelfCheck = sal_False;
+ pReader = &m_reader;
+ }
+
+ sal_uInt32 count = 0;
+ OString superType(pReader->getSuperTypeName());
+ if (superType.getLength() > 0)
+ {
+ TypeReader aSuperReader(m_typeMgr.getTypeReader(superType));
+ if (aSuperReader.isValid())
+ {
+ count = checkInheritedMemberCount(&aSuperReader);
+ }
+ }
+
+ if (bSelfCheck)
+ {
+ count += pReader->getMethodCount();
+ sal_uInt32 fieldCount = pReader->getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = pReader->getFieldAccess(i);
+
+ if (access != RT_ACCESS_CONST && access != RT_ACCESS_INVALID)
+ {
+ count++;
+ }
+ }
+ }
+
+ return count;
+}
+
+sal_uInt32 InterfaceType::getInheritedMemberCount()
+{
+ if (m_inheritedMemberCount == 0)
+ {
+ m_inheritedMemberCount = checkInheritedMemberCount(0);
+ }
+
+ return m_inheritedMemberCount;
+}
+
+void InterfaceType::dumpCppuAttributes(FileStream& o, sal_uInt32& index)
+{
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ OString scope = m_typeName.replace('/', '.');
+
+ sal_uInt32 absoluteIndex = index;
+
+ if (m_hasAttributes)
+ {
+ o << "\n" << indent() << "typelib_InterfaceAttributeTypeDescription * pAttribute = 0;\n";
+
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = checkRealBaseType(m_reader.getFieldType(i), sal_True);
+
+ o << indent() << "::rtl::OUString sAttributeType" << i << "( RTL_CONSTASCII_USTRINGPARAM(\""
+ << fieldType.replace('/', '.') << "\") );\n";
+ o << indent() << "typelib_typedescription_newInterfaceAttribute( &pAttribute,\n";
+ inc();
+ o << indent() << absoluteIndex++ << ", sAttributeName" << i << ".pData,\n";
+ o << indent() << "(typelib_TypeClass)" << getTypeClass(fieldType)
+ << ", sAttributeType" << i << ".pData,\n";
+ if (access == RT_ACCESS_READONLY)
+ o << indent() << "sal_True );\n";
+ else
+ o << indent() << "sal_False );\n";
+ dec();
+ o << indent() << "typelib_typedescription_register( (typelib_TypeDescription**)&pAttribute );\n\n";
+ }
+ o << indent() << "typelib_typedescription_release( (typelib_TypeDescription*)pAttribute );\n";
+
+ index = absoluteIndex;
+ }
+}
+
+void InterfaceType::dumpCppuMethods(FileStream& o, sal_uInt32& index)
+{
+ sal_uInt32 methodCount = m_reader.getMethodCount();
+ OString methodName, returnType, paramType, paramName;
+ OString scope = m_typeName.replace('/', '.');
+ sal_uInt32 paramCount = 0;
+ sal_uInt32 excCount = 0;
+ RTMethodMode methodMode = RT_MODE_INVALID;
+ RTParamMode paramMode = RT_PARAM_INVALID;
+
+ sal_uInt32 absoluteIndex = index;
+
+ if (m_hasMethods)
+ {
+ o << "\n" << indent() << "typelib_InterfaceMethodTypeDescription * pMethod = 0;\n";
+
+ for (sal_uInt16 i=0; i < methodCount; i++)
+ {
+ methodName = m_reader.getMethodName(i);
+ returnType = checkRealBaseType(m_reader.getMethodReturnType(i), sal_True);
+ paramCount = m_reader.getMethodParamCount(i);
+ excCount = m_reader.getMethodExcCount(i);
+ methodMode = m_reader.getMethodMode(i);
+
+ o << indent() << "{\n";
+ inc();
+
+ if (paramCount)
+ {
+ o << indent() << "typelib_Parameter_Init aParameters[" << paramCount << "];\n";
+ }
+
+ sal_uInt16 j;
+ for (j=0; j < paramCount; j++)
+ {
+ paramName = m_reader.getMethodParamName(i, j);
+ paramType = checkRealBaseType(m_reader.getMethodParamType(i, j), sal_True);
+ paramMode = m_reader.getMethodParamMode(i, j);
+
+ o << indent() << "::rtl::OUString sParamName" << j << "( RTL_CONSTASCII_USTRINGPARAM(\""
+ << scope << "::" << paramName << "\") );\n";
+ o << indent() << "::rtl::OUString sParamType" << j << "( RTL_CONSTASCII_USTRINGPARAM(\""
+ << paramType.replace('/', '.') << "\") );\n";
+ o << indent() << "aParameters[" << j << "].pParamName = sParamName" << j << ".pData;\n";
+ o << indent() << "aParameters[" << j << "].eTypeClass = (typelib_TypeClass)"
+ << getTypeClass(paramType) << ";\n";
+ o << indent() << "aParameters[" << j << "].pTypeName = sParamType" << j << ".pData;\n";
+
+ if (paramMode == RT_PARAM_IN || paramMode == RT_PARAM_INOUT)
+ o << indent() << "aParameters[" << j << "].bIn = sal_True;\n";
+ else
+ o << indent() << "aParameters[" << j << "].bIn = sal_False;\n";
+
+ if (paramMode == RT_PARAM_OUT || paramMode == RT_PARAM_INOUT)
+ o << indent() << "aParameters[" << j << "].bOut = sal_True;\n";
+ else
+ o << indent() << "aParameters[" << j << "].bOut = sal_False;\n";
+ }
+
+ o << indent() << "rtl_uString * pExceptions[" << excCount + 1 << "];\n";
+ for (j=0; j < excCount; j++)
+ {
+ if (!m_reader.getMethodExcType(i, j).equals("com/sun/star/uno/RuntimeException"))
+ {
+ o << indent() << "::rtl::OUString sExceptionName" << j << "( RTL_CONSTASCII_USTRINGPARAM(\""
+ << OString(m_reader.getMethodExcType(i, j)).replace('/', '.') << "\") );\n";
+ o << indent() << "pExceptions[" << j << "] = sExceptionName" << j << ".pData;\n";
+ }
+ }
+ o << indent() << "::rtl::OUString sExceptionName" << excCount << "( RTL_CONSTASCII_USTRINGPARAM("
+ << "\"com.sun.star.uno.RuntimeException\") );\n";
+
+ o << indent() << "pExceptions[" << excCount << "] = sExceptionName" << excCount << ".pData;\n";
+
+ o << indent() << "::rtl::OUString sReturnType" << i << "( RTL_CONSTASCII_USTRINGPARAM(\""
+ << returnType.replace('/', '.') << "\") );\n";
+ o << indent() << "typelib_typedescription_newInterfaceMethod( &pMethod,\n";
+ inc();
+ o << indent() << absoluteIndex++ << ", ";
+ if (methodMode == RT_MODE_ONEWAY || methodMode == RT_MODE_ONEWAY_CONST)
+ o << "sal_True,\n";
+ else
+ o << "sal_False,\n";
+ o << indent() << "sMethodName" << i << ".pData,\n";
+ o << indent() << "(typelib_TypeClass)" << getTypeClass(returnType)
+ << ", sReturnType" << i << ".pData,\n";
+ if (paramCount)
+ o << indent() << paramCount << ", aParameters,\n";
+ else
+ o << indent() << "0, 0,\n";
+
+ o << indent() << excCount + 1 << ", pExceptions );\n";
+ dec();
+ o << indent() << "typelib_typedescription_register( (typelib_TypeDescription**)&pMethod );\n";
+
+ dec();
+ o << indent() << "}\n";
+ }
+ o << indent() << "typelib_typedescription_release( (typelib_TypeDescription*)pMethod );\n";
+
+ index = absoluteIndex;
+ }
+}
+
+void InterfaceType::dumpAttributesCppuDecl(FileStream& o, StringSet* pFinishedTypes, CppuTypeDecl eDeclFlag)
+{
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ if (pFinishedTypes->count(fieldType) == 0)
+ {
+ pFinishedTypes->insert(fieldType);
+ dumpCppuGetType(o, fieldType, sal_True, eDeclFlag);
+ }
+ }
+}
+
+void InterfaceType::dumpMethodsCppuDecl(FileStream& o, StringSet* pFinishedTypes, CppuTypeDecl eDeclFlag)
+{
+ sal_uInt32 methodCount = m_reader.getMethodCount();
+ OString returnType, paramType, excType;
+ sal_uInt32 paramCount = 0;
+ sal_uInt32 excCount = 0;
+
+ for (sal_uInt16 i=0; i < methodCount; i++)
+ {
+ returnType = m_reader.getMethodReturnType(i);
+ paramCount = m_reader.getMethodParamCount(i);
+ excCount = m_reader.getMethodExcCount(i);
+
+ if (pFinishedTypes->count(returnType) == 0)
+ {
+ pFinishedTypes->insert(returnType);
+ dumpCppuGetType(o, returnType, sal_True, eDeclFlag);
+ }
+ sal_uInt16 j;
+ for (j=0; j < paramCount; j++)
+ {
+ paramType = m_reader.getMethodParamType(i, j);
+
+ if (pFinishedTypes->count(paramType) == 0)
+ {
+ pFinishedTypes->insert(paramType);
+ dumpCppuGetType(o, paramType, sal_True, eDeclFlag);
+ }
+ }
+
+ for (j=0; j < excCount; j++)
+ {
+ excType = m_reader.getMethodExcType(i, j);
+ if (pFinishedTypes->count(excType) == 0)
+ {
+ pFinishedTypes->insert(excType);
+ dumpCppuGetType(o, excType, sal_True, eDeclFlag);
+ }
+ }
+ }
+}
+
+//*************************************************************************
+// ModuleType
+//*************************************************************************
+ModuleType::ModuleType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : CppuType(typeReader, typeName, typeMgr, typeDependencies)
+{
+}
+
+ModuleType::~ModuleType()
+{
+
+}
+
+sal_Bool ModuleType::dump(CppuOptions* pOptions)
+ throw( CannotDumpException )
+{
+ sal_Bool ret = sal_False;
+
+ if (pOptions->isValid("-U"))
+ m_cppuTypeDynamic = sal_True;
+
+ OString outPath;
+ if (pOptions->isValid("-O"))
+ outPath = pOptions->getOption("-O");
+
+ OString tmpName(m_typeName);
+
+ if (tmpName.equals("/"))
+ tmpName = "global";
+ else
+ tmpName += "/" + m_typeName.getToken(m_typeName.getTokenCount('/') - 1, '/');
+
+ OString tmpFileName;
+ OString hFileName = createFileNameFromType(outPath, tmpName, ".hdl");
+
+ sal_Bool bFileExists = sal_False;
+ sal_Bool bFileCheck = sal_False;
+
+ if ( pOptions->isValid("-G") || pOptions->isValid("-Gc") )
+ {
+ bFileExists = fileExists( hFileName );
+ ret = sal_True;
+ }
+
+ if ( bFileExists && pOptions->isValid("-Gc") )
+ {
+ tmpFileName = createFileNameFromType(outPath, m_typeName, ".tml");
+ bFileCheck = sal_True;
+ }
+
+ if ( !bFileExists || bFileCheck )
+ {
+ FileStream hFile;
+
+ if ( bFileCheck )
+ hFile.openFile(tmpFileName);
+ else
+ hFile.openFile(hFileName);
+
+ if(!hFile.isValid())
+ {
+ OString message("cannot open ");
+ message += hFileName + " for writing";
+ throw CannotDumpException(message);
+ }
+
+ ret = dumpHFile(hFile);
+
+ hFile.closeFile();
+ if (ret && bFileCheck)
+ {
+ ret = checkFileContent(hFileName, tmpFileName);
+ }
+ }
+
+ OString hxxFileName = createFileNameFromType(outPath, tmpName, ".hpp");
+
+ if ( pOptions->isValid("-G") || pOptions->isValid("-Gc") )
+ {
+ bFileExists = fileExists( hFileName );
+ ret = sal_True;
+ }
+
+ if ( bFileExists && pOptions->isValid("-Gc") )
+ {
+ tmpFileName = createFileNameFromType(outPath, m_typeName, ".tmp");
+ bFileCheck = sal_True;
+ }
+
+
+ if ( !bFileExists || bFileCheck )
+ {
+ FileStream hxxFile;
+
+ if ( bFileCheck )
+ hxxFile.openFile(tmpFileName);
+ else
+ hxxFile.openFile(hxxFileName);
+
+ if(!hxxFile.isValid())
+ {
+ OString message("cannot open ");
+ message += hxxFileName + " for writing";
+ throw CannotDumpException(message);
+ }
+
+ ret = dumpHxxFile(hxxFile);
+
+ hxxFile.closeFile();
+ if (ret && bFileCheck)
+ {
+ ret = checkFileContent(hFileName, tmpFileName);
+ }
+ }
+
+ return ret;
+}
+
+sal_Bool ModuleType::dumpHFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ sal_Bool bSpecialDefine = sal_True;
+
+ if (m_reader.getTypeClass() == RT_TYPE_CONSTANTS)
+ {
+ bSpecialDefine = sal_False;
+ }
+
+ OString headerDefine(dumpHeaderDefine(o, "HDL", bSpecialDefine));
+ o << endl;
+
+ dumpDefaultHIncludes(o);
+ o << endl;
+ dumpDepIncludes(o, m_typeName, "hdl");
+ o << endl;
+
+ dumpNameSpace(o, sal_True, sal_True);
+ o << endl;
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST)
+ {
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ o << "static const ";
+ dumpType(o, fieldType);
+ o << " " << fieldName << " = ";
+ dumpConstantValue(o, i);
+ o << ";\n";
+ }
+ }
+
+ o << endl;
+ dumpNameSpace(o, sal_False, sal_True);
+ o << "\n#endif // "<< headerDefine << endl;
+
+ return sal_True;
+}
+
+sal_Bool ModuleType::hasConstants()
+{
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST)
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+sal_Bool ModuleType::dumpHxxFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ sal_Bool bSpecialDefine = sal_True;
+
+ if (m_reader.getTypeClass() == RT_TYPE_CONSTANTS)
+ {
+ bSpecialDefine = sal_False;
+ }
+
+ OString headerDefine(dumpHeaderDefine(o, "HPP", bSpecialDefine));
+ o << endl;
+
+ dumpInclude(o, m_typeName, "hdl", bSpecialDefine);
+
+ o << "\n#endif // "<< headerDefine << endl;
+
+ return sal_True;
+}
+
+//*************************************************************************
+// ConstantsType
+//*************************************************************************
+ConstantsType::ConstantsType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : ModuleType(typeReader, typeName, typeMgr, typeDependencies)
+{
+}
+
+ConstantsType::~ConstantsType()
+{
+
+}
+
+sal_Bool ConstantsType::dump(CppuOptions* pOptions)
+ throw( CannotDumpException )
+{
+ sal_Bool ret = sal_False;
+
+ if (pOptions->isValid("-U"))
+ m_cppuTypeDynamic = sal_True;
+
+ OString outPath;
+ if (pOptions->isValid("-O"))
+ outPath = pOptions->getOption("-O");
+
+ OString tmpFileName;
+ OString hFileName = createFileNameFromType(outPath, m_typeName, ".hdl");
+
+ sal_Bool bFileExists = sal_False;
+ sal_Bool bFileCheck = sal_False;
+
+ if ( pOptions->isValid("-G") || pOptions->isValid("-Gc") )
+ {
+ bFileExists = fileExists( hFileName );
+ ret = sal_True;
+ }
+
+ if ( bFileExists && pOptions->isValid("-Gc") )
+ {
+ tmpFileName = createFileNameFromType(outPath, m_typeName, ".tml");
+ bFileCheck = sal_True;
+ }
+
+ if ( !bFileExists || bFileCheck )
+ {
+ FileStream hFile;
+
+ if ( bFileCheck )
+ hFile.openFile(tmpFileName);
+ else
+ hFile.openFile(hFileName);
+
+ if(!hFile.isValid())
+ {
+ OString message("cannot open ");
+ message += hFileName + " for writing";
+ throw CannotDumpException(message);
+ }
+
+ ret = dumpHFile(hFile);
+
+ hFile.closeFile();
+ if (ret && bFileCheck)
+ {
+ ret = checkFileContent(hFileName, tmpFileName);
+ }
+ }
+
+ OString hxxFileName = createFileNameFromType(outPath, m_typeName, ".hpp");
+
+ if ( pOptions->isValid("-G") || pOptions->isValid("-Gc") )
+ {
+ bFileExists = fileExists( hFileName );
+ ret = sal_True;
+ }
+
+ if ( bFileExists && pOptions->isValid("-Gc") )
+ {
+ tmpFileName = createFileNameFromType(outPath, m_typeName, ".tmp");
+ bFileCheck = sal_True;
+ }
+
+ if ( !bFileExists || bFileCheck )
+ {
+ FileStream hxxFile;
+
+ if ( bFileCheck )
+ hxxFile.openFile(tmpFileName);
+ else
+ hxxFile.openFile(hxxFileName);
+
+ if(!hxxFile.isValid())
+ {
+ OString message("cannot open ");
+ message += hxxFileName + " for writing";
+ throw CannotDumpException(message);
+ }
+
+ ret = dumpHxxFile(hxxFile);
+
+ hxxFile.closeFile();
+ if (ret && bFileCheck)
+ {
+ ret = checkFileContent(hFileName, tmpFileName);
+ }
+ }
+
+ return ret;
+}
+
+//*************************************************************************
+// StructureType
+//*************************************************************************
+StructureType::StructureType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : CppuType(typeReader, typeName, typeMgr, typeDependencies)
+{
+}
+
+StructureType::~StructureType()
+{
+
+}
+
+sal_Bool StructureType::dumpHFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ OString headerDefine(dumpHeaderDefine(o, "HDL"));
+ o << endl;
+
+ dumpDefaultHIncludes(o);
+ o << endl;
+ dumpDepIncludes(o, m_typeName, "hdl");
+ o << endl;
+
+ dumpNameSpace(o);
+
+ o << "\n#ifdef SAL_W32\n"
+ << "# pragma pack(push, 8)\n"
+ << "#elif defined(SAL_OS2)\n"
+ << "# pragma pack(8)\n"
+ << "#endif\n\n";
+
+ o << "struct " << m_name;
+
+ OString superType(m_reader.getSuperTypeName());
+ if (superType.getLength() > 0)
+ o << " : public " << scopedName(m_typeName, superType);
+
+ o << "\n{\n";
+ inc();
+ o << indent() << "inline " << m_name << "();\n\n";
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ sal_uInt16 i=0;
+ if (fieldCount > 0 || getInheritedMemberCount() > 0)
+ {
+ o << indent() << m_name << "(";
+
+ sal_Bool superHasMember = dumpSuperMember(o, superType, sal_True);
+
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ if (superHasMember)
+ o << ", ";
+ else
+ superHasMember = sal_True;
+
+ dumpType(o, fieldType, sal_True, sal_True);
+ o << " __" << fieldName;
+ }
+ o << ");\n\n";
+ }
+
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ o << indent();
+ dumpType(o, fieldType);
+ o << " " << fieldName << ";\n";
+ }
+
+ dec();
+ o << "};\n\n";
+
+ o << "#ifdef SAL_W32\n"
+ << "# pragma pack(pop)\n"
+ << "#elif defined(SAL_OS2)\n"
+ << "# pragma pack()\n"
+ << "#endif\n\n";
+
+ dumpNameSpace(o, sal_False);
+
+ o << "\nnamespace com { namespace sun { namespace star { namespace uno {\n"
+ << "class Type;\n} } } }\n\n";
+
+ if (m_cppuTypeStatic)
+ o << "static";
+ else
+ o << "inline";
+ o << " const ::com::sun::star::uno::Type& SAL_CALL getCppuType( ";
+ dumpType(o, m_typeName, sal_True, sal_False);
+ o << "* );\n\n";
+
+ o << "#endif // "<< headerDefine << endl;
+
+ return sal_True;
+}
+
+sal_Bool StructureType::dumpHxxFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ OString headerDefine(dumpHeaderDefine(o, "HPP"));
+ o << endl;
+
+ dumpInclude(o, m_typeName, "hdl");
+ o << endl;
+
+ dumpDefaultHxxIncludes(o);
+ o << endl;
+
+ dumpDepIncludes(o, m_typeName, "hpp");
+ o << endl;
+
+ dumpNameSpace(o);
+ o << endl;
+
+ o << "inline " << m_name << "::" << m_name << "()\n";
+ inc();
+ OString superType(m_reader.getSuperTypeName());
+ sal_Bool first = sal_True;
+ if (superType.getLength() > 0)
+ {
+ o << indent() << ": " << scopedName(m_typeName, superType) << "()\n";
+ first = sal_False;
+ }
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ sal_uInt16 i = 0;
+
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ if (first)
+ {
+ first = sal_False;
+ o << indent() << ": ";
+ } else
+ o << indent() << ", ";
+
+ o << fieldName;
+ dumpTypeInit(o, fieldType);
+ o << endl;
+ }
+ dec();
+ o << "{\n}\n\n";
+
+ if (fieldCount > 0 || getInheritedMemberCount() > 0)
+ {
+ o << indent() << "inline " << m_name << "::" << m_name << "(";
+
+ sal_Bool superHasMember = dumpSuperMember(o, superType, sal_True);
+
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ if (superHasMember)
+ o << ", ";
+ else
+ superHasMember = sal_True;
+
+ dumpType(o, fieldType, sal_True, sal_True);
+ o << " __" << fieldName;
+ }
+ o << ")\n";
+
+ inc();
+ sal_Bool first = sal_True;
+ if (superType.getLength() > 0)
+ {
+ o << indent() << ": " << scopedName(m_typeName, superType) << "(";
+ dumpSuperMember(o, superType, sal_False);
+ o << ")\n";
+ first = sal_False;
+ }
+
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+
+ if (first)
+ {
+ first = sal_False;
+ o << indent() << ": ";
+ } else
+ o << indent() << ", ";
+
+ o << fieldName << "(__" << fieldName << ")\n";
+ }
+
+ dec();
+ o << "{\n}\n\n";
+ }
+
+ dumpNameSpace(o, sal_False);
+
+ o << endl;
+ dumpGetCppuType(o);
+
+ o << "\n#endif // "<< headerDefine << endl;
+
+ return sal_True;
+}
+
+sal_Bool StructureType::dumpSuperMember(FileStream& o, const OString& superType, sal_Bool bWithType)
+{
+ sal_Bool hasMember = sal_False;
+
+ if (superType.getLength() > 0)
+ {
+ TypeReader aSuperReader(m_typeMgr.getTypeReader(superType));
+
+ if (aSuperReader.isValid())
+ {
+ hasMember = dumpSuperMember(o, aSuperReader.getSuperTypeName(), bWithType);
+
+ sal_uInt32 fieldCount = aSuperReader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ for (sal_Int16 i=0; i < fieldCount; i++)
+ {
+ access = aSuperReader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = aSuperReader.getFieldName(i);
+ fieldType = aSuperReader.getFieldType(i);
+
+ if (hasMember)
+ {
+ o << ", ";
+ } else
+ {
+ hasMember = (fieldCount > 0);
+ }
+
+ if (bWithType)
+ {
+ dumpType(o, fieldType, sal_True, sal_True);
+ o << " ";
+ }
+ o << "__" << fieldName;
+ }
+ }
+/*
+ RegistryKey superKey = m_typeMgr.getTypeKey(superType);
+ RegValueType valueType;
+ sal_uInt32 valueSize;
+
+ if (!superKey.getValueInfo(OUString(), &valueType, &valueSize))
+ {
+ sal_uInt8* pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize);
+ RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader();
+
+ if (!superKey.getValue(OUString(), pBuffer) )
+ {
+ TypeReader aSuperReader(rReaderLoader, pBuffer, valueSize, sal_True);
+
+ hasMember = dumpSuperMember(o, aSuperReader.getSuperTypeName(), bWithType);
+
+ sal_uInt32 fieldCount = aSuperReader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ for (sal_Int16 i=0; i < fieldCount; i++)
+ {
+ access = aSuperReader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = aSuperReader.getFieldName(i);
+ fieldType = aSuperReader.getFieldType(i);
+
+ if (hasMember)
+ {
+ o << ", ";
+ } else
+ {
+ hasMember = (fieldCount > 0);
+ }
+
+ if (bWithType)
+ {
+ dumpType(o, fieldType, sal_True, sal_True);
+ o << " ";
+ }
+ o << "__" << fieldName;
+ }
+ }
+
+ rtl_freeMemory(pBuffer);
+ }
+*/
+ }
+
+ return hasMember;
+}
+
+//*************************************************************************
+// ExceptionType
+//*************************************************************************
+ExceptionType::ExceptionType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : CppuType(typeReader, typeName, typeMgr, typeDependencies)
+{
+}
+
+ExceptionType::~ExceptionType()
+{
+
+}
+
+sal_Bool ExceptionType::dumpHFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ OString headerDefine(dumpHeaderDefine(o, "HDL"));
+ o << endl;
+
+ dumpDefaultHIncludes(o);
+ o << endl;
+ dumpDepIncludes(o, m_typeName, "hdl");
+ o << endl;
+
+ dumpNameSpace(o);
+
+ o << "\nclass " << m_name;
+
+ OString superType(m_reader.getSuperTypeName());
+ if (superType.getLength() > 0)
+ o << " : public " << scopedName(m_typeName, superType);
+
+ o << "\n{\npublic:\n";
+ inc();
+// o << indent() << "inline " << m_name << "();\n\n";
+ o << indent() << "inline " << m_name << "() { }\n\n";
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ sal_uInt16 i = 0;
+
+ if (fieldCount > 0 || getInheritedMemberCount() > 0)
+ {
+ o << indent() << "inline " << m_name << "(";
+
+ sal_Bool superHasMember = dumpSuperMember(o, superType, sal_True);
+
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ if (superHasMember)
+ o << ", ";
+ else
+ superHasMember = sal_True;
+
+ dumpType(o, fieldType, sal_True, sal_True);
+ o << " __" << fieldName;
+ }
+ o << ");\n\n";
+ }
+
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ o << indent();
+ dumpType(o, fieldType);
+ o << " " << fieldName << ";\n";
+ }
+
+
+ dec();
+ o << "};\n\n";
+
+ dumpNameSpace(o, sal_False);
+
+ o << "\nnamespace com { namespace sun { namespace star { namespace uno {\n"
+ << "class Type;\n} } } }\n\n";
+
+ if (m_cppuTypeStatic)
+ o << "static";
+ else
+ o << "inline";
+ o << " const ::com::sun::star::uno::Type& SAL_CALL getCppuType( ";
+ dumpType(o, m_typeName, sal_True, sal_False);
+ o << "* );\n\n";
+
+ o << "#endif // "<< headerDefine << endl;
+
+ return sal_True;
+}
+
+sal_Bool ExceptionType::dumpHxxFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ OString headerDefine(dumpHeaderDefine(o, "HPP"));
+ o << endl;
+
+ dumpInclude(o, m_typeName, "hdl");
+ o << endl;
+
+ dumpDefaultHxxIncludes(o);
+ o << endl;
+
+ dumpDepIncludes(o, m_typeName, "hpp");
+ o << endl;
+
+ dumpNameSpace(o);
+ o << endl;
+//
+ OString superType(m_reader.getSuperTypeName());
+ sal_Bool first = sal_True;
+/*
+ o << "inline " << m_name << "::" << m_name << "()\n";
+ inc();
+ OString superType(m_reader.getSuperTypeName());
+ sal_Bool first = sal_True;
+ if (superType.getLength() > 0)
+ {
+ o << indent() << ": " << scopedName(m_typeName, superType) << "()\n";
+ first = sal_False;
+ }
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ sal_uInt16 i = 0;
+
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ if (first)
+ {
+ first = sal_False;
+ o << indent() << ": ";
+ } else
+ o << indent() << ", ";
+
+ o << fieldName;
+ dumpTypeInit(o, fieldType);
+ o << endl;
+ }
+ dec();
+ o << "{\n";
+ inc();
+ dumpCppuGetType(o, m_typeName, sal_True);
+ dec();
+ o << "}\n\n";
+*/
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ sal_uInt16 i = 0;
+//
+ if (fieldCount > 0 || getInheritedMemberCount() > 0)
+ {
+ o << indent() << "inline " << m_name << "::" << m_name << "(";
+
+ sal_Bool superHasMember = dumpSuperMember(o, superType, sal_True);
+
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ if (superHasMember)
+ o << ", ";
+ else
+ superHasMember = sal_True;
+
+ dumpType(o, fieldType, sal_True, sal_True);
+ o << " __" << fieldName;
+ }
+ o << ")\n";
+
+ inc();
+ sal_Bool first = sal_True;
+ if (superType.getLength() > 0)
+ {
+ o << indent() << ": " << scopedName(m_typeName, superType) << "(";
+ dumpSuperMember(o, superType, sal_False);
+ o << ")\n";
+ first = sal_False;
+ }
+
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+
+ if (first)
+ {
+ first = sal_False;
+ o << indent() << ": ";
+ } else
+ o << indent() << ", ";
+
+ o << fieldName << "(__" << fieldName << ")\n";
+ }
+
+ dec();
+ o << "{ }\n\n";
+/*
+ o << "{\n";
+ inc();
+ dumpCppuGetType(o, m_typeName, sal_True);
+ dec();
+ o << "}\n\n";
+*/
+ }
+
+ dumpNameSpace(o, sal_False);
+
+ o << endl;
+ dumpGetCppuType(o);
+
+ o << "\n#endif // "<< headerDefine << endl;
+ return sal_True;
+}
+
+sal_Bool ExceptionType::dumpSuperMember(FileStream& o, const OString& superType, sal_Bool bWithType)
+{
+ sal_Bool hasMember = sal_False;
+
+ if (superType.getLength() > 0)
+ {
+ TypeReader aSuperReader(m_typeMgr.getTypeReader(superType));
+
+ if (aSuperReader.isValid())
+ {
+ hasMember = dumpSuperMember(o, aSuperReader.getSuperTypeName(), bWithType);
+
+ sal_uInt32 fieldCount = aSuperReader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = aSuperReader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = aSuperReader.getFieldName(i);
+ fieldType = aSuperReader.getFieldType(i);
+
+ if (hasMember)
+ {
+ o << ", ";
+ } else
+ {
+ hasMember = (fieldCount > 0);
+ }
+
+ if (bWithType)
+ {
+ dumpType(o, fieldType, sal_True, sal_True);
+ o << " ";
+ }
+ o << "__" << fieldName;
+ }
+ }
+/*
+ RegistryKey superKey = m_typeMgr.getTypeKey(superType);
+ RegValueType valueType;
+ sal_uInt32 valueSize;
+
+ if (!superKey.getValueInfo(OUString(), &valueType, &valueSize))
+ {
+ sal_uInt8* pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize);
+ RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader();
+
+ if (!superKey.getValue(OUString(), pBuffer) )
+ {
+ TypeReader aSuperReader(rReaderLoader, pBuffer, valueSize, sal_True);
+
+ hasMember = dumpSuperMember(o, aSuperReader.getSuperTypeName(), bWithType);
+
+ sal_uInt32 fieldCount = aSuperReader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = aSuperReader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = aSuperReader.getFieldName(i);
+ fieldType = aSuperReader.getFieldType(i);
+
+ if (hasMember)
+ {
+ o << ", ";
+ } else
+ {
+ hasMember = (fieldCount > 0);
+ }
+
+ if (bWithType)
+ {
+ dumpType(o, fieldType, sal_True, sal_True);
+ o << " ";
+ }
+ o << "__" << fieldName;
+ }
+ }
+
+ rtl_freeMemory(pBuffer);
+ }
+*/
+ }
+
+ return hasMember;
+}
+
+//*************************************************************************
+// EnumType
+//*************************************************************************
+EnumType::EnumType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : CppuType(typeReader, typeName, typeMgr, typeDependencies)
+{
+}
+
+EnumType::~EnumType()
+{
+
+}
+
+sal_Bool EnumType::dumpHFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ OString headerDefine(dumpHeaderDefine(o, "HDL"));
+ o << endl;
+
+ dumpDefaultHIncludes(o);
+ o << endl;
+
+ dumpNameSpace(o);
+
+ o << "\nenum " << m_name << "\n{\n";
+ inc();
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ RTConstValue constValue;
+ OString fieldName;
+ sal_uInt32 value=0;
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access != RT_ACCESS_CONST)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ constValue = m_reader.getFieldConstValue(i);
+
+ if (constValue.m_type == RT_TYPE_INT32)
+ value = constValue.m_value.aLong;
+ else
+ value++;
+
+ o << indent() << m_name << "_" << fieldName << " = "
+ << value << ",\n";
+ }
+
+ o << indent() << m_name << "_MAKE_FIXED_SIZE = SAL_MAX_ENUM\n";
+
+ dec();
+ o << "};\n\n";
+
+ dumpNameSpace(o, sal_False);
+
+ o << "\nnamespace com { namespace sun { namespace star { namespace uno {\n"
+ << "class Type;\n} } } }\n\n";
+
+ if (m_cppuTypeStatic)
+ o << "static";
+ else
+ o << "inline";
+ o << " const ::com::sun::star::uno::Type& SAL_CALL getCppuType( ";
+ dumpType(o, m_typeName, sal_True, sal_False);
+ o << "* );\n\n";
+
+ o << "#endif // "<< headerDefine << endl;
+
+ return sal_True;
+}
+
+sal_Bool EnumType::dumpHxxFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ OString headerDefine(dumpHeaderDefine(o, "HPP"));
+ o << endl;
+
+ dumpInclude(o, m_typeName, "hdl");
+ o << endl;
+
+ dumpDefaultHxxIncludes(o);
+ o << endl;
+
+ dumpGetCppuType(o);
+
+ o << "\n#endif // "<< headerDefine << endl;
+ return sal_True;
+}
+
+void EnumType::dumpGetCppuType(FileStream& o)
+{
+ OString typeName(m_typeName.replace('/', '_'));
+
+ if ( m_cppuTypeLeak )
+ {
+ dumpLGetCppuType(o);
+ return;
+ }
+ if ( !m_cppuTypeDynamic )
+ {
+ dumpCGetCppuType(o);
+ return;
+ }
+
+ o << "#if ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n"
+ << "#endif\n\n";
+
+ o << "inline const ::com::sun::star::uno::Type& SAL_CALL getCppuType( ";
+ dumpType(o, m_typeName, sal_True, sal_False);
+ o << "* )\n{\n";
+ inc();
+
+ o << indent() << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << indent() << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n"
+ << indent() << "#endif\n\n";
+
+ o << indent() << "if ( !s_pType_" << typeName << " )\n" << indent() << "{\n";
+ inc();
+
+ o << indent() << "typelib_static_enum_type_init( &s_pType_" << typeName << ",\n";
+ inc(31);
+ o << indent() << "\"" << m_typeName.replace('/', '.') << "\",\n"
+ << indent() << scopedName(OString(), m_typeName) << "_" << m_reader.getFieldName(0) << " );\n";
+ dec(31);
+ dec();
+ o << indent() << "}\n";
+ o << indent() << "return * reinterpret_cast< ::com::sun::star::uno::Type * >( &s_pType_"
+ << typeName <<" );\n";
+ dec();
+ o << indent() << "}\n";
+
+ return;
+}
+
+void EnumType::dumpCGetCppuType(FileStream& o)
+{
+ OString typeName(m_typeName.replace('/', '_'));
+
+ o << "#if ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << "static ::com::sun::star::uno::Type * pType_" << typeName << " = 0;\n"
+ << "#endif\n\n";
+
+ if (m_cppuTypeStatic)
+ o << "static";
+ else
+ o << "inline";
+ o << " const ::com::sun::star::uno::Type& SAL_CALL getCppuType( ";
+ dumpType(o, m_typeName, sal_True, sal_False);
+ o << "* )\n{\n";
+ inc();
+
+ o << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << indent() << "static ::com::sun::star::uno::Type * pType_" << typeName << " = 0;\n"
+ << "#endif\n\n";
+
+ o << indent() << "if ( !pType_" << typeName << " )\n" << indent() << "{\n";
+ inc();
+ o << indent() << "::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );\n";
+
+ o << indent() << "if ( !pType_" << typeName << " )\n" << indent() << "{\n";
+ inc();
+ o << indent() << "::rtl::OUString sTypeName( RTL_CONSTASCII_USTRINGPARAM(\""
+ << m_typeName.replace('/', '.') << "\") );\n\n";
+
+ if ( m_cppuTypeDynamic )
+ {
+ o << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n";
+ o << indent() << "static ::com::sun::star::uno::Type aType_" << typeName << "( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << indent() << "pType_" << typeName << " = &aType_" << typeName << ";\n";
+ o << "#else\n";
+ o << indent() << "pType_" << typeName << " = new ::com::sun::star::uno::Type( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << "#endif\n";
+ } else
+ {
+ o << indent() << "// Start inline typedescription generation\n"
+ << indent() << "typelib_TypeDescription * pTD = 0;\n\n";
+
+ sal_uInt32 count = m_reader.getFieldCount();
+ o << indent() << "rtl_uString* enumValueNames[" << count << "];\n";
+ sal_uInt32 i;
+ for (i = 0; i < count; i++)
+ {
+ o << indent() << "::rtl::OUString sEnumValue" << i << "( RTL_CONSTASCII_USTRINGPARAM(\""
+ << m_reader.getFieldName(i) << "\") );\n";
+ o << indent() << "enumValueNames[" << i << "] = sEnumValue" << i << ".pData;\n";
+ }
+
+ o << "\n" << indent() << "sal_Int32 enumValues[" << count << "];\n";
+ RTConstValue constValue;
+ sal_Int32 value=0;
+ for (i = 0; i < count; i++)
+ {
+ o << indent() << "enumValues[" << i << "] = ";
+ constValue = m_reader.getFieldConstValue(i);
+ if (constValue.m_type == RT_TYPE_INT32)
+ value = constValue.m_value.aLong;
+ else
+ value++;
+ o << value << ";\n";
+ }
+
+ o << "\n" << indent() << "typelib_typedescription_newEnum( &pTD,\n";
+ inc();
+ o << indent() << "sTypeName.pData,\n"
+ << indent() << "(sal_Int32)" << scopedName("", m_typeName, sal_False)
+ << "_" << m_reader.getFieldName(0) << ",\n"
+ << indent() << count << ", enumValueNames, enumValues );\n\n";
+ dec();
+
+ o << indent() << "typelib_typedescription_register( (typelib_TypeDescription**)&pTD );\n";
+ o << indent() << "typelib_typedescription_release( pTD );\n"
+ << indent() << "// End inline typedescription generation\n\n";
+
+ o << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n";
+ o << indent() << "static ::com::sun::star::uno::Type aType_" << typeName << "( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << indent() << "pType_" << typeName << " = &aType_" << typeName << ";\n";
+ o << "#else\n";
+ o << indent() << "pType_" << typeName << " = new ::com::sun::star::uno::Type( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << "#endif\n";
+ }
+
+ dec();
+ o << indent() << "}\n";
+ dec();
+ o << indent() << "}\n\n"
+ << indent() << "return *pType_" << typeName << ";\n";
+
+ dec();
+ o << "}\n";
+}
+
+//*************************************************************************
+// TypeDefType
+//*************************************************************************
+TypeDefType::TypeDefType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : CppuType(typeReader, typeName, typeMgr, typeDependencies)
+{
+}
+
+TypeDefType::~TypeDefType()
+{
+
+}
+
+sal_Bool TypeDefType::dumpHFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ OString headerDefine(dumpHeaderDefine(o, "HDL"));
+ o << endl;
+
+ dumpDefaultHIncludes(o);
+ o << endl;
+ dumpDepIncludes(o, m_typeName, "hdl");
+ o << endl;
+
+ dumpNameSpace(o);
+
+ o << "\ntypedef ";
+ dumpType(o, m_reader.getSuperTypeName());
+ o << " " << m_name << ";\n\n";
+
+ dumpNameSpace(o, sal_False);
+
+// o << "\nnamespace com { namespace sun { namespace star { namespace uno {\n"
+// << "class Type;\n} } } }\n\n";
+// o << "inline const ::com::sun::star::uno::Type& SAL_CALL get_" << m_typeName.replace('/', '_')
+// << "_Type( );\n\n";
+
+ o << "#endif // "<< headerDefine << endl;
+
+ return sal_True;
+}
+
+sal_Bool TypeDefType::dumpHxxFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ OString headerDefine(dumpHeaderDefine(o, "HPP"));
+ o << endl;
+
+ dumpInclude(o, m_typeName, "hdl");
+ o << endl;
+ dumpDefaultHxxIncludes(o);
+ o << endl;
+ dumpDepIncludes(o, m_typeName, "hpp");
+ o << endl;
+
+ dumpGetCppuType(o);
+
+ o << "\n#endif // "<< headerDefine << endl;
+ return sal_True;
+}
+
+void TypeDefType::dumpGetCppuType(FileStream& o)
+{
+ if ( m_cppuTypeLeak )
+ {
+ dumpLGetCppuType(o);
+ return;
+ }
+ if ( !m_cppuTypeDynamic )
+ {
+ dumpCGetCppuType(o);
+ return;
+ }
+}
+
+void TypeDefType::dumpCGetCppuType(FileStream& o)
+{
+/*
+ OString typeName(m_typeName.replace('/', '_'));
+
+ if (m_cppuTypeLeak)
+ {
+ dumpLGetCppuType(o);
+ return;
+ }
+
+ o << "#if ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << "static ::com::sun::star::uno::Type * pType_" << typeName << " = 0;\n"
+ << "#endif\n\n";
+
+ o << "inline const ::com::sun::star::uno::Type& SAL_CALL get_" << typeName << "_Type( )\n" << "{\n";
+ inc();
+
+ o << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << indent() << "static ::com::sun::star::uno::Type * pType_" << typeName << " = 0;\n"
+ << "#endif\n\n";
+
+ o << indent() << "if ( !pType_" << typeName << " )\n" << indent() << "{\n";
+ inc();
+ o << indent() << "::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );\n";
+
+ o << indent() << "if ( !pType_" << typeName << " )\n" << indent() << "{\n";
+ inc();
+ o << indent() << "::rtl::OUString sTypeName( RTL_CONSTASCII_USTRINGPARAM(\""
+ << m_typeName.replace('/', '.') << "\") );\n\n";
+
+ if ( m_cppuTypeDynamic )
+ {
+ o << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n";
+ o << indent() << "static ::com::sun::star::uno::Type aType_" << typeName << "( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << indent() << "pType_" << typeName << " = &aType_" << typeName << ";\n";
+ o << "#else\n";
+ o << indent() << "pType_" << typeName << " = new ::com::sun::star::uno::Type( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << "#endif\n";
+ } else
+ {
+ o << indent() << "// Start inline typedescription generation\n"
+ << indent() << "typelib_TypeDescription * pTD = 0;\n";
+
+ OString superType(m_reader.getSuperTypeName());
+ o << indent() << "typelib_TypeDescription * pITD = 0;\n";
+
+ o << indent() << "getCppuType( ( ";
+ dumpType(o, superType, sal_True, sal_False);
+ o << " *)0 ).getDescription( &pITD );\n\n";
+
+ o << indent() << "typelib_typedescription_new(\n";
+ inc();
+ o << indent() << "&pTD,\n"
+ << indent() << "(typelib_TypeClass)::com::sun::star::uno::TypeClass_TYPEDEF, "
+ << "sTypeName.pData,\n";
+
+ o << indent() << "pITD,\n" << indent() << "0, 0 );\n\n";
+ dec();
+ o << indent() << "typelib_typedescription_register( (typelib_TypeDescription**)&pTD );\n";
+ o << indent() << "typelib_typedescription_release( pITD );\n"
+ << indent() << "typelib_typedescription_release( pTD );\n"
+ << indent() << "// End inline typedescription generation\n\n";
+
+ o << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n";
+ o << indent() << "static ::com::sun::star::uno::Type aType_" << typeName << "( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << indent() << "pType_" << typeName << " = &aType_" << typeName << ";\n";
+ o << "#else\n";
+ o << indent() << "pType_" << typeName << " = new ::com::sun::star::uno::Type( "
+ << getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << "#endif\n";
+ }
+
+ dec();
+ o << indent() << "}\n";
+ dec();
+ o << indent() << "}\n\n"
+ << indent() << "return *pType_" << typeName << ";\n";
+ dec();
+ o << "}\n";
+*/
+}
+
+void TypeDefType::dumpLGetCppuType(FileStream& o)
+{
+/*
+ OString typeName(m_typeName.replace('/', '_'));
+
+ o << "#if ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n"
+ << "#endif\n\n";
+
+ o << "inline const ::com::sun::star::uno::Type& SAL_CALL get_" << typeName << "_Type( )\n{\n";
+ inc();
+
+ o << indent() << "#if ! ((defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)))\n"
+ << indent() << "static typelib_TypeDescriptionReference * s_pType_" << typeName << " = 0;\n"
+ << indent() << "#endif\n\n";
+
+ o << indent() << "if ( !s_pType_" << typeName << " )\n" << indent() << "{\n";
+ inc();
+ o << indent() << "const ::com::sun::star::uno::Type& rType = getCppuType( ( ";
+ dumpType(o, m_reader.getSuperTypeName(), sal_True, sal_False);
+ o << " *)0 );\n\n";
+
+ o << indent() << "::typelib_static_typedef_type_init( &s_pType_" << typeName
+ << ", \"" << m_typeName.replace('/', '.') << "\", rType.getTypeLibType() );\n";
+ dec();
+ o << indent() << "}\n";
+ o << indent() << "return * reinterpret_cast< ::com::sun::star::uno::Type * >( &s_pType_"
+ << typeName <<" );\n";
+ dec();
+ o << indent() << "}\n";
+*/
+}
+
+//*************************************************************************
+// produceType
+//*************************************************************************
+sal_Bool produceType(const OString& typeName,
+ TypeManager& typeMgr,
+ TypeDependency& typeDependencies,
+ CppuOptions* pOptions)
+ throw( CannotDumpException )
+{
+ if (typeDependencies.isGenerated(typeName))
+ return sal_True;
+
+ TypeReader reader(typeMgr.getTypeReader(typeName));
+
+ if (!reader.isValid())
+ {
+ if (typeName.equals("/"))
+ return sal_True;
+ else
+ return sal_False;
+ }
+
+/* RegistryKey typeKey = typeMgr.getTypeKey(typeName);
+
+ if (!typeKey.isValid())
+ return sal_False;
+*/
+ if( !checkTypeDependencies(typeMgr, typeDependencies, typeName))
+ return sal_False;
+/*
+ RegValueType valueType;
+ sal_uInt32 valueSize;
+
+ if (typeKey.getValueInfo(OUString(), &valueType, &valueSize))
+ {
+ if (typeName.equals("/"))
+ return sal_True;
+ else
+ return sal_False;
+ }
+ sal_uInt8* pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize);
+
+ if (typeKey.getValue(OUString(), pBuffer))
+ {
+ rtl_freeMemory(pBuffer);
+ return sal_False;
+ }
+
+ RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader();
+
+ TypeReader reader(rReaderLoader, pBuffer, valueSize, sal_True);
+
+ rtl_freeMemory(pBuffer);
+*/
+ RTTypeClass typeClass = reader.getTypeClass();
+ sal_Bool ret = sal_False;
+ switch (typeClass)
+ {
+ case RT_TYPE_INTERFACE:
+ {
+ InterfaceType iType(reader, typeName, typeMgr, typeDependencies);
+ ret = iType.dump(pOptions);
+ if (ret) typeDependencies.setGenerated(typeName);
+ ret = iType.dumpDependedTypes(pOptions);
+ }
+ break;
+ case RT_TYPE_MODULE:
+ {
+ ModuleType mType(reader, typeName, typeMgr, typeDependencies);
+ if (mType.hasConstants())
+ {
+ ret = mType.dump(pOptions);
+ if (ret) typeDependencies.setGenerated(typeName);
+// ret = mType.dumpDependedTypes(pOptions);
+ } else
+ {
+ typeDependencies.setGenerated(typeName);
+ ret = sal_True;
+ }
+ }
+ break;
+ case RT_TYPE_STRUCT:
+ {
+ StructureType sType(reader, typeName, typeMgr, typeDependencies);
+ ret = sType.dump(pOptions);
+ if (ret) typeDependencies.setGenerated(typeName);
+ ret = sType.dumpDependedTypes(pOptions);
+ }
+ break;
+ case RT_TYPE_ENUM:
+ {
+ EnumType enType(reader, typeName, typeMgr, typeDependencies);
+ ret = enType.dump(pOptions);
+ if (ret) typeDependencies.setGenerated(typeName);
+ ret = enType.dumpDependedTypes(pOptions);
+ }
+ break;
+ case RT_TYPE_EXCEPTION:
+ {
+ ExceptionType eType(reader, typeName, typeMgr, typeDependencies);
+ ret = eType.dump(pOptions);
+ if (ret) typeDependencies.setGenerated(typeName);
+ ret = eType.dumpDependedTypes(pOptions);
+ }
+ break;
+ case RT_TYPE_TYPEDEF:
+ {
+ TypeDefType tdType(reader, typeName, typeMgr, typeDependencies);
+ ret = tdType.dump(pOptions);
+ if (ret) typeDependencies.setGenerated(typeName);
+ ret = tdType.dumpDependedTypes(pOptions);
+ }
+ break;
+ case RT_TYPE_CONSTANTS:
+ {
+ ConstantsType cType(reader, typeName, typeMgr, typeDependencies);
+ if (cType.hasConstants())
+ {
+ ret = cType.dump(pOptions);
+ if (ret) typeDependencies.setGenerated(typeName);
+// ret = cType.dumpDependedTypes(pOptions);
+ } else
+ {
+ typeDependencies.setGenerated(typeName);
+ ret = sal_True;
+ }
+ }
+ break;
+ case RT_TYPE_SERVICE:
+ case RT_TYPE_OBJECT:
+ ret = sal_True;
+ break;
+ }
+
+ return ret;
+}
+
+//*************************************************************************
+// scopedName
+//*************************************************************************
+OString scopedName(const OString& scope, const OString& type,
+ sal_Bool bNoNameSpace)
+{
+ sal_uInt32 count = type.getTokenCount('/');
+ sal_uInt32 offset = 0;
+/*
+ if (count > 1)
+ offset = count - 1;
+ else
+ return type;
+*/
+ if (count == 1)
+ return type;
+
+ if (bNoNameSpace)
+ return type.getToken(count - 1, '/');
+
+ // scoped name only if the namespace is not equal
+/*
+ if (scope.lastIndexOf('/') > 0)
+ {
+ OString tmpScp(scope.copy(0, scope.lastIndexOf('/')));
+ OString tmpScp2(type.copy(0, type.lastIndexOf('/')));
+
+ if (tmpScp == tmpScp2)
+ return type.getToken(count - 1, '/');
+ }
+*/
+
+// OStringBuffer tmpBuf(type.getLength() + offset);
+// tmpBuf.append(type.getToken(0, '/'));
+// for (int i=1; i < count; i++)
+ OStringBuffer tmpBuf(type.getLength() + count);
+ for (int i=0; i < count; i++)
+ {
+ tmpBuf.append("::");
+ tmpBuf.append(type.getToken(i, '/'));
+ }
+
+ return tmpBuf.makeStringAndClear();
+}
+
+//*************************************************************************
+// shortScopedName
+//*************************************************************************
+OString shortScopedName(const OString& scope, const OString& type,
+ sal_Bool bNoNameSpace)
+{
+ sal_uInt32 count = type.getTokenCount('/');
+ sal_uInt32 offset = 0;
+
+ if (count > 1)
+// offset = count - 2;
+ offset = count - 1;
+ else
+ return OString();
+
+ if (bNoNameSpace)
+ return OString();
+
+ // scoped name only if the namespace is not equal
+ if (scope.lastIndexOf('/') > 0)
+ {
+ OString tmpScp(scope.copy(0, scope.lastIndexOf('/')));
+ OString tmpScp2(type.copy(0, type.lastIndexOf('/')));
+
+ if (tmpScp == tmpScp2)
+ return OString();
+ }
+
+ OStringBuffer tmpBuf(type.lastIndexOf('/') + offset);
+
+ for (int i=0; i < count - 1; i++)
+ {
+ tmpBuf.append("::");
+ tmpBuf.append(type.getToken(i, '/'));
+ }
+
+ return tmpBuf.makeStringAndClear();
+}
+
+
diff --git a/codemaker/source/cppumaker/cpputype.hxx b/codemaker/source/cppumaker/cpputype.hxx
new file mode 100644
index 000000000000..7002fd12d181
--- /dev/null
+++ b/codemaker/source/cppumaker/cpputype.hxx
@@ -0,0 +1,325 @@
+/*************************************************************************
+ *
+ * $RCSfile: cpputype.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CPPUMAKER_CPPUTYPE_HXX_
+#define _CPPUMAKER_CPPUTYPE_HXX_
+
+#ifndef _CODEMAKER_TYPEMANAGER_HXX_
+#include <codemaker/typemanager.hxx>
+#endif
+
+#ifndef _CODEMAKER_DEPENDENCY_HXX_
+#include <codemaker/dependency.hxx>
+#endif
+
+enum BASETYPE
+{
+ BT_INVALID,
+ BT_VOID,
+ BT_ANY,
+ BT_TYPE,
+ BT_BOOLEAN,
+ BT_CHAR,
+ BT_STRING,
+ BT_FLOAT,
+ BT_DOUBLE,
+ BT_OCTET,
+ BT_BYTE,
+ BT_SHORT,
+ BT_LONG,
+ BT_HYPER,
+ BT_UNSIGNED_SHORT,
+ BT_UNSIGNED_LONG,
+ BT_UNSIGNED_HYPER
+};
+
+
+enum CppuTypeDecl
+{
+ CPPUTYPEDECL_ALLTYPES,
+ CPPUTYPEDECL_NOINTERFACES,
+ CPPUTYPEDECL_ONLYINTERFACES
+};
+
+class CppuOptions;
+class FileStream;
+
+class CppuType
+{
+public:
+ CppuType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~CppuType();
+
+ virtual sal_Bool dump(CppuOptions* pOptions) throw( CannotDumpException );
+ virtual sal_Bool dumpDependedTypes(CppuOptions* pOptions) throw( CannotDumpException );
+ virtual sal_Bool dumpHFile(FileStream& o) throw( CannotDumpException ) = 0;
+ virtual sal_Bool dumpHxxFile(FileStream& o) throw( CannotDumpException ) = 0;
+
+ virtual ::rtl::OString dumpHeaderDefine(FileStream& o, sal_Char* prefix, sal_Bool bExtended=sal_False);
+ virtual void dumpDefaultHIncludes(FileStream& o);
+ virtual void dumpDefaultHxxIncludes(FileStream& o);
+ virtual void dumpInclude(FileStream& o, const ::rtl::OString& typeName, sal_Char* prefix, sal_Bool bExtended=sal_False, sal_Bool bCaseSensitive=sal_False);
+
+ virtual void dumpDepIncludes(FileStream& o, const ::rtl::OString& typeName, sal_Char* prefix);
+
+ virtual void dumpNameSpace(FileStream& o, sal_Bool bOpen = sal_True, sal_Bool bFull = sal_False, const ::rtl::OString& type="");
+ virtual void dumpGetCppuType(FileStream& o);
+ virtual void dumpCGetCppuType(FileStream& o);
+ virtual void dumpLGetCppuType(FileStream& o);
+
+ virtual void dumpType(FileStream& o, const ::rtl::OString& type, sal_Bool bConst=sal_False,
+ sal_Bool bRef=sal_False, sal_Bool bNative=sal_False)
+ throw( CannotDumpException );
+ ::rtl::OString getTypeClass(const ::rtl::OString& type="", sal_Bool bCStyle=sal_False);
+ ::rtl::OString getBaseType(const ::rtl::OString& type);
+ void dumpCppuGetType(FileStream& o, const ::rtl::OString& type, sal_Bool bDecl=sal_False, CppuTypeDecl eDeclFlag=CPPUTYPEDECL_ALLTYPES);
+ void dumpTypeInit(FileStream& o, const ::rtl::OString& type);
+ BASETYPE isBaseType(const ::rtl::OString& type);
+
+ ::rtl::OString typeToIdentifier(const ::rtl::OString& type);
+
+ void dumpConstantValue(FileStream& o, sal_uInt16 index);
+
+ virtual sal_uInt32 getMemberCount();
+ virtual sal_uInt32 getInheritedMemberCount();
+
+ void inc(sal_uInt32 num=4);
+ void dec(sal_uInt32 num=4);
+ ::rtl::OString indent();
+ ::rtl::OString indent(sal_uInt32 num);
+protected:
+ virtual sal_uInt32 checkInheritedMemberCount(const TypeReader* pReader);
+
+ ::rtl::OString checkSpecialCppuType(const ::rtl::OString& type);
+ ::rtl::OString checkRealBaseType(const ::rtl::OString& type, sal_Bool bResolveTypeOnly = sal_False);
+ void dumpCppuGetTypeMemberDecl(FileStream& o, CppuTypeDecl eDeclFlag);
+
+protected:
+ sal_uInt32 m_inheritedMemberCount;
+
+ sal_Bool m_cppuTypeLeak;
+ sal_Bool m_cppuTypeDynamic;
+ sal_Bool m_cppuTypeStatic;
+ sal_uInt32 m_indentLength;
+ ::rtl::OString m_typeName;
+ ::rtl::OString m_name;
+ TypeReader m_reader;
+ TypeManager& m_typeMgr;
+ TypeDependency m_dependencies;
+};
+
+class InterfaceType : public CppuType
+{
+public:
+ InterfaceType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~InterfaceType();
+
+ sal_Bool dumpHFile(FileStream& o) throw( CannotDumpException );
+ sal_Bool dumpHxxFile(FileStream& o) throw( CannotDumpException );
+
+ void dumpAttributes(FileStream& o);
+ void dumpMethods(FileStream& o);
+ void dumpGetCppuType(FileStream& o);
+ void dumpCGetCppuType(FileStream& o);
+ void dumpCppuAttributeRefs(FileStream& o, sal_uInt32& index);
+ void dumpCppuMethodRefs(FileStream& o, sal_uInt32& index);
+ void dumpCppuAttributes(FileStream& o, sal_uInt32& index);
+ void dumpCppuMethods(FileStream& o, sal_uInt32& index);
+ void dumpAttributesCppuDecl(FileStream& o, StringSet* pFinishedTypes, CppuTypeDecl eDeclFlag);
+ void dumpMethodsCppuDecl(FileStream& o, StringSet* pFinishedTypes, CppuTypeDecl eDeclFlag );
+
+ sal_uInt32 getMemberCount();
+ sal_uInt32 getInheritedMemberCount();
+
+protected:
+ sal_uInt32 checkInheritedMemberCount(const TypeReader* pReader);
+
+protected:
+ sal_uInt32 m_inheritedMemberCount;
+ sal_Bool m_hasAttributes;
+ sal_Bool m_hasMethods;
+};
+
+class ModuleType : public CppuType
+{
+public:
+ ModuleType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~ModuleType();
+
+ virtual sal_Bool dump(CppuOptions* pOptions) throw( CannotDumpException );
+ sal_Bool dumpHFile(FileStream& o) throw( CannotDumpException );
+ sal_Bool dumpHxxFile(FileStream& o) throw( CannotDumpException );
+ sal_Bool hasConstants();
+};
+
+class ConstantsType : public ModuleType
+{
+public:
+ ConstantsType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~ConstantsType();
+
+ virtual sal_Bool dump(CppuOptions* pOptions) throw( CannotDumpException );
+};
+
+class StructureType : public CppuType
+{
+public:
+ StructureType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~StructureType();
+
+ sal_Bool dumpHFile(FileStream& o) throw( CannotDumpException );
+ sal_Bool dumpHxxFile(FileStream& o) throw( CannotDumpException );
+
+ sal_Bool dumpSuperMember(FileStream& o, const ::rtl::OString& super, sal_Bool bWithType);
+};
+
+class ExceptionType : public CppuType
+{
+public:
+ ExceptionType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~ExceptionType();
+
+ sal_Bool dumpHFile(FileStream& o) throw( CannotDumpException );
+ sal_Bool dumpHxxFile(FileStream& o) throw( CannotDumpException );
+
+ sal_Bool dumpSuperMember(FileStream& o, const ::rtl::OString& super, sal_Bool bWithType);
+};
+
+class EnumType : public CppuType
+{
+public:
+ EnumType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~EnumType();
+
+ sal_Bool dumpHFile(FileStream& o) throw( CannotDumpException );
+ sal_Bool dumpHxxFile(FileStream& o) throw( CannotDumpException );
+
+ void dumpGetCppuType(FileStream& o);
+ void dumpCGetCppuType(FileStream& o);
+};
+
+class TypeDefType : public CppuType
+{
+public:
+ TypeDefType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~TypeDefType();
+
+ sal_Bool dumpHFile(FileStream& o) throw( CannotDumpException );
+ sal_Bool dumpHxxFile(FileStream& o) throw( CannotDumpException );
+
+ void dumpGetCppuType(FileStream& o);
+ void dumpLGetCppuType(FileStream& o);
+ void dumpCGetCppuType(FileStream& o);
+};
+
+
+sal_Bool produceType(const ::rtl::OString& typeName,
+ TypeManager& typeMgr,
+ TypeDependency& typeDependencies,
+ CppuOptions* pOptions)
+ throw( CannotDumpException );
+
+/**
+ * This function returns a C++ scoped name, represents the namespace
+ * scoping of this type, e.g. com:.sun::star::uno::XInterface. If the scope of
+ * the type is equal scope, the relativ name will be used.
+ */
+::rtl::OString scopedName(const ::rtl::OString& scope, const ::rtl::OString& type,
+ sal_Bool bNoNameSpace=sal_False);
+
+::rtl::OString shortScopedName(const ::rtl::OString& scope, const ::rtl::OString& type,
+ sal_Bool bNoNameSpace=sal_False);
+
+
+#endif // _CPPUMAKER_CPPUTYPE_HXX_
+
diff --git a/codemaker/source/cppumaker/makefile.mk b/codemaker/source/cppumaker/makefile.mk
new file mode 100644
index 000000000000..fe915e3cb1d7
--- /dev/null
+++ b/codemaker/source/cppumaker/makefile.mk
@@ -0,0 +1,104 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $
+#
+# 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=codemaker
+TARGET=cppumaker
+TARGETTYPE=CUI
+LIBTARGET=NO
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Files --------------------------------------------------------
+
+CXXFILES= cppumaker.cxx \
+ cppuoptions.cxx \
+ cpputype.cxx
+
+
+APP1TARGET= $(TARGET)
+
+APP1OBJS= $(OBJ)$/cppumaker.obj \
+ $(OBJ)$/cppuoptions.obj \
+ $(OBJ)$/cpputype.obj
+
+APP1STDLIBS=\
+ $(SALLIB) \
+ $(VOSLIB) \
+ $(REGLIB) \
+ $(STDLIBCPP)
+
+.IF "$(GUI)"=="WNT"
+APP1STDLIBS+= \
+ $(LIBCIMT) $(LIBCMT)
+.ENDIF
+
+APP1LIBS= \
+ $(LB)$/codemaker.lib
+
+.INCLUDE : target.mk
diff --git a/codemaker/source/javamaker/javamaker.cxx b/codemaker/source/javamaker/javamaker.cxx
new file mode 100644
index 000000000000..3e1714748f1f
--- /dev/null
+++ b/codemaker/source/javamaker/javamaker.cxx
@@ -0,0 +1,222 @@
+/*************************************************************************
+ *
+ * $RCSfile: javamaker.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $
+ *
+ * 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>
+
+#ifndef _CODEMAKER_TYPEMANAGER_HXX_
+#include <codemaker/typemanager.hxx>
+#endif
+#ifndef _CODEMAKER_DEPENDENCY_HXX_
+#include <codemaker/dependency.hxx>
+#endif
+
+#include "javaoptions.hxx"
+#include "javatype.hxx"
+
+using namespace rtl;
+
+sal_Bool produceAllTypes(const OString& typeName,
+ TypeManager& typeMgr,
+ TypeDependency& typeDependencies,
+ JavaOptions* pOptions,
+ sal_Bool bFullScope)
+ throw( CannotDumpException )
+{
+ if (!produceType(typeName, typeMgr, typeDependencies, pOptions))
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ pOptions->getProgramName().getStr(),
+ OString("cannot dump Type '" + typeName + "'").getStr());
+ exit(99);
+ }
+
+ RegistryKey typeKey = typeMgr.getTypeKey(typeName);
+ RegistryKeyNames subKeys;
+
+ if (typeKey.getKeyNames(OUString(), subKeys))
+ return sal_False;
+
+ OString tmpName;
+ for (sal_uInt32 i=0; i < subKeys.getLength(); i++)
+ {
+ tmpName = OUStringToOString(subKeys.getElement(i), RTL_TEXTENCODING_UTF8);
+
+ if (pOptions->isValid("-B"))
+ tmpName = tmpName.copy(tmpName.indexOf('/', 1) + 1);
+ else
+ tmpName = tmpName.copy(1);
+
+ if (bFullScope)
+ {
+ if (!produceAllTypes(tmpName, typeMgr, typeDependencies, pOptions, sal_True))
+ return sal_False;
+ } else
+ {
+ if (!produceType(tmpName, typeMgr, typeDependencies, pOptions))
+ return sal_False;
+ }
+ }
+
+ return sal_True;
+}
+
+#if (defined UNX) || (defined OS2)
+int main( int argc, char * argv[] )
+#else
+int _cdecl main( int argc, char * argv[] )
+#endif
+{
+ JavaOptions options;
+
+ try
+ {
+ if (!options.initOptions(argc, argv))
+ {
+ exit(1);
+ }
+ }
+ catch( IllegalArgument& e)
+ {
+ fprintf(stderr, "Illegal option: %s\n", e.m_message.getStr());
+ exit(99);
+ }
+
+ RegistryTypeManager typeMgr;
+ TypeDependency typeDependencies;
+
+ if (!typeMgr.init(!options.isValid("-T"), options.getInputFiles()))
+ {
+ fprintf(stderr, "%s : init registries failed, check your registry files.\n", options.getProgramName().getStr());
+ exit(99);
+ }
+
+ if (options.isValid("-B"))
+ {
+ typeMgr.setBase(options.getOption("-B"));
+ }
+
+ try
+ {
+ if (options.isValid("-T"))
+ {
+ OString tOption(options.getOption("-T"));
+ sal_uInt32 count = tOption.getTokenCount(';');
+
+ OString typeName, tmpName;
+ sal_Bool ret = sal_False;
+ for (sal_uInt32 i = 0; i < count; i++)
+ {
+ typeName = tOption.getToken(i, ';');
+
+ tmpName = typeName.getToken(typeName.getTokenCount('.') - 1, '.');
+ if (tmpName == "*")
+ {
+ // produce this type and his scope, but the scope is not recursively generated.
+ if (typeName.equals("*"))
+ {
+ tmpName = "/";
+ } else
+ {
+ tmpName = typeName.copy(0, typeName.lastIndexOf('.')).replace('.', '/');
+ if (tmpName.getLength() == 0)
+ tmpName = "/";
+ else
+ tmpName.replace('.', '/');
+ }
+ ret = produceAllTypes(tmpName, typeMgr, typeDependencies, &options, sal_False);
+ } else
+ {
+ // produce only this type
+ ret = produceType(typeName.replace('.', '/'), typeMgr, typeDependencies, &options);
+ }
+
+ if (!ret)
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ options.getProgramName().getStr(),
+ OString("cannot dump Type '" + typeName + "'").getStr());
+ exit(99);
+ }
+ }
+ } else
+ {
+ // produce all types
+ if (!produceAllTypes("/", typeMgr, typeDependencies, &options, sal_True))
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ options.getProgramName().getStr(),
+ "an error occurs while dumping all types.");
+ exit(99);
+ }
+ }
+ }
+ catch( CannotDumpException& e)
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ options.getProgramName().getStr(),
+ e.m_message.getStr());
+ exit(99);
+ }
+
+ return 0;
+}
+
+
diff --git a/codemaker/source/javamaker/javaoptions.cxx b/codemaker/source/javamaker/javaoptions.cxx
new file mode 100644
index 000000000000..750fecb46a59
--- /dev/null
+++ b/codemaker/source/javamaker/javaoptions.cxx
@@ -0,0 +1,246 @@
+/*************************************************************************
+ *
+ * $RCSfile: javaoptions.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $
+ *
+ * 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 "javaoptions.hxx"
+
+using namespace rtl;
+
+sal_Bool JavaOptions::initOptions(int ac, char* av[], sal_Bool bCmdFile)
+ throw( IllegalArgument )
+{
+ sal_Bool ret = sal_True;
+ sal_uInt16 i=0;
+
+ if (!bCmdFile)
+ {
+ bCmdFile = sal_True;
+
+ m_program = av[0];
+
+ if (ac < 2)
+ {
+ fprintf(stderr, "%s", prepareHelp().getStr());
+ ret = sal_False;
+ }
+
+ i = 1;
+ } else
+ {
+ i = 0;
+ }
+
+ char *s=NULL;
+ for (i; i < ac; i++)
+ {
+ if (av[i][0] == '-')
+ {
+ switch (av[i][1])
+ {
+ case 'O':
+ if (av[i][2] == '\0')
+ {
+ if (i < ac - 1 && av[i+1][0] != '-')
+ {
+ i++;
+ s = av[i];
+ } else
+ {
+ OString tmp("'-O', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i+1]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+ } else
+ {
+ s = av[i] + 2;
+ }
+
+ m_options["-O"] = OString(s);
+ break;
+ case 'B':
+ if (av[i][2] == '\0')
+ {
+ if (i < ac - 1 && av[i+1][0] != '-')
+ {
+ i++;
+ s = av[i];
+ } else
+ {
+ OString tmp("'-B', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i+1]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+ } else
+ {
+ s = av[i] + 2;
+ }
+
+ m_options["-B"] = OString(s);
+ break;
+ case 'T':
+ if (av[i][2] == '\0')
+ {
+ if (i < ac - 1 && av[i+1][0] != '-')
+ {
+ i++;
+ s = av[i];
+ } else
+ {
+ OString tmp("'-T', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i+1]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+ } else
+ {
+ s = av[i] + 2;
+ }
+
+ if (m_options.count("-T") > 0)
+ {
+ OString tmp(m_options["-T"]);
+ tmp = tmp + ";" + s;
+ m_options["-T"] = tmp;
+ } else
+ {
+ m_options["-T"] = OString(s);
+ }
+ break;
+ default:
+ throw IllegalArgument("the option is unknown" + OString(av[i]));
+ break;
+ }
+ } else
+ {
+ if (av[i][0] == '@')
+ {
+ FILE* cmdFile = fopen(av[i]+1, "r");
+ if( cmdFile == NULL )
+ {
+ fprintf(stderr, "%s", prepareHelp().getStr());
+ ret = sal_False;
+ } else
+ {
+ int rargc=0;
+ char* rargv[512];
+ char buffer[512];
+
+ while ( fscanf(cmdFile, "%s", buffer) != EOF )
+ {
+ rargv[rargc]= strdup(buffer);
+ rargc++;
+ }
+ fclose(cmdFile);
+
+ ret = initOptions(rargc, rargv, bCmdFile);
+
+ for (long i=0; i < rargc; i++)
+ {
+ free(rargv[i]);
+ }
+ }
+ } else
+ {
+ m_inputFiles.push_back(av[i]);
+ }
+ }
+ }
+
+ return ret;
+}
+
+OString JavaOptions::prepareHelp()
+{
+ OString help("\nusing: ");
+ help += m_program + " [-options] file_1 ... file_n\nOptions:\n";
+ help += " -O<path> = path describes the root directory for the generated output.\n";
+ help += " The output directory tree is generated under this directory.\n";
+ help += " -T<name> = name specifies a type or a list of types. The output for this\n";
+ help += " [t1;...] type is generated. If no '-T' option is specified,\n";
+ help += " then output for all types is generated.\n";
+ help += " Example: 'com.sun.star.uno.XInterface' is a valid type.\n";
+ help += " -B<name> = name specifies the base node. All types are searched under this\n";
+ help += " node. Default is the root '/' of the registry files.\n";
+ help += prepareVersion();
+
+ return help;
+}
+
+OString JavaOptions::prepareVersion()
+{
+ OString version("\nSun Microsystems (R) ");
+ version += m_program + " Version 2.0\n\n";
+
+ return version;
+}
+
+
diff --git a/codemaker/source/javamaker/javaoptions.hxx b/codemaker/source/javamaker/javaoptions.hxx
new file mode 100644
index 000000000000..5a6488db7420
--- /dev/null
+++ b/codemaker/source/javamaker/javaoptions.hxx
@@ -0,0 +1,85 @@
+/*************************************************************************
+ *
+ * $RCSfile: javaoptions.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CPPUMAKER_CPPUOPTIONS_HXX_
+#define _CPPUMAKER_CPPUOPTIONS_HXX_
+
+#include <codemaker/options.hxx>
+
+class JavaOptions : public Options
+{
+public:
+ JavaOptions()
+ : Options() {}
+
+ ~JavaOptions() {}
+
+ sal_Bool initOptions(int ac, char* av[], sal_Bool bCmdFile=sal_False)
+ throw( IllegalArgument );
+
+ ::rtl::OString prepareHelp();
+
+ ::rtl::OString prepareVersion();
+
+protected:
+};
+
+#endif // _CPPUMAKER_CPPUOPTIONS_HXX_
diff --git a/codemaker/source/javamaker/javatype.cxx b/codemaker/source/javamaker/javatype.cxx
new file mode 100644
index 000000000000..241a5fb787fe
--- /dev/null
+++ b/codemaker/source/javamaker/javatype.cxx
@@ -0,0 +1,1977 @@
+/*************************************************************************
+ *
+ * $RCSfile: javatype.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:27 $
+ *
+ * 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>
+
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+
+#ifndef _RTL_USTRING_HXX_
+#include <rtl/ustring.hxx>
+#endif
+
+#ifndef _RTL_STRBUF_HXX_
+#include <rtl/strbuf.hxx>
+#endif
+
+#include "javatype.hxx"
+#include "javaoptions.hxx"
+
+using namespace rtl;
+
+//*************************************************************************
+// JavaType
+//*************************************************************************
+JavaType::JavaType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : m_indentLength(0)
+ , m_typeName(typeName)
+ , m_name(typeName.getToken(typeName.getTokenCount('/') - 1, '/'))
+ , m_reader(typeReader)
+ , m_typeMgr((TypeManager&)typeMgr)
+ , m_dependencies(typeDependencies)
+{
+}
+
+JavaType::~JavaType()
+{
+
+}
+
+sal_Bool JavaType::dump(JavaOptions* pOptions)
+ throw( CannotDumpException )
+{
+ sal_Bool ret = sal_False;
+
+ OString outPath;
+ if (pOptions->isValid("-O"))
+ outPath = pOptions->getOption("-O");
+
+ OString fileName = createFileNameFromType(outPath, m_typeName, ".java");
+
+ FileStream javaFile(fileName);
+
+ if(!javaFile.isValid())
+ {
+ OString message("cannot open ");
+ message += fileName + " for writing";
+ throw CannotDumpException(message);
+ }
+
+ return dumpFile(javaFile);
+}
+
+sal_Bool JavaType::dumpDependedTypes(JavaOptions* pOptions)
+ throw( CannotDumpException )
+{
+ sal_Bool ret = sal_True;
+
+ TypeUsingSet usingSet(m_dependencies.getDependencies(m_typeName));
+
+ TypeUsingSet::const_iterator iter = usingSet.begin();
+ OString typeName;
+ sal_Int32 index = 0;
+ while (iter != usingSet.end())
+ {
+ typeName = (*iter).m_type;
+ if ((index = typeName.lastIndexOf(']')) > 0)
+ typeName = typeName.copy(index + 1);
+
+ if (getBaseType(typeName).getLength() == 0)
+ {
+ if (!produceType(typeName,
+ m_typeMgr,
+ m_dependencies,
+ pOptions))
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ pOptions->getProgramName().getStr(),
+ OString("cannot dump Type '" + typeName + "'").getStr());
+ exit(99);
+ }
+ }
+ iter++;
+ }
+
+ return ret;
+}
+
+void JavaType::dumpPackage(FileStream& o, sal_Bool bFullScope)
+{
+ if (m_typeName.equals("/"))
+ return;
+
+ if (bFullScope)
+ {
+ o << "package " << m_typeName.replace('/', '.') << ";\n\n";
+ } else
+ {
+ if (m_typeName.lastIndexOf('/') > 0)
+ o << "package " << m_typeName.copy(0, m_typeName.lastIndexOf('/')).replace('/', '.') << ";\n\n";
+ }
+}
+
+void JavaType::dumpDepImports(FileStream& o, const OString& typeName)
+{
+ TypeUsingSet usingSet(m_dependencies.getDependencies(typeName));
+
+ TypeUsingSet::const_iterator iter = usingSet.begin();
+
+ sal_Int32 index = 0;
+ sal_Int32 seqNum = 0;
+ OString relType;
+ while (iter != usingSet.end())
+ {
+ index = (*iter).m_type.lastIndexOf(']');
+ seqNum = (index > 0 ? ((index+1) / 2) : 0);
+
+ relType = (*iter).m_type;
+ if (index > 0)
+ relType = relType.copy(index+1);
+
+ if (getBaseType(relType).getLength() == 0 &&
+ m_typeName != relType)
+ {
+ /// dump import;
+ }
+
+ iter++;
+ }
+}
+
+sal_uInt32 JavaType::getMemberCount()
+{
+ sal_uInt32 count = m_reader.getMethodCount();
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access != RT_ACCESS_CONST && access != RT_ACCESS_INVALID)
+ count++;
+ }
+ return count;
+}
+
+void JavaType::dumpType(FileStream& o, const OString& type)
+ throw( CannotDumpException )
+{
+ sal_Int32 index = type.lastIndexOf(']');
+ sal_Int32 seqNum = (index > 0 ? ((index+1) / 2) : 0);
+
+ OString relType = (index > 0 ? ((OString)type).copy(index+1) : type);
+
+ RTTypeClass typeClass = m_typeMgr.getTypeClass(relType);
+
+ switch (typeClass)
+ {
+ case RT_TYPE_INVALID:
+ {
+ OString tmp(getBaseType(relType));
+ if (tmp.getLength() > 0)
+ o << getBaseType(relType);
+ else
+ throw CannotDumpException("Unknown type '" + relType + "', incomplete type library.");
+ }
+ break;
+ case RT_TYPE_TYPEDEF:
+ {
+ OString baseType = checkSpecialJavaType(relType);
+ dumpType(o, baseType);
+ }
+ break;
+ case RT_TYPE_INTERFACE:
+ if (relType.equals("com/sun/star/uno/XInterface"))
+ {
+ o << "java.lang.Object";
+ } else
+ {
+ o << scopedName(m_typeName, relType);
+ }
+ break;
+ case RT_TYPE_STRUCT:
+ case RT_TYPE_ENUM:
+ case RT_TYPE_EXCEPTION:
+ o << scopedName(m_typeName, relType);
+ break;
+ }
+
+ for (sal_Int32 i=0; i < seqNum; i++)
+ {
+ o << "[]";
+ }
+}
+
+OString JavaType::getBaseType(const OString& type)
+{
+ if (type.equals("long"))
+ return "int";
+ if (type.equals("short"))
+ return "short";
+ if (type.equals("hyper"))
+ return "long";
+ if (type.equals("string"))
+ return "String";
+ if (type.equals("boolean"))
+ return type;
+ if (type.equals("char"))
+ return type;
+ if (type.equals("byte"))
+ return type;
+ if (type.equals("any"))
+ return "java.lang.Object";
+ if (type.equals("type"))
+ return "com.sun.star.uno.Type";
+ if (type.equals("float"))
+ return type;
+ if (type.equals("double"))
+ return type;
+ if (type.equals("octet"))
+ return "byte";
+ if (type.equals("void"))
+ return type;
+ if (type.equals("unsigned long"))
+ return "int";
+ if (type.equals("unsigned short"))
+ return "short";
+ if (type.equals("unsigned hyper"))
+ return "long";
+
+ return OString();
+}
+
+sal_Bool JavaType::isUnsigned(const OString& typeName)
+{
+ OString type(checkSpecialJavaType(typeName));
+
+ sal_Int32 index = type.lastIndexOf(']');
+
+ OString relType = (index > 0 ? ((OString)type).copy(index+1) : type);
+
+ if ( relType.equals("unsigned long") ||
+ relType.equals("unsigned short") ||
+ relType.equals("unsigned hyper") )
+ return sal_True;
+
+ return sal_False;
+}
+
+sal_Bool JavaType::isAny(const OString& typeName)
+{
+ OString type(checkSpecialJavaType(typeName));
+
+ sal_Int32 index = type.lastIndexOf(']');
+
+ OString relType = (index > 0 ? ((OString)type).copy(index+1) : type);
+
+ if ( relType.equals("any") )
+ return sal_True;
+
+ return sal_False;
+}
+
+sal_Bool JavaType::isInterface(const OString& typeName)
+{
+ OString type(checkSpecialJavaType(typeName));
+
+ sal_Int32 index = type.lastIndexOf(']');
+
+ OString relType = (index > 0 ? ((OString)type).copy(index+1) : type);
+
+ RTTypeClass typeClass = m_typeMgr.getTypeClass(relType);
+
+ if ( typeClass == RT_TYPE_INTERFACE)
+ return sal_True;
+
+ return sal_False;
+}
+
+void JavaType::dumpTypeInit(FileStream& o, const OString& name, const OString& typeName)
+{
+ OString type(checkSpecialJavaType(typeName));
+
+ sal_Int32 index = type.lastIndexOf(']');
+ sal_Int32 seqNum = (index > 0 ? ((index+1) / 2) : 0);
+
+ OString relType = (index > 0 ? ((OString)type).copy(index+1) : type);
+
+ if (seqNum > 0)
+ {
+ o << indent() << name << " = _static_seq_" << name << ";\n";
+ return;
+ }
+
+ BASETYPE baseType = isBaseType(relType);
+
+ switch (baseType)
+ {
+ case BT_STRING:
+// o << "new String()";
+ o << indent() << name << " = \"\";\n";
+ return;
+ case BT_TYPE:
+ o << indent() << name << " = new com.sun.star.uno.Type();\n";
+ return;
+ case BT_ANY:
+// o << "new java.lang.Object()";
+// return;
+ case BT_BOOLEAN:
+ case BT_CHAR:
+ case BT_FLOAT:
+ case BT_DOUBLE:
+ case BT_BYTE:
+ case BT_SHORT:
+ case BT_LONG:
+ case BT_HYPER:
+ case BT_UNSIGNED_SHORT:
+ case BT_UNSIGNED_LONG:
+ case BT_UNSIGNED_HYPER:
+// o << "0";
+ return;
+ }
+
+ RTTypeClass typeClass = m_typeMgr.getTypeClass(type);
+
+ if (typeClass == RT_TYPE_ENUM)
+ {
+ o << indent() << name << " = " << type.replace('/', '.') << ".getDefault();\n";
+ return;
+ }
+
+ if (typeClass == RT_TYPE_INTERFACE)
+ {
+// o << "null";
+ return;
+ }
+
+ o << indent() << name << " = new " << type.replace('/', '.') << "();\n";
+}
+
+BASETYPE JavaType::isBaseType(const OString& type)
+{
+ if (type.equals("long"))
+ return BT_LONG;
+ if (type.equals("short"))
+ return BT_SHORT;
+ if (type.equals("hyper"))
+ return BT_HYPER;
+ if (type.equals("string"))
+ return BT_STRING;
+ if (type.equals("boolean"))
+ return BT_BOOLEAN;
+ if (type.equals("char"))
+ return BT_CHAR;
+ if (type.equals("byte"))
+ return BT_BYTE;
+ if (type.equals("any"))
+ return BT_ANY;
+ if (type.equals("float"))
+ return BT_FLOAT;
+ if (type.equals("double"))
+ return BT_DOUBLE;
+ if (type.equals("void"))
+ return BT_VOID;
+ if (type.equals("type"))
+ return BT_TYPE;
+ if (type.equals("unsigned long"))
+ return BT_UNSIGNED_LONG;
+ if (type.equals("unsigned short"))
+ return BT_UNSIGNED_SHORT;
+ if (type.equals("unsigned hyper"))
+ return BT_UNSIGNED_HYPER;
+
+ return BT_INVALID;
+}
+
+OString JavaType::checkSpecialJavaType(const OString& type)
+{
+ OString baseType(type);
+
+ RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader();
+
+ RegistryKey key;
+ RegValueType valueType;
+ sal_uInt32 valueSize;
+ sal_uInt8* pBuffer=NULL;
+ RTTypeClass typeClass;
+ sal_Bool isTypeDef = (m_typeMgr.getTypeClass(baseType) == RT_TYPE_TYPEDEF);
+
+ while (isTypeDef)
+ {
+ key = m_typeMgr.getTypeKey(baseType);
+
+ if (key.isValid())
+ {
+ if (!key.getValueInfo(OUString(), &valueType, &valueSize))
+ {
+ pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize);
+ if (!key.getValue(OUString(), pBuffer))
+ {
+ TypeReader reader(rReaderLoader, pBuffer, valueSize, sal_False);
+
+ typeClass = reader.getTypeClass();
+
+ if (typeClass == RT_TYPE_TYPEDEF)
+ baseType = reader.getSuperTypeName();
+ else
+ isTypeDef = sal_False;
+ }
+ rtl_freeMemory(pBuffer);
+ }
+ key.closeKey();
+ } else
+ {
+ break;
+ }
+ }
+
+ return baseType;
+}
+
+OString JavaType::checkRealBaseType(const OString& type)
+{
+ sal_Int32 index = type.lastIndexOf(']');
+ OString baseType = (index > 0 ? ((OString)type).copy(index+1) : type);
+
+ RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader();
+
+ RegistryKey key;
+ RegValueType valueType;
+ sal_uInt32 valueSize;
+ sal_uInt8* pBuffer=NULL;
+ RTTypeClass typeClass;
+ sal_Bool mustBeChecked = (m_typeMgr.getTypeClass(baseType) == RT_TYPE_TYPEDEF);
+
+ while (mustBeChecked)
+ {
+ key = m_typeMgr.getTypeKey(baseType);
+
+ if (key.isValid())
+ {
+ if (!key.getValueInfo(OUString(), &valueType, &valueSize))
+ {
+ pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize);
+ if (!key.getValue(OUString(), pBuffer))
+ {
+ TypeReader reader(rReaderLoader, pBuffer, valueSize, sal_False);
+
+ typeClass = reader.getTypeClass();
+
+ if (typeClass == RT_TYPE_TYPEDEF)
+ {
+ baseType = reader.getSuperTypeName();
+ index = baseType.lastIndexOf(']');
+ if (index > 0)
+ {
+ baseType = baseType.copy(index+1);
+ }
+
+ } else
+ mustBeChecked = sal_False;
+ }
+ rtl_freeMemory(pBuffer);
+ }
+ key.closeKey();
+ } else
+ {
+ break;
+ }
+ }
+
+ return baseType;
+}
+
+void JavaType::dumpConstantValue(FileStream& o, sal_uInt16 index)
+{
+ RTConstValue constValue = m_reader.getFieldConstValue(index);
+
+ switch (constValue.m_type)
+ {
+ case RT_TYPE_BOOL:
+ o << "(boolean)" << constValue.m_value.aBool;
+ break;
+ case RT_TYPE_BYTE:
+ o << "(byte)" << (sal_Int16) constValue.m_value.aByte;
+ break;
+ case RT_TYPE_INT16:
+ o << "(short)" << constValue.m_value.aShort << "L";
+ break;
+ case RT_TYPE_UINT16:
+ o << "(short)" << constValue.m_value.aUShort << "L";
+ break;
+ case RT_TYPE_INT32:
+ o << "(int)" << constValue.m_value.aLong << "L";
+ break;
+ case RT_TYPE_UINT32:
+ o << "(int)" << constValue.m_value.aULong << "L";
+ break;
+ case RT_TYPE_FLOAT:
+ o << "(float)" << constValue.m_value.aFloat;
+ break;
+ case RT_TYPE_DOUBLE:
+ o << "(double)" << constValue.m_value.aDouble;
+ break;
+ case RT_TYPE_STRING:
+ {
+ ::rtl::OUString aUStr(constValue.m_value.aString);
+ ::rtl::OString aStr = ::rtl::OUStringToOString(aUStr, RTL_TEXTENCODING_ASCII_US);
+ o << "L\"" << aStr.getStr() << "\"";
+ }
+ break;
+ }
+}
+
+sal_Bool JavaType::dumpMemberConstructor(FileStream& o)
+{
+ o << indent() << "public " << m_name << "( ";
+ inc(9 + m_name.getLength());
+
+ OString superType(m_reader.getSuperTypeName());
+ sal_Bool withIndent = sal_False;
+ if (superType.getLength() > 0)
+ withIndent = dumpInheritedMembers(o, superType, sal_True);
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ sal_Bool first = withIndent;
+
+ sal_uInt16 i;
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+
+ if (withIndent)
+ {
+ if (first)
+ {
+ first = sal_False;
+ o << ",\n";
+ }
+ o << indent();
+ } else
+ withIndent = sal_True;
+
+ dumpType(o, m_reader.getFieldType(i));
+ o << " _" << fieldName;
+
+ if (i+1 < fieldCount)
+ o << ",\n";
+ }
+
+ o << " )\n";
+ dec(9 + m_name.getLength());
+ o << indent() << "{\n";
+ inc();
+
+ if (m_typeName.equals("com/sun/star/uno/RuntimeException"))
+ {
+ o << indent() << "super( _Message );\n";
+ o << indent() << "Context" << " = _Context;\n";
+ } else
+ {
+ if (superType.getLength() > 0)
+ {
+ o << indent() << "super( ";
+ inc(7);
+ dumpInheritedMembers(o, superType, sal_True, sal_False);
+ o << " );\n";
+ dec(7);
+ } else
+ {
+ if (m_typeName.equals("com/sun/star/uno/Exception"))
+ o << indent() << "super( _Message );\n";
+ }
+ }
+
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ if (m_typeName.equals("com/sun/star/uno/Exception") && fieldName.equals("Message"))
+ continue;
+
+ o << indent() << fieldName << " = _" << fieldName << ";\n";
+ }
+
+ dec();
+ o << indent() << "}\n";
+
+ return sal_True;
+}
+
+sal_Bool JavaType::dumpInheritedMembers(FileStream& o, const OString& type, sal_Bool first, sal_Bool withType)
+{
+ RegistryKey key = m_typeMgr.getTypeKey(type);
+ RegValueType valueType;
+ sal_uInt32 valueSize;
+ sal_uInt8* pBuffer=NULL;
+ sal_Bool withIndent = sal_False;
+
+ if (key.isValid())
+ {
+ if (!key.getValueInfo(OUString(), &valueType, &valueSize))
+ {
+ pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize);
+ if (!key.getValue(OUString(), pBuffer))
+ {
+ RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader();
+
+ TypeReader reader(rReaderLoader, pBuffer, valueSize, sal_False);
+
+ OString superType(reader.getSuperTypeName());
+ if (superType.getLength() > 0)
+ withIndent = dumpInheritedMembers(o, superType, first, withType);
+
+ first = withIndent;
+
+ sal_uInt32 fieldCount = reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ if (withIndent)
+ {
+ if (first)
+ {
+ first = sal_False;
+ o << ",\n";
+ }
+ o << indent();
+ }else
+ withIndent = sal_True;
+
+ if (withType)
+ {
+ dumpType(o, reader.getFieldType(i));
+ o << " ";
+ }
+
+ o << "_" << reader.getFieldName(i);
+
+ if (i+1 < fieldCount)
+ o << ",\n";
+ }
+ }
+ rtl_freeMemory(pBuffer);
+ }
+ key.closeKey();
+ }
+
+ return withIndent;
+}
+
+void JavaType::dumpSeqStaticMember(FileStream& o, const ::rtl::OString& typeName,
+ const ::rtl::OString& name)
+{
+ OString type(checkSpecialJavaType(typeName));
+
+ sal_Int32 index = type.lastIndexOf(']');
+ sal_Int32 seqNum = (index > 0 ? ((index+1) / 2) : 0);
+
+ if (seqNum > 0)
+ {
+ OString relType = (index > 0 ? ((OString)type).copy(index+1) : type);
+
+ o << indent() << "public static final ";
+ dumpType(o, relType);
+ for (sal_Int32 i=0; i < seqNum; i++)
+ {
+ o << "[]";
+ }
+ o << " _static_seq_" << name << " = new ";
+ dumpType(o, relType);
+ for (i=0; i < seqNum; i++)
+ {
+ o << "[0]";
+ }
+ o << ";\n";
+ return;
+ }
+}
+
+
+void JavaType::inc(sal_uInt32 num)
+{
+ m_indentLength += num;
+}
+
+void JavaType::dec(sal_uInt32 num)
+{
+ if (m_indentLength - num < 0)
+ m_indentLength = 0;
+ else
+ m_indentLength -= num;
+}
+
+OString JavaType::indent()
+{
+ OStringBuffer tmp(m_indentLength);
+
+ for (int i=0; i < m_indentLength; i++)
+ {
+ tmp.append(' ');
+ }
+ return tmp.makeStringAndClear();
+}
+
+OString JavaType::indent(sal_uInt32 num)
+{
+ OStringBuffer tmp(m_indentLength + num);
+
+ for (int i=0; i < m_indentLength + num; i++)
+ {
+ tmp.append(' ');
+ }
+ return tmp.makeStringAndClear();
+}
+
+//*************************************************************************
+// InterfaceType
+//*************************************************************************
+InterfaceType::InterfaceType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : JavaType(typeReader, typeName, typeMgr, typeDependencies)
+{
+}
+
+InterfaceType::~InterfaceType()
+{
+
+}
+
+sal_Bool InterfaceType::dumpFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ dumpPackage(o);
+
+ o << "public interface " << m_name;
+
+ OString superType(m_reader.getSuperTypeName());
+ if (superType.getLength() > 0)
+ o << " extends " << scopedName(m_typeName, superType);
+
+ o << "\n{\n";
+ inc();
+
+ UnoInfoList aUnoTypeInfos;
+
+ dumpAttributes(o, &aUnoTypeInfos);
+ dumpMethods(o, &aUnoTypeInfos);
+
+ o << indent() << "// static Member\n" << indent() << "public static "
+ << "com.sun.star.uno.Uik UIK = new com.sun.star.uno.Uik( ";
+
+ RTUik uik;
+ m_reader.getUik(uik);
+ sal_Char buffer[67];
+ sprintf(buffer, "0x%.8x, (short)0x%.4x, (short)0x%.4x, 0x%.8x, 0x%.8x",
+ uik.m_Data1, uik.m_Data2, uik.m_Data3, uik.m_Data4, uik.m_Data5);
+ o << buffer << " );\n";
+
+ if (!aUnoTypeInfos.empty())
+ {
+ o << "\n" << indent() << "public static final com.sun.star.lib.uno.typeinfo.TypeInfo UNOTYPEINFO[] = { \n";
+
+ inc();
+
+ sal_Int32 index = 0;
+ UnoInfoList::const_iterator iter = aUnoTypeInfos.begin();
+ while (iter != aUnoTypeInfos.end())
+ {
+ o << indent();
+
+ dumpUnoInfo(o, *iter, &index);
+ if (++iter != aUnoTypeInfos.end())
+ o << ",";
+
+ o << "\n";
+ }
+
+ dec();
+ o << indent() << " };\n";
+ }
+
+ o << "\n" << indent() << "public static Object UNORUNTIMEDATA = null;\n";
+
+ dec();
+ o << "}\n\n";
+
+ return sal_True;
+}
+
+void InterfaceType::dumpAttributes(FileStream& o, UnoInfoList* pUnoInfos)
+{
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ sal_Bool first=sal_True;
+
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ sal_Int32 flags;
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ flags = 0;
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ if (first)
+ {
+ first = sal_False;
+ o << indent() << "// Attributes\n";
+ }
+
+ o << indent() << "public ";
+ dumpType(o, fieldType);
+ o << " get" << fieldName << "() throws com.sun.star.uno.RuntimeException;\n";
+
+ if (access != RT_ACCESS_READONLY)
+ {
+ o << indent() << "public void set" << fieldName << "( ";
+ dumpType(o, fieldType);
+ o << " _" << fieldName.toLowerCase() << " ) throws com.sun.star.uno.RuntimeException;\n";
+ }
+
+ if (access == RT_ACCESS_READONLY)
+ flags = flags | UIT_READONLY;
+ if (isUnsigned(fieldType))
+ flags = flags | UIT_UNSIGNED;
+ if (isAny(fieldType))
+ flags = flags | UIT_ANY;
+ if (isInterface(fieldType))
+ flags = flags | UIT_INTERFACE;
+
+ pUnoInfos->push_back(UnoInfo(fieldName, "", UNOTYPEINFO_ATTIRBUTE, i, flags));
+ }
+
+ if (!first)
+ o << endl;
+}
+
+void InterfaceType::dumpMethods(FileStream& o, UnoInfoList* pUnoInfos)
+{
+ sal_uInt32 methodCount = m_reader.getMethodCount();
+ sal_Bool first=sal_True;
+
+ OString methodName, returnType, paramType, paramName;
+ sal_uInt32 paramCount = 0;
+ sal_uInt32 excCount = 0;
+ RTMethodMode methodMode = RT_MODE_INVALID;
+ RTParamMode paramMode = RT_PARAM_INVALID;
+ sal_Int32 flags;
+
+ for (sal_uInt16 i=0; i < methodCount; i++)
+ {
+ flags = 0;
+
+ methodName = m_reader.getMethodName(i);
+ returnType = m_reader.getMethodReturnType(i);
+ paramCount = m_reader.getMethodParamCount(i);
+ excCount = m_reader.getMethodExcCount(i);
+ methodMode = m_reader.getMethodMode(i);
+
+ if ( m_typeName.equals("com/sun/star/uno/XInterface") &&
+ ( methodName.equals("queryInterface") ||
+ methodName.equals("acquire") ||
+ methodName.equals("release") ) )
+ {
+ continue;
+ }
+
+ if (isUnsigned(returnType))
+ flags = flags | UIT_UNSIGNED;
+ if (isAny(returnType))
+ flags = flags | UIT_ANY;
+ if (isInterface(returnType))
+ flags = flags | UIT_INTERFACE;
+ if (methodMode == RT_MODE_ONEWAY || methodMode == RT_MODE_ONEWAY_CONST)
+ flags = flags | UIT_ONEWAY;
+ if (methodMode == RT_MODE_ONEWAY_CONST || methodMode == RT_MODE_TWOWAY_CONST)
+ flags = flags | UIT_CONST;
+
+ if (sal_True || flags) // while unsorted, add always method type info
+ pUnoInfos->push_back(UnoInfo(methodName, "", UNOTYPEINFO_METHOD, i, flags));
+
+ if (first)
+ {
+ first = sal_False;
+ o << indent() << "// Methods\n";
+ }
+
+ o << indent() << "public ";
+ dumpType(o, returnType);
+ o << " " << methodName << "( ";
+
+ sal_uInt16 j;
+ for (j=0; j < paramCount; j++)
+ {
+ flags = 0;
+ paramName = m_reader.getMethodParamName(i, j);
+ paramType = m_reader.getMethodParamType(i, j);
+ paramMode = m_reader.getMethodParamMode(i, j);
+
+ switch (paramMode)
+ {
+ case RT_PARAM_IN:
+ flags = flags | UIT_IN;
+ o << "/*IN*/";
+ break;
+ case RT_PARAM_OUT:
+ flags = flags | UIT_OUT;
+ o << "/*OUT*/";
+ break;
+ case RT_PARAM_INOUT:
+ flags = flags | UIT_IN | UIT_OUT;
+ o << "/*INOUT*/";
+ break;
+ }
+ if (isUnsigned(paramType))
+ flags = flags | UIT_UNSIGNED;
+ if (isAny(paramType))
+ flags = flags | UIT_ANY;
+ if (isInterface(paramType))
+ flags = flags | UIT_INTERFACE;
+ if (flags && flags != 1)
+ pUnoInfos->push_back(UnoInfo(paramName, methodName, UNOTYPEINFO_PARAMETER, j, flags));
+
+ dumpType(o, paramType);
+ if (paramMode != RT_PARAM_IN)
+ o << "[]";
+
+ o << " " << paramName;
+
+ if (j+1 < paramCount) o << ", ";
+ }
+ o << " )";
+
+ o << " throws ";
+ OString excpName;
+ for (j=0; j < excCount; j++)
+ {
+ excpName = m_reader.getMethodExcType(i, j);
+ if (excpName != "com/sun/star/uno/RuntimeException")
+ o << scopedName(m_typeName, excpName) << ", ";
+ }
+ o << "com.sun.star.uno.RuntimeException;\n";
+ }
+
+ if (!first)
+ o << endl;
+}
+
+void InterfaceType::dumpUnoInfo(FileStream& o, const UnoInfo& unoInfo, sal_Int32 * index)
+{
+ switch (unoInfo.m_unoTypeInfo)
+ {
+ case UNOTYPEINFO_ATTIRBUTE:
+ {
+ sal_Bool hasFlags = sal_False;
+ o << "new com.sun.star.lib.uno.typeinfo.AttributeTypeInfo( \"" << unoInfo.m_name << "\", " << (*index) << ", ";
+ if (unoInfo.m_flags & UIT_READONLY)
+ {
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.READONLY";
+ hasFlags = sal_True;
+ }
+ else // mutable attributes have also a set method (in addition to the get method)
+ (*index) ++;
+
+ ++ (*index);
+
+ if (unoInfo.m_flags & UIT_UNSIGNED)
+ {
+ if (hasFlags)
+ o << "|";
+ else
+ hasFlags = sal_True;
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.UNSIGNED";
+ }
+ if (unoInfo.m_flags & UIT_ANY)
+ {
+ if (hasFlags)
+ o << "|";
+ else
+ hasFlags = sal_True;
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.ANY";
+ }
+ if (unoInfo.m_flags & UIT_INTERFACE)
+ {
+ if (hasFlags)
+ o << "|";
+ else
+ hasFlags = sal_True;
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.INTERFACE";
+ }
+ if (!hasFlags)
+ {
+ o << "0";
+ }
+ o << " )";
+ }
+ break;
+ case UNOTYPEINFO_METHOD:
+ {
+ sal_Bool hasFlags = sal_False;
+ o << "new com.sun.star.lib.uno.typeinfo.MethodTypeInfo( \"" << unoInfo.m_name << "\", " << (*index) << ", ";
+ ++ (*index);
+ if (unoInfo.m_flags & UIT_UNSIGNED)
+ {
+ if (hasFlags)
+ o << "|";
+ else
+ hasFlags = sal_True;
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.UNSIGNED";
+ }
+ if (unoInfo.m_flags & UIT_ONEWAY)
+ {
+ if (hasFlags)
+ o << "|";
+ else
+ hasFlags = sal_True;
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.ONEWAY";
+ }
+ if (unoInfo.m_flags & UIT_CONST)
+ {
+ if (hasFlags)
+ o << "|";
+ else
+ hasFlags = sal_True;
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.CONST";
+ }
+ if (unoInfo.m_flags & UIT_ANY)
+ {
+ if (hasFlags)
+ o << "|";
+ else
+ hasFlags = sal_True;
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.ANY";
+ }
+ if (unoInfo.m_flags & UIT_INTERFACE)
+ {
+ if (hasFlags)
+ o << "|";
+ else
+ hasFlags = sal_True;
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.INTERFACE";
+ }
+ if (!hasFlags)
+ {
+ o << "0";
+ }
+ o << " )";
+ }
+ break;
+ case UNOTYPEINFO_PARAMETER:
+ {
+ sal_Bool hasFlags = sal_False;
+ o << "new com.sun.star.lib.uno.typeinfo.ParameterTypeInfo( \"" << unoInfo.m_name
+ << "\", \"" << unoInfo.m_methodName << "\", " << unoInfo.m_index
+ << ", ";
+ if (unoInfo.m_flags & UIT_OUT)
+ {
+ if (unoInfo.m_flags & UIT_IN)
+ {
+ hasFlags = sal_True;
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.IN";
+ }
+
+ if (hasFlags)
+ o << "|";
+ else
+ hasFlags = sal_True;
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.OUT";
+ }
+ if (unoInfo.m_flags & UIT_ANY)
+ {
+ if (hasFlags)
+ o << "|";
+ else
+ hasFlags = sal_True;
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.ANY";
+ }
+ if (unoInfo.m_flags & UIT_INTERFACE)
+ {
+ if (hasFlags)
+ o << "|";
+ else
+ hasFlags = sal_True;
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.INTERFACE";
+ }
+ if (unoInfo.m_flags & UIT_UNSIGNED)
+ {
+ if (hasFlags)
+ o << "|";
+ else
+ hasFlags = sal_True;
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.UNSIGNED";
+ }
+ if (!hasFlags)
+ {
+ o << "0";
+ }
+ o << " )";
+ }
+ break;
+ }
+}
+
+//*************************************************************************
+// ModuleType
+//*************************************************************************
+ModuleType::ModuleType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : JavaType(typeReader, typeName, typeMgr, typeDependencies)
+{
+}
+
+ModuleType::~ModuleType()
+{
+
+}
+
+sal_Bool ModuleType::dump(JavaOptions* pOptions)
+ throw( CannotDumpException )
+{
+ OString outPath;
+ if (pOptions->isValid("-O"))
+ outPath = pOptions->getOption("-O");
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ OString fileName;
+
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST)
+ {
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ fileName = createFileNameFromType(outPath, m_typeName + "/" + fieldName, ".java");
+ FileStream o(fileName);
+
+ if(!o.isValid())
+ {
+ OString message("cannot open ");
+ message += fileName + " for writing";
+ throw CannotDumpException(message);
+ }
+
+ dumpPackage(o, sal_True);
+ o << indent() << "public interface " << fieldName << "\n{\n";
+ inc();
+ o << indent() << "public static final ";
+ dumpType(o, fieldType);
+ o << " value = ";
+ dumpConstantValue(o, i);
+ o << ";\n\n";
+
+ if (isUnsigned(fieldType))
+ {
+ o << indent() << "public static final com.sun.star.lib.uno.typeinfo.TypeInfo UNOTYPEINFO[] = { new com.sun.star.lib.uno.typeinfo.ConstantTypeInfo( \""
+ << fieldName << "\", com.sun.star.lib.uno.typeinfo.TypeInfo.UNSIGNED ) };\n";
+ }
+
+ dec();
+ o << "}\n";
+ }
+ }
+
+ return sal_True;
+}
+
+sal_Bool ModuleType::hasConstants()
+{
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST)
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+//*************************************************************************
+// ConstantsType
+//*************************************************************************
+ConstantsType::ConstantsType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : JavaType(typeReader, typeName, typeMgr, typeDependencies)
+{
+}
+
+ConstantsType::~ConstantsType()
+{
+
+}
+
+sal_Bool ConstantsType::dumpFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ dumpPackage(o);
+
+ o << "public interface " << m_name << "\n{\n";
+ inc();
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+ StringSet aTypeInfos;
+
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST)
+ {
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ if (isUnsigned(fieldType))
+ aTypeInfos.insert(fieldName);
+
+ o << indent() << "public static final ";
+ dumpType(o, fieldType);
+ o << " " << fieldName << " = ";
+ dumpConstantValue(o, i);
+ o << ";\n";
+ }
+ }
+
+ if (!aTypeInfos.empty())
+ {
+ o << "\n" << indent() << "public static final com.sun.star.lib.uno.typeinfo.TypeInfo UNOTYPEINFO[] = { ";
+ inc(63);
+
+ StringSet::const_iterator iter = aTypeInfos.begin();
+ while (iter != aTypeInfos.end())
+ {
+ if (iter != aTypeInfos.begin())
+ o << indent();
+
+ o << "new com.sun.star.lib.uno.typeinfo.ConstantTypeInfo( \"" << *iter << "\", com.sun.star.lib.uno.typeinfo.TypeInfo.UNSIGNED )";
+
+ if (++iter != aTypeInfos.end())
+ o << ",\n";
+ }
+
+ dec(63);
+ o << " };\n";
+ }
+
+ dec();
+ o << "}\n";
+
+ return sal_True;
+}
+
+
+//*************************************************************************
+// StructureType
+//*************************************************************************
+StructureType::StructureType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : JavaType(typeReader, typeName, typeMgr, typeDependencies)
+{
+}
+
+StructureType::~StructureType()
+{
+
+}
+
+sal_Bool StructureType::dumpFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ dumpPackage(o);
+
+ o << "public class " << m_name;
+
+ OString superType(m_reader.getSuperTypeName());
+ if (superType.getLength() > 0)
+ o << " extends " << scopedName(m_typeName, superType);
+
+ o << "\n{\n";
+ inc();
+ o << indent() << "//instance variables\n";
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+// StringSet aTypeInfos;
+ UnoInfoList aUnoTypeInfos;
+ sal_Int32 flags = 0;
+
+ sal_uInt16 i;
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ flags = 0;
+ if (isUnsigned(fieldType))
+ flags = flags | UIT_UNSIGNED;
+ if (isAny(fieldType))
+ flags = flags | UIT_ANY;
+ if (isInterface(fieldType))
+ flags = flags | UIT_INTERFACE;
+ if (flags)
+ aUnoTypeInfos.push_back(UnoInfo(fieldName, "", UNOTYPEINFO_MEMBER, i, flags));
+
+ dumpSeqStaticMember(o, fieldType, fieldName);
+ o << indent() << "public ";
+ dumpType(o, fieldType);
+ o << " " << fieldName << ";\n";
+ }
+
+ o << endl << indent() << "//constructors\n";
+ o << indent() << "public " << m_name << "()\n" << indent() << "{\n";
+ inc();
+ OString relType;
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ dumpTypeInit(o, fieldName, fieldType);
+ }
+ dec();
+ o << indent() << "}\n\n";
+
+ dumpMemberConstructor(o);
+
+ if (!aUnoTypeInfos.empty())
+ {
+ o << "\n" << indent() << "public static final com.sun.star.lib.uno.typeinfo.TypeInfo UNOTYPEINFO[] = { ";
+ inc(63);
+
+ UnoInfoList::const_iterator iter = aUnoTypeInfos.begin();
+ while (iter != aUnoTypeInfos.end())
+ {
+ if (iter != aUnoTypeInfos.begin())
+ o << indent();
+
+ o << "new com.sun.star.lib.uno.typeinfo.MemberTypeInfo( \"" << (*iter).m_name << "\", ";
+
+ if ((*iter).m_flags & UIT_UNSIGNED)
+ {
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.UNSIGNED )";
+ }
+ else if ((*iter).m_flags & UIT_ANY)
+ {
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.ANY )";
+ }
+ else if ((*iter).m_flags & UIT_INTERFACE)
+ {
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.INTERFACE )";
+ }
+
+ if (++iter != aUnoTypeInfos.end())
+ o << ",\n";
+ }
+
+ dec(63);
+ o << " };\n";
+ }
+
+ o << "\n" << indent() << "public static Object UNORUNTIMEDATA = null;\n";
+
+ dec();
+ o << "}\n";
+
+ return sal_True;
+}
+
+
+//*************************************************************************
+// ExceptionType
+//*************************************************************************
+ExceptionType::ExceptionType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : JavaType(typeReader, typeName, typeMgr, typeDependencies)
+{
+}
+
+ExceptionType::~ExceptionType()
+{
+
+}
+
+sal_Bool ExceptionType::dumpFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ dumpPackage(o);
+
+ o << "public class " << m_name;
+
+ if (m_typeName.equals("com/sun/star/uno/RuntimeException"))
+ {
+ o << " extends java.lang.RuntimeException\n";
+ } else
+ {
+ OString superType(m_reader.getSuperTypeName());
+ if (superType.getLength() > 0)
+ o << " extends " << scopedName(m_typeName, superType);
+ else
+ o << " extends java.lang.Exception\n";
+ }
+
+ o << "\n{\n";
+ inc();
+ o << indent() << "//instance variables\n";
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+// StringSet aTypeInfos;
+ UnoInfoList aUnoTypeInfos;
+ sal_Int32 flags = 0;
+
+ if (m_typeName.equals("com/sun/star/uno/RuntimeException"))
+ {
+ o << indent() << "public java.lang.Object Context;\n";
+ }
+
+ sal_uInt16 i;
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ flags = 0;
+
+ if (isUnsigned(fieldType))
+ flags = flags | UIT_UNSIGNED;
+ if (isAny(fieldType))
+ flags = flags | UIT_ANY;
+ if (isInterface(fieldType))
+ flags = flags | UIT_INTERFACE;
+ if (flags)
+ aUnoTypeInfos.push_back(UnoInfo(fieldName, "", UNOTYPEINFO_MEMBER, i, flags));
+
+ if (m_typeName.equals("com/sun/star/uno/Exception") && fieldName.equals("Message"))
+ continue;
+
+ dumpSeqStaticMember(o, fieldType, fieldName);
+ o << indent() << "public ";
+ dumpType(o, fieldType);
+ o << " " << fieldName << ";\n";
+ }
+
+ o << endl << indent() << "//constructors\n";
+ o << indent() << "public " << m_name << "()\n" << indent() << "{\n";
+ inc();
+/*
+ if (m_typeName.equals("com/sun/star/uno/RuntimeException"))
+ {
+ o << indent() << "Context = null;\n";
+ }
+*/
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ if (m_typeName.equals("com/sun/star/uno/Exception") && fieldName.equals("Message"))
+ continue;
+
+ dumpTypeInit(o, fieldName, fieldType);
+ }
+ dec();
+
+ o << indent() << "}\n\n";
+
+ dumpSimpleMemberConstructor(o);
+ dumpMemberConstructor(o);
+
+ if (m_typeName.equals("com/sun/star/uno/RuntimeException"))
+ {
+ o << "\n" << indent() << "public static final com.sun.star.lib.uno.typeinfo.TypeInfo UNOTYPEINFO[] = { "
+ << "new com.sun.star.lib.uno.typeinfo.MemberTypeInfo( \"Context\", com.sun.star.lib.uno.typeinfo.TypeInfo.INTERFACE ) };\n";
+ } else
+ if (!aUnoTypeInfos.empty())
+ {
+ o << "\n" << indent() << "public static final com.sun.star.lib.uno.typeinfo.TypeInfo UNOTYPEINFO[] = { ";
+ inc(63);
+
+ UnoInfoList::const_iterator iter = aUnoTypeInfos.begin();
+ while (iter != aUnoTypeInfos.end())
+ {
+ if (iter != aUnoTypeInfos.begin())
+ o << indent();
+
+ o << "new com.sun.star.lib.uno.typeinfo.MemberTypeInfo( \"" << (*iter).m_name << "\", ";
+
+ if ((*iter).m_flags & UIT_UNSIGNED)
+ {
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.UNSIGNED )";
+ }
+ else if ((*iter).m_flags & UIT_ANY)
+ {
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.ANY )";
+ }
+ else if ((*iter).m_flags & UIT_INTERFACE)
+ {
+ o << "com.sun.star.lib.uno.typeinfo.TypeInfo.INTERFACE )";
+ }
+
+ if (++iter != aUnoTypeInfos.end())
+ o << ",\n";
+ }
+
+ dec(63);
+ o << " };\n";
+ }
+
+ o << "\n" << indent() << "public static Object UNORUNTIMEDATA = null;\n";
+
+ dec();
+ o << "}\n";
+
+ return sal_True;
+}
+
+sal_Bool ExceptionType::dumpSimpleMemberConstructor(FileStream& o)
+{
+ o << indent() << "public " << m_name << "( String _Message )\n";
+
+ OString superType(m_reader.getSuperTypeName());
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ OString fieldName;
+ OString fieldType;
+
+ o << indent() << "{\n";
+ inc();
+
+ o << indent() << "super( _Message );\n";
+/*
+ if (m_typeName.equals("com/sun/star/uno/RuntimeException"))
+ {
+ o << indent() << "super( _Message );\n";
+ o << indent() << "Context" << " = null;\n";
+ } else
+ {
+ o << indent() << "super( _Message );\n";
+ }
+*/
+ for (sal_uInt16 i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access == RT_ACCESS_CONST || access == RT_ACCESS_INVALID)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ fieldType = m_reader.getFieldType(i);
+
+ if (m_typeName.equals("com/sun/star/uno/Exception") && fieldName.equals("Message"))
+ continue;
+
+ dumpTypeInit(o, fieldName, fieldType);
+ }
+
+ dec();
+ o << indent() << "}\n\n";
+
+ return sal_True;
+}
+
+//*************************************************************************
+// EnumType
+//*************************************************************************
+EnumType::EnumType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : JavaType(typeReader, typeName, typeMgr, typeDependencies)
+{
+}
+
+EnumType::~EnumType()
+{
+
+}
+
+sal_Bool EnumType::dumpFile(FileStream& o)
+ throw( CannotDumpException )
+{
+ dumpPackage(o);
+
+ o << "final public class " << m_name << " extends com.sun.star.uno.Enum\n{\n";
+ inc();
+
+ o << indent() << "private " << m_name << "(int value)\n" << indent() << "{\n";
+ inc();
+ o << indent() << "super(value);\n";
+ dec();
+ o << indent() << "}\n\n";
+
+ o << indent() << "public static " << m_name << " getDefault()\n" << indent() << "{\n";
+ inc();
+ o << indent() << "return " << m_reader.getFieldName(0) << ";\n";
+ dec();
+ o << indent() << "}\n\n";
+
+ sal_uInt32 fieldCount = m_reader.getFieldCount();
+ RTFieldAccess access = RT_ACCESS_INVALID;
+ RTConstValue constValue;
+ OString fieldName;
+ sal_uInt32 value=0;
+
+ sal_uInt16 i;
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access != RT_ACCESS_CONST)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ constValue = m_reader.getFieldConstValue(i);
+
+ if (constValue.m_type == RT_TYPE_INT32)
+ value = constValue.m_value.aLong;
+ else
+ value++;
+
+ o << indent() << "public static final " << m_name << " " << fieldName << " = "
+ << "new " << m_name << "(" << value << ");\n";
+ o << indent() << "public static final int " << fieldName << "_value = " << value << ";\n";
+ }
+
+ o << "\n" << indent() << "public static " << m_name << " fromInt(int value)\n" << indent() << "{\n";
+ inc();
+ o << indent() << "switch( value )\n" << indent() << "{\n";
+ inc();
+ for (i=0; i < fieldCount; i++)
+ {
+ access = m_reader.getFieldAccess(i);
+
+ if (access != RT_ACCESS_CONST)
+ continue;
+
+ fieldName = m_reader.getFieldName(i);
+ constValue = m_reader.getFieldConstValue(i);
+
+ if (constValue.m_type == RT_TYPE_INT32)
+ value = constValue.m_value.aLong;
+ else
+ value++;
+
+ o << indent() << "case " << value << ":\n";
+ inc();
+ o << indent() << "return " << fieldName << ";\n";
+ dec();
+ }
+ o << indent() << "default:\n";
+ inc();
+ o << indent() << "return null;\n";
+ dec();
+
+ dec();
+ o << indent() << "}\n";
+ dec();
+ o << indent() << "}\n";
+
+ o << "\n" << indent() << "public static Object UNORUNTIMEDATA = null;\n";
+
+ dec();
+ o << "}\n";
+
+ return sal_True;
+}
+
+//*************************************************************************
+// TypeDefType
+//*************************************************************************
+TypeDefType::TypeDefType(TypeReader& typeReader,
+ const OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies)
+ : JavaType(typeReader, typeName, typeMgr, typeDependencies)
+{
+}
+
+TypeDefType::~TypeDefType()
+{
+
+}
+
+sal_Bool TypeDefType::dump(JavaOptions* pOptions)
+ throw( CannotDumpException )
+{
+ OString relBaseType(checkRealBaseType(m_typeName));
+
+ return produceType(relBaseType, m_typeMgr, m_dependencies, pOptions);
+}
+
+
+//*************************************************************************
+// produceType
+//*************************************************************************
+sal_Bool produceType(const OString& typeName,
+ TypeManager& typeMgr,
+ TypeDependency& typeDependencies,
+ JavaOptions* pOptions)
+ throw( CannotDumpException )
+{
+ if (typeDependencies.isGenerated(typeName))
+ return sal_True;
+
+ RegistryKey typeKey = typeMgr.getTypeKey(typeName);
+
+ if (!typeKey.isValid())
+ return sal_False;
+
+ if( !checkTypeDependencies(typeMgr, typeDependencies, typeName))
+ return sal_False;
+
+ RegValueType valueType;
+ sal_uInt32 valueSize;
+
+ if (typeKey.getValueInfo(OUString(), &valueType, &valueSize))
+ {
+ if (typeName.equals("/"))
+ return sal_True;
+ else
+ return sal_False;
+ }
+ sal_uInt8* pBuffer = (sal_uInt8*)rtl_allocateMemory(valueSize);
+
+ if (typeKey.getValue(OUString(), pBuffer))
+ {
+ rtl_freeMemory(pBuffer);
+ return sal_False;
+ }
+
+ RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader();
+
+ TypeReader reader(rReaderLoader, pBuffer, valueSize, sal_True);
+
+ rtl_freeMemory(pBuffer);
+
+ RTTypeClass typeClass = reader.getTypeClass();
+ sal_Bool ret = sal_False;
+ switch (typeClass)
+ {
+ case RT_TYPE_INTERFACE:
+ {
+ InterfaceType iType(reader, typeName, typeMgr, typeDependencies);
+ ret = iType.dump(pOptions);
+ if (ret) typeDependencies.setGenerated(typeName);
+ ret = iType.dumpDependedTypes(pOptions);
+ }
+ break;
+ case RT_TYPE_MODULE:
+ {
+ ModuleType mType(reader, typeName, typeMgr, typeDependencies);
+ if (mType.hasConstants())
+ {
+ ret = mType.dump(pOptions);
+ if (ret) typeDependencies.setGenerated(typeName);
+ } else
+ ret = sal_True;
+ }
+ break;
+ case RT_TYPE_STRUCT:
+ {
+ StructureType sType(reader, typeName, typeMgr, typeDependencies);
+ ret = sType.dump(pOptions);
+ if (ret) typeDependencies.setGenerated(typeName);
+ ret = sType.dumpDependedTypes(pOptions);
+ }
+ break;
+ case RT_TYPE_ENUM:
+ {
+ EnumType enType(reader, typeName, typeMgr, typeDependencies);
+ ret = enType.dump(pOptions);
+ if (ret) typeDependencies.setGenerated(typeName);
+ ret = enType.dumpDependedTypes(pOptions);
+ }
+ break;
+ case RT_TYPE_EXCEPTION:
+ {
+ ExceptionType eType(reader, typeName, typeMgr, typeDependencies);
+ ret = eType.dump(pOptions);
+ if (ret) typeDependencies.setGenerated(typeName);
+ ret = eType.dumpDependedTypes(pOptions);
+ }
+ break;
+ case RT_TYPE_CONSTANTS:
+ {
+ ConstantsType cType(reader, typeName, typeMgr, typeDependencies);
+ ret = cType.dump(pOptions);
+ if (ret) typeDependencies.setGenerated(typeName);
+ return ret;
+ }
+ break;
+ case RT_TYPE_TYPEDEF:
+ {
+ TypeDefType tdType(reader, typeName, typeMgr, typeDependencies);
+ ret = tdType.dump(pOptions);
+ if (ret) typeDependencies.setGenerated(typeName);
+ ret = tdType.dumpDependedTypes(pOptions);
+ }
+ break;
+ case RT_TYPE_SERVICE:
+ case RT_TYPE_OBJECT:
+ ret = sal_True;
+ break;
+ }
+
+ return ret;
+}
+
+//*************************************************************************
+// scopedName
+//*************************************************************************
+OString scopedName(const OString& scope, const OString& type,
+ sal_Bool bNoNameSpace)
+{
+ if (type.indexOf('/') < 0)
+ return type;
+
+ if (bNoNameSpace)
+ return type.getToken(type.getTokenCount('/') - 1, '/');
+
+ // scoped name only if the namespace is not equal
+ if (scope.lastIndexOf('/') > 0)
+ {
+ OString tmpScp(scope.copy(0, scope.lastIndexOf('/')));
+ OString tmpScp2(type.copy(0, type.lastIndexOf('/')));
+
+ if (tmpScp == tmpScp2)
+ return type.getToken(type.getTokenCount('/') - 1, '/');
+ }
+
+ return type.replace('/', '.');
+}
+
+
+
diff --git a/codemaker/source/javamaker/javatype.hxx b/codemaker/source/javamaker/javatype.hxx
new file mode 100644
index 000000000000..d281176befbf
--- /dev/null
+++ b/codemaker/source/javamaker/javatype.hxx
@@ -0,0 +1,342 @@
+/*************************************************************************
+ *
+ * $RCSfile: javatype.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:25:28 $
+ *
+ * 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): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _CPPUMAKER_CPPUTYPE_HXX_
+#define _CPPUMAKER_CPPUTYPE_HXX_
+
+#ifndef _CODEMAKER_TYPEMANAGER_HXX_
+#include <codemaker/typemanager.hxx>
+#endif
+
+#ifndef _CODEMAKER_DEPENDENCY_HXX_
+#include <codemaker/dependency.hxx>
+#endif
+
+enum BASETYPE
+{
+ BT_INVALID,
+ BT_VOID,
+ BT_ANY,
+ BT_TYPE,
+ BT_BOOLEAN,
+ BT_CHAR,
+ BT_STRING,
+ BT_FLOAT,
+ BT_DOUBLE,
+ BT_OCTET,
+ BT_BYTE,
+ BT_SHORT,
+ BT_LONG,
+ BT_HYPER,
+ BT_UNSIGNED_SHORT,
+ BT_UNSIGNED_LONG,
+ BT_UNSIGNED_HYPER
+};
+
+
+enum JavaTypeDecl
+{
+ CPPUTYPEDECL_ALLTYPES,
+ CPPUTYPEDECL_NOINTERFACES,
+ CPPUTYPEDECL_ONLYINTERFACES
+};
+
+static const sal_Int32 UIT_IN = 0x00000001;
+static const sal_Int32 UIT_OUT = 0x00000002;
+static const sal_Int32 UIT_UNSIGNED = 0x00000004;
+static const sal_Int32 UIT_READONLY = 0x00000008;
+static const sal_Int32 UIT_ONEWAY = 0x00000010;
+static const sal_Int32 UIT_CONST = 0x00000020;
+static const sal_Int32 UIT_ANY = 0x00000040;
+static const sal_Int32 UIT_INTERFACE = 0x00000080;
+
+enum UnoTypeInfo
+{
+ UNOTYPEINFO_INVALID,
+ UNOTYPEINFO_METHOD,
+ UNOTYPEINFO_PARAMETER,
+ UNOTYPEINFO_ATTIRBUTE,
+ UNOTYPEINFO_MEMBER
+};
+
+struct UnoInfo
+{
+ UnoInfo()
+ : m_unoTypeInfo(UNOTYPEINFO_INVALID)
+ , m_index(-1)
+ , m_flags(0)
+ {}
+
+ UnoInfo(const ::rtl::OString& name, const ::rtl::OString& methodName,
+ UnoTypeInfo unoTypeInfo, sal_Int32 index, sal_Int32 flags)
+ : m_name(name)
+ , m_methodName(methodName)
+ , m_unoTypeInfo(unoTypeInfo)
+ , m_index(index)
+ , m_flags(flags)
+ {}
+
+ ::rtl::OString m_name;
+ ::rtl::OString m_methodName;
+ UnoTypeInfo m_unoTypeInfo;
+ sal_Int32 m_index;
+ sal_Int32 m_flags;
+};
+
+inline int operator == (const UnoInfo& u1, const UnoInfo& u2)
+{
+ return ((u1.m_name == u2.m_name) && (u1.m_methodName == u2.m_methodName));
+}
+
+inline int operator < (const UnoInfo& u1, const UnoInfo& u2)
+{
+ if (u1.m_name == u2.m_name)
+ return (u1.m_methodName < u2.m_methodName);
+ else
+ return (u1.m_name < u2.m_name);
+}
+
+/*
+struct LessUnoInfo
+{
+ bool operator()(const UnoInfo& unoInfo1, const UnoInfo& unoInfo2) const
+ {
+ return (unoInfo1.m_name < unoInfo2.m_name);
+ }
+};
+
+typedef NAMESPACE_STD(set) <UnoInfo, LessUnoInfo> UnoInfoSet;
+*/
+typedef NAMESPACE_STD(list) <UnoInfo> UnoInfoList;
+
+class JavaOptions;
+class FileStream;
+
+class JavaType
+{
+public:
+ JavaType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~JavaType();
+
+ virtual sal_Bool dump(JavaOptions* pOptions) throw( CannotDumpException );
+ virtual sal_Bool dumpDependedTypes(JavaOptions* pOptions) throw( CannotDumpException );
+ virtual sal_Bool dumpFile(FileStream& o) throw( CannotDumpException ) { return sal_True; }
+
+ void dumpPackage(FileStream& o, sal_Bool bFullScope = sal_False);
+
+ virtual void dumpDepImports(FileStream& o, const ::rtl::OString& typeName);
+
+ virtual void dumpType(FileStream& o, const ::rtl::OString& type) throw( CannotDumpException );
+ ::rtl::OString getBaseType(const ::rtl::OString& type);
+ void dumpTypeInit(FileStream& o, const ::rtl::OString& name, const ::rtl::OString& type);
+ BASETYPE isBaseType(const ::rtl::OString& type);
+ sal_Bool isUnsigned(const ::rtl::OString& type);
+ sal_Bool isAny(const ::rtl::OString& type);
+ sal_Bool isInterface(const ::rtl::OString& type);
+
+ void dumpConstantValue(FileStream& o, sal_uInt16 index);
+
+ sal_uInt32 getMemberCount();
+
+ // only used for structs and exceptions
+ sal_Bool dumpMemberConstructor(FileStream& o);
+ sal_Bool dumpInheritedMembers( FileStream& o, const ::rtl::OString& type,
+ sal_Bool first, sal_Bool withType= sal_True );
+ void dumpSeqStaticMember(FileStream& o, const ::rtl::OString& type,
+ const ::rtl::OString& name);
+
+ void inc(sal_uInt32 num=4);
+ void dec(sal_uInt32 num=4);
+ ::rtl::OString indent();
+ ::rtl::OString indent(sal_uInt32 num);
+protected:
+ ::rtl::OString checkSpecialJavaType(const ::rtl::OString& type);
+ ::rtl::OString checkRealBaseType(const ::rtl::OString& type);
+
+protected:
+ sal_uInt32 m_indentLength;
+ ::rtl::OString m_typeName;
+ ::rtl::OString m_name;
+ TypeReader m_reader;
+ TypeManager& m_typeMgr;
+ TypeDependency m_dependencies;
+};
+
+class InterfaceType : public JavaType
+{
+public:
+ InterfaceType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~InterfaceType();
+
+ sal_Bool dumpFile(FileStream& o) throw( CannotDumpException );
+
+ void dumpAttributes(FileStream& o, UnoInfoList* pUnoInfos);
+ void dumpMethods(FileStream& o, UnoInfoList* pUnoInfos);
+
+ void dumpUnoInfo(FileStream& o, const UnoInfo& unoInfo, sal_Int32 * index);
+};
+
+class ModuleType : public JavaType
+{
+public:
+ ModuleType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~ModuleType();
+
+ sal_Bool dump(JavaOptions* pOptions) throw( CannotDumpException );
+ sal_Bool hasConstants();
+};
+
+class ConstantsType : public JavaType
+{
+public:
+ ConstantsType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~ConstantsType();
+
+ sal_Bool dumpFile(FileStream& o) throw( CannotDumpException );
+};
+
+class StructureType : public JavaType
+{
+public:
+ StructureType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~StructureType();
+
+ sal_Bool dumpFile(FileStream& o) throw( CannotDumpException );
+};
+
+class ExceptionType : public JavaType
+{
+public:
+ ExceptionType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~ExceptionType();
+
+ sal_Bool dumpFile(FileStream& o) throw( CannotDumpException );
+ sal_Bool dumpSimpleMemberConstructor(FileStream& o);
+};
+
+class EnumType : public JavaType
+{
+public:
+ EnumType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~EnumType();
+
+ sal_Bool dumpFile(FileStream& o) throw( CannotDumpException );
+};
+
+class TypeDefType : public JavaType
+{
+public:
+ TypeDefType(TypeReader& typeReader,
+ const ::rtl::OString& typeName,
+ const TypeManager& typeMgr,
+ const TypeDependency& typeDependencies);
+
+ virtual ~TypeDefType();
+
+ sal_Bool dump(JavaOptions* pOptions) throw( CannotDumpException );
+};
+
+
+sal_Bool produceType(const ::rtl::OString& typeName,
+ TypeManager& typeMgr,
+ TypeDependency& typeDependencies,
+ JavaOptions* pOptions)
+ throw( CannotDumpException );
+
+/**
+ * This function returns a Java scoped name, represents the package
+ * scoping of this type, e.g. com.sun.star.uno.XInterface. If the scope of
+ * the type is equal scope, the relativ name will be used.
+ */
+::rtl::OString scopedName(const ::rtl::OString& scope, const ::rtl::OString& type,
+ sal_Bool bNoNameSpace=sal_False);
+
+
+#endif // _CPPUMAKER_CPPUTYPE_HXX_
+
diff --git a/codemaker/source/javamaker/makefile.mk b/codemaker/source/javamaker/makefile.mk
new file mode 100644
index 000000000000..113f19ddf3c4
--- /dev/null
+++ b/codemaker/source/javamaker/makefile.mk
@@ -0,0 +1,104 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:25:28 $
+#
+# 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=codemaker
+TARGET=javamaker
+TARGETTYPE=CUI
+LIBTARGET=NO
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Files --------------------------------------------------------
+
+CXXFILES= javamaker.cxx \
+ javaoptions.cxx \
+ javatype.cxx
+
+
+APP1TARGET= $(TARGET)
+
+APP1OBJS= $(OBJ)$/javamaker.obj \
+ $(OBJ)$/javaoptions.obj \
+ $(OBJ)$/javatype.obj
+
+APP1STDLIBS=\
+ $(SALLIB) \
+ $(VOSLIB) \
+ $(REGLIB) \
+ $(STDLIBCPP)
+
+.IF "$(GUI)"=="WNT"
+APP1STDLIBS+= \
+ $(LIBCIMT) $(LIBCMT)
+.ENDIF
+
+APP1LIBS= \
+ $(LB)$/codemaker.lib
+
+.INCLUDE : target.mk