Python.Runtime.DelegateObject.tp_new C# (CSharp) Method

tp_new() public static method

public static tp_new ( IntPtr tp, IntPtr args, IntPtr kw ) : IntPtr
tp System.IntPtr
args System.IntPtr
kw System.IntPtr
return System.IntPtr
        public static IntPtr tp_new(IntPtr tp, IntPtr args, IntPtr kw)
        {
            DelegateObject self = (DelegateObject)GetManagedObject(tp);

            if (Runtime.PyTuple_Size(args) != 1)
            {
                string message = "class takes exactly one argument";
                return Exceptions.RaiseTypeError(message);
            }

            IntPtr method = Runtime.PyTuple_GetItem(args, 0);

            if (Runtime.PyCallable_Check(method) != 1)
            {
                return Exceptions.RaiseTypeError("argument must be callable");
            }

            Delegate d = PythonEngine.DelegateManager.GetDelegate(self.type, method);
            return CLRObject.GetInstHandle(d, self.pyHandle);
        }