Closed kamahen closed 1 year ago
I think an abstraction of blobs used as pointers is very useful. In C++ it can probably be done quite easily. In C it is a bit harder, though the ffi
pack contains some abstractions.
I wasn't thinking of providing a "smart pointer" for blobs, just a light wrapper around PL_blob_t
and related things like PL_blob_data
. Smart pointers would require me trying to remember how to write C++ templates, and smart pointers can be fairly tricky to get right.
I'll take a look at pack(ffi), but from a quick look at it, it seems to be more functionality than I want to provide right now.
Yes, pack(ffi) does too much. Something that would create a named blob and has virtual methods to deal with the blob hook functions in a nice C++ way would be great.
Keep up the great work, guys! Please don't hesitate wo tag me (@jan) if you have any further questions.
Commit 7c351d5334292e09022cadaf82d9a6c00c2c846d added a PlBlob
class that can be subclassed, for easy creation of blobs using C++.
Currently, the only way to store an arbitrary vaule is using the PL_put_pointer/PL_get_pointer interface. This leads to weird stuff:
which also shows that this is dangerous because the deleted object can still be accessed (but returning an incorrect value).
The implementation of PlBlob should be an abstract class that requires defining the "release" and "compare" methods, with a default implementation of "write".
@jan - please assign this to me.