[pygtk] Bind pointers in codegen?

ha shao hashao@hashao.hypermart.net
Sat, 12 Oct 2002 10:51:15 +0800

It seem that most simple pointers (int*, ulong*, etc) are 
not wrapped in codegen's argtypes.py. But there are quite 
a few functions use pointer type as parameters. Most of
these functions cannot be wrapped without hand-code.

Since python does not pass value by reference in most cases,
the wrapper should return the pointers inside a tuple. This
can be done like this:

 For type without a wrapper, check if it is a pointer to a known

 For write_return, it should append a tuple of 
    (code_to_write, PyObject_name) to the return list.

 For pointer to a known type, use the correspond type's write_param.
    but also do a write_return for the pointer.

 When handling return value, write the codes in return list
    first. Then construct the return PyObject into a tuple and return
    it. Except if only one item in the return list, then just return 
    the PyObject directly.

If the write_return and write_param for non-pointer type cannot 
be reused, the above procedure can still be used to wrap pointer
types individually.

I counted about 128 function not wrapped due to unknow pointer types.
Another 27 function due to mostly callback function type which is
another story. 

parameters should have a property for callback. If the parameter is a
callback, a callable check on the parameter will be performed. check on
its signiture can also be performed if the callback type is set. Then we
don't have to wrap individual functions with callback parameter.


Best regard