summaryrefslogtreecommitdiff
path: root/rdbmaker
diff options
context:
space:
mode:
Diffstat (limited to 'rdbmaker')
-rw-r--r--rdbmaker/inc/codemaker/dependency.hxx170
-rw-r--r--rdbmaker/inc/codemaker/global.hxx138
-rw-r--r--rdbmaker/inc/codemaker/options.hxx98
-rw-r--r--rdbmaker/inc/codemaker/registry.hxx208
-rw-r--r--rdbmaker/inc/codemaker/typemanager.hxx172
-rw-r--r--rdbmaker/prj/build.lst6
-rw-r--r--rdbmaker/prj/d.lst4
-rw-r--r--rdbmaker/source/codemaker/dependency.cxx301
-rw-r--r--rdbmaker/source/codemaker/global.cxx171
-rw-r--r--rdbmaker/source/codemaker/makefile.mk55
-rw-r--r--rdbmaker/source/codemaker/options.cxx67
-rw-r--r--rdbmaker/source/codemaker/typemanager.cxx273
-rw-r--r--rdbmaker/source/rdbmaker/makefile.mk63
-rw-r--r--rdbmaker/source/rdbmaker/rdbmaker.cxx508
-rw-r--r--rdbmaker/source/rdbmaker/rdboptions.cxx381
-rw-r--r--rdbmaker/source/rdbmaker/rdboptions.hxx57
-rw-r--r--rdbmaker/source/rdbmaker/rdbtype.cxx195
-rw-r--r--rdbmaker/source/rdbmaker/rdbtype.hxx52
-rw-r--r--rdbmaker/source/rdbmaker/specialtypemanager.cxx101
-rw-r--r--rdbmaker/source/rdbmaker/specialtypemanager.hxx71
-rw-r--r--rdbmaker/source/rdbmaker/typeblop.cxx535
21 files changed, 3626 insertions, 0 deletions
diff --git a/rdbmaker/inc/codemaker/dependency.hxx b/rdbmaker/inc/codemaker/dependency.hxx
new file mode 100644
index 000000000000..138aad46999b
--- /dev/null
+++ b/rdbmaker/inc/codemaker/dependency.hxx
@@ -0,0 +1,170 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CODEMAKER_DEPENDENCY_HXX_
+#define _CODEMAKER_DEPENDENCY_HXX_
+
+#include <hash_map>
+#include <registry/registry.hxx>
+#ifndef __REGISTRY_REFLREAD_HXX__
+#include <registry/reflread.hxx>
+#endif
+#include <codemaker/typemanager.hxx>
+#include <codemaker/global.hxx>
+#include <osl/diagnose.h>
+
+#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
+#define TYPEUSE_SCOPE 0x0100
+
+/**
+ * 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 ::std::set< TypeUsing, LessTypeUsing > TypeUsingSet;
+
+
+#if (defined( _MSC_VER ) && ( _MSC_VER < 1200 ))
+typedef ::std::__hash_map__
+<
+ ::rtl::OString,
+ TypeUsingSet,
+ HashString,
+ EqualString,
+ NewAlloc
+> DependencyMap;
+
+typedef ::std::__hash_map__
+<
+ ::rtl::OString,
+ sal_uInt16,
+ HashString,
+ EqualString,
+ NewAlloc
+> GenerationMap;
+#else
+typedef ::std::hash_map
+<
+ ::rtl::OString,
+ TypeUsingSet,
+ HashString,
+ EqualString
+> DependencyMap;
+
+typedef ::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 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, sal_Bool bDepend = sal_False);
+
+#endif // _CODEMAKER_DEPENDENCY_HXX_
diff --git a/rdbmaker/inc/codemaker/global.hxx b/rdbmaker/inc/codemaker/global.hxx
new file mode 100644
index 000000000000..dc12fd833811
--- /dev/null
+++ b/rdbmaker/inc/codemaker/global.hxx
@@ -0,0 +1,138 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CODEMAKER_GLOBAL_HXX_
+#define _CODEMAKER_GLOBAL_HXX_
+
+#include <list>
+#include <vector>
+#include <set>
+
+#include <stdio.h>
+#include <rtl/ustring.hxx>
+#include <rtl/strbuf.hxx>
+
+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 ::std::new_alloc NewAlloc;
+#endif
+
+
+typedef ::std::list< ::rtl::OString > StringList;
+typedef ::std::vector< ::rtl::OString > StringVector;
+typedef ::std::set< ::rtl::OString, LessString > StringSet;
+
+::rtl::OString makeTempName();
+
+const ::rtl::OString inGlobalSet(const ::rtl::OUString & r);
+
+::rtl::OUString convertToFileUrl(const ::rtl::OString& fileName);
+
+//*************************************************************************
+// FileStream
+//*************************************************************************
+enum FileAccessMode
+{
+ FAM_READ, // "r"
+ FAM_WRITE, // "w"
+ FAM_APPEND, // "a"
+ FAM_READWRITE_EXIST, // "r+"
+ FAM_READWRITE, // "w+"
+ FAM_READAPPEND // "a+"
+};
+
+class FileStream //: public ofstream
+{
+public:
+ FileStream();
+ virtual ~FileStream();
+
+ sal_Bool isValid();
+
+ void open(const ::rtl::OString& name, FileAccessMode nMode = FAM_READWRITE);
+ void close();
+
+ ::rtl::OString getName() { return m_name; }
+
+ // friend functions
+ friend FileStream &operator<<(FileStream& o, sal_uInt32 i)
+ { fprintf(o.m_pFile, "%lu", sal::static_int_cast< unsigned long >(i));
+ return o;
+ }
+ friend FileStream &operator<<(FileStream& o, char const * s)
+ { fprintf(o.m_pFile, "%s", s);
+ return o;
+ }
+ friend FileStream &operator<<(FileStream& o, ::rtl::OString* s)
+ { fprintf(o.m_pFile, "%s", s->getStr());
+ return o;
+ }
+ friend FileStream &operator<<(FileStream& o, const ::rtl::OString& s)
+ { fprintf(o.m_pFile, "%s", s.getStr());
+ return o;
+ }
+ friend FileStream &operator<<(FileStream& o, ::rtl::OStringBuffer* s)
+ { fprintf(o.m_pFile, "%s", s->getStr());
+ return o;
+ }
+ friend FileStream &operator<<(FileStream& o, const ::rtl::OStringBuffer& s)
+ { fprintf(o.m_pFile, "%s", s.getStr());
+ return o;
+ }
+
+protected:
+ const sal_Char* checkAccessMode(FileAccessMode mode);
+
+ FILE* m_pFile;
+ ::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..a4e6d53981c9
--- /dev/null
+++ b/rdbmaker/inc/codemaker/options.hxx
@@ -0,0 +1,98 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CODEMAKER_OPTIONS_HXX_
+#define _CODEMAKER_OPTIONS_HXX_
+
+#include <hash_map>
+#include <codemaker/global.hxx>
+
+#if defined( _MSC_VER ) && ( _MSC_VER < 1200 )
+typedef ::std::__hash_map__
+<
+ ::rtl::OString,
+ ::rtl::OString,
+ HashString,
+ EqualString,
+ NewAlloc
+> OptionMap;
+#else
+typedef ::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();
+ virtual ~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_Bool isValid(const ::rtl::OString& option);
+ const ::rtl::OString getOption(const ::rtl::OString& option)
+ 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..09030a77026a
--- /dev/null
+++ b/rdbmaker/inc/codemaker/registry.hxx
@@ -0,0 +1,208 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CODEMAKER_REGISTRY_HXX_
+#define _CODEMAKER_REGISTRY_HXX_
+
+#include <rtl/alloc.h>
+#include <osl/interlck.h>
+#include <registry/registry.hxx>
+#include "registry/reader.hxx"
+#include "registry/version.h"
+#include <codemaker/options.hxx>
+
+struct TypeReader_Impl
+{
+ TypeReader_Impl(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 typereg::Reader(
+ m_pBlop, m_blopSize, false, TYPEREG_VERSION_1);
+ }
+
+ ~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;
+ typereg::Reader* 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 sal_uInt8* buffer,
+ sal_uInt32 bufferLen,
+ sal_Bool copyData)
+ {
+ m_pImpl = new TypeReader_Impl(buffer, bufferLen, copyData);
+ acquire();
+ }
+
+ inline TypeReader(const TypeReader& toCopy)
+ : m_pImpl(toCopy.m_pImpl)
+ {
+ acquire();
+ }
+
+ inline ~TypeReader()
+ {
+ release();
+ }
+
+ 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 RTTypeClass getTypeClass() const
+ { return m_pImpl->m_pReader->getTypeClass(); }
+ inline const ::rtl::OString getTypeName() const
+ { return inGlobalSet( m_pImpl->m_pReader->getTypeName() ); }
+ inline sal_uInt16 getSuperTypeCount() const
+ { return m_pImpl->m_pReader->getSuperTypeCount(); }
+ inline const ::rtl::OString getSuperTypeName(sal_uInt16 index) const
+ { return inGlobalSet( m_pImpl->m_pReader->getSuperTypeName(index) ); }
+ inline const ::rtl::OString getDoku() const
+ { return inGlobalSet( m_pImpl->m_pReader->getDocumentation() ); }
+ 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->getFieldTypeName(index) ); }
+ inline RTFieldAccess getFieldAccess( sal_uInt16 index ) const
+ { return m_pImpl->m_pReader->getFieldFlags(index); }
+ inline RTConstValue getFieldConstValue( sal_uInt16 index ) const
+ { return m_pImpl->m_pReader->getFieldValue(index); }
+ inline const ::rtl::OString getFieldDoku( sal_uInt16 index ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getFieldDocumentation(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->getMethodParameterCount(index); }
+ inline const ::rtl::OString getMethodParamType( sal_uInt16 index, sal_uInt16 paramIndex ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getMethodParameterTypeName(index,paramIndex) ); }
+ inline const ::rtl::OString getMethodParamName( sal_uInt16 index, sal_uInt16 paramIndex ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getMethodParameterName(index,paramIndex) ); }
+ inline RTParamMode getMethodParamMode( sal_uInt16 index, sal_uInt16 paramIndex ) const
+ { return m_pImpl->m_pReader->getMethodParameterFlags(index,paramIndex); }
+ inline sal_uInt32 getMethodExcCount( sal_uInt16 index ) const
+ { return m_pImpl->m_pReader->getMethodExceptionCount(index); }
+ inline const ::rtl::OString getMethodExcType( sal_uInt16 index, sal_uInt16 excIndex ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getMethodExceptionTypeName(index,excIndex) ); }
+ inline const ::rtl::OString getMethodReturnType( sal_uInt16 index ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getMethodReturnTypeName(index) ); }
+ inline RTMethodMode getMethodMode( sal_uInt16 index ) const
+ { return m_pImpl->m_pReader->getMethodFlags(index); }
+ inline const ::rtl::OString getMethodDoku( sal_uInt16 index ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getMethodDocumentation(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->getReferenceTypeName(index) ); }
+ inline RTReferenceType getReferenceType( sal_uInt16 index ) const
+ { return m_pImpl->m_pReader->getReferenceSort(index); }
+ inline const ::rtl::OString getReferenceDoku( sal_uInt16 index ) const
+ { return inGlobalSet( m_pImpl->m_pReader->getReferenceDocumentation(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..a776865e677f
--- /dev/null
+++ b/rdbmaker/inc/codemaker/typemanager.hxx
@@ -0,0 +1,172 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <hash_map>
+
+#ifndef _CODEMAKER_TYPEMANAGER_HXX_
+#define _CODEMAKER_TYPEMANAGER_HXX_
+#include <codemaker/registry.hxx>
+
+typedef ::std::list< Registry* > RegistryList;
+
+#if defined( _MSC_VER ) && ( _MSC_VER < 1200 )
+typedef ::std::__hash_map__
+<
+ ::rtl::OString, // Typename
+ RTTypeClass, // TypeClass
+ HashString,
+ EqualString,
+ NewAlloc
+> T2TypeClassMap;
+#else
+typedef ::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();
+ virtual ~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_base("/")
+ , m_isMerged(sal_False)
+ {}
+
+ T2TypeClassMap m_t2TypeClass;
+ RegistryList m_registries;
+ Registry* m_pMergedRegistry;
+ ::rtl::OString m_base;
+ sal_Bool m_isMerged;
+};
+
+class RegistryTypeManager : public TypeManager
+{
+public:
+ RegistryTypeManager();
+ virtual ~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;
+ }
+*/
+ using TypeManager::init;
+ 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/build.lst b/rdbmaker/prj/build.lst
new file mode 100644
index 000000000000..e10522229b01
--- /dev/null
+++ b/rdbmaker/prj/build.lst
@@ -0,0 +1,6 @@
+rm rdbmaker : cppuhelper NULL
+rm rdbmaker usr1 - all rm_mkout NULL
+rm rdbmaker\inc get - all rm_inc NULL
+rm rdbmaker\prj get - all rm_prj NULL
+rm rdbmaker\source\codemaker nmake - all rm_codemaker NULL
+rm rdbmaker\source\rdbmaker nmake - all rm_rdbmaker rm_codemaker NULL
diff --git a/rdbmaker/prj/d.lst b/rdbmaker/prj/d.lst
new file mode 100644
index 000000000000..4476addfa59e
--- /dev/null
+++ b/rdbmaker/prj/d.lst
@@ -0,0 +1,4 @@
+..\%__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..5305fad0b968
--- /dev/null
+++ b/rdbmaker/source/codemaker/dependency.cxx
@@ -0,0 +1,301 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <osl/interlck.h>
+#include <rtl/alloc.h>
+#include <codemaker/dependency.hxx>
+
+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::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;
+ default:
+ 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, sal_Bool bDepend)
+{
+ 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;
+ }
+
+ if ( bDepend && reader.getTypeClass() == RT_TYPE_MODULE)
+ {
+ checkFieldDependencies(typeMgr, dependencies, reader, type);
+ return sal_True;
+ }
+
+ for (sal_uInt16 i = 0; i < reader.getSuperTypeCount(); ++i) {
+ OString superType(reader.getSuperTypeName(i));
+ 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", bDepend);
+ }
+
+ checkFieldDependencies(typeMgr, dependencies, reader, type);
+ checkMethodDependencies(typeMgr, dependencies, reader, type);
+ checkReferenceDependencies(typeMgr, dependencies, reader, type);
+
+ // make the scope modules as dependencies
+ sal_Int32 nPos = type.lastIndexOf( '/' );
+
+ if ( nPos >= 0 )
+ {
+ OString aScope( type.copy( 0, nPos ) );
+ OStringBuffer tmpBuf(aScope.getLength());
+
+ nPos = 0;
+ do
+ {
+ tmpBuf.append(aScope.getToken(0, '/', nPos));
+ dependencies.insert(type, tmpBuf.getStr(), TYPEUSE_SCOPE);
+ tmpBuf.append('/');
+ } while( nPos != -1 );
+ }
+
+ return sal_True;
+}
+
+
diff --git a/rdbmaker/source/codemaker/global.cxx b/rdbmaker/source/codemaker/global.cxx
new file mode 100644
index 000000000000..2e6d2a586444
--- /dev/null
+++ b/rdbmaker/source/codemaker/global.cxx
@@ -0,0 +1,171 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <osl/process.h>
+#ifndef _RTL_OSTRINGBUFFER_HXX_
+#include <rtl/strbuf.hxx>
+#endif
+#include <rtl/ustring.hxx>
+#include <osl/thread.h>
+#include <osl/file.hxx>
+
+#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
+#include <codemaker/global.hxx>
+
+#ifdef SAL_UNX
+#define SEPARATOR '/'
+#else
+#define SEPARATOR '\\'
+#endif
+
+using namespace ::rtl;
+using namespace ::osl;
+
+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);
+}
+
+static sal_Bool isFileUrl(const OString& fileName)
+{
+ if (fileName.indexOf("file://") == 0 )
+ return sal_True;
+ return sal_False;
+}
+
+OUString convertToFileUrl(const OString& fileName)
+{
+ if ( isFileUrl(fileName) )
+ {
+ return OStringToOUString(fileName, osl_getThreadTextEncoding());
+ }
+
+ OUString uUrlFileName;
+ OUString uFileName(fileName.getStr(), fileName.getLength(), osl_getThreadTextEncoding());
+ if ( fileName.indexOf('.') == 0 || fileName.indexOf(SEPARATOR) < 0 )
+ {
+ OUString uWorkingDir;
+ if (osl_getProcessWorkingDir(&uWorkingDir.pData) != osl_Process_E_None) {
+ OSL_ASSERT(false);
+ }
+ if (FileBase::getAbsoluteFileURL(uWorkingDir, uFileName, uUrlFileName)
+ != FileBase::E_None)
+ {
+ OSL_ASSERT(false);
+ }
+ } else
+ {
+ if (FileBase::getFileURLFromSystemPath(uFileName, uUrlFileName)
+ != FileBase::E_None)
+ {
+ OSL_ASSERT(false);
+ }
+ }
+
+ return uUrlFileName;
+}
+
+//*************************************************************************
+// FileStream
+//*************************************************************************
+FileStream::FileStream()
+{
+}
+
+FileStream::~FileStream()
+{
+ if ( isValid() )
+ {
+ fflush(m_pFile);
+ fclose(m_pFile);
+ }
+}
+
+sal_Bool FileStream::isValid()
+{
+ if ( m_pFile )
+ return sal_True;
+
+ return sal_False;
+}
+
+void FileStream::open(const OString& name, FileAccessMode mode)
+{
+ if ( name.getLength() > 0 )
+ {
+ m_name = name;
+ m_pFile = fopen(m_name, checkAccessMode(mode));
+ }
+}
+
+void FileStream::close()
+{
+ if ( isValid() )
+ {
+ fflush(m_pFile);
+ fclose(m_pFile);
+ m_pFile = NULL;
+ m_name = OString();
+ }
+}
+
+const sal_Char* FileStream::checkAccessMode(FileAccessMode mode)
+{
+ switch( mode )
+ {
+ case FAM_READ:
+ return "r";
+ case FAM_WRITE:
+ return "w";
+ case FAM_APPEND:
+ return "a";
+ case FAM_READWRITE_EXIST:
+ return "r+";
+ case FAM_READWRITE:
+ return "w+";
+ case FAM_READAPPEND:
+ return "a+";
+ }
+ return "w+";
+}
+
diff --git a/rdbmaker/source/codemaker/makefile.mk b/rdbmaker/source/codemaker/makefile.mk
new file mode 100644
index 000000000000..626b71ec0ed5
--- /dev/null
+++ b/rdbmaker/source/codemaker/makefile.mk
@@ -0,0 +1,55 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org 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 version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME=codemaker
+TARGET=$(PRJNAME)
+
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : settings.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..c4fe96d48d04
--- /dev/null
+++ b/rdbmaker/source/codemaker/options.cxx
@@ -0,0 +1,67 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <codemaker/options.hxx>
+
+using namespace rtl;
+
+Options::Options()
+{
+}
+
+Options::~Options()
+{
+
+}
+
+const OString& Options::getProgramName() const
+{
+ return m_program;
+}
+
+sal_Bool Options::isValid(const OString& option)
+{
+ return (m_options.count(option) > 0);
+}
+
+const OString Options::getOption(const OString& option)
+ throw( IllegalArgument )
+{
+ if (m_options.count(option) > 0)
+ {
+ return m_options[option];
+ } else
+ {
+ throw IllegalArgument("Option is not valid or currently not set.");
+ }
+}
+
+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..f8e231a9403a
--- /dev/null
+++ b/rdbmaker/source/codemaker/typemanager.cxx
@@ -0,0 +1,273 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <rtl/alloc.h>
+#include <osl/file.hxx>
+#include <codemaker/typemanager.hxx>
+
+using namespace rtl;
+
+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();
+
+ Registry tmpReg;
+ while (iter != regFiles.end())
+ {
+ if (!tmpReg.open( convertToFileUrl(*iter), 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;
+ OUString tmpName;
+ osl::FileBase::createTempFile(0, 0, &tmpName);
+ if (!pTmpReg->create(tmpName))
+ {
+ 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, convertToFileUrl( *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))
+ {
+ reader = TypeReader(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))
+ {
+ TypeReader reader(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..8b41a93b6e7f
--- /dev/null
+++ b/rdbmaker/source/rdbmaker/makefile.mk
@@ -0,0 +1,63 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org 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 version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=codemaker
+TARGET=rdbmaker
+TARGETTYPE=CUI
+LIBTARGET=NO
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : settings.mk
+
+OBJFILES= $(OBJ)$/rdbmaker.obj \
+ $(OBJ)$/rdboptions.obj \
+ $(OBJ)$/typeblop.obj \
+ $(OBJ)$/specialtypemanager.obj \
+ $(OBJ)$/rdbtype.obj
+
+
+APP1TARGET= $(TARGET)
+
+APP1OBJS= $(OBJFILES)
+
+APP1STDLIBS=\
+ $(SALLIB) \
+ $(SALHELPERLIB) \
+ $(REGLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB)
+
+APP1LIBS= \
+ $(LB)$/codemaker.lib
+
+APP1RPATH= NONE
+
+.INCLUDE : target.mk
diff --git a/rdbmaker/source/rdbmaker/rdbmaker.cxx b/rdbmaker/source/rdbmaker/rdbmaker.cxx
new file mode 100644
index 000000000000..5a4bd498cca2
--- /dev/null
+++ b/rdbmaker/source/rdbmaker/rdbmaker.cxx
@@ -0,0 +1,508 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+#include <osl/file.hxx>
+#include <osl/process.h>
+#include <codemaker/typemanager.hxx>
+#include <codemaker/dependency.hxx>
+
+#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;
+
+FileStream listFile;
+RegistryKey rootKey;
+Registry regFile;
+sal_Bool useSpecial;
+TypeManager* pTypeMgr = NULL;
+StringList dirEntries;
+StringSet filterTypes;
+
+OString getFullNameOfApplicatRdb()
+{
+ OUString bootReg;
+ OUString uTmpStr;
+ if( osl_getExecutableFile(&uTmpStr.pData) == osl_Process_E_None )
+ {
+ 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::getSystemPathFromFileURL(tmpReg, bootReg);
+ }
+
+ return OUStringToOString(bootReg, RTL_TEXTENCODING_ASCII_US);
+}
+
+void initFilterTypes(RdbOptions* pOptions)
+{
+ if (pOptions->isValid("-FT"))
+ {
+ OString fOption(pOptions->getOption("-FT"));
+ sal_Int32 nIndex = 0;
+ do
+ {
+ filterTypes.insert( fOption.getToken( 0, ';', nIndex ).replace('.', '/') );
+ }
+ while ( nIndex >= 0 );
+ }
+ 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.close();
+ 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
+
+ OStringBuffer nameBuffer( path.getLength() );
+
+ sal_Int32 nIndex = 0;
+ do
+ {
+ nameBuffer.append(fileName.getToken( 0, token, nIndex ).getStr());
+ if ( nIndex == -1 ) break;
+
+ if (nameBuffer.getLength() == 0 || OString(".") == nameBuffer.getStr())
+ {
+ nameBuffer.append(token);
+ continue;
+ }
+
+#if defined(SAL_UNX) || defined(SAL_OS2)
+ 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);
+ }
+ while ( nIndex >= 0 );
+
+ return fileName;
+}
+
+sal_Bool produceAllTypes(const OString& typeName,
+ TypeManager& typeMgr,
+ TypeDependency& typeDependencies,
+ RdbOptions* pOptions,
+ sal_Bool bFullScope,
+ FileStream& o,
+ RegistryKey& regKey,
+ StringSet& filterTypes2)
+ throw( CannotDumpException )
+{
+ if (!produceType(typeName, typeMgr, typeDependencies, pOptions, o, regKey, filterTypes2))
+ {
+ 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, filterTypes2))
+ return sal_False;
+ } else
+ {
+ if (!produceType(tmpName, typeMgr, typeDependencies, pOptions, o, regKey, filterTypes2))
+ 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.open(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"));
+ OString typeName, tmpName;
+ sal_Bool ret = sal_False;
+ sal_Int32 nIndex = 0;
+ do
+ {
+ typeName = tOption.getToken( 0, ';', nIndex);
+ sal_Int32 lastIndex = typeName.lastIndexOf('.');
+ tmpName = typeName.copy( lastIndex+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);
+ }
+ }
+ while ( nIndex >= 0 );
+ } 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..c70424bb7b25
--- /dev/null
+++ b/rdbmaker/source/rdbmaker/rdboptions.cxx
@@ -0,0 +1,381 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <stdio.h>
+#include <string.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 < 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]));
+ }
+ } 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 j=0; j < rargc; j++)
+ {
+ free(rargv[j]);
+ }
+ }
+ } else
+ {
+ m_inputFiles.push_back(av[i]);
+ }
+ }
+ }
+
+ return ret;
+}
+
+OString RdbOptions::prepareHelp()
+{
+ OString help("\nusing: ");
+ help += m_program + " [-options] (-R<regname> | file_1 [... file_n])\n";
+ help += "The rdbmaker supports 2 modes:\n";
+ help += " 1. using the internal UNO type description manager -> use -R<regname>\n"
+ " where regname specifies the type library used by the UNO type description manager\n"
+ " after UNO is bootstrapped. This option disables the use of any other type libraries.\n"
+ " The tpye library must be a valid product type library which means that all types are\n"
+ " stored under the global base node UCR (Uno Core Reflection data).\n";
+ help += " 2. using one or more type library files -> use file_1 ... file_n\n"
+ " file_1 .. file_n specifies one or more valid type library files which are used to\n"
+ " find the needed type information. The used type libraries have to support the same base\n"
+ " node (-B option).\n";
+ help += "Options:\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 += " This option takes effect using run mode 2 only.\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..533dc6187197
--- /dev/null
+++ b/rdbmaker/source/rdbmaker/rdboptions.hxx
@@ -0,0 +1,57 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#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..5bfd27be21af
--- /dev/null
+++ b/rdbmaker/source/rdbmaker/rdbtype.cxx
@@ -0,0 +1,195 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+#include <rtl/alloc.h>
+#include <rtl/ustring.hxx>
+#include <rtl/strbuf.hxx>
+
+#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,
+ sal_True))
+ {
+ 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,
+ sal_Bool bDepend)
+ 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, bDepend))
+ return sal_False;
+
+ if ( !checkFilterTypes(typeName) )
+ {
+ if ( pOptions->generateTypeList() )
+ {
+ o << typeName.getStr() << "\n";
+ } 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..a6df2266257c
--- /dev/null
+++ b/rdbmaker/source/rdbmaker/rdbtype.hxx
@@ -0,0 +1,52 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _RDBMAKER_RDBTYPE_HXX_
+#define _RDBMAKER_RDBTYPE_HXX_
+
+#include <codemaker/typemanager.hxx>
+#include <codemaker/dependency.hxx>
+
+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,
+ sal_Bool bDepend = sal_False)
+ 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..8089e1b8d68d
--- /dev/null
+++ b/rdbmaker/source/rdbmaker/specialtypemanager.cxx
@@ -0,0 +1,101 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <rtl/alloc.h>
+
+#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 )
+ {
+ reader = TypeReader(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..b363e875b042
--- /dev/null
+++ b/rdbmaker/source/rdbmaker/specialtypemanager.hxx
@@ -0,0 +1,71 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SPECIALTYPEMANAGER_HXX_
+#define _SPECIALTYPEMANAGER_HXX_
+
+#include <codemaker/registry.hxx>
+#include <codemaker/typemanager.hxx>
+
+
+struct SpecialTypeManagerImpl
+{
+ T2TypeClassMap m_t2TypeClass;
+};
+
+class SpecialTypeManager : public TypeManager
+{
+public:
+ SpecialTypeManager();
+ ~SpecialTypeManager();
+
+ SpecialTypeManager( const SpecialTypeManager& value )
+ : TypeManager(value)
+ , m_pImpl( value.m_pImpl )
+ {
+ acquire();
+ }
+
+ using TypeManager::init;
+ sal_Bool init(const ::rtl::OString& registryName);
+
+ sal_Bool isValidType(const ::rtl::OString&)
+ { 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..0300970567d4
--- /dev/null
+++ b/rdbmaker/source/rdbmaker/typeblop.cxx
@@ -0,0 +1,535 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <rtl/alloc.h>
+#ifndef __REGISTRY_REFLWRIT_HXX__
+#include <registry/reflwrit.hxx>
+#endif
+#include <cppuhelper/servicefactory.hxx>
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <com/sun/star/reflection/XInterfaceTypeDescription.hpp>
+#include <com/sun/star/reflection/XConstantsTypeDescription.hpp>
+#include <com/sun/star/reflection/XConstantTypeDescription.hpp>
+#include <com/sun/star/reflection/XModuleTypeDescription.hpp>
+#include <com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp>
+#include <com/sun/star/reflection/XInterfaceAttributeTypeDescription.hpp>
+#include <com/sun/star/reflection/XMethodParameter.hpp>
+#include <com/sun/star/reflection/XCompoundTypeDescription.hpp>
+#include <com/sun/star/reflection/XIndirectTypeDescription.hpp>
+#include <com/sun/star/reflection/XEnumTypeDescription.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <codemaker/global.hxx>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+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;
+
+void writeConstantData( RegistryTypeWriter& rWriter, sal_uInt16 fieldIndex,
+ const Reference< XConstantTypeDescription >& xConstant)
+
+{
+ RTConstValue constValue;
+ OUString uConstTypeName;
+ OUString uConstName = xConstant->getName();
+ Any aConstantAny = xConstant->getConstantValue();
+
+ switch ( aConstantAny.getValueTypeClass() )
+ {
+ case TypeClass_BOOLEAN:
+ {
+ uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("boolean") );
+ constValue.m_type = RT_TYPE_BOOL;
+ aConstantAny >>= constValue.m_value.aBool;
+ }
+ break;
+ case TypeClass_BYTE:
+ {
+ uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("byte") );
+ constValue.m_type = RT_TYPE_BYTE;
+ aConstantAny >>= constValue.m_value.aByte;
+ }
+ break;
+ case TypeClass_SHORT:
+ {
+ uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("short") );
+ constValue.m_type = RT_TYPE_INT16;
+ aConstantAny >>= constValue.m_value.aShort;
+ }
+ break;
+ case TypeClass_UNSIGNED_SHORT:
+ {
+ uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("unsigned short") );
+ constValue.m_type = RT_TYPE_UINT16;
+ aConstantAny >>= constValue.m_value.aUShort;
+ }
+ break;
+ case TypeClass_LONG:
+ {
+ uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("long") );
+ constValue.m_type = RT_TYPE_INT32;
+ aConstantAny >>= constValue.m_value.aLong;
+ }
+ break;
+ case TypeClass_UNSIGNED_LONG:
+ {
+ uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("unsigned long") );
+ constValue.m_type = RT_TYPE_UINT32;
+ aConstantAny >>= constValue.m_value.aULong;
+ }
+ break;
+ case TypeClass_FLOAT:
+ {
+ uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("float") );
+ constValue.m_type = RT_TYPE_FLOAT;
+ aConstantAny >>= constValue.m_value.aFloat;
+ }
+ break;
+ case TypeClass_DOUBLE:
+ {
+ uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("double") );
+ constValue.m_type = RT_TYPE_DOUBLE;
+ aConstantAny >>= 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*)aConstantAny.getValue())->getStr();
+ }
+ break;
+ default:
+ OSL_ASSERT(false);
+ break;
+ }
+
+ rWriter.setFieldData(fieldIndex, uConstName, uConstTypeName, OUString(),
+ OUString(), RT_ACCESS_CONST, constValue);
+}
+
+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 calculatedMemberOffset,
+ 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_uInt16 methodIndex = (sal_uInt16)(xMember->getPosition() - calculatedMemberOffset);
+ sal_uInt16 paramCount = (sal_uInt16)parameters.getLength();
+ sal_uInt16 exceptionCount = (sal_uInt16)exceptions.getLength();
+
+ rWriter.setMethodData(methodIndex, xMember->getMemberName(),
+ xMethod->getReturnType()->getName().replace('.', '/'),
+ methodMode, paramCount, exceptionCount, OUString());
+
+ RTParamMode paramMode = RT_PARAM_IN;
+ sal_uInt16 i;
+
+ for ( 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, (sal_uInt16)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( convertToFileUrl(pRegName) ) );
+
+ if ( !xSMgr.is() )
+ return sal_False;
+
+ Reference< XHierarchicalNameAccess > xNAccess;
+
+ Reference< beans::XPropertySet > xProps( xSMgr, UNO_QUERY );
+ if (xProps.is())
+ {
+ try
+ {
+ Reference< XComponentContext > xContext;
+ if (xProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ) >>= xContext)
+ {
+ xContext->getValueByName(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/singletons/com.sun.star.reflection.theTypeDescriptionManager") ) ) >>= xNAccess;
+ }
+ }
+ catch (beans::UnknownPropertyException &)
+ {
+ }
+ }
+
+ 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;
+
+ Reference< XTypeDescription > xType;
+ aTypeAny >>= xType;
+
+ if ( !xType.is() )
+ return length;
+
+ switch (xType->getTypeClass())
+ {
+ case TypeClass_CONSTANTS:
+ {
+ Reference< XConstantsTypeDescription > xCFace(xType, UNO_QUERY);
+
+ if ( !xCFace.is() )
+ return length;
+
+ Sequence< Reference< XConstantTypeDescription > > constTypes( xCFace->getConstants());
+ sal_uInt16 constCount = (sal_uInt16)constTypes.getLength();
+
+ RegistryTypeWriter writer(RT_TYPE_MODULE, uTypeName.replace('.', '/'),
+ OUString(), constCount, 0, 0);
+
+ for (sal_uInt16 i=0; i < constCount; i++)
+ writeConstantData(writer, i, constTypes[i]);
+
+ length = writer.getBlopSize();
+ *pBlop = (sal_uInt8*)rtl_allocateMemory( length );
+ rtl_copyMemory(*pBlop, writer.getBlop(), length);
+ }
+ break;
+ case TypeClass_MODULE:
+ {
+ Reference< XModuleTypeDescription > xMFace(xType, UNO_QUERY);
+
+ if ( !xMFace.is() )
+ return length;
+
+ Sequence< Reference< XTypeDescription > > memberTypes( xMFace->getMembers());
+
+ sal_uInt16 memberCount = (sal_uInt16)memberTypes.getLength();
+ sal_uInt16 constCount = 0;
+ sal_Int16 i;
+
+ for ( i=0; i < memberCount; i++)
+ {
+ if ( TypeClass_CONSTANT == memberTypes[i]->getTypeClass() )
+ constCount++;
+ }
+
+ RegistryTypeWriter writer(RT_TYPE_MODULE, uTypeName.replace('.', '/'),
+ OUString(), constCount, 0, 0);
+
+ if ( 0 < constCount )
+ {
+ Reference< XConstantTypeDescription > xConst;
+ sal_uInt16 fieldIndex = 0;
+ for (i=0; i < memberCount; i++)
+ {
+ if ( TypeClass_CONSTANT == memberTypes[i]->getTypeClass() )
+ {
+ xConst = Reference< XConstantTypeDescription >(memberTypes[i], UNO_QUERY);
+
+ writeConstantData(writer, ++fieldIndex, xConst);
+ }
+ }
+ }
+
+ length = writer.getBlopSize();
+ *pBlop = (sal_uInt8*)rtl_allocateMemory( length );
+ rtl_copyMemory(*pBlop, writer.getBlop(), length);
+ }
+ break;
+ 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_uInt16 memberCount = (sal_uInt16)memberTypes.getLength();
+ sal_uInt16 attrCount = 0;
+ sal_uInt16 inheritedMemberCount = 0;
+ sal_Int32 i;
+
+ for ( 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 = (sal_uInt16)getInheritedMemberCount( xSuperType );
+ }
+
+ RegistryTypeWriter writer(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;
+ // reset attrCount, used for method index calculation
+ attrCount = 0;
+
+ for (i=0; i < memberCount; i++)
+ {
+ xAttr = Reference< XInterfaceAttributeTypeDescription >(memberTypes[i], UNO_QUERY);
+ if ( xAttr.is() )
+ {
+ ++attrCount;
+ if (xAttr->isReadOnly())
+ {
+ attrAccess = RT_ACCESS_READONLY;
+ } else
+ {
+ attrAccess = RT_ACCESS_READWRITE;
+ }
+ writer.setFieldData(sal::static_int_cast< sal_uInt16 >(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, attrCount+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;
+ }
+#include <com/sun/star/reflection/XConstantsTypeDescription.hpp>
+
+ Reference< XCompoundTypeDescription > xComp(xType, UNO_QUERY);
+
+ if ( !xComp.is() )
+ return length;
+
+ Sequence< OUString > memberNames( xComp->getMemberNames());
+ Sequence< Reference< XTypeDescription > > memberTypes( xComp->getMemberTypes());
+ sal_uInt16 memberCount = (sal_uInt16)memberNames.getLength();
+
+ OUString uSuperType;
+ Reference< XTypeDescription > xSuperType = xComp->getBaseType();
+ if ( xSuperType.is() )
+ {
+ uSuperType = xSuperType->getName().replace('.','/');
+ }
+
+ RegistryTypeWriter writer(rtTypeClass, uTypeName.replace('.', '/'),
+ uSuperType, memberCount, 0, 0);
+
+ for (sal_Int16 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_uInt16 enumCount = (sal_uInt16)enumNames.getLength();
+
+ RegistryTypeWriter writer(RT_TYPE_ENUM, uTypeName.replace('.', '/'),
+ OUString(), enumCount, 0, 0);
+
+ RTConstValue constValue;
+ for (sal_Int16 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(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;
+ default:
+ OSL_ASSERT(false);
+ break;
+ }
+
+ }
+ catch( Exception& )
+ {
+ }
+
+ return length;
+}
+
+} // extern "C"
+
+
+