aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature')
-rw-r--r--sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/PSF-3.7.0.txt43
-rw-r--r--sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/__init__.py42
-rw-r--r--sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py141
-rw-r--r--sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/layout.py246
-rw-r--r--sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/lib/__init__.py40
-rw-r--r--sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/lib/enum_sig.py169
-rw-r--r--sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/loader.py214
-rw-r--r--sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/mapping.py674
-rw-r--r--sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/parser.py308
-rw-r--r--sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/qt_attribution.json13
10 files changed, 0 insertions, 1890 deletions
diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/PSF-3.7.0.txt b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/PSF-3.7.0.txt
deleted file mode 100644
index be42010dd..000000000
--- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/PSF-3.7.0.txt
+++ /dev/null
@@ -1,43 +0,0 @@
-PSF LICENSE AGREEMENT FOR PYTHON 3.7.0
-
-1. This LICENSE AGREEMENT is between the Python Software Foundation ("PSF"), and
- the Individual or Organization ("Licensee") accessing and otherwise using Python
- 3.7.0 software in source or binary form and its associated documentation.
-
-2. Subject to the terms and conditions of this License Agreement, PSF hereby
- grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
- analyze, test, perform and/or display publicly, prepare derivative works,
- distribute, and otherwise use Python 3.7.0 alone or in any derivative
- version, provided, however, that PSF's License Agreement and PSF's notice of
- copyright, i.e., "Copyright © 2001-2018 Python Software Foundation; All Rights
- Reserved" are retained in Python 3.7.0 alone or in any derivative version
- prepared by Licensee.
-
-3. In the event Licensee prepares a derivative work that is based on or
- incorporates Python 3.7.0 or any part thereof, and wants to make the
- derivative work available to others as provided herein, then Licensee hereby
- agrees to include in any such work a brief summary of the changes made to Python
- 3.7.0.
-
-4. PSF is making Python 3.7.0 available to Licensee on an "AS IS" basis.
- PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF
- EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY REPRESENTATION OR
- WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE
- USE OF PYTHON 3.7.0 WILL NOT INFRINGE ANY THIRD PARTY RIGHTS.
-
-5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON 3.7.0
- FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF
- MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 3.7.0, OR ANY DERIVATIVE
- THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
-
-6. This License Agreement will automatically terminate upon a material breach of
- its terms and conditions.
-
-7. Nothing in this License Agreement shall be deemed to create any relationship
- of agency, partnership, or joint venture between PSF and Licensee. This License
- Agreement does not grant permission to use PSF trademarks or trade name in a
- trademark sense to endorse or promote products or services of Licensee, or any
- third party.
-
-8. By copying, installing or otherwise using Python 3.7.0, Licensee agrees
- to be bound by the terms and conditions of this License Agreement.
diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/__init__.py b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/__init__.py
deleted file mode 100644
index ee541d0ea..000000000
--- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/__init__.py
+++ /dev/null
@@ -1,42 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2019 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is part of Qt for Python.
-##
-## $QT_BEGIN_LICENSE:LGPL$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU Lesser General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU Lesser
-## General Public License version 3 as published by the Free Software
-## Foundation and appearing in the file LICENSE.LGPL3 included in the
-## packaging of this file. Please review the following information to
-## ensure the GNU Lesser General Public License version 3 requirements
-## will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 2.0 or (at your option) the GNU General
-## Public license version 3 or any later version approved by the KDE Free
-## Qt Foundation. The licenses are as published by the Free Software
-## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-2.0.html and
-## https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
-
-from __future__ import print_function, absolute_import
-
-__all__ = "get_signature layout mapping lib".split()
diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py
deleted file mode 100644
index cb148830f..000000000
--- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/errorhandler.py
+++ /dev/null
@@ -1,141 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2019 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is part of Qt for Python.
-##
-## $QT_BEGIN_LICENSE:LGPL$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU Lesser General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU Lesser
-## General Public License version 3 as published by the Free Software
-## Foundation and appearing in the file LICENSE.LGPL3 included in the
-## packaging of this file. Please review the following information to
-## ensure the GNU Lesser General Public License version 3 requirements
-## will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 2.0 or (at your option) the GNU General
-## Public license version 3 or any later version approved by the KDE Free
-## Qt Foundation. The licenses are as published by the Free Software
-## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-2.0.html and
-## https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
-
-from __future__ import print_function, absolute_import
-
-"""
-errorhandler.py
-
-This module handles the TypeError messages which were previously
-produced by the generated C code.
-
-This version is at least consistent with the signatures, which
-are created by the same module.
-
-Experimentally, we are trying to guess those errors which are
-just the wrong number of elements in an iterator.
-At the moment, it is unclear whether the information given is
-enough to produce a useful ValueError.
-
-This matter will be improved in a later version.
-"""
-
-from shibokensupport.signature import inspect
-from shibokensupport.signature import get_signature
-from shibokensupport.signature.mapping import update_mapping, namespace
-from textwrap import dedent
-
-
-def qt_isinstance(inst, the_type):
- if the_type == float:
- return isinstance(inst, int) or isinstance(int, float)
- try:
- return isinstance(inst, the_type)
- except TypeError as e:
- print("FIXME", e)
- return False
-
-
-def matched_type(args, sigs):
- for sig in sigs:
- params = list(sig.parameters.values())
- if len(args) > len(params):
- continue
- if len(args) < len(params):
- k = len(args)
- if params[k].default is params[k].empty:
- # this is a necessary parameter, so it fails.
- continue
- ok = True
- for arg, param in zip(args, params):
- ann = param.annotation
- if qt_isinstance(arg, ann):
- continue
- ok = False
- if ok:
- return sig
- return None
-
-
-def seterror_argument(args, func_name):
- update_mapping()
- func = eval(func_name, namespace)
- sigs = get_signature(func, "typeerror")
- if type(sigs) != list:
- sigs = [sigs]
- if type(args) != tuple:
- args = (args,)
- # temp!
- found = matched_type(args, sigs)
- if found:
- msg = dedent("""
- '{func_name}' called with wrong argument values:
- {func_name}{args}
- Found signature:
- {func_name}{found}
- """.format(**locals())).strip()
- return ValueError, msg
- type_str = ", ".join(type(arg).__name__ for arg in args)
- msg = dedent("""
- '{func_name}' called with wrong argument types:
- {func_name}({type_str})
- Supported signatures:
- """.format(**locals())).strip()
- for sig in sigs:
- msg += "\n {func_name}{sig}".format(**locals())
- # We don't raise the error here, to avoid the loader in the traceback.
- return TypeError, msg
-
-
-def make_helptext(func):
- existing_doc = func.__doc__
- sigs = get_signature(func)
- if not sigs:
- return existing_doc
- if type(sigs) != list:
- sigs = [sigs]
- try:
- func_name = func.__name__
- except AttribureError:
- func_name = func.__func__.__name__
- sigtext = "\n".join(func_name + str(sig) for sig in sigs)
- msg = sigtext + "\n\n" + existing_doc if existing_doc else sigtext
- return msg
-
-# end of file
diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/layout.py b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/layout.py
deleted file mode 100644
index c43d6d076..000000000
--- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/layout.py
+++ /dev/null
@@ -1,246 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2019 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is part of Qt for Python.
-##
-## $QT_BEGIN_LICENSE:LGPL$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU Lesser General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU Lesser
-## General Public License version 3 as published by the Free Software
-## Foundation and appearing in the file LICENSE.LGPL3 included in the
-## packaging of this file. Please review the following information to
-## ensure the GNU Lesser General Public License version 3 requirements
-## will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 2.0 or (at your option) the GNU General
-## Public license version 3 or any later version approved by the KDE Free
-## Qt Foundation. The licenses are as published by the Free Software
-## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-2.0.html and
-## https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
-
-from __future__ import print_function, absolute_import
-
-"""
-layout.py
-
-The signature module now has the capability to configure
-differently formatted versions of signatures. The default
-layout is known from the "__signature__" attribute.
-
-The function "get_signature(ob, modifier=None)" produces the same
-signatures by default. By passing different modifiers, you
-can select different layouts.
-
-This module configures the different layouts which can be used.
-It also implements them in this file. The configurations are
-used literally as strings like "signature", "existence", etc.
-"""
-
-from textwrap import dedent
-from shibokensupport.signature import inspect
-from shibokensupport.signature.mapping import ellipsis
-
-
-class SimpleNamespace(object):
- # From types.rst, because the builtin is implemented in Python 3, only.
- def __init__(self, **kwargs):
- self.__dict__.update(kwargs)
-
- def __repr__(self):
- keys = sorted(self.__dict__)
- items = ("{}={!r}".format(k, self.__dict__[k]) for k in keys)
- return "{}({})".format(type(self).__name__, ", ".join(items))
-
- def __eq__(self, other):
- return self.__dict__ == other.__dict__
-
-
-class SignatureLayout(SimpleNamespace):
- """
- Configure a signature.
-
- The layout of signatures can have different layouts which are
- controlled by keyword arguments:
-
- definition=True Determines if self will generated.
- defaults=True
- ellipsis=False Replaces defaults by "...".
- return_annotation=True
- parameter_names=True False removes names before ":".
- """
- allowed_keys = SimpleNamespace(definition=True,
- defaults=True,
- ellipsis=False,
- return_annotation=True,
- parameter_names=True)
- allowed_values = True, False
-
- def __init__(self, **kwds):
- args = SimpleNamespace(**self.allowed_keys.__dict__)
- args.__dict__.update(kwds)
- self.__dict__.update(args.__dict__)
- err_keys = list(set(self.__dict__) - set(self.allowed_keys.__dict__))
- if err_keys:
- self._attributeerror(err_keys)
- err_values = list(set(self.__dict__.values()) - set(self.allowed_values))
- if err_values:
- self._valueerror(err_values)
-
- def __setattr__(self, key, value):
- if key not in self.allowed_keys.__dict__:
- self._attributeerror([key])
- if value not in self.allowed_values:
- self._valueerror([value])
- self.__dict__[key] = value
-
- def _attributeerror(self, err_keys):
- err_keys = ", ".join(err_keys)
- allowed_keys = ", ".join(self.allowed_keys.__dict__.keys())
- raise AttributeError(dedent("""\
- Not allowed: '{err_keys}'.
- The only allowed keywords are '{allowed_keys}'.
- """.format(**locals())))
-
- def _valueerror(self, err_values):
- err_values = ", ".join(map(str, err_values))
- allowed_values = ", ".join(map(str, self.allowed_values))
- raise ValueError(dedent("""\
- Not allowed: '{err_values}'.
- The only allowed values are '{allowed_values}'.
- """.format(**locals())))
-
-# The following names are used literally in this module.
-# This way, we avoid the dict hashing problem.
-signature = SignatureLayout()
-
-existence = SignatureLayout(definition=False,
- defaults=False,
- return_annotation=False,
- parameter_names=False)
-
-hintingstub = SignatureLayout(ellipsis=True)
-
-typeerror = SignatureLayout(definition=False,
- return_annotation=False,
- parameter_names=False)
-
-
-def define_nameless_parameter():
- """
- Create Nameless Parameters
-
- A nameless parameter has a reduced string representation.
- This is done by cloning the parameter type and overwriting its
- __str__ method. The inner structure is still a valid parameter.
- """
- def __str__(self):
- # for Python 2, we must change self to be an instance of P
- klass = self.__class__
- self.__class__ = P
- txt = P.__str__(self)
- self.__class__ = klass
- txt = txt[txt.index(":") + 1:].strip() if ":" in txt else txt
- return txt
-
- P = inspect.Parameter
- newname = "NamelessParameter"
- bases = P.__bases__
- body = dict(P.__dict__) # get rid of mappingproxy
- if "__slots__" in body:
- # __slots__ would create duplicates
- for name in body["__slots__"]:
- del body[name]
- body["__str__"] = __str__
- return type(newname, bases, body)
-
-
-NamelessParameter = define_nameless_parameter()
-
-
-def make_signature_nameless(signature):
- """
- Make a Signature Nameless
-
- We use an existing signature and change the type of its parameters.
- The signature looks different, but is totally intact.
- """
- for key in signature.parameters.keys():
- signature.parameters[key].__class__ = NamelessParameter
-
-
-def create_signature(props, key):
- if not props:
- # empty signatures string
- return
- if isinstance(props["multi"], list):
- # multi sig: call recursively
- return list(create_signature(elem, key)
- for elem in props["multi"])
- if type(key) is tuple:
- sig_kind, modifier = key
- else:
- sig_kind, modifier = key, "signature"
-
- layout = globals()[modifier] # lookup of the modifier in this module
- if not isinstance(layout, SignatureLayout):
- raise SystemError("Modifiers must be names of a SignatureLayout "
- "instance")
-
- # this is the basic layout of a signature
- varnames = props["varnames"]
- if layout.definition:
- if sig_kind == "function":
- pass
- elif sig_kind == "method":
- varnames = ("self",) + varnames
- elif sig_kind == "staticmethod":
- pass
- elif sig_kind == "classmethod":
- varnames = ("klass",) + varnames
- else:
- raise SystemError("Methods must be function, method, staticmethod or "
- "classmethod")
- # calculate the modifications
- defaults = props["defaults"][:]
- if not layout.defaults:
- defaults = ()
- if layout.ellipsis:
- defaults = (ellipsis,) * len(defaults)
- annotations = props["annotations"].copy()
- if not layout.return_annotation and "return" in annotations:
- del annotations["return"]
-
- # attach parameters to a fake function and build a signature
- argstr = ", ".join(varnames)
- fakefunc = eval("lambda {}: None".format(argstr))
- fakefunc.__name__ = props["name"]
- fakefunc.__defaults__ = defaults
- fakefunc.__kwdefaults__ = props["kwdefaults"]
- fakefunc.__annotations__ = annotations
- sig = inspect._signature_from_function(inspect.Signature, fakefunc)
-
- # the special case of nameless parameters
- if not layout.parameter_names:
- make_signature_nameless(sig)
- return sig
-
-# end of file
diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/lib/__init__.py b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/lib/__init__.py
deleted file mode 100644
index 2d640cb89..000000000
--- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/lib/__init__.py
+++ /dev/null
@@ -1,40 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2018 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is part of Qt for Python.
-##
-## $QT_BEGIN_LICENSE:LGPL$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU Lesser General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU Lesser
-## General Public License version 3 as published by the Free Software
-## Foundation and appearing in the file LICENSE.LGPL3 included in the
-## packaging of this file. Please review the following information to
-## ensure the GNU Lesser General Public License version 3 requirements
-## will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 2.0 or (at your option) the GNU General
-## Public license version 3 or any later version approved by the KDE Free
-## Qt Foundation. The licenses are as published by the Free Software
-## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-2.0.html and
-## https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
-
-# this file intentionally left blank
diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/lib/enum_sig.py b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/lib/enum_sig.py
deleted file mode 100644
index e6f6dc379..000000000
--- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/lib/enum_sig.py
+++ /dev/null
@@ -1,169 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2018 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is part of Qt for Python.
-##
-## $QT_BEGIN_LICENSE:LGPL$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU Lesser General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU Lesser
-## General Public License version 3 as published by the Free Software
-## Foundation and appearing in the file LICENSE.LGPL3 included in the
-## packaging of this file. Please review the following information to
-## ensure the GNU Lesser General Public License version 3 requirements
-## will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 2.0 or (at your option) the GNU General
-## Public license version 3 or any later version approved by the KDE Free
-## Qt Foundation. The licenses are as published by the Free Software
-## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-2.0.html and
-## https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
-
-from __future__ import print_function, absolute_import
-
-"""
-enum_sig.py
-
-Enumerate all signatures of a class.
-
-This module separates the enumeration process from the formatting.
-It is not easy to adhere to this protocol, but in the end, it paid off
-by producing a lot of clarity.
-"""
-
-import sys
-from shibokensupport.signature import inspect
-from shibokensupport.signature import get_signature
-
-
-class ExactEnumerator(object):
- """
- ExactEnumerator enumerates all signatures in a module as they are.
-
- This class is used for generating complete listings of all signatures.
- An appropriate formatter should be supplied, if printable output
- is desired.
- """
-
- def __init__(self, formatter, result_type=dict):
- self.fmt = formatter
- self.result_type = result_type
-
- def module(self, mod_name):
- __import__(mod_name)
- with self.fmt.module(mod_name):
- module = sys.modules[mod_name]
- members = inspect.getmembers(module, inspect.isclass)
- functions = inspect.getmembers(module, inspect.isroutine)
- ret = self.result_type()
- self.fmt.class_name = None
- for func_name, func in functions:
- ret.update(self.function(func_name, func))
- for class_name, klass in members:
- ret.update(self.klass(class_name, klass))
- return ret
-
- def klass(self, class_name, klass):
- if not "Shiboken" in repr(klass.mro()):
- # don't look into any foreign classes!
- ret = self.result_type()
- return ret
- bases_list = []
- for base in klass.__bases__:
- name = base.__name__
- if name == "object":
- pass
- else:
- modname = base.__module__
- name = modname + "." + base.__name__
- bases_list.append(name)
- class_str = "{}({})".format(class_name, ", ".join(bases_list))
- with self.fmt.klass(class_name, class_str):
- ret = self.function("__init__", klass)
- # class_members = inspect.getmembers(klass)
- # gives us also the inherited things.
- class_members = sorted(list(klass.__dict__.items()))
- subclasses = []
- for thing_name, thing in class_members:
- if inspect.isclass(thing):
- subclass_name = ".".join((class_name, thing_name))
- subclasses.append((subclass_name, thing))
- else:
- func_name = thing_name.split(".")[0] # remove ".overload"
- ret.update(self.function(func_name, thing))
- for subclass_name, subclass in subclasses:
- ret.update(self.klass(subclass_name, subclass))
- return ret
-
- def function(self, func_name, func):
- ret = self.result_type()
- signature = getattr(func, '__signature__', None)
- if signature is not None:
- with self.fmt.function(func_name, signature) as key:
- ret[key] = signature
- return ret
-
-
-def stringify(signature):
- if isinstance(signature, list):
- # remove duplicates which still sometimes occour:
- ret = set(stringify(sig) for sig in signature)
- return sorted(ret) if len(ret) > 1 else list(ret)[0]
- return tuple(str(pv) for pv in signature.parameters.values())
-
-
-class SimplifyingEnumerator(ExactEnumerator):
- """
- SimplifyingEnumerator enumerates all signatures in a module filtered.
-
- There are no default values, no variable
- names and no self parameter. Only types are present after simplification.
- The functions 'next' resp. '__next__' are removed
- to make the output identical for Python 2 and 3.
- An appropriate formatter should be supplied, if printable output
- is desired.
- """
-
- def function(self, func_name, func):
- ret = self.result_type()
- signature = get_signature(func, 'existence')
- sig = stringify(signature) if signature is not None else None
- if sig is not None and func_name not in ("next", "__next__", "__div__"):
- with self.fmt.function(func_name, sig) as key:
- ret[key] = sig
- return ret
-
-class HintingEnumerator(ExactEnumerator):
- """
- HintingEnumerator enumerates all signatures in a module slightly changed.
-
- This class is used for generating complete listings of all signatures for
- hinting stubs. Only default values are replaced by "...".
- """
-
- def function(self, func_name, func):
- ret = self.result_type()
- signature = get_signature(func, 'hintingstub')
- if signature is not None:
- with self.fmt.function(func_name, signature) as key:
- ret[key] = signature
- return ret
-
diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/loader.py b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/loader.py
deleted file mode 100644
index 6c76483a0..000000000
--- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/loader.py
+++ /dev/null
@@ -1,214 +0,0 @@
-# This Python file uses the following encoding: utf-8
-# It has been edited by fix-complaints.py .
-
-#############################################################################
-##
-## Copyright (C) 2019 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is part of Qt for Python.
-##
-## $QT_BEGIN_LICENSE:LGPL$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU Lesser General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU Lesser
-## General Public License version 3 as published by the Free Software
-## Foundation and appearing in the file LICENSE.LGPL3 included in the
-## packaging of this file. Please review the following information to
-## ensure the GNU Lesser General Public License version 3 requirements
-## will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 2.0 or (at your option) the GNU General
-## Public license version 3 or any later version approved by the KDE Free
-## Qt Foundation. The licenses are as published by the Free Software
-## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-2.0.html and
-## https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
-
-from __future__ import print_function, absolute_import
-
-"""
-loader.py
-
-The loader has to load the signature module completely at startup,
-to make sure that the functions are available when needed.
-This is meanwhile necessary to make the '__doc__' attribute work correctly.
-
-It does not mean that everything is initialized in advance. Only the modules
-are loaded completely after 'import PySide2'.
-
-This version uses both a normal directory, but has also an embedded ZIP file
-as a fallback solution. The ZIP file is generated by 'embedding_generator.py'
-and embedded into 'signature.cpp' as "embed/signature.inc".
-
-Meanwhile, the ZIP file grew so much, that MSVC had problems
-with it's 64k string limit, so we had to break the string up.
-See 'zipped_string_sequence' in signature.cpp.
-"""
-
-import sys
-import os
-import traceback
-import types
-
-# On Python 2, we only have ImportError, which is way too coarse.
-# When problems occour, please use Python 3, because it has the finer
-# ModuleNotFoundError.
-
-try:
- ModuleNotFoundError
-except NameError:
- ModuleNotFoundError = ImportError
-
-# patching inspect's formatting to keep the word "typing":
-def formatannotation(annotation, base_module=None):
- # if getattr(annotation, '__module__', None) == 'typing':
- # return repr(annotation).replace('typing.', '')
- if isinstance(annotation, type):
- if annotation.__module__ in ('builtins', base_module):
- return annotation.__qualname__
- return annotation.__module__ + '.' + annotation.__qualname__
- return repr(annotation)
-
-# patching __repr__ to disable the __repr__ of typing.TypeVar:
-"""
- def __repr__(self):
- if self.__covariant__:
- prefix = '+'
- elif self.__contravariant__:
- prefix = '-'
- else:
- prefix = '~'
- return prefix + self.__name__
-"""
-def _typevar__repr__(self):
- return "typing." + self.__name__
-
-# Note also that during the tests we have a different encoding that would
-# break the Python license decorated files without an encoding line.
-
-# name used in signature.cpp
-def create_signature(props, key):
- return layout.create_signature(props, key)
-
-# name used in signature.cpp
-def seterror_argument(args, func_name):
- return errorhandler.seterror_argument(args, func_name)
-
-# name used in signature.cpp
-def make_helptext(func):
- return errorhandler.make_helptext(func)
-
-import signature_bootstrap
-from shibokensupport import signature
-signature.get_signature = signature_bootstrap.get_signature
-del signature_bootstrap
-
-def _get_modname(mod):
- return mod.__spec__.name if getattr(mod, "__spec__", None) else mod.__name__
-
-def _set_modname(mod, name):
- if getattr(mod, "__spec__", None):
- mod.__spec__.name = name
- else:
- mod.__name__ = name
-
-
-def put_into_package(package, module, override=None):
- # take the last component of the module name
- name = (override if override else _get_modname(module)).rsplit(".", 1)[-1]
- # allow access as {package}.typing
- if package:
- setattr(package, name, module)
- # put into sys.modules as a package to allow all import options
- fullname = "{}.{}".format(_get_modname(package), name) if package else name
- _set_modname(module, fullname)
- # publish new dotted name in sys.modules
- sys.modules[fullname] = module
-
-
-# Debug: used to inspect what each step loads
-def list_modules(message):
- ext_modules = {key:value for (key, value) in sys.modules.items()
- if hasattr(value, "__file__")}
- print("SYS.MODULES", message, len(sys.modules), len(ext_modules))
- for (name, module) in sorted(ext_modules.items()):
- print(" {:23}".format(name), repr(module)[:70])
-
-
-if sys.version_info >= (3,):
- import typing
- import inspect
- inspect.formatannotation = formatannotation
-else:
- from shibokensupport import typing27 as typing
- import inspect
- namespace = inspect.__dict__
- from shibokensupport import backport_inspect as inspect
- _doc = inspect.__doc__
- inspect.__dict__.update(namespace)
- inspect.__doc__ += _doc
- # force inspect to find all attributes. See "heuristic" in pydoc.py!
- inspect.__all__ = list(x for x in dir(inspect) if not x.startswith("_"))
-typing.TypeVar.__repr__ = _typevar__repr__
-
-# Fix the module names in typing if possible. This is important since
-# the typing names should be I/O compatible, so that typing.Dict
-# shows itself as "typing.Dict".
-for name, obj in typing.__dict__.items():
- if hasattr(obj, "__module__"):
- try:
- obj.__module__ = "typing"
- except (TypeError, AttributeError):
- pass
-
-import shibokensupport
-put_into_package(shibokensupport.signature, typing, "typing")
-put_into_package(shibokensupport.signature, inspect, "inspect")
-
-
-def move_into_pyside_package():
- import PySide2
- try:
- import PySide2.support
- except ModuleNotFoundError:
- PySide2.support = types.ModuleType("PySide2.support")
- put_into_package(PySide2.support, signature)
- put_into_package(PySide2.support.signature, mapping)
- put_into_package(PySide2.support.signature, errorhandler)
- put_into_package(PySide2.support.signature, layout)
- put_into_package(PySide2.support.signature, lib)
- put_into_package(PySide2.support.signature, parser)
- put_into_package(PySide2.support.signature.lib, enum_sig)
-
- put_into_package(PySide2.support.signature, typing)
- put_into_package(PySide2.support.signature, inspect)
-
-from shibokensupport.signature import mapping
-from shibokensupport.signature import errorhandler
-from shibokensupport.signature import layout
-from shibokensupport.signature import lib
-from shibokensupport.signature import parser
-from shibokensupport.signature.lib import enum_sig
-from shibokensupport.signature.parser import pyside_type_init
-
-if "PySide2" in sys.modules:
- # We publish everything under "PySide2.support.signature", again.
- move_into_pyside_package()
-
-# end of file
diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/mapping.py b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/mapping.py
deleted file mode 100644
index 5f92446cf..000000000
--- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/mapping.py
+++ /dev/null
@@ -1,674 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2019 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is part of Qt for Python.
-##
-## $QT_BEGIN_LICENSE:LGPL$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU Lesser General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU Lesser
-## General Public License version 3 as published by the Free Software
-## Foundation and appearing in the file LICENSE.LGPL3 included in the
-## packaging of this file. Please review the following information to
-## ensure the GNU Lesser General Public License version 3 requirements
-## will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 2.0 or (at your option) the GNU General
-## Public license version 3 or any later version approved by the KDE Free
-## Qt Foundation. The licenses are as published by the Free Software
-## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-2.0.html and
-## https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
-
-from __future__ import print_function, absolute_import
-
-"""
-mapping.py
-
-This module has the mapping from the pyside C-modules view of signatures
-to the Python representation.
-
-The PySide modules are not loaded in advance, but only after they appear
-in sys.modules. This minimizes the loading overhead.
-"""
-
-import sys
-import struct
-import os
-
-from shibokensupport.signature import typing
-from shibokensupport.signature.typing import TypeVar, Generic
-
-class ellipsis(object):
- def __repr__(self):
- return "..."
-
-ellipsis = ellipsis()
-StringList = typing.List[str]
-IntList = typing.List[int]
-Point = typing.Tuple[float, float]
-PointList = typing.List[Point]
-IntMatrix = typing.List[IntList]
-Variant = typing.Any
-ModelIndexList = typing.List[int]
-QImageCleanupFunction = typing.Callable
-
-# First time installing our own Pair type into typing.
-T = TypeVar('T')
-S = TypeVar('S')
-
-class Pair(Generic[T, S]):
- __module__ = "typing"
-
-typing.Pair = Pair
-
-
-# Building our own Char type, which is much nicer than
-# Char = typing.Union[str, int] # how do I model the limitation to 1 char?
-
-# Copied from the six module:
-def with_metaclass(meta, *bases):
- """Create a base class with a metaclass."""
- # This requires a bit of explanation: the basic idea is to make a dummy
- # metaclass for one level of class instantiation that replaces itself with
- # the actual metaclass.
- class metaclass(type):
-
- def __new__(cls, name, this_bases, d):
- return meta(name, bases, d)
-
- @classmethod
- def __prepare__(cls, name, this_bases):
- return meta.__prepare__(name, bases)
- return type.__new__(metaclass, 'temporary_class', (), {})
-
-class _CharMeta(type):
- def __repr__(self):
- return '%s.%s' % (self.__module__, self.__name__)
-
-
-class Char(with_metaclass(_CharMeta)):
- """
- From http://doc.qt.io/qt-5/qchar.html :
-
- In Qt, Unicode characters are 16-bit entities without any markup or
- structure. This class represents such an entity. It is lightweight,
- so it can be used everywhere. Most compilers treat it like an
- unsigned short.
-
- Here, we provide a simple implementation just to avoid long aliases.
- """
- __module__ = "typing"
-
- def __init__(self, code):
- if isinstance(code, int):
- self.code = code & 0xffff
- else:
- self.code = ord(code)
-
- def __add__(self, other):
- return chr(self.code) + other
-
- def __radd__(self, other):
- return other + chr(self.code)
-
- def __repr__(self):
- return "typing.Char({})".format(self.code)
-
-typing.Char = Char
-
-
-MultiMap = typing.DefaultDict[str, typing.List[str]]
-
-# ulong_max is only 32 bit on windows.
-ulong_max = 2*sys.maxsize+1 if len(struct.pack("L", 1)) != 4 else 0xffffffff
-ushort_max = 0xffff
-
-GL_COLOR_BUFFER_BIT = 0x00004000
-GL_NEAREST = 0x2600
-
-WId = int
-
-# from 5.9
-GL_TEXTURE_2D = 0x0DE1
-GL_RGBA = 0x1908
-
-
-class _NotCalled(str):
- """
- Wrap some text with semantics
-
- This class is wrapped around text in order to avoid calling it.
- There are three reasons for this:
-
- - some instances cannot be created since they are abstract,
- - some can only be created after qApp was created,
- - some have an ugly __repr__ with angle brackets in it.
-
- By using derived classes, good looking instances can be created
- which can be used to generate source code or .pyi files. When the
- real object is needed, the wrapper can simply be called.
- """
- def __repr__(self):
- return "{}({})".format(type(self).__name__, self)
-
- def __call__(self):
- from shibokensupport.signature.mapping import __dict__ as namespace
- text = self if self.endswith(")") else self + "()"
- return eval(text, namespace)
-
-USE_PEP563 = sys.version_info[:2] >= (3, 7)
-
-
-# Some types are abstract. They just show their name.
-class Virtual(_NotCalled):
- pass
-
-# Other types I simply could not find.
-class Missing(_NotCalled):
- if not USE_PEP563:
- # The string must be quoted, because the object does not exist.
- def __repr__(self):
- return '{}("{}")'.format(type(self).__name__, self)
-
-
-class Invalid(_NotCalled):
- pass
-
-# Helper types
-class Default(_NotCalled):
- pass
-
-
-class Instance(_NotCalled):
- pass
-
-
-class Reloader(object):
- """
- Reloder class
-
- This is a singleton class which provides the update function for the
- shiboken and PySide classes.
- """
- def __init__(self):
- self.sys_module_count = 0
-
- @staticmethod
- def module_valid(mod):
- if getattr(mod, "__file__", None) and not os.path.isdir(mod.__file__):
- ending = os.path.splitext(mod.__file__)[-1]
- return ending not in (".py", ".pyc", ".pyo", ".pyi")
- return False
-
- def update(self):
- """
- 'update' imports all binary modules which are already in sys.modules.
- The reason is to follow all user imports without introducing new ones.
- This function is called by pyside_type_init to adapt imports
- when the number of imported modules has changed.
- """
- if self.sys_module_count == len(sys.modules):
- return
- self.sys_module_count = len(sys.modules)
- g = globals()
- # PYSIDE-1009: Try to recognize unknown modules in errorhandler.py
- candidates = list(mod_name for mod_name in sys.modules
- if self.module_valid(sys.modules[mod_name]))
- for mod_name in candidates:
- # 'top' is PySide2 when we do 'import PySide.QtCore'
- # or Shiboken if we do 'import Shiboken'.
- # Convince yourself that these two lines below have the same
- # global effect as "import Shiboken" or "import PySide2.QtCore".
- top = __import__(mod_name)
- g[top.__name__] = top
- proc_name = "init_" + mod_name.replace(".", "_")
- if proc_name in g:
- # Modules are in place, we can update the type_map.
- g.update(g.pop(proc_name)())
-
-
-def check_module(mod):
- # During a build, there exist the modules already as directories,
- # although the '*.so' was not yet created. This causes a problem
- # in Python 3, because it accepts folders as namespace modules
- # without enforcing an '__init__.py'.
- if not Reloader.module_valid(mod):
- mod_name = mod.__name__
- raise ImportError("Module '{mod_name}' is not a binary module!"
- .format(**locals()))
-
-update_mapping = Reloader().update
-type_map = {}
-namespace = globals() # our module's __dict__
-
-type_map.update({
- "QList": typing.List,
- "QVector": typing.List,
- "QSet": typing.Set,
- "QPair": Pair,
- "QMap": typing.Dict,
- })
-
-
-# The Shiboken Part
-def init_Shiboken():
- type_map.update({
- "shiboken2.bool": bool,
- "size_t": int,
- "PyType": type,
- })
- return locals()
-
-
-def init_minimal():
- type_map.update({
- "MinBool": bool,
- })
- return locals()
-
-
-def init_sample():
- import datetime
- type_map.update({
- "double": float,
- "sample.int": int,
- "Complex": complex,
- "sample.OddBool": bool,
- "sample.bool": bool,
- "sample.PStr": str,
- "OddBool": bool,
- "PStr": str,
- "char": Char,
- "sample.char": Char,
- "sample.Point": Point,
- "sample.ObjectType": object,
- "std.string": str,
- "HANDLE": int,
- "Foo.HANDLE": int,
- "sample.Photon.TemplateBase": Missing("sample.Photon.TemplateBase"),
- "ObjectType.Identifier": Missing("sample.ObjectType.Identifier"),
- "zero(HANDLE)": 0,
- "Null": None,
- "zero(sample.ObjectType)": None,
- "std.size_t": int,
- 'Str("<unknown>")': "<unknown>",
- 'Str("<unk")': "<unk",
- 'Str("nown>")': "nown>",
- "zero(sample.ObjectModel)": None,
- "sample.unsigned char": Char,
- "sample.double": float,
- "zero(sample.bool)": False,
- "PyDate": datetime.date,
- "ZeroIn": 0,
- })
- return locals()
-
-
-def init_other():
- import numbers
- type_map.update({
- "other.Number": numbers.Number,
- "other.ExtendsNoImplicitConversion": Missing("other.ExtendsNoImplicitConversion"),
- })
- return locals()
-
-
-def init_smart():
- type_map.update({
- "smart.SharedPtr": Missing("smart.SharedPtr"), # bad object "SharedPtr<Obj >"
- "smart.Smart.Integer2": int,
- })
- return locals()
-
-# The PySide Part
-def init_PySide2_QtCore():
- from PySide2.QtCore import Qt, QUrl, QDir
- from PySide2.QtCore import QRect, QSize, QPoint, QLocale, QByteArray
- from PySide2.QtCore import QMarginsF # 5.9
- try:
- # seems to be not generated by 5.9 ATM.
- from PySide2.QtCore import Connection
- except ImportError:
- pass
- type_map.update({
- "str": str,
- "int": int,
- "QString": str,
- "bool": bool,
- "PyObject": object,
- "void": int, # be more specific?
- "char": Char,
- "'%'": "%",
- "' '": " ",
- "false": False,
- "double": float,
- "'g'": "g",
- "long long": int,
- "unsigned int": int, # should we define an unsigned type?
- "Q_NULLPTR": None,
- "long": int,
- "float": float,
- "short": int,
- "unsigned long": int,
- "unsigned long long": int,
- "unsigned short": int,
- "QStringList": StringList,
- "QChar": Char,
- "signed char": Char,
- "QVariant": Variant,
- "QVariant.Type": type, # not so sure here...
- "QStringRef": str,
- "QString()": "",
- "QModelIndexList": ModelIndexList,
- "unsigned char": Char,
- "QJsonObject": typing.Dict[str, PySide2.QtCore.QJsonValue],
- "QStringList()": [],
- "ULONG_MAX": ulong_max,
- "quintptr": int,
- "PyCallable": typing.Callable,
- "PyTypeObject": type,
- "PySequence": typing.Iterable, # important for numpy
- "qptrdiff": int,
- "true": True,
- "Qt.HANDLE": int, # be more explicit with some consts?
- "list of QAbstractState": typing.List[PySide2.QtCore.QAbstractState],
- "list of QAbstractAnimation": typing.List[PySide2.QtCore.QAbstractAnimation],
- "QVariant()": Invalid(Variant),
- "PySide2.QtCore.bool": bool,
- "QHash": typing.Dict,
- "PySide2.QtCore.QChar": Char,
- "PySide2.QtCore.qreal": float,
- "PySide2.QtCore.float": float,
- "PySide2.QtCore.qint16": int,
- "PySide2.QtCore.qint32": int,
- "PySide2.QtCore.qint64": int,
- "PySide2.QtCore.qint8": int,
- "PySide2.QtCore.QString": str,
- "PySide2.QtCore.QStringList": StringList,
- "PySide2.QtCore.QVariant": Variant,
- "PySide2.QtCore.quint16": int,
- "PySide2.QtCore.quint32": int,
- "PySide2.QtCore.quint64": int,
- "PySide2.QtCore.quint8": int,
- "PySide2.QtCore.short": int,
- "PySide2.QtCore.unsigned short": int,
- "PySide2.QtCore.signed char": Char,
- "PySide2.QtCore.uchar": Char,
- "PySide2.QtCore.unsigned char": Char, # 5.9
- "PySide2.QtCore.long": int,
- "PySide2.QtCore.QUrl.ComponentFormattingOptions":
- PySide2.QtCore.QUrl.ComponentFormattingOption, # mismatch option/enum, why???
- "QUrl.FormattingOptions(PrettyDecoded)": Instance(
- "QUrl.FormattingOptions(QUrl.PrettyDecoded)"),
- # from 5.9
- "QDir.Filters(AllEntries | NoDotAndDotDot)": Instance(
- "QDir.Filters(QDir.AllEntries | QDir.NoDotAndDotDot)"),
- "NULL": None, # 5.6, MSVC
- "QDir.SortFlags(Name | IgnoreCase)": Instance(
- "QDir.SortFlags(QDir.Name | QDir.IgnoreCase)"),
- "PyBytes": bytes,
- "PyByteArray": bytearray,
- "PyUnicode": typing.Text,
- "signed long": int,
- "PySide2.QtCore.int": int,
- "PySide2.QtCore.char": StringList, # A 'char **' is a list of strings.
- "unsigned long int": int, # 5.6, RHEL 6.6
- "unsigned short int": int, # 5.6, RHEL 6.6
- "4294967295UL": 4294967295, # 5.6, RHEL 6.6
- "PySide2.QtCore.int32_t": int, # 5.9
- "PySide2.QtCore.int64_t": int, # 5.9
- "UnsignedShortType": int, # 5.9
- "nullptr": None, # 5.9
- "uint64_t": int, # 5.9
- "PySide2.QtCore.uint32_t": int, # 5.9
- "PySide2.QtCore.unsigned int": int, # 5.9 Ubuntu
- "PySide2.QtCore.long long": int, # 5.9, MSVC 15
- "QGenericArgument(nullptr)": ellipsis, # 5.10
- "QModelIndex()": Invalid("PySide2.QtCore.QModelIndex"), # repr is btw. very wrong, fix it?!
- "QGenericArgument((0))": ellipsis, # 5.6, RHEL 6.6. Is that ok?
- "QGenericArgument()": ellipsis,
- "QGenericArgument(0)": ellipsis,
- "QGenericArgument(NULL)": ellipsis, # 5.6, MSVC
- "QGenericArgument(Q_NULLPTR)": ellipsis,
- "zero(PySide2.QtCore.QObject)": None,
- "zero(PySide2.QtCore.QThread)": None,
- "zero(quintptr)": 0,
- "zero(str)": "",
- "zero(int)": 0,
- "zero(PySide2.QtCore.QState)": None,
- "zero(PySide2.QtCore.bool)": False,
- "zero(PySide2.QtCore.int)": 0,
- "zero(void)": None,
- "zero(long long)": 0,
- "zero(PySide2.QtCore.QAbstractItemModel)": None,
- "zero(PySide2.QtCore.QJsonParseError)": None,
- "zero(double)": 0.0,
- "zero(PySide2.QtCore.qint64)": 0,
- "zero(PySide2.QtCore.QTextCodec.ConverterState)": None,
- "zero(long long)": 0,
- "zero(QImageCleanupFunction)": None,
- "zero(unsigned int)": 0,
- "zero(PySide2.QtCore.QPoint)": Default("PySide2.QtCore.QPoint"),
- "zero(unsigned char)": 0,
- "zero(PySide2.QtCore.QEvent.Type)": None,
- "CheckIndexOption.NoOption": Instance(
- "PySide2.QtCore.QAbstractItemModel.CheckIndexOptions.NoOption"), # 5.11
- "QVariantMap": typing.Dict[str, Variant],
- "PySide2.QtCore.QCborStreamReader.StringResult": typing.AnyStr,
- "PySide2.QtCore.double": float,
- })
- try:
- type_map.update({
- "PySide2.QtCore.QMetaObject.Connection": PySide2.QtCore.Connection, # wrong!
- })
- except AttributeError:
- # this does not exist on 5.9 ATM.
- pass
- return locals()
-
-
-def init_PySide2_QtGui():
- from PySide2.QtGui import QPageLayout, QPageSize # 5.12 macOS
- type_map.update({
- "QVector< QTextLayout.FormatRange >()": [], # do we need more structure?
- "USHRT_MAX": ushort_max,
- "0.0f": 0.0,
- "1.0f": 1.0,
- "uint32_t": int,
- "uint8_t": int,
- "int32_t": int,
- "GL_COLOR_BUFFER_BIT": GL_COLOR_BUFFER_BIT,
- "GL_NEAREST": GL_NEAREST,
- "WId": WId,
- "PySide2.QtGui.QPlatformSurface": int, # a handle
- "QList< QTouchEvent.TouchPoint >()": [], # XXX improve?
- "QPixmap()": Default("PySide2.QtGui.QPixmap"), # can't create without qApp
- "PySide2.QtCore.uint8_t": int, # macOS 5.9
- "zero(uint32_t)": 0,
- "zero(PySide2.QtGui.QWindow)": None,
- "zero(PySide2.QtGui.QOpenGLContext)": None,
- "zero(PySide2.QtGui.QRegion)": None,
- "zero(PySide2.QtGui.QPaintDevice)": None,
- "zero(PySide2.QtGui.QTextLayout.FormatRange)": None,
- "zero(PySide2.QtGui.QTouchDevice)": None,
- "zero(PySide2.QtGui.QScreen)": None,
- "PySide2.QtGui.QGenericMatrix": Missing("PySide2.QtGui.QGenericMatrix"),
- })
- return locals()
-
-
-def init_PySide2_QtWidgets():
- from PySide2.QtWidgets import QWidget, QMessageBox, QStyleOption, QStyleHintReturn, QStyleOptionComplex
- from PySide2.QtWidgets import QGraphicsItem, QStyleOptionGraphicsItem # 5.9
- type_map.update({
- "QMessageBox.StandardButtons(Yes | No)": Instance(
- "QMessageBox.StandardButtons(QMessageBox.Yes | QMessageBox.No)"),
- "QWidget.RenderFlags(DrawWindowBackground | DrawChildren)": Instance(
- "QWidget.RenderFlags(QWidget.DrawWindowBackground | QWidget.DrawChildren)"),
- "static_cast<Qt.MatchFlags>(Qt.MatchExactly|Qt.MatchCaseSensitive)": Instance(
- "Qt.MatchFlags(Qt.MatchExactly | Qt.MatchCaseSensitive)"),
- "QVector< int >()": [],
- "WId": WId,
- # from 5.9
- "Type": PySide2.QtWidgets.QListWidgetItem.Type,
- "SO_Default": QStyleOption.SO_Default,
- "SH_Default": QStyleHintReturn.SH_Default,
- "SO_Complex": QStyleOptionComplex.SO_Complex,
- "zero(PySide2.QtWidgets.QWidget)": None,
- "zero(PySide2.QtWidgets.QGraphicsItem)": None,
- "zero(PySide2.QtCore.QEvent)": None,
- "zero(PySide2.QtWidgets.QStyleOption)": None,
- "zero(PySide2.QtWidgets.QStyleHintReturn)": None,
- "zero(PySide2.QtWidgets.QGraphicsLayoutItem)": None,
- "zero(PySide2.QtWidgets.QListWidget)": None,
- "zero(PySide2.QtGui.QKeySequence)": None,
- "zero(PySide2.QtWidgets.QAction)": None,
- "zero(PySide2.QtWidgets.QUndoCommand)": None,
- "zero(WId)": 0,
- })
- return locals()
-
-
-def init_PySide2_QtSql():
- from PySide2.QtSql import QSqlDatabase
- type_map.update({
- "QLatin1String(defaultConnection)": QSqlDatabase.defaultConnection,
- "QVariant.Invalid": Invalid("Variant"), # not sure what I should create, here...
- })
- return locals()
-
-
-def init_PySide2_QtNetwork():
- type_map.update({
- "QMultiMap": MultiMap,
- "zero(unsigned short)": 0,
- "zero(PySide2.QtCore.QIODevice)": None,
- "zero(QList)": [],
- })
- return locals()
-
-
-def init_PySide2_QtXmlPatterns():
- from PySide2.QtXmlPatterns import QXmlName
- type_map.update({
- "QXmlName.PrefixCode": Missing("PySide2.QtXmlPatterns.QXmlName.PrefixCode"),
- "QXmlName.NamespaceCode": Missing("PySide2.QtXmlPatterns.QXmlName.NamespaceCode")
- })
- return locals()
-
-
-def init_PySide2_QtMultimedia():
- import PySide2.QtMultimediaWidgets
- # Check if foreign import is valid. See mapping.py in shiboken2.
- check_module(PySide2.QtMultimediaWidgets)
- type_map.update({
- "QGraphicsVideoItem": PySide2.QtMultimediaWidgets.QGraphicsVideoItem,
- "QVideoWidget": PySide2.QtMultimediaWidgets.QVideoWidget,
- })
- return locals()
-
-
-def init_PySide2_QtOpenGL():
- type_map.update({
- "GLuint": int,
- "GLenum": int,
- "GLint": int,
- "GLbitfield": int,
- "PySide2.QtOpenGL.GLint": int,
- "PySide2.QtOpenGL.GLuint": int,
- "GLfloat": float, # 5.6, MSVC 15
- "zero(PySide2.QtOpenGL.QGLContext)": None,
- "zero(GLenum)": 0,
- "zero(PySide2.QtOpenGL.QGLWidget)": None,
- })
- return locals()
-
-
-def init_PySide2_QtQml():
- type_map.update({
- "QJSValueList()": [],
- "PySide2.QtQml.bool volatile": bool,
- # from 5.9
- "QVariantHash()": typing.Dict[str, Variant], # XXX sorted?
- "zero(PySide2.QtQml.QQmlContext)": None,
- "zero(PySide2.QtQml.QQmlEngine)": None,
- })
- return locals()
-
-
-def init_PySide2_QtQuick():
- type_map.update({
- "PySide2.QtQuick.QSharedPointer": int,
- "PySide2.QtCore.uint": int,
- "T": int,
- "zero(PySide2.QtQuick.QQuickItem)": None,
- "zero(GLuint)": 0,
- })
- return locals()
-
-
-def init_PySide2_QtScript():
- type_map.update({
- "QScriptValueList()": [],
- })
- return locals()
-
-
-def init_PySide2_QtTest():
- type_map.update({
- "PySide2.QtTest.QTouchEventSequence": PySide2.QtTest.QTest.QTouchEventSequence,
- })
- return locals()
-
-# from 5.9
-def init_PySide2_QtWebEngineWidgets():
- type_map.update({
- "zero(PySide2.QtWebEngineWidgets.QWebEnginePage.FindFlags)": 0,
- })
- return locals()
-
-# from 5.6, MSVC
-def init_PySide2_QtWinExtras():
- type_map.update({
- "QList< QWinJumpListItem* >()": [],
- })
- return locals()
-
-# from 5.12, macOS
-def init_PySide2_QtDataVisualization():
- from PySide2.QtDataVisualization import QtDataVisualization
- QtDataVisualization.QBarDataRow = typing.List[QtDataVisualization.QBarDataItem]
- QtDataVisualization.QBarDataArray = typing.List[QtDataVisualization.QBarDataRow]
- QtDataVisualization.QSurfaceDataRow = typing.List[QtDataVisualization.QSurfaceDataItem]
- QtDataVisualization.QSurfaceDataArray = typing.List[QtDataVisualization.QSurfaceDataRow]
- type_map.update({
- "100.0f": 100.0,
- })
- return locals()
-
-
-def init_testbinding():
- type_map.update({
- "testbinding.PySideCPP2.TestObjectWithoutNamespace": testbinding.TestObjectWithoutNamespace,
- })
- return locals()
-
-# end of file
diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/parser.py b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/parser.py
deleted file mode 100644
index 72ca35757..000000000
--- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/parser.py
+++ /dev/null
@@ -1,308 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2019 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is part of Qt for Python.
-##
-## $QT_BEGIN_LICENSE:LGPL$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU Lesser General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU Lesser
-## General Public License version 3 as published by the Free Software
-## Foundation and appearing in the file LICENSE.LGPL3 included in the
-## packaging of this file. Please review the following information to
-## ensure the GNU Lesser General Public License version 3 requirements
-## will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 2.0 or (at your option) the GNU General
-## Public license version 3 or any later version approved by the KDE Free
-## Qt Foundation. The licenses are as published by the Free Software
-## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-2.0.html and
-## https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
-
-from __future__ import print_function, absolute_import
-
-import sys
-import re
-import warnings
-import types
-import keyword
-import functools
-from shibokensupport.signature.mapping import (type_map, update_mapping,
- namespace, typing, _NotCalled)
-
-_DEBUG = False
-LIST_KEYWORDS = False
-
-"""
-parser.py
-
-This module parses the signature text and creates properties for the
-signature objects.
-
-PySide has a new function 'CppGenerator::writeSignatureInfo()'
-that extracts the gathered information about the function arguments
-and defaults as good as it can. But what PySide generates is still
-very C-ish and has many constants that Python doesn't understand.
-
-The function 'try_to_guess()' below understands a lot of PySide's
-peculiar way to assume local context. If it is able to do the guess,
-then the result is inserted into the dict, so the search happens
-not again. For everything that is not covered by these automatic
-guesses, we provide an entry in 'type_map' that resolves it.
-
-In effect, 'type_map' maps text to real Python objects.
-"""
-
-def dprint(*args, **kw):
- if _DEBUG:
- import pprint
- for arg in args:
- pprint.pprint(arg)
- sys.stdout.flush()
-
-def _parse_line(line):
- line_re = r"""
- ((?P<multi> ([0-9]+)) : )? # the optional multi-index
- (?P<funcname> \w+(\.\w+)*) # the function name
- \( (?P<arglist> .*?) \) # the argument list
- ( -> (?P<returntype> .*) )? # the optional return type
- $
- """
- ret = re.match(line_re, line, re.VERBOSE).groupdict()
- arglist = ret["arglist"]
- # The following is a split re. The string is broken into pieces which are
- # between the recognized strings. Because the re has groups, both the
- # strings and the delimiters are returned, where the strings are not
- # interesting at all: They are just the commata.
- # Note that it is necessary to put the characters with special handling in
- # the first group (comma, brace, angle bracket).
- # Then they are not recognized there, and we can handle them differently
- # in the following expressions.
- arglist = list(x.strip() for x in re.split(r"""
- (
- (?: # inner group is not capturing
- [^,()<>] # no commas or braces or angle brackets
- |
- \(
- (?:
- [^()]* # or one brace pair
- |
- \(
- [^()]* # or doubls nested pair
- \)
- )*
- \)
- |
- < # or one angle bracket pair
- [^<>]*
- >
- )+ # longest possible span
- ) # this list is interspersed with "," and surrounded by ""
- """, arglist, flags=re.VERBOSE)
- if x.strip() not in ("", ","))
- args = []
- for arg in arglist:
- name, ann = arg.split(":")
- if name in keyword.kwlist:
- if LIST_KEYWORDS:
- print("KEYWORD", ret)
- name = name + "_"
- if "=" in ann:
- ann, default = ann.split("=")
- tup = name, ann, default
- else:
- tup = name, ann
- args.append(tup)
- ret["arglist"] = args
- multi = ret["multi"]
- if multi is not None:
- ret["multi"] = int(multi)
- funcname = ret["funcname"]
- parts = funcname.split(".")
- if parts[-1] in keyword.kwlist:
- ret["funcname"] = funcname + "_"
- return ret
-
-def make_good_value(thing, valtype):
- try:
- if thing.endswith("()"):
- thing = 'Default("{}")'.format(thing[:-2])
- else:
- ret = eval(thing, namespace)
- if valtype and repr(ret).startswith("<"):
- thing = 'Instance("{}")'.format(thing)
- return eval(thing, namespace)
- except Exception:
- pass
-
-def try_to_guess(thing, valtype):
- if "." not in thing and "(" not in thing:
- text = "{}.{}".format(valtype, thing)
- ret = make_good_value(text, valtype)
- if ret is not None:
- return ret
- typewords = valtype.split(".")
- valwords = thing.split(".")
- braceless = valwords[0] # Yes, not -1. Relevant is the overlapped word.
- if "(" in braceless:
- braceless = braceless[:braceless.index("(")]
- for idx, w in enumerate(typewords):
- if w == braceless:
- text = ".".join(typewords[:idx] + valwords)
- ret = make_good_value(text, valtype)
- if ret is not None:
- return ret
- return None
-
-def _resolve_value(thing, valtype, line):
- if thing in ("0", "None") and valtype:
- thing = "zero({})".format(valtype)
- if thing in type_map:
- return type_map[thing]
- res = make_good_value(thing, valtype)
- if res is not None:
- type_map[thing] = res
- return res
- res = try_to_guess(thing, valtype) if valtype else None
- if res is not None:
- type_map[thing] = res
- return res
- warnings.warn("""pyside_type_init:
-
- UNRECOGNIZED: {!r}
- OFFENDING LINE: {!r}
- """.format(thing, line), RuntimeWarning)
- return thing
-
-def _resolve_arraytype(thing, line):
- thing = thing[:-2]
- if thing.endswith("[]"):
- thing = _resolve_arraytype(thing, line)
- # this mapping is in shiboken
- thing = "QList[" + thing + "]"
- return thing
-
-def to_string(thing):
- if isinstance(thing, str):
- return thing
- if hasattr(thing, "__name__"):
- dot = "." in str(type(thing))
- return thing.__module__ + "." + thing.__name__ if dot else thing.__name__
- # Note: This captures things from the typing module:
- return str(thing)
-
-def _resolve_type(thing, line):
- if thing.endswith("[]"):
- thing = _resolve_arraytype(thing, line)
- if "[" in thing:
- # Handle a container return type. (see PYSIDE-921 in cppgenerator.cpp)
- contr, thing = re.match(r"(.*?)\[(.*?)\]$", thing).groups()
- contr = to_string(_resolve_type(contr, line))
- thing = to_string(_resolve_type(thing, line))
- result = "{contr}[{thing}]".format(**locals())
- if not isinstance(thing, _NotCalled):
- result = eval(result, namespace)
- return result
- return _resolve_value(thing, None, line)
-
-def calculate_props(line):
- res = _parse_line(line)
- arglist = res["arglist"]
- annotations = {}
- _defaults = []
- for idx, tup in enumerate(arglist):
- name, ann = tup[:2]
- if ann == "...":
- name = "*args"
- # copy the fields back :()
- ann = 'NULL' # maps to None
- tup = name, ann
- arglist[idx] = tup
- annotations[name] = _resolve_type(ann, line)
- if len(tup) == 3:
- default = _resolve_value(tup[2], ann, line)
- _defaults.append(default)
- defaults = tuple(_defaults)
- returntype = res["returntype"]
- if returntype is not None:
- annotations["return"] = _resolve_type(returntype, line)
- props = {}
- props["defaults"] = defaults
- props["kwdefaults"] = {}
- props["annotations"] = annotations
- props["varnames"] = varnames = tuple(tup[0] for tup in arglist)
- funcname = res["funcname"]
- props["fullname"] = funcname
- shortname = funcname[funcname.rindex(".")+1:]
- props["name"] = shortname
- props["multi"] = res["multi"]
- return props
-
-def fixup_multilines(lines):
- res = []
- multi_lines = []
- for line in lines:
- multi = re.match(r"([0-9]+):", line)
- if multi:
- idx, rest = int(multi.group(1)), line[multi.end():]
- multi_lines.append(rest)
- if idx > 0:
- continue
- # remove duplicates
- multi_lines = sorted(set(multi_lines))
- # renumber or return a single line
- nmulti = len(multi_lines)
- if nmulti > 1:
- for idx, line in enumerate(multi_lines):
- res.append("{}:{}".format(nmulti-idx-1, line))
- else:
- res.append(multi_lines[0])
- multi_lines = []
- else:
- res.append(line)
- return res
-
-def pyside_type_init(type_key, sig_strings):
- dprint()
- dprint("Initialization of type key '{}'".format(type_key))
- update_mapping()
- lines = fixup_multilines(sig_strings)
- ret = {}
- multi_props = []
- for line in lines:
- props = calculate_props(line)
- shortname = props["name"]
- multi = props["multi"]
- if multi is None:
- ret[shortname] = props
- dprint(props)
- else:
- multi_props.append(props)
- if multi > 0:
- continue
- fullname = props.pop("fullname")
- multi_props = {"multi": multi_props, "fullname": fullname}
- ret[shortname] = multi_props
- dprint(multi_props)
- multi_props = []
- return ret
-
-# end of file
diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/qt_attribution.json b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/qt_attribution.json
deleted file mode 100644
index fbe4c51ab..000000000
--- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/qt_attribution.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "Id": "python",
- "Name": "Python",
- "QDocModule": "QtForPython",
- "QtUsage": "Used for Qt for Python in the signature extension.",
- "Description": "Qt for Python is an add-on for Python. The signature packages of PySide uses certain copied and adapted source files (backport_inspect.py, typing27.py). See the folder sources/shiboken2/files.dir/shibokensupport/signature .",
- "Homepage": "http://www.python.org/",
- "Version": "3.7.0",
- "LicenseId": "Python-2.0",
- "License": "Python License 2.0",
- "LicenseFile": "PSF-3.7.0.txt",
- "Copyright": "© Copyright 2001-2018, Python Software Foundation."
-}