[Kde-bindings] Qyoto gets better...

Richard Dale Richard_Dale at tipitina.demon.co.uk
Fri Dec 2 20:41:34 UTC 2005


On Friday 02 December 2005 18:50, Arno Rehn wrote:
> > Here is the QtRuby code to call a method (from the method_missing()
> > function in Qt.cpp):
> >
> >     MethodCall c(qt_Smoke, _current_method, self, temp_stack+4, argc-1);
> >     c.next();
> >     VALUE result = *(c.var());
> >
> > There is a C++ class called 'MethodCall' in qt3qyoto.cpp too, and so that
> > needs to be passed the SmokeStack, once it is correctly set up. We
> > already have the correct method lookup in the Smoke library.
>
> I have added these lines after the 'printf' in 'CallMethod' in
> qt3qyoto.cpp: MethodCall c(qt_Smoke, methodId, obj, sp, items);
>         c.next();
> I didn't expect it to work, and it didn't. It compiles without errors, but
> while executing I get a SIGSEV. Waiting for your explanations, if you have
> some time.
I added a bit of debugging, and it is nearly calling a method. It has looked 
up the QApplication constructor, which is method number 17 in the 
x_QApplication class in the Smoke library in source file x_1.cpp. It crashes 
because there is no marshaller for a 'char**' type yet, and so the second 
argument isn't set up. The new QApplication is returned in the _stack[0] 
element of the Smoke::Stack, and the 'MethodReturnValue' C++ class takes that 
as an arg and wraps it in a new C# instance, by calling an appropriate 
marshalling function in qt3handlers.cpp.

Debugging in the MethodCall::callMethod() method:

	printf("In callMethod() fn: %p method().method: %d ptr: %p _stack[1]: %d\n", 
fn, method().method, ptr, _stack[1]);
	(*fn)(method().method, ptr, _stack);
	MethodReturnValue r(_smoke, _method, _stack, _retval);

Debugging in kdebindings/smoke/qt/x_1.cpp:

    static void x_17(Smoke::Stack x) {
	// QApplication(int&, char**)
printf("In QApplication(int&, char**) *(int *)x[1].s_voidp: %d, 
(char**)x[2].s_voidp: %p\n",
*(int *)x[1].s_voidp, (char**)x[2].s_voidp);
	x_QApplication* xret = new x_QApplication(*(int *)x[1].s_voidp,
(char**)x[2].s_voidp);
	x[0].s_class = (void*)xret;
    }

Debug output:

Invoke() MethodName: NewQApplication Type: Qt.QApplication, hello, 
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null ArgCount: 2
FindMethod() className: QApplication MethodName: QApplication$?
                In FindMethodId QApplication::QApplication$? => 146
FindMethod() MethodName: QApplication$? result: 154
        ArgName: argc Arg: 0 Type: System.Int32
        ArgName: argv Arg: System.String[] Type: System.String[]
In CallMethod methodId: 154 target: 0x00000003 items: 2
In CallMethod 0
In CallMethod classId: 123
o->ptr: (nil) o->classId: 123
In callMethod() fn: 0xe3a3324 method().method: 17 ptr: (nil) _stack[1]: 
2147477800
In QApplication(int&, char**) *(int *)x[1].s_voidp: 0, (char**)x[2].s_voidp: 
(nil)
s_voidp is nil, so BOOM!

I'll try and actually get it working this weekend, and report here on Monday.

-- Richard



More information about the Kde-bindings mailing list