[Kde-bindings] QtRuby virtual method callbacks

Richard Dale Richard_Dale at tipitina.demon.co.uk
Sat Jul 19 00:01:28 UTC 2003


On Friday 18 July 2003 17:57, Germain Garand wrote:
> Le Jeudi 17 Juillet 2003 09:39, Richard Dale a écrit :
> > interface. The main thing still to be done are signals/slots, and I think
> > I'll put it in the cvs when they're working. Yesterday I found the
> > sources 'slots.pm, signals.pm and isa.pm' under lib/Qt - I hadn't
> > realised they were there. I had just kept staring and staring at Qt.pm
> > trying to see how it worked, but when I got to see 'isa.pm' the lightbulb
> > finally switched on in my head :)
>
> ah, that brings bad memories to me :)
> ... I had a hard time grasping that as well
> That's why I added the comment above getMetaObject, but I forgot to add the
> location of isa.pm & friends. Fixed.
>
> > I've attached a current snapshot of qtruby. I'm working through the
> > tutorials, and am up to t4.rb. To get that working I need to add a custom
> > QApplication constructor to set up the Qt::app class variable, like
> > PerlQt. There is a bug in the smoke munged name for the method - it's
> > 'QApplication$?' when it should be 'QApplication?$' for 'int&, char**'
>
> mmh, but why?
> "$" is for scalars, and I think that's what all languages will use for
> marshalling "int&".
> char** ought to be fed by the target language's equivalent of an array of
> strings, so "?" looks right aswell...
This is the code in qtruby.rb for references:

			for arg in args
				if arg == nil or isObject(arg)
					method << "#"
				elsif isRef(arg)
					method << "?"
				else
					method << "$"
				end
			end

I 'made up' isRef() - there is no 'ref' in ruby as far as I know.

static VALUE
isRef(VALUE self, VALUE obj)
{
	VALUE klass = rb_funcall(obj, rb_intern("class"), 0);
	VALUE class_name = rb_funcall(klass, rb_intern("name"), 0);
	return strcmp(STR2CSTR(class_name), "Qt::Internal::Reference") == 0 ? Qtrue : 
Qfalse;
}

The class 'Qt::Internal::Reference' wraps a reference value.

-- Richard


More information about the Kde-bindings mailing list