[Kde-bindings] KDE/kdebindings/csharp/qyoto
Richard Dale
rdale at foton.es
Fri May 18 16:19:16 UTC 2007
On Friday 18 May 2007, Arno Rehn wrote:
> Am Freitag, 18. Mai 2007 schrieb Richard Dale:
> > On Friday 18 May 2007, Arno Rehn wrote:
> > > Am Freitag, 18. Mai 2007 schrieb Richard Dale:
> > > > On Friday 18 May 2007, Arno Rehn wrote:
> > > > > SVN commit 665951 by arnorehn:
> > > > >
> > > > > * Made 'ref' arguments work.
> > > >
> > > > Oh, I wasn't going to implement them like this. It should be just a
> > > > matter of adding marshallers for the various ref types, and copying a
> > > > pointer to the item on the C# stack to the smoke stack like
> > > > Marshall::ToObject below: [...]
> > >
> > > Ah, I see. I didn't think about this possibility. Shall we change that
> > > again or keep it as it is?
> >
> > Well I haven't looked closely at exactly what you've done, but if it only
> > does the same as the simple approach I describe above, I think it would
> > be better to change it to work the simpler way. The code in PerlQt was
> > designed from the start to work with ref types, but primitive types in
> > ruby are immutable and there is no equivalent to the 'ref' arg type in
> > C#, and so it isn't implemented very well as it could be in QtRuby.
>
> What it does: After the method is called, it checks whether there are any
> ref-arguements. If that's true, it marshalls the C++ arg-values to
> C#-values and copies them on the C# stack. It basically does the same as
> your approach, but it doesn't need to have any extra marshallers; it uses
> the existing ones. I think the two approaches are rather equal in their
> simplicity.
OK, I've had a look at the diff and studied what's going on, but I really
don't agree we need this.
You need to have 'int&', 'bool&' etc marshallers anyway and the marshalling
functions are all designed to be able to copy back args from the smoke stack
to the C# stack after a method call anyway. Although we don't need to do that
in this case because the primitive types are pushed onto the smoke stack as
pointers (not as values like non-ref types).
Note that if you put a 'm->next()' call in the middle of a marshaller, the
code following it is called after the target method has been invoked.
case Marshall::ToObject:
{
// This code is before the method has been called
m->var().s_voidp = &(m->item().s_int);
// This method is called while in the next() call
m->next();
// This code is after the method has been called
m->item().s_int = *((int *)(m->var().s_voidp));
}
-- Richard
More information about the Kde-bindings
mailing list