Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #18110

ctypes argument by reference

Date 2011-12-28 08:58 +0100
From bouleetbil (gaetan) <bouleetbil@gmail.com>
Subject ctypes argument by reference
Newsgroups comp.lang.python
Message-ID <mailman.4177.1325060929.27778.python-list@python.org> (permalink)

Show all headers | View raw


Hi
I try to write a python backend for pamcan-g2, for that I should write a callback for *trans_cb_conv

In python I've write :
trans_cb_event = CFUNCTYPE(ctypes.c_char_p,ctypes.c_void_p,POINTER(ctypes.c_int)
...
def fpm_trans_conv(event,pkg,response):
    foo...
    response=1
and for call the callback
if trans_init(pm_trans,flags, trans_cb_event(fpm_progress_event), trans_cb_conv(fpm_trans_conv), None) == -1 :
    foo...

Into libpacman response is a C int pointer :
...
QUESTION(trans, PM_TRANS_CONV_LOCAL_UPTODATE, local, NULL, NULL, &resp);
...

but resp=0 howto pass response by reference instead by value ?

If you would more informations/code :
the .h is here : http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=blob_plain;f=lib/libpacman/pacman.h;hb=HEAD
the python code here : http://git.frugalware.org/gitweb/gitweb.cgi?p=frugal-tweak.git;a=blob_plain;f=py-pacman/py-pacman.py;hb=4abed4ee445f009387a3a51957e231c010c123bb

trans_cb_event line 315
fpm_trans_conv line 676
pacman_trans_init callback 708

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

ctypes argument by reference bouleetbil (gaetan) <bouleetbil@gmail.com> - 2011-12-28 08:58 +0100

csiph-web