Re: Method returning non-scalar

Germain Garand <[email protected]> Tue, 23 Nov 2004 08:16:27 +0000
Newsgroups gmane.comp.kde.devel.perl
Message-ID <[email protected]>
Le Mardi 23 Novembre 2004 07:41, Ole Christensen a écrit :
> Ok, so it is me who got you wrong. I just was not sure and I did not
> want to have that dim feeling stay around.
>

Hi again,
are you able to test the attached? That's what I intend to commit if all is 
fine.
I figured we were doing some useless stack copy instead of just proxying, so 
that should even be faster.

> And another but final remark: It seems PerlQt attributes are writable
> from the package itself but not from inheritors. Read access works fine
> if preceeding the attribute with an "&". So they are a kind of between
> private and protected (borrowed from C++). Haven't tried pulic read
> access. That's another item for a FAQ I guess.
>
> Everthing above true and maybe only true for PerlQt 3.008.

mmh, I'll investigate that... have you, by chance, a minimal testcase at hand?

Greetings,
Germain

_______________________________________________
Kde-perl mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kde-perl
ret.diff (text/x-diff, 1.1 KB)
Index: Qt.xs
===================================================================
RCS file: /cvsroot/perlqt/PerlQt-3/PerlQt/Qt.xs,v
retrieving revision 1.87
diff -u -3 -p -r1.87 Qt.xs
--- Qt.xs	29 Mar 2004 20:31:31 -0000	1.87
+++ Qt.xs	23 Nov 2004 07:50:55 -0000
@@ -993,17 +993,16 @@ XS(XS_AUTOLOAD) {
 	    sv_this = newSVsv(ST(0));
 	}
 
-	ENTER;
-	SAVETMPS;
 	PUSHMARK(SP - items + withObject);
 	PUTBACK;
-	int count = call_sv((SV*)GvCV(gv), G_SCALAR|G_EVAL);
+        I32 gimme = GIMME_V;
+	int count = call_sv((SV*)GvCV(gv), gimme|G_EVAL);
 	SPAGAIN;
-	SV *ret = newSVsv(TOPs);
-	SP -= count;
-	PUTBACK;
-	FREETMPS;
-	LEAVE;
+        SP -= count;
+        if (withObject) // shift the stack
+            for (int i=0; i<count; i++)
+                ST(i) = ST(i+1);
+        PUTBACK;
 
 	if(withObject && !isSuper) {
 	    SvREFCNT_dec(sv_this);
@@ -1014,8 +1013,10 @@ XS(XS_AUTOLOAD) {
 
         if(SvTRUE(ERRSV))
             croak(SvPV_nolen(ERRSV));
-	ST(0) = sv_2mortal(ret);
-	XSRETURN(1);
+        if (gimme == G_VOID)
+            XSRETURN_UNDEF;
+        else
+	    XSRETURN(count);
     }
     else if(!strcmp(method, "DESTROY")) {
         SV *old_this;