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