Exemplo n.º 1
0
        public QRect BoundingRect(int x, int y, int w, int h, int flags, string text, int tabstops, ref int tabarray)
        {
            StackItem[] stack = new StackItem[9];
            stack[1].s_int = x;
            stack[2].s_int = y;
            stack[3].s_int = w;
            stack[4].s_int = h;
            stack[5].s_int = flags;
#if DEBUG
            stack[6].s_class = (IntPtr)DebugGCHandle.Alloc(text);
#else
            stack[6].s_class = (IntPtr)GCHandle.Alloc(text);
#endif
            stack[7].s_int = tabstops;
            stack[8].s_int = tabarray;
            interceptor.Invoke("boundingRect$$$$$$$$", "boundingRect(int, int, int, int, int, const QString&, int, int*) const", stack);
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[6].s_class);
#else
            ((GCHandle)stack[6].s_class).SynchronizedFree();
#endif
            tabarray = stack[8].s_int;
            object returnValue = ((GCHandle)stack[0].s_class).Target;
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[0].s_class);
#else
            ((GCHandle)stack[0].s_class).SynchronizedFree();
#endif
            return((QRect)returnValue);
        }
Exemplo n.º 2
0
        public long ReadDatagram(Pointer <sbyte> data, long maxlen, QHostAddress host, ref short port)
        {
            StackItem[] stack = new StackItem[5];
#if DEBUG
            stack[1].s_class = (IntPtr)DebugGCHandle.Alloc(data);
#else
            stack[1].s_class = (IntPtr)GCHandle.Alloc(data);
#endif
            stack[2].s_long = maxlen;
#if DEBUG
            stack[3].s_class = (IntPtr)DebugGCHandle.Alloc(host);
#else
            stack[3].s_class = (IntPtr)GCHandle.Alloc(host);
#endif
            stack[4].s_short = port;
            interceptor.Invoke("readDatagram$$#$", "readDatagram(char*, qint64, QHostAddress*, unsigned short*)", stack);
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[1].s_class);
#else
            ((GCHandle)stack[1].s_class).SynchronizedFree();
#endif
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[3].s_class);
#else
            ((GCHandle)stack[3].s_class).SynchronizedFree();
#endif
            port = stack[4].s_short;
            return(stack[0].s_long);
        }
Exemplo n.º 3
0
        public bool SetContent(QByteArray text, bool namespaceProcessing, StringBuilder errorMsg, ref int errorLine)
        {
            StackItem[] stack = new StackItem[5];
#if DEBUG
            stack[1].s_class = (IntPtr)DebugGCHandle.Alloc(text);
#else
            stack[1].s_class = (IntPtr)GCHandle.Alloc(text);
#endif
            stack[2].s_bool = namespaceProcessing;
#if DEBUG
            stack[3].s_class = (IntPtr)DebugGCHandle.Alloc(errorMsg);
#else
            stack[3].s_class = (IntPtr)GCHandle.Alloc(errorMsg);
#endif
            stack[4].s_int = errorLine;
            interceptor.Invoke("setContent#$$$", "setContent(const QByteArray&, bool, QString*, int*)", stack);
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[1].s_class);
#else
            ((GCHandle)stack[1].s_class).SynchronizedFree();
#endif
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[3].s_class);
#else
            ((GCHandle)stack[3].s_class).SynchronizedFree();
#endif
            errorLine = stack[4].s_int;
            return(stack[0].s_bool);
        }
Exemplo n.º 4
0
        public static QFont GetFont(ref bool ok, QFont initial, QWidget parent)
        {
            StackItem[] stack = new StackItem[4];
            stack[1].s_bool = ok;
#if DEBUG
            stack[2].s_class = (IntPtr)DebugGCHandle.Alloc(initial);
#else
            stack[2].s_class = (IntPtr)GCHandle.Alloc(initial);
#endif
#if DEBUG
            stack[3].s_class = (IntPtr)DebugGCHandle.Alloc(parent);
#else
            stack[3].s_class = (IntPtr)GCHandle.Alloc(parent);
#endif
            staticInterceptor.Invoke("getFont$##", "getFont(bool*, const QFont&, QWidget*)", stack);
            ok = stack[1].s_bool;
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[2].s_class);
#else
            ((GCHandle)stack[2].s_class).SynchronizedFree();
#endif
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[3].s_class);
#else
            ((GCHandle)stack[3].s_class).SynchronizedFree();
#endif
            object returnValue = ((GCHandle)stack[0].s_class).Target;
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[0].s_class);
#else
            ((GCHandle)stack[0].s_class).SynchronizedFree();
#endif
            return((QFont)returnValue);
        }
Exemplo n.º 5
0
        public QSizeF Size(int flags, string str, int tabstops, ref int tabarray)
        {
            StackItem[] stack = new StackItem[5];
            stack[1].s_int = flags;
#if DEBUG
            stack[2].s_class = (IntPtr)DebugGCHandle.Alloc(str);
#else
            stack[2].s_class = (IntPtr)GCHandle.Alloc(str);
#endif
            stack[3].s_int = tabstops;
            stack[4].s_int = tabarray;
            interceptor.Invoke("size$$$$", "size(int, const QString&, int, int*) const", stack);
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[2].s_class);
#else
            ((GCHandle)stack[2].s_class).SynchronizedFree();
#endif
            tabarray = stack[4].s_int;
            object returnValue = ((GCHandle)stack[0].s_class).Target;
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[0].s_class);
#else
            ((GCHandle)stack[0].s_class).SynchronizedFree();
#endif
            return((QSizeF)returnValue);
        }
Exemplo n.º 6
0
        public static IntPtr OverridenMethod(IntPtr instance, string method)
        {
            Type klass = ((GCHandle)instance).Target.GetType();

            if (method == "metaObject() const")
            {
#if DEBUG
                return((IntPtr)DebugGCHandle.Alloc(metaObjectMethod));
#else
                return((IntPtr)GCHandle.Alloc(metaObjectMethod));
#endif
            }

            Dictionary <string, MemberInfo> methods;
            if (!overridenMethods.TryGetValue(klass, out methods))
            {
                return((IntPtr)0);
            }

            MemberInfo methodInfo;
            if (!methods.TryGetValue(method, out methodInfo))
            {
                return((IntPtr)0);
            }

#if DEBUG
            return((IntPtr)DebugGCHandle.Alloc(methodInfo));
#else
            return((IntPtr)GCHandle.Alloc(methodInfo));
#endif
        }
Exemplo n.º 7
0
        public bool SetContent(QIODevice dev, StringBuilder errorMsg, ref int errorLine)
        {
            StackItem[] stack = new StackItem[4];
#if DEBUG
            stack[1].s_class = (IntPtr)DebugGCHandle.Alloc(dev);
#else
            stack[1].s_class = (IntPtr)GCHandle.Alloc(dev);
#endif
#if DEBUG
            stack[2].s_class = (IntPtr)DebugGCHandle.Alloc(errorMsg);
#else
            stack[2].s_class = (IntPtr)GCHandle.Alloc(errorMsg);
#endif
            stack[3].s_int = errorLine;
            interceptor.Invoke("setContent#$$", "setContent(QIODevice*, QString*, int*)", stack);
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[1].s_class);
#else
            ((GCHandle)stack[1].s_class).SynchronizedFree();
#endif
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[2].s_class);
#else
            ((GCHandle)stack[2].s_class).SynchronizedFree();
#endif
            errorLine = stack[3].s_int;
            return(stack[0].s_bool);
        }
Exemplo n.º 8
0
        public bool SetContent(string text, StringBuilder errorMsg, ref int errorLine, ref int errorColumn)
        {
            StackItem[] stack = new StackItem[5];
#if DEBUG
            stack[1].s_class = (IntPtr)DebugGCHandle.Alloc(text);
#else
            stack[1].s_class = (IntPtr)GCHandle.Alloc(text);
#endif
#if DEBUG
            stack[2].s_class = (IntPtr)DebugGCHandle.Alloc(errorMsg);
#else
            stack[2].s_class = (IntPtr)GCHandle.Alloc(errorMsg);
#endif
            stack[3].s_int = errorLine;
            stack[4].s_int = errorColumn;
            interceptor.Invoke("setContent$$$$", "setContent(const QString&, QString*, int*, int*)", stack);
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[1].s_class);
#else
            ((GCHandle)stack[1].s_class).SynchronizedFree();
#endif
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[2].s_class);
#else
            ((GCHandle)stack[2].s_class).SynchronizedFree();
#endif
            errorLine   = stack[3].s_int;
            errorColumn = stack[4].s_int;
            return(stack[0].s_bool);
        }
Exemplo n.º 9
0
        public static bool Connect(QObject sender, int signal_index, QObject receiver, int method_index, int type, ref int types)
        {
            StackItem[] stack = new StackItem[7];
#if DEBUG
            stack[1].s_class = (IntPtr)DebugGCHandle.Alloc(sender);
#else
            stack[1].s_class = (IntPtr)GCHandle.Alloc(sender);
#endif
            stack[2].s_int = signal_index;
#if DEBUG
            stack[3].s_class = (IntPtr)DebugGCHandle.Alloc(receiver);
#else
            stack[3].s_class = (IntPtr)GCHandle.Alloc(receiver);
#endif
            stack[4].s_int = method_index;
            stack[5].s_int = type;
            stack[6].s_int = types;
            staticInterceptor.Invoke("connect#$#$$$", "connect(const QObject*, int, const QObject*, int, int, int*)", stack);
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[1].s_class);
#else
            ((GCHandle)stack[1].s_class).SynchronizedFree();
#endif
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[3].s_class);
#else
            ((GCHandle)stack[3].s_class).SynchronizedFree();
#endif
            types = stack[6].s_int;
            return(stack[0].s_bool);
        }
Exemplo n.º 10
0
        public virtual uint QueryProperty(QScriptValue arg1, QScriptString name, uint flags, ref int id)
        {
            StackItem[] stack = new StackItem[5];
#if DEBUG
            stack[1].s_class = (IntPtr)DebugGCHandle.Alloc(arg1);
#else
            stack[1].s_class = (IntPtr)GCHandle.Alloc(arg1);
#endif
#if DEBUG
            stack[2].s_class = (IntPtr)DebugGCHandle.Alloc(name);
#else
            stack[2].s_class = (IntPtr)GCHandle.Alloc(name);
#endif
            stack[3].s_uint = flags;
            stack[4].s_int  = id;
            interceptor.Invoke("queryProperty##$$", "queryProperty(const QScriptValue&, const QScriptString&, QScriptClass::QueryFlags, uint*)", stack);
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[1].s_class);
#else
            ((GCHandle)stack[1].s_class).SynchronizedFree();
#endif
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[2].s_class);
#else
            ((GCHandle)stack[2].s_class).SynchronizedFree();
#endif
            id = stack[4].s_int;
            return(stack[0].s_uint);
        }
Exemplo n.º 11
0
        public override int GetHashCode()
        {
#if DEBUG
            return(QyotoHash((IntPtr)DebugGCHandle.Alloc(instance)));
#else
            return(QyotoHash((IntPtr)GCHandle.Alloc(instance)));
#endif
        }
Exemplo n.º 12
0
        public static string GetItem(QWidget parent, string title, string label, List <string> items, int current, bool editable, ref bool ok, uint flags)
        {
            StackItem[] stack = new StackItem[9];
#if DEBUG
            stack[1].s_class = (IntPtr)DebugGCHandle.Alloc(parent);
#else
            stack[1].s_class = (IntPtr)GCHandle.Alloc(parent);
#endif
#if DEBUG
            stack[2].s_class = (IntPtr)DebugGCHandle.Alloc(title);
#else
            stack[2].s_class = (IntPtr)GCHandle.Alloc(title);
#endif
#if DEBUG
            stack[3].s_class = (IntPtr)DebugGCHandle.Alloc(label);
#else
            stack[3].s_class = (IntPtr)GCHandle.Alloc(label);
#endif
#if DEBUG
            stack[4].s_class = (IntPtr)DebugGCHandle.Alloc(items);
#else
            stack[4].s_class = (IntPtr)GCHandle.Alloc(items);
#endif
            stack[5].s_int  = current;
            stack[6].s_bool = editable;
            stack[7].s_bool = ok;
            stack[8].s_uint = flags;
            staticInterceptor.Invoke("getItem#$$?$$$$", "getItem(QWidget*, const QString&, const QString&, const QStringList&, int, bool, bool*, Qt::WindowFlags)", stack);
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[1].s_class);
#else
            ((GCHandle)stack[1].s_class).SynchronizedFree();
#endif
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[2].s_class);
#else
            ((GCHandle)stack[2].s_class).SynchronizedFree();
#endif
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[3].s_class);
#else
            ((GCHandle)stack[3].s_class).SynchronizedFree();
#endif
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[4].s_class);
#else
            ((GCHandle)stack[4].s_class).SynchronizedFree();
#endif
            ok = stack[7].s_bool;
            object returnValue = ((GCHandle)stack[0].s_class).Target;
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[0].s_class);
#else
            ((GCHandle)stack[0].s_class).SynchronizedFree();
#endif
            return((string)returnValue);
        }
Exemplo n.º 13
0
        // A variant of Invoke() for use in method calls with 'ref' argument types.
        // The caller is responsible for setting up the stack, and copying items
        // back from the stack to the arguments after Invoke() has been called.
        public void Invoke(string mungedName, string signature, StackItem[] stack)
        {
#if DEBUG
            if ((QDebug.DebugChannel() & QtDebugChannel.QTDB_TRANSPARENT_PROXY) != 0)
            {
                Console.WriteLine("ENTER SmokeInvocation.Invoke1() MethodName: {0}.{1}",
                                  className,
                                  signature);
            }
#endif

            ModuleIndex methodId;
            methodId.smoke = IntPtr.Zero;
            methodId.index = -1;
            if (!methodIdCache.TryGetValue(signature, out methodId))
            {
                methodId = FindMethodId(className, mungedName, signature);

                if (methodId.index == -1)
                {
                    Console.Error.WriteLine("LEAVE Invoke() ** Missing method ** {0}.{1}",
                                            className,
                                            signature);
                    return;
                }

                methodIdCache[signature] = methodId;
            }

            unsafe
            {
                fixed(StackItem *stackPtr = stack)
                {
                    if (instance == null)
                    {
                        CallSmokeMethod(methodId.smoke, (int)methodId.index, (IntPtr)0, (IntPtr)stackPtr, stack.Length);
                    }
                    else
                    {
#if DEBUG
                        GCHandle instanceHandle = DebugGCHandle.Alloc(instance);
#else
                        GCHandle instanceHandle = GCHandle.Alloc(instance);
#endif
                        CallSmokeMethod(methodId.smoke, methodId.index, (IntPtr)instanceHandle, (IntPtr)stackPtr, stack.Length);
#if DEBUG
                        DebugGCHandle.Free(instanceHandle);
#else
                        instanceHandle.SynchronizedFree();
#endif
                    }
                }
            }

            return;
        }
Exemplo n.º 14
0
        public static string GetText(QWidget parent, string title, string label, QLineEdit.EchoMode echo, string text, ref bool ok, uint flags)
        {
            StackItem[] stack = new StackItem[8];
#if DEBUG
            stack[1].s_class = (IntPtr)DebugGCHandle.Alloc(parent);
#else
            stack[1].s_class = (IntPtr)GCHandle.Alloc(parent);
#endif
#if DEBUG
            stack[2].s_class = (IntPtr)DebugGCHandle.Alloc(title);
#else
            stack[2].s_class = (IntPtr)GCHandle.Alloc(title);
#endif
#if DEBUG
            stack[3].s_class = (IntPtr)DebugGCHandle.Alloc(label);
#else
            stack[3].s_class = (IntPtr)GCHandle.Alloc(label);
#endif
            stack[4].s_int = (int)echo;
#if DEBUG
            stack[5].s_class = (IntPtr)DebugGCHandle.Alloc(text);
#else
            stack[5].s_class = (IntPtr)GCHandle.Alloc(text);
#endif
            stack[6].s_bool = ok;
            stack[7].s_uint = flags;
            staticInterceptor.Invoke("getText#$$$$$$", "getText(QWidget*, const QString&, const QString&, QLineEdit::EchoMode, const QString&, bool*, Qt::WindowFlags)", stack);
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[1].s_class);
#else
            ((GCHandle)stack[1].s_class).SynchronizedFree();
#endif
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[2].s_class);
#else
            ((GCHandle)stack[2].s_class).SynchronizedFree();
#endif
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[3].s_class);
#else
            ((GCHandle)stack[3].s_class).SynchronizedFree();
#endif
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[5].s_class);
#else
            ((GCHandle)stack[5].s_class).SynchronizedFree();
#endif
            ok = stack[6].s_bool;
            object returnValue = ((GCHandle)stack[0].s_class).Target;
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[0].s_class);
#else
            ((GCHandle)stack[0].s_class).SynchronizedFree();
#endif
            return((string)returnValue);
        }
Exemplo n.º 15
0
        public override QValidator.State Validate(StringBuilder arg1, ref int arg2)
        {
            StackItem[] stack = new StackItem[3];
#if DEBUG
            stack[1].s_class = (IntPtr)DebugGCHandle.Alloc(arg1);
#else
            stack[1].s_class = (IntPtr)GCHandle.Alloc(arg1);
#endif
            stack[2].s_int = arg2;
            interceptor.Invoke("validate$$", "validate(QString&, int&) const", stack);
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[1].s_class);
#else
            ((GCHandle)stack[1].s_class).SynchronizedFree();
#endif
            arg2 = stack[2].s_int;
            return((QValidator.State)Enum.ToObject(typeof(QValidator.State), stack[0].s_int));
        }
Exemplo n.º 16
0
        protected new virtual QValidator.State Validate(StringBuilder input, ref int pos)
        {
            StackItem[] stack = new StackItem[3];
#if DEBUG
            stack[1].s_class = (IntPtr)DebugGCHandle.Alloc(input);
#else
            stack[1].s_class = (IntPtr)GCHandle.Alloc(input);
#endif
            stack[2].s_int = pos;
            interceptor.Invoke("validate$$", "validate(QString&, int&) const", stack);
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[1].s_class);
#else
            ((GCHandle)stack[1].s_class).SynchronizedFree();
#endif
            pos = stack[2].s_int;
            return((QValidator.State)Enum.ToObject(typeof(QValidator.State), stack[0].s_int));
        }
Exemplo n.º 17
0
        public double ToDouble(string s, ref bool ok)
        {
            StackItem[] stack = new StackItem[3];
#if DEBUG
            stack[1].s_class = (IntPtr)DebugGCHandle.Alloc(s);
#else
            stack[1].s_class = (IntPtr)GCHandle.Alloc(s);
#endif
            stack[2].s_bool = ok;
            interceptor.Invoke("toDouble$$", "toDouble(const QString&, bool*) const", stack);
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[1].s_class);
#else
            ((GCHandle)stack[1].s_class).SynchronizedFree();
#endif
            ok = stack[2].s_bool;
            return(stack[0].s_double);
        }
Exemplo n.º 18
0
        public override bool Feature(string name, ref bool ok)
        {
            StackItem[] stack = new StackItem[3];
#if DEBUG
            stack[1].s_class = (IntPtr)DebugGCHandle.Alloc(name);
#else
            stack[1].s_class = (IntPtr)GCHandle.Alloc(name);
#endif
            stack[2].s_bool = ok;
            interceptor.Invoke("feature$$", "feature(const QString&, bool*) const", stack);
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[1].s_class);
#else
            ((GCHandle)stack[1].s_class).SynchronizedFree();
#endif
            ok = stack[2].s_bool;
            return(stack[0].s_bool);
        }
Exemplo n.º 19
0
        public long ToULongLong(string s, ref bool ok, int arg3)
        {
            StackItem[] stack = new StackItem[4];
#if DEBUG
            stack[1].s_class = (IntPtr)DebugGCHandle.Alloc(s);
#else
            stack[1].s_class = (IntPtr)GCHandle.Alloc(s);
#endif
            stack[2].s_bool = ok;
            stack[3].s_int  = arg3;
            interceptor.Invoke("toULongLong$$$", "toULongLong(const QString&, bool*, int) const", stack);
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[1].s_class);
#else
            ((GCHandle)stack[1].s_class).SynchronizedFree();
#endif
            ok = stack[2].s_bool;
            return(stack[0].s_long);
        }
Exemplo n.º 20
0
        public void GetLayoutPosition(QLayout layout, ref int rowPtr, QFormLayout.ItemRole rolePtr)
        {
            StackItem[] stack = new StackItem[4];
#if DEBUG
            stack[1].s_class = (IntPtr)DebugGCHandle.Alloc(layout);
#else
            stack[1].s_class = (IntPtr)GCHandle.Alloc(layout);
#endif
            stack[2].s_int = rowPtr;
            stack[3].s_int = (int)rolePtr;
            interceptor.Invoke("getLayoutPosition#$$", "getLayoutPosition(QLayout*, int*, QFormLayout::ItemRole*) const", stack);
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[1].s_class);
#else
            ((GCHandle)stack[1].s_class).Free();
#endif
            rowPtr = stack[2].s_int;
            return;
        }
Exemplo n.º 21
0
        public static int GetInteger(QWidget parent, string title, string label, int value, int minValue, int maxValue, int step, ref bool ok, uint flags)
        {
            StackItem[] stack = new StackItem[10];
#if DEBUG
            stack[1].s_class = (IntPtr)DebugGCHandle.Alloc(parent);
#else
            stack[1].s_class = (IntPtr)GCHandle.Alloc(parent);
#endif
#if DEBUG
            stack[2].s_class = (IntPtr)DebugGCHandle.Alloc(title);
#else
            stack[2].s_class = (IntPtr)GCHandle.Alloc(title);
#endif
#if DEBUG
            stack[3].s_class = (IntPtr)DebugGCHandle.Alloc(label);
#else
            stack[3].s_class = (IntPtr)GCHandle.Alloc(label);
#endif
            stack[4].s_int  = value;
            stack[5].s_int  = minValue;
            stack[6].s_int  = maxValue;
            stack[7].s_int  = step;
            stack[8].s_bool = ok;
            stack[9].s_uint = flags;
            staticInterceptor.Invoke("getInteger#$$$$$$$$", "getInteger(QWidget*, const QString&, const QString&, int, int, int, int, bool*, Qt::WindowFlags)", stack);
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[1].s_class);
#else
            ((GCHandle)stack[1].s_class).SynchronizedFree();
#endif
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[2].s_class);
#else
            ((GCHandle)stack[2].s_class).SynchronizedFree();
#endif
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[3].s_class);
#else
            ((GCHandle)stack[3].s_class).SynchronizedFree();
#endif
            ok = stack[8].s_bool;
            return(stack[0].s_int);
        }
Exemplo n.º 22
0
        public static uint GetRgba(uint rgba, ref bool ok, QWidget parent)
        {
            StackItem[] stack = new StackItem[4];
            stack[1].s_uint = rgba;
            stack[2].s_bool = ok;
#if DEBUG
            stack[3].s_class = (IntPtr)DebugGCHandle.Alloc(parent);
#else
            stack[3].s_class = (IntPtr)GCHandle.Alloc(parent);
#endif
            staticInterceptor.Invoke("getRgba$$#", "getRgba(unsigned int, bool*, QWidget*)", stack);
            ok = stack[2].s_bool;
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[3].s_class);
#else
            ((GCHandle)stack[3].s_class).SynchronizedFree();
#endif
            return(stack[0].s_uint);
        }
Exemplo n.º 23
0
        public static double GetDouble(QWidget parent, string title, string label, double value, double minValue, double maxValue, int decimals, ref bool ok)
        {
            StackItem[] stack = new StackItem[9];
#if DEBUG
            stack[1].s_class = (IntPtr)DebugGCHandle.Alloc(parent);
#else
            stack[1].s_class = (IntPtr)GCHandle.Alloc(parent);
#endif
#if DEBUG
            stack[2].s_class = (IntPtr)DebugGCHandle.Alloc(title);
#else
            stack[2].s_class = (IntPtr)GCHandle.Alloc(title);
#endif
#if DEBUG
            stack[3].s_class = (IntPtr)DebugGCHandle.Alloc(label);
#else
            stack[3].s_class = (IntPtr)GCHandle.Alloc(label);
#endif
            stack[4].s_double = value;
            stack[5].s_double = minValue;
            stack[6].s_double = maxValue;
            stack[7].s_int    = decimals;
            stack[8].s_bool   = ok;
            staticInterceptor.Invoke("getDouble#$$$$$$$", "getDouble(QWidget*, const QString&, const QString&, double, double, double, int, bool*)", stack);
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[1].s_class);
#else
            ((GCHandle)stack[1].s_class).SynchronizedFree();
#endif
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[2].s_class);
#else
            ((GCHandle)stack[2].s_class).SynchronizedFree();
#endif
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[3].s_class);
#else
            ((GCHandle)stack[3].s_class).SynchronizedFree();
#endif
            ok = stack[8].s_bool;
            return(stack[0].s_double);
        }
Exemplo n.º 24
0
        public bool SetContent(QXmlInputSource source, QXmlReader reader, StringBuilder errorMsg, ref int errorLine, ref int errorColumn)
        {
            StackItem[] stack = new StackItem[6];
#if DEBUG
            stack[1].s_class = (IntPtr)DebugGCHandle.Alloc(source);
#else
            stack[1].s_class = (IntPtr)GCHandle.Alloc(source);
#endif
#if DEBUG
            stack[2].s_class = (IntPtr)DebugGCHandle.Alloc(reader);
#else
            stack[2].s_class = (IntPtr)GCHandle.Alloc(reader);
#endif
#if DEBUG
            stack[3].s_class = (IntPtr)DebugGCHandle.Alloc(errorMsg);
#else
            stack[3].s_class = (IntPtr)GCHandle.Alloc(errorMsg);
#endif
            stack[4].s_int = errorLine;
            stack[5].s_int = errorColumn;
            interceptor.Invoke("setContent##$$$", "setContent(QXmlInputSource*, QXmlReader*, QString*, int*, int*)", stack);
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[1].s_class);
#else
            ((GCHandle)stack[1].s_class).SynchronizedFree();
#endif
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[2].s_class);
#else
            ((GCHandle)stack[2].s_class).SynchronizedFree();
#endif
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[3].s_class);
#else
            ((GCHandle)stack[3].s_class).SynchronizedFree();
#endif
            errorLine   = stack[4].s_int;
            errorColumn = stack[5].s_int;
            return(stack[0].s_bool);
        }
Exemplo n.º 25
0
        public static bool StartDetached(string program, List <string> arguments, string workingDirectory, ref long pid)
        {
            StackItem[] stack = new StackItem[5];
#if DEBUG
            stack[1].s_class = (IntPtr)DebugGCHandle.Alloc(program);
#else
            stack[1].s_class = (IntPtr)GCHandle.Alloc(program);
#endif
#if DEBUG
            stack[2].s_class = (IntPtr)DebugGCHandle.Alloc(arguments);
#else
            stack[2].s_class = (IntPtr)GCHandle.Alloc(arguments);
#endif
#if DEBUG
            stack[3].s_class = (IntPtr)DebugGCHandle.Alloc(workingDirectory);
#else
            stack[3].s_class = (IntPtr)GCHandle.Alloc(workingDirectory);
#endif
            stack[4].s_long = pid;
            staticInterceptor.Invoke("startDetached$?$?", "startDetached(const QString&, const QStringList&, const QString&, qint64*)", stack);
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[1].s_class);
#else
            ((GCHandle)stack[1].s_class).SynchronizedFree();
#endif
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[2].s_class);
#else
            ((GCHandle)stack[2].s_class).SynchronizedFree();
#endif
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[3].s_class);
#else
            ((GCHandle)stack[3].s_class).SynchronizedFree();
#endif
            pid = stack[4].s_long;
            return(stack[0].s_bool);
        }
Exemplo n.º 26
0
        public QRectF BoundingRect(QRectF r, int flags, string arg3, int tabstops, ref int tabarray)
        {
            StackItem[] stack = new StackItem[6];
#if DEBUG
            stack[1].s_class = (IntPtr)DebugGCHandle.Alloc(r);
#else
            stack[1].s_class = (IntPtr)GCHandle.Alloc(r);
#endif
            stack[2].s_int = flags;
#if DEBUG
            stack[3].s_class = (IntPtr)DebugGCHandle.Alloc(arg3);
#else
            stack[3].s_class = (IntPtr)GCHandle.Alloc(arg3);
#endif
            stack[4].s_int = tabstops;
            stack[5].s_int = tabarray;
            interceptor.Invoke("boundingRect#$$$$", "boundingRect(const QRectF&, int, const QString&, int, int*) const", stack);
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[1].s_class);
#else
            ((GCHandle)stack[1].s_class).SynchronizedFree();
#endif
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[3].s_class);
#else
            ((GCHandle)stack[3].s_class).SynchronizedFree();
#endif
            tabarray = stack[5].s_int;
            object returnValue = ((GCHandle)stack[0].s_class).Target;
#if DEBUG
            DebugGCHandle.Free((GCHandle)stack[0].s_class);
#else
            ((GCHandle)stack[0].s_class).SynchronizedFree();
#endif
            return((QRectF)returnValue);
        }
Exemplo n.º 27
0
        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

            if (callMessage.MethodSignature != null)
            {
                Type[] types = (Type[])callMessage.MethodSignature;

                for (int i = 0; i < callMessage.ArgCount; i++)
                {
                    if (callMessage.Args[i] == null)
                    {
                        unsafe {
                            stack[i + 1].s_class = (IntPtr)0;
                        }
                    }
                    else if (types[i] == typeof(bool))
                    {
                        stack[i + 1].s_bool = (bool)callMessage.Args[i];
                    }
                    else if (types[i] == typeof(sbyte))
                    {
                        stack[i + 1].s_char = (sbyte)callMessage.Args[i];
                    }
                    else if (types[i] == typeof(byte))
                    {
                        stack[i + 1].s_uchar = (byte)callMessage.Args[i];
                    }
                    else if (types[i] == typeof(char))
                    {
                        stack[i + 1].s_uchar = (byte)(char)callMessage.Args[i];
                    }
                    else if (types[i] == typeof(short))
                    {
                        stack[i + 1].s_short = (short)callMessage.Args[i];
                    }
                    else if (types[i] == typeof(ushort))
                    {
                        stack[i + 1].s_ushort = (ushort)callMessage.Args[i];
                    }
                    else if (types[i] == typeof(int) || types[i].IsEnum)
                    {
                        stack[i + 1].s_int = (int)callMessage.Args[i];
                    }
                    else if (types[i] == typeof(uint))
                    {
                        stack[i + 1].s_uint = (uint)callMessage.Args[i];
                    }
                    else if (types[i] == typeof(long))
                    {
                        stack[i + 1].s_long = (long)callMessage.Args[i];
                    }
                    else if (types[i] == typeof(ulong))
                    {
                        stack[i + 1].s_ulong = (ulong)callMessage.Args[i];
                    }
                    else if (types[i] == typeof(float))
                    {
                        stack[i + 1].s_float = (float)callMessage.Args[i];
                    }
                    else if (types[i] == typeof(double))
                    {
                        stack[i + 1].s_double = (double)callMessage.Args[i];
                    }
                    else if (types[i] == typeof(string))
                    {
#if DEBUG
                        stack[i + 1].s_class = (IntPtr)DebugGCHandle.Alloc(callMessage.Args[i]);
#else
                        stack[i + 1].s_class = (IntPtr)GCHandle.Alloc(callMessage.Args[i]);
#endif
                    }
                    else
                    {
#if DEBUG
                        stack[i + 1].s_class = (IntPtr)DebugGCHandle.Alloc(callMessage.Args[i]);
#else
                        stack[i + 1].s_class = (IntPtr)GCHandle.Alloc(callMessage.Args[i]);
#endif
                    }
                }
            }

            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);

            unsafe
            {
                fixed(StackItem *stackPtr = stack)
                {
                    Type returnType = ((MethodInfo)returnMessage.MethodBase).ReturnType;

                    SignalEmit(signalEntry.signature, signalEntry.type, (IntPtr)instanceHandle, (IntPtr)stackPtr, callMessage.ArgCount);

                    if (returnType == typeof(void))
                    {
                        ;
                    }
                    else if (returnType == typeof(bool))
                    {
                        returnValue.ReturnValue = stack[0].s_bool;
                    }
                    else if (returnType == typeof(sbyte))
                    {
                        returnValue.ReturnValue = stack[0].s_char;
                    }
                    else if (returnType == typeof(byte))
                    {
                        returnValue.ReturnValue = stack[0].s_uchar;
                    }
                    else if (returnType == typeof(char))
                    {
                        returnValue.ReturnValue = (char)stack[0].s_uchar;
                    }
                    else if (returnType == typeof(short))
                    {
                        returnValue.ReturnValue = stack[0].s_short;
                    }
                    else if (returnType == typeof(ushort))
                    {
                        returnValue.ReturnValue = stack[0].s_ushort;
                    }
                    else if (returnType.IsEnum)
                    {
                        returnValue.ReturnValue = Enum.ToObject(returnType, stack[0].s_int);
                    }
                    else if (returnType == typeof(int))
                    {
                        returnValue.ReturnValue = stack[0].s_int;
                    }
                    else if (returnType == typeof(uint))
                    {
                        returnValue.ReturnValue = stack[0].s_uint;
                    }
                    else if (returnType == typeof(long))
                    {
                        // s_long will contain the wrong value on 32 bit platforms
                        // (i.e. where a native C++ 'long' isn't at least 64 bit)
                        returnValue.ReturnValue = (SmokeMarshallers.SizeOfNativeLong < sizeof(long))? stack[0].s_int : stack[0].s_long;
                    }
                    else if (returnType == typeof(ulong))
                    {
                        returnValue.ReturnValue = (SmokeMarshallers.SizeOfNativeLong < sizeof(long))? stack[0].s_uint : stack[0].s_ulong;
                    }
                    else if (returnType == typeof(float))
                    {
                        returnValue.ReturnValue = stack[0].s_float;
                    }
                    else if (returnType == typeof(double))
                    {
                        returnValue.ReturnValue = stack[0].s_double;
                    }
                    else if (returnType == typeof(string))
                    {
                        if (stack[0].s_class != IntPtr.Zero)
                        {
                            returnValue.ReturnValue = ((GCHandle)stack[0].s_class).Target;
#if DEBUG
                            DebugGCHandle.Free((GCHandle)stack[0].s_class);
#else
                            ((GCHandle)stack[0].s_class).SynchronizedFree();
#endif
                        }
                    }
                    else
                    {
                        if (stack[0].s_class != IntPtr.Zero)
                        {
                            returnValue.ReturnValue = ((GCHandle)stack[0].s_class).Target;
#if DEBUG
                            DebugGCHandle.Free((GCHandle)stack[0].s_class);
#else
                            ((GCHandle)stack[0].s_class).SynchronizedFree();
#endif
                        }
                    }
                }
            }

            returnMessage = returnValue;
            return(returnMessage);
        }
Exemplo n.º 28
0
        public object Invoke(string mungedName, string signature, Type returnType, params object[] args)
        {
#if DEBUG
            if ((QDebug.DebugChannel() & QtDebugChannel.QTDB_TRANSPARENT_PROXY) != 0)
            {
                Console.WriteLine("ENTER SmokeInvocation.Invoke() MethodName: {0}.{1} Type: {2} ArgCount: {3}",
                                  className,
                                  signature,
                                  returnType,
                                  args.Length / 2);
            }
#endif

            if (signature.StartsWith("operator=="))
            {
                if (args[1] == null && args[3] == null)
                {
                    return(true);
                }
                else if (args[1] == null || args[3] == null)
                {
                    return(false);
                }
            }
            ModuleIndex methodId;
            methodId.smoke = IntPtr.Zero;
            methodId.index = -1;
            if (!methodIdCache.TryGetValue(signature, out methodId))
            {
                methodId = FindMethodId(className, mungedName, signature);

                if (methodId.index == -1)
                {
                    Console.Error.WriteLine("LEAVE Invoke() ** Missing method ** {0}.{1}",
                                            className,
                                            signature);
                    return(null);
                }

                methodIdCache[signature] = methodId;
            }

            StackItem[] stack = new StackItem[(args.Length / 2) + 1];

            for (int i = 0, k = 1; i < args.Length; i += 2, k++)
            {
                if (args[i + 1] == null)
                {
                    unsafe {
                        stack[k].s_class = IntPtr.Zero;
                    }
                }
                else if (args[i] == typeof(int) || ((Type)args[i]).IsEnum)
                {
                    stack[k].s_int = (int)args[i + 1];
                }
                else if (args[i] == typeof(bool))
                {
                    stack[k].s_bool = (bool)args[i + 1];
                }
                else if (args[i] == typeof(short))
                {
                    stack[k].s_short = (short)args[i + 1];
                }
                else if (args[i] == typeof(float))
                {
                    stack[k].s_float = (float)args[i + 1];
                }
                else if (args[i] == typeof(double))
                {
                    stack[k].s_double = (double)args[i + 1];
                }
                else if (args[i] == typeof(long))
                {
                    stack[k].s_long = (long)args[i + 1];
                }
                else if (args[i] == typeof(ushort))
                {
                    stack[k].s_ushort = (ushort)args[i + 1];
                }
                else if (args[i] == typeof(uint))
                {
                    stack[k].s_uint = (uint)args[i + 1];
                }
                else if (args[i] == typeof(ulong))
                {
                    stack[k].s_ulong = (ulong)args[i + 1];
                }
                else if (args[i] == typeof(sbyte))
                {
                    stack[k].s_char = (sbyte)args[i + 1];
                }
                else if (args[i] == typeof(byte))
                {
                    stack[k].s_uchar = (byte)args[i + 1];
                }
                else if (args[i] == typeof(char))
                {
                    stack[k].s_uchar = (byte)(char)args[i + 1];
                }
                else
                {
#if DEBUG
                    stack[k].s_class = (IntPtr)DebugGCHandle.Alloc(args[i + 1]);
#else
                    stack[k].s_class = (IntPtr)GCHandle.Alloc(args[i + 1]);
#endif
                }
            }

            object returnValue = null;

            unsafe
            {
                fixed(StackItem *stackPtr = stack)
                {
                    if (instance == null)
                    {
                        CallSmokeMethod(methodId.smoke, (int)methodId.index, (IntPtr)0, (IntPtr)stackPtr, args.Length / 2);
                    }
                    else
                    {
#if DEBUG
                        GCHandle instanceHandle = DebugGCHandle.Alloc(instance);
#else
                        GCHandle instanceHandle = GCHandle.Alloc(instance);
#endif
                        CallSmokeMethod(methodId.smoke, methodId.index, (IntPtr)instanceHandle, (IntPtr)stackPtr, args.Length / 2);
#if DEBUG
                        DebugGCHandle.Free(instanceHandle);
#else
                        instanceHandle.SynchronizedFree();
#endif
                    }

                    if (returnType == typeof(void))
                    {
                        ;
                    }
                    else if (returnType == typeof(int))
                    {
                        returnValue = stack[0].s_int;
                    }
                    else if (returnType == typeof(bool))
                    {
                        returnValue = stack[0].s_bool;
                    }
                    else if (returnType == typeof(short))
                    {
                        returnValue = stack[0].s_short;
                    }
                    else if (returnType == typeof(float))
                    {
                        returnValue = stack[0].s_float;
                    }
                    else if (returnType == typeof(double))
                    {
                        returnValue = stack[0].s_double;
                    }
                    else if (returnType == typeof(long))
                    {
                        // s_long will contain the wrong value on 32 bit platforms
                        // (i.e. where a native C++ 'long' isn't at least 64 bit)
                        returnValue = (SmokeMarshallers.SizeOfNativeLong < sizeof(long))? stack[0].s_int : stack[0].s_long;
                    }
                    else if (returnType == typeof(ushort))
                    {
                        returnValue = stack[0].s_ushort;
                    }
                    else if (returnType == typeof(uint))
                    {
                        returnValue = stack[0].s_uint;
                    }
                    else if (returnType.IsEnum)
                    {
                        returnValue = Enum.ToObject(returnType, stack[0].s_int);
                    }
                    else if (returnType == typeof(ulong))
                    {
                        returnValue = (SmokeMarshallers.SizeOfNativeLong < sizeof(long))? stack[0].s_uint : stack[0].s_ulong;
                    }
                    else if (returnType == typeof(sbyte))
                    {
                        returnValue = stack[0].s_char;
                    }
                    else if (returnType == typeof(byte))
                    {
                        returnValue = stack[0].s_uchar;
                    }
                    else if (returnType == typeof(char))
                    {
                        returnValue = (char)stack[0].s_char;
                    }
                    else
                    {
                        if (((IntPtr)stack[0].s_class) == IntPtr.Zero)
                        {
                            returnValue = null;
                        }
                        else
                        {
                            returnValue = ((GCHandle)stack[0].s_class).Target;
#if DEBUG
                            DebugGCHandle.Free((GCHandle)stack[0].s_class);
#else
                            ((GCHandle)stack[0].s_class).SynchronizedFree();
#endif
                        }
                    }
                }
            }

            return(returnValue);
        }
Exemplo n.º 29
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++)
                {
                    if (parameters[i].ParameterType == typeof(bool))
                    {
                        args[i] = stackPtr[i].s_bool;
                    }
                    else if (parameters[i].ParameterType == typeof(sbyte))
                    {
                        args[i] = stackPtr[i].s_char;
                    }
                    else if (parameters[i].ParameterType == typeof(byte))
                    {
                        args[i] = stackPtr[i].s_uchar;
                    }
                    else if (parameters[i].ParameterType == typeof(char))
                    {
                        args[i] = (char)stackPtr[i].s_uchar;
                    }
                    else if (parameters[i].ParameterType == typeof(short))
                    {
                        args[i] = stackPtr[i].s_short;
                    }
                    else if (parameters[i].ParameterType == typeof(ushort))
                    {
                        args[i] = stackPtr[i].s_ushort;
                    }
                    else if (parameters[i].ParameterType == typeof(int) ||
                             parameters[i].ParameterType.IsEnum)
                    {
                        args[i] = stackPtr[i].s_int;
                    }
                    else if (parameters[i].ParameterType == typeof(uint))
                    {
                        args[i] = stackPtr[i].s_uint;
                    }
                    else if (parameters[i].ParameterType == typeof(long))
                    {
                        // s_long will contain the wrong value on 32 bit platforms
                        // (i.e. where a native C++ 'long' isn't at least 64 bit)
                        args[i] = (SmokeMarshallers.SizeOfNativeLong < sizeof(long))? stackPtr[i + 1].s_int : stackPtr[i + 1].s_long;
                    }
                    else if (parameters[i].ParameterType == typeof(ulong))
                    {
                        args[i] = (SmokeMarshallers.SizeOfNativeLong < sizeof(long))? stackPtr[i + 1].s_uint : stackPtr[i + 1].s_ulong;
                    }
                    else if (parameters[i].ParameterType == typeof(float))
                    {
                        args[i] = stackPtr[i].s_float;
                    }
                    else if (parameters[i].ParameterType == typeof(double))
                    {
                        args[i] = stackPtr[i].s_double;
                    }
                    else if (parameters[i].ParameterType == typeof(string))
                    {
                        if (stackPtr[i].s_class != IntPtr.Zero)
                        {
                            args[i] = (string)((GCHandle)stackPtr[i].s_class).Target;
#if DEBUG
                            DebugGCHandle.Free((GCHandle)stackPtr[i].s_class);
#else
                            ((GCHandle)stackPtr[i].s_class).SynchronizedFree();
#endif
                        }
                    }
                    else
                    {
                        if (stackPtr[i].s_class != IntPtr.Zero)
                        {
                            args[i] = ((GCHandle)stackPtr[i].s_class).Target;
#if DEBUG
                            DebugGCHandle.Free((GCHandle)stackPtr[i].s_class);
#else
                            ((GCHandle)stackPtr[i].s_class).SynchronizedFree();
#endif
                        }
                    }
                }
            }

            object returnValue = slot.Invoke(qobj, args);
            Type   returnType  = slot.ReturnType;

            unsafe {
                StackItem *retval = (StackItem *)ret;
                if (returnType == typeof(void))
                {
                    ;
                }
                else if (returnType == typeof(bool))
                {
                    retval[0].s_bool = (bool)returnValue;
                }
                else if (returnType == typeof(sbyte))
                {
                    retval[0].s_char = (sbyte)returnValue;
                }
                else if (returnType == typeof(byte))
                {
                    retval[0].s_uchar = (byte)returnValue;
                }
                else if (returnType == typeof(short))
                {
                    retval[0].s_short = (short)returnValue;
                }
                else if (returnType == typeof(ushort))
                {
                    retval[0].s_ushort = (ushort)returnValue;
                }
                else if (returnType == typeof(int) || returnType.IsEnum)
                {
                    retval[0].s_int = (int)returnValue;
                }
                else if (returnType == typeof(uint))
                {
                    retval[0].s_uint = (uint)returnValue;
                }
                else if (returnType == typeof(long))
                {
                    retval[0].s_long = (long)returnValue;
                }
                else if (returnType == typeof(ulong))
                {
                    retval[0].s_ulong = (ulong)returnValue;
                }
                else if (returnType == typeof(float))
                {
                    retval[0].s_float = (float)returnValue;
                }
                else if (returnType == typeof(double))
                {
                    retval[0].s_double = (double)returnValue;
                }
                else if (returnType == typeof(string))
                {
#if DEBUG
                    retval[0].s_class = (IntPtr)DebugGCHandle.Alloc(returnValue);
#else
                    retval[0].s_class = (IntPtr)GCHandle.Alloc(returnValue);
#endif
                }
                else if (returnValue == null)
                {
                    retval[0].s_class = IntPtr.Zero;
                }
                else
                {
#if DEBUG
                    retval[0].s_class = (IntPtr)DebugGCHandle.Alloc(returnValue);
#else
                    retval[0].s_class = (IntPtr)GCHandle.Alloc(returnValue);
#endif
                }
            }
        }
Exemplo n.º 30
0
        public static void InvokeMethod(IntPtr instanceHandle, IntPtr methodHandle, IntPtr stack)
        {
            object     instance = ((GCHandle)instanceHandle).Target;
            MethodInfo method   = (MethodInfo)((GCHandle)methodHandle).Target;

#if DEBUG
            if ((QDebug.DebugChannel() & QtDebugChannel.QTDB_TRANSPARENT_PROXY) != 0 &&
                (QDebug.DebugChannel() & QtDebugChannel.QTDB_VIRTUAL) != 0)
            {
                Console.WriteLine("ENTER InvokeMethod() {0}.{1}",
                                  instance,
                                  method.Name);
            }
#endif

            unsafe {
                StackItem *     stackPtr   = (StackItem *)stack;
                ParameterInfo[] parameters = method.GetParameters();
                object[]        args       = new object[parameters.Length];

                for (int i = 0; i < args.Length; i++)
                {
                    if (parameters[i].ParameterType == typeof(bool))
                    {
                        args[i] = stackPtr[i + 1].s_bool;
                    }
                    else if (parameters[i].ParameterType == typeof(sbyte))
                    {
                        args[i] = stackPtr[i + 1].s_char;
                    }
                    else if (parameters[i].ParameterType == typeof(byte))
                    {
                        args[i] = stackPtr[i + 1].s_uchar;
                    }
                    else if (parameters[i].ParameterType == typeof(char))
                    {
                        args[i] = (char)stackPtr[i + 1].s_uchar;
                    }
                    else if (parameters[i].ParameterType == typeof(short))
                    {
                        args[i] = stackPtr[i + 1].s_short;
                    }
                    else if (parameters[i].ParameterType == typeof(ushort))
                    {
                        args[i] = stackPtr[i + 1].s_ushort;
                    }
                    else if (parameters[i].ParameterType == typeof(int))
                    {
                        args[i] = stackPtr[i + 1].s_int;
                    }
                    else if (parameters[i].ParameterType.IsEnum)
                    {
                        args[i] = Enum.ToObject(parameters[i].ParameterType, stackPtr[i + 1].s_int);
                    }
                    else if (parameters[i].ParameterType == typeof(uint))
                    {
                        args[i] = stackPtr[i + 1].s_uint;
                    }
                    else if (parameters[i].ParameterType == typeof(long))
                    {
                        // s_long will contain the wrong value on 32 bit platforms
                        // (i.e. where a native C++ 'long' isn't at least 64 bit)
                        args[i] = (SmokeMarshallers.SizeOfNativeLong < sizeof(long))? stackPtr[i + 1].s_int : stackPtr[i + 1].s_long;
                    }
                    else if (parameters[i].ParameterType == typeof(ulong))
                    {
                        args[i] = (SmokeMarshallers.SizeOfNativeLong < sizeof(long))? stackPtr[i + 1].s_uint : stackPtr[i + 1].s_ulong;
                    }
                    else if (parameters[i].ParameterType == typeof(float))
                    {
                        args[i] = stackPtr[i + 1].s_float;
                    }
                    else if (parameters[i].ParameterType == typeof(double))
                    {
                        args[i] = stackPtr[i + 1].s_double;
                    }
                    else if (parameters[i].ParameterType == typeof(string))
                    {
                        if (stackPtr[i + 1].s_class != IntPtr.Zero)
                        {
                            args[i] = (string)((GCHandle)stackPtr[i + 1].s_class).Target;
#if DEBUG
                            DebugGCHandle.Free((GCHandle)stackPtr[i + 1].s_class);
#else
                            ((GCHandle)stackPtr[i + 1].s_class).SynchronizedFree();
#endif
                        }
                    }
                    else
                    {
                        if (stackPtr[i + 1].s_class != IntPtr.Zero)
                        {
                            args[i] = ((GCHandle)stackPtr[i + 1].s_class).Target;
#if DEBUG
                            DebugGCHandle.Free((GCHandle)stackPtr[i + 1].s_class);
#else
                            ((GCHandle)stackPtr[i + 1].s_class).SynchronizedFree();
#endif
                        }
                    }
                }

                object returnValue = method.Invoke(instance, args);
                Type   returnType  = method.ReturnType;

                if (returnType == typeof(void))
                {
                    ;
                }
                else if (returnType == typeof(bool))
                {
                    stackPtr[0].s_bool = (bool)returnValue;
                }
                else if (returnType == typeof(sbyte))
                {
                    stackPtr[0].s_char = (sbyte)returnValue;
                }
                else if (returnType == typeof(byte))
                {
                    stackPtr[0].s_uchar = (byte)returnValue;
                }
                else if (returnType == typeof(char))
                {
                    stackPtr[0].s_uchar = (byte)(char)returnValue;
                }
                else if (returnType == typeof(short))
                {
                    stackPtr[0].s_short = (short)returnValue;
                }
                else if (returnType == typeof(ushort))
                {
                    stackPtr[0].s_ushort = (ushort)returnValue;
                }
                else if (returnType == typeof(int) || returnType.IsEnum)
                {
                    stackPtr[0].s_int = (int)returnValue;
                }
                else if (returnType == typeof(uint))
                {
                    stackPtr[0].s_uint = (uint)returnValue;
                }
                else if (returnType == typeof(long))
                {
                    stackPtr[0].s_long = (long)returnValue;
                }
                else if (returnType == typeof(ulong))
                {
                    stackPtr[0].s_ulong = (ulong)returnValue;
                }
                else if (returnType == typeof(float))
                {
                    stackPtr[0].s_float = (float)returnValue;
                }
                else if (returnType == typeof(double))
                {
                    stackPtr[0].s_double = (double)returnValue;
                }
                else if (returnType == typeof(string))
                {
#if DEBUG
                    stackPtr[0].s_class = (IntPtr)DebugGCHandle.Alloc(returnValue);
#else
                    stackPtr[0].s_class = (IntPtr)GCHandle.Alloc(returnValue);
#endif
                }
                else if (returnValue == null)
                {
                    stackPtr[0].s_class = IntPtr.Zero;
                }
                else
                {
#if DEBUG
                    stackPtr[0].s_class = (IntPtr)DebugGCHandle.Alloc(returnValue);
#else
                    stackPtr[0].s_class = (IntPtr)GCHandle.Alloc(returnValue);
#endif
                }
            }

            return;
        }