[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Audit Parsing Library Requirements

Steve Grubb <sgrubb redhat com> writes:

> I'll take a hack at proposing an API and send it in a little while.


I looked at both the SWIG and Python/C API, and then realized that I
sit just two doors down from Sam Bayer.  He has made extensive use of
these tools, and here is what I learned from talking with him.

(1) Even if you plan to only support Python as the scripting language,
    use SWIG to generate as much of the interface as you can, because
    it automatically generates a lot of Python/C API code for you.

(2) Even if you plan to specify your interfaces only in SWIG, become
    familiar with the Python/C API so you can read the generated
    code.  Sam found important errors by carefully reading generated
    code.  Memory management issues become obvious by reading the code.

(3) It is very simple to use SWIG if the only objects that are passed
    across the language boundary are numbers, strings, and opaque

(4) Sam avoided passing structures, preferring to define classes in
    pure Python code, and using a function interface to implement
    methods of the class.  The SWIG document suggests structures can
    be used, and appear as a class in Python.  I think Sam likes the
    idea of a thin interface, and passing a structure is too
    heavy-weight for his tastes.

(5) One can pass functions in both directions, and Sam described all
    the details to me that is involved with passing and invoking a
    Python function in C.  In this case, one cannot use SWIG.  My
    reading is Steve is unlikely to define an interface that passes
    either C or Python functions, so these difficulties can be

So read the SWIG 1.3 Basics Chapter, and then flip to the chapter on
Python, and along with the Python/C API document, you should be able
access the information you need.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]