diff options
author | Max Waterman <david.waterman@nokia.com> | 2010-06-13 15:48:29 +0300 |
---|---|---|
committer | Tomas Junnonen <tomas.junnonen@nokia.com> | 2010-06-14 11:24:30 +0300 |
commit | 47e401ad87cbec61fc4a391227607bc100440420 (patch) | |
tree | 570edf1c1aeac4a3144fc04c3ab8fd6f9a08b192 /tools | |
parent | ddab5a2656cac8f655b3d7388593dca652781cb9 (diff) |
Fixes: NB#172441 - Serviceframework: m-servicefwgen generates non-compiling code
RevBy: Dominik Kapusta
Details:
Implemented fix.
Added test to ft_mservicefwgen.
Tested with examples/{chaining,servicefw}.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/m-servicefwgen.d/m-servicefwgen.cpp | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/tools/m-servicefwgen.d/m-servicefwgen.cpp b/tools/m-servicefwgen.d/m-servicefwgen.cpp index 3c41ebcf..935a618a 100644 --- a/tools/m-servicefwgen.d/m-servicefwgen.cpp +++ b/tools/m-servicefwgen.d/m-servicefwgen.cpp @@ -983,6 +983,7 @@ void processAdaptorHeaderFile() } // remove asyncTask attribute + bool chainTaskHasNoParameters = false; bool isChainTask = false; { QRegExp matchThis("chainTask=\\\\\"(\\w+)\\\\\"\\s*"); @@ -990,6 +991,12 @@ void processAdaptorHeaderFile() line.remove(matchThis); isChainTask = matchThis.cap(1).contains("true"); line.remove(w.chainTag()); + if ( line.contains( "/>") ) { + chainTaskHasNoParameters = true; + line.replace( "/>", ">" ); // if the method has no args, it'll have a />, but we will add args, so we don't want this + } else { + chainTaskHasNoParameters = false; + } } } @@ -1004,6 +1011,10 @@ void processAdaptorHeaderFile() << "\" <arg direction=\\\"in\\\" type=\\\"s\\\" name=\\\"backServiceName\\\"/>\\n\"" << endl << "\" <arg direction=\\\"in\\\" type=\\\"s\\\" name=\\\"windowTitle\\\"/>\\n\"" << endl << "\" <arg direction=\\\"in\\\" type=\\\"u\\\" name=\\\"windowId\\\"/>\\n\"" << endl; + if ( chainTaskHasNoParameters ) { + newAdaptorHeaderStream + << "\" </method>\\n\"" << endl; + } } } else if (line.contains(w.chainTag() + "(") || line.contains(w.asyncTag() + "(")) { // add parameters to the chain methods if (line.contains(w.asyncTag())) { @@ -1032,7 +1043,14 @@ void processAdaptorHeaderFile() if (line.contains(w.chainTag())) { hasChains = true; line.remove(w.chainTag()); - line.replace("(", "(const QString &backServiceName, const QString &windowTitle, const uint windowId, "); + + QString parameterString = "(const QString &backServiceName, const QString &windowTitle, const uint windowId"; + + bool methodHasParameters = !line.contains( QRegExp( "\\(\\s*\\)" )); + if ( methodHasParameters ) { + parameterString += ", "; + } + line.replace("(", parameterString); } newAdaptorHeaderStream << line << endl; @@ -1234,21 +1252,33 @@ void processProxyHeaderFile() QStringList paramNames = getParamNames(parameters); + QString paramString; + if ( parameters.isEmpty() ) { + paramString = ""; + } else { + paramString = " "+parameters+" "; + } + wrapperHeaderStream << -" " + returnType + " " + methodName + "( " + parameters + " );" << endl; + " " + returnType + " " + methodName + "(" + paramString + ");" << endl; wrapperCppStream << -returnType + " " + w.upperCamelServiceName() + "::" + methodName + "( " + parameters + " )" << endl; + returnType + " " + w.upperCamelServiceName() + "::" + methodName + "(" + paramString + ")" << endl; wrapperCppStream << "{" << endl; + if ( parameters.isEmpty() ) { + paramString = ""; + } else { + paramString = " " + paramNames.join(", ")+" "; + } if (returnType == "void") { wrapperCppStream << -" static_cast<" + w.upperCamelServiceName() + "Proxy*>(interfaceProxy())->" + methodName + "( " + paramNames.join(", ") + " );" << endl; +" static_cast<" + w.upperCamelServiceName() + "Proxy*>(interfaceProxy())->" + methodName + "(" + paramString + ");" << endl; } else { wrapperCppStream << -" return qobject_cast<" + w.upperCamelServiceName() + "Proxy*>(interfaceProxy())->" + methodName + "( " + paramNames.join(", ") + " ).value();" << endl; +" return qobject_cast<" + w.upperCamelServiceName() + "Proxy*>(interfaceProxy())->" + methodName + "(" + paramString + ").value();" << endl; } wrapperCppStream << "}\n" << endl; } |