Skip to content

Commit 7991d39

Browse files
committed
object: implement PyObject_Call{Function,Method}ObjArgs
1 parent dcbfa20 commit 7991d39

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

object.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ func (self *PyObject) CallObject(args *PyObject) *PyObject {
301301
// PyObject* PyObject_CallFunction(PyObject *callable, char *format, ...)
302302
// Return value: New reference.
303303
// Call a callable Python object callable, with a variable number of C arguments. The C arguments are described using a Py_BuildValue() style format string. The format may be NULL, indicating that no arguments are provided. Returns the result of the call on success, or NULL on failure. This is the equivalent of the Python expression apply(callable, args) or callable(*args). Note that if you only pass PyObject * args, PyObject_CallFunctionObjArgs() is a faster alternative.
304-
func (self *PyObject) CallFunction(format string, args ...interface{}) *PyObject {
304+
func (self *PyObject) CallFunction(args ...interface{}) *PyObject {
305305
if len(args) > int(C._gopy_max_varargs) {
306306
panic(fmt.Errorf(
307307
"gopy: maximum number of varargs (%d) exceeded (%d)",
@@ -390,14 +390,15 @@ func (self *PyObject) CallMethod(method string, args ...interface{}) *PyObject {
390390
}
391391

392392
/*
393-
FIXME: varargs in cgo ?
394-
395393
PyObject* PyObject_CallFunctionObjArgs(PyObject *callable, ..., NULL)
396394
Return value: New reference.
397395
Call a callable Python object callable, with a variable number of PyObject* arguments. The arguments are provided as a variable number of parameters followed by NULL. Returns the result of the call on success, or NULL on failure.
398396
399397
New in version 2.2.
400398
*/
399+
func (self *PyObject) CallFunctionObjArgs(format string, args ...interface{}) *PyObject {
400+
return self.CallFunction(args...)
401+
}
401402

402403
/*
403404
PyObject* PyObject_CallMethodObjArgs(PyObject *o, PyObject *name, ..., NULL)
@@ -406,6 +407,9 @@ Calls a method of the object o, where the name of the method is given as a Pytho
406407
407408
New in version 2.2.
408409
*/
410+
func (self *PyObject) CallMethodObjArgs(method string, args ...interface{}) *PyObject {
411+
return self.CallMethod(method, args...)
412+
}
409413

410414
// long PyObject_Hash(PyObject *o)
411415
// Compute and return the hash value of an object o. On failure, return -1. This is the equivalent of the Python expression hash(o).

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy