No subject


Thu Nov 10 03:57:02 UTC 2011


	class DCOPRef < Qt::Base
		def method_missing(*k)
			# Enables DCOPRef calls to be made like this:
			#
			# dcopRef = DCOPRef.new("dcopslot", "MyWidget")
			# result = dcopRef.getPoint("Hello from dcopcall")
			begin
				# First look for a method in the Smoke runtime.
				# If not found, then throw an exception and try dcop.
				super(*k)
			rescue
			
			...

				return callExt(method, *dcopArgs)
			end

It dynamically looks up QDataStream '<<' and '>>' operators in the Smoke 
runtime. From Korundum.cpp:

// Look for methods of the form: QDataStream & operator>>(QDataStream&, 
MyClass&)
Smoke::Index meth = t.smoke()->findMethod("QGlobalSpace", "operator>>##");
Smoke::Index ix;
if (meth > 0) {
	ix = t.smoke()->methodMaps[meth].method;
	ix = -ix;		// turn into ambiguousMethodList index
	while (t.smoke()->ambiguousMethodList[ix]) {
		Smoke::Method &method = 
t.smoke()->methods[t.smoke()->ambiguousMethodList[ix]];
		QString	refType(t.name());
		refType += "&";
		if (	strcmp(	"QDataStream&", 
						t.smoke()->types[t.smoke()->argumentList[method.args+0]].name ) == 0 
				&& strcmp(	refType.latin1(), 
							t.smoke()->types[t.smoke()->argumentList[method.args+1]].name ) == 0 ) 
		{
			Smoke::ClassFn fn = t.smoke()->classes[method.classId].classFn;
			Smoke::StackItem local_stack[3];
			local_stack[1].s_voidp = stream;
			local_stack[2].s_voidp = stack[i].s_voidp;
			// Call the QDataStream marshaller read method
			// on the instance to be marshalled
			(*fn)(method.method, 0, local_stack);
			break;
		}
		ix++;
	}
}					

-- Richard



More information about the Kde-bindings mailing list