Commits

camlspotter  committed 67444c7

split idl entries

  • Participants
  • Parent commits 4b61ad5
  • Branches dev

Comments (0)

Files changed (26)

 \.(sp[io]t|annot|o|cm[a-z]+|orig|omc|lock|so|a|exe|byt)$
 \.omakedb$
 ^auto\.(idl|ml|mli)
+^.*\.idl
 ^auto_stubs\.c
 autoapi\.ml
 	camidl
 	python 2.x (>= 2.6) library and header
 	omake
+        perl :-)
+
 PY_VERSION=2.6
 CFLAGS+= -fPIC -I $(OCAML_WHERE) -I $(PY_PREFIX)/include/python$(PY_VERSION)
 
-auto.idl: auto.idl.in idlconvert.pl
+IDLS= auto err object base string number sequence mapping misc type int import bytearray module dict tuple high
+
+%.idl: %.idl.in idlconvert.pl
     ./idlconvert.pl $< > $@
 
-auto.ml auto.mli auto_stubs.c: auto.idl $(Installed camlidl)
-	camlidl $<
+auto.ml auto.mli auto_stubs.c: $(addsuffix .idl, $(IDLS)) $(Installed camlidl)
+	camlidl auto.idl
 
 autoapi.ml : auto.ml automodular.pl
-    ./automodular.pl $< > $@
+    ./automodular.pl *.idl.in > $@
 
 auto_stubs.o: auto_stubs.c auto.h api_ml.h
 
-
 ( ゚∀゚)o彡°O'PyCaml
 
   If you do not see a For-all sign at the first line, install unicode capable fonts.
 module Sequence = Sequence
 module Eval = Eval
 module Object = Object
+module Run = Run
 
-module Base = struct
-  include Base
+module Base : sig
+  include module type of Base
 
   external none : unit -> t = "opycaml_none"
     (** Get Py_None object. *)
 
-  external phys_eq : t -> t -> bool = "py_physical_equal"
+  external phys_eq : t -> t -> bool = "opycaml_physical_equal"
+    (** Checks physical equality of objects *)
 
+  (* reference count functions: use with care *)
+  external refcnt : t -> int = "opycaml_refcnt"
+  external incref : t -> unit = "opycaml_incref"
+  external decref : t -> unit = "opycaml_decref"
+
+  (* get address of objects for debugging *)
+  external address : t -> nativeint = "opycaml_address"
+
+  val initialize : unit -> unit
+    (** Python api initialization with OCaml exception registeration.
+	Any other function in OPyCaml must be called after [initialize ()].
+    *)
+
+  val debug : string -> t -> unit
+    (** debug print of objects *) 
+
+  val main : string list -> int
+    (** Call to Py_Main
+
+	The main program for the standard interpreter. This is made available for programs which embed Python. The argc and argv parameters should be prepared exactly as those which are passed to a C program’s main() function. It is important to note that the argument list may be modified (but the contents of the strings pointed to by the argument list are not). The return value will be the integer passed to the sys.exit() function, 1 if the interpreter exits due to an exception, or 2 if the parameter list does not represent a valid Python command line.
+	Note that if an otherwise unhandled SystemError is raised,
+	this function will not return 1, but exit the process, as long
+	as Py_InspectFlag is not set.
+
+	Bug: Py_Main never returns to OCaml at exit(_). Strange...
+    **)
+end = struct
+  include Base
+
+  external none : unit -> t = "opycaml_none"
+  external phys_eq : t -> t -> bool = "opycaml_physical_equal"
   external refcnt : t -> int = "opycaml_refcnt"
   external incref : t -> unit = "opycaml_incref"
   external decref : t -> unit = "opycaml_decref"
     let repr = String.asString (Object.repr o) in
     let address = address o in
     Printf.eprintf "%s : %d : %nx : %s\n%!" name cnt address repr
+
+  external _main : int -> string list -> int = "opycaml_Py_Main"
+  let main argv = _main (List.length argv) argv
 end
 
 module Tuple = struct
 
 end
 
-module Err = struct
+module Err : sig
+  include module type of Err
+
+  external reraise : unit -> 'a = "opycaml_error"
+    (** reraise the current exception. 
+	Err.Occured() must be return Some. Otherwise Failwith is raised instead. *)
+end = struct
   include Err
     
-  external reraise : unit -> unit = "pyerror"
-    (** reraise the current exception. 
-	Err.Occured() must be return Some. Otherwise Failwith is raised instead. *)
+  external reraise : unit -> 'a = "opycaml_error"
 end
 
-module Int = struct
+module Int : sig
+  include module type of Int
+
+  val asLong : t -> int
+    (** raises Error at overflow *)
+end = struct
   include Int
 
   let asLong t =
     if res <> -1 then res
     else match Err.occurred () with
     | None -> -1
-    | Some _ -> Err.clear (); raise (Error_by_string "Int.asLong: failed")
+    | Some _ -> Err.reraise ()
 end
+
+
 #include "api_ml.h"
 
+// initialization
+
 // exception
 static value *opycaml_exc = NULL;
 
     caml_raise_with_arg(*opycaml_exc, v); 
 }
 
+// custom value
+
 static void pydecref( value v ) {
     PyObject *py = PyObject_val(v);
     if( py ) { Py_DECREF(py); }
     NULL
 };
 
+// apis for refcnts
+
 value opycaml_refcnt(value obj){
     PyObject *o = PyObject_val(obj);
     return Val_int(o->ob_refcnt);
     return caml_copy_nativeint((int)o);
 }
 
+// val <-> PyObject conversion 
+
 value Val_PyObject( PyObject *obj, int incr ) {
     CAMLparam0();
     CAMLlocal1(v);
     return Val_PyObject(Py_None, 1); // check what happens if caml gets none and gc'ed
 }
 
-void pyerror()
+void opycaml_error()
 {
     value err;
     PyObject *exn = PyErr_Occurred(); // It's borrowed. Increment its refcnt!
 }
 
 value Val_PyObject_exc_at_null( PyObject *obj ) {
-    if( !obj ) { pyerror(); }
+    if( !obj ) { opycaml_error(); }
     return Val_PyObject(obj, 1); // incr
 }
 
 value Val_PyObject_noincr_exc_at_null( PyObject *obj ) {
-    if( !obj ) { pyerror(); }
+    if( !obj ) { opycaml_error(); }
     return Val_PyObject(obj, 0); // no need to incr
 }
 
     }
 }
 
-value py_physical_equal( value v1, value v2 ){
-    return Val_int(getcustom(v1) == getcustom(v2));
-}
-
 value Plus_or_fail(int v)
 {
-    if (v == -1) pyerror();
+    if (v == -1) opycaml_error();
     return Val_int(v); // for unit
 }
 
 value Hash_or_fail(long v)
 {
-    if (v == -1) pyerror();
+    if (v == -1) opycaml_error();
     return caml_copy_nativeint(v); // for unit
 }
 
+// Other useful functions
+
+value opycaml_physical_equal( value v1, value v2 ){
+    return Val_int(getcustom(v1) == getcustom(v2));
+}
+
+value opycaml_Py_Main(value argc, value argv){
+    CAMLparam2(argc, argv);
+    int i;
+    int cargc = Int_val(argc);
+    char **cargv = malloc(sizeof(char*) * argc);
+    for(i=0; i< cargc; i++ ){
+        if( Is_block(argv) ){
+            cargv[i] = String_val(Field(argv, 0));
+            argv = Field(argv, 1);
+        } else {
+            caml_failwith("opycaml_Py_Main: wrong argc and argv");
+        }
+    }
+    int res = Py_Main(cargc, cargv);
+    CAMLreturn(Val_int(res));
+}
+
+// Callbacks from pycaml. Not investigated yet. 
 
 value funcwrap( void *obj ) {
     CAMLparam0();
 type size_t = int
 
 exception Error of t
-exception Error_by_string of string
+
 typedef int Py_ssize_t; // not sure
 typedef int size_t; // not sure
 
-// Exceptions
+#include "err.idl"
+#include "object.idl"
+#include "base.idl"
+#include "string.idl"
+#include "number.idl"
+#include "sequence.idl"
+#include "mapping.idl"
+#include "misc.idl"
+#include "type.idl"
+#include "int.idl"
+#include "import.idl"
+#include "bytearray.idl"
+#include "module.idl"
+#include "dict.idl"
+#include "tuple.idl"
+#include "high.idl"
 
-void PyErr_PrintEx(boolean set_sys_last_vars);
-// Print a standard traceback to sys.stderr and clear the error indicator. Call this function only when the error indicator is set. (Otherwise it will cause a fatal error!)
-// If set_sys_last_vars is nonzero, the variables sys.last_type, sys.last_value and sys.last_traceback will be set to the type, value and traceback of the printed exception, respectively.
-
-void PyErr_Print();
-// Alias for PyErr_PrintEx(1).
-
-[option] PyObject* PyErr_Occurred();
-// Return value: Borrowed reference.
-// Test whether the error indicator is set. If set, return the exception type (the first argument to the last call to one of the PyErr_Set*() functions or to PyErr_Restore()). If not set, return NULL. You do not own a reference to the return value, so you do not need to Py_DECREF() it.
-//
-// Note Do not compare the return value to a specific exception; use PyErr_ExceptionMatches() instead, shown below. (The comparison could easily fail since the exception may be an instance instead of a class, in the case of a class exception, or it may the a subclass of the expected exception.)
-
-int PyErr_ExceptionMatches(PyObject *exc);
-// Equivalent to PyErr_GivenExceptionMatches(PyErr_Occurred(), exc). This should only be called when an exception is actually set; a memory access violation will occur if no exception has been raised.;
-
-boolean PyErr_GivenExceptionMatches(PyObject *given, PyObject *exc);
-// Return true if the given exception matches the exception in exc. If exc is a class object, this also returns true when given is an instance of a subclass. If exc is a tuple, all exceptions in the tuple (and recursively in subtuples) are searched for a match.
-
-// void PyErr_NormalizeException(PyObject**exc, PyObject**val, PyObject**tb)
-// Under certain circumstances, the values returned by PyErr_Fetch() below can be “unnormalized”, meaning that *exc is a class object but *val is not an instance of the same class. This function can be used to instantiate the class in that case. If the values are already normalized, nothing happens. The delayed normalization is implemented to improve performance.
-
-void PyErr_Clear();
-// Clear the error indicator. If the error indicator is not set, there is no effect.
-
-// void PyErr_Fetch(PyObject **ptype, PyObject **pvalue, PyObject **ptraceback)
-// Retrieve the error indicator into three variables whose addresses are passed. If the error indicator is not set, set all three variables to NULL. If it is set, it will be cleared and you own a reference to each object retrieved. The value and traceback object may be NULL even when the type object is not.
-// Note This function is normally only used by code that needs to handle exceptions or by code that needs to save and restore the error indicator temporarily.
-
-// void PyErr_Restore(PyObject *type, PyObject *value, PyObject *traceback)
-// Set the error indicator from the three objects. If the error indicator is already set, it is cleared first. If the objects are NULL, the error indicator is cleared. Do not pass a NULL type and non-NULL value or traceback. The exception type should be a class. Do not pass an invalid exception type or value. (Violating these rules will cause subtle problems later.) This call takes away a reference to each object: you must own a reference to each object before the call and after the call you no longer own these references. (If you don’t understand this, don’t use this function. I warned you.)
-// Note This function is normally only used by code that needs to save and restore the error indicator temporarily; use PyErr_Fetch() to save the current exception state.
-
-void PyErr_SetString(PyObject *type, [string] const char *message);
-// This is the most common way to set the error indicator. The first argument specifies the exception type; it is normally one of the standard exceptions, e.g. PyExc_RuntimeError. You need not increment its reference count. The second argument is an error message; it is converted to a string object.
-
-void PyErr_SetObject(PyObject *type, PyObject *value);
-// This function is similar to PyErr_SetString() but lets you specify an arbitrary Python object for the “value” of the exception.
-
-// PyObject* PyErr_Format(PyObject *exception, const char *format, ...)
-// Return value: Always NULL.
-// This function sets the error indicator and returns NULL. exception should be a Python exception (class, not an instance). format should be a string, containing format codes, similar to printf(). The width.precision before a format code is parsed, but the width part is ignored.
-
-void PyErr_SetNone(PyObject *type);
-// This is a shorthand for PyErr_SetObject(type, Py_None).
-
-int PyErr_BadArgument();
-// This is a shorthand for PyErr_SetString(PyExc_TypeError, message), where message indicates that a built-in operation was invoked with an illegal argument. It is mostly for internal use.
-
-// [null] PyObject* PyErr_NoMemory();
-// Return value: Always NULL.
-// This is a shorthand for PyErr_SetNone(PyExc_MemoryError); it returns NULL so an object allocation function can write return PyErr_NoMemory(); when it runs out of memory.
-
-// [null] PyObject* PyErr_SetFromErrno(PyObject *type);
-// Return value: Always NULL.
-// This is a convenience function to raise an exception when a C library function has returned an error and set the C variable errno. It constructs a tuple object whose first item is the integer errno value and whose second item is the corresponding error message (gotten from strerror()), and then calls PyErr_SetObject(type, object). On Unix, when the errno value is EINTR, indicating an interrupted system call, this calls PyErr_CheckSignals(), and if that set the error indicator, leaves it set to that. The function always returns NULL, so a wrapper function around a system call can write return PyErr_SetFromErrno(type); when the system call returns an error.
-
-// [null] PyObject* PyErr_SetFromErrnoWithFilename(PyObject *type, const char *filename)
-// Return value: Always NULL.
-// Similar to PyErr_SetFromErrno(), with the additional behavior that if filename is not NULL, it is passed to the constructor of type as a third parameter. In the case of exceptions such as IOError and OSError, this is used to define the filename attribute of the exception instance.
-
-// [null] PyObject* PyErr_SetFromWindowsErr(int ierr);
-// Return value: Always NULL.
-// This is a convenience function to raise WindowsError. If called with ierr of 0, the error code returned by a call to GetLastError() is used instead. It calls the Win32 function FormatMessage() to retrieve the Windows description of error code given by ierr or GetLastError(), then it constructs a tuple object whose first item is the ierr value and whose second item is the corresponding error message (gotten from FormatMessage()), and then calls PyErr_SetObject(PyExc_WindowsError, object). This function always returns NULL. Availability: Windows.
-
-// [null] PyObject* PyErr_SetExcFromWindowsErr(PyObject *type, int ierr)
-// Return value: Always NULL.
-// Similar to PyErr_SetFromWindowsErr(), with an additional parameter specifying the exception type to be raised. Availability: Windows.
-
-// [null] PyObject* PyErr_SetFromWindowsErrWithFilename(int ierr, [string] const char *filename)
-// Return value: Always NULL.
-// Similar to PyErr_SetFromWindowsErr(), with the additional behavior that if filename is not NULL, it is passed to the constructor of WindowsError as a third parameter. Availability: Windows.
-
-// [null] PyObject* PyErr_SetExcFromWindowsErrWithFilename(PyObject *type, int ierr, char *filename)
-// Return value: Always NULL.
-// Similar to PyErr_SetFromWindowsErrWithFilename(), with an additional parameter specifying the exception type to be raised. Availability: Windows.
-
-void PyErr_BadInternalCall();
-// This is a shorthand for PyErr_SetString(PyExc_SystemError, message), where message indicates that an internal operation (e.g. a Python/C API function) was invoked with an illegal argument. It is mostly for internal use.
-
-// int PyErr_WarnEx(PyObject *category, [string] char *message, int stacklevel);
-// Issue a warning message. The category argument is a warning category (see below) or NULL; the message argument is a message string. stacklevel is a positive number giving a number of stack frames; the warning will be issued from the currently executing line of code in that stack frame. A stacklevel of 1 is the function calling PyErr_WarnEx(), 2 is the function above that, and so forth.
-// This function normally prints a warning message to sys.stderr; however, it is also possible that the user has specified that warnings are to be turned into errors, and in that case this will raise an exception. It is also possible that the function raises an exception because of a problem with the warning machinery (the implementation imports the warnings module to do the heavy lifting). The return value is 0 if no exception is raised, or -1 if an exception is raised. (It is not possible to determine whether a warning message is actually printed, nor what the reason is for the exception; this is intentional.) If an exception is raised, the caller should do its normal exception handling (for example, Py_DECREF() owned references and return an error value).
-// Warning categories must be subclasses of Warning; the default warning category is RuntimeWarning. The standard Python warning categories are available as global variables whose names are PyExc_ followed by the Python exception name. These have the type PyObject*; they are all class objects. Their names are PyExc_Warning, PyExc_UserWarning, PyExc_UnicodeWarning, PyExc_DeprecationWarning, PyExc_SyntaxWarning, PyExc_RuntimeWarning, and PyExc_FutureWarning. PyExc_Warning is a subclass of PyExc_Exception; the other warning categories are subclasses of PyExc_Warning.
-// For information about warning control, see the documentation for the warnings module and the -W option in the command line documentation. There is no C API for warning control.
-
-// int PyErr_Warn(PyObject *category, [string] char *message);
-// Issue a warning message. The category argument is a warning category (see below) or NULL; the message argument is a message string. The warning will appear to be issued from the function calling PyErr_Warn(), equivalent to calling PyErr_WarnEx() with a stacklevel of 1.
-// 
-// Deprecated; use PyErr_WarnEx() instead.
-
-// int PyErr_WarnExplicit(PyObject *category, const char *message, const char *filename, int lineno, const char *module, PyObject *registry)
-// Issue a warning message with explicit control over all warning attributes. This is a straightforward wrapper around the Python function warnings.warn_explicit(), see there for more information. The module and registry arguments may be set to NULL to get the default effect described there.
-
-// int PyErr_WarnPy3k(char *message, int stacklevel)
-// Issue a DeprecationWarning with the given message and stacklevel if the Py_Py3kWarningFlag flag is enabled.
-
-// int PyErr_CheckSignals()
-// This function interacts with Python’s signal handling. It checks whether a signal has been sent to the processes and if so, invokes the corresponding signal handler. If the signal module is supported, this can invoke a signal handler written in Python. In all cases, the default effect for SIGINT is to raise the KeyboardInterrupt exception. If an exception is raised the error indicator is set and the function returns -1; otherwise the function returns 0. The error indicator may or may not be cleared if it was previously set.
-
-// void PyErr_SetInterrupt()
-// aThis function simulates the effect of a SIGINT signal arriving  the next time PyErr_CheckSignals() is called, KeyboardInterrupt will be raised. It may be called without holding the interpreter lock.
-
-// int PySignal_SetWakeupFd(int fd)
-// This utility function specifies a file descriptor to which a '\0' byte will be written whenever a signal is received. It returns the previous such file descriptor. The value -1 disables the feature; this is the initial state. This is equivalent to signal.set_wakeup_fd() in Python, but without any error checking. fd should be a valid file descriptor. The function should only be called from the main thread.
-
-[new] PyObject* PyErr_NewException([string] char *name, PyObject *base, PyObject *dict);
-// Return value: New reference.
-// This utility function creates and returns a new exception object. The name argument must be the name of the new exception, a C string of the form module.class. The base and dict arguments are normally NULL. This creates a class object derived from Exception (accessible in C as PyExc_Exception).
-// The __module__ attribute of the new class is set to the first part (up to the last dot) of the name argument, and the class name is set to the last part (after the last dot). The base argument can be used to specify alternate base classes; it can either be only one class or a tuple of classes. The dict argument can be used to specify a dictionary of class variables and methods.
-
-// [new] PyObject* PyErr_NewExceptionWithDoc([string] char *name, [string] char *doc, PyObject *base, PyObject *dict);
-// Return value: New reference.
-// Same as PyErr_NewException(), except that the new exception class can easily be given a docstring: If doc is non-NULL, it will be used as the docstring for the exception class.
-// New in version 2.7.
-
-void PyErr_WriteUnraisable(PyObject *obj);
-// This utility function prints a warning message to sys.stderr when an exception has been set but it is impossible for the interpreter to actually raise the exception. It is used, for example, when an exception occurs in an __del__() method.
-// The function is called with a single argument obj that identifies the context in which the unraisable exception occurred. The repr of obj will be printed in the warning message.
-
-// Recursion Control
-// These two functions provide a way to perform safe recursive calls at the C level, both in the core and in extension modules. They are needed if the recursive code does not necessarily invoke Python code (which tracks its recursion depth automatically).
-// 
-// int Py_EnterRecursiveCall(char *where)
-// Marks a point where a recursive C-level call is about to be performed.
-// 
-// If USE_STACKCHECK is defined, this function checks if the the OS stack overflowed using PyOS_CheckStack(). In this is the case, it sets a MemoryError and returns a nonzero value.
-// 
-// The function then checks if the recursion limit is reached. If this is the case, a RuntimeError is set and a nonzero value is returned. Otherwise, zero is returned.
-// 
-// where should be a string such as " in instance check" to be concatenated to the RuntimeError message caused by the recursion depth limit.
-// 
-// void Py_LeaveRecursiveCall()
-// Ends a Py_EnterRecursiveCall(). Must be called once for each successful invocation of Py_EnterRecursiveCall().
-// 
-
-// ------------------- Object Protocol http://docs.python.org/c-api/object.html
-
-// int PyObject_Print(PyObject *o, FILE *fp, int flags)
-// Print an object o, on file fp. Returns -1 on error. The flags argument is used to enable certain printing options. The only option currently supported is Py_PRINT_RAW; if given, the str() of the object is written instead of the repr().
-
-boolean PyObject_HasAttr(PyObject *o, PyObject *attr_name);
-// Returns 1 if o has the attribute attr_name, and 0 otherwise. This is equivalent to the Python expression hasattr(o, attr_name). This function always succeeds.
-
-boolean PyObject_HasAttrString(PyObject *o, [string] const char *attr_name);
-// Returns 1 if o has the attribute attr_name, and 0 otherwise. This is equivalent to the Python expression hasattr(o, attr_name). This function always succeeds.
-
-[new] PyObject* PyObject_GetAttr(PyObject *o, PyObject *attr_name);
-// Return value: New reference.
-// Retrieve an attribute named attr_name from object o. Returns the attribute value on success, or NULL on failure. This is the equivalent of the Python expression o.attr_name.
-
-[new] PyObject* PyObject_GetAttrString(PyObject *o, [string] const char *attr_name);
-// Return value: New reference.
-// Retrieve an attribute named attr_name from object o. Returns the attribute value on success, or NULL on failure. This is the equivalent of the Python expression o.attr_name.
-
-PyObject* PyObject_GenericGetAttr(PyObject *o, PyObject *name); // Guess it is borrowed, since there is a case when this function returns the result of PyDict_GetItem.
-// Generic attribute getter function that is meant to be put into a type object’s tp_getattro slot. It looks for a descriptor in the dictionary of classes in the object’s MRO as well as an attribute in the object’s __dict__ (if present). As outlined in Implementing Descriptors, data descriptors take preference over instance attributes, while non-data descriptors don’t. Otherwise, an AttributeError is raised.
-
-unit_or_fail PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v);
-// Set the value of the attribute named attr_name, for object o, to the value v. Returns -1 on failure. This is the equivalent of the Python statement o.attr_name = v.
-
-unit_or_fail PyObject_SetAttrString(PyObject *o, [string] const char *attr_name, PyObject *v);
-// Set the value of the attribute named attr_name, for object o, to the value v. Returns -1 on failure. This is the equivalent of the Python statement o.attr_name = v.
-
-unit_or_fail PyObject_GenericSetAttr(PyObject *o, PyObject *name, PyObject *value);
-// Generic attribute setter function that is meant to be put into a type object’s tp_setattro slot. It looks for a data descriptor in the dictionary of classes in the object’s MRO, and if found it takes preference over setting the attribute in the instance dictionary. Otherwise, the attribute is set in the object’s __dict__ (if present). Otherwise, an AttributeError is raised and -1 is returned.
-
-unit_or_fail PyObject_DelAttr(PyObject *o, PyObject *attr_name);
-// Delete attribute named attr_name, for object o. Returns -1 on failure. This is the equivalent of the Python statement del o.attr_name.
-
-unit_or_fail PyObject_DelAttrString(PyObject *o, [string] const char *attr_name);
-// Delete attribute named attr_name, for object o. Returns -1 on failure. This is the equivalent of the Python statement del o.attr_name.
-
-[new] PyObject* PyObject_RichCompare(PyObject *o1, PyObject *o2, int opid);
-// Return value: New reference.
-// Compare the values of o1 and o2 using the operation specified by opid, which must be one of Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, or Py_GE, corresponding to <, <=, ==, !=, >, or >= respectively. This is the equivalent of the Python expression o1 op o2, where op is the operator corresponding to opid. Returns the value of the comparison on success, or NULL on failure.
-
-bool_or_fail PyObject_RichCompareBool(PyObject *o1, PyObject *o2, int opid);
-// Compare the values of o1 and o2 using the operation specified by opid, which must be one of Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, or Py_GE, corresponding to <, <=, ==, !=, >, or >= respectively. Returns -1 on error, 0 if the result is false, 1 otherwise. This is the equivalent of the Python expression o1 op o2, where op is the operator corresponding to opid.
-
-unit_or_fail PyObject_Cmp(PyObject *o1, PyObject *o2, [out] int *result);
-// Compare the values of o1 and o2 using a routine provided by o1, if one exists, otherwise with a routine provided by o2. The result of the comparison is returned in result. Returns -1 on failure. This is the equivalent of the Python statement result = cmp(o1, o2).
-
-// Need more hacks
-// int PyObject_Compare(PyObject *o1, PyObject *o2);
-// Compare the values of o1 and o2 using a routine provided by o1, if one exists, otherwise with a routine provided by o2. Returns the result of the comparison on success. On error, the value returned is undefined; use PyErr_Occurred() to detect an error. This is equivalent to the Python expression cmp(o1, o2).
-
-[new] PyObject* PyObject_Repr(PyObject *o);
-// Return value: New reference.
-// Compute a string representation of object o. Returns the string representation on success, NULL on failure. This is the equivalent of the Python expression repr(o). Called by the repr() built-in function and by reverse quotes.
-
-[new] PyObject* PyObject_Str(PyObject *o);
-// Return value: New reference.
-// aCompute a string representation of object o. Returns the string representation on success, NULL on failure. This is the equivalent of the Python expression str(o). Called by the str() built-in function and by the print statement.
-
-[new] PyObject* PyObject_Bytes(PyObject *o);
-// Compute a bytes representation of object o. In 2.x, this is just a alias for PyObject_Str().
-
-[new] PyObject* PyObject_Unicode(PyObject *o);
-// Return value: New reference.
-// Compute a Unicode string representation of object o. Returns the Unicode string representation on success, NULL on failure. This is the equivalent of the Python expression unicode(o). Called by the unicode() built-in function.
-
-bool_or_fail PyObject_IsInstance(PyObject *inst, PyObject *cls);
-// Returns 1 if inst is an instance of the class cls or a subclass of cls, or 0 if not. On error, returns -1 and sets an exception. If cls is a type object rather than a class object, PyObject_IsInstance() returns 1 if inst is of type cls. If cls is a tuple, the check will be done against every entry in cls. The result will be 1 when at least one of the checks returns 1, otherwise it will be 0. If inst is not a class instance and cls is neither a type object, nor a class object, nor a tuple, inst must have a __class__ attribute  the class relationship of the value of that attribute with cls will be used to determine the result of this function.
-
-// Subclass determination is done in a fairly straightforward way, but includes a wrinkle that implementors of extensions to the class system may want to be aware of. If A and B are class objects, B is a subclass of A if it inherits from A either directly or indirectly. If either is not a class object, a more general mechanism is used to determine the class relationship of the two objects. When testing if B is a subclass of A, if A is B, PyObject_IsSubclass() returns true. If A and B are different objects, B‘s __bases__ attribute is searched in a depth-first fashion for A  the presence of the __bases__ attribute is considered sufficient for this determination.
-
-bool_or_fail PyObject_IsSubclass(PyObject *derived, PyObject *cls);
-// Returns 1 if the class derived is identical to or derived from the class cls, otherwise returns 0. In case of an error, returns -1. If cls is a tuple, the check will be done against every entry in cls. The result will be 1 when at least one of the checks returns 1, otherwise it will be 0. If either derived or cls is not an actual class object (or tuple), this function uses the generic algorithm described above.
-
-boolean PyCallable_Check(PyObject *o);
-// Determine if the object o is callable. Return 1 if the object is callable and 0 otherwise. This function always succeeds.
-
-// Need to think about NULL
-[new] PyObject* PyObject_Call(PyObject *callable_object, PyObject *args, [option] PyObject *kw);
-// Return value: New reference.
-// Call a callable Python object callable_object, with arguments given by the tuple args, and named arguments given by the dictionary kw. If no named arguments are needed, kw may be NULL. args must not be NULL, use an empty tuple if no arguments are needed. Returns the result of the call on success, or NULL on failure. This is the equivalent of the Python expression apply(callable_object, args, kw) or callable_object(*args, **kw).
-
-[new] PyObject* PyObject_CallObject(PyObject *callable_object, [option] PyObject *args);
-// Return value: New reference.
-// 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 call on success, or NULL on failure. This is the equivalent of the Python expression apply(callable_object, args) or callable_object(*args).
-
-[new] PyObject* PyEval_CallObject(PyObject *callable_object, [option] PyObject *args);
-// Return value: New reference.
-// 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 call on success, or NULL on failure. This is the equivalent of the Python expression apply(callable_object, args) or callable_object(*args).
-// Same as PyObject_CallObject but with sanity checks
-
-// PyObject* PyObject_CallFunction(PyObject *callable, char *format, ...)
-// Return value: New reference.
-// 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.
-
-// PyObject* PyObject_CallMethod(PyObject *o, char *method, char *format, ...)
-// Return value: New reference.
-// Call the method named method of object o with a variable number of C arguments. The C arguments are described by a Py_BuildValue() format string that should produce a tuple. 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 o.method(args). Note that if you only pass PyObject * args, PyObject_CallMethodObjArgs() is a faster alternative.
-
-// PyObject* PyObject_CallFunctionObjArgs(PyObject *callable, ..., NULL)
-// Return value: New reference.
-// 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.
-
-// PyObject* PyObject_CallMethodObjArgs(PyObject *o, PyObject *name, ..., NULL)
-// Return value: New reference.
-// Calls a method of the object o, where the name of the method is given as a Python string object in name. It is called 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.
-
-hash_or_fail PyObject_Hash(PyObject *o);
-// Compute and return the hash value of an object o. On failure, return -1. This is the equivalent of the Python expression hash(o).
-
-bool_or_fail /* actually always fails */  PyObject_HashNotImplemented(PyObject *o);
-// Set a TypeError indicating that type(o) is not hashable and return -1. This function receives special treatment when stored in a tp_hash slot, allowing a type to explicitly indicate to the interpreter that it is not hashable.
-
-bool_or_fail PyObject_IsTrue(PyObject *o);
-// Returns 1 if the object o is considered to be true, and 0 otherwise. This is equivalent to the Python expression not not o. On failure, return -1.
-
-bool_or_fail PyObject_Not(PyObject *o);
-// Returns 0 if the object o is considered to be true, and 1 otherwise. This is equivalent to the Python expression not o. On failure, return -1.
-
-[new] PyObject* PyObject_Type(PyObject *o);
-// Return value: New reference.
-// When o is non-NULL, returns a type object corresponding to the object type of object o. On failure, raises SystemError and returns NULL. This is equivalent to the Python expression type(o). This function increments the reference count of the return value. There’s really no reason to use this function instead of the common expression o->ob_type, which returns a pointer of type PyTypeObject*, except when the incremented reference count is needed.
-
-// bool_or_fail PyObject_TypeCheck(PyObject *o, PyTypeObject *type);
-// Return true if the object o is of type type or a subtype of type. Both parameters must be non-NULL.
-
-size_or_fail PyObject_Length(PyObject *o);
-size_or_fail PyObject_Size(PyObject *o);
-// Return the length of object o. If the object o provides either the sequence and mapping protocols, the sequence length is returned. On error, -1 is returned. This is the equivalent to the Python expression len(o).
-
-[new] PyObject* PyObject_GetItem(PyObject *o, PyObject *key);
-// Return value: New reference.
-// Return element of o corresponding to the object key or NULL on failure. This is the equivalent of the Python expression o[key].
-
-unit_or_fail PyObject_SetItem(PyObject *o, PyObject *key, PyObject *v);
-// Map the object key to the value v. Returns -1 on failure. This is the equivalent of the Python statement o[key] = v.
-
-unit_or_fail PyObject_DelItem(PyObject *o, PyObject *key);
-// Delete the mapping for key from o. Returns -1 on failure. This is the equivalent of the Python statement del o[key].
-
-int PyObject_AsFileDescriptor(PyObject *o);
-// Derives a file descriptor from a Python object. If the object is an integer or long integer, its value is returned. If not, the object’s fileno() method is called if it exists; the method must return an integer or long integer, which is returned as the file descriptor value. Returns -1 on failure.
-
-[new] PyObject* PyObject_Dir(PyObject *o);
-// Return value: New reference.
-// This is equivalent to the Python expression dir(o), returning a (possibly empty) list of strings appropriate for the object argument, or NULL if there was an error. If the argument is NULL, this is like the Python dir(), returning the names of the current locals; in this case, if no execution frame is active then NULL is returned but PyErr_Occurred() will return false.
-
-[new] PyObject* PyObject_GetIter(PyObject *o);
-// Return value: New reference.
-// This is equivalent to the Python expression iter(o). It returns a new iterator for the object argument, or the object itself if the object is already an iterator. Raises TypeError and returns NULL if the object cannot be iterated.
-
-// --------------------------------- base
- 
-void Py_Initialize();
-
-void Py_Finalize();
- 
-// ----------------------------------- string
-
-// PyStringObject
-// This subtype of PyObject represents a Python string object.
-
-// PyTypeObject PyString_Type
-// This instance of PyTypeObject represents the Python string type; it is the same object as str and types.StringType in the Python layer. .
-
-boolean PyString_Check(PyObject *o);
-// Return true if the object o is a string object or an instance of a subtype of the string type.
-
-boolean /* or fail? */ PyString_CheckExact(PyObject *o);
-// Return true if the object o is a string object, but not an instance of a subtype of the string type.
-
-[new] PyObject* PyString_FromString([string] const char *v);
-// Return value: New reference.
-// Return a new string object with a copy of the string v as value on success, and NULL on failure. The parameter v must not be NULL; it will not be checked.
-
-[new] PyObject* PyString_FromStringAndSize([string] const char *v, Py_ssize_t len);
-// Return value: New reference.
-// Return a new string object with a copy of the string v as value and length len on success, and NULL on failure. If v is NULL, the contents of the string are uninitialized.
-
-// PyObject* PyString_FromFormat(const char *format, ...);
-// Return value: New reference.
-// Take a C printf()-style format string and a variable number of arguments, calculate the size of the resulting Python string and return a string with the values formatted into it. The variable arguments must be C types and must correspond exactly to the format characters in the format string. The following format characters are allowed:
-//
-// Format Characters	Type	Comment
-// %%	n/a	The literal % character.
-// %c	int	A single character, represented as an C int.
-// %d	int	Exactly equivalent to printf("%d").
-// %u	unsigned int	Exactly equivalent to printf("%u").
-// %ld	long	Exactly equivalent to printf("%ld").
-// %lu	unsigned long	Exactly equivalent to printf("%lu").
-// %lld	long long	Exactly equivalent to printf("%lld").
-// %llu	unsigned long long	Exactly equivalent to printf("%llu").
-// %zd	Py_ssize_t	Exactly equivalent to printf("%zd").
-// %zu	size_t	Exactly equivalent to printf("%zu").
-// %i	int	Exactly equivalent to printf("%i").
-// %x	int	Exactly equivalent to printf("%x").
-// %s	char*	A null-terminated C character array.
-// %p	void*	The hex representation of a C pointer. Mostly equivalent to printf("%p") except that it is guaranteed to start with the literal 0x regardless of what the platform’s printf yields.
-// An unrecognized format character causes all the rest of the format string to be copied as-is to the result string, and any extra arguments discarded.
-// 
-// Note The “%lld” and “%llu” format specifiers are only available when HAVE_LONG_LONG is defined.
-// Changed in version 2.7: Support for “%lld” and “%llu” added.
-
-// PyObject* PyString_FromFormatV(const char *format, va_list vargs);
-// Return value: New reference.
-// Identical to PyString_FromFormat() except that it takes exactly two arguments.
-
-size_or_fail PyString_Size(PyObject *string);
-// Return the length of the string in string object string.
-
-size_or_fail PyString_GET_SIZE(PyObject *string);
-// Macro form of PyString_Size() but without error checking.
-
-[string] char* PyString_AsString(PyObject *string);
-// Return a NUL-terminated representation of the contents of string. The pointer refers to the internal buffer of string, not a copy. The data must not be modified in any way, unless the string was just created using PyString_FromStringAndSize(NULL, size). It must not be deallocated. If string is a Unicode object, this function computes the default encoding of string and operates on that. If string is not a string object at all, PyString_AsString() returns NULL and raises TypeError.
-
-[string] char* PyString_AS_STRING(PyObject *string);
-// Macro form of PyString_AsString() but without error checking. Only string objects are supported; no Unicode objects should be passed.
-
-size_or_fail /* int */ PyString_AsStringAndSize(PyObject *obj, char **buffer, Py_ssize_t *length);
-// Return a NUL-terminated representation of the contents of the object obj through the output variables buffer and length.
-// The function accepts both string and Unicode objects as input. For Unicode objects it returns the default encoded version of the object. If length is NULL, the resulting buffer may not contain NUL characters; if it does, the function returns -1 and a TypeError is raised.
-// The buffer refers to an internal string buffer of obj, not a copy. The data must not be modified in any way, unless the string was just created using PyString_FromStringAndSize(NULL, size). It must not be deallocated. If string is a Unicode object, this function computes the default encoding of string and operates on that. If string is not a string object at all, PyString_AsStringAndSize() returns -1 and raises TypeError.
-
-// void PyString_Concat(PyObject **string, PyObject *newpart);
-// Create a new string object in *string containing the contents of newpart appended to string; the caller will own the new reference. The reference to the old value of string will be stolen. If the new string cannot be created, the old reference to string will still be discarded and the value of *string will be set to NULL; the appropriate exception will be set.
-
-// void PyString_ConcatAndDel(PyObject **string, PyObject *newpart);
-// Create a new string object in *string containing the contents of newpart appended to string. This version decrements the reference count of newpart.
-
-// int _PyString_Resize(PyObject **string, Py_ssize_t newsize);
-// A way to resize a string object even though it is “immutable”. Only use this to build up a brand new string object; don’t use this if the string may already be known in other parts of the code. It is an error to call this function if the refcount on the input string object is not one. Pass the address of an existing string object as an lvalue (it may be written into), and the new size desired. On success, *string holds the resized string object and 0 is returned; the address in *string may differ from its input value. If the reallocation fails, the original string object at *string is deallocated, *string is set to NULL, a memory exception is set, and -1 is returned.
-
-[new] PyObject* PyString_Format(PyObject *format, PyObject *args);
-// Return value: New reference.
-// Return a new string object from format and args. Analogous to format % args. The args argument must be a tuple.
-
-// void PyString_InternInPlace(PyObject **string);
-// Intern the argument *string in place. The argument must be the address of a pointer variable pointing to a Python string object. If there is an existing interned string that is the same as *string, it sets *string to it (decrementing the reference count of the old string object and incrementing the reference count of the interned string object), otherwise it leaves *string alone and interns it (incrementing its reference count). (Clarification: even though there is a lot of talk about reference counts, think of this function as reference-count-neutral; you own the object after the call if and only if you owned it before the call.)
-
-[new] PyObject* PyString_InternFromString([string] const char *v);
-// Return value: New reference.
-// A combination of PyString_FromString() and PyString_InternInPlace(), returning either a new string object that has been interned, or a new (“owned”) reference to an earlier interned string object with the same value.
-
-// PyObject* PyString_Decode(const char *s, Py_ssize_t size, const char *encoding, const char *errors)
-// Return value: New reference.
-// Create an object by decoding size bytes of the encoded buffer s using the codec registered for encoding. encoding and errors have the same meaning as the parameters of the same name in the unicode() built-in function. The codec to be used is looked up using the Python codec registry. Return NULL if an exception was raised by the codec.
-
-// PyObject* PyString_AsDecodedObject(PyObject *str, const char *encoding, const char *errors);
-// Return value: New reference.
-// Decode a string object by passing it to the codec registered for encoding and return the result as Python object. encoding and errors have the same meaning as the parameters of the same name in the string encode() method. The codec to be used is looked up using the Python codec registry. Return NULL if an exception was raised by the codec.
-
-// PyObject* PyString_Encode(const char *s, Py_ssize_t size, const char *encoding, const char *errors);
-// Return value: New reference.
-// Encode the char buffer of the given size by passing it to the codec registered for encoding and return a Python object. encoding and errors have the same meaning as the parameters of the same name in the string encode() method. The codec to be used is looked up using the Python codec registry. Return NULL if an exception was raised by the codec.
-
-// PyObject* PyString_AsEncodedObject(PyObject *str, const char *encoding, const char *errors);
-// Return value: New reference.
-// Encode a string object using the codec registered for encoding and return the result as Python object. encoding and errors have the same meaning as the parameters of the same name in the string encode() method. The codec to be used is looked up using the Python codec registry. Return NULL if an exception was raised by the codec.
-
-// -------------------------------------- Number protocol
-
-boolean PyNumber_Check(PyObject  *o);
-// Returns 1 if the object o provides numeric protocols, and false otherwise. This function always succeeds.
-
-[new] PyObject* PyNumber_Add(PyObject *o1, PyObject *o2);
-// Return value: New reference.
-// Returns the result of adding o1 and o2, or NULL on failure. This is the equivalent of the Python expression o1 + o2.
-
-[new] PyObject* PyNumber_Subtract(PyObject *o1, PyObject *o2);
-// Return value: New reference.
-// Returns the result of subtracting o2 from o1, or NULL on failure. This is the equivalent of the Python expression o1 - o2.
-
-[new] PyObject* PyNumber_Multiply(PyObject *o1, PyObject *o2);
-// Return value: New reference.
-// Returns the result of multiplying o1 and o2, or NULL on failure. This is the equivalent of the Python expression o1 * o2.
-
-[new] PyObject* PyNumber_Divide(PyObject *o1, PyObject *o2);
-// Return value: New reference.
-// Returns the result of dividing o1 by o2, or NULL on failure. This is the equivalent of the Python expression o1 / o2.
-
-[new] PyObject* PyNumber_FloorDivide(PyObject *o1, PyObject *o2);
-// Return value: New reference.
-// Return the floor of o1 divided by o2, or NULL on failure. This is equivalent to the “classic” division of integers.
-
-[new] PyObject* PyNumber_TrueDivide(PyObject *o1, PyObject *o2);
-// Return value: New reference.
-// Return a reasonable approximation for the mathematical value of o1 divided by o2, or NULL on failure. The return value is “approximate” because binary floating point numbers are approximate; it is not possible to represent all real numbers in base two. This function can return a floating point value when passed two integers.
-
-[new] PyObject* PyNumber_Remainder(PyObject *o1, PyObject *o2);
-// Return value: New reference.
-// Returns the remainder of dividing o1 by o2, or NULL on failure. This is the equivalent of the Python expression o1 % o2.
-
-[new] PyObject* PyNumber_Divmod(PyObject *o1, PyObject *o2);
-// Return value: New reference.
-// See the built-in function divmod(). Returns NULL on failure. This is the equivalent of the Python expression divmod(o1, o2).
-
-[new] PyObject* PyNumber_Power(PyObject *o1, PyObject *o2, PyObject *o3);
-// Return value: New reference.
-// See the built-in function pow(). Returns NULL on failure. This is the equivalent of the Python expression pow(o1, o2, o3), where o3 is optional. If o3 is to be ignored, pass Py_None in its place (passing NULL for o3 would cause an illegal memory access).
-
-[new] PyObject* PyNumber_Negative(PyObject *o);
-// Return value: New reference.
-// Returns the negation of o on success, or NULL on failure. This is the equivalent of the Python expression -o.
-
-[new] PyObject* PyNumber_Positive(PyObject *o);
-// Return value: New reference.
-// Returns o on success, or NULL on failure. This is the equivalent of the Python expression +o.
-
-[new] PyObject* PyNumber_Absolute(PyObject *o);
-// Return value: New reference.
-// Returns the absolute value of o, or NULL on failure. This is the equivalent of the Python expression abs(o).
-
-[new] PyObject* PyNumber_Invert(PyObject *o);
-// Return value: New reference.
-// Returns the bitwise negation of o on success, or NULL on failure. This is the equivalent of the Python expression ~o.
-
-[new] PyObject* PyNumber_Lshift(PyObject *o1, PyObject *o2);
-// Return value: New reference.
-// Returns the result of left shifting o1 by o2 on success, or NULL on failure. This is the equivalent of the Python expression o1 << o2.
-
-[new] PyObject* PyNumber_Rshift(PyObject *o1, PyObject *o2);
-// Return value: New reference.
-// Returns the result of right shifting o1 by o2 on success, or NULL on failure. This is the equivalent of the Python expression o1 >> o2.
-
-[new] PyObject* PyNumber_And(PyObject *o1, PyObject *o2);
-// Return value: New reference.
-// Returns the “bitwise and” of o1 and o2 on success and NULL on failure. This is the equivalent of the Python expression o1 & o2.
-
-[new] PyObject* PyNumber_Xor(PyObject *o1, PyObject *o2);
-// Return value: New reference.
-// Returns the “bitwise exclusive or” of o1 by o2 on success, or NULL on failure. This is the equivalent of the Python expression o1 ^ o2.
-
-[new] PyObject* PyNumber_Or(PyObject *o1, PyObject *o2);
-// Return value: New reference.
-// Returns the “bitwise or” of o1 and o2 on success, or NULL on failure. This is the equivalent of the Python expression o1 | o2.
-
-[new] PyObject* PyNumber_InPlaceAdd(PyObject *o1, PyObject *o2);
-// Return value: New reference.
-// Returns the result of adding o1 and o2, or NULL on failure. The operation is done in-place when o1 supports it. This is the equivalent of the Python statement o1 += o2.
-
-[new] PyObject* PyNumber_InPlaceSubtract(PyObject *o1, PyObject *o2);
-// Return value: New reference.
-// Returns the result of subtracting o2 from o1, or NULL on failure. The operation is done in-place when o1 supports it. This is the equivalent of the Python statement o1 -= o2.
-
-[new] PyObject* PyNumber_InPlaceMultiply(PyObject *o1, PyObject *o2);
-// Return value: New reference.
-// Returns the result of multiplying o1 and o2, or NULL on failure. The operation is done in-place when o1 supports it. This is the equivalent of the Python statement o1 *= o2.
-
-[new] PyObject* PyNumber_InPlaceDivide(PyObject *o1, PyObject *o2);
-// Return value: New reference.
-// Returns the result of dividing o1 by o2, or NULL on failure. The operation is done in-place when o1 supports it. This is the equivalent of the Python statement o1 /= o2.
-
-[new] PyObject* PyNumber_InPlaceFloorDivide(PyObject *o1, PyObject *o2);
-// Return value: New reference.
-// Returns the mathematical floor of dividing o1 by o2, or NULL on failure. The operation is done in-place when o1 supports it. This is the equivalent of the Python statement o1 //= o2.
-
-[new] PyObject* PyNumber_InPlaceTrueDivide(PyObject *o1, PyObject *o2);
-// Return value: New reference.
-// Return a reasonable approximation for the mathematical value of o1 divided by o2, or NULL on failure. The return value is “approximate” because binary floating point numbers are approximate; it is not possible to represent all real numbers in base two. This function can return a floating point value when passed two integers. The operation is done in-place when o1 supports it.
-
-[new] PyObject* PyNumber_InPlaceRemainder(PyObject *o1, PyObject *o2);
-// Return value: New reference.
-// Returns the remainder of dividing o1 by o2, or NULL on failure. The operation is done in-place when o1 supports it. This is the equivalent of the Python statement o1 %= o2.
-
-[new] PyObject* PyNumber_InPlacePower(PyObject *o1, PyObject *o2, PyObject *o3);
-// Return value: New reference.
-// See the built-in function pow(). Returns NULL on failure. The operation is done in-place when o1 supports it. This is the equivalent of the Python statement o1 **= o2 when o3 is Py_None, or an in-place variant of pow(o1, o2, o3) otherwise. If o3 is to be ignored, pass Py_None in its place (passing NULL for o3 would cause an illegal memory access).
-
-[new] PyObject* PyNumber_InPlaceLshift(PyObject *o1, PyObject *o2);
-// Return value: New reference.
-// Returns the result of left shifting o1 by o2 on success, or NULL on failure. The operation is done in-place when o1 supports it. This is the equivalent of the Python statement o1 <<= o2.
-
-[new] PyObject* PyNumber_InPlaceRshift(PyObject *o1, PyObject *o2);
-// Return value: New reference.
-// Returns the result of right shifting o1 by o2 on success, or NULL on failure. The operation is done in-place when o1 supports it. This is the equivalent of the Python statement o1 >>= o2.
-
-[new] PyObject* PyNumber_InPlaceAnd(PyObject *o1, PyObject *o2);
-// Return value: New reference.
-// Returns the “bitwise and” of o1 and o2 on success and NULL on failure. The operation is done in-place when o1 supports it. This is the equivalent of the Python statement o1 &= o2.
-
-[new] PyObject* PyNumber_InPlaceXor(PyObject *o1, PyObject *o2);
-// Return value: New reference.
-// Returns the “bitwise exclusive or” of o1 by o2 on success, or NULL on failure. The operation is done in-place when o1 supports it. This is the equivalent of the Python statement o1 ^= o2.
-
-[new] PyObject* PyNumber_InPlaceOr(PyObject *o1, PyObject *o2);
-// Return value: New reference.
-// Returns the “bitwise or” of o1 and o2 on success, or NULL on failure. The operation is done in-place when o1 supports it. This is the equivalent of the Python statement o1 |= o2.
-
-// int PyNumber_Coerce(PyObject **p1, PyObject **p2);
-// This function takes the addresses of two variables of type PyObject*. If the objects pointed to by *p1 and *p2 have the same type, increment their reference count and return 0 (success). If the objects can be converted to a common numeric type, replace *p1 and *p2 by their converted value (with ‘new’ reference counts), and return 0. If no conversion is possible, or if some other error occurs, return -1 (failure) and don’t increment the reference counts. The call PyNumber_Coerce(&o1, &o2) is equivalent to the Python statement o1, o2 = coerce(o1, o2).
-
-// int PyNumber_CoerceEx(PyObject **p1, PyObject **p2);
-// This function is similar to PyNumber_Coerce(), except that it returns 1 when the conversion is not possible and when no error is raised. Reference counts are still not increased in this case.
-
-[new] PyObject* PyNumber_Int(PyObject *o);
-// Return value: New reference.
-// Returns the o converted to an integer object on success, or NULL on failure. If the argument is outside the integer range a long object will be returned instead. This is the equivalent of the Python expression int(o).
-
-[new] PyObject* PyNumber_Long(PyObject *o);
-// Return value: New reference.
-// Returns the o converted to a long integer object on success, or NULL on failure. This is the equivalent of the Python expression long(o).
-
-[new] PyObject* PyNumber_Float(PyObject *o);
-// Return value: New reference.
-// Returns the o converted to a float object on success, or NULL on failure. This is the equivalent of the Python expression float(o).
-
-PyObject* PyNumber_Index(PyObject *o);
-// Returns the o converted to a Python int or long on success or NULL with a TypeError exception raised on failure.
-
-PyObject* PyNumber_ToBase(PyObject *n, int base);
-// Returns the integer n converted to base as a string with a base marker of '0b', '0o', or '0x' if applicable. When base is not 2, 8, 10, or 16, the format is 'x#num' where x is the base. If n is not an int object, it is converted with PyNumber_Index() first.
-
-size_or_fail PyNumber_AsSsize_t(PyObject *o, PyObject *exc);
-// Returns o converted to a Py_ssize_t value if o can be interpreted as an integer. If o can be converted to a Python int or long but the attempt to convert to a Py_ssize_t value would raise an OverflowError, then the exc argument is the type of exception that will be raised (usually IndexError or OverflowError). If exc is NULL, then the exception is cleared and the value is clipped to PY_SSIZE_T_MIN for a negative integer or PY_SSIZE_T_MAX for a positive integer.
-
-boolean PyIndex_Check(PyObject *o); // or bool_or_fail ?
-// Returns True if o is an index integer (has the nb_index slot of the tp_as_number structure filled in).
-
-// ------------------------- Sequence protocol
-
-boolean PySequence_Check(PyObject  *o);
-// Return 1 if the object provides sequence protocol, and 0 otherwise. This function always succeeds.
-
-size_or_fail PySequence_Size(PyObject *o);
-size_or_fail PySequence_Length(PyObject *o);
-// Returns the number of objects in sequence o on success, and -1 on failure. For objects that do not provide sequence protocol, this is equivalent to the Python expression len(o).
-
-[new] PyObject* PySequence_Concat(PyObject *o1, PyObject *o2);
-// Return value: New reference.
-// Return the concatenation of o1 and o2 on success, and NULL on failure. This is the equivalent of the Python expression o1 + o2.
-
-[new] PyObject* PySequence_Repeat(PyObject *o, Py_ssize_t count);
-// Return value: New reference.
-// Return the result of repeating sequence object o count times, or NULL on failure. This is the equivalent of the Python expression o * count.
-
-[new] PyObject* PySequence_InPlaceConcat(PyObject *o1, PyObject *o2);
-// Return value: New reference.
-// Return the concatenation of o1 and o2 on success, and NULL on failure. The operation is done in-place when o1 supports it. This is the equivalent of the Python expression o1 += o2.
-
-[new] PyObject* PySequence_InPlaceRepeat(PyObject *o, Py_ssize_t count);
-// Return value: New reference.
-// Return the result of repeating sequence object o count times, or NULL on failure. The operation is done in-place when o supports it. This is the equivalent of the Python expression o *= count.
-
-[new] PyObject* PySequence_GetItem(PyObject *o, Py_ssize_t i);
-// Return value: New reference.
-// Return the ith element of o, or NULL on failure. This is the equivalent of the Python expression o[i].
-
-[new] PyObject* PySequence_GetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2);
-// Return value: New reference.
-// Return the slice of sequence object o between i1 and i2, or NULL on failure. This is the equivalent of the Python expression o[i1:i2].
-
-unit_or_fail PySequence_SetItem(PyObject *o, Py_ssize_t i, [stolen] PyObject *v);
-// Assign object v to the ith element of o. Returns -1 on failure. This is the equivalent of the Python statement o[i] = v. This function does not steal a reference to v.
-
-unit_or_fail PySequence_DelItem(PyObject *o, Py_ssize_t i);
-// Delete the ith element of object o. Returns -1 on failure. This is the equivalent of the Python statement del o[i].
-
-unit_or_fail PySequence_SetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2, PyObject *v);
-// Assign the sequence object v to the slice in sequence object o from i1 to i2. This is the equivalent of the Python statement o[i1:i2] = v.
-
-unit_or_fail PySequence_DelSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2);
-// Delete the slice in sequence object o from i1 to i2. Returns -1 on failure. This is the equivalent of the Python statement del o[i1:i2].
-
-size_or_fail PySequence_Count(PyObject *o, PyObject *value_);
-// Return the number of occurrences of value in o, that is, return the number of keys for which o[key] == value. On failure, return -1. This is equivalent to the Python expression o.count(value).
-
-bool_or_fail PySequence_Contains(PyObject *o, PyObject *value_);
-// Determine if o contains value. If an item in o is equal to value, return 1, otherwise return 0. On error, return -1. This is equivalent to the Python expression value in o.
-
-size_or_fail PySequence_Index(PyObject *o, PyObject *value_);
-// Return the first index i for which o[i] == value. On error, return -1. This is equivalent to the Python expression o.index(value).
-
-[new] PyObject* PySequence_List(PyObject *o);
-// Return value: New reference.
-// Return a list object with the same contents as the arbitrary sequence o. The returned list is guaranteed to be new.
-
-[new] PyObject* PySequence_Tuple(PyObject *o);
-// Return value: New reference.
-// Return a tuple object with the same contents as the arbitrary sequence o or NULL on failure. If o is a tuple, a new reference will be returned, otherwise a tuple will be constructed with the appropriate contents. This is equivalent to the Python expression tuple(o).
-
-[new] PyObject* PySequence_Fast(PyObject *o, [string] const char *m);
-// Return value: New reference.
-// Returns the sequence o as a tuple, unless it is already a tuple or list, in which case o is returned. Use PySequence_Fast_GET_ITEM() to access the members of the result. Returns NULL on failure. If the object is not a sequence, raises TypeError with m as the message text.
-
-PyObject* PySequence_Fast_GET_ITEM(PyObject *o, Py_ssize_t i);
-// Return value: Borrowed reference.
-// Return the ith element of o, assuming that o was returned by PySequence_Fast(), o is not NULL, and that i is within bounds.
-
-// PyObject** PySequence_Fast_ITEMS(PyObject *o);
-// Return the underlying array of PyObject pointers. Assumes that o was returned by PySequence_Fast() and o is not NULL.
-// Note, if a list gets resized, the reallocation may relocate the items array. So, only use the underlying array pointer in contexts where the sequence cannot change.
-
-[new] PyObject* PySequence_ITEM(PyObject *o, Py_ssize_t i);
-// Return value: New reference.
-//Return the ith element of o or NULL on failure. Macro form of PySequence_GetItem() but without checking that PySequence_Check(o)() is true and without adjustment for negative indices.
-
-size_or_fail PySequence_Fast_GET_SIZE(PyObject *o);
-// Returns the length of o, assuming that o was returned by PySequence_Fast() and that o is not NULL. The size can also be gotten by calling PySequence_Size() on o, but PySequence_Fast_GET_SIZE() is faster because it can assume o is a list or tuple.
-
-// ---------------------- mapping protocol
-
-boolean PyMapping_Check(PyObject  *o);
-// Return 1 if the object provides mapping protocol, and 0 otherwise. This function always succeeds.
-
-size_or_fail PyMapping_Size(PyObject *o);
-size_or_fail PyMapping_Length(PyObject *o);
-// Returns the number of keys in object o on success, and -1 on failure. For objects that do not provide mapping protocol, this is equivalent to the Python expression len(o).
-
-unit_or_fail PyMapping_DelItemString(PyObject *o, [string] char *key);
-// Remove the mapping for object key from the object o. Return -1 on failure. This is equivalent to the Python statement del o[key].
-
-unit_or_fail PyMapping_DelItem(PyObject *o, PyObject *key);
-// Remove the mapping for object key from the object o. Return -1 on failure. This is equivalent to the Python statement del o[key].
-
-boolean PyMapping_HasKeyString(PyObject *o, [string] char *key);
-// On success, return 1 if the mapping object has the key key and 0 otherwise. This is equivalent to o[key], returning True on success and False on an exception. This function always succeeds.
-
-boolean PyMapping_HasKey(PyObject *o, PyObject *key);
-// Return 1 if the mapping object has the key key and 0 otherwise. This is equivalent to o[key], returning True on success and False on an exception. This function always succeeds.
-
-[new] PyObject* PyMapping_Keys(PyObject *o);
-// Return value: New reference.
-// On success, return a list of the keys in object o. On failure, return NULL. This is equivalent to the Python expression o.keys().
-
-[new] PyObject* PyMapping_Values(PyObject *o);
-// Return value: New reference.
-// On success, return a list of the values in object o. On failure, return NULL. This is equivalent to the Python expression o.values().
-
-[new] PyObject* PyMapping_Items(PyObject *o);
-// Return value: New reference.
-// On success, return a list of the items in object o, where each item is a tuple containing a key-value pair. On failure, return NULL. This is equivalent to the Python expression o.items().
-
-[new] PyObject* PyMapping_GetItemString(PyObject *o, [string] char *key);
-// Return value: New reference.
-// Return element of o corresponding to the object key or NULL on failure. This is the equivalent of the Python expression o[key].
-
-unit_or_fail PyMapping_SetItemString(PyObject *o, [string] char *key, PyObject *v);
-// Map the object key to the value v in object o. Returns -1 on failure. This is the equivalent of the Python statement o[key] = v.
-
-// -------------------------- iterator protocol
-
-boolean PyIter_Check(PyObject *o);
-// Return true if the object o supports the iterator protocol.
-
-[new] PyObject* PyIter_Next(PyObject *o);
-// Return value: New reference.
-// Return the next value from the iteration o. If the object is an iterator, this retrieves the next value from the iteration, and returns NULL with no exception set if there are no remaining items. If the object is not an iterator, TypeError is raised, or if there is an error in retrieving the item, returns NULL and passes along the exception.
-
-// ------------------------ type objects
-
-// PyTypeObject;
-//    The C structure of the objects used to describe built-in types.
-
-// PyObject* PyType_Type;
-//    This is the type object for type objects; it is the same object as type and types.TypeType in the Python layer.
-
-boolean PyType_Check(PyObject *o);
-//    Return true if the object o is a type object, including instances of types derived from the standard type object. Return false in all other cases.
-
-boolean PyType_CheckExact(PyObject *o);
-//    Return true if the object o is a type object, but not a subtype of the standard type object. Return false in all other cases.
-
-// unsigned int PyType_ClearCache()¶
-int PyType_ClearCache(); // unsigned int actually
-
-//TYPE void PyType_Modified(PyTypeObject *type);
-//TYPE //    Invalidate the internal lookup cache for the type and all of its subtypes. This function must be called after any manual modification of the attributes or base classes of the type.
-
-//TYPE bool_or_fail PyType_HasFeature(PyObject *o, int feature);
-//TYPE //    Return true if the type object o sets the feature feature. Type features are denoted by single bit flags.
-
-//TYPE bool_or_fail PyType_IS_GC(PyObject *o);
-//TYPE //    Return true if the type object includes support for the cycle detector; this tests the type flag Py_TPFLAGS_HAVE_GC.
-
-//TYPE bool_or_fail PyType_IsSubtype(PyTypeObject *a, PyTypeObject *b);
-//TYPE //    Return true if a is a subtype of b.
-//TYPE 
-//TYPE PyObject* PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems);
-//TYPE //    Return value: New reference.
-//TYPE 
-//TYPE PyObject* PyType_GenericNew(PyTypeObject *type, PyObject *args, PyObject *kwds);
-//TYPE //    Return value: New reference.
-//TYPE 
-//TYPE unit_or_fail PyType_Ready(PyTypeObject *type);
-//TYPE //    Finalize a type object. This should be called on all type objects to finish their initialization. This function is responsible for adding inherited slots from a type’s base class. Return 0 on success, or return -1 and sets an exception on error.
-
-// ----------------------- Plain integers
-
-// PyIntObject;
-// This subtype of PyObject represents a Python integer object.
-
-// PyTypeObject PyInt_Type;
-//    This instance of PyTypeObject represents the Python plain integer type. This is the same object as int and types.IntType.
-
-boolean PyInt_Check(PyObject *o);
-//    Return true if o is of type PyInt_Type or a subtype of PyInt_Type.
-
-boolean PyInt_CheckExact(PyObject *o);
-//    Return true if o is of type PyInt_Type, but not a subtype of PyInt_Type.
-
-// PyObject* PyInt_FromString([string] char *str, char **pend, int base);
-//    Return value: New reference.
-//    Return a new PyIntObject or PyLongObject based on the string value in str, which is interpreted according to the radix in base. If pend is non-NULL, *pend will point to the first character in str which follows the representation of the number. If base is 0, the radix will be determined based on the leading characters of str: if str starts with '0x' or '0X', radix 16 will be used; if str starts with '0', radix 8 will be used; otherwise radix 10 will be used. If base is not 0, it must be between 2 and 36, inclusive. Leading spaces are ignored. If there are no digits, ValueError will be raised. If the string represents a number too large to be contained within the machine’s long int type and overflow warnings are being suppressed, a PyLongObject will be returned. If overflow warnings are not being suppressed, NULL will be returned in this case.
-
-[new] PyObject* PyInt_FromLong(long ival);
-//    Return value: New reference.
-//    Create a new integer object with a value of ival.
-//    The current implementation keeps an array of integer objects for all integers between -5 and 256, when you create an int in that range you actually just get back a reference to the existing object. So it should be possible to change the value of 1. I suspect the behaviour of Python in this case is undefined. :-)
-
-[new] PyObject* PyInt_FromSsize_t(Py_ssize_t ival);
-//    Return value: New reference.
-//    Create a new integer object with a value of ival. If the value is larger than LONG_MAX or smaller than LONG_MIN, a long integer object is returned.
-
-[new] PyObject* PyInt_FromSize_t(size_t ival);
-//    Create a new integer object with a value of ival. If the value exceeds LONG_MAX, a long integer object is returned.
-
-long PyInt_AsLong(PyObject *io);
-//    Will first attempt to cast the object to a PyIntObject, if it is not already one, and then return its value. If there is an error, -1 is returned, and the caller should check PyErr_Occurred() to find out whether there was an error, or whether the value just happened to be -1.
-
-// long PyInt_AS_LONG(PyObject *io);
-//    Return the value of the object io. No error checking is performed.
-
-// unsigned long PyInt_AsUnsignedLongMask(PyObject *io);
-//    Will first attempt to cast the object to a PyIntObject or PyLongObject, if it is not already one, and then return its value as unsigned long. This function does not check for overflow.
-
-// unsigned PY_LONG_LONG PyInt_AsUnsignedLongLongMask(PyObject *io);
-//    Will first attempt to cast the object to a PyIntObject or PyLongObject, if it is not already one, and then return its value as unsigned long long, without checking for overflow.
-
-size_or_fail PyInt_AsSsize_t(PyObject *io);
-//    Will first attempt to cast the object to a PyIntObject or PyLongObject, if it is not already one, and then return its value as Py_ssize_t.
-
-long PyInt_GetMax();
-//    Return the system’s idea of the largest integer it can handle (LONG_MAX, as defined in the system header files).
-
-int PyInt_ClearFreeList();
-//    Clear the integer free list. Return the number of items that could not be freed.
-
-// ------------------ Importing modules
-
-[new] PyObject* PyImport_ImportModule([string] const char  *name);
-//    Return value: New reference.
-//    This is a simplified interface to PyImport_ImportModuleEx() below, leaving the globals and locals arguments set to NULL and level set to 0. When the name argument contains a dot (when it specifies a submodule of a package), the fromlist argument is set to the list ['*'] so that the return value is the named module rather than the top-level package containing it as would otherwise be the case. (Unfortunately, this has an additional side effect when name in fact specifies a subpackage instead of a submodule: the submodules specified in the package’s __all__ variable are loaded.) Return a new reference to the imported module, or NULL with an exception set on failure. Before Python 2.4, the module may still be created in the failure case — examine sys.modules to find out. Starting with Python 2.4, a failing import of a module no longer leaves the module in sys.modules.
-
-[new] PyObject* PyImport_ImportModuleNoBlock([string] const char *name);
-//    This version of PyImport_ImportModule() does not block. It’s intended to be used in C functions that import other modules to execute a function. The import may block if another thread holds the import lock. The function PyImport_ImportModuleNoBlock() never blocks. It first tries to fetch the module from sys.modules and falls back to PyImport_ImportModule() unless the lock is held, in which case the function will raise an ImportError.
-
-// PyObject* PyImport_ImportModuleEx([string] char *name, PyObject *globals, PyObject *locals, PyObject *fromlist);
-//    Return value: New reference.
-//    Import a module. This is best described by referring to the built-in Python function __import__(), as the standard __import__() function calls this function directly.
-//    The return value is a new reference to the imported module or top-level package, or NULL with an exception set on failure (before Python 2.4, the module may still be created in this case). Like for __import__(), the return value when a submodule of a package was requested is normally the top-level package, unless a non-empty fromlist was given.
-
-// PyObject* PyImport_ImportModuleLevel([string] char *name, PyObject *globals, PyObject *locals, PyObject *fromlist, int level);
-//    Return value: New reference.
-//    Import a module. This is best described by referring to the built-in Python function __import__(), as the standard __import__() function calls this function directly.
-//    The return value is a new reference to the imported module or top-level package, or NULL with an exception set on failure. Like for __import__(), the return value when a submodule of a package was requested is normally the top-level package, unless a non-empty fromlist was given.
-
-[new] PyObject* PyImport_Import(PyObject *name);
-//    Return value: New reference.
-//    This is a higher-level interface that calls the current “import hook function”. It invokes the __import__() function from the __builtins__ of the current globals. This means that the import is done using whatever import hooks are installed in the current environment, e.g. by rexec or ihooks.
-
-[new] PyObject* PyImport_ReloadModule(PyObject *m);
-//    Return value: New reference.
-//    Reload a module. This is best described by referring to the built-in Python function reload(), as the standard reload() function calls this function directly. Return a new reference to the reloaded module, or NULL with an exception set on failure (the module still exists in this case).
-
-PyObject* PyImport_AddModule([string] const char *name);
-//    Return value: Borrowed reference.
-//    Return the module object corresponding to a module name. The name argument may be of the form package.module. First check the modules dictionary if there’s one there, and if not, create a new one and insert it in the modules dictionary. Return NULL with an exception set on failure.
-//    Note
-//    This function does not load or import the module; if the module wasn’t already loaded, you will get an empty module object. Use PyImport_ImportModule() or one of its variants to import a module. Package structures implied by a dotted name for name are not created if not already present.
-
-[new] PyObject* PyImport_ExecCodeModule([string] char *name, PyObject *co);
-//    Return value: New reference.
-//    Given a module name (possibly of the form package.module) and a code object read from a Python bytecode file or obtained from the built-in function compile(), load the module. Return a new reference to the module object, or NULL with an exception set if an error occurred. Before Python 2.4, the module could still be created in error cases. Starting with Python 2.4, name is removed from sys.modules in error cases, and even if name was already in sys.modules on entry to PyImport_ExecCodeModule(). Leaving incompletely initialized modules in sys.modules is dangerous, as imports of such modules have no way to know that the module object is an unknown (and probably damaged with respect to the module author’s intents) state.
-//    The module’s __file__ attribute will be set to the code object’s co_filename.
-//    This function will reload the module if it was already imported. See PyImport_ReloadModule() for the intended way to reload a module.
-//    If name points to a dotted name of the form package.module, any package structures not already created will still not be created.
-
-[new] PyObject* PyImport_ExecCodeModuleEx([string] char *name, PyObject *co, [string] char *pathname);
-//    Return value: New reference.
-//    Like PyImport_ExecCodeModule(), but the __file__ attribute of the module object is set to pathname if it is non-NULL.
-
-long PyImport_GetMagicNumber();
-//    Return the magic number for Python bytecode files (a.k.a. .pyc and .pyo files). The magic number should be present in the first four bytes of the bytecode file, in little-endian byte order.
-
-PyObject* PyImport_GetModuleDict(); // Borrowed reference!
-//    Return value: Borrowed reference.
-//    Return the dictionary used for the module administration (a.k.a. sys.modules). Note that this is a per-interpreter variable.
-
-[new] PyObject* PyImport_GetImporter(PyObject *path); // not quite sure about [new]
-//    Return an importer object for a sys.path/pkg.__path__ item path, possibly by fetching it from the sys.path_importer_cache dict. If it wasn’t yet cached, traverse sys.path_hooks until a hook is found that can handle the path item. Return None if no hook could; this tells our caller it should fall back to the built-in import mechanism. Cache the result in sys.path_importer_cache. Return a new reference to the importer object.
-
-//void _PyImport_Init();
-//    Initialize the import mechanism. For internal use only.
-
-// void PyImport_Cleanup();
-//    Empty the module table. For internal use only.
-
-// void _PyImport_Fini();
-//    Finalize the import mechanism. For internal use only.
-
-// PyObject* _PyImport_FindExtension(char *, char *);
-//    For internal use only.
-
-// PyObject* _PyImport_FixupExtension(char *, char *);
-//    For internal use only.
-
-bool_or_fail PyImport_ImportFrozenModule([string] char *name);
-//    Load a frozen module named name. Return 1 for success, 0 if the module is not found, and -1 with an exception set if the initialization failed. To access the imported module on a successful load, use PyImport_ImportModule(). (Note the misnomer — this function would reload the module if it was already imported.)
-
-//struct _frozen¶
-//
-//    This is the structure type definition for frozen module descriptors, as generated by the freeze utility (see Tools/freeze/ in the Python source distribution). Its definition, found in Include/import.h, is:
-//
-//    struct _frozen {
-//        char *name;
-//        unsigned char *code;
-//        int size;
-//    };
-
-// struct _frozen* PyImport_FrozenModules¶
-//    This pointer is initialized to point to an array of struct _frozen records, terminated by one whose members are all NULL or zero. When a frozen module is imported, it is searched in this table. Third-party code could play tricks with this to provide a dynamically created collection of frozen modules.
-
-// int PyImport_AppendInittab(const char *name, void (*initfunc)(void))¶
-//    Add a single module to the existing table of built-in modules. This is a convenience wrapper around PyImport_ExtendInittab(), returning -1 if the table could not be extended. The new module can be imported by the name name, and uses the function initfunc as the initialization function called on the first attempted import. This should be called before Py_Initialize().
-
-// struct _inittab¶
-// 
-//     Structure describing a single entry in the list of built-in modules. Each of these structures gives the name and initialization function for a module built into the interpreter. Programs which embed Python may use an array of these structures in conjunction with PyImport_ExtendInittab() to provide additional built-in modules. The structure is defined in Include/import.h as:
-// 
-//     struct _inittab {
-//         char *name;
-//         void (*initfunc)(void);
-//     };
-
-// int PyImport_ExtendInittab(struct _inittab *newtab)¶
-//    Add a collection of modules to the table of built-in modules. The newtab array must end with a sentinel entry which contains NULL for the name field; failure to provide the sentinel value can result in a memory fault. Returns 0 on success or -1 if insufficient memory could be allocated to extend the internal table. In the event of failure, no modules are added to the internal table. This should be called before Py_Initialize().
-
-// -------------------------- Byte array
-
-// PyByteArrayObject;
-//    This subtype of PyObject represents a Python bytearray object.
-
-// PyTypeObject PyByteArray_Type;
-//    This instance of PyTypeObject represents the Python bytearray type; it is the same object as bytearray in the Python layer.
-
-boolean PyByteArray_Check(PyObject *o);
-//    Return true if the object o is a bytearray object or an instance of a subtype of the bytearray type.
-
-boolean PyByteArray_CheckExact(PyObject *o);
-//    Return true if the object o is a bytearray object, but not an instance of a subtype of the bytearray type.
-
-[new] PyObject* PyByteArray_FromObject(PyObject *o);
-//    Return a new bytearray object from any object, o, that implements the buffer protocol.
-
-[new] PyObject* PyByteArray_FromStringAndSize([string] const char *string, Py_ssize_t len);
-//    Create a new bytearray object from string and its length, len. On failure, NULL is returned.
-
-[new] PyObject* PyByteArray_Concat(PyObject *a, PyObject *b);
-//    Concat bytearrays a and b and return a new bytearray with the result.
-
-size_or_fail PyByteArray_Size(PyObject *bytearray);
-//    Return the size of bytearray after checking for a NULL pointer.
-
-[string] char* PyByteArray_AsString(PyObject *bytearray);
-//    Return the contents of bytearray as a char array after checking for a NULL pointer.
-
-unit_or_fail /* ? */ PyByteArray_Resize(PyObject *bytearray, Py_ssize_t len); // return type is int
-//    Resize the internal buffer of bytearray to len.
-
-// These macros trade safety for speed and they don’t check pointers.
-
-[string] char* PyByteArray_AS_STRING(PyObject *bytearray);
-//    Macro version of PyByteArray_AsString().
-
-Py_ssize_t PyByteArray_GET_SIZE(PyObject *bytearray);
-//    Macro version of PyByteArray_Size().
-
-// ------------------------- module object
-
-// PyTypeObject PyModule_Type
-// This instance of PyTypeObject represents the Python module type. This is exposed to Python programs as types.ModuleType.
-
-boolean PyModule_Check(PyObject *p);
-// Return true if p is a module object, or a subtype of a module object.
-
-boolean PyModule_CheckExact(PyObject *p);
-// Return true if p is a module object, but not a subtype of PyModule_Type.
-
-[new] PyObject* PyModule_New([string] const char *name);
-// Return value: New reference.
-// Return a new module object with the __name__ attribute set to name. Only the module’s __doc__ and __name__ attributes are filled in; the caller is responsible for providing a __file__ attribute.
-
-PyObject* PyModule_GetDict(PyObject *module);
-// Return value: Borrowed reference.
-// Return the dictionary object that implements module‘s namespace; this object is the same as the __dict__ attribute of the module object. This function never fails. It is recommended extensions use other PyModule_*() and PyObject_*() functions rather than directly manipulate a module’s __dict__.
-
-[string] char* PyModule_GetName(PyObject *module);
-// Return module‘s __name__ value. If the module does not provide one, or if it is not a string, SystemError is raised and NULL is returned.
-
-[string] char* PyModule_GetFilename(PyObject *module);
-// Return the name of the file from which module was loaded using module‘s __file__ attribute. If this is not defined, or if it is not a string, raise SystemError and return NULL.
-
-unit_or_fail PyModule_AddObject(PyObject *module, [string] const char *name, [stolen] PyObject *value);
-// Add an object to module as name. This is a convenience function which can be used from the module’s initialization function. This steals a reference to value. Return -1 on error, 0 on success.
-
-unit_or_fail PyModule_AddIntConstant(PyObject *module, [string] const char *name, long value);
-// Add an integer constant to module as name. This convenience function can be used from the module’s initialization function. Return -1 on error, 0 on success.
-
-unit_or_fail PyModule_AddStringConstant(PyObject *module, [string] const char *name, [string] const char *value);
-// Add a string constant to module as name. This convenience function can be used from the module’s initialization function. The string value must be null-terminated. Return -1 on error, 0 on success.
-
-// unit_or_fail PyModule_AddIntMacro(PyObject *module, macro);
-// Add an int constant to module. The name and the value are taken from macro. For example PyModule_AddConstant(module, AF_INET) adds the int constant AF_INET with the value of AF_INET to module. Return -1 on error, 0 on success.
-
-// int PyModule_AddStringMacro(PyObject *module, macro);
-// Add a string constant to module.
-
-// ------------------ dict
-
-// PyDictObject
-// This subtype of PyObject represents a Python dictionary object.
-// PyTypeObject PyDict_Type
-// This instance of PyTypeObject represents the Python dictionary type. This is exposed to Python programs as dict and types.DictType.
-
-boolean PyDict_Check(PyObject *p);
-// Return true if p is a dict object or an instance of a subtype of the dict type.
-
-boolean PyDict_CheckExact(PyObject *p);
-// aReturn true if p is a dict object, but not an instance of a subtype of the dict type.
-
-[new] PyObject* PyDict_New();
-// Return value: New reference.
-// Return a new empty dictionary, or NULL on failure.
-
-[new] PyObject* PyDictProxy_New(PyObject *dict);
-// Return value: New reference.
-// Return a proxy object for a mapping which enforces read-only behavior. This is normally used to create a proxy to prevent modification of the dictionary for non-dynamic class types.
-
-// No error ?!?!
-void PyDict_Clear(PyObject *p);
-// Empty an existing dictionary of all key-value pairs.
-
-bool_or_fail PyDict_Contains(PyObject *p, PyObject *key);
-// Determine if dictionary p contains key. If an item in p is matches key, return 1, otherwise return 0. On error, return -1. This is equivalent to the Python expression key in p.
-
-[new] PyObject* PyDict_Copy(PyObject *p);
-// Return value: New reference.
-// Return a new dictionary that contains the same key-value pairs as p.
-
-unit_or_fail PyDict_SetItem(PyObject *p, PyObject *key, PyObject *val);
-// Insert value into the dictionary p with a key of key. key must be hashable; if it isn’t, TypeError will be raised. Return 0 on success or -1 on failure.
-
-unit_or_fail PyDict_SetItemString(PyObject *p, [string] const char *key, PyObject *val);
-// Insert value into the dictionary p using key as a key. key should be a char*. The key object is created using PyString_FromString(key). Return 0 on success or -1 on failure.
-
-unit_or_fail PyDict_DelItem(PyObject *p, PyObject *key);
-// Remove the entry in dictionary p with key key. key must be hashable; if it isn’t, TypeError is raised. Return 0 on success or -1 on failure.
-
-int PyDict_DelItemString(PyObject *p, [string] char *key);
-// Remove the entry in dictionary p which has a key specified by the string key. Return 0 on success or -1 on failure.
-
-PyObject* PyDict_GetItem(PyObject *p, PyObject *key);
-// Return value: Borrowed reference.
-// Return the object from dictionary p which has a key key. Return NULL if the key key is not present, but without setting an exception.
-
-PyObject* PyDict_GetItemString(PyObject *p, [string] const char *key);
-// Return value: Borrowed reference.
-// This is the same as PyDict_GetItem(), but key is specified as a char*, rather than a PyObject*.
-
-[new] PyObject* PyDict_Items(PyObject *p);
-// Return value: New reference.
-// Return a PyListObject containing all the items from the dictionary, as in the dictionary method dict.items().
-
-[new] PyObject* PyDict_Keys(PyObject *p);
-// Return value: New reference.
-// Return a PyListObject containing all the keys from the dictionary, as in the dictionary method dict.keys().
-
-[new] PyObject* PyDict_Values(PyObject *p);
-// Return value: New reference.
-// Return a PyListObject containing all the values from the dictionary p, as in the dictionary method dict.values().
-
-size_or_fail PyDict_Size(PyObject *p);
-// Return the number of items in the dictionary. This is equivalent to len(p) on a dictionary.
-
-// int PyDict_Next(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue)
-// Iterate over all key-value pairs in the dictionary p. The Py_ssize_t referred to by ppos must be initialized to 0 prior to the first call to this function to start the iteration; the function returns true for each pair in the dictionary, and false once all pairs have been reported. The parameters pkey and pvalue should either point to PyObject* variables that will be filled in with each key and value, respectively, or may be NULL. Any references returned through them are borrowed. ppos should not be altered during iteration. Its value represents offsets within the internal dictionary structure, and since the structure is sparse, the offsets are not consecutive.
-// 
-// For example:
-// 
-// PyObject *key, *value;
-// Py_ssize_t pos = 0;
-// 
-// while (PyDict_Next(self->dict, &pos, &key, &value)) {
-//     /* do something interesting with the values... */
-//     ...
-// }
-// The dictionary p should not be mutated during iteration. It is safe (since Python 2.1) to modify the values of the keys as you iterate over the dictionary, but only so long as the set of keys does not change. For example:
-// 
-// PyObject *key, *value;
-// Py_ssize_t pos = 0;
-// 
-// while (PyDict_Next(self->dict, &pos, &key, &value)) {
-//     int i = PyInt_AS_LONG(value) + 1;
-//     PyObject *o = PyInt_FromLong(i);
-//     if (o == NULL)
-//         return -1;
-//     if (PyDict_SetItem(self->dict, key, o) < 0) {
-//         Py_DECREF(o);
-//         return -1;
-//     }
-//     Py_DECREF(o);
-// }
-
-unit_or_fail PyDict_Merge(PyObject *a, PyObject *b, boolean override);
-// Iterate over mapping object b adding key-value pairs to dictionary a. b may be a dictionary, or any object supporting PyMapping_Keys() and PyObject_GetItem(). If override is true, existing pairs in a will be replaced if a matching key is found in b, otherwise pairs will only be added if there is not a matching key in a. Return 0 on success or -1 if an exception was raised.
-
-unit_or_fail PyDict_Update(PyObject *a, PyObject *b);
-// This is the same as PyDict_Merge(a, b, 1) in C, or a.update(b) in Python. Return 0 on success or -1 if an exception was raised.
-
-unit_or_fail PyDict_MergeFromSeq2(PyObject *a, PyObject *seq2, boolean override);
-// Update or merge into dictionary a, from the key-value pairs in seq2. seq2 must be an iterable object producing iterable objects of length 2, viewed as key-value pairs. In case of duplicate keys, the last wins if override is true, else the first wins. Return 0 on success or -1 if an exception was raised. Equivalent Python (except for the return value):
-// 
-// def PyDict_MergeFromSeq2(a, seq2, override):
-//     for key, value in seq2:
-//         if override or key not in a:
-//             a[key] = value
-
-// ----------- tuple
-
-// PyTupleObject
-// This subtype of PyObject represents a Python tuple object.
-
-// PyTypeObject PyTuple_Type
-// This instance of PyTypeObject represents the Python tuple type; it is the same object as tuple and types.TupleType in the Python layer..
-
-boolean PyTuple_Check(PyObject *p);
-// Return true if p is a tuple object or an instance of a subtype of the tuple type.
-
-boolean PyTuple_CheckExact(PyObject *p);
-// Return true if p is a tuple object, but not an instance of a subtype of the tuple type.
-
-[new] PyObject* PyTuple_New(Py_ssize_t len);
-// Return value: New reference.
-// Return a new tuple object of size len, or NULL on failure.
-
-// PyObject* PyTuple_Pack(Py_ssize_t n, ...)
-// Return value: New reference.
-// Return a new tuple object of size n, or NULL on failure. The tuple values are initialized to the subsequent n C arguments pointing to Python objects. PyTuple_Pack(2, a, b) is equivalent to Py_BuildValue("(OO)", a, b).
-
-size_or_fail PyTuple_Size(PyObject *p);
-// Take a pointer to a tuple object, and return the size of that tuple.
-
-size_or_fail PyTuple_GET_SIZE(PyObject *p);
-// Return the size of the tuple p, which must be non-NULL and point to a tuple; no error checking is performed.
-
-PyObject* PyTuple_GetItem(PyObject *p, Py_ssize_t pos);
-// Return value: Borrowed reference.
-// Return the object at position pos in the tuple pointed to by p. If pos is out of bounds, return NULL and sets an IndexError exception.
-
-PyObject* PyTuple_GET_ITEM(PyObject *p, Py_ssize_t pos);
-// Return value: Borrowed reference.
-// Like PyTuple_GetItem(), but does no checking of its arguments.
-
-[new] PyObject* PyTuple_GetSlice(PyObject *p, Py_ssize_t low, Py_ssize_t high);
-// Return value: New reference.
-// Take a slice of the tuple pointed to by p from low to high and return it as a new tuple.
-
-unit_or_fail PyTuple_SetItem(PyObject *p, Py_ssize_t pos, [stolen] PyObject *o);
-// Insert a reference to object o at position pos of the tuple pointed to by p. Return 0 on success.
-// 
-// Note This function “steals” a reference to o.
-
-void PyTuple_SET_ITEM(PyObject *p, Py_ssize_t pos, [stolen] PyObject *o);
-// Like PyTuple_SetItem(), but does no error checking, and should only be used to fill in brand new tuples.
-//
-// Note This function “steals” a reference to o.
-
-// int _PyTuple_Resize(PyObject **p, Py_ssize_t newsize);
-// Can be used to resize a tuple. newsize will be the new length of the tuple. Because tuples are supposed to be immutable, this should only be used if there is only one reference to the object. Do not use this if the tuple may already be known to some other part of the code. The tuple will always grow or shrink at the end. Think of this as destroying the old tuple and creating a new one, only more efficiently. Returns 0 on success. Client code should never assume that the resulting value of *p will be the same as before calling this function. If the object referenced by *p is replaced, the original *p is destroyed. On failure, returns -1 and sets *p to NULL, and raises MemoryError or SystemError.
-
-int PyTuple_ClearFreeList();
-// Clear the free list. Return the total number of freed items.
-
-// very high level layer ----------------- 
-// int Py_Main(int argc, char **argv);
-// The main program for the standard interpreter. This is made available for programs which embed Python. The argc and argv parameters should be prepared exactly as those which are passed to a C program’s main() function. It is important to note that the argument list may be modified (but the contents of the strings pointed to by the argument list are not). The return value will be the integer passed to the sys.exit() function, 1 if the interpreter exits due to an exception, or 2 if the parameter list does not represent a valid Python command line.
-// 
-// Note that if an otherwise unhandled SystemError is raised, this function will not return 1, but exit the process, as long as Py_InspectFlag is not set.
-
-// int PyRun_AnyFile(FILE *fp, const char *filename);
-// This is a simplified interface to PyRun_AnyFileExFlags() below, leaving closeit set to 0 and flags set to NULL.
-
-// int PyRun_AnyFileFlags(FILE *fp, const char *filename, PyCompilerFlags *flags);
-// This is a simplified interface to PyRun_AnyFileExFlags() below, leaving the closeit argument set to 0.
-
-// int PyRun_AnyFileEx(FILE *fp, const char *filename, int closeit);
-// This is a simplified interface to PyRun_AnyFileExFlags() below, leaving the flags argument set to NULL.
-
-// int PyRun_AnyFileExFlags(FILE *fp, const char *filename, int closeit, PyCompilerFlags *flags);
-// If fp refers to a file associated with an interactive device (console or terminal input or Unix pseudo-terminal), return the value of PyRun_InteractiveLoop(), otherwise return the result of PyRun_SimpleFile(). If filename is NULL, this function uses "???" as the filename.
-
-unit_or_fail PyRun_SimpleString([string] const char *command); // CR jfuruse: We cannot get exception.
-// This is a simplified interface to PyRun_SimpleStringFlags() below, leaving the PyCompilerFlags* argument set to NULL.
-
-// int PyRun_SimpleStringFlags(const char *command, PyCompilerFlags *flags);
-// Executes the Python source code from command in the __main__ module according to the flags argument. If __main__ does not already exist, it is created. Returns 0 on success or -1 if an exception was raised. If there was an error, there is no way to get the exception information. For the meaning of flags, see below.
-// 
-// Note that if an otherwise unhandled SystemError is raised, this function will not return -1, but exit the process, as long as Py_InspectFlag is not set.
-
-// int PyRun_SimpleFile(FILE *fp, const char *filename);
-// This is a simplified interface to PyRun_SimpleFileExFlags() below, leaving closeit set to 0 and flags set to NULL.
-
-// int PyRun_SimpleFileFlags(FILE *fp, const char *filename, PyCompilerFlags *flags);
-// This is a simplified interface to PyRun_SimpleFileExFlags() below, leaving closeit set to 0.
-
-// int PyRun_SimpleFileEx(FILE *fp, const char *filename, int closeit);
-// This is a simplified interface to PyRun_SimpleFileExFlags() below, leaving flags set to NULL.
-
-// int PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit, PyCompilerFlags *flags);
-// Similar to PyRun_SimpleStringFlags(), but the Python source code is read from fp instead of an in-memory string. filename should be the name of the file. If closeit is true, the file is closed before PyRun_SimpleFileExFlags returns.
-
-// int PyRun_InteractiveOne(FILE *fp, const char *filename);
-// This is a simplified interface to PyRun_InteractiveOneFlags() below, leaving flags set to NULL.
-
-// int PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags);
-// Read and execute a single statement from a file associated with an interactive device according to the flags argument. If filename is NULL, "???" is used instead. The user will be prompted using sys.ps1 and sys.ps2. Returns 0 when the input was executed successfully, -1 if there was an exception, or an error code from the errcode.h include file distributed as part of Python if there was a parse error. (Note that errcode.h is not included by Python.h, so must be included specifically if needed.)
-
-// int PyRun_InteractiveLoop(FILE *fp, const char *filename);
-// This is a simplified interface to PyRun_InteractiveLoopFlags() below, leaving flags set to NULL.
-
-// int PyRun_InteractiveLoopFlags(FILE *fp, const char *filename, PyCompilerFlags *flags);
-// Read and execute statements from a file associated with an interactive device until EOF is reached. If filename is NULL, "???" is used instead. The user will be prompted using sys.ps1 and sys.ps2. Returns 0 at EOF.
-
-// struct _node* PyParser_SimpleParseString(const char *str, int start);
-// This is a simplified interface to PyParser_SimpleParseStringFlagsFilename() below, leaving filename set to NULL and flags set to 0.
-
-// struct _node* PyParser_SimpleParseStringFlags(const char *str, int start, int flags);
-// This is a simplified interface to PyParser_SimpleParseStringFlagsFilename() below, leaving filename set to NULL.
-
-// struct _node* PyParser_SimpleParseStringFlagsFilename(const char *str, const char *filename, int start, int flags);
-// Parse Python source code from str using the start token start according to the flags argument. The result can be used to create a code object which can be evaluated efficiently. This is useful if a code fragment must be evaluated many times.
-
-// struct _node* PyParser_SimpleParseFile(FILE *fp, const char *filename, int start);
-// This is a simplified interface to PyParser_SimpleParseFileFlags() below, leaving flags set to 0
-
-// struct _node* PyParser_SimpleParseFileFlags(FILE *fp, const char *filename, int start, int flags);
-// Similar to PyParser_SimpleParseStringFlagsFilename(), but the Python source code is read from fp instead of an in-memory string.
-
-// PyObject* PyRun_String(const char *str, int start, PyObject *globals, PyObject *locals);
-// Return value: New reference.
-// This is a simplified interface to PyRun_StringFlags() below, leaving flags set to NULL.
-
-// PyObject* PyRun_StringFlags([string] const char *str, int start, PyObject *globals, PyObject *locals, PyCompilerFlags *flags);
-// Return value: New reference.
-// Execute Python source code from str in the context specified by the dictionaries globals and locals with the compiler flags specified by flags. The parameter start specifies the start token that should be used to parse the source code.
-//
-// Returns the result of executing the code as a Python object, or NULL if an exception was raised.
-
-// PyObject* PyRun_File(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals);
-// Return value: New reference.
-// This is a simplified interface to PyRun_FileExFlags() below, leaving closeit set to 0 and flags set to NULL.
-
-// PyObject* PyRun_FileEx(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, int closeit);
-// Return value: New reference.
-// This is a simplified interface to PyRun_FileExFlags() below, leaving flags set to NULL.
-
-// PyObject* PyRun_FileFlags(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, PyCompilerFlags *flags);
-// Return value: New reference.
-// This is a simplified interface to PyRun_FileExFlags() below, leaving closeit set to 0.
-
-// aPyObject* PyRun_FileExFlags(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, int closeit, PyCompilerFlags *flags);
-// Return value: New reference.
-// Similar to PyRun_StringFlags(), but the Python source code is read from fp instead of an in-memory string. filename should be the name of the file. If closeit is true, the file is closed before PyRun_FileExFlags() returns.
-
-// PyObject* Py_CompileString(const char *str, const char *filename, int start);
-// Return value: New reference.
-// This is a simplified interface to Py_CompileStringFlags() below, leaving flags set to NULL.
-
-// PyObject* Py_CompileStringFlags(const char *str, const char *filename, int start, PyCompilerFlags *flags);
-// Return value: New reference.
-// Parse and compile the Python source code in str, returning the resulting code object. The start token is given by start; this can be used to constrain the code which can be compiled and should be Py_eval_input, Py_file_input, or Py_single_input. The filename specified by filename is used to construct the code object and may appear in tracebacks or SyntaxError exception messages. This returns NULL if the code cannot be parsed or compiled.
-
-// PyObject* PyEval_EvalCode(PyCodeObject *co, PyObject *globals, PyObject *locals);
-// Return value: New reference.
-// This is a simplified interface to PyEval_EvalCodeEx(), with just the code object, and the dictionaries of global and local variables. The other arguments are set to NULL.
-
-// PyObject* PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, PyObject **args, int argcount, PyObject **kws, int kwcount, PyObject **defs, int defcount, PyObject *closure);
-// Evaluate a precompiled code object, given a particular environment for its evaluation. This environment consists of dictionaries of global and local variables, arrays of arguments, keywords and defaults, and a closure tuple of cells.
-
-// PyObject* PyEval_EvalFrame(PyFrameObject *f);
-// Evaluate an execution frame. This is a simplified interface to PyEval_EvalFrameEx, for backward compatibility.
-
-// PyObject* PyEval_EvalFrameEx(PyFrameObject *f, int throwflag);
-// This is the main, unvarnished function of Python interpretation. It is literally 2000 lines long. The code object associated with the execution frame f is executed, interpreting bytecode and executing calls as needed. The additional throwflag parameter can mostly be ignored - if true, then it causes an exception to immediately be thrown; this is used for the throw() methods of generator objects.
-
-// int PyEval_MergeCompilerFlags(PyCompilerFlags *cf);
-// This function changes the flags of the current evaluation frame, and returns true on success, false on failure.
-
-// int Py_eval_input
-// The start symbol from the Python grammar for isolated expressions; for use with Py_CompileString().
-
-// int Py_file_input
-// The start symbol from the Python grammar for sequences of statements as read from a file or other source; for use with Py_CompileString(). This is the symbol to use when compiling arbitrarily long Python source code.
-
-// int Py_single_input
-// The start symbol from the Python grammar for a single statement; for use with Py_CompileString(). This is the symbol used for the interactive interpreter loop.
-
-// struct PyCompilerFlags
-// This is the structure used to hold compiler flags. In cases where code is only being compiled, it is passed as int flags, and in cases where code is being executed, it is passed as PyCompilerFlags *flags. In this case, from __future__ import can modify flags.
-//
-// Whenever PyCompilerFlags *flags is NULL, cf_flags is treated as equal to 0, and any modification due to from __future__ import is discarded.
-// 
-// struct PyCompilerFlags {
-//     int cf_flags;
-// }
-
-// int CO_FUTURE_DIVISION
-// This bit can be set in flags to cause division operator / to be interpreted as “true division” according to PEP 238.

File automodular.pl

 filter();
 
 sub get_comments {
-    open(IN, "auto.idl.in");
-    while(<IN>){
-	if( /^typedef/ ){ next; }
-	if( /^\s*$/ ){ next; }
-	if( /^\s*\/\// ){ next; }
-	if( /(Py[A-Za-z_0-9]+)\(/ ){
-	    $func_name = $1;
-	    while(<IN>){
-		if( /^\/\/\s*/ ){
-		    $_ = $';
-		    s/\(\*/( */g;
-		    $comment{$func_name} = "$comment{$func_name}$_";
-		} else { last; }
+    for $i (@ARGV){
+	open(IN, "$i");
+	while(<IN>){
+	    if( /^typedef/ ){ next; }
+	    if( /^\s*$/ ){ next; }
+	    if( /^\s*\/\// ){ next; }
+	    if( /(Py[A-Za-z_0-9]+)\(/ ){
+		$func_name = $1;
+		while(<IN>){
+		    if( /^\/\/\s*/ ){
+			$_ = $';
+		        s/\(\*/( */g;
+		        $comment{$func_name} = "$comment{$func_name}$_";
+		    } else { last; }
+                }  
 	    }
 	}
     }
+// --------------------------------- base
+ 
+void Py_Initialize();
+
+void Py_Finalize();
+ 

File bytearray.idl.in

+// -------------------------- Byte array
+
+// PyByteArrayObject;
+//    This subtype of PyObject represents a Python bytearray object.
+
+// PyTypeObject PyByteArray_Type;
+//    This instance of PyTypeObject represents the Python bytearray type; it is the same object as bytearray in the Python layer.
+
+boolean PyByteArray_Check(PyObject *o);
+//    Return true if the object o is a bytearray object or an instance of a subtype of the bytearray type.
+
+boolean PyByteArray_CheckExact(PyObject *o);
+//    Return true if the object o is a bytearray object, but not an instance of a subtype of the bytearray type.
+
+[new] PyObject* PyByteArray_FromObject(PyObject *o);
+//    Return a new bytearray object from any object, o, that implements the buffer protocol.
+
+[new] PyObject* PyByteArray_FromStringAndSize([string] const char *string, Py_ssize_t len);
+//    Create a new bytearray object from string and its length, len. On failure, NULL is returned.
+
+[new] PyObject* PyByteArray_Concat(PyObject *a, PyObject *b);
+//    Concat bytearrays a and b and return a new bytearray with the result.
+
+size_or_fail PyByteArray_Size(PyObject *bytearray);
+//    Return the size of bytearray after checking for a NULL pointer.
+
+[string] char* PyByteArray_AsString(PyObject *bytearray);
+//    Return the contents of bytearray as a char array after checking for a NULL pointer.
+
+unit_or_fail /* ? */ PyByteArray_Resize(PyObject *bytearray, Py_ssize_t len); // return type is int
+//    Resize the internal buffer of bytearray to len.
+
+// These macros trade safety for speed and they don’t check pointers.
+
+[string] char* PyByteArray_AS_STRING(PyObject *bytearray);
+//    Macro version of PyByteArray_AsString().
+
+Py_ssize_t PyByteArray_GET_SIZE(PyObject *bytearray);
+//    Macro version of PyByteArray_Size().
+
+// ------------------ dict
+
+// PyDictObject
+// This subtype of PyObject represents a Python dictionary object.
+// PyTypeObject PyDict_Type
+// This instance of PyTypeObject represents the Python dictionary type. This is exposed to Python programs as dict and types.DictType.
+
+boolean PyDict_Check(PyObject *p);
+// Return true if p is a dict object or an instance of a subtype of the dict type.
+
+boolean PyDict_CheckExact(PyObject *p);
+// aReturn true if p is a dict object, but not an instance of a subtype of the dict type.
+
+[new] PyObject* PyDict_New();
+// Return value: New reference.
+// Return a new empty dictionary, or NULL on failure.
+
+[new] PyObject* PyDictProxy_New(PyObject *dict);
+// Return value: New reference.
+// Return a proxy object for a mapping which enforces read-only behavior. This is normally used to create a proxy to prevent modification of the dictionary for non-dynamic class types.
+
+// No error ?!?!
+void PyDict_Clear(PyObject *p);
+// Empty an existing dictionary of all key-value pairs.
+
+bool_or_fail PyDict_Contains(PyObject *p, PyObject *key);
+// Determine if dictionary p contains key. If an item in p is matches key, return 1, otherwise return 0. On error, return -1. This is equivalent to the Python expression key in p.
+
+[new] PyObject* PyDict_Copy(PyObject *p);
+// Return value: New reference.
+// Return a new dictionary that contains the same key-value pairs as p.
+
+unit_or_fail PyDict_SetItem(PyObject *p, PyObject *key, PyObject *val);
+// Insert value into the dictionary p with a key of key. key must be hashable; if it isn’t, TypeError will be raised. Return 0 on success or -1 on failure.
+
+unit_or_fail PyDict_SetItemString(PyObject *p, [string] const char *key, PyObject *val);
+// Insert value into the dictionary p using key as a key. key should be a char*. The key object is created using PyString_FromString(key). Return 0 on success or -1 on failure.
+
+unit_or_fail PyDict_DelItem(PyObject *p, PyObject *key);
+// Remove the entry in dictionary p with key key. key must be hashable; if it isn’t, TypeError is raised. Return 0 on success or -1 on failure.
+
+int PyDict_DelItemString(PyObject *p, [string] char *key);
+// Remove the entry in dictionary p which has a key specified by the string key. Return 0 on success or -1 on failure.
+
+PyObject* PyDict_GetItem(PyObject *p, PyObject *key);
+// Return value: Borrowed reference.
+// Return the object from dictionary p which has a key key. Return NULL if the key key is not present, but without setting an exception.
+
+PyObject* PyDict_GetItemString(PyObject *p, [string] const char *key);
+// Return value: Borrowed reference.
+// This is the same as PyDict_GetItem(), but key is specified as a char*, rather than a PyObject*.
+
+[new] PyObject* PyDict_Items(PyObject *p);
+// Return value: New reference.
+// Return a PyListObject containing all the items from the dictionary, as in the dictionary method dict.items().
+
+[new] PyObject* PyDict_Keys(PyObject *p);
+// Return value: New reference.
+// Return a PyListObject containing all the keys from the dictionary, as in the dictionary method dict.keys().
+
+[new] PyObject* PyDict_Values(PyObject *p);
+// Return value: New reference.
+// Return a PyListObject containing all the values from the dictionary p, as in the dictionary method dict.values().
+
+size_or_fail PyDict_Size(PyObject *p);
+// Return the number of items in the dictionary. This is equivalent to len(p) on a dictionary.
+
+// int PyDict_Next(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue)
+// Iterate over all key-value pairs in the dictionary p. The Py_ssize_t referred to by ppos must be initialized to 0 prior to the first call to this function to start the iteration; the function returns true for each pair in the dictionary, and false once all pairs have been reported. The parameters pkey and pvalue should either point to PyObject* variables that will be filled in with each key and value, respectively, or may be NULL. Any references returned through them are borrowed. ppos should not be altered during iteration. Its value represents offsets within the internal dictionary structure, and since the structure is sparse, the offsets are not consecutive.
+// 
+// For example:
+// 
+// PyObject *key, *value;
+// Py_ssize_t pos = 0;
+// 
+// while (PyDict_Next(self->dict, &pos, &key, &value)) {
+//     /* do something interesting with the values... */
+//     ...
+// }
+// The dictionary p should not be mutated during iteration. It is safe (since Python 2.1) to modify the values of the keys as you iterate over the dictionary, but only so long as the set of keys does not change. For example:
+// 
+// PyObject *key, *value;
+// Py_ssize_t pos = 0;
+// 
+// while (PyDict_Next(self->dict, &pos, &key, &value)) {
+//     int i = PyInt_AS_LONG(value) + 1;
+//     PyObject *o = PyInt_FromLong(i);
+//     if (o == NULL)
+//         return -1;
+//     if (PyDict_SetItem(self->dict, key, o) < 0) {
+//         Py_DECREF(o);
+//         return -1;
+//     }
+//     Py_DECREF(o);
+// }
+
+unit_or_fail PyDict_Merge(PyObject *a, PyObject *b, boolean override);
+// Iterate over mapping object b adding key-value pairs to dictionary a. b may be a dictionary, or any object supporting PyMapping_Keys() and PyObject_GetItem(). If override is true, existing pairs in a will be replaced if a matching key is found in b, otherwise pairs will only be added if there is not a matching key in a. Return 0 on success or -1 if an exception was raised.
+
+unit_or_fail PyDict_Update(PyObject *a, PyObject *b);
+// This is the same as PyDict_Merge(a, b, 1) in C, or a.update(b) in Python. Return 0 on success or -1 if an exception was raised.
+
+unit_or_fail PyDict_MergeFromSeq2(PyObject *a, PyObject *seq2, boolean override);
+// Update or merge into dictionary a, from the key-value pairs in seq2. seq2 must be an iterable object producing iterable objects of length 2, viewed as key-value pairs. In case of duplicate keys, the last wins if override is true, else the first wins. Return 0 on success or -1 if an exception was raised. Equivalent Python (except for the return value):
+// 
+// def PyDict_MergeFromSeq2(a, seq2, override):
+//     for key, value in seq2:
+//         if override or key not in a:
+//             a[key] = value
+
+// Exceptions
+
+void PyErr_PrintEx(boolean set_sys_last_vars);
+// Print a standard traceback to sys.stderr and clear the error indicator. Call this function only when the error indicator is set. (Otherwise it will cause a fatal error!)
+// If set_sys_last_vars is nonzero, the variables sys.last_type, sys.last_value and sys.last_traceback will be set to the type, value and traceback of the printed exception, respectively.
+
+void PyErr_Print();
+// Alias for PyErr_PrintEx(1).
+
+[option] PyObject* PyErr_Occurred();
+// Return value: Borrowed reference.
+// Test whether the error indicator is set. If set, return the exception type (the first argument to the last call to one of the PyErr_Set*() functions or to PyErr_Restore()). If not set, return NULL. You do not own a reference to the return value, so you do not need to Py_DECREF() it.
+//
+// Note Do not compare the return value to a specific exception; use PyErr_ExceptionMatches() instead, shown below. (The comparison could easily fail since the exception may be an instance instead of a class, in the case of a class exception, or it may the a subclass of the expected exception.)
+
+int PyErr_ExceptionMatches(PyObject *exc);
+// Equivalent to PyErr_GivenExceptionMatches(PyErr_Occurred(), exc). This should only be called when an exception is actually set; a memory access violation will occur if no exception has been raised.;
+
+boolean PyErr_GivenExceptionMatches(PyObject *given, PyObject *exc);
+// Return true if the given exception matches the exception in exc. If exc is a class object, this also returns true when given is an instance of a subclass. If exc is a tuple, all exceptions in the tuple (and recursively in subtuples) are searched for a match.
+
+// void PyErr_NormalizeException(PyObject**exc, PyObject**val, PyObject**tb)
+// Under certain circumstances, the values returned by PyErr_Fetch() below can be “unnormalized”, meaning that *exc is a class object but *val is not an instance of the same class. This function can be used to instantiate the class in that case. If the values are already normalized, nothing happens. The delayed normalization is implemented to improve performance.
+
+void PyErr_Clear();
+// Clear the error indicator. If the error indicator is not set, there is no effect.
+
+// void PyErr_Fetch(PyObject **ptype, PyObject **pvalue, PyObject **ptraceback)
+// Retrieve the error indicator into three variables whose addresses are passed. If the error indicator is not set, set all three variables to NULL. If it is set, it will be cleared and you own a reference to each object retrieved. The value and traceback object may be NULL even when the type object is not.
+// Note This function is normally only used by code that needs to handle exceptions or by code that needs to save and restore the error indicator temporarily.
+
+// void PyErr_Restore(PyObject *type, PyObject *value, PyObject *traceback)
+// Set the error indicator from the three objects. If the error indicator is already set, it is cleared first. If the objects are NULL, the error indicator is cleared. Do not pass a NULL type and non-NULL value or traceback. The exception type should be a class. Do not pass an invalid exception type or value. (Violating these rules will cause subtle problems later.) This call takes away a reference to each object: you must own a reference to each object before the call and after the call you no longer own these references. (If you don’t understand this, don’t use this function. I warned you.)
+// Note This function is normally only used by code that needs to save and restore the error indicator temporarily; use PyErr_Fetch() to save the current exception state.
+
+void PyErr_SetString(PyObject *type, [string] const char *message);
+// This is the most common way to set the error indicator. The first argument specifies the exception type; it is normally one of the standard exceptions, e.g. PyExc_RuntimeError. You need not increment its reference count. The second argument is an error message; it is converted to a string object.
+
+void PyErr_SetObject(PyObject *type, PyObject *value);
+// This function is similar to PyErr_SetString() but lets you specify an arbitrary Python object for the “value” of the exception.
+
+// PyObject* PyErr_Format(PyObject *exception, const char *format, ...)
+// Return value: Always NULL.
+// This function sets the error indicator and returns NULL. exception should be a Python exception (class, not an instance). format should be a string, containing format codes, similar to printf(). The width.precision before a format code is parsed, but the width part is ignored.
+
+void PyErr_SetNone(PyObject *type);
+// This is a shorthand for PyErr_SetObject(type, Py_None).
+
+int PyErr_BadArgument();
+// This is a shorthand for PyErr_SetString(PyExc_TypeError, message), where message indicates that a built-in operation was invoked with an illegal argument. It is mostly for internal use.
+
+// [null] PyObject* PyErr_NoMemory();
+// Return value: Always NULL.
+// This is a shorthand for PyErr_SetNone(PyExc_MemoryError); it returns NULL so an object allocation function can write return PyErr_NoMemory(); when it runs out of memory.
+
+// [null] PyObject* PyErr_SetFromErrno(PyObject *type);
+// Return value: Always NULL.
+// This is a convenience function to raise an exception when a C library function has returned an error and set the C variable errno. It constructs a tuple object whose first item is the integer errno value and whose second item is the corresponding error message (gotten from strerror()), and then calls PyErr_SetObject(type, object). On Unix, when the errno value is EINTR, indicating an interrupted system call, this calls PyErr_CheckSignals(), and if that set the error indicator, leaves it set to that. The function always returns NULL, so a wrapper function around a system call can write return PyErr_SetFromErrno(type); when the system call returns an error.
+
+// [null] PyObject* PyErr_SetFromErrnoWithFilename(PyObject *type, const char *filename)
+// Return value: Always NULL.
+// Similar to PyErr_SetFromErrno(), with the additional behavior that if filename is not NULL, it is passed to the constructor of type as a third parameter. In the case of exceptions such as IOError and OSError, this is used to define the filename attribute of the exception instance.
+
+// [null] PyObject* PyErr_SetFromWindowsErr(int ierr);
+// Return value: Always NULL.
+// This is a convenience function to raise WindowsError. If called with ierr of 0, the error code returned by a call to GetLastError() is used instead. It calls the Win32 function FormatMessage() to retrieve the Windows description of error code given by ierr or GetLastError(), then it constructs a tuple object whose first item is the ierr value and whose second item is the corresponding error message (gotten from FormatMessage()), and then calls PyErr_SetObject(PyExc_WindowsError, object). This function always returns NULL. Availability: Windows.
+
+// [null] PyObject* PyErr_SetExcFromWindowsErr(PyObject *type, int ierr)
+// Return value: Always NULL.
+// Similar to PyErr_SetFromWindowsErr(), with an additional parameter specifying the exception type to be raised. Availability: Windows.
+
+// [null] PyObject* PyErr_SetFromWindowsErrWithFilename(int ierr, [string] const char *filename)
+// Return value: Always NULL.
+// Similar to PyErr_SetFromWindowsErr(), with the additional behavior that if filename is not NULL, it is passed to the constructor of WindowsError as a third parameter. Availability: Windows.
+
+// [null] PyObject* PyErr_SetExcFromWindowsErrWithFilename(PyObject *type, int ierr, char *filename)
+// Return value: Always NULL.
+// Similar to PyErr_SetFromWindowsErrWithFilename(), with an additional parameter specifying the exception type to be raised. Availability: Windows.
+
+void PyErr_BadInternalCall();
+// This is a shorthand for PyErr_SetString(PyExc_SystemError, message), where message indicates that an internal operation (e.g. a Python/C API function) was invoked with an illegal argument. It is mostly for internal use.
+
+// int PyErr_WarnEx(PyObject *category, [string] char *message, int stacklevel);
+// Issue a warning message. The category argument is a warning category (see below) or NULL; the message argument is a message string. stacklevel is a positive number giving a number of stack frames; the warning will be issued from the currently executing line of code in that stack frame. A stacklevel of 1 is the function calling PyErr_WarnEx(), 2 is the function above that, and so forth.
+// This function normally prints a warning message to sys.stderr; however, it is also possible that the user has specified that warnings are to be turned into errors, and in that case this will raise an exception. It is also possible that the function raises an exception because of a problem with the warning machinery (the implementation imports the warnings module to do the heavy lifting). The return value is 0 if no exception is raised, or -1 if an exception is raised. (It is not possible to determine whether a warning message is actually printed, nor what the reason is for the exception; this is intentional.) If an exception is raised, the caller should do its normal exception handling (for example, Py_DECREF() owned references and return an error value).
+// Warning categories must be subclasses of Warning; the default warning category is RuntimeWarning. The standard Python warning categories are available as global variables whose names are PyExc_ followed by the Python exception name. These have the type PyObject*; they are all class objects. Their names are PyExc_Warning, PyExc_UserWarning, PyExc_UnicodeWarning, PyExc_DeprecationWarning, PyExc_SyntaxWarning, PyExc_RuntimeWarning, and PyExc_FutureWarning. PyExc_Warning is a subclass of PyExc_Exception; the other warning categories are subclasses of PyExc_Warning.
+// For information about warning control, see the documentation for the warnings module and the -W option in the command line documentation. There is no C API for warning control.
+
+// int PyErr_Warn(PyObject *category, [string] char *message);
+// Issue a warning message. The category argument is a warning category (see below) or NULL; the message argument is a message string. The warning will appear to be issued from the function calling PyErr_Warn(), equivalent to calling PyErr_WarnEx() with a stacklevel of 1.
+// 
+// Deprecated; use PyErr_WarnEx() instead.
+
+// int PyErr_WarnExplicit(PyObject *category, const char *message, const char *filename, int lineno, const char *module, PyObject *registry)
+// Issue a warning message with explicit control over all warning attributes. This is a straightforward wrapper around the Python function warnings.warn_explicit(), see there for more information. The module and registry arguments may be set to NULL to get the default effect described there.
+
+// int PyErr_WarnPy3k(char *message, int stacklevel)
+// Issue a DeprecationWarning with the given message and stacklevel if the Py_Py3kWarningFlag flag is enabled.
+
+// int PyErr_CheckSignals()
+// This function interacts with Python’s signal handling. It checks whether a signal has been sent to the processes and if so, invokes the corresponding signal handler. If the signal module is supported, this can invoke a signal handler written in Python. In all cases, the default effect for SIGINT is to raise the KeyboardInterrupt exception. If an exception is raised the error indicator is set and the function returns -1; otherwise the function returns 0. The error indicator may or may not be cleared if it was previously set.
+
+// void PyErr_SetInterrupt()
+// aThis function simulates the effect of a SIGINT signal arriving  the next time PyErr_CheckSignals() is called, KeyboardInterrupt will be raised. It may be called without holding the interpreter lock.
+
+// int PySignal_SetWakeupFd(int fd)
+// This utility function specifies a file descriptor to which a '\0' byte will be written whenever a signal is received. It returns the previous such file descriptor. The value -1 disables the feature; this is the initial state. This is equivalent to signal.set_wakeup_fd() in Python, but without any error checking. fd should be a valid file descriptor. The function should only be called from the main thread.
+
+[new] PyObject* PyErr_NewException([string] char *name, PyObject *base, PyObject *dict);
+// Return value: New reference.
+// This utility function creates and returns a new exception object. The name argument must be the name of the new exception, a C string of the form module.class. The base and dict arguments are normally NULL. This creates a class object derived from Exception (accessible in C as PyExc_Exception).
+// The __module__ attribute of the new class is set to the first part (up to the last dot) of the name argument, and the class name is set to the last part (after the last dot). The base argument can be used to specify alternate base classes; it can either be only one class or a tuple of classes. The dict argument can be used to specify a dictionary of class variables and methods.
+
+// [new] PyObject* PyErr_NewExceptionWithDoc([string] char *name, [string] char *doc, PyObject *base, PyObject *dict);
+// Return value: New reference.
+// Same as PyErr_NewException(), except that the new exception class can easily be given a docstring: If doc is non-NULL, it will be used as the docstring for the exception class.
+// New in version 2.7.
+
+void PyErr_WriteUnraisable(PyObject *obj);
+// This utility function prints a warning message to sys.stderr when an exception has been set but it is impossible for the interpreter to actually raise the exception. It is used, for example, when an exception occurs in an __del__() method.
+// The function is called with a single argument obj that identifies the context in which the unraisable exception occurred. The repr of obj will be printed in the warning message.
+
+// Recursion Control
+// These two functions provide a way to perform safe recursive calls at the C level, both in the core and in extension modules. They are needed if the recursive code does not necessarily invoke Python code (which tracks its recursion depth automatically).
+// 
+// int Py_EnterRecursiveCall(char *where)
+// Marks a point where a recursive C-level call is about to be performed.
+// 
+// If USE_STACKCHECK is defined, this function checks if the the OS stack overflowed using PyOS_CheckStack(). In this is the case, it sets a MemoryError and returns a nonzero value.
+// 
+// The function then checks if the recursion limit is reached. If this is the case, a RuntimeError is set and a nonzero value is returned. Otherwise, zero is returned.
+// 
+// where should be a string such as " in instance check" to be concatenated to the RuntimeError message caused by the recursion depth limit.
+// 
+// void Py_LeaveRecursiveCall()
+// Ends a Py_EnterRecursiveCall(). Must be called once for each successful invocation of Py_EnterRecursiveCall().
+// 
+// very high level layer ----------------- 
+// int Py_Main(int argc, char **argv);
+// The main program for the standard interpreter. This is made available for programs which embed Python. The argc and argv parameters should be prepared exactly as those which are passed to a C program’s main() function. It is important to note that the argument list may be modified (but the contents of the strings pointed to by the argument list are not). The return value will be the integer passed to the sys.exit() function, 1 if the interpreter exits due to an exception, or 2 if the parameter list does not represent a valid Python command line.
+// 
+// Note that if an otherwise unhandled SystemError is raised, this function will not return 1, but exit the process, as long as Py_InspectFlag is not set.
+
+// int PyRun_AnyFile(FILE *fp, const char *filename);
+// This is a simplified interface to PyRun_AnyFileExFlags() below, leaving closeit set to 0 and flags set to NULL.
+
+// int PyRun_AnyFileFlags(FILE *fp, const char *filename, PyCompilerFlags *flags);
+// This is a simplified interface to PyRun_AnyFileExFlags() below, leaving the closeit argument set to 0.
+
+// int PyRun_AnyFileEx(FILE *fp, const char *filename, int closeit);
+// This is a simplified interface to PyRun_AnyFileExFlags() below, leaving the flags argument set to NULL.
+
+// int PyRun_AnyFileExFlags(FILE *fp, const char *filename, int closeit, PyCompilerFlags *flags);
+// If fp refers to a file associated with an interactive device (console or terminal input or Unix pseudo-terminal), return the value of PyRun_InteractiveLoop(), otherwise return the result of PyRun_SimpleFile(). If filename is NULL, this function uses "???" as the filename.
+
+unit_or_fail PyRun_SimpleString([string] const char *command); // CR jfuruse: We cannot get exception.
+// This is a simplified interface to PyRun_SimpleStringFlags() below, leaving the PyCompilerFlags* argument set to NULL.
+
+// int PyRun_SimpleStringFlags(const char *command, PyCompilerFlags *flags);
+// Executes the Python source code from command in the __main__ module according to the flags argument. If __main__ does not already exist, it is created. Returns 0 on success or -1 if an exception was raised. If there was an error, there is no way to get the exception information. For the meaning of flags, see below.
+// 
+// Note that if an otherwise unhandled SystemError is raised, this function will not return -1, but exit the process, as long as Py_InspectFlag is not set.
+
+// int PyRun_SimpleFile(FILE *fp, const char *filename);
+// This is a simplified interface to PyRun_SimpleFileExFlags() below, leaving closeit set to 0 and flags set to NULL.
+
+// int PyRun_SimpleFileFlags(FILE *fp, const char *filename, PyCompilerFlags *flags);
+// This is a simplified interface to PyRun_SimpleFileExFlags() below, leaving closeit set to 0.
+
+// int PyRun_SimpleFileEx(FILE *fp, const char *filename, int closeit);
+// This is a simplified interface to PyRun_SimpleFileExFlags() below, leaving flags set to NULL.
+
+// int PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit, PyCompilerFlags *flags);
+// Similar to PyRun_SimpleStringFlags(), but the Python source code is read from fp instead of an in-memory string. filename should be the name of the file. If closeit is true, the file is closed before PyRun_SimpleFileExFlags returns.
+
+// int PyRun_InteractiveOne(FILE *fp, const char *filename);
+// This is a simplified interface to PyRun_InteractiveOneFlags() below, leaving flags set to NULL.
+
+// int PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags);
+// Read and execute a single statement from a file associated with an interactive device according to the flags argument. If filename is NULL, "???" is used instead. The user will be prompted using sys.ps1 and sys.ps2. Returns 0 when the input was executed successfully, -1 if there was an exception, or an error code from the errcode.h include file distributed as part of Python if there was a parse error. (Note that errcode.h is not included by Python.h, so must be included specifically if needed.)
+
+// int PyRun_InteractiveLoop(FILE *fp, const char *filename);
+// This is a simplified interface to PyRun_InteractiveLoopFlags() below, leaving flags set to NULL.
+
+// int PyRun_InteractiveLoopFlags(FILE *fp, const char *filename, PyCompilerFlags *flags);
+// Read and execute statements from a file associated with an interactive device until EOF is reached. If filename is NULL, "???" is used instead. The user will be prompted using sys.ps1 and sys.ps2. Returns 0 at EOF.
+
+// struct _node* PyParser_SimpleParseString(const char *str, int start);
+// This is a simplified interface to PyParser_SimpleParseStringFlagsFilename() below, leaving filename set to NULL and flags set to 0.
+
+// struct _node* PyParser_SimpleParseStringFlags(const char *str, int start, int flags);
+// This is a simplified interface to PyParser_SimpleParseStringFlagsFilename() below, leaving filename set to NULL.
+
+// struct _node* PyParser_SimpleParseStringFlagsFilename(const char *str, const char *filename, int start, int flags);
+// Parse Python source code from str using the start token start according to the flags argument. The result can be used to create a code object which can be evaluated efficiently. This is useful if a code fragment must be evaluated many times.
+
+// struct _node* PyParser_SimpleParseFile(FILE *fp, const char *filename, int start);
+// This is a simplified interface to PyParser_SimpleParseFileFlags() below, leaving flags set to 0
+
+// struct _node* PyParser_SimpleParseFileFlags(FILE *fp, const char *filename, int start, int flags);
+// Similar to PyParser_SimpleParseStringFlagsFilename(), but the Python source code is read from fp instead of an in-memory string.
+
+// PyObject* PyRun_String(const char *str, int start, PyObject *globals, PyObject *locals);
+// Return value: New reference.
+// This is a simplified interface to PyRun_StringFlags() below, leaving flags set to NULL.
+
+// PyObject* PyRun_StringFlags([string] const char *str, int start, PyObject *globals, PyObject *locals, PyCompilerFlags *flags);
+// Return value: New reference.
+// Execute Python source code from str in the context specified by the dictionaries globals and locals with the compiler flags specified by flags. The parameter start specifies the start token that should be used to parse the source code.
+//
+// Returns the result of executing the code as a Python object, or NULL if an exception was raised.
+
+// PyObject* PyRun_File(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals);
+// Return value: New reference.
+// This is a simplified interface to PyRun_FileExFlags() below, leaving closeit set to 0 and flags set to NULL.
+
+// PyObject* PyRun_FileEx(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, int closeit);
+// Return value: New reference.
+// This is a simplified interface to PyRun_FileExFlags() below, leaving flags set to NULL.
+
+// PyObject* PyRun_FileFlags(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, PyCompilerFlags *flags);
+// Return value: New reference.
+// This is a simplified interface to PyRun_FileExFlags() below, leaving closeit set to 0.
+
+// aPyObject* PyRun_FileExFlags(FILE *fp, const char *filename, int start, PyObject *globals, PyObject *locals, int closeit, PyCompilerFlags *flags);
+// Return value: New reference.
+// Similar to PyRun_StringFlags(), but the Python source code is read from fp instead of an in-memory string. filename should be the name of the file. If closeit is true, the file is closed before PyRun_FileExFlags() returns.
+
+// PyObject* Py_CompileString(const char *str, const char *filename, int start);
+// Return value: New reference.
+// This is a simplified interface to Py_CompileStringFlags() below, leaving flags set to NULL.
+
+// PyObject* Py_CompileStringFlags(const char *str, const char *filename, int start, PyCompilerFlags *flags);
+// Return value: New reference.
+// Parse and compile the Python source code in str, returning the resulting code object. The start token is given by start; this can be used to constrain the code which can be compiled and should be Py_eval_input, Py_file_input, or Py_single_input. The filename specified by filename is used to construct the code object and may appear in tracebacks or SyntaxError exception messages. This returns NULL if the code cannot be parsed or compiled.
+
+// PyObject* PyEval_EvalCode(PyCodeObject *co, PyObject *globals, PyObject *locals);
+// Return value: New reference.
+// This is a simplified interface to PyEval_EvalCodeEx(), with just the code object, and the dictionaries of global and local variables. The other arguments are set to NULL.
+
+// PyObject* PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, PyObject **args, int argcount, PyObject **kws, int kwcount, PyObject **defs, int defcount, PyObject *closure);
+// Evaluate a precompiled code object, given a particular environment for its evaluation. This environment consists of dictionaries of global and local variables, arrays of arguments, keywords and defaults, and a closure tuple of cells.
+
+// PyObject* PyEval_EvalFrame(PyFrameObject *f);
+// Evaluate an execution frame. This is a simplified interface to PyEval_EvalFrameEx, for backward compatibility.
+
+// PyObject* PyEval_EvalFrameEx(PyFrameObject *f, int throwflag);
+// This is the main, unvarnished function of Python interpretation. It is literally 2000 lines long. The code object associated with the execution frame f is executed, interpreting bytecode and executing calls as needed. The additional throwflag parameter can mostly be ignored - if true, then it causes an exception to immediately be thrown; this is used for the throw() methods of generator objects.
+
+// int PyEval_MergeCompilerFlags(PyCompilerFlags *cf);
+// This function changes the flags of the current evaluation frame, and returns true on success, false on failure.
+
+// int Py_eval_input
+// The start symbol from the Python grammar for isolated expressions; for use with Py_CompileString().
+
+// int Py_file_input
+// The start symbol from the Python grammar for sequences of statements as read from a file or other source; for use with Py_CompileString(). This is the symbol to use when compiling arbitrarily long Python source code.
+
+// int Py_single_input
+// The start symbol from the Python grammar for a single statement; for use with Py_CompileString(). This is the symbol used for the interactive interpreter loop.
+
+// struct PyCompilerFlags
+// This is the structure used to hold compiler flags. In cases where code is only being compiled, it is passed as int flags, and in cases where code is being executed, it is passed as PyCompilerFlags *flags. In this case, from __future__ import can modify flags.
+//
+// Whenever PyCompilerFlags *flags is NULL, cf_flags is treated as equal to 0, and any modification due to from __future__ import is discarded.
+// 
+// struct PyCompilerFlags {
+//     int cf_flags;
+// }
+
+// int CO_FUTURE_DIVISION
+// This bit can be set in flags to cause division operator / to be interpreted as “true division” according to PEP 238.

File import.idl.in

+// ------------------ Importing modules
+
+[new] PyObject* PyImport_ImportModule([string] const char  *name);
+//    Return value: New reference.
+//    This is a simplified interface to PyImport_ImportModuleEx() below, leaving the globals and locals arguments set to NULL and level set to 0. When the name argument contains a dot (when it specifies a submodule of a package), the fromlist argument is set to the list ['*'] so that the return value is the named module rather than the top-level package containing it as would otherwise be the case. (Unfortunately, this has an additional side effect when name in fact specifies a subpackage instead of a submodule: the submodules specified in the package’s __all__ variable are loaded.) Return a new reference to the imported module, or NULL with an exception set on failure. Before Python 2.4, the module may still be created in the failure case — examine sys.modules to find out. Starting with Python 2.4, a failing import of a module no longer leaves the module in sys.modules.