Remove unused functions in Python builtin mode
This commit is contained in:
parent
9c67a2c007
commit
a12fc916e4
1 changed files with 47 additions and 44 deletions
|
|
@ -712,9 +712,11 @@ public:
|
|||
Printv(default_import_code, tab4, "from ", module, " import *\n", NULL);
|
||||
}
|
||||
|
||||
/* Need builtins to qualify names like Exception that might also be
|
||||
defined in this module (try both Python 3 and Python 2 names) */
|
||||
Printv(f_shadow, "try:\n", tab4, "import builtins as __builtin__\n", "except ImportError:\n", tab4, "import __builtin__\n", NULL);
|
||||
if (!builtin) {
|
||||
/* Need builtins to qualify names like Exception that might also be
|
||||
defined in this module (try both Python 3 and Python 2 names) */
|
||||
Printv(f_shadow, "try:\n", tab4, "import builtins as __builtin__\n", "except ImportError:\n", tab4, "import __builtin__\n", NULL);
|
||||
}
|
||||
|
||||
if (!builtin && fastproxy) {
|
||||
Printf(f_shadow, "\n");
|
||||
|
|
@ -722,53 +724,54 @@ public:
|
|||
Printf(f_shadow, "_swig_new_static_method = %s.SWIG_PyStaticMethod_New\n", module);
|
||||
}
|
||||
|
||||
Printv(f_shadow, "\n",
|
||||
"def _swig_repr(self):\n",
|
||||
tab4, "try:\n",
|
||||
tab4, tab4, "strthis = \"proxy of \" + self.this.__repr__()\n",
|
||||
tab4, "except __builtin__.Exception:\n",
|
||||
tab4, tab4, "strthis = \"\"\n",
|
||||
tab4, "return \"<%s.%s; %s >\" % (self.__class__.__module__, self.__class__.__name__, strthis,)\n\n", NIL);
|
||||
if (!builtin) {
|
||||
Printv(f_shadow, "\n",
|
||||
"def _swig_repr(self):\n",
|
||||
tab4, "try:\n",
|
||||
tab4, tab4, "strthis = \"proxy of \" + self.this.__repr__()\n",
|
||||
tab4, "except __builtin__.Exception:\n",
|
||||
tab4, tab4, "strthis = \"\"\n",
|
||||
tab4, "return \"<%s.%s; %s >\" % (self.__class__.__module__, self.__class__.__name__, strthis,)\n\n", NIL);
|
||||
|
||||
Printv(f_shadow, "\n",
|
||||
"def _swig_setattr_nondynamic_instance_variable(set):\n",
|
||||
tab4, "def set_instance_attr(self, name, value):\n",
|
||||
tab4, tab4, "if name == \"this\":\n",
|
||||
tab4, tab4, tab4, "set(self, name, value)\n",
|
||||
tab4, tab4, "elif name == \"thisown\":\n",
|
||||
tab4, tab4, tab4, "self.this.own(value)\n",
|
||||
tab4, tab4, "elif hasattr(self, name) and isinstance(getattr(type(self), name), property):\n",
|
||||
tab4, tab4, tab4, "set(self, name, value)\n",
|
||||
tab4, tab4, "else:\n",
|
||||
tab4, tab4, tab4, "raise AttributeError(\"You cannot add instance attributes to %s\" % self)\n",
|
||||
tab4, "return set_instance_attr\n\n", NIL);
|
||||
Printv(f_shadow, "\n",
|
||||
"def _swig_setattr_nondynamic_instance_variable(set):\n",
|
||||
tab4, "def set_instance_attr(self, name, value):\n",
|
||||
tab4, tab4, "if name == \"this\":\n",
|
||||
tab4, tab4, tab4, "set(self, name, value)\n",
|
||||
tab4, tab4, "elif name == \"thisown\":\n",
|
||||
tab4, tab4, tab4, "self.this.own(value)\n",
|
||||
tab4, tab4, "elif hasattr(self, name) and isinstance(getattr(type(self), name), property):\n",
|
||||
tab4, tab4, tab4, "set(self, name, value)\n",
|
||||
tab4, tab4, "else:\n",
|
||||
tab4, tab4, tab4, "raise AttributeError(\"You cannot add instance attributes to %s\" % self)\n",
|
||||
tab4, "return set_instance_attr\n\n", NIL);
|
||||
|
||||
Printv(f_shadow, "\n",
|
||||
"def _swig_setattr_nondynamic_class_variable(set):\n",
|
||||
tab4, "def set_class_attr(cls, name, value):\n",
|
||||
tab4, tab4, "if hasattr(cls, name) and not isinstance(getattr(cls, name), property):\n",
|
||||
tab4, tab4, tab4, "set(cls, name, value)\n",
|
||||
tab4, tab4, "else:\n",
|
||||
tab4, tab4, tab4, "raise AttributeError(\"You cannot add class attributes to %s\" % cls)\n",
|
||||
tab4, "return set_class_attr\n\n", NIL);
|
||||
Printv(f_shadow, "\n",
|
||||
"def _swig_setattr_nondynamic_class_variable(set):\n",
|
||||
tab4, "def set_class_attr(cls, name, value):\n",
|
||||
tab4, tab4, "if hasattr(cls, name) and not isinstance(getattr(cls, name), property):\n",
|
||||
tab4, tab4, tab4, "set(cls, name, value)\n",
|
||||
tab4, tab4, "else:\n",
|
||||
tab4, tab4, tab4, "raise AttributeError(\"You cannot add class attributes to %s\" % cls)\n",
|
||||
tab4, "return set_class_attr\n\n", NIL);
|
||||
|
||||
Printv(f_shadow, "\n",
|
||||
"def _swig_add_metaclass(metaclass):\n",
|
||||
tab4, "\"\"\"Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass\"\"\"\n",
|
||||
tab4, "def wrapper(cls):\n",
|
||||
tab4, tab4, "return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())\n",
|
||||
tab4, "return wrapper\n\n", NIL);
|
||||
Printv(f_shadow, "\n",
|
||||
"def _swig_add_metaclass(metaclass):\n",
|
||||
tab4, "\"\"\"Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass\"\"\"\n",
|
||||
tab4, "def wrapper(cls):\n",
|
||||
tab4, tab4, "return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())\n",
|
||||
tab4, "return wrapper\n\n", NIL);
|
||||
|
||||
Printv(f_shadow, "\n",
|
||||
"class _SwigNonDynamicMeta(type):\n",
|
||||
tab4, "\"\"\"Meta class to enforce nondynamic attributes (no new attributes) for a class\"\"\"\n",
|
||||
tab4, "__setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)\n",
|
||||
"\n", NIL);
|
||||
Printv(f_shadow, "\n",
|
||||
"class _SwigNonDynamicMeta(type):\n",
|
||||
tab4, "\"\"\"Meta class to enforce nondynamic attributes (no new attributes) for a class\"\"\"\n",
|
||||
tab4, "__setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)\n",
|
||||
"\n", NIL);
|
||||
|
||||
Printv(f_shadow, "\n", NIL);
|
||||
Printv(f_shadow, "\n", NIL);
|
||||
|
||||
if (directorsEnabled()) {
|
||||
Printv(f_shadow, "import weakref\n\n", NIL);
|
||||
if (directorsEnabled())
|
||||
Printv(f_shadow, "import weakref\n\n", NIL);
|
||||
}
|
||||
}
|
||||
// Include some information in the code
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue