summaryrefslogtreecommitdiff
path: root/rdbmaker
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 /rdbmaker
parent9399c662f36c385b0c705eb34e636a9aec450282 (diff)
initial import
Diffstat (limited to 'rdbmaker')
-rw-r--r--rdbmaker/inc/codemaker/dependency.hxx215
-rw-r--r--rdbmaker/inc/codemaker/global.hxx152
-rw-r--r--rdbmaker/inc/codemaker/options.hxx141
-rw-r--r--rdbmaker/inc/codemaker/registry.hxx254
-rw-r--r--rdbmaker/inc/codemaker/typemanager.hxx212
-rw-r--r--rdbmaker/prj/d.lst5
-rw-r--r--rdbmaker/source/codemaker/dependency.cxx348
-rw-r--r--rdbmaker/source/codemaker/global.cxx377
-rw-r--r--rdbmaker/source/codemaker/makefile.mk92
-rw-r--r--rdbmaker/source/codemaker/options.cxx138
-rw-r--r--rdbmaker/source/codemaker/typemanager.cxx322
-rw-r--r--rdbmaker/source/rdbmaker/makefile.mk128
-rw-r--r--rdbmaker/source/rdbmaker/rdbmaker.cxx554
-rw-r--r--rdbmaker/source/rdbmaker/rdboptions.cxx406
-rw-r--r--rdbmaker/source/rdbmaker/rdboptions.hxx91
-rw-r--r--rdbmaker/source/rdbmaker/rdbtype.cxx235
-rw-r--r--rdbmaker/source/rdbmaker/rdbtype.hxx90
-rw-r--r--rdbmaker/source/rdbmaker/specialtypemanager.cxx139
-rw-r--r--rdbmaker/source/rdbmaker/specialtypemanager.hxx111
-rw-r--r--rdbmaker/source/rdbmaker/typeblop.cxx517
20 files changed, 4527 insertions, 0 deletions
diff --git a/rdbmaker/inc/codemaker/dependency.hxx b/rdbmaker/inc/codemaker/dependency.hxx
new file mode 100644
index 000000000000..f8b2d1805931
--- /dev/null
+++ b/rdbmaker/inc/codemaker/dependency.hxx
@@ -0,0 +1,215 @@
+/*************************************************************************
+ *
+ * $RCSfile: dependency.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+ *
+ * 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_DEPENDENCY_HXX_
+#define _CODEMAKER_DEPENDENCY_HXX_
+
+#include <hash_map>
+
+#ifndef _REGISTRY_REGISTRY_HXX_
+#include <registry/registry.hxx>
+#endif
+#ifndef __REGISTRY_REFLREAD_HXX__
+#include <registry/reflread.hxx>
+#endif
+
+#ifndef _CODEMAKER_TYPEMANAGER_HXX_
+#include <codemaker/typemanager.hxx>
+#endif
+#ifndef _CODEMAKER_GLOBAL_HXX_
+#include <codemaker/global.hxx>
+#endif
+
+#ifndef _OSL_DIAGNOSE_H_
+#include <osl/diagnose.h>
+#endif
+
+#define TYPEUSE_NORMAL 0x0001
+#define TYPEUSE_SUPER 0x0002
+#define TYPEUSE_MEMBER 0x0004
+#define TYPEUSE_INPARAM 0x0008
+#define TYPEUSE_OUTPARAM 0x0010
+#define TYPEUSE_INOUTPARAM 0x0020
+#define TYPEUSE_RETURN 0x0040
+#define TYPEUSE_EXCEPTION 0x0080
+
+/**
+ * Flag shows the state of the code generation. If the Flag is set
+ * the code for this type is generated.
+ */
+#define CODEGEN_DEFAULT 0x0001
+
+struct TypeUsing
+{
+ TypeUsing(const ::rtl::OString& type, sal_uInt16 use)
+ : m_type(type)
+ , m_use(use)
+ {}
+
+ ::rtl::OString m_type;
+ sal_uInt16 m_use;
+
+ sal_Bool operator == (const TypeUsing & typeUsing) const
+ {
+ OSL_ASSERT(0);
+ return m_type == typeUsing.m_type && m_use == typeUsing.m_use;
+ }
+};
+
+struct LessTypeUsing
+{
+ sal_Bool operator()(const TypeUsing& tuse1, const TypeUsing& tuse2) const
+ {
+ return (tuse1.m_type < tuse2.m_type);
+ }
+};
+
+typedef NAMESPACE_STD(set) <TypeUsing, LessTypeUsing> TypeUsingSet;
+
+
+#if (defined( _MSC_VER ) && ( _MSC_VER < 1200 ))
+typedef NAMESPACE_STD(__hash_map__)
+<
+ ::rtl::OString,
+ TypeUsingSet,
+ HashString,
+ EqualString,
+ NewAlloc
+> DependencyMap;
+
+typedef NAMESPACE_STD(__hash_map__)
+<
+ ::rtl::OString,
+ sal_uInt16,
+ HashString,
+ EqualString,
+ NewAlloc
+> GenerationMap;
+#else
+typedef NAMESPACE_STD(hash_map)
+<
+ ::rtl::OString,
+ TypeUsingSet,
+ HashString,
+ EqualString
+> DependencyMap;
+
+typedef NAMESPACE_STD(hash_map)
+<
+ ::rtl::OString,
+ sal_uInt16,
+ HashString,
+ EqualString
+> GenerationMap;
+
+#endif
+
+struct TypeDependencyImpl
+{
+ TypeDependencyImpl()
+ : m_refCount(0)
+ {}
+
+ sal_Int32 m_refCount;
+ DependencyMap m_dependencies;
+ GenerationMap m_generatedTypes;
+};
+
+class TypeDependency
+{
+public:
+ TypeDependency();
+ ~TypeDependency();
+
+ TypeDependency( const TypeDependency& value )
+ : m_pImpl( value.m_pImpl )
+ {
+ acquire();
+ }
+
+ TypeDependency& operator = ( const TypeDependency& value )
+ {
+ release();
+ m_pImpl = value.m_pImpl;
+ acquire();
+ return *this;
+ }
+
+ sal_Bool insert(const ::rtl::OString& type, const ::rtl::OString& depend, sal_uInt16);
+ TypeUsingSet getDependencies(const ::rtl::OString& type);
+ sal_Bool lookupDependency(const ::rtl::OString& type, const ::rtl::OString& depend, sal_uInt16);
+ sal_Bool hasDependencies(const ::rtl::OString& type);
+
+ void setGenerated(const ::rtl::OString& type, sal_uInt16 genFlag=CODEGEN_DEFAULT);
+ sal_Bool isGenerated(const ::rtl::OString& type, sal_uInt16 genFlag=CODEGEN_DEFAULT);
+
+ sal_Int32 getSize() { return m_pImpl->m_generatedTypes.size(); }
+protected:
+ void acquire();
+ void release();
+
+protected:
+ TypeDependencyImpl* m_pImpl;
+};
+
+sal_Bool checkTypeDependencies(TypeManager& typeMgr, TypeDependency& dependencies, const ::rtl::OString& type);
+
+#endif // _CODEMAKER_DEPENDENCY_HXX_
diff --git a/rdbmaker/inc/codemaker/global.hxx b/rdbmaker/inc/codemaker/global.hxx
new file mode 100644
index 000000000000..6ab359efd970
--- /dev/null
+++ b/rdbmaker/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:29:08 $
+ *
+ * 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/rdbmaker/inc/codemaker/options.hxx b/rdbmaker/inc/codemaker/options.hxx
new file mode 100644
index 000000000000..875d3e785d9b
--- /dev/null
+++ b/rdbmaker/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:29:08 $
+ *
+ * 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/rdbmaker/inc/codemaker/registry.hxx b/rdbmaker/inc/codemaker/registry.hxx
new file mode 100644
index 000000000000..aef51ffa048d
--- /dev/null
+++ b/rdbmaker/inc/codemaker/registry.hxx
@@ -0,0 +1,254 @@
+/*************************************************************************
+ *
+ * $RCSfile: registry.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+ *
+ * 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_REGISTRY_HXX_
+#define _CODEMAKER_REGISTRY_HXX_
+
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+
+#ifndef _OSL_INTERLOCK_H_
+#include <osl/interlck.h>
+#endif
+
+#ifndef _REGISTRY_REGISTRY_HXX_
+#include <registry/registry.hxx>
+#endif
+#ifndef __REGISTRY_REFLREAD_HXX__
+#include <registry/reflread.hxx>
+#endif
+
+#ifndef _CODEMAKER_OPTIONS_HXX_
+#include <codemaker/options.hxx>
+#endif
+
+struct TypeReader_Impl
+{
+ TypeReader_Impl(const RegistryTypeReaderLoader& rLoader,
+ const sal_uInt8* buffer,
+ sal_uInt32 bufferLen,
+ sal_Bool copyData)
+ : m_refCount(0)
+ , m_copyData(copyData)
+ , m_blopSize(bufferLen)
+ , m_pBlop(buffer)
+ {
+ if (copyData)
+ {
+ m_pBlop = (sal_uInt8*)rtl_allocateMemory(bufferLen);
+ rtl_copyMemory((void*)m_pBlop, buffer, bufferLen);
+ } else
+ {
+ m_blopSize = bufferLen;
+ m_pBlop = buffer;
+ }
+
+ m_pReader = new RegistryTypeReader( rLoader, m_pBlop, m_blopSize, sal_False);
+ }
+
+ ~TypeReader_Impl()
+ {
+ if (m_copyData && m_pReader)
+ {
+ delete m_pReader;
+ }
+ }
+
+ sal_Int32 m_refCount;
+ sal_Bool m_copyData;
+ sal_Int32 m_blopSize;
+ const sal_uInt8* m_pBlop;
+ RegistryTypeReader* m_pReader;
+};
+
+class TypeReader
+{
+/*
+ inline TypeReader(const RegistryTypeReader_Api* pApi,
+ const sal_uInt8* buffer,
+ sal_uInt32 bufferLen,
+ sal_Bool copyData);
+*/
+public:
+ inline TypeReader()
+ : m_pImpl(NULL)
+ {}
+
+ inline TypeReader(const RegistryTypeReaderLoader& rLoader,
+ const sal_uInt8* buffer,
+ sal_uInt32 bufferLen,
+ sal_Bool copyData)
+ {
+ m_pImpl = new TypeReader_Impl(rLoader, buffer, bufferLen, copyData);
+ acquire();
+ }
+
+ inline TypeReader(const TypeReader& toCopy)
+ : m_pImpl(toCopy.m_pImpl)
+ {
+ acquire();
+ }
+
+ inline void acquire()
+ {
+ if (m_pImpl)
+ osl_incrementInterlockedCount(&m_pImpl->m_refCount);
+ }
+
+ inline void release()
+ {
+ if (m_pImpl && 0 == osl_decrementInterlockedCount(&m_pImpl->m_refCount))
+ {
+ delete m_pImpl;
+ }
+ }
+
+ inline TypeReader& operator = ( const TypeReader& value )
+ {
+ release();
+ m_pImpl = value.m_pImpl;
+ acquire();
+ return *this;
+ }
+
+ inline sal_Bool isValid() const
+ {
+ if (m_pImpl)
+ return m_pImpl->m_pReader->isValid();
+ else
+ return sal_False;
+ }
+
+ inline sal_uInt16 getMinorVersion() const
+ { return m_pImpl->m_pReader->getMinorVersion(); }
+ inline sal_uInt16 getMajorVersion() const
+ { return m_pImpl->m_pReader->getMajorVersion(); }
+ inline RTTypeClass getTypeClass() const
+ { return m_pImpl->m_pReader->getTypeClass(); }
+ inline const ::rtl::OString getTypeName() const
+ { return inGlobalSet( m_pImpl->m_pReader->getTypeName() ); }
+ inline const ::rtl::OString getSuperTypeName() const
+ { return inGlobalSet( m_pImpl->m_pReader->getSuperTypeName() ); }
+ inline void getUik(RTUik& uik) const
+ { m_pImpl->m_pReader->getUik(uik); }
+ inline const ::rtl::OString getDoku() const
+ { return inGlobalSet( m_pImpl->m_pReader->getDoku() ); }
+ inline const ::rtl::OString getFileName() const
+ { return inGlobalSet( m_pImpl->m_pReader->getFileName() ); }
+ inline sal_uInt32 getFieldCount() const
+ { return m_pImpl->m_pReader->getFieldCount(); }
+ inline const ::rtl::OString getFieldName( sal_uInt16 index ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getFieldName(index) ); }
+ inline const ::rtl::OString getFieldType( sal_uInt16 index ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getFieldType(index) ); }
+ inline RTFieldAccess getFieldAccess( sal_uInt16 index ) const
+ { return m_pImpl->m_pReader->getFieldAccess(index); }
+ inline RTConstValue getFieldConstValue( sal_uInt16 index ) const
+ { return m_pImpl->m_pReader->getFieldConstValue(index); }
+ inline const ::rtl::OString getFieldDoku( sal_uInt16 index ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getFieldDoku(index) ); }
+ inline const ::rtl::OString getFieldFileName( sal_uInt16 index ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getFieldFileName(index) ); }
+ inline sal_uInt32 getMethodCount() const
+ { return m_pImpl->m_pReader->getMethodCount(); }
+ inline const ::rtl::OString getMethodName( sal_uInt16 index ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getMethodName(index) ); }
+ inline sal_uInt32 getMethodParamCount( sal_uInt16 index ) const
+ { return m_pImpl->m_pReader->getMethodParamCount(index); }
+ inline const ::rtl::OString getMethodParamType( sal_uInt16 index, sal_uInt16 paramIndex ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getMethodParamType(index,paramIndex) ); }
+ inline const ::rtl::OString getMethodParamName( sal_uInt16 index, sal_uInt16 paramIndex ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getMethodParamName(index,paramIndex) ); }
+ inline RTParamMode getMethodParamMode( sal_uInt16 index, sal_uInt16 paramIndex ) const
+ { return m_pImpl->m_pReader->getMethodParamMode(index,paramIndex); }
+ inline sal_uInt32 getMethodExcCount( sal_uInt16 index ) const
+ { return m_pImpl->m_pReader->getMethodExcCount(index); }
+ inline const ::rtl::OString getMethodExcType( sal_uInt16 index, sal_uInt16 excIndex ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getMethodExcType(index,excIndex) ); }
+ inline const ::rtl::OString getMethodReturnType( sal_uInt16 index ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getMethodReturnType(index) ); }
+ inline RTMethodMode getMethodMode( sal_uInt16 index ) const
+ { return m_pImpl->m_pReader->getMethodMode(index); }
+ inline const ::rtl::OString getMethodDoku( sal_uInt16 index ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getMethodDoku(index) ); }
+
+ inline sal_uInt32 getReferenceCount() const
+ { return m_pImpl->m_pReader->getReferenceCount(); }
+ inline const ::rtl::OString getReferenceName( sal_uInt16 index ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getReferenceName(index) ); }
+ inline RTReferenceType getReferenceType( sal_uInt16 index ) const
+ { return m_pImpl->m_pReader->getReferenceType(index); }
+ inline const ::rtl::OString getReferenceDoku( sal_uInt16 index ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getReferenceDoku(index) ); }
+
+ inline sal_uInt32 getBlopSize() const
+ { return m_pImpl->m_blopSize; }
+
+ inline const sal_uInt8* getBlop() const
+ { return m_pImpl->m_pBlop; }
+
+private:
+ TypeReader_Impl* m_pImpl;
+};
+
+
+#endif // _CODEMAKER_REGISTRY_HXX_
diff --git a/rdbmaker/inc/codemaker/typemanager.hxx b/rdbmaker/inc/codemaker/typemanager.hxx
new file mode 100644
index 000000000000..030dd962795e
--- /dev/null
+++ b/rdbmaker/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:29:08 $
+ *
+ * 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/rdbmaker/prj/d.lst b/rdbmaker/prj/d.lst
new file mode 100644
index 000000000000..47a8ff0d36c1
--- /dev/null
+++ b/rdbmaker/prj/d.lst
@@ -0,0 +1,5 @@
+..\%__SRC%\bin\rdbmaker.exe %_DEST%\bin%_EXT%\rdbmaker.exe
+..\%__SRC%\bin\rdbmaker.pdb %_DEST%\bin%_EXT%\rdbmaker.pdb
+
+..\%__SRC%\bin\rdbmaker %_DEST%\bin%_EXT%\rdbmaker
+
diff --git a/rdbmaker/source/codemaker/dependency.cxx b/rdbmaker/source/codemaker/dependency.cxx
new file mode 100644
index 000000000000..2bba05227f01
--- /dev/null
+++ b/rdbmaker/source/codemaker/dependency.cxx
@@ -0,0 +1,348 @@
+/*************************************************************************
+ *
+ * $RCSfile: dependency.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+ *
+ * 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 _OSL_INTERLOCK_H_
+#include <osl/interlck.h>
+#endif
+
+#ifndef _RTL_ALLOC_H_
+#include <rtl/alloc.h>
+#endif
+
+#ifndef _CODEMAKER_DEPENDENCY_HXX_
+#include <codemaker/dependency.hxx>
+#endif
+
+using namespace rtl;
+
+TypeDependency::TypeDependency()
+{
+ m_pImpl = new TypeDependencyImpl();
+ acquire();
+}
+
+TypeDependency::~TypeDependency()
+{
+ release();
+}
+
+void TypeDependency::acquire()
+{
+ osl_incrementInterlockedCount(&m_pImpl->m_refCount);
+}
+
+void TypeDependency::release()
+{
+ if (0 == osl_decrementInterlockedCount(&m_pImpl->m_refCount))
+ {
+ delete m_pImpl;
+ }
+}
+
+sal_Bool TypeDependency::insert(const OString& type, const OString& depend, sal_uInt16 use)
+{
+ sal_Bool ret = sal_False;
+
+ if (type.getLength() > 0 && depend.getLength() > 0)
+ {
+ if (m_pImpl->m_dependencies.count(type) > 0)
+ {
+ TypeUsing typeUsing(depend, use);
+ TypeUsingSet::iterator iter;
+ if ((iter = m_pImpl->m_dependencies[type].find(typeUsing)) != m_pImpl->m_dependencies[type].end())
+ {
+ (((TypeUsing *) &(*iter))->m_use) = (*iter).m_use | use;
+ } else
+ {
+ m_pImpl->m_dependencies[type].insert(typeUsing);
+ }
+ } else
+ {
+ TypeUsing typeUsing(depend, use);
+ TypeUsingSet tmpSet;
+ tmpSet.insert(typeUsing);
+ m_pImpl->m_dependencies[type]=tmpSet;
+ }
+ }
+
+ return ret;
+}
+
+TypeUsingSet TypeDependency::getDependencies(const OString& type)
+{
+ if (type.getLength() > 0)
+ {
+ if (m_pImpl->m_dependencies.count(type) > 0)
+ {
+ return m_pImpl->m_dependencies[type];
+ }
+ }
+
+ return TypeUsingSet();
+}
+
+sal_Bool TypeDependency::lookupDependency(const OString& type, const OString& depend, sal_uInt16 use)
+{
+ sal_Bool ret = sal_False;
+
+ if (type.getLength() > 0 && depend.getLength() > 0)
+ {
+ if (m_pImpl->m_dependencies.count(type) > 0)
+ {
+ TypeUsingSet::const_iterator iter = m_pImpl->m_dependencies[type].begin();
+
+ while (iter != m_pImpl->m_dependencies[type].end())
+ {
+ if (depend == (*iter).m_type &&
+ (use & (*iter).m_use))
+ {
+ ret = sal_True;
+ break;
+ }
+ iter++;
+ }
+ } else
+ {
+ ret = sal_False;
+ }
+ }
+
+ return ret;
+}
+
+sal_Bool TypeDependency::hasDependencies(const OString& type)
+{
+ if (type.getLength() > 0)
+ {
+ if (m_pImpl->m_dependencies.count(type) > 0)
+ {
+ return sal_True;
+ }
+ }
+
+ return sal_False;
+}
+
+void TypeDependency::setGenerated(const OString& type, sal_uInt16 genFlag)
+{
+// m_pImpl->m_generatedTypes.insert(type);
+ if (m_pImpl->m_generatedTypes.count(type) > 0)
+ m_pImpl->m_generatedTypes[type]= m_pImpl->m_generatedTypes[type] | genFlag;
+ else
+ m_pImpl->m_generatedTypes[type]=genFlag;
+}
+
+sal_Bool TypeDependency::isGenerated(const OString& type, sal_uInt16 genFlag)
+{
+/*
+ if (m_pImpl->m_generatedTypes.count(type) > 0)
+ return sal_True;
+
+ return sal_False;
+*/
+ if (m_pImpl->m_generatedTypes.count(type) > 0 &&
+ m_pImpl->m_generatedTypes[type] & genFlag)
+ {
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+static sal_Bool checkFieldDependencies(TypeManager& typeMgr, TypeDependency& dependencies,
+ TypeReader& reader, const OString& type)
+{
+ sal_uInt32 count = reader.getFieldCount();
+
+ if (count == 0 || reader.getTypeClass() == RT_TYPE_ENUM)
+ return sal_True;
+
+ OString fieldType;
+ for (sal_uInt16 i=0; i < count; i++)
+ {
+ fieldType = reader.getFieldType(i);
+
+ if (fieldType.getLength() > 0)
+ {
+ dependencies.insert(type, fieldType, TYPEUSE_MEMBER);
+ checkTypeDependencies(typeMgr, dependencies, fieldType);
+ }
+ }
+
+ return sal_True;
+}
+
+static sal_Bool checkMethodDependencies(TypeManager& typeMgr, TypeDependency& dependencies,
+ TypeReader& reader, const OString& type)
+{
+ sal_uInt32 count = reader.getMethodCount();
+
+ if (count == 0)
+ return sal_True;
+
+ OString returnType, paramType, excType;
+ sal_uInt32 paramCount = 0;
+ sal_uInt32 excCount = 0;
+ RTParamMode paramMode = RT_PARAM_INVALID;
+ for (sal_uInt16 i=0; i < count; i++)
+ {
+ returnType = reader.getMethodReturnType(i);
+
+ dependencies.insert(type, returnType, TYPEUSE_RETURN);
+ checkTypeDependencies(typeMgr, dependencies, returnType);
+
+ paramCount = reader.getMethodParamCount(i);
+ excCount = reader.getMethodExcCount(i);
+
+ sal_uInt16 j;
+ for (j=0; j < paramCount; j++)
+ {
+ paramType = reader.getMethodParamType(i, j);
+ paramMode = reader.getMethodParamMode(i, j);
+
+ switch (paramMode)
+ {
+ case RT_PARAM_IN:
+ dependencies.insert(type, paramType, TYPEUSE_INPARAM);
+ break;
+ case RT_PARAM_OUT:
+ dependencies.insert(type, paramType, TYPEUSE_OUTPARAM);
+ break;
+ case RT_PARAM_INOUT:
+ dependencies.insert(type, paramType, TYPEUSE_INOUTPARAM);
+ break;
+ }
+
+ checkTypeDependencies(typeMgr, dependencies, paramType);
+ }
+
+ for (j=0; j < excCount; j++)
+ {
+ excType = reader.getMethodExcType(i, j);
+ dependencies.insert(type, excType, TYPEUSE_EXCEPTION);
+ checkTypeDependencies(typeMgr, dependencies, excType);
+ }
+
+ }
+
+ return sal_True;
+}
+
+static sal_Bool checkReferenceDependencies(TypeManager& typeMgr, TypeDependency& dependencies,
+ TypeReader& reader, const OString& type)
+{
+ sal_uInt32 count = reader.getReferenceCount();
+
+ if (count == 0)
+ return sal_True;
+
+ OString referenceName;
+ for (sal_uInt16 i=0; i < count; i++)
+ {
+ referenceName = reader.getReferenceName(i);
+
+ dependencies.insert(type, referenceName, TYPEUSE_NORMAL);
+ checkTypeDependencies(typeMgr, dependencies, referenceName);
+ }
+
+ return sal_True;
+}
+
+sal_Bool checkTypeDependencies(TypeManager& typeMgr, TypeDependency& dependencies, const OString& type)
+{
+ if (!typeMgr.isValidType(type))
+ return sal_False;
+
+ if (dependencies.hasDependencies(type))
+ return sal_True;
+
+ TypeReader reader = typeMgr.getTypeReader(type);
+
+ if ( !reader.isValid() )
+ {
+ if (type.equals("/"))
+ return sal_True;
+ else
+ return sal_False;
+ }
+
+ OString superType(reader.getSuperTypeName());
+ if (superType.getLength() > 0)
+ {
+ dependencies.insert(type, superType, TYPEUSE_SUPER);
+ checkTypeDependencies(typeMgr, dependencies, superType);
+ }
+
+ if (reader.getTypeClass() == RT_TYPE_INTERFACE)
+ {
+ dependencies.insert(type, "com/sun/star/uno/RuntimeException", TYPEUSE_EXCEPTION);
+ dependencies.insert(type, "com/sun/star/uno/TypeClass", TYPEUSE_NORMAL);
+ checkTypeDependencies(typeMgr, dependencies, "com/sun/star/uno/RuntimeException");
+ }
+
+ checkFieldDependencies(typeMgr, dependencies, reader, type);
+ checkMethodDependencies(typeMgr, dependencies, reader, type);
+ checkReferenceDependencies(typeMgr, dependencies, reader, type);
+
+ return sal_True;
+}
+
+
diff --git a/rdbmaker/source/codemaker/global.cxx b/rdbmaker/source/codemaker/global.cxx
new file mode 100644
index 000000000000..8dccbc9b9ea6
--- /dev/null
+++ b/rdbmaker/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:29:08 $
+ *
+ * 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/rdbmaker/source/codemaker/makefile.mk b/rdbmaker/source/codemaker/makefile.mk
new file mode 100644
index 000000000000..946cd49d00c7
--- /dev/null
+++ b/rdbmaker/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:29:08 $
+#
+# 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/rdbmaker/source/codemaker/options.cxx b/rdbmaker/source/codemaker/options.cxx
new file mode 100644
index 000000000000..2b582ad730d3
--- /dev/null
+++ b/rdbmaker/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:29:08 $
+ *
+ * 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/rdbmaker/source/codemaker/typemanager.cxx b/rdbmaker/source/codemaker/typemanager.cxx
new file mode 100644
index 000000000000..88031401083f
--- /dev/null
+++ b/rdbmaker/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:29:08 $
+ *
+ * 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/rdbmaker/source/rdbmaker/makefile.mk b/rdbmaker/source/rdbmaker/makefile.mk
new file mode 100644
index 000000000000..6cd7e3918c02
--- /dev/null
+++ b/rdbmaker/source/rdbmaker/makefile.mk
@@ -0,0 +1,128 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+#
+# 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=rdbmaker
+TARGETTYPE=CUI
+LIBTARGET=NO
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Files --------------------------------------------------------
+UNOUCRDEP= $(SOLARBINDIR)$/applicat.rdb
+UNOUCRRDB= $(SOLARBINDIR)$/applicat.rdb
+
+UNOUCROUT= $(OUT)$/inc
+INCPRE+= $(OUT)$/inc
+
+UNOTYPES= \
+ com.sun.star.lang.XMultiServiceFactory \
+ com.sun.star.lang.XSingleServiceFactory \
+ com.sun.star.container.XHierarchicalNameAccess \
+ com.sun.star.reflection.XInterfaceTypeDescription \
+ com.sun.star.reflection.XInterfaceMemberTypeDescription \
+ com.sun.star.reflection.XInterfaceMethodTypeDescription \
+ com.sun.star.reflection.XInterfaceAttributeTypeDescription \
+ com.sun.star.reflection.XCompoundTypeDescription \
+ com.sun.star.reflection.XIndirectTypeDescription \
+ com.sun.star.reflection.XEnumTypeDescription \
+ com.sun.star.registry.XRegistryKey \
+
+CXXFILES= rdbmaker.cxx \
+ rdboptions.cxx \
+ typeblop.cxx \
+ specialtypemanager.cxx \
+ rdbtype.cxx
+
+
+APP1TARGET= $(TARGET)
+
+APP1OBJS= $(OBJ)$/rdbmaker.obj \
+ $(OBJ)$/rdboptions.obj \
+ $(OBJ)$/typeblop.obj \
+ $(OBJ)$/specialtypemanager.obj \
+ $(OBJ)$/rdbtype.obj
+
+APP1STDLIBS=\
+ $(SALLIB) \
+ $(VOSLIB) \
+ $(REGLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(STDLIBCPP)
+
+.IF "$(GUI)"=="WNT"
+APP1STDLIBS+= \
+ $(LIBCIMT) $(LIBCMT)
+.ENDIF
+
+APP1LIBS= \
+ $(LB)$/codemaker.lib
+
+.INCLUDE : target.mk
diff --git a/rdbmaker/source/rdbmaker/rdbmaker.cxx b/rdbmaker/source/rdbmaker/rdbmaker.cxx
new file mode 100644
index 000000000000..575d13dee99f
--- /dev/null
+++ b/rdbmaker/source/rdbmaker/rdbmaker.cxx
@@ -0,0 +1,554 @@
+/*************************************************************************
+ *
+ * $RCSfile: rdbmaker.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+ *
+ * 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 _OSL_FILE_HXX_
+#include <osl/file.hxx>
+#endif
+#ifndef _VOS_PROCESS_HXX_
+#include <vos/process.hxx>
+#endif
+
+#ifndef _CODEMAKER_TYPEMANAGER_HXX_
+#include <codemaker/typemanager.hxx>
+#endif
+#ifndef _CODEMAKER_DEPENDENCY_HXX_
+#include <codemaker/dependency.hxx>
+#endif
+
+#ifndef _RTL_OSTRINGBUFFER_HXX_
+#include <rtl/strbuf.hxx>
+#endif
+
+#if defined(SAL_W32) || defined(SAL_OS2)
+#include <io.h>
+#include <direct.h>
+#include <errno.h>
+#endif
+
+#ifdef UNX
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <unistd.h>
+#endif
+
+#include "specialtypemanager.hxx"
+#include "rdboptions.hxx"
+#include "rdbtype.hxx"
+
+#define PATH_DELEMITTER '/'
+
+using namespace rtl;
+using namespace osl;
+using namespace vos;
+
+FileStream listFile;
+RegistryKey rootKey;
+RegistryLoader loader;
+Registry regFile(loader);
+sal_Bool useSpecial;
+TypeManager* pTypeMgr = NULL;
+StringList dirEntries;
+StringSet filterTypes;
+
+OString getFullNameOfApplicatRdb()
+{
+ OUString bootReg;
+ OUString uTmpStr;
+ if( OStartupInfo::E_None == OStartupInfo().getExecutableFile(uTmpStr) )
+ {
+ sal_uInt32 lastIndex = uTmpStr.lastIndexOf(PATH_DELEMITTER);
+ OUString tmpReg;
+
+ if ( lastIndex > 0 )
+ {
+ tmpReg =uTmpStr.copy(0, lastIndex + 1);
+ }
+
+ tmpReg += OUString( RTL_CONSTASCII_USTRINGPARAM("applicat.rdb") );
+
+ FileBase::getSystemPathFromNormalizedPath(tmpReg, bootReg);
+ }
+
+ return OUStringToOString(bootReg, RTL_TEXTENCODING_ASCII_US);
+}
+
+void initFilterTypes(RdbOptions* pOptions)
+{
+ if (pOptions->isValid("-FT"))
+ {
+ OString fOption(pOptions->getOption("-FT"));
+ sal_uInt32 count = fOption.getTokenCount(';');
+
+ sal_Bool ret = sal_False;
+ for (sal_uInt32 i = 0; i < count; i++)
+ {
+ filterTypes.insert( fOption.getToken(i, ';').replace('.', '/') );
+ }
+ }
+ if (pOptions->isValid("-F"))
+ {
+ FILE *f = fopen(pOptions->getOption("-F").getStr(), "r");
+
+ if (f)
+ {
+ sal_Char buffer[1024+1];
+ sal_Char *pBuf = fgets(buffer, 1024, f);
+ sal_Char *s = NULL;
+ sal_Char *p = NULL;
+ while ( pBuf && !feof(f))
+ {
+ p = pBuf;
+ if (*p != '\n' && *p != '\r')
+ {
+ while (*p == ' ' && *p =='\t')
+ p++;
+
+ s = p;
+ while (*p != '\n' && *p != '\r' && *p != ' ' && *p != '\t')
+ p++;
+
+ *p = '\0';
+ filterTypes.insert( OString(s).replace('.', '/') );
+ }
+
+ pBuf = fgets(buffer, 1024, f);
+ }
+
+ fclose(f);
+ }
+ }
+}
+
+sal_Bool checkFilterTypes(const OString& type)
+{
+ StringSet::iterator iter = filterTypes.begin();
+ while ( iter != filterTypes.end() )
+ {
+ if ( type.indexOf( *iter ) == 0 )
+ {
+ return sal_True;
+ }
+
+ iter++;
+ }
+
+ return sal_False;
+}
+
+void cleanUp( sal_Bool bError)
+{
+ if ( pTypeMgr )
+ {
+ delete pTypeMgr;
+ }
+ if (useSpecial)
+ {
+ pTypeMgr = new SpecialTypeManager();
+ }else
+ {
+ pTypeMgr = new RegistryTypeManager();
+ }
+
+ if ( rootKey.isValid() )
+ {
+ rootKey.closeKey();
+ }
+ if ( regFile.isValid() )
+ {
+ if ( bError )
+ {
+ regFile.destroy(OUString());
+ } else
+ {
+ regFile.close();
+ }
+ }
+ if ( listFile.isValid() )
+ {
+ listFile.closeFile();
+ unlink(listFile.getName().getStr());
+ }
+
+ StringList::reverse_iterator iter = dirEntries.rbegin();
+ while ( iter != dirEntries.rend() )
+ {
+ if (rmdir((char*)(*iter).getStr()) == -1)
+ {
+ break;
+ }
+
+ iter++;
+ }
+}
+
+OString createFileName(const OString& path)
+{
+ OString fileName(path);
+
+ sal_Char token;
+#ifdef SAL_UNX
+ fileName = fileName.replace('\\', '/');
+ token = '/';
+#else
+ fileName = fileName.replace('/', '\\');
+ token = '\\';
+#endif
+
+ sal_Int32 count = fileName.getTokenCount(token) - 1;
+
+ OStringBuffer nameBuffer( path.getLength() );
+
+ 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 ( errno == ENOENT )
+ return OString();
+ } else
+ {
+ dirEntries.push_back(nameBuffer.getStr());
+ }
+
+ nameBuffer.append(token);
+ }
+
+ return fileName;
+}
+
+sal_Bool produceAllTypes(const OString& typeName,
+ TypeManager& typeMgr,
+ TypeDependency& typeDependencies,
+ RdbOptions* pOptions,
+ sal_Bool bFullScope,
+ FileStream& o,
+ RegistryKey& regKey,
+ StringSet& filterTypes)
+ throw( CannotDumpException )
+{
+ if (!produceType(typeName, typeMgr, typeDependencies, pOptions, o, regKey, filterTypes))
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ pOptions->getProgramName().getStr(),
+ OString("cannot dump Type '" + typeName + "'").getStr());
+ cleanUp(sal_True);
+ 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,
+ o, regKey, filterTypes))
+ return sal_False;
+ } else
+ {
+ if (!produceType(tmpName, typeMgr, typeDependencies, pOptions, o, regKey, filterTypes))
+ 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
+{
+ RdbOptions options;
+
+ try
+ {
+ if (!options.initOptions(argc, argv))
+ {
+ cleanUp(sal_True);
+ exit(1);
+ }
+ }
+ catch( IllegalArgument& e)
+ {
+ fprintf(stderr, "Illegal option: %s\n", e.m_message.getStr());
+ cleanUp(sal_True);
+ exit(99);
+ }
+
+ TypeDependency typeDependencies;
+
+ OString bootReg;
+
+ if ( options.isValid("-R") )
+ {
+ bootReg = options.getOption("-R");
+ } else
+ {
+ if (options.getInputFiles().empty())
+ {
+ bootReg = getFullNameOfApplicatRdb();
+ }
+ }
+
+ if ( bootReg.getLength() )
+ {
+ pTypeMgr = new SpecialTypeManager();
+ useSpecial = sal_True;
+ } else
+ {
+ pTypeMgr = new RegistryTypeManager();
+ useSpecial = sal_False;
+ }
+
+ TypeManager& typeMgr = *pTypeMgr;
+
+ if ( useSpecial && !typeMgr.init( bootReg ) )
+ {
+ fprintf(stderr, "%s : init typemanager failed, check your environment for bootstrapping uno.\n", options.getProgramName().getStr());
+ cleanUp(sal_True);
+ exit(99);
+ }
+ if ( !useSpecial && !typeMgr.init(!options.isValid("-T"), options.getInputFiles()))
+ {
+ fprintf(stderr, "%s : init registries failed, check your registry files.\n", options.getProgramName().getStr());
+ cleanUp(sal_True);
+ exit(99);
+ }
+
+ initFilterTypes(&options);
+
+ if (options.isValid("-B"))
+ {
+ typeMgr.setBase(options.getOption("-B"));
+ }
+
+ if ( !options.isValid("-O") )
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ options.getProgramName().getStr(),
+ "no output file is specified.");
+ cleanUp(sal_True);
+ exit(99);
+ }
+
+ if ( options.generateTypeList() )
+ {
+ OString fileName = createFileName( options.getOption("-O") );
+ listFile.openFile(fileName);
+
+ if ( !listFile.isValid() )
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ options.getProgramName().getStr(),
+ "could not open output file.");
+ cleanUp(sal_True);
+ exit(99);
+ }
+ } else
+ {
+ OUString fileName( OStringToOUString(createFileName( options.getOption("-O") ), RTL_TEXTENCODING_UTF8) );
+ if ( regFile.create(fileName) )
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ options.getProgramName().getStr(),
+ "could not create registry output file.");
+ cleanUp(sal_True);
+ exit(99);
+ }
+
+
+ if (options.isValid("-b"))
+ {
+ RegistryKey tmpKey;
+ regFile.openRootKey(tmpKey);
+
+ tmpKey.createKey( OStringToOUString(options.getOption("-b"), RTL_TEXTENCODING_UTF8), rootKey);
+ } else
+ {
+ regFile.openRootKey(rootKey);
+ }
+ }
+
+ 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 == "*")
+ {
+ if (bootReg.getLength())
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ options.getProgramName().getStr(),
+ "dumping all types of a scope is not possible if -R option is used.");
+ exit(99);
+ }
+ // 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,
+ listFile, rootKey, filterTypes);
+ } else
+ {
+ // produce only this type
+ ret = produceType(typeName.replace('.', '/'), typeMgr, typeDependencies,
+ &options, listFile, rootKey, filterTypes);
+ }
+/*
+ // produce only this type
+ ret = produceType(typeName.replace('.', '/'), typeMgr, typeDependencies,
+ &options, listFile, rootKey, filterTypes);
+*/
+ if (!ret)
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ options.getProgramName().getStr(),
+ OString("cannot dump Type '" + typeName + "'").getStr());
+ cleanUp(sal_True);
+ exit(99);
+ }
+ }
+ } else
+ if (options.isValid("-X"))
+ {
+ } else
+ {
+ if (!bootReg.getLength())
+ {
+ // produce all types
+ if (!produceAllTypes("/", typeMgr, typeDependencies, &options, sal_True,
+ listFile, rootKey, filterTypes))
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ options.getProgramName().getStr(),
+ "an error occurs while dumping all types.");
+ exit(99);
+ }
+ } else
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ options.getProgramName().getStr(),
+ "dumping all types is not possible if -R option is used.");
+ exit(99);
+ }
+ }
+ }
+ catch( CannotDumpException& e)
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ options.getProgramName().getStr(),
+ e.m_message.getStr());
+ cleanUp(sal_True);
+ exit(99);
+ }
+
+ cleanUp(sal_False);
+ return 0;
+}
+
+
diff --git a/rdbmaker/source/rdbmaker/rdboptions.cxx b/rdbmaker/source/rdbmaker/rdboptions.cxx
new file mode 100644
index 000000000000..9e0e90c6d983
--- /dev/null
+++ b/rdbmaker/source/rdbmaker/rdboptions.cxx
@@ -0,0 +1,406 @@
+/*************************************************************************
+ *
+ * $RCSfile: rdboptions.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+ *
+ * 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 "rdboptions.hxx"
+
+using namespace rtl;
+
+sal_Bool RdbOptions::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 'X':
+ if (av[i][2] == '\0')
+ {
+ if (i < ac - 1 && av[i+1][0] != '-')
+ {
+ i++;
+ s = av[i];
+ } else
+ {
+ OString tmp("'-X', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i+1]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+ } else
+ {
+ s = av[i] + 2;
+ }
+
+ m_options["-X"] = OString(s);
+ break;
+ case 'R':
+ if (av[i][2] == '\0')
+ {
+ if (i < ac - 1 && av[i+1][0] != '-')
+ {
+ i++;
+ s = av[i];
+ } else
+ {
+ OString tmp("'-R', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i+1]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+ } else
+ {
+ s = av[i] + 2;
+ }
+
+ m_options["-R"] = 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 '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 'F':
+ if (av[i][2] == 'T')
+ {
+ if (av[i][3] == '\0')
+ {
+ if (i < ac - 1 && av[i+1][0] != '-')
+ {
+ i++;
+ s = av[i];
+ } else
+ {
+ OString tmp("'-FT', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i+1]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+ } else
+ {
+ s = av[i] + 3;
+ }
+
+ if (m_options.count("-FT") > 0)
+ {
+ OString tmp(m_options["-FT"]);
+ tmp = tmp + ";" + s;
+ m_options["-FT"] = tmp;
+ } else
+ {
+ m_options["-FT"] = OString(s);
+ }
+ } else
+ {
+ if (av[i][2] == '\0')
+ {
+ if (i < ac - 1 && av[i+1][0] != '-')
+ {
+ i++;
+ s = av[i];
+ } else
+ {
+ OString tmp("'-F', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i+1]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+ } else
+ {
+ s = av[i] + 2;
+ }
+
+ m_options["-F"] = OString(s);
+ }
+ break;
+ case 'L':
+ if (av[i][2] != '\0')
+ {
+ OString tmp("'-L', please check");
+ if (i <= ac - 1)
+ {
+ tmp += " your input '" + OString(av[i+1]) + "'";
+ }
+
+ throw IllegalArgument(tmp);
+ }
+
+ m_options["-L"] = OString();
+ m_generateTypeList = sal_True;
+ 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 RdbOptions::prepareHelp()
+{
+ OString help("\nusing: ");
+ help += m_program + " [-options] [file_1 ... file_n]\nOptions:\n";
+ help += " [-R<regname>]= registry name specifies the registry used for bootstrapping\n"
+ " uno. If no registry is specified, the program use the\n"
+ " applicat.rdb finding near the executable.\n";
+ help += " -O<filename> = filename specifies the name of the generated registry\n";
+ help += " or text file.\n";
+ help += " -L = specifies that only a text file is generated with the\n";
+ help += " names of the specified types and their dependencies.\n";
+ help += " Default is that a registry file will be created\n";
+// help += " -X<xmlfile> = xmlfile specifies the name of an xml description where\n";
+// help += " all types are specified which will be generated.\n";
+ help += " -T<name> = name specifies a type or a list of types. The output for\n";
+ help += " [t1;...] this type is generated.\n";
+ help += " Example: 'com.sun.star.uno.XInterface' is a valid type.\n";
+ help += " -FT<name> = name specifies a type or a list of types. For this types\n";
+ help += " [t1;...] nothing will be generated.\n";
+ help += " |F<file> = file specifies an text file. For the specified types in\n" ;
+ help += " this file nothing will be generated.\n";
+ help += " -B<name> = name specifies the base node. All types are searched under\n";
+ help += " this node. Default is the root '/' of the registry files.\n";
+ help += " -b<name> = name specifies the base node of the output registry. All\n";
+ help += " types will be generated under this node. Default is the\n";
+ help += " root '/' of the registry file.\n";
+ help += prepareVersion();
+
+ return help;
+}
+
+OString RdbOptions::prepareVersion()
+{
+ OString version("\nSun Microsystems (R) ");
+ version += m_program + " Version 2.0\n\n";
+
+ return version;
+}
+
+
diff --git a/rdbmaker/source/rdbmaker/rdboptions.hxx b/rdbmaker/source/rdbmaker/rdboptions.hxx
new file mode 100644
index 000000000000..7399cea84bb9
--- /dev/null
+++ b/rdbmaker/source/rdbmaker/rdboptions.hxx
@@ -0,0 +1,91 @@
+/*************************************************************************
+ *
+ * $RCSfile: rdboptions.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+ *
+ * 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 _RDBMAKER_RDBOPTIONS_HXX_
+#define _RDBMAKER_RDBOPTIONS_HXX_
+
+#include <codemaker/options.hxx>
+
+class RdbOptions : public Options
+{
+public:
+ RdbOptions()
+ : Options()
+ , m_generateTypeList(sal_False)
+ {}
+
+ ~RdbOptions() {}
+
+ sal_Bool initOptions(int ac, char* av[], sal_Bool bCmdFile=sal_False)
+ throw( IllegalArgument );
+
+ ::rtl::OString prepareHelp();
+
+ ::rtl::OString prepareVersion();
+
+ sal_Bool generateTypeList()
+ { return m_generateTypeList; }
+
+protected:
+ sal_Bool m_generateTypeList;
+};
+
+#endif // _RDBMAKER_RDBOPTIONS_HXX_
diff --git a/rdbmaker/source/rdbmaker/rdbtype.cxx b/rdbmaker/source/rdbmaker/rdbtype.cxx
new file mode 100644
index 000000000000..aebaa1546542
--- /dev/null
+++ b/rdbmaker/source/rdbmaker/rdbtype.cxx
@@ -0,0 +1,235 @@
+/*************************************************************************
+ *
+ * $RCSfile: rdbtype.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+ *
+ * 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 "rdbtype.hxx"
+#include "rdboptions.hxx"
+
+using namespace rtl;
+
+sal_Bool isBaseType(const OString& type)
+{
+ if ( type.equals("long") ||
+ type.equals("short") ||
+ type.equals("hyper") ||
+ type.equals("string") ||
+ type.equals("boolean") ||
+ type.equals("char") ||
+ type.equals("byte") ||
+ type.equals("any") ||
+ type.equals("type") ||
+ type.equals("float") ||
+ type.equals("double") ||
+ type.equals("octet") ||
+ type.equals("void") ||
+ type.equals("unsigned long") ||
+ type.equals("unsigned short") ||
+ type.equals("unsigned hyper") )
+ return sal_True;
+
+ return sal_False;
+}
+
+sal_Bool produceDependedTypes(const OString& typeName,
+ TypeManager& typeMgr,
+ TypeDependency& typeDependencies,
+ RdbOptions* pOptions,
+ FileStream& o,
+ RegistryKey& regKey,
+ StringSet& filterTypes)
+ throw( CannotDumpException )
+{
+ sal_Bool ret = sal_True;
+
+ TypeUsingSet usingSet(typeDependencies.getDependencies(typeName));
+
+ TypeUsingSet::const_iterator iter = usingSet.begin();
+ OString sTypeName;
+ sal_Int32 index = 0;
+ while (iter != usingSet.end())
+ {
+ sTypeName = (*iter).m_type;
+ if ((index = sTypeName.lastIndexOf(']')) > 0)
+ sTypeName = sTypeName.copy(index + 1);
+
+ if ( !isBaseType(sTypeName) )
+ {
+ if (!produceType(sTypeName,
+ typeMgr,
+ typeDependencies,
+ pOptions,
+ o, regKey,
+ filterTypes))
+ {
+ fprintf(stderr, "%s ERROR: %s\n",
+ pOptions->getProgramName().getStr(),
+ OString("cannot dump Type '" + sTypeName + "'").getStr());
+ cleanUp(sal_True);
+ exit(99);
+ }
+ }
+ iter++;
+ }
+
+ return ret;
+}
+
+//*************************************************************************
+// produceType
+//*************************************************************************
+sal_Bool produceType(const OString& typeName,
+ TypeManager& typeMgr,
+ TypeDependency& typeDependencies,
+ RdbOptions* pOptions,
+ FileStream& o,
+ RegistryKey& regKey,
+ StringSet& filterTypes)
+ 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;
+
+ if ( !checkFilterTypes(typeName) )
+ {
+ if ( pOptions->generateTypeList() )
+ {
+ o << typeName.getStr() << endl;
+ } else
+ {
+/*
+ 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;
+ }
+*/
+ TypeReader reader = typeMgr.getTypeReader(typeName);
+
+ if (!reader.isValid())
+ {
+ if (typeName.equals("/"))
+ {
+ return sal_True;
+ } else
+ {
+ return sal_False;
+ }
+ }
+ RegistryKey typeKey;
+ if ( regKey.createKey( OStringToOUString(typeName, RTL_TEXTENCODING_UTF8), typeKey) )
+ {
+// rtl_freeMemory(pBuffer);
+ return sal_False;
+ }
+
+ if ( typeKey.setValue(OUString(), RG_VALUETYPE_BINARY, (void*)reader.getBlop(), reader.getBlopSize()) )
+// if ( typeKey.setValue(OUString(), valueType, pBuffer, valueSize) )
+ {
+// rtl_freeMemory(pBuffer);
+ return sal_False;
+ }
+
+// rtl_freeMemory(pBuffer);
+ }
+ }
+
+ typeDependencies.setGenerated(typeName);
+ sal_Bool ret = produceDependedTypes(typeName, typeMgr, typeDependencies,
+ pOptions, o, regKey, filterTypes);
+
+ return ret;
+}
+
+
+
diff --git a/rdbmaker/source/rdbmaker/rdbtype.hxx b/rdbmaker/source/rdbmaker/rdbtype.hxx
new file mode 100644
index 000000000000..54f957a96108
--- /dev/null
+++ b/rdbmaker/source/rdbmaker/rdbtype.hxx
@@ -0,0 +1,90 @@
+/*************************************************************************
+ *
+ * $RCSfile: rdbtype.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+ *
+ * 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 _RDBMAKER_RDBTYPE_HXX_
+#define _RDBMAKER_RDBTYPE_HXX_
+
+#ifndef _CODEMAKER_TYPEMANAGER_HXX_
+#include <codemaker/typemanager.hxx>
+#endif
+
+#ifndef _CODEMAKER_DEPENDENCY_HXX_
+#include <codemaker/dependency.hxx>
+#endif
+
+sal_Bool checkFilterTypes(const ::rtl::OString& type);
+void cleanUp(sal_Bool);
+
+class RdbOptions;
+class FileStream;
+class RegistryKey;
+
+sal_Bool produceType(const ::rtl::OString& typeName,
+ TypeManager& typeMgr,
+ TypeDependency& typeDependencies,
+ RdbOptions* pOptions,
+ FileStream& o,
+ RegistryKey& regKey,
+ StringSet& filterTypes)
+ throw( CannotDumpException );
+
+#endif // _RDBMAKER_RDBTYPE_HXX_
+
diff --git a/rdbmaker/source/rdbmaker/specialtypemanager.cxx b/rdbmaker/source/rdbmaker/specialtypemanager.cxx
new file mode 100644
index 000000000000..11c49419cd69
--- /dev/null
+++ b/rdbmaker/source/rdbmaker/specialtypemanager.cxx
@@ -0,0 +1,139 @@
+/*************************************************************************
+ *
+ * $RCSfile: specialtypemanager.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+ *
+ * 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
+
+#include "specialtypemanager.hxx"
+
+extern "C"
+{
+sal_Bool SAL_CALL initTypeMapper( const sal_Char* pRegName );
+sal_uInt32 SAL_CALL getTypeBlop(const sal_Char* pTypeName, sal_uInt8** pBlop);
+}
+
+using namespace rtl;
+
+SpecialTypeManager::SpecialTypeManager()
+{
+ m_pImpl = new SpecialTypeManagerImpl();
+ acquire();
+}
+
+SpecialTypeManager::~SpecialTypeManager()
+{
+ release();
+}
+
+void SpecialTypeManager::acquire()
+{
+ TypeManager::acquire();
+}
+
+void SpecialTypeManager::release()
+{
+ if (0 == TypeManager::release())
+ {
+ delete m_pImpl;
+ }
+}
+
+sal_Bool SpecialTypeManager::init(const OString& registryName)
+{
+ return initTypeMapper( registryName.getStr() );
+}
+
+TypeReader SpecialTypeManager::getTypeReader(const OString& name)
+{
+ TypeReader reader;
+
+ sal_uInt8* pBlop = NULL;
+ sal_uInt32 blopSize = 0;
+
+ if ( (blopSize = getTypeBlop( name.getStr(), &pBlop)) > 0 )
+ {
+ RegistryTypeReaderLoader & rReaderLoader = getRegistryTypeReaderLoader();
+
+ reader = TypeReader(rReaderLoader, pBlop, blopSize, sal_True);
+ }
+
+ if ( pBlop )
+ {
+ rtl_freeMemory(pBlop);
+ }
+
+ return reader;
+}
+
+RTTypeClass SpecialTypeManager::getTypeClass(const OString& name)
+{
+ if (m_pImpl->m_t2TypeClass.count(name) > 0)
+ {
+ return m_pImpl->m_t2TypeClass[name];
+ } else
+ {
+ }
+
+ return RT_TYPE_INVALID;
+}
+
+
diff --git a/rdbmaker/source/rdbmaker/specialtypemanager.hxx b/rdbmaker/source/rdbmaker/specialtypemanager.hxx
new file mode 100644
index 000000000000..567c8dabf464
--- /dev/null
+++ b/rdbmaker/source/rdbmaker/specialtypemanager.hxx
@@ -0,0 +1,111 @@
+/*************************************************************************
+ *
+ * $RCSfile: specialtypemanager.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+ *
+ * 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 _SPECIALTYPEMANAGER_HXX_
+#define _SPECIALTYPEMANAGER_HXX_
+
+#ifndef _CODEMAKER_REGISTRY_HXX_
+#include <codemaker/registry.hxx>
+#endif
+
+#ifndef _CODEMAKER_TYPEMANAGER_HXX_
+#include <codemaker/typemanager.hxx>
+#endif
+
+
+struct SpecialTypeManagerImpl
+{
+ T2TypeClassMap m_t2TypeClass;
+};
+
+class SpecialTypeManager : public TypeManager
+{
+public:
+ SpecialTypeManager();
+ ~SpecialTypeManager();
+
+ SpecialTypeManager( const SpecialTypeManager& value )
+ : TypeManager(value)
+ , m_pImpl( value.m_pImpl )
+ {
+ acquire();
+ }
+
+ sal_Bool init(const ::rtl::OString& registryName);
+
+ sal_Bool isValidType(const ::rtl::OString& name)
+ { return sal_True; }
+ TypeReader getTypeReader(const ::rtl::OString& name);
+ RTTypeClass getTypeClass(const ::rtl::OString& name);
+
+ sal_Int32 getSize() { return m_pImpl->m_t2TypeClass.size(); }
+
+protected:
+ void acquire();
+ void release();
+
+protected:
+ SpecialTypeManagerImpl* m_pImpl;
+};
+
+#endif // _CODEMAKER_TYPEMANAGER_HXX_
diff --git a/rdbmaker/source/rdbmaker/typeblop.cxx b/rdbmaker/source/rdbmaker/typeblop.cxx
new file mode 100644
index 000000000000..2cc82d397c4f
--- /dev/null
+++ b/rdbmaker/source/rdbmaker/typeblop.cxx
@@ -0,0 +1,517 @@
+/*************************************************************************
+ *
+ * $RCSfile: typeblop.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 15:29:08 $
+ *
+ * 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 __REGISTRY_REFLWRIT_HXX__
+#include <registry/reflwrit.hxx>
+#endif
+
+#ifndef _CPPUHELPER_SERVICEFACTORY_HXX_
+#include <cppuhelper/servicefactory.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAMEACCESS_HPP_
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_REFLECTION_XINTERFACETYPEDESCRIPTION_HPP_
+#include <com/sun/star/reflection/XInterfaceTypeDescription.hpp>
+#endif
+#ifndef _COM_SUN_STAR_REFLECTION_XINTERFACEMETHODTYPEDESCRIPTION_HPP_
+#include <com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp>
+#endif
+#ifndef _COM_SUN_STAR_REFLECTION_XINTERFACEATTRIBUTETYPEDESCRIPTION_HPP_
+#include <com/sun/star/reflection/XInterfaceAttributeTypeDescription.hpp>
+#endif
+#ifndef _COM_SUN_STAR_REFLECTION_XMETHODPARAMETER_HPP_
+#include <com/sun/star/reflection/XMethodParameter.hpp>
+#endif
+#ifndef _COM_SUN_STAR_REFLECTION_XCOMPOUNDTYPEDESCRIPTION_HPP_
+#include <com/sun/star/reflection/XCompoundTypeDescription.hpp>
+#endif
+#ifndef _COM_SUN_STAR_REFLECTION_XINDIRECTTYPEDESCRIPTION_HPP_
+#include <com/sun/star/reflection/XIndirectTypeDescription.hpp>
+#endif
+#ifndef _COM_SUN_STAR_REFLECTION_XENUMTYPEDESCRIPTION_HPP_
+#include <com/sun/star/reflection/XEnumTypeDescription.hpp>
+#endif
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::reflection;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::container;
+using namespace cppu;
+//using namespace osl;
+using namespace rtl;
+
+static Reference< XHierarchicalNameAccess > xNameAccess;
+
+sal_uInt32 writeConstantData( const RegistryTypeWriterLoader& rLoader,
+ const OUString& typeName,
+ const Any& aTypeAny,
+ sal_uInt8** pBlop )
+{
+ sal_uInt32 lastIndex = typeName.lastIndexOf('.');
+ OUString uModuleName( typeName.copy(0, lastIndex) );
+ OUString uConstName( typeName.copy(lastIndex + 1) );
+
+ RegistryTypeWriter writer(rLoader, RT_TYPE_MODULE, uModuleName.replace('.', '/'),
+ OUString(), 1, 0, 0);
+
+ RTConstValue constValue;
+ OUString uConstTypeName;
+ switch ( aTypeAny.getValueTypeClass() )
+ {
+ case TypeClass_BOOLEAN:
+ {
+ uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("boolean") );
+ constValue.m_type = RT_TYPE_BOOL;
+ aTypeAny >>= constValue.m_value.aBool;
+ }
+ break;
+ case TypeClass_BYTE:
+ {
+ uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("byte") );
+ constValue.m_type = RT_TYPE_BYTE;
+ aTypeAny >>= constValue.m_value.aByte;
+ }
+ break;
+ case TypeClass_SHORT:
+ {
+ uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("short") );
+ constValue.m_type = RT_TYPE_INT16;
+ aTypeAny >>= constValue.m_value.aShort;
+ }
+ break;
+ case TypeClass_UNSIGNED_SHORT:
+ {
+ uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("unsigned short") );
+ constValue.m_type = RT_TYPE_UINT16;
+ aTypeAny >>= constValue.m_value.aUShort;
+ }
+ break;
+ case TypeClass_LONG:
+ {
+ uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("long") );
+ constValue.m_type = RT_TYPE_INT32;
+ aTypeAny >>= constValue.m_value.aLong;
+ }
+ break;
+ case TypeClass_UNSIGNED_LONG:
+ {
+ uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("unsigned long") );
+ constValue.m_type = RT_TYPE_UINT32;
+ aTypeAny >>= constValue.m_value.aULong;
+ }
+ break;
+ case TypeClass_FLOAT:
+ {
+ uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("float") );
+ constValue.m_type = RT_TYPE_FLOAT;
+ aTypeAny >>= constValue.m_value.aFloat;
+ }
+ break;
+ case TypeClass_DOUBLE:
+ {
+ uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("double") );
+ constValue.m_type = RT_TYPE_DOUBLE;
+ aTypeAny >>= constValue.m_value.aDouble;
+ }
+ break;
+ case TypeClass_STRING:
+ {
+ uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("string") );
+ constValue.m_type = RT_TYPE_STRING;
+ constValue.m_value.aString = ((OUString*)aTypeAny.getValue())->getStr();
+ }
+ break;
+ }
+
+ writer.setFieldData(1, uConstName, uConstTypeName, OUString(),
+ OUString(), RT_ACCESS_CONST, constValue);
+
+ sal_uInt32 length = writer.getBlopSize();
+ *pBlop = (sal_uInt8*)rtl_allocateMemory( length );
+ rtl_copyMemory(*pBlop, writer.getBlop(), length);
+
+ return length;
+}
+
+sal_uInt32 getInheritedMemberCount( Reference< XTypeDescription >& xType )
+{
+ sal_uInt32 memberCount = 0;
+ if ( xType->getTypeClass() == TypeClass_INTERFACE )
+ {
+ Reference< XInterfaceTypeDescription > xIFace(xType, UNO_QUERY);
+
+ if ( !xIFace.is() )
+ return memberCount;
+
+ Reference< XTypeDescription > xSuperType = xIFace->getBaseType();
+
+ if ( xSuperType.is() )
+ memberCount = getInheritedMemberCount( xSuperType );
+
+ memberCount += xIFace->getMembers().getLength();
+ }
+// } else
+// if ( xType->getTypeClass() == TypeClass_Struct || xType->getTypeClass() == TypeClass_Exception )
+// {
+// Reference< XCompoundTypeDescription > xComp(xType, UNO_QUERY);
+//
+// if ( xComp.is() )
+// return membercount;
+//
+// Reference< XTypeDescription > xSuperType = xComp->getBaseType();
+//
+// if ( xSuperType.is() )
+// memberCount = getInheritedMemberCount( xSuperType );
+//
+// memberCount += xComp->getMemberNames().getLength();
+// }
+
+ return memberCount;
+}
+
+void writeMethodData( RegistryTypeWriter& rWriter, sal_uInt32 inheritedMmeberCount,
+ const Reference< XInterfaceMemberTypeDescription >& xMember,
+ const Reference< XInterfaceMethodTypeDescription >& xMethod )
+{
+ RTMethodMode methodMode = RT_MODE_TWOWAY;
+ if ( xMethod->isOneway() )
+ {
+ methodMode = RT_MODE_ONEWAY;
+ }
+
+ Sequence< Reference< XMethodParameter > > parameters( xMethod->getParameters() );
+ Sequence< Reference< XTypeDescription > > exceptions( xMethod->getExceptions() );
+ sal_uInt32 methodIndex = xMember->getPosition() - inheritedMmeberCount;
+ sal_uInt32 paramCount = parameters.getLength();
+ sal_uInt32 exceptionCount = exceptions.getLength();
+
+ rWriter.setMethodData(methodIndex, xMember->getMemberName(),
+ xMethod->getReturnType()->getName().replace('.', '/'),
+ methodMode, paramCount, exceptionCount, OUString());
+
+ RTParamMode paramMode = RT_PARAM_IN;
+ for (sal_Int32 i=0; i < paramCount; i++)
+ {
+ Reference< XMethodParameter > xParam = parameters[i];
+ if ( xParam->isIn() && xParam->isOut())
+ {
+ paramMode = RT_PARAM_INOUT;
+ } else
+ if ( xParam->isIn() )
+ {
+ paramMode = RT_PARAM_IN;
+ } else
+ if ( xParam->isOut() )
+ {
+ paramMode = RT_PARAM_OUT;
+ }
+
+ rWriter.setParamData(methodIndex, xParam->getPosition(), xParam->getType()->getName().replace('.', '/'),
+ xParam->getName(), paramMode);
+ }
+
+ for (i=0; i < exceptionCount; i++)
+ {
+ rWriter.setExcData(methodIndex, i, exceptions[i]->getName().replace('.', '/'));
+ }
+}
+
+extern "C"
+{
+
+sal_Bool SAL_CALL initTypeMapper( const sal_Char* pRegName )
+{
+ try
+ {
+ if (!pRegName)
+ return sal_False;
+
+ Reference< XMultiServiceFactory > xSMgr( createRegistryServiceFactory( OUString::createFromAscii(pRegName) ) );
+
+ if ( !xSMgr.is() )
+ return sal_False;
+
+ Reference< XInterface > xIFace( xSMgr->createInstance(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.reflection.TypeDescriptionManager"))) );
+
+ if ( !xIFace.is() )
+ return sal_False;
+
+ Reference< XHierarchicalNameAccess > xNAccess(xIFace, UNO_QUERY);
+
+ if ( !xNAccess.is() )
+ return sal_False;
+
+ xNameAccess = xNAccess;
+ }
+ catch( Exception& )
+ {
+ return sal_False;
+ }
+
+ return sal_True;
+}
+
+sal_uInt32 SAL_CALL getTypeBlop(const sal_Char* pTypeName, sal_uInt8** pBlop)
+{
+ sal_uInt32 length = 0;
+
+ if ( !pTypeName )
+ return length;
+
+ OUString uTypeName( OUString::createFromAscii(pTypeName).replace('/', '.') );
+ try
+ {
+ Any aTypeAny( xNameAccess->getByHierarchicalName( uTypeName ) );
+
+ if ( !aTypeAny.hasValue() )
+ return length;
+
+ RegistryTypeWriterLoader rtwLoader;
+ if ( !rtwLoader.isLoaded() )
+ return length;
+
+ if ( aTypeAny.getValueTypeClass() != TypeClass_INTERFACE )
+ {
+ return writeConstantData( rtwLoader, uTypeName, aTypeAny, pBlop );
+ }
+
+ Reference< XTypeDescription > xType;
+ aTypeAny >>= xType;
+
+ if ( !xType.is() )
+ return length;
+
+ switch (xType->getTypeClass())
+ {
+ case TypeClass_INTERFACE:
+ {
+ Reference< XInterfaceTypeDescription > xIFace(xType, UNO_QUERY);
+
+ if ( !xIFace.is() )
+ return length;
+
+ Reference< XInterfaceAttributeTypeDescription > xAttr;
+ Reference< XInterfaceMethodTypeDescription > xMethod;
+ Sequence< Reference< XInterfaceMemberTypeDescription > > memberTypes( xIFace->getMembers());
+ sal_uInt32 memberCount = memberTypes.getLength();
+ sal_uInt32 attrCount = 0;
+ sal_uInt32 inheritedMemberCount = 0;
+
+ for (sal_Int32 i=0; i < memberCount; i++)
+ {
+ xAttr = Reference< XInterfaceAttributeTypeDescription >(memberTypes[i], UNO_QUERY);
+ if ( xAttr.is() )
+ {
+ attrCount++;
+ }
+ }
+
+ OUString uSuperType;
+ Reference< XTypeDescription > xSuperType = xIFace->getBaseType();
+ if ( xSuperType.is() )
+ {
+ uSuperType = xSuperType->getName().replace('.','/');
+ inheritedMemberCount = getInheritedMemberCount( xSuperType );
+ }
+
+ RegistryTypeWriter writer(rtwLoader, RT_TYPE_INTERFACE, uTypeName.replace('.', '/'),
+ uSuperType, attrCount, memberCount-attrCount, 0);
+
+ Uik uik = xIFace->getUik();
+ RTUik rtUik = { uik.m_Data1, uik.m_Data2, uik.m_Data3, uik.m_Data4, uik.m_Data5 };
+ writer.setUik( rtUik );
+
+ RTFieldAccess attrAccess = RT_ACCESS_READWRITE;
+ for (i=0; i < memberCount; i++)
+ {
+ xAttr = Reference< XInterfaceAttributeTypeDescription >(memberTypes[i], UNO_QUERY);
+ if ( xAttr.is() )
+ {
+ if (xAttr->isReadOnly())
+ {
+ attrAccess = RT_ACCESS_READONLY;
+ } else
+ {
+ attrAccess = RT_ACCESS_READWRITE;
+ }
+ writer.setFieldData(memberTypes[i]->getPosition() - inheritedMemberCount,
+ memberTypes[i]->getMemberName(),
+ xAttr->getType()->getName().replace('.', '/'),
+ OUString(), OUString(), attrAccess);
+ continue;
+ }
+
+ xMethod = Reference< XInterfaceMethodTypeDescription >(memberTypes[i], UNO_QUERY);
+ if ( xMethod.is() )
+ {
+ writeMethodData( writer, inheritedMemberCount, memberTypes[i], xMethod );
+ }
+ }
+
+ length = writer.getBlopSize();
+ *pBlop = (sal_uInt8*)rtl_allocateMemory( length );
+ rtl_copyMemory(*pBlop, writer.getBlop(), length);
+ }
+ break;
+ case TypeClass_STRUCT:
+ case TypeClass_EXCEPTION:
+ {
+ RTTypeClass rtTypeClass = RT_TYPE_STRUCT;
+ if (xType->getTypeClass() == TypeClass_EXCEPTION)
+ {
+ rtTypeClass = RT_TYPE_EXCEPTION;
+ }
+
+ Reference< XCompoundTypeDescription > xComp(xType, UNO_QUERY);
+
+ if ( !xComp.is() )
+ return length;
+
+ Sequence< OUString > memberNames( xComp->getMemberNames());
+ Sequence< Reference< XTypeDescription > > memberTypes( xComp->getMemberTypes());
+ sal_uInt32 memberCount = memberNames.getLength();
+
+ OUString uSuperType;
+ Reference< XTypeDescription > xSuperType = xComp->getBaseType();
+ if ( xSuperType.is() )
+ {
+ uSuperType = xSuperType->getName().replace('.','/');
+ }
+
+ RegistryTypeWriter writer(rtwLoader, rtTypeClass, uTypeName.replace('.', '/'),
+ uSuperType, memberCount, 0, 0);
+
+ for (sal_Int32 i=0; i < memberCount; i++)
+ {
+ writer.setFieldData(i , memberNames[i], memberTypes[i]->getName().replace('.', '/'),
+ OUString(), OUString(), RT_ACCESS_READWRITE);
+ }
+
+ length = writer.getBlopSize();
+ *pBlop = (sal_uInt8*)rtl_allocateMemory( length );
+ rtl_copyMemory(*pBlop, writer.getBlop(), length);
+ }
+ break;
+ case TypeClass_ENUM:
+ {
+ Reference< XEnumTypeDescription > xEnum(xType, UNO_QUERY);
+
+ if ( !xEnum.is() )
+ return length;
+
+ Sequence< OUString > enumNames( xEnum->getEnumNames());
+ Sequence< sal_Int32 > enumValues( xEnum->getEnumValues());
+ sal_uInt32 enumCount = enumNames.getLength();
+
+ RegistryTypeWriter writer(rtwLoader, RT_TYPE_ENUM, uTypeName.replace('.', '/'),
+ OUString(), enumCount, 0, 0);
+
+ RTConstValue constValue;
+ for (sal_Int32 i=0; i < enumCount; i++)
+ {
+ constValue.m_type = RT_TYPE_INT32;
+ constValue.m_value.aLong = enumValues[i];
+
+ writer.setFieldData(i, enumNames[i], OUString(), OUString(), OUString(),
+ RT_ACCESS_CONST, constValue);
+ }
+
+ length = writer.getBlopSize();
+ *pBlop = (sal_uInt8*)rtl_allocateMemory( length );
+ rtl_copyMemory(*pBlop, writer.getBlop(), length);
+ }
+ break;
+ case TypeClass_TYPEDEF:
+ {
+ Reference< XIndirectTypeDescription > xTD(xType, UNO_QUERY);
+
+ if ( !xTD.is() )
+ return length;
+
+ RegistryTypeWriter writer(rtwLoader, RT_TYPE_TYPEDEF, uTypeName.replace('.', '/'),
+ xTD->getReferencedType()->getName().replace('.', '/'),
+ 0, 0, 0);
+ length = writer.getBlopSize();
+ *pBlop = (sal_uInt8*)rtl_allocateMemory( length );
+ rtl_copyMemory(*pBlop, writer.getBlop(), length);
+ }
+ break;
+ }
+
+ }
+ catch( Exception& )
+ {
+ }
+
+ return length;
+}
+
+} // extern "C"
+
+
+