File indexing completed on 2024-12-01 04:22:15

0001 # -*- coding: utf-8 -*-
0002 #     Copyright 2009-2010 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 re
0020 import kbindinggenerator.toolkit as toolkit
0021 
0022 __QtBareMacros = ["Q_OBJECT", "Q_GADGET", "Q_OBJECT_CHECK", "K_DCOP", "Q_CORE_EXPORT", "Q_INVOKABLE",
0023                     "QT_BEGIN_HEADER","QT_BEGIN_NAMESPACE", "QT_END_HEADER","QT_END_NAMESPACE"]
0024 
0025 def QtBareMacros(extraMacros=[]):
0026     macros = __QtBareMacros[:]
0027     macros.extend(extraMacros)
0028     return macros
0029     
0030 __QtMacros = [
0031         "Q_ENUMS", "Q_PROPERTY", "Q_OVERRIDE", "Q_SETS", "Q_CLASSINFO",\
0032         "Q_DECLARE_OPERATORS_FOR_FLAGS", "Q_PRIVATE_SLOT", "Q_FLAGS", \
0033         "Q_DECLARE_INTERFACE", "Q_DECLARE_METATYPE","KDE_DUMMY_COMPARISON_OPERATOR",\
0034         "Q_GADGET", "K_DECLARE_PRIVATE", "PHONON_ABSTRACTBASE", "PHONON_HEIR",\
0035         "PHONON_OBJECT", "Q_DECLARE_PRIVATE", "QT_BEGIN_HEADER", "QT_END_HEADER",\
0036         "Q_DECLARE_BUILTIN_METATYPE", "Q_OBJECT_CHECK", "Q_DECLARE_PRIVATE_MI",\
0037         "KDEUI_DECLARE_PRIVATE", "KPARTS_DECLARE_PRIVATE", "Q_INTERFACES",\
0038         '__attribute__', 'Q_DISABLE_COPY', 'K_SYCOCATYPE', 'Q_DECLARE_TR_FUNCTIONS',\
0039         'Q_DECLARE_TYPEINFO' 'Q_REQUIRED_RESULT' 'KCONFIGCORE_DEPRECATED'
0040         'KCONFIGGUI_EXPORT', 'KCOREADDONS_DEPRECATED']
0041 
0042 
0043 def QtMacros(extraMacros=[]):
0044     macros = __QtMacros[:]
0045     macros.extend(extraMacros)
0046     return macros
0047 
0048 __QtPreprocessSubstitutionMacros = [
0049         ('Q_SLOTS','slots'),
0050         ('Q_SIGNALS','signals'),
0051         (re.compile(r'Q_DECLARE_FLAGS\((.*?),(.*?)\)',re.DOTALL),r'typedef QFlags<\2> \1;'),
0052         ("KDE_CONSTRUCTOR_DEPRECATED",""),
0053         ("KDE_DEPRECATED",""),
0054         ("QT_MOC_COMPAT",""),
0055         ("Q_SCRIPTABLE",""),
0056         ("KDE_NO_DEPRECATED",""),
0057         ("KITEMVIEWS_DEPRECATED",""),
0058         ("Q_DECL_OVERRIDE", ""),
0059         ("Q_DECL_FINAL", ""),
0060         ("Q_DECL_IMPORT", ""),
0061         ("Q_REQUIRED_RESULT", ""),
0062         ("KCONFIGCORE_DEPRECATED", ""),
0063         ("KCONFIGGUI_EXPORT", ""),
0064         ("KCOREADDONS_DEPRECATED", "")
0065         ]
0066 def QtPreprocessSubstitutionMacros(extraMacros=[]):
0067     macros = __QtPreprocessSubstitutionMacros[:]
0068     macros.extend(extraMacros)
0069     return macros
0070 
0071 def copyrightNotice():
0072     return """// Copyright 2014 Simon Edwards <simon@simonzone.com>
0073 
0074 //                 Generated by twine2
0075 
0076 // This program is free software; you can redistribute it and/or modify
0077 // it under the terms of the GNU Library General Public License as
0078 // published by the Free Software Foundation; either version 2, or
0079 // (at your option) any later version.
0080 
0081 // This program is distributed in the hope that it will be useful,
0082 // but WITHOUT ANY WARRANTY; without even the implied warranty of
0083 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0084 // GNU General Public License for more details
0085 
0086 // You should have received a copy of the GNU Library General Public
0087 // License along with this program; if not, write to the
0088 // Free Software Foundation, Inc.,
0089 // 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
0090 """
0091 
0092 def annotationRules():
0093     return [
0094         toolkit.AnnotationRule(
0095             methodTypeMatch="*",
0096             parameterTypeMatch=["QWidget*","QObject*"],
0097             parameterNameMatch="parent",
0098             annotations="TransferThis"),
0099 
0100         toolkit.AnnotationRule(
0101             methodTypeMatch="ctor",
0102             parameterTypeMatch=["QWidget*","QObject*"],
0103             parameterNameMatch="pParent",
0104             annotations="TransferThis")
0105             ]