aboutsummaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
authorJohn Ehresman <jpe@wingware.com>2013-06-23 15:07:57 -0400
committerJohn Cummings <jcummings2@users.sf.net>2013-06-24 17:51:54 +0200
commitf060e1ce92fdb4714ca2cface9474db33f1d8e95 (patch)
tree3e9d2fbce555761e38d4e7c5d570be917cb2fb2c /generator
parent7d56c8e1d3025edb967906d9481075c38290574c (diff)
Use non-static method def for instance methods
For methods that can be called as either class or instance methods (e.g. PySide's QObject.connect), a non-static variant of the PyMethodDef struct is needed in Python 3.3 when method is used as an instance method. Fixes https://bugreports.qt-project.org/browse/PYSIDE-145 Change-Id: Ie8876a381614f33815f9b6449ea4a61cde9e5cee Reviewed-by: John Cummings <jcummings2@users.sf.net>
Diffstat (limited to 'generator')
-rw-r--r--generator/shiboken/cppgenerator.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/generator/shiboken/cppgenerator.cpp b/generator/shiboken/cppgenerator.cpp
index e7ecbdd02..4e9b84be7 100644
--- a/generator/shiboken/cppgenerator.cpp
+++ b/generator/shiboken/cppgenerator.cpp
@@ -4534,9 +4534,19 @@ void CppGenerator::writeGetattroFunction(QTextStream& s, const AbstractMetaClass
s << INDENT << '}' << endl;
foreach (const AbstractMetaFunction* func, getMethodsWithBothStaticAndNonStaticMethods(metaClass)) {
+ QString defName = cpythonMethodDefinitionName(func);
+ s << INDENT << "static PyMethodDef non_static_" << defName << " = {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << defName << ".ml_name," << endl;
+ s << INDENT << defName << ".ml_meth," << endl;
+ s << INDENT << defName << ".ml_flags & (~METH_STATIC)," << endl;
+ s << INDENT << defName << ".ml_doc," << endl;
+ }
+ s << INDENT << "};" << endl;
s << INDENT << "if (Shiboken::String::compare(name, \"" << func->name() << "\") == 0)" << endl;
Indentation indent(INDENT);
- s << INDENT << "return PyCFunction_NewEx(&" << cpythonMethodDefinitionName(func) << ", " PYTHON_SELF_VAR ", 0);" << endl;
+ s << INDENT << "return PyCFunction_NewEx(&non_static_" << defName << ", " PYTHON_SELF_VAR ", 0);" << endl;
}
}
s << INDENT << '}' << endl;