static public void InvokeCustomSlot(IntPtr obj, string slotname, IntPtr stack, IntPtr ret) { QObject qobj = (QObject)((GCHandle)obj).Target; #if DEBUG if ((QDebug.DebugChannel() & QtDebugChannel.QTDB_TRANSPARENT_PROXY) != 0) { Console.WriteLine("ENTER InvokeCustomSlot() {0}.{1}", qobj, slotname); } #endif MethodInfo slot = Qyoto.GetSlotMethodInfo(qobj.GetType(), slotname); ParameterInfo[] parameters = slot.GetParameters(); object[] args = new object[parameters.Length]; unsafe { StackItem *stackPtr = (StackItem *)stack; for (int i = 0; i < args.Length; i++) { args[i] = SmokeMarshallers.BoxFromStackItem(parameters[i].ParameterType, 0, stackPtr + i); } object returnValue = slot.Invoke(qobj, args); StackItem *retval = (StackItem *)ret; if (slot.ReturnType != typeof(void)) { SmokeMarshallers.UnboxToStackItem(returnValue, retval); } } }
public static int Exec() { int result = (int)staticInterceptor.Invoke("exec", "exec()", typeof(int), false); Qyoto.Cleanup(); return(result); }
public T FindChild <T>(string name) { string childClassName = null; IntPtr metaObject = IntPtr.Zero; if (SmokeMarshallers.IsSmokeClass(typeof(T))) { childClassName = SmokeMarshallers.SmokeClassName(typeof(T)); } else { metaObject = (IntPtr)GCHandle.Alloc(Qyoto.GetMetaObject(typeof(T))); } IntPtr child = FindQObjectChild((IntPtr)GCHandle.Alloc(this), childClassName, metaObject, name); if (child != IntPtr.Zero) { try { return((T)((GCHandle)child).Target); } catch (Exception e) { Console.WriteLine("Found child, but an error has occurred: {0}", e.Message); return(default(T)); } } else { return(default(T)); } }
public virtual QMetaObject MetaObject() { if (SmokeMarshallers.IsSmokeClass(GetType())) { return((QMetaObject)interceptor.Invoke("metaObject", "metaObject()", typeof(QMetaObject), false)); } else { return(Qyoto.GetMetaObject(this)); } }
public override IMessage Invoke(IMessage message) { IMethodCallMessage callMessage = (IMethodCallMessage)message; StackItem[] stack = new StackItem[callMessage.ArgCount + 1]; #if DEBUG if ((QDebug.DebugChannel() & QtDebugChannel.QTDB_TRANSPARENT_PROXY) != 0) { Console.WriteLine("ENTER SignalInvocation.Invoke() MethodName: {0}.{1} Type: {2} ArgCount: {3}", instance, callMessage.MethodName, callMessage.TypeName, callMessage.ArgCount.ToString()); } #endif unsafe { fixed(StackItem *stackPtr = stack) { for (int i = 0; i < callMessage.ArgCount; i++) { SmokeMarshallers.UnboxToStackItem(callMessage.Args[i], stackPtr + i + 1); } IMethodReturnMessage returnMessage = new ReturnMessage(null, callMessage); /*(IMethodReturnMessage) message;*/ MethodReturnMessageWrapper returnValue = new MethodReturnMessageWrapper((IMethodReturnMessage)returnMessage); #if DEBUG GCHandle instanceHandle = DebugGCHandle.Alloc(instance); #else GCHandle instanceHandle = GCHandle.Alloc(instance); #endif Qyoto.CPPMethod signalEntry = Qyoto.GetSignalSignature(signalsInterface, (MethodInfo)callMessage.MethodBase); Type returnType = ((MethodInfo)returnMessage.MethodBase).ReturnType; SignalEmit(signalEntry.signature, signalEntry.type, (IntPtr)instanceHandle, (IntPtr)stackPtr, callMessage.ArgCount); if (returnType != typeof(void)) { returnValue.ReturnValue = SmokeMarshallers.BoxFromStackItem(returnType, 0, stackPtr); } returnMessage = returnValue; return(returnMessage); } } }
public List <T> FindChildren <T>(QRegExp regExp) { List <T> list = new List <T>(); AddToListFn addFn = delegate(IntPtr obj) { T o = (T)((System.Runtime.InteropServices.GCHandle)obj).Target; list.Add(o); }; string childClassName = null; IntPtr metaObject = IntPtr.Zero; if (SmokeMarshallers.IsSmokeClass(typeof(T))) { childClassName = SmokeMarshallers.SmokeClassName(typeof(T)); } else { metaObject = (IntPtr)GCHandle.Alloc(Qyoto.GetMetaObject(typeof(T))); } FindQObjectChildren((IntPtr)GCHandle.Alloc(this), childClassName, metaObject, (IntPtr)GCHandle.Alloc(regExp), string.Empty, addFn); return(list); }
public static void InitRuntime() { if (runtimeInitialized) { return; } Qyoto.Init_qyoto_qtcore(); SmokeMarshallers.SetUp(); QMetaType.RegisterType <object>(); // not set when mono is embedded if (AppDomain.CurrentDomain.SetupInformation.ConfigurationFile == null) { PropertyInfo pi = typeof(AppDomain).GetProperty("SetupInformationNoCopy", BindingFlags.NonPublic | BindingFlags.Instance); AppDomainSetup setup = (AppDomainSetup)pi.GetValue(AppDomain.CurrentDomain, null); setup.ConfigurationFile = Assembly.GetExecutingAssembly().Location + ".config"; } foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies()) { TryInitialize(a); } runtimeInitialized = true; }