File indexing completed on 2024-12-08 04:20:22

0001 # -*- coding: utf-8 -*-
0002 #     Copyright 2009 Simon Edwards <simon@simonzone.com>
0003 #
0004 # This program is free software; you can redistribute it and/or modify
0005 # it under the terms of the GNU General Public License as published by
0006 # the Free Software Foundation; either version 2 of the License, or
0007 # (at your option) any later version.
0008 #
0009 # This program is distributed in the hope that it will be useful,
0010 # but WITHOUT ANY WARRANTY; without even the implied warranty of
0011 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012 # GNU General Public License for more details.
0013 #
0014 # You should have received a copy of the GNU General Public License
0015 # along with this program; if not, write to the
0016 # Free Software Foundation, Inc.,
0017 # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0018 
0019 import kbindinggenerator.toolkit
0020 import kbindinggenerator.qtkdemacros
0021 import os.path
0022 import kbindinggenerator.sipsymboldata
0023 import re
0024 
0025 outputBaseDirectory = "/home/sbe/devel/git/kde/marble"
0026 cmakelistBaseDirectory = outputBaseDirectory
0027 pyqt4SipDir = "/home/sbe/devel/kdesvninstall/share/sip/PyQt4/"
0028 
0029 ###########################################################################
0030 marble = toolkit.ModuleGenerator(
0031     module="PyKDE4.marble",
0032     outputDirectory=os.path.join(outputBaseDirectory,"src/bindings/python/sip"),
0033     docsOutputDirectory=os.path.join(outputBaseDirectory, "docs/bindings/python/html/marble"),
0034     mainDocs=os.path.join(outputBaseDirectory,"Mainpage.dox"),
0035     
0036     # .h file extraction
0037     cmakelists=[os.path.join(cmakelistBaseDirectory,"src/lib/marble/CMakeLists.txt"),
0038                 os.path.join(cmakelistBaseDirectory,"src/lib/marble/geodata/CMakeLists.txt")],
0039     
0040     ignoreHeaders="""marble_export.h geodata_export.h TileCreatorDialog.h GeoDataCoordinates_p.h AbstractProjectionHelper.h EquirectProjection.h EquirectProjectionHelper.h MercatorProjection.h MercatorProjectionHelper.h SphericalProjection.h SphericalProjectionHelper.h MapThemeSortFilterProxyModel.h ExtDateTime.h MarbleWidgetInputHandler.h BoundingBox.h GeoDataDocument_p.h GeoDataMultiGeometry_p.h GeoDataPoint_p.h GeoDataFeature_p.h GeoDataLinearRing_p.h GeoDataLookAt_p.h GeoDataRegion_p.h GeoDataPlacemark_p.h GeoDataLineString_p.h GeoDataContainer_p.h GeoDataPolygon_p.h GeoDataGeometry_p.h GeoDataLod_p.h RoutingManager.h RoutingWidget.h global.h""".split(" "),
0041 
0042     #noUpdateSip=["phononnamespace.sip"],
0043     ignoreBases=["QSharedData"],
0044     
0045     # Cpp parsing    
0046     preprocessSubstitutionMacros=qtkdemacros.QtPreprocessSubstitutionMacros([
0047         (re.compile(r'MARBLE_DEPRECATED\((.*?)\);',re.DOTALL),r'\1;'),
0048         ]),
0049     preprocessorValues={"Q_WS_X11": 1, "QT_VERSION": "0x040400"},
0050     
0051     macros=qtkdemacros.QtMacros(),
0052     bareMacros=qtkdemacros.QtBareMacros(["MARBLE_EXPORT","GEODATA_EXPORT"]),
0053     
0054     # Sip generation
0055     sipImportDirs=[pyqt4SipDir,os.path.join(outputBaseDirectory,"sip")],
0056     sipImports=["QtCore/QtCoremod.sip","QtGui/QtGuimod.sip","QtWebKit/QtWebKitmod.sip","QtXml/QtXmlmod.sip"],
0057     
0058     copyrightNotice=qtkdemacros.copyrightNotice(),
0059     exportMacros=["MARBLE_EXPORT","GEODATA_EXPORT","KDE_EXPORT"],
0060     noCTSCC=["GeoPainter","ClipPainter","RenderPluginInterface"],
0061     
0062     annotationRules=[
0063         toolkit.AnnotationRule(
0064             methodTypeMatch="ctor",
0065             parameterTypeMatch=["QWidget*","QObject*"],
0066             parameterNameMatch=["parent"],
0067             annotations="TransferThis"),
0068             
0069         toolkit.AnnotationRule(
0070             methodTypeMatch="ctor",
0071             parameterTypeMatch=["QWidget*","QObject*"],
0072             parameterNameMatch=["pParent"],
0073             annotations="TransferThis"),
0074             
0075         toolkit.AnnotationRule(
0076             methodTypeMatch="function",
0077             parameterTypeMatch=["QWidget*","QObject*"],
0078             parameterNameMatch="parent",
0079             annotations="Transfer")
0080         ]
0081     )
0082 
0083 ###########################################################################
0084 marble.run()
0085 
0086 classNames = []
0087 nsNames = []
0088 
0089 def UpdateClassNamespaceList(moduleName,sipScopes):
0090     nsNames.append( (moduleName,'global', 'global') )
0091     def ExtractClassNamespace(scope):
0092         for item in scope:
0093             if isinstance(item,sipsymboldata.SymbolData.SipClass):
0094                 classNames.append( (moduleName, item.fqPythonName(), item.fqPythonName()) )
0095                 ExtractClassNamespace(item)
0096             elif isinstance(item,sipsymboldata.SymbolData.Namespace):
0097                 nsTuple = (moduleName,item.fqPythonName(),item.fqPythonName())
0098                 if nsTuple not in nsNames:
0099                     nsNames.append( nsTuple )
0100                 ExtractClassNamespace(item)
0101     for scope in sipScopes:
0102         ExtractClassNamespace(scope)
0103 
0104 UpdateClassNamespaceList('marble',marble.docs())
0105 print("Writing all classes index:")
0106 toolkit.ModuleGenerator.WriteAllClasses(os.path.join(outputBaseDirectory,"docs/bindings/python/html"),nsNames,classNames)
0107 print("Done")
0108