aboutsummaryrefslogtreecommitdiffstats
path: root/cppgenerator.cpp
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2009-12-28 16:51:08 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2009-12-28 16:51:08 -0300
commit731a68999274ab58fb35f3d3238f713fbf91c878 (patch)
treea6ceccd4e61199b2a2e7f45029ffe33686632620 /cppgenerator.cpp
parente489074ccb5bf5b98564d9752907a5657506f4e4 (diff)
Modifies ShibokenGenerator::writeCodeSnips semantics.
A NULL pointer in the "lastArg" parameter of writeCodeSnips means that the function being processed will be called without arguments. The behavior prior to this change was that a NULL lastArg indicates that all arguments are to be used.
Diffstat (limited to 'cppgenerator.cpp')
-rw-r--r--cppgenerator.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/cppgenerator.cpp b/cppgenerator.cpp
index 84dcdee70..76b233e28 100644
--- a/cppgenerator.cpp
+++ b/cppgenerator.cpp
@@ -299,9 +299,10 @@ void CppGenerator::writeConstructorNative(QTextStream& s, const AbstractMetaFunc
if (usePySideExtensions() && func->ownerClass()->isQObject())
s << ", m_metaObject(0)";
s << " {" << endl;
- writeCodeSnips(s, func->injectedCodeSnips(), CodeSnip::Beginning, TypeSystem::NativeCode, func);
+ const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().last();
+ writeCodeSnips(s, func->injectedCodeSnips(), CodeSnip::Beginning, TypeSystem::NativeCode, func, lastArg);
s << INDENT << "// ... middle" << endl;
- writeCodeSnips(s, func->injectedCodeSnips(), CodeSnip::End, TypeSystem::NativeCode, func);
+ writeCodeSnips(s, func->injectedCodeSnips(), CodeSnip::End, TypeSystem::NativeCode, func, lastArg);
s << '}' << endl << endl;
}
@@ -402,7 +403,8 @@ void CppGenerator::writeVirtualMethodNative(QTextStream &s, const AbstractMetaFu
if (injectedCodeUsesPySelf(func))
s << INDENT << "PyObject* pySelf = BindingManager::instance().retrieveWrapper(this);" << endl;
- writeCodeSnips(s, snips, CodeSnip::Beginning, TypeSystem::NativeCode, func);
+ const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().last();
+ writeCodeSnips(s, snips, CodeSnip::Beginning, TypeSystem::NativeCode, func, lastArg);
s << endl;
}
@@ -426,7 +428,8 @@ void CppGenerator::writeVirtualMethodNative(QTextStream &s, const AbstractMetaFu
if (func->hasInjectedCode()) {
s << endl;
- writeCodeSnips(s, snips, CodeSnip::End, TypeSystem::NativeCode, func);
+ const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().last();
+ writeCodeSnips(s, snips, CodeSnip::End, TypeSystem::NativeCode, func, lastArg);
}
s << INDENT << "Py_XDECREF(pyargs);" << endl;
@@ -1057,14 +1060,15 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f
// Find the last argument available in the method call to provide
// the injected code writer with information to avoid invalid replacements
// on the %# variable.
- if (maxArgs > 0
- && maxArgs < func->arguments().size() - OverloadData::numberOfRemovedArguments(func)) {
+ if (maxArgs > 0 && maxArgs < func->arguments().size() - OverloadData::numberOfRemovedArguments(func)) {
int removedArgs = 0;
for (int i = 0; i < maxArgs + removedArgs; i++) {
lastArg = func->arguments()[i];
if (func->argumentRemoved(i + 1))
removedArgs++;
}
+ } else if (maxArgs != 0 && !func->arguments().isEmpty()) {
+ lastArg = func->arguments().last();
}
writeCodeSnips(s, snips, CodeSnip::Beginning, TypeSystem::TargetLangCode, func, lastArg);
@@ -1535,7 +1539,8 @@ void CppGenerator::writeSequenceMethods(QTextStream& s, const AbstractMetaClass*
s << cpythonWrapperCPtr(func->ownerClass(), "self") << ';' << endl;
s << INDENT << "(void)cppSelf; // avoid warnings about unused variables" << endl;
- writeCodeSnips(s, snips,CodeSnip::Any, TypeSystem::TargetLangCode, func);
+ const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().last();
+ writeCodeSnips(s, snips,CodeSnip::Any, TypeSystem::TargetLangCode, func, lastArg);
s << '}' << endl << endl;
}
}