示例#1
0
        static void MarshalCallback(IntPtr raw_closure, IntPtr return_val, uint n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)
        {
            string message = String.Empty;

            try {
                SignalClosure closure = closures [raw_closure] as SignalClosure;
                message = "Marshaling " + closure.name + " signal";
                Value objval = (Value) Marshal.PtrToStructure (param_values, typeof (Value));
                GLib.Object __obj = objval.Val as GLib.Object;
                if (__obj == null)
                    return;

                if (closure.args_type == typeof (EventArgs)) {
                    closure.Invoke (new ClosureInvokedArgs (__obj, EventArgs.Empty));
                    return;
                }

                SignalArgs args = Activator.CreateInstance (closure.args_type, new object [0]) as SignalArgs;
                args.Args = new object [n_param_vals - 1];
                GLib.Value[] vals = new GLib.Value [n_param_vals - 1];
                for (int i = 1; i < n_param_vals; i++) {
                    IntPtr ptr = new IntPtr (param_values.ToInt64 () + i * Marshal.SizeOf (typeof (Value)));
                    vals [i - 1] = (Value) Marshal.PtrToStructure (ptr, typeof (Value));
                    args.Args [i - 1] = vals [i - 1].Val;
                }
                ClosureInvokedArgs ci_args = new ClosureInvokedArgs (__obj, args);
                closure.Invoke (ci_args);
                for (int i = 1; i < n_param_vals; i++) {
                    vals [i - 1].Update (args.Args [i - 1]);
                    IntPtr ptr = new IntPtr (param_values.ToInt64 () + i * Marshal.SizeOf (typeof (Value)));
                    Marshal.StructureToPtr (vals [i - 1], ptr, false);
                }
                if (return_val == IntPtr.Zero || args.RetVal == null)
                    return;

                Value ret = (Value) Marshal.PtrToStructure (return_val, typeof (Value));
                ret.Val = args.RetVal;
                Marshal.StructureToPtr (ret, return_val, false);
            } catch (Exception e) {
                Console.WriteLine (message);
                ExceptionManager.RaiseUnhandledException (e, false);
            }
        }
示例#2
0
        void ClosureInvokedCB(object o, ClosureInvokedArgs args)
        {
            Delegate handler;
            if (o == before_closure)
                handler = before_handler;
            else
                handler = after_handler;

            if (handler != null)
                handler.DynamicInvoke (new object[] {args.Target, args.Args});
        }
示例#3
0
 public void Invoke(ClosureInvokedArgs args)
 {
     if (Invoked == null)
         return;
     Invoked (this, args);
 }
示例#4
0
		void ClosureInvokedCB (object o, ClosureInvokedArgs args)
		{
			Delegate handler;
			if (o == before_closure)
				handler = args.Target.BeforeSignals [name] as Delegate;
			else
				handler = args.Target.AfterSignals [name] as Delegate;

			if (handler != null)
				handler.DynamicInvoke (new object[] {args.Target, args.Args});
		}