From: Andrew S. T. <as...@at...> - 2008-10-18 16:47:09
|
On Sun, 2008-10-19 at 00:09 +0900, Kouhei Sutou wrote: > > I wrote a reply for that: > > In <200...@co...> > "Re: [ruby-gnome2-devel-en] Additional info Re: Hopefully trivial question regarding UIManager & Menu items" on Sat, 18 Oct 2008 15:29:57 +0900 (JST), > Kouhei Sutou <ko...@co...> wrote: > > > You can get it as RD format: > > % svn co https://ruby-gnome2.svn.sourceforge.net/svnroot/ruby-gnome2/doc/trunk > > > > You can see it by rbbr: > > http://ruby-gnome2.sourceforge.jp/hiki.cgi?rbbr > > > > Put RD formatted documentation to rbbr's data > > dir. (e.g. /usr/share/rbbr/rd/, /usr/local/share/rbbr/rd/ > > and so on) Sorry, Kouhei. I got the replies out of order. Cheers, and thanks for the fix! > > If this isn't clear, it looks something like this: > > > > factory = factory_class_new(); > > sstruct = factory_class_create_struct(factory); > > > > To clean things up, you're supposed to do: > > > > struct_class_destroy(sstruct); > > > > Any suggestions? > > I'm sorry but I couldn't understand. Could you show me an > example code that is executable? I guess the simplest example is here: http://svn.gnome.org/viewvc/gtkhtml/trunk/gtkhtml/test.c?annotate=8858 On line 121, the GtkHTMLStream is created through the call to gtk_html_begin(). On line 79 or 82, the GtkHTMLStream is closed via the call to gtk_html_stream_close(). I don't claim that it's pretty (or even correct), but you can see what I'm doing either via http://www.atownley.org/projects/ruby-gtkhtml3/bzr/2008-10-18T17:24:47+0100/src/rbgtkhtmlstream.c http://www.atownley.org/projects/ruby-gtkhtml3/bzr/2008-10-18T17:24:47+0100/src/rbgtkhtml.c or via bzr pull http://www.atownley.org/projects/ruby-gtkhtml3/bzr/2008-10-18T17:24:47+0100 and looking at the src/rbgthkthmlstream.c and rbgtkhtml.c files. Like I said, this was the only approach that I could come up with that didn't result in segfaults. However, I'm interested in how to do it more cleanly. The "interesting" functions are: in rbgtkhtml.c: static VALUE rb_gtk_html_stream_obj_from_struct(stream) GtkHTMLStream *stream; { VALUE rval; GtkHTMLStream *rval_stream = NULL; printf("creating stream object\n"); rval = rb_eval_string("Gtk::Html::Stream.new"); Data_Get_Struct(rval, GtkHTMLStream, rval_stream); MEMCPY(rval_stream, stream, GtkHTMLStream, 1); return rval; } in rbgtkhtmlstream.c: static void rb_gtk_html_stream_free(stream) GtkHTMLStream *stream; { // FIXME: How do we tell if we've already been destroyed? // printf("destroying stream: %p\n", stream); // gtk_html_stream_destroy(stream); } static VALUE rb_gtk_html_stream_alloc(klass) VALUE klass; { VALUE obj; GtkHTMLStream *stream = NULL; stream = gtk_html_stream_new(NULL, NULL, NULL, NULL, NULL); printf("created stream: %p\n", stream); obj = Data_Wrap_Struct(klass, NULL, rb_gtk_html_stream_free, stream); return obj; } Is this enough to go on? It really needs to be fixed because each time you request a separate resource from within a given HTML document, the stream_from_struct function is called. It was the only way I could come up with to get the block parameter marshalling to work, but I'm positive that the original structure is leaking somewhere. I also had to remove the rb_gtk_html_stream_free functionality because the stream is destroyed within the gtk_html_stream_close call, but I don't have any way to tell if there aren't streams created that aren't closed. With the code uncommented, the stream was getting freed twice. Any suggestions/advice would be appreciated. > > One more question that I probably also missed in the docs on the Hiki: > > is there a recommended mechanism for producing the class/method > > documentation? I can add the RDoc to the C source, but it doesn't seem > > like that's how the rest of the library works. > > I'm using update-rd.rb to generate template and update > documents: > https://ruby-gnome2.svn.sourceforge.net/svnroot/ruby-gnome2/doc/trunk/update-rd.rb I'll have a look at that. Thanks for the pointer. Cheers, ast -- Andrew S. Townley <as...@at...> http://atownley.org |