On 8/12/06, Greg Ewing <[EMAIL PROTECTED]> wrote:
> Tim Peters wrote:
>
> > It's unclear to me how to write portable ctypes code in the presence
> > of a gazillion integer typedefs and #defines, such as for Py_ssize_t.
>
> A start would be to have constants in the ctypes module
> for Py_ssize_t and other such Python-defined API types.

rctypes and pypy tools are somewhat one step further than ctypes
machinery. In rctypes you can easily do something like:

size_t = ctypes_platform.SimpleType("size_t", c_ulong)

In this way you have platform safe data type to use in your code. The
second argument of SimpleType() is a hint for the tool.

You can also use ConstantInteger() and DefinedCostantInteger() to get
values of costants in headers file like this:

BUFSIZ = ctypes_platform.ConstantInteger("BUFSIZ")

Maybe one day this can be ported to CPython ctypes from the RPython one.

-- 
Lawrence
http://www.oluyede.org/blog
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to