aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cppgenerator.cpp10
-rw-r--r--doc/typesystemvariables.rst9
-rw-r--r--shibokengenerator.cpp19
-rw-r--r--shibokengenerator.h2
4 files changed, 28 insertions, 12 deletions
diff --git a/cppgenerator.cpp b/cppgenerator.cpp
index f185f2798..e9078de12 100644
--- a/cppgenerator.cpp
+++ b/cppgenerator.cpp
@@ -123,7 +123,7 @@ void CppGenerator::generateClass(QTextStream &s, const AbstractMetaClass *metaCl
// class inject-code native/beginning
if (!metaClass->typeEntry()->codeSnips().isEmpty()) {
- writeCodeSnips(s, metaClass->typeEntry()->codeSnips(), CodeSnip::Beginning, TypeSystem::NativeCode, 0, metaClass);
+ writeCodeSnips(s, metaClass->typeEntry()->codeSnips(), CodeSnip::Beginning, TypeSystem::NativeCode, 0, 0, metaClass);
s << endl;
}
@@ -260,7 +260,7 @@ void CppGenerator::generateClass(QTextStream &s, const AbstractMetaClass *metaCl
// class inject-code native/end
if (!metaClass->typeEntry()->codeSnips().isEmpty()) {
- writeCodeSnips(s, metaClass->typeEntry()->codeSnips(), CodeSnip::End, TypeSystem::NativeCode, 0, metaClass);
+ writeCodeSnips(s, metaClass->typeEntry()->codeSnips(), CodeSnip::End, TypeSystem::NativeCode, 0, 0, metaClass);
s << endl;
}
}
@@ -804,7 +804,7 @@ void CppGenerator::writeOverloadedMethodDecisor(QTextStream& s, OverloadData* pa
if (overloadData->hasDefaultValue())
func = overloadData->overloads().first();
}
- writeMethodCall(s, func, numArgs);;
+ writeMethodCall(s, func, numArgs);
}
s << INDENT << "} else ";
}
@@ -1796,7 +1796,7 @@ void CppGenerator::writeClassRegister(QTextStream& s, const AbstractMetaClass* m
// class inject-code target/beginning
if (!metaClass->typeEntry()->codeSnips().isEmpty()) {
- writeCodeSnips(s, metaClass->typeEntry()->codeSnips(), CodeSnip::Beginning, TypeSystem::TargetLangCode, 0, metaClass);
+ writeCodeSnips(s, metaClass->typeEntry()->codeSnips(), CodeSnip::Beginning, TypeSystem::TargetLangCode, 0, 0, metaClass);
s << endl;
}
@@ -1830,7 +1830,7 @@ void CppGenerator::writeClassRegister(QTextStream& s, const AbstractMetaClass* m
// class inject-code target/end
if (!metaClass->typeEntry()->codeSnips().isEmpty()) {
s << endl;
- writeCodeSnips(s, metaClass->typeEntry()->codeSnips(), CodeSnip::End, TypeSystem::TargetLangCode, 0, metaClass);
+ writeCodeSnips(s, metaClass->typeEntry()->codeSnips(), CodeSnip::End, TypeSystem::TargetLangCode, 0, 0, metaClass);
}
s << '}' << endl << endl;
diff --git a/doc/typesystemvariables.rst b/doc/typesystemvariables.rst
index 15fe8732c..ff4a0e34f 100644
--- a/doc/typesystemvariables.rst
+++ b/doc/typesystemvariables.rst
@@ -54,9 +54,14 @@ Variables
**%ARGUMENT_NAMES**
Replaced by a comma separated list with the names of all C++ arguments that
- were not removed on the type system description for the method/function. If
+ were not removed on the type system description for the method/function. When
the removed argument has a default value (original or provided in the type
- system), this value will be inserted in the argument list.
+ system), this value will be inserted in the argument list. If you want to remove
+ the argument so completely that it doesn't appear in any form on the
+ ``%ARGUMENT_NAMES`` replacement, don't forget to remove also its default value
+ with the `<remove-default-expression/>
+ <http://www.pyside.org/docs/apiextractor/typesystem_arguments.html#remove-default-expression>`_
+ type system tag.
Take the following method and related type system description as an example:
diff --git a/shibokengenerator.cpp b/shibokengenerator.cpp
index d2172fedf..4ff500166 100644
--- a/shibokengenerator.cpp
+++ b/shibokengenerator.cpp
@@ -821,6 +821,7 @@ void ShibokenGenerator::writeCodeSnips(QTextStream& s,
CodeSnip::Position position,
TypeSystem::Language language,
const AbstractMetaFunction* func,
+ const AbstractMetaArgument* lastArg,
const AbstractMetaClass* context)
{
static QRegExp toPythonRegex("%CONVERTTOPYTHON\\[([^\\[]*)\\]");
@@ -860,7 +861,7 @@ void ShibokenGenerator::writeCodeSnips(QTextStream& s,
if (func) {
// replace "toPython "converters
- code.replace(toPythonRegex, "Shiboken::Converter<\\1>::toPython");
+ code.replace(toPythonRegex, "Shiboken::Converter<\\1 >::toPython");
// replace %PYARG_# variables
if (numArgs > 1) {
@@ -912,13 +913,16 @@ void ShibokenGenerator::writeCodeSnips(QTextStream& s,
int removed = 0;
for (int i = 0; i < func->arguments().size(); i++) {
QString argReplacement;
+ const AbstractMetaArgument* arg = func->arguments().at(i);
if (func->argumentRemoved(i+1)) {
- const AbstractMetaArgument* arg = func->arguments().at(i);
if (!arg->defaultValueExpression().isEmpty())
argReplacement = arg->defaultValueExpression();
removed++;
}
+ if (lastArg && arg->argumentIndex() > lastArg->argumentIndex())
+ argReplacement = arg->defaultValueExpression();
+
if (argReplacement.isEmpty())
argReplacement = QString("cpp_arg%1").arg(i - removed);
code.replace("%" + QString::number(i+1), argReplacement);
@@ -935,9 +939,14 @@ void ShibokenGenerator::writeCodeSnips(QTextStream& s,
continue;
}
- QString argName = QString("cpp_arg%1").arg(arg->argumentIndex() - removed);
- if (shouldDereferenceArgumentPointer(arg))
- argName.prepend('*');
+ QString argName;
+ if (lastArg && arg->argumentIndex() > lastArg->argumentIndex()) {
+ argName = arg->defaultValueExpression();
+ } else {
+ argName = QString("cpp_arg%1").arg(arg->argumentIndex() - removed);
+ if (shouldDereferenceArgumentPointer(arg))
+ argName.prepend('*');
+ }
argumentNames << argName;
}
diff --git a/shibokengenerator.h b/shibokengenerator.h
index 7fdfc8912..51c4c34aa 100644
--- a/shibokengenerator.h
+++ b/shibokengenerator.h
@@ -102,6 +102,7 @@ public:
* \param position the position to insert the code snip
* \param language the kind of code snip
* \param func the cpp function
+ * \param lastArg last argument whose value is available
* \param context the class context for the place where the code snip will be written
*/
void writeCodeSnips(QTextStream &s,
@@ -109,6 +110,7 @@ public:
CodeSnip::Position position,
TypeSystem::Language language,
const AbstractMetaFunction* func = 0,
+ const AbstractMetaArgument* lastArg = 0,
const AbstractMetaClass* context = 0);
/**