summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-10-26 16:21:32 (GMT)
committerFred Drake <fdrake@acm.org>2001-10-26 16:21:32 (GMT)
commitb421b8c19105d08b97122b7c84eec37ad83c6de4 (patch)
tree37e00d4acbdd57916ba418dbd79989c17c741ea7 /Include
parentef7d08a661dc28c732f4738cb328a74b32ce435b (diff)
downloadcpython-b421b8c19105d08b97122b7c84eec37ad83c6de4.zip
cpython-b421b8c19105d08b97122b7c84eec37ad83c6de4.tar.gz
cpython-b421b8c19105d08b97122b7c84eec37ad83c6de4.tar.bz2
Added two new functions to conveniently call functions/methods from C.
PyObject_CallFunctionObArgs() and PyObject_CallMethodObArgs() have the advantage that no format strings need to be parsed. The CallMethod variant also avoids creating a new string object in order to retrieve a method from an object as well.
Diffstat (limited to 'Include')
-rw-r--r--Include/abstract.h28
1 files changed, 23 insertions, 5 deletions
diff --git a/Include/abstract.h b/Include/abstract.h
index 351149d..0d44f6d 100644
--- a/Include/abstract.h
+++ b/Include/abstract.h
@@ -299,7 +299,6 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
PyObject *args, PyObject *kw);
/*
-
Call a callable Python object, callable_object, with
arguments and keywords arguments. The 'args' argument can not be
NULL, but the 'kw' argument can be NULL.
@@ -310,7 +309,6 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
PyObject *args);
/*
-
Call a callable Python object, callable_object, with
arguments given by the tuple, args. If no arguments are
needed, then args may be NULL. Returns the result of the
@@ -343,11 +341,31 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
arguments are provided. Returns the result of the call on
success, or NULL on failure. This is the equivalent of the
Python expression: o.method(args).
+ */
+
- Note that Special method names, such as "__add__",
- "__getitem__", and so on are not supported. The specific
- abstract-object routines for these must be used.
+ DL_IMPORT(PyObject *) PyObject_CallFunctionObArgs(PyObject *callable,
+ ...);
+ /*
+ Call a callable Python object, callable_object, with a
+ variable number of C arguments. The C arguments are provided
+ as PyObject * values; 'n' specifies the number of arguments
+ present. Returns the result of the call on success, or NULL
+ on failure. This is the equivalent of the Python expression:
+ apply(o,args).
+ */
+
+
+ DL_IMPORT(PyObject *) PyObject_CallMethodObArgs(PyObject *o,
+ PyObject *m, ...);
+
+ /*
+ Call the method named m of object o with a variable number of
+ C arguments. The C arguments are provided as PyObject * values;
+ 'n' specifies the number of arguments present. Returns the
+ result of the call on success, or NULL on failure. This is the
+ equivalent of the Python expression: o.method(args).
*/