@@ -124,18 +124,29 @@ void ShellGenerator::writeTypeInfo(QTextStream &s, const AbstractMetaType *type,
124124}
125125
126126
127- void ShellGenerator::writeFunctionArguments (QTextStream &s, const AbstractMetaClass* owner,
128- const AbstractMetaArgumentList &arguments ,
129- Option option,
130- int numArguments)
127+ void ShellGenerator::writeFunctionArguments (QTextStream &s,
128+ const AbstractMetaFunction *meta_function ,
129+ Option option,
130+ int numArguments)
131131{
132+ const AbstractMetaClass* owner = meta_function->ownerClass ();
133+ const AbstractMetaArgumentList &arguments = meta_function->arguments ();
134+
132135 if (numArguments < 0 ) numArguments = arguments.size ();
133136
134137 for (int i=0 ; i<numArguments; ++i) {
135138 if (i != 0 )
136139 s << " , " ;
137140 AbstractMetaArgument *arg = arguments.at (i);
141+ TypeSystem::Ownership ownership = TypeSystem::InvalidOwnership;
142+ if (option & AddOwnershipTemplates) {
143+ ownership = writeOwnershipTemplate (s, meta_function, i+1 );
144+ }
138145 writeTypeInfo (s, arg->type (), option);
146+ if (ownership != TypeSystem::InvalidOwnership) {
147+ s << " > " ;
148+ }
149+
139150 if (!(option & SkipName)) {
140151 if (option & UseIndexedName) {
141152 s << " " << arg->indexedName ();
@@ -194,8 +205,15 @@ void ShellGenerator::writeFunctionSignature(QTextStream &s,
194205
195206 if ((option & SkipReturnType) == 0 ) {
196207 if (function_type) {
197- writeTypeInfo (s, function_type, option);
198- s << " " ;
208+ TypeSystem::Ownership ownership = TypeSystem::InvalidOwnership;
209+ if (option & AddOwnershipTemplates) {
210+ ownership = writeOwnershipTemplate (s, meta_function, 0 );
211+ }
212+ writeTypeInfo (s, function_type, option);
213+ s << " " ;
214+ if (ownership != TypeSystem::InvalidOwnership) {
215+ s << " > " ;
216+ }
199217 } else if (!meta_function->isConstructor ()) {
200218 s << " void " ;
201219 }
@@ -245,7 +263,7 @@ void ShellGenerator::writeFunctionSignature(QTextStream &s,
245263 }
246264 }
247265
248- writeFunctionArguments (s, meta_function-> ownerClass (), meta_function-> arguments () , Option (option & Option (~ConvertReferenceToPtr)), numArguments);
266+ writeFunctionArguments (s, meta_function, Option (option & Option (~ConvertReferenceToPtr)), numArguments);
249267
250268 // The extra arguments...
251269 for (int i=0 ; i<extra_arguments.size (); ++i) {
@@ -409,3 +427,18 @@ bool ShellGenerator::isBuiltIn(const QString& name) {
409427 }
410428 return builtIn.contains (name);
411429}
430+
431+ TypeSystem::Ownership ShellGenerator::writeOwnershipTemplate (QTextStream & s, const AbstractMetaFunction * meta_function, int argumentIndex)
432+ {
433+ TypeSystem::Ownership ownership = meta_function->ownership (meta_function->ownerClass (), TypeSystem::TargetLangCode, argumentIndex);
434+ if (ownership == TypeSystem::CppOwnership) {
435+ s << " PythonQtPassOwnershipToCPP<" ;
436+ }
437+ else if (ownership == TypeSystem::TargetLangOwnership) {
438+ s << " PythonQtPassOwnershipToPython<" ;
439+ }
440+ else if (ownership == TypeSystem::TargetLangThisOwnership) {
441+ s << " PythonQtNewOwnerOfThis<" ;
442+ }
443+ return ownership;
444+ }
0 commit comments