Ctypes update: pretty objects
Since my last couple of posts, things have been done:
Crap... when you list it like that, sounds pretty dire…
Since my last couple of posts, things have been done:
Crap... when you list it like that, sounds pretty dire…
I've been meaning to write this post for a while. I'd like your opinion on it.
…For the past few days I've been considering and experimenting with the design of simple Ctypes::Type objects. These are objects which, funnily enough, represent C data types for manipulation in Perl.
Looking at the Python ctypes module, there were various things I didn't like. Python's simple types [0] can be summarized thusly:
>>> i = c_int(42) >>> print i c_long(42) >>> print i.value 42 >>> i.value = -99 >>> print i.value -99 >>>
The week has been frustrating, funny, yet ultimately fruitful.
I had callbacks to Perl almost working at the start of the week, but couldn't seem to get variables updated 'in place'. The example function I was using to test callbacks, the C standard qsort
, takes as its arguments a pointer to an array, the number of items in the array, the size in bytes of one item, and a reference to a function which will be passed two items from the array at a time and decide how to sort them. It returns void, and the …
July already - where has the time gone? Oh wait, Twitter can tell me.
In the wake of my last blog post, rurban told me Magic was more of a 'last resort', and that everything necessary for making type objects could be done with perl's pack and unpack functions, which precipitated a day or two experimenting and trying to get …