Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SWIG bindings for
user_cb_data
in repo::DownloadCallbacks
In the C++ API, the user can return a pointer (void *) to user data in the `add_new_download` method of the `repo::DownlodCallbacks` class. This pointer is then passed as an argument to `void * user_cb_data` in other methods of the `repo::DownloadCallbacks` class. There was a problem of how to use this mechanism in SWIG bindings. I implemented and tested several solutions. In the case of passing a pointer, there was a problem with the ownership of the data the pointer points to. Users of Python and some other languages are used to the gargabe collector and automatically holding ownership of the passed data. While I've solved this for `user_cb_data`, passing another void pointer will need to be solved (I'll do that later). And from there, the ownership will be more complicated. We need the solution to work reliably in Python, Ruby and Perl. And possibly be easy to use for other languages in the future. In the end, I chose the method of passing an integer instead of a pointer. When passing an integer, there is no need to deal with who owns the number. The integer is passed by value. And if the user needs to pass objects, for example, he can create an array of objects and pass the index (integer) to the array. The array also provides ownership of the objects.
- Loading branch information