|
From: Chris F. <cd...@fo...> - 2011-05-23 19:29:44
|
On Mon, May 23, 2011 at 11:26:55AM -0300, Luiz Angelo Daros de Luca wrote:
> Class Info
> def objtype_sinks
> Opensync::osync_objtype_sink_get_objtype_sinks(@_self).collect
> {|_sink| Sink.for(_sink) }
> end
> end
>
> It is a little different approach from what I saw in python-module plugin.
> All logic is inside ruby world and C code is just for wrapping.
Thanks for the explanation and code. Please keep in mind that I didn't
make the original change in opensync to make the _get_ function that you
need internal, so I want to make sure I understand all the reasons before
I change it. It's easy to change, but maybe there's a reason behind
it that is useful. I'm trying to maintain opensync, but I didn't write
most of it. :-)
As you say, less code, less bugs... that goes for the library side too. :-)
The userdata is basically application data, and it is assumed that the
application will keep track of it, and free it, etc.
So, I hope this is my last question. :-) If you just get a list
of objtype_sinks with the code above, then when you need to register
a callback, how do you know which sink to use?
I don't see where you're connecting the sink and the callback in your
code. And if you have a list of sinks already, maybe it would be wise
to store your userdata along with it?
i.e. If you have a Sink object that contains your sink pointer, and
the ruby programmer asks to register a callback via some Sink object
method, why wouldn't the userdata be stored in Sink itself?
I'm leaning toward exposing osync_objtype_sink_get_userdata() anyway,
I just want to fully understand the change.
> Sorry, I guess I wasn't clear. I just asked why the name of
> osync_objtype_sink_set_userdata is this and not osync_objtype_sink_set_data
> like in osync_plugin_set_data. I was worried that
> osync_objtype_sink_set_userdata might
> be designed to store something other than a pointer for plugin developer own
> use. If it is just like what osync_plugin_set_data is for plugins but for
> sinks, I'm fine.
Yep, both are just void* pointers that opensync stores for the app's use.
Maybe a rename is in order before 0.40. :-)
Thanks,
- Chris
|