コード例 #1
0
        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);
                }
            }
        }