diff options
Diffstat (limited to 'sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/lib')
3 files changed, 0 insertions, 413 deletions
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 fa4d5e77c..000000000 --- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/lib/enum_sig.py +++ /dev/null @@ -1,219 +0,0 @@ -############################################################################# -## -## Copyright (C) 2020 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): - global EnumType - try: - # Lazy import - from PySide2.QtCore import Qt - EnumType = type(Qt.Key) - except ImportError: - EnumType = None - - self.fmt = formatter - self.result_type = result_type - self.fmt.level = 0 - self.fmt.after_enum = self.after_enum - self._after_enum = False - - def after_enum(self): - ret = self._after_enum - self._after_enum = False - - def module(self, mod_name): - __import__(mod_name) - self.fmt.mod_name = 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 class_name, klass in members: - ret.update(self.klass(class_name, klass)) - if isinstance(klass, EnumType): - raise SystemError("implement enum instances at module level") - for func_name, func in functions: - ret.update(self.function(func_name, func)) - return ret - - def klass(self, class_name, klass): - ret = self.result_type() - if "<" in class_name: - # This is happening in QtQuick for some reason: - ## class QSharedPointer<QQuickItemGrabResult >: - # We simply skip over this class. - return ret - bases_list = [] - for base in klass.__bases__: - name = base.__name__ - if name not in ("object", "type"): - name = base.__module__ + "." + name - bases_list.append(name) - class_str = "{}({})".format(class_name, ", ".join(bases_list)) - # class_members = inspect.getmembers(klass) - # gives us also the inherited things. - class_members = sorted(list(klass.__dict__.items())) - subclasses = [] - functions = [] - enums = [] - - for thing_name, thing in class_members: - if inspect.isclass(thing): - subclass_name = ".".join((class_name, thing_name)) - subclasses.append((subclass_name, thing)) - elif inspect.isroutine(thing): - func_name = thing_name.split(".")[0] # remove ".overload" - signature = getattr(thing, "__signature__", None) - if signature is not None: - functions.append((func_name, thing)) - elif type(type(thing)) is EnumType: - enums.append((thing_name, thing)) - init_signature = getattr(klass, "__signature__", None) - enums.sort(key=lambda tup: tup[1]) # sort by enum value - self.fmt.have_body = bool(subclasses or functions or enums or init_signature) - - with self.fmt.klass(class_name, class_str): - self.fmt.level += 1 - self.fmt.class_name = class_name - if hasattr(self.fmt, "enum"): - # this is an optional feature - for enum_name, value in enums: - with self.fmt.enum(class_name, enum_name, int(value)): - pass - for subclass_name, subclass in subclasses: - if klass == subclass: - # this is a side effect of the typing module for Python 2.7 - # via the "._gorg" property, which we can safely ignore. - print("Warning: {class_name} points to itself via {subclass_name}, skipped!" - .format(**locals())) - continue - ret.update(self.klass(subclass_name, subclass)) - self.fmt.class_name = class_name - ret.update(self.function("__init__", klass)) - for func_name, func in functions: - func_kind = get_signature(func, "__func_kind__") - modifier = func_kind if func_kind in ( - "staticmethod", "classmethod") else None - ret.update(self.function(func_name, func, modifier)) - self.fmt.level -= 1 - return ret - - def function(self, func_name, func, modifier=None): - self.fmt.level += 1 - ret = self.result_type() - signature = func.__signature__ - if signature is not None: - with self.fmt.function(func_name, signature, modifier) as key: - ret[key] = signature - self.fmt.level -= 1 - 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, modifier=None): - 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, modifier=None): - ret = self.result_type() - signature = get_signature(func, 'hintingstub') - if signature is not None: - with self.fmt.function(func_name, signature, modifier) as key: - ret[key] = signature - return ret - diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/lib/tool.py b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/lib/tool.py deleted file mode 100644 index 24e75e42c..000000000 --- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/lib/tool.py +++ /dev/null @@ -1,154 +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 - -""" -tool.py - -Some useful stuff, see below. -On the function with_metaclass see the answer from Martijn Pieters on -https://stackoverflow.com/questions/18513821/python-metaclass-understanding-the-with-metaclass -""" - -from textwrap import dedent - - -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__ - -try: - from types import SimpleNamespace -except ImportError: - pass - - -def build_brace_pattern(level, separators=""): - """ - Build a brace pattern upto a given depth - - The brace pattern parses any pattern with round, square, curly, or angle - brackets. Inside those brackets, any characters are allowed. - - The structure is quite simple and is recursively repeated as needed. - When separators are given, the match stops at that separator. - - Reason to use this instead of some Python function: - The resulting regex is _very_ fast! - - A faster replacement would be written in C, but this solution is - sufficient when the nesting level is not too large. - - Because of the recursive nature of the pattern, the size grows by a factor - of 4 at every level, as does the creation time. Up to a level of 6, this - is below 10 ms. - - There are other regex engines available which allow recursive patterns, - avoiding this problem completely. It might be considered to switch to - such an engine if the external module is not a problem. - """ - def escape(str): - return "".join("\\" + c for c in str) - - ro, rc = round = "()" - so, sc = square = "[]" - co, cc = curly = "CD" # we insert "{}", later... - ao, ac = angle = "<>" - qu, bs = '"', "\\" - all = round + square + curly + angle - __ = " " - ro, rc, so, sc, co, cc, ao, ac, separators, qu, bs, all = map( - escape, (ro, rc, so, sc, co, cc, ao, ac, separators, qu, bs, all)) - - no_brace_sep_q = r"[^{all}{separators}{qu}{bs}]".format(**locals()) - no_quote = r"(?: [^{qu}{bs}] | {bs}. )*".format(**locals()) - pattern = dedent(r""" - ( - (?: {__} {no_brace_sep_q} - | {qu} {no_quote} {qu} - | {ro} {replacer} {rc} - | {so} {replacer} {sc} - | {co} {replacer} {cc} - | {ao} {replacer} {ac} - )+ - ) - """) - no_braces_q = "[^{all}{qu}{bs}]*".format(**locals()) - repeated = dedent(r""" - {indent} (?: {__} {no_braces_q} - {indent} | {qu} {no_quote} {qu} - {indent} | {ro} {replacer} {rc} - {indent} | {so} {replacer} {sc} - {indent} | {co} {replacer} {cc} - {indent} | {ao} {replacer} {ac} - {indent} )* - """) - for idx in range(level): - pattern = pattern.format(replacer = repeated if idx < level-1 else no_braces_q, - indent = idx * " ", **locals()) - return pattern.replace("C", "{").replace("D", "}") - - -# 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', (), {}) - -# eof |