public override bool TryInvoke(InvokeBinder binder, object[] args, out object result) { if (this.IsCallable()) { PyTuple pyargs = null; PyDict kwargs = null; try { GetArgs(args, binder.CallInfo, out pyargs, out kwargs); result = CheckNone(Invoke(pyargs, kwargs)); } finally { if (null != pyargs) { pyargs.Dispose(); } if (null != kwargs) { kwargs.Dispose(); } } return(true); } else { return(base.TryInvoke(binder, args, out result)); } }
/// <summary> /// Invoke Method /// </summary> /// <remarks> /// Invoke the callable object with the given positional and keyword /// arguments. A PythonException is raised if the invokation fails. /// </remarks> public PyObject Invoke(PyObject[] args, PyDict kw) { var t = new PyTuple(args); IntPtr r = Runtime.PyObject_Call(obj, t.obj, kw != null ? kw.obj : IntPtr.Zero); t.Dispose(); if (r == IntPtr.Zero) { throw new PythonException(); } return(new PyObject(r)); }
/// <summary> /// Invoke Method /// </summary> /// <remarks> /// Invoke the callable object with the given arguments, passed as a /// PyObject[]. A PythonException is raised if the invokation fails. /// </remarks> public PyObject Invoke(params PyObject[] args) { var t = new PyTuple(args); IntPtr r = Runtime.PyObject_Call(obj, t.obj, IntPtr.Zero); t.Dispose(); if (r == IntPtr.Zero) { throw new PythonException(); } return(new PyObject(r)); }
/// <summary> /// Invoke Method /// </summary> /// <remarks> /// Invoke the callable object with the given positional and keyword /// arguments. A PythonException is raised if the invocation fails. /// </remarks> public PyObject Invoke(PyObject[] args, PyDict kw) { if (args == null) { throw new ArgumentNullException(nameof(args)); } if (args.Contains(null)) { throw new ArgumentNullException(); } var t = new PyTuple(args); IntPtr r = Runtime.PyObject_Call(obj, t.obj, kw?.obj ?? IntPtr.Zero); t.Dispose(); if (r == IntPtr.Zero) { throw new PythonException(); } return(new PyObject(r)); }
/// <summary> /// Invoke Method /// </summary> /// /// <remarks> /// Invoke the callable object with the given positional and keyword /// arguments. A PythonException is raised if the invokation fails. /// </remarks> public PyObject Invoke(PyObject[] args, PyDict kw) { PyTuple t = new PyTuple(args); IntPtr r = Runtime.PyObject_Call(obj, t.obj, kw != null ? kw.obj : IntPtr.Zero); t.Dispose(); if (r == IntPtr.Zero) { throw new PythonException(); } return new PyObject(r); }
/// <summary> /// Invoke Method /// </summary> /// /// <remarks> /// Invoke the callable object with the given arguments, passed as a /// PyObject[]. A PythonException is raised if the invokation fails. /// </remarks> public PyObject Invoke(params PyObject[] args) { PyTuple t = new PyTuple(args); IntPtr r = Runtime.PyObject_Call(obj, t.obj, IntPtr.Zero); t.Dispose(); if (r == IntPtr.Zero) { throw new PythonException(); } return new PyObject(r); }