[Kde-bindings] SMOKE copy constructor problem

Germain Garand germain at ebooksfrance.org
Tue Jun 8 14:40:51 UTC 2004


Le Mardi 08 Juin 2004 11:52, Richard Dale a écrit :
> On Tuesday 08 June 2004 10:27, Germain Garand wrote:
> > Le Mardi 08 Juin 2004 06:15, Richard Dale a écrit :
[...]
> > > In ruby it fails and won't run because ambiguous calls are an error.
> >
> > I thought you had an ambiguous methods resolver aswell?
> > do you bail out when you can marshall either e.g as an int, a double or a
> > long or is that only for classes?
>
> Yes, qtruby has the same logic as PerlQt apart from matching classes. I
> think you implemented a 'nearest subclass' match, whereas QtRuby just goes
> for an exact match first or any subclass is second best. I've been meaning
> to copy the latest PerlQt code for that..
>

I see, I was taking ambiguous in the broader sense of "anything returned by 
smoke for a query" :)

> If there is an ambiguous method call, it doesn't just choose the first one
> like PerlQt - it's an error. Maybe PerlQt should only allow ambiguous
> methods with no 'use strict' option?
>

yes, we could certainly use a runtime switch.
whether 'use strict' suits the task, I don't know... it's not really supposed 
to remove functionalities... 
it's not clear to me how many methods would be
out of reach and if that could be a stumbling block for an application.
Either direction is painful...

[...]
> > The problem is not what they are worth for the user, it's that right now
> > we need them from the binding in at least two circumstances:
> > - when we have to marshall a const ref "ToLanguage"
> > - when we have to marshall a stack item "FromLanguage"
> >
> > when this happens, we have to be able to locate a copy constructor, even
> > the default, or we are in deep troubles...
>
> Yes, I wasn't sure if there was some problem like this. But I couldn't see
> that the cf_deepcopy flag was being used:
>
> baldhead duke 1186% pwd
> /home/duke/src/PerlQt-3.008/PerlQt
> baldhead duke 1187% grep deepcopy *
> smokeperl.h:    bool hasCopy() const { return flags() & Smoke::cf_deepcopy;
> } baldhead duke 1188% grep hasCopy *
> smokeperl.h:    bool hasCopy() const { return flags() & Smoke::cf_deepcopy;
> }
>

you need to grep for construct_copy (I think QtRuby uses it too)
the function doesn't use the deepcopy class flag, though it could... it only 
performs a standard Smoke lookup and discriminate "by hand" (with cache for 
PerlQt)
So a method flag would speed up things quite a bit...

> > the first could be fixed in Smoke by building a copy of const ref
> > arguments, that would then be freed by the binding,
> > but the second is unavoidable....
>
> Maybe that sounds too complicated
>
> > A simple plan would be to add some logic in the binding to remove copy
> > ctor methods from the ambiguous list (testing for cf_deepcopy
> > beforehand), or much better: go the BIC route and add an mf_copyctor
> > method flag... what do you think?
>
> Yes, we need a way of having some 'internal methods' which wouldn't be
> visible via pqtapi, but could be used by marshallers (if I could work out
> where cf_deepcopy is used at the moment).

maybe something like mf_lowlevel, on top of the suggested mf_copyctor?

> I don't think there are enough
> QtRuby users yet for BIC to be an issue for ruby.

anyway, it just requires appending enum values, so it's even BC

Germain



More information about the Kde-bindings mailing list