Skip to content

Commit 63c9668

Browse files
florianlinkmsmolens
florianlink
authored andcommitted
improved handling of qualified virtual calls
git-svn-id: http://svn.code.sf.net/p/pythonqt/code/trunk@401 ea8d5007-eb21-0410-b261-ccb3ea6e24a9
1 parent 61dfba6 commit 63c9668

File tree

3 files changed

+23
-32
lines changed

3 files changed

+23
-32
lines changed

generator/abstractmetalang.cpp

-12
Original file line numberDiff line numberDiff line change
@@ -696,18 +696,6 @@ QString AbstractMetaFunction::targetLangSignature(bool minimal) const
696696

697697
// Attributes...
698698
if (!minimal) {
699-
#if 0 // jambi
700-
if (isPublic()) s += "public ";
701-
else if (isProtected()) s += "protected ";
702-
else if (isPrivate()) s += "private ";
703-
704-
// if (isNative()) s += "native ";
705-
// else
706-
if (isFinalInTargetLang()) s += "final ";
707-
else if (isAbstract()) s += "abstract ";
708-
709-
if (isStatic()) s += "static ";
710-
#endif
711699
// Return type
712700
if (type())
713701
s += type()->name() + " ";

generator/shellheadergenerator.cpp

+21-19
Original file line numberDiff line numberDiff line change
@@ -199,30 +199,32 @@ void ShellHeaderGenerator::write(QTextStream &s, const AbstractMetaClass *meta_c
199199

200200
foreach(AbstractMetaFunction* fun, promoteFunctions) {
201201
// normal promoter
202-
if (fun->isStatic()) {
203-
s << "static ";
204-
}
205-
s << "inline ";
206-
writeFunctionSignature(s, fun, 0, "promoted_",
207-
Option(IncludeDefaultExpression | OriginalName | UnderscoreSpaces | ProtectedEnumAsInts));
208-
s << " { ";
209-
QString scriptFunctionName = fun->originalName();
210-
AbstractMetaArgumentList args = fun->arguments();
211-
if (fun->type()) {
212-
s << "return ";
202+
if (fun->wasProtected()) {
203+
if (fun->isStatic()) {
204+
s << "static ";
205+
}
206+
s << "inline ";
207+
writeFunctionSignature(s, fun, 0, "promoted_",
208+
Option(IncludeDefaultExpression | OriginalName | UnderscoreSpaces | ProtectedEnumAsInts));
209+
s << " { ";
210+
QString scriptFunctionName = fun->originalName();
211+
AbstractMetaArgumentList args = fun->arguments();
212+
if (fun->type()) {
213+
s << "return ";
214+
}
215+
// always do a direct call, since we want to call the real virtual function here
216+
s << "this->";
217+
s << fun->originalName() << "(";
218+
writePromoterArgs(args, s);
219+
s << "); }" << endl;
213220
}
214-
// always do a direct call, since we want to call the real virtual function here
215-
s << "this->";
216-
s << fun->originalName() << "(";
217-
writePromoterArgs(args, s);
218-
s << "); }" << endl;
219221
}
220222

221223
foreach(AbstractMetaFunction* fun, promoteFunctions) {
222224
// qualified promoter for virtual functions
223225
if (fun->isVirtual()) {
224226
s << "inline ";
225-
writeFunctionSignature(s, fun, 0, "py_qualified_",
227+
writeFunctionSignature(s, fun, 0, "py_q_",
226228
Option(IncludeDefaultExpression | OriginalName | UnderscoreSpaces | ProtectedEnumAsInts));
227229
s << " { ";
228230
QString scriptFunctionName = fun->originalName();
@@ -361,7 +363,7 @@ void ShellHeaderGenerator::write(QTextStream &s, const AbstractMetaClass *meta_c
361363
if (function->isVirtual()) {
362364
// qualified version that calls the promoter/the qualified version
363365
s << " ";
364-
writeFunctionSignature(s, function, 0, "py_qualified_",
366+
writeFunctionSignature(s, function, 0, "py_q_",
365367
Option(AddOwnershipTemplates | ConvertReferenceToPtr | FirstArgIsWrappedObject | IncludeDefaultExpression | OriginalName | ShowStatic | UnderscoreSpaces | ProtectedEnumAsInts));
366368
s << "{ ";
367369

@@ -375,7 +377,7 @@ void ShellHeaderGenerator::write(QTextStream &s, const AbstractMetaClass *meta_c
375377
s << "&";
376378
}
377379
}
378-
s << "(((" << promoterClassName(meta_class) << "*)theWrappedObject)->py_qualified_";
380+
s << "(((" << promoterClassName(meta_class) << "*)theWrappedObject)->py_q_";
379381
s << function->originalName() << "(";
380382
for (int i = 0; i < args.size(); ++i) {
381383
if (i > 0)

generator/shellimplgenerator.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,8 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla
294294
s << meta_class->qualifiedCppName() << "::";
295295
}
296296
} else {
297-
if (fun->wasProtected() || (fun->isVirtual() && meta_class->typeEntry()->shouldCreatePromoter())) {
297+
if (fun->wasProtected()) {
298+
//|| (fun->isVirtual() && meta_class->typeEntry()->shouldCreatePromoter())) {
298299
s << " ((" << promoterClassName(meta_class) << "*)theWrappedObject)->promoted_";
299300
} else {
300301
s << " theWrappedObject->";

0 commit comments

Comments
 (0)