[Libreoffice-commits] .: Repository.mk xml2cmp/Executable_srvdepy.mk xml2cmp/Executable_xml2cmp.mk xml2cmp/Module_xml2cmp.mk xml2cmp/source xml2cmp/StaticLibrary_x2c_support.mk xml2cmp/StaticLibrary_x2c_xcd.mk

Norbert Thiebaud nthiebaud at kemper.freedesktop.org
Wed Sep 14 08:10:59 PDT 2011


 Repository.mk                        |    5 
 xml2cmp/Executable_srvdepy.mk        |   40 ----
 xml2cmp/Executable_xml2cmp.mk        |   19 +-
 xml2cmp/Module_xml2cmp.mk            |    4 
 xml2cmp/StaticLibrary_x2c_support.mk |   38 ----
 xml2cmp/StaticLibrary_x2c_xcd.mk     |   40 ----
 xml2cmp/source/finder/dependy.cxx    |  225 ----------------------------
 xml2cmp/source/finder/dependy.hxx    |  118 --------------
 xml2cmp/source/support/cmdline.cxx   |   10 +
 xml2cmp/source/support/cmdline.hxx   |    3 
 xml2cmp/source/xcd/dependy.cxx       |  225 ++++++++++++++++++++++++++++
 xml2cmp/source/xcd/dependy.hxx       |  118 ++++++++++++++
 xml2cmp/source/xcd/main.cxx          |  281 +++++++++++++++++++----------------
 13 files changed, 527 insertions(+), 599 deletions(-)

New commits:
commit 0a97ece91e8a87724230f39276f0a7537b1566c3
Author: Norbert Thiebaud <nthiebaud at gmail.com>
Date:   Wed Sep 14 10:10:34 2011 -0500

    merge srvdepy functions into xml2cmp and simplify xml2cmp gbuild

diff --git a/Repository.mk b/Repository.mk
index 962356c..f13f72d 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -2,7 +2,7 @@
 #*************************************************************************
 #
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-# 
+#
 # Copyright 2009 by Sun Microsystems, Inc.
 #
 # OpenOffice.org - a multi-platform office productivity suite
@@ -36,7 +36,6 @@ $(eval $(call gb_Helper_register_executables,NONE, \
     mkunroll \
     rscdep \
     so_checksum \
-    srvdepy \
     xml2cmp \
 ))
 
@@ -257,8 +256,6 @@ $(eval $(call gb_Helper_register_static_libraries,PLAINLIBS, \
     salcpprt \
 	vclmain \
 	writerperfect \
-    x2c_support \
-    x2c_xcd \
 ))
 
 ifeq ($(OS),WNT)
diff --git a/xml2cmp/Executable_srvdepy.mk b/xml2cmp/Executable_srvdepy.mk
deleted file mode 100644
index 3bcaa84..0000000
--- a/xml2cmp/Executable_srvdepy.mk
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# Version: MPL 1.1 / GPLv3+ / LGPLv3+
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License or as specified alternatively below. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Initial Developer of the Original Code is
-# 	Peter Foley <pefoley2 at verizon.net>
-# Portions created by the Initial Developer are Copyright (C) 2011 the
-# Initial Developer. All Rights Reserved.
-#
-# Major Contributor(s):
-#
-# For minor contributions see the git repository.
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
-# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
-# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
-# instead of those above.
-#
-
-$(eval $(call gb_Executable_Executable,srvdepy))
-
-$(eval $(call gb_Executable_add_exception_objects,srvdepy,\
-	xml2cmp/source/finder/dependy \
-	xml2cmp/source/finder/dep_main \
-))
-
-$(eval $(call gb_Executable_add_linked_static_libs,srvdepy,\
-	x2c_support \
-	x2c_xcd \
-))
diff --git a/xml2cmp/Executable_xml2cmp.mk b/xml2cmp/Executable_xml2cmp.mk
index 692a043..28ed105 100644
--- a/xml2cmp/Executable_xml2cmp.mk
+++ b/xml2cmp/Executable_xml2cmp.mk
@@ -1,3 +1,4 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
 #
 # Version: MPL 1.1 / GPLv3+ / LGPLv3+
 #
@@ -31,9 +32,21 @@ $(eval $(call gb_Executable_Executable,xml2cmp))
 
 $(eval $(call gb_Executable_add_exception_objects,xml2cmp,\
 	xml2cmp/source/xcd/main \
+	xml2cmp/source/support/cmdline \
+	xml2cmp/source/support/heap \
+	xml2cmp/source/support/sistr \
+	xml2cmp/source/support/syshelp \
+	xml2cmp/source/support/badcast \
+	xml2cmp/source/xcd/cr_html \
+	xml2cmp/source/xcd/cr_index \
+	xml2cmp/source/xcd/cr_metho \
+	xml2cmp/source/xcd/filebuff \
+	xml2cmp/source/xcd/parse \
+	xml2cmp/source/xcd/xmlelem \
+	xml2cmp/source/xcd/xmltree \
+	xml2cmp/source/xcd/dependy \
 ))
 
-$(eval $(call gb_Executable_add_linked_static_libs,xml2cmp,\
-	x2c_support \
-	x2c_xcd \
+$(eval $(call gb_Executable_add_linked_libs,xml2cmp,\
+    $(gb_STDLIBS) \
 ))
diff --git a/xml2cmp/Module_xml2cmp.mk b/xml2cmp/Module_xml2cmp.mk
index dc11c53..c4279fb 100644
--- a/xml2cmp/Module_xml2cmp.mk
+++ b/xml2cmp/Module_xml2cmp.mk
@@ -1,3 +1,4 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
 #
 # Version: MPL 1.1 / GPLv3+ / LGPLv3+
 #
@@ -31,9 +32,6 @@ $(eval $(call gb_Module_Module,xml2cmp))
 
 ifneq ($(CROSS_COMPILING),YES)
 $(eval $(call gb_Module_add_targets,xml2cmp,\
-	StaticLibrary_x2c_support \
-	StaticLibrary_x2c_xcd \
-	Executable_srvdepy \
 	Executable_xml2cmp \
 ))
 endif
diff --git a/xml2cmp/StaticLibrary_x2c_support.mk b/xml2cmp/StaticLibrary_x2c_support.mk
deleted file mode 100644
index 0219bbe..0000000
--- a/xml2cmp/StaticLibrary_x2c_support.mk
+++ /dev/null
@@ -1,38 +0,0 @@
-#
-# Version: MPL 1.1 / GPLv3+ / LGPLv3+
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License or as specified alternatively below. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Initial Developer of the Original Code is
-# 	Peter Foley <pefoley2 at verizon.net>
-# Portions created by the Initial Developer are Copyright (C) 2011 the
-# Initial Developer. All Rights Reserved.
-#
-# Major Contributor(s):
-#
-# For minor contributions see the git repository.
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
-# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
-# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
-# instead of those above.
-#
-
-$(eval $(call gb_StaticLibrary_StaticLibrary,x2c_support))
-
-$(eval $(call gb_StaticLibrary_add_exception_objects,x2c_support,\
-	xml2cmp/source/support/cmdline \
-	xml2cmp/source/support/heap \
-	xml2cmp/source/support/sistr \
-	xml2cmp/source/support/syshelp \
-	xml2cmp/source/support/badcast \
-))
diff --git a/xml2cmp/StaticLibrary_x2c_xcd.mk b/xml2cmp/StaticLibrary_x2c_xcd.mk
deleted file mode 100644
index b4f8261..0000000
--- a/xml2cmp/StaticLibrary_x2c_xcd.mk
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# Version: MPL 1.1 / GPLv3+ / LGPLv3+
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License or as specified alternatively below. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Initial Developer of the Original Code is
-# 	Peter Foley <pefoley2 at verizon.net>
-# Portions created by the Initial Developer are Copyright (C) 2011 the
-# Initial Developer. All Rights Reserved.
-#
-# Major Contributor(s):
-#
-# For minor contributions see the git repository.
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
-# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
-# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
-# instead of those above.
-#
-
-$(eval $(call gb_StaticLibrary_StaticLibrary,x2c_xcd))
-
-$(eval $(call gb_StaticLibrary_add_exception_objects,x2c_xcd,\
-	xml2cmp/source/xcd/cr_html \
-	xml2cmp/source/xcd/cr_index \
-	xml2cmp/source/xcd/cr_metho \
-	xml2cmp/source/xcd/filebuff \
-	xml2cmp/source/xcd/parse \
-	xml2cmp/source/xcd/xmlelem \
-	xml2cmp/source/xcd/xmltree \
-))
diff --git a/xml2cmp/source/finder/dependy.cxx b/xml2cmp/source/finder/dependy.cxx
deleted file mode 100644
index 8a7ae0a..0000000
--- a/xml2cmp/source/finder/dependy.cxx
+++ /dev/null
@@ -1,225 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * 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 "dependy.hxx"
-#include <iostream>
-#include "../support/syshelp.hxx"
-#include "../support/list.hxx"
-#include "../xcd/xmltree.hxx"
-#include "../xcd/parse.hxx"
-
-
-
-Simstr              ShortName(const Simstr & i_rService);
-
-
-
-Service::Service( const char * i_sName )
-    :   sName(i_sName)
-        // aImplementations
-{
-}
-
-ServiceInfo &
-Service::AddImplementation( const char * i_sLibrary )
-{
-    ServiceInfo * ret = new ServiceInfo(i_sLibrary);
-    aImplementations.push_back(ret);
-    return *ret;
-}
-
-ServiceInfo::ServiceInfo( const char * i_sLibrary )
-    :   sImplementingLibrary(i_sLibrary)
-        // aNeededServices
-{
-}
-
-void
-ServiceInfo::AddDependency( const char * i_sNeededService )
-{
-    aNeededServices.push_back(i_sNeededService);
-}
-
-DependencyFinder::DependencyFinder()
-{
-}
-
-DependencyFinder::~DependencyFinder()
-{
-}
-
-void
-DependencyFinder::GatherData( const char * i_sSearchDirectory )
-{
-    List<Simstr> aFiles;
-    GatherFileNames( aFiles, i_sSearchDirectory );
-
-    for ( unsigned i = 0; i < aFiles.size(); ++i )
-    {
-        ReadFile( aFiles[i].str() );
-    }
-}
-
-void
-DependencyFinder::FindNeededServices( StringVector &        o_rLibraries,
-                                      StringVector &        o_rServices,
-                                      const Simstr &        i_rService )
-{
-    Map_Services::const_iterator itService = aServices.find(i_rService);
-    if ( itService == aServices.end() )
-    {
-        std::cerr << "Error: Service \""
-                  << i_rService.str()
-                  << "\" not found."
-                  << std::endl;
-        return ;
-    }
-
-    aResult_Libraries.erase( aResult_Libraries.begin(), aResult_Libraries.end() );
-    aResult_Services.erase( aResult_Services.begin(), aResult_Services.end() );
-
-    Add2Result( *(*itService).second );
-
-    for ( std::set< Simstr >::const_iterator il = aResult_Libraries.begin();
-          il != aResult_Libraries.end();
-          ++il )
-    {
-        o_rLibraries.push_back(*il);
-    }
-
-    for ( std::set< Simstr >::const_iterator is = aResult_Services.begin();
-          is != aResult_Services.end();
-          ++is )
-    {
-        o_rServices.push_back(*is);
-    }
-}
-
-void
-DependencyFinder::ReadFile(  const char * i_sFilename )
-{
-    ModuleDescription   aModule;
-    X2CParser           aParser(aModule);
-
-    if ( !aParser.Parse(i_sFilename) )
-    {
-        std::cerr << "Error: File \""
-             << i_sFilename
-             << "\" could not be parsed."
-             << std::endl;
-        return;
-    }
-
-    // GetResults:
-    Simstr sModule = aModule.ModuleName();
-
-    List < const MultipleTextElement* > aImplServices;
-    List < const MultipleTextElement* > aNeededServices;
-
-    aModule.Get_SupportedServices(aImplServices);
-    aModule.Get_ServiceDependencies(aNeededServices);
-
-    unsigned nImplServicesSize = aImplServices.size();
-    unsigned nNeededServicesSize = aNeededServices.size();
-
-    for ( unsigned i = 0; i < nImplServicesSize; ++i )
-    {
-        const MultipleTextElement & rImpl = *aImplServices[i];
-
-        unsigned nImplDataSize = rImpl.Size();
-        for ( unsigned di = 0; di < nImplDataSize; ++di )
-        {
-            Simstr sService = ShortName(rImpl.Data(di));
-            Service * pService = aServices[sService];
-            if (pService == 0)
-            {
-                pService = new Service(rImpl.Data(di));
-                aServices[sService] = pService;
-            }
-            ServiceInfo & rSInfo = pService->AddImplementation(sModule);
-
-            for ( unsigned n = 0; n < nNeededServicesSize; ++n )
-            {
-                unsigned nNeededDataSize = aNeededServices[n]->Size();
-                for ( unsigned dn = 0; dn < nNeededDataSize; ++dn )
-                {
-                    if (! aNeededServices[n]->Data(dn).is_no_text())
-                        rSInfo.AddDependency( ShortName(aNeededServices[n]->Data(dn)) );
-                }   // end for dn
-            }   // end for n
-        }   //  end for di
-    }   // end for i
-}
-
-void
-DependencyFinder::Add2Result( const Service & i_rService )
-{
-    const ServiceInfo & rSInfo = i_rService.FirstImplementation();
-    aResult_Libraries.insert(rSInfo.Library());
-
-    const ServiceInfo::List_NeededServices & rNeededs
-            = rSInfo.NeededServices();
-    for ( StringVector::const_iterator it = rNeededs.begin();
-          it != rNeededs.end();
-          ++it )
-    {
-        std::pair< std::set< Simstr >::iterator, bool > aInsertResult
-                = aResult_Services.insert(*it);
-        if (aInsertResult.second)
-        {   // Needed service not yet known
-            Map_Services::const_iterator itFound = aServices.find(*it);
-            if ( itFound == aServices.end() )
-            {
-                std::cerr << "Needed service \""
-                          << (*it).str()
-                          << "\" not found,"
-                          << std::endl;
-            }
-            else
-            {
-                Add2Result( *(*itFound).second );
-            }
-        }   // endif (! aInsertResult.second)
-    }   // end for (it)
-}
-
-
-
-Simstr
-ShortName(const Simstr & i_rService)
-{
-    const char * pStart = i_rService.str();
-    const char * pEnd = strchr(pStart,' ');
-    if (pEnd != 0)
-        return Simstr(pStart, 0, int(pEnd-pStart));
-    else
-        return i_rService;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xml2cmp/source/finder/dependy.hxx b/xml2cmp/source/finder/dependy.hxx
deleted file mode 100644
index c2c2d7d..0000000
--- a/xml2cmp/source/finder/dependy.hxx
+++ /dev/null
@@ -1,118 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * 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 X2C_DEPENDY_HXX
-#define X2C_DEPENDY_HXX
-
-
-#include <vector>
-#include <map>
-#include <set>
-#include <../support/sistr.hxx>
-
-class Service;
-class ServiceInfo;
-
-typedef std::vector< Simstr>            StringVector;
-typedef std::vector< ServiceInfo* >     List_Implementations;
-typedef std::map< Simstr, Service* >    Map_Services;
-
-class Service
-{
-  public:
-                        Service(
-                            const char *        i_sName );
-
-    ServiceInfo &       AddImplementation(
-                            const char *        i_sLibrary );   /// That is: module-name.
-
-    const Simstr &      Name() const            { return sName; }
-    const ServiceInfo & FirstImplementation() const
-                                                { return *aImplementations[0]; }
-
-  private:
-    Simstr              sName;
-    List_Implementations
-                        aImplementations;
-};
-
-class ServiceInfo
-{
-  public:
-    typedef StringVector List_NeededServices;
-
-                        ServiceInfo(
-                            const char *        i_sLibrary );
-
-    void                AddDependency(
-                            const char *        i_sNeededService );
-
-    const Simstr &      Library() const         { return sImplementingLibrary; }
-    const List_NeededServices &
-                        NeededServices() const  { return aNeededServices; }
-
-
-  private:
-    Simstr              sImplementingLibrary;
-    List_NeededServices aNeededServices;
-};
-
-
-class DependencyFinder
-{
-  public:
-                        DependencyFinder();
-                        ~DependencyFinder();
-
-    void                GatherData(
-                            const char *        i_sSearchDirectory );
-
-    void                FindNeededServices(
-                            StringVector &      o_rLibraries,
-                            StringVector &      o_rServices,
-                            const Simstr &      i_rService );
-  private:
-    void                ReadFile(
-                            const char *        i_sFilename );
-    void                Add2Result(
-                            const Service &     i_rService );
-
-    // Data
-    Map_Services        aServices;
-
-    // Temporary data
-    std::set< Simstr >  aResult_Libraries;
-    std::set< Simstr >  aResult_Services;
-};
-
-
-
-#endif
-
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xml2cmp/source/support/cmdline.cxx b/xml2cmp/source/support/cmdline.cxx
index 2af998c..eb1b867 100644
--- a/xml2cmp/source/support/cmdline.cxx
+++ b/xml2cmp/source/support/cmdline.cxx
@@ -35,6 +35,7 @@
 
 
 char C_sUseText[] = "Use: xml2cmp.exe \n"
+                    "        [-dep <xml-component-descriptions-root-directory> \n"
                     "        [-func funcFile] \n"
                     "        [-html htmlFile] \n"
                     "        [-types typeFile] \n"
@@ -49,6 +50,7 @@ char C_sUseText[] = "Use: xml2cmp.exe \n"
 
 
 char C_sCmdFunc[]       = "-func";
+char C_sCmdDep[]       = "-dep";
 char C_sCmdHtml[]       = "-html";
 char C_sCmdType[]       = "-types";
 char C_sCmdIndex[]      = "-ix";
@@ -215,6 +217,14 @@ CommandLine::ParseSingleFileCommand( int                argc,
                                 argc,
                                 argv  );
         }
+        else if ( strcmp( argv[nCountArg], C_sCmdDep ) == 0 )
+        {
+            bIsOk = GetParameter(
+                                sDepPath,
+                                nCountArg,
+                                argc,
+                                argv  );
+        }
         else
         {
             sXmlSourceFile = argv[nCountArg];
diff --git a/xml2cmp/source/support/cmdline.hxx b/xml2cmp/source/support/cmdline.hxx
index 126cdea..948685e 100644
--- a/xml2cmp/source/support/cmdline.hxx
+++ b/xml2cmp/source/support/cmdline.hxx
@@ -48,8 +48,10 @@ class CommandLine
     const char *        FuncFile() const        { return sFuncFile.str(); }
     const char *        HtmlFile() const        { return sHtmlFile.str(); }
     const char *        TypeInfoFile() const    { return sTypeInfoFile.str(); }
+    const char *        DepPath() const         { return sDepPath.str(); }
 
     bool                IsIndexCommand() const  { return sIndexFile.l() > 0; }
+    bool                IsDepCommand() const    { return sDepPath.l() > 0; }
     const char *        XmlSrcDirectory() const { return sXmlSourceDirectory.str(); }
     const char *        IndexOutputFile() const { return sIndexFile.str(); }
     const char *        OutputDirectory() const { return sOutputDirectory.str(); }
@@ -76,6 +78,7 @@ class CommandLine
     List<Simstr>        aTagsInIndex;
 
     Simstr              sIdlRootPath;
+    Simstr              sDepPath;
 
     bool                bIsOk;
 };
diff --git a/xml2cmp/source/xcd/dependy.cxx b/xml2cmp/source/xcd/dependy.cxx
new file mode 100644
index 0000000..6e909d0
--- /dev/null
+++ b/xml2cmp/source/xcd/dependy.cxx
@@ -0,0 +1,225 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 "dependy.hxx"
+#include <iostream>
+#include "../support/syshelp.hxx"
+#include "../support/list.hxx"
+#include "xmltree.hxx"
+#include "parse.hxx"
+
+
+
+Simstr              ShortName(const Simstr & i_rService);
+
+
+
+Service::Service( const char * i_sName )
+    :   sName(i_sName)
+        // aImplementations
+{
+}
+
+ServiceInfo &
+Service::AddImplementation( const char * i_sLibrary )
+{
+    ServiceInfo * ret = new ServiceInfo(i_sLibrary);
+    aImplementations.push_back(ret);
+    return *ret;
+}
+
+ServiceInfo::ServiceInfo( const char * i_sLibrary )
+    :   sImplementingLibrary(i_sLibrary)
+        // aNeededServices
+{
+}
+
+void
+ServiceInfo::AddDependency( const char * i_sNeededService )
+{
+    aNeededServices.push_back(i_sNeededService);
+}
+
+DependencyFinder::DependencyFinder()
+{
+}
+
+DependencyFinder::~DependencyFinder()
+{
+}
+
+void
+DependencyFinder::GatherData( const char * i_sSearchDirectory )
+{
+    List<Simstr> aFiles;
+    GatherFileNames( aFiles, i_sSearchDirectory );
+
+    for ( unsigned i = 0; i < aFiles.size(); ++i )
+    {
+        ReadFile( aFiles[i].str() );
+    }
+}
+
+void
+DependencyFinder::FindNeededServices( StringVector &        o_rLibraries,
+                                      StringVector &        o_rServices,
+                                      const Simstr &        i_rService )
+{
+    Map_Services::const_iterator itService = aServices.find(i_rService);
+    if ( itService == aServices.end() )
+    {
+        std::cerr << "Error: Service \""
+                  << i_rService.str()
+                  << "\" not found."
+                  << std::endl;
+        return ;
+    }
+
+    aResult_Libraries.erase( aResult_Libraries.begin(), aResult_Libraries.end() );
+    aResult_Services.erase( aResult_Services.begin(), aResult_Services.end() );
+
+    Add2Result( *(*itService).second );
+
+    for ( std::set< Simstr >::const_iterator il = aResult_Libraries.begin();
+          il != aResult_Libraries.end();
+          ++il )
+    {
+        o_rLibraries.push_back(*il);
+    }
+
+    for ( std::set< Simstr >::const_iterator is = aResult_Services.begin();
+          is != aResult_Services.end();
+          ++is )
+    {
+        o_rServices.push_back(*is);
+    }
+}
+
+void
+DependencyFinder::ReadFile(  const char * i_sFilename )
+{
+    ModuleDescription   aModule;
+    X2CParser           aParser(aModule);
+
+    if ( !aParser.Parse(i_sFilename) )
+    {
+        std::cerr << "Error: File \""
+             << i_sFilename
+             << "\" could not be parsed."
+             << std::endl;
+        return;
+    }
+
+    // GetResults:
+    Simstr sModule = aModule.ModuleName();
+
+    List < const MultipleTextElement* > aImplServices;
+    List < const MultipleTextElement* > aNeededServices;
+
+    aModule.Get_SupportedServices(aImplServices);
+    aModule.Get_ServiceDependencies(aNeededServices);
+
+    unsigned nImplServicesSize = aImplServices.size();
+    unsigned nNeededServicesSize = aNeededServices.size();
+
+    for ( unsigned i = 0; i < nImplServicesSize; ++i )
+    {
+        const MultipleTextElement & rImpl = *aImplServices[i];
+
+        unsigned nImplDataSize = rImpl.Size();
+        for ( unsigned di = 0; di < nImplDataSize; ++di )
+        {
+            Simstr sService = ShortName(rImpl.Data(di));
+            Service * pService = aServices[sService];
+            if (pService == 0)
+            {
+                pService = new Service(rImpl.Data(di));
+                aServices[sService] = pService;
+            }
+            ServiceInfo & rSInfo = pService->AddImplementation(sModule);
+
+            for ( unsigned n = 0; n < nNeededServicesSize; ++n )
+            {
+                unsigned nNeededDataSize = aNeededServices[n]->Size();
+                for ( unsigned dn = 0; dn < nNeededDataSize; ++dn )
+                {
+                    if (! aNeededServices[n]->Data(dn).is_no_text())
+                        rSInfo.AddDependency( ShortName(aNeededServices[n]->Data(dn)) );
+                }   // end for dn
+            }   // end for n
+        }   //  end for di
+    }   // end for i
+}
+
+void
+DependencyFinder::Add2Result( const Service & i_rService )
+{
+    const ServiceInfo & rSInfo = i_rService.FirstImplementation();
+    aResult_Libraries.insert(rSInfo.Library());
+
+    const ServiceInfo::List_NeededServices & rNeededs
+            = rSInfo.NeededServices();
+    for ( StringVector::const_iterator it = rNeededs.begin();
+          it != rNeededs.end();
+          ++it )
+    {
+        std::pair< std::set< Simstr >::iterator, bool > aInsertResult
+                = aResult_Services.insert(*it);
+        if (aInsertResult.second)
+        {   // Needed service not yet known
+            Map_Services::const_iterator itFound = aServices.find(*it);
+            if ( itFound == aServices.end() )
+            {
+                std::cerr << "Needed service \""
+                          << (*it).str()
+                          << "\" not found,"
+                          << std::endl;
+            }
+            else
+            {
+                Add2Result( *(*itFound).second );
+            }
+        }   // endif (! aInsertResult.second)
+    }   // end for (it)
+}
+
+
+
+Simstr
+ShortName(const Simstr & i_rService)
+{
+    const char * pStart = i_rService.str();
+    const char * pEnd = strchr(pStart,' ');
+    if (pEnd != 0)
+        return Simstr(pStart, 0, int(pEnd-pStart));
+    else
+        return i_rService;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xml2cmp/source/xcd/dependy.hxx b/xml2cmp/source/xcd/dependy.hxx
new file mode 100644
index 0000000..c2c2d7d
--- /dev/null
+++ b/xml2cmp/source/xcd/dependy.hxx
@@ -0,0 +1,118 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 X2C_DEPENDY_HXX
+#define X2C_DEPENDY_HXX
+
+
+#include <vector>
+#include <map>
+#include <set>
+#include <../support/sistr.hxx>
+
+class Service;
+class ServiceInfo;
+
+typedef std::vector< Simstr>            StringVector;
+typedef std::vector< ServiceInfo* >     List_Implementations;
+typedef std::map< Simstr, Service* >    Map_Services;
+
+class Service
+{
+  public:
+                        Service(
+                            const char *        i_sName );
+
+    ServiceInfo &       AddImplementation(
+                            const char *        i_sLibrary );   /// That is: module-name.
+
+    const Simstr &      Name() const            { return sName; }
+    const ServiceInfo & FirstImplementation() const
+                                                { return *aImplementations[0]; }
+
+  private:
+    Simstr              sName;
+    List_Implementations
+                        aImplementations;
+};
+
+class ServiceInfo
+{
+  public:
+    typedef StringVector List_NeededServices;
+
+                        ServiceInfo(
+                            const char *        i_sLibrary );
+
+    void                AddDependency(
+                            const char *        i_sNeededService );
+
+    const Simstr &      Library() const         { return sImplementingLibrary; }
+    const List_NeededServices &
+                        NeededServices() const  { return aNeededServices; }
+
+
+  private:
+    Simstr              sImplementingLibrary;
+    List_NeededServices aNeededServices;
+};
+
+
+class DependencyFinder
+{
+  public:
+                        DependencyFinder();
+                        ~DependencyFinder();
+
+    void                GatherData(
+                            const char *        i_sSearchDirectory );
+
+    void                FindNeededServices(
+                            StringVector &      o_rLibraries,
+                            StringVector &      o_rServices,
+                            const Simstr &      i_rService );
+  private:
+    void                ReadFile(
+                            const char *        i_sFilename );
+    void                Add2Result(
+                            const Service &     i_rService );
+
+    // Data
+    Map_Services        aServices;
+
+    // Temporary data
+    std::set< Simstr >  aResult_Libraries;
+    std::set< Simstr >  aResult_Services;
+};
+
+
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xml2cmp/source/xcd/main.cxx b/xml2cmp/source/xcd/main.cxx
index 5a42d51..ea6b140 100644
--- a/xml2cmp/source/xcd/main.cxx
+++ b/xml2cmp/source/xcd/main.cxx
@@ -41,46 +41,151 @@
 #include "parse.hxx"
 #include "../support/syshelp.hxx"
 #include "../support/heap.hxx"
+#include "dependy.hxx"
 
 
 
-int                     Do_IndexCommandLine(
-                            const CommandLine &     i_rCommandLine );
-int                     Do_SingleFileCommandLine(
-                            const CommandLine &     i_rCommandLine );
-void                    Create_TypeInfo(
-                            const char *            o_sOutputFile,
-                            ModuleDescription &     i_rData );
+void StreamOut_TypeInfo( std::ostream& o_rOut, ModuleDescription& i_rData,
+                         const char* i_sSeparator )
+{
+    Heap    aTypesHeap(12);
 
+    // Gather types:
+    List< const MultipleTextElement * > aTypes;
+    i_rData.Get_Types(aTypes);
 
-int
-#ifdef WNT
-_cdecl
-#endif
-main( int       argc,
-      char *    argv[] )
+    for ( unsigned t = 0; t < aTypes.size(); ++t )
+    {
+        unsigned i_max = aTypes[t]->Size();
+        for ( unsigned  i = 0; i < i_max; ++i )
+        {
+            aTypesHeap.InsertValue( aTypes[t]->Data(i), "" );
+        }  // end for
+    }
+
+    // Write types:
+    HeapItem * pLastHeapTop = 0;
+    for ( HeapItem * pHeapTop = aTypesHeap.ReleaseTop(); pHeapTop != 0; pHeapTop = aTypesHeap.ReleaseTop() )
+    {
+        if (pLastHeapTop != 0)
+        {
+            if ( 0 == strcmp(pHeapTop->Key(), pLastHeapTop->Key()) )
+                continue;
+            delete pLastHeapTop;
+        }
+        pLastHeapTop = pHeapTop;
+
+        WriteStr( o_rOut, i_sSeparator );
+
+        const char * sEnd = strchr( pHeapTop->Key(), ' ' );
+        if (sEnd != 0)
+        {
+            const char * sQuali = strrchr( pHeapTop->Key(), ' ' ) + 1;
+            WriteStr( o_rOut, sQuali );
+            WriteStr( o_rOut, "." );
+            o_rOut.write( pHeapTop->Key(), sEnd - pHeapTop->Key() );
+        }
+        else
+        {
+            WriteStr( o_rOut, pHeapTop->Key() );
+        }
+    }   // end for
+
+    if (pLastHeapTop != 0)
+    {
+        delete pLastHeapTop;
+        pLastHeapTop = 0;
+    }
+}
+
+void Put2StdOut_TypeInfo( ModuleDescription& i_rData )
 {
-    // Variables
-    CommandLine             aCommandLine(argc, argv);
-    int ret = 0;
+    StreamOut_TypeInfo(std::cout, i_rData, " ");
+}
 
-    if (! aCommandLine.IsOk())
+void Put2File_TypeInfo( const char* i_sOutputFile, ModuleDescription& i_rData )
+{
+    std::ofstream aOut(i_sOutputFile, std::ios::out
+#if defined(WNT)
+                                               | std::ios::binary
+#endif
+    );
+    if ( !aOut )
     {
-        std::cerr <<  aCommandLine.ErrorText() << std::endl ;
-        return 1;
+        std::cerr << "Error: " << i_sOutputFile << " could not be created." << std::endl;
+        return;
     }
 
-    if ( aCommandLine.IsIndexCommand() )
-        ret = Do_IndexCommandLine(aCommandLine);
-    else
-        ret = Do_SingleFileCommandLine(aCommandLine);
+    Simstr  sLibPrefix = i_rData.ModuleName();
+    WriteStr( aOut, sLibPrefix );
+    WriteStr( aOut, "_XML2CMPTYPES= ");
 
-    return ret;
+    StreamOut_TypeInfo(aOut, i_rData, "\t\\\n\t\t");
+
+    aOut.close();
 }
 
+void Create_TypeInfo( const char* o_sOutputFile, ModuleDescription& i_rData )
+{
+    if ( strcmp(o_sOutputFile, "stdout") == 0 )
+    {
+        Put2StdOut_TypeInfo(i_rData);
+    }
+    else
+    {
+        Put2File_TypeInfo(o_sOutputFile,i_rData);
+    }
+}
 
-int
-Do_SingleFileCommandLine(const CommandLine & i_rCommandLine)
+int Do_DepCommandLine(const CommandLine & i_rCommandLine)
+{
+DependencyFinder aDependencies;
+
+    aDependencies.GatherData(i_rCommandLine.DepPath());
+    char sInput[500] = "";
+    std::vector<Simstr>  aLibs;
+    std::vector<Simstr>  aServs;
+
+
+    std::cout
+         << "\nNow you can start to put in Service names.\n"
+         << "Please use correct case, but don't use namespaces.\n"
+         << "Just the Service's own name.\n\n"
+         << "To stop the program, put in a hashmark \"#\" + ENTER.\n"
+         << std::endl;
+
+    do
+    {
+        sInput[0] = 0;
+        std::cin >> sInput;
+        Simstr sImplService(sInput);
+        if (*sInput != '#')
+        {
+            aLibs.erase( aLibs.begin(), aLibs.end() );
+            aServs.erase( aServs.begin(), aServs.end() );
+
+            aDependencies.FindNeededServices( aLibs, aServs, sImplService );
+
+            std::cout << "\n\n\nNeeded libraries: " << std::endl;
+            for ( unsigned i = 0; i < aLibs.size(); ++i )
+            {
+                std::cout << "    " << aLibs[i].str() << std::endl;
+            }
+            std::cout << "\nNeeded services: " << std::endl;
+            for ( unsigned s= 0; s < aServs.size(); ++s )
+            {
+                std::cout << "    " << aServs[s].str() << std::endl;
+            }
+            std::cout << "\n\n" << std::endl;
+        }
+    }
+    while (*sInput != '#');
+
+    return 0;
+
+}
+
+int Do_SingleFileCommandLine(const CommandLine & i_rCommandLine)
 {
     ModuleDescription   aDescr;
     X2CParser           aParser(aDescr);
@@ -95,8 +200,7 @@ Do_SingleFileCommandLine(const CommandLine & i_rCommandLine)
 
     if ( strlen(i_rCommandLine.FuncFile()) > 0 )
     {
-        Create_AccessMethod( i_rCommandLine.FuncFile(),
-                             aParser.PureText() );
+        Create_AccessMethod( i_rCommandLine.FuncFile(), aParser.PureText() );
 
         std::cout << "File "
              << i_rCommandLine.FuncFile()
@@ -118,15 +222,13 @@ Do_SingleFileCommandLine(const CommandLine & i_rCommandLine)
 
     if (strlen(i_rCommandLine.TypeInfoFile()) > 0)
     {
-        Create_TypeInfo( i_rCommandLine.TypeInfoFile(),
-                         aDescr );
+        Create_TypeInfo( i_rCommandLine.TypeInfoFile(), aDescr );
     }
 
     return 0;
 };
 
-int
-Do_IndexCommandLine(const CommandLine & i_rCommandLine)
+int Do_IndexCommandLine(const CommandLine & i_rCommandLine)
 {
     // Parse files:
     List<Simstr>    aFiles;
@@ -148,113 +250,36 @@ Do_IndexCommandLine(const CommandLine & i_rCommandLine)
 
 
 
-//********************      Creating of typeinfo       ********************//
-
-
-void                    Put2StdOut_TypeInfo(
-                            ModuleDescription &     i_rData );
-void                    Put2File_TypeInfo(
-                            const char *            i_sOutputFile,
-                            ModuleDescription &     i_rData );
-void                    StreamOut_TypeInfo(
-                            std::ostream &               o_rOut,
-                            ModuleDescription &     i_rData,
-                            const char *            i_sSeparator );
-
-
-
 
-void
-Create_TypeInfo( const char *           o_sOutputFile,
-                 ModuleDescription &    i_rData )
-{
-    if ( strcmp(o_sOutputFile, "stdout") == 0 )
-        Put2StdOut_TypeInfo(i_rData);
-    else
-        Put2File_TypeInfo(o_sOutputFile,i_rData);
-}
-
-void
-Put2StdOut_TypeInfo( ModuleDescription &    i_rData )
+int
+#ifdef WNT
+_cdecl
+#endif
+main( int argc, char* argv[] )
 {
-    StreamOut_TypeInfo(std::cout, i_rData, " ");
-}
+    // Variables
+    CommandLine             aCommandLine(argc, argv);
+    int ret = 0;
 
-void
-Put2File_TypeInfo( const char *            i_sOutputFile,
-                   ModuleDescription &     i_rData )
-{
-    std::ofstream aOut(i_sOutputFile, std::ios::out
-#if defined(WNT)
-                                               | std::ios::binary
-#endif
-    );
-    if ( !aOut )
+    if (! aCommandLine.IsOk())
     {
-        std::cerr << "Error: " << i_sOutputFile << " could not be created." << std::endl;
-        return;
+        std::cerr <<  aCommandLine.ErrorText() << std::endl ;
+        return 1;
     }
 
-    Simstr  sLibPrefix = i_rData.ModuleName();
-    WriteStr( aOut, sLibPrefix );
-    WriteStr( aOut, "_XML2CMPTYPES= ");
-
-    StreamOut_TypeInfo(aOut, i_rData, "\t\\\n\t\t");
-
-    aOut.close();
-}
-
-void
-StreamOut_TypeInfo( std::ostream &               o_rOut,
-                    ModuleDescription &     i_rData,
-                    const char *            i_sSeparator )
-{
-    Heap    aTypesHeap(12);
-
-    // Gather types:
-    List< const MultipleTextElement * > aTypes;
-    i_rData.Get_Types(aTypes);
-
-    for ( unsigned t = 0; t < aTypes.size(); ++t )
+    if ( aCommandLine.IsIndexCommand() )
     {
-        unsigned i_max = aTypes[t]->Size();
-        for ( unsigned  i = 0; i < i_max; ++i )
-        {
-            aTypesHeap.InsertValue( aTypes[t]->Data(i), "" );
-        }  // end for
+        ret = Do_IndexCommandLine(aCommandLine);
     }
-
-    // Write types:
-    HeapItem * pLastHeapTop = 0;
-    for ( HeapItem * pHeapTop = aTypesHeap.ReleaseTop(); pHeapTop != 0; pHeapTop = aTypesHeap.ReleaseTop() )
+    else if ( aCommandLine.IsDepCommand() )
     {
-        if (pLastHeapTop != 0)
-        {
-            if ( 0 == strcmp(pHeapTop->Key(), pLastHeapTop->Key()) )
-                continue;
-            delete pLastHeapTop;
-        }
-        pLastHeapTop = pHeapTop;
-
-        WriteStr( o_rOut, i_sSeparator );
-
-        const char * sEnd = strchr( pHeapTop->Key(), ' ' );
-        if (sEnd != 0)
-        {
-            const char * sQuali = strrchr( pHeapTop->Key(), ' ' ) + 1;
-            WriteStr( o_rOut, sQuali );
-            WriteStr( o_rOut, "." );
-            o_rOut.write( pHeapTop->Key(), sEnd - pHeapTop->Key() );
-        }
-        else
-            WriteStr( o_rOut, pHeapTop->Key() );
-    }   // end for
-
-    if (pLastHeapTop != 0)
+        ret = Do_DepCommandLine(aCommandLine);
+    }
+    else
     {
-        delete pLastHeapTop;
-        pLastHeapTop = 0;
+        ret = Do_SingleFileCommandLine(aCommandLine);
     }
+    return ret;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list