c_void_p arguments in callbacks using ctypes in Python -
I am a frequent user of CTIPs, but I have to face the things I can not understand.
First of all, when I define a callback with c_void_p, callback will get an integer.
I have seen some other posts that wrap c_void_p by wrapping it in second digit when it returns the c_void_p return value. So, I thought I could try it for reasoning in callback definition: POINTER (c_void_p) When called callback, now I get a pointer, but I still do not know that this value indicates data is.
Since C_void_p indicates the buffer with the binary data, I do not believe that I can use a c_char_p I put the array without any realization, whose length is passed to me But then Python tells me that I have a tupe, and there is no "content" or "value" property which I can use.
Suggestion
In the callback, as an integer, Say that you have an integer address in He said, knowing that I define callback to use the * c_void_p is normal. It's using simple type of
getfunc to auto conversion - the same as receiving a
c_void_p as the
structure field . CTIP will not automatically transition for a simple type of subclass - e.g.
Type ('my_void_p', (c_void_p,), {}) . Although I do not think there is a case in this matter.
p . You can * it by using
c_char one of the length of the line
n :
Buf = cast (p, pointer (c_char * n)) [0] # 2.6+ buf = (c_char * n) .from_address (p)
four * , I use
POINTER (c_char) . Then access the buffer with an index or a piece, e.g.
P [0] or
P [: n] .
p [n] is equal to
* (p + n) , where
* The operator is operator and also using the pointer arithmetic based on the size of the director. You can use
p [0] instead of
p.contents , but call the same type
getfunc converter, if applicable.
Comments
Post a Comment