aboutsummaryrefslogtreecommitdiffstats
path: root/cppgenerator.h
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2010-06-15 15:11:11 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2010-06-15 20:15:09 -0300
commitb22d72848c3ce6a8433399a5e9e3d182ff08c13d (patch)
tree0714ae4c4a5df708197d3a161f3577526afcc62f /cppgenerator.h
parent7f433285d4e78a9525d6b72fcaf679a208d45bf3 (diff)
Overload decisor code modified to separate the decision and caller parts.
This makes the generated code more clear and eases future improvements as named argument support. There is room for performance improvements. Reviewed by Luciano Wolf <luciano.wolf@openbossa.org> Reviewed by Renato Araújo <renato.filho@openbossa.org>
Diffstat (limited to 'cppgenerator.h')
-rw-r--r--cppgenerator.h31
1 files changed, 21 insertions, 10 deletions
diff --git a/cppgenerator.h b/cppgenerator.h
index c6ba546ba..eee5e2e9d 100644
--- a/cppgenerator.h
+++ b/cppgenerator.h
@@ -76,20 +76,22 @@ private:
* code to deallocate a possible new instance is also generated.
* \param s text stream to write
* \param metatype a pointer to the argument type to be converted
- * \param context the current meta class
* \param argName C++ argument name
- * \param argName Python argument name
+ * \param pyArgName Python argument name
+ * \param context the current meta class
+ * \param defaultValue an optional default value to be used instead of the conversion result
*/
void writeArgumentConversion(QTextStream& s, const AbstractMetaType* argType,
QString argName, QString pyArgName,
- const AbstractMetaClass* context = 0);
- /// Convenience method to call writeArgumentConversion with an AbstractMetaArgument
- /// instead of an AbstractMetaType.
+ const AbstractMetaClass* context = 0,
+ QString defaultValue = QString());
+ /// Convenience method to call writeArgumentConversion with an AbstractMetaArgument instead of an AbstractMetaType.
void writeArgumentConversion(QTextStream& s, const AbstractMetaArgument* arg,
QString argName, QString pyArgName,
- const AbstractMetaClass* context = 0)
+ const AbstractMetaClass* context = 0,
+ QString defaultValue = QString())
{
- writeArgumentConversion(s, arg->type(), argName, pyArgName, context);
+ writeArgumentConversion(s, arg->type(), argName, pyArgName, context, defaultValue);
}
/**
@@ -104,12 +106,21 @@ private:
void writeNoneReturn(QTextStream& s, const AbstractMetaFunction* func, bool thereIsReturnValue);
/**
- * Writes the Python method wrapper overload decisor that selects which C++
+ * Writes the Python function wrapper overload decisor that selects which C++
* method/function to call with the received Python arguments.
* \param s text stream to write
- * \param parentOverloadData a pointer to overload data describing the argument being evaluated
+ * \param overloadData the overload data describing all the possible overloads for the function/method
*/
- void writeOverloadedMethodDecisor(QTextStream& s, OverloadData* parentOverloadData);
+ void writeOverloadedFunctionDecisor(QTextStream& s, const OverloadData& overloadData);
+ /// Recursive auxiliar method to the other writeOverloadedFunctionDecisor.
+ void writeOverloadedFunctionDecisor(QTextStream& s, const OverloadData* parentOverloadData);
+
+ /// Writes calls to all the possible method/function overloads.
+ void writeFunctionCalls(QTextStream& s, const OverloadData& overloadData);
+
+ /// Writes the call to a single function usually from a collection of overloads.
+ void writeSingleFunctionCall(QTextStream& s, const OverloadData& overloadData, const AbstractMetaFunction* func = 0);
+
/// Returns a string containing the name of an argument for the given function and argument index.
QString argumentNameFromIndex(const AbstractMetaFunction* func, int argIndex, const AbstractMetaClass** wrappedClass);
void writeMethodCall(QTextStream& s, const AbstractMetaFunction* func, int maxArgs = 0);