|
From: Luiz A. D. de L. <lui...@gm...> - 2011-06-01 05:09:51
|
Now my real problem :-)
---
Luiz Angelo Daros de Luca, Me.
lui...@gm...
2011/5/27 Chris Frey <cd...@fo...>
> On Fri, May 27, 2011 at 01:24:28AM -0300, Luiz Angelo Daros de Luca wrote:
> > Hello Chris,
> >
> > I hope that, if you see my code, it didn't scary you. :-)
> > I have finished the plugin implementation part and I also almost
> > finished the ruby-file-sync example. However, I cannot finish the
> > plugin without a format implementation.
> >
> > Here comes my problem: formats have no data. There is no
> > osync_objformat_set_data. I implemented it using the
> > same strategy that I used to workarround the missing
> > osync_objtype_sink_get_userdata. It was all ok until I started to
> > implement the first objformat callback router method. All format
> > callbacks do not have an OSyncObjFormat argument, as
> > plugin and objettype sink callbacks have OSyncPlugin and
> > OSyncObjTypeSink. The only way to define data is by returning some
> > pointer from initialization function.
>
> Yeah, I see how that could be a problem for a wrapper.
>
> I'm guessing a bit here, but I believe that implementing the objformat
> userdata that way means that the objformat names can be known, while
> not using much memory. If any objformat is needed during the sync,
> then it could be initialized on the fly.
>
> If all objformats had to be initialized at the beginning, and only
> two were needed, it would be a waste.
>
Maybe we are talking about different things. :-) The objformat is already
avaiable to who askes for it.
My suggestion is to do something like these:
char *osync_objformat_print(OSyncObjFormat *format, const char *data,
unsigned int size, OSyncError **error) {
(...)
+ return format->print_func(data, size, format->user_data, error);
- return format->print_func(format, data, size, format->user_data,
error);
}
And so on for all callbacks. plugin and sink does just like this. My ruby
wrapper can implement multiple objformats (and plugins) and I have, for each
callback type, only one C callback for all ruby objects. If I have
the format inside the callback, I can look for the ruby callback defined for
this format.
> Is it possible to make use of this in ruby? i.e. only initialize
> things when asked for? The only key you can use would be the objformat
> name, but that does not change once created.
>
Sure, I can initialize a plugin, register it and so on. I even call ref when
I receive some argument and call unref when GC cleans it.
It is not a problem for me.
>
> - Chris
>
>
>
> ------------------------------------------------------------------------------
> vRanger cuts backup time in half-while increasing security.
> With the market-leading solution for virtual backup and recovery,
> you get blazing-fast, flexible, and affordable data protection.
> Download your free trial now.
> http://p.sf.net/sfu/quest-d2dcopy1
> _______________________________________________
> Opensync-devel mailing list
> Ope...@li...
> https://lists.sourceforge.net/lists/listinfo/opensync-devel
>
|