From: Christer Sandberg Date: 2006-09-23T05:21:23+09:00 Subject: Re: Creating a reference to a ruby variable in a C extension Vincent Fourmond wrote: > Hello ! > >> The issue with self not being available was that I was calling yyparse() >> and hadn't configured bison so that yyparse was given any parameters, >> hence self wasn't available in the parser code. I didn't destroy it just >> couldn't reach it. Now I have taken a different aproach. yyparse is >> called with a parameter and instead of passing the callback instance as >> a parameter to initialize I have made it a class/module method instead, >> since the only task for my extension is to delegate the parsing routine. > > Yes, bison and flex always give great fun. Just out of curiosity, what > are you parsing ? > >> Thanks again, though, for opening my eyes. There's been a long time >> since I wrote some C code and I didn't think about this. > > I did bump into this not so long ago... I'd rather you didn't ;-) ! > > Vince Hi again, Vince! Maybe I'm well deep over my head here, but my goal is to modify/customize the CSS parser/lexer used by KDE and Apple (in Safari) and wrap it up as a Ruby extension. My first thing on the TODO list is making an implementation of the SAC API, and then move on to make a DOM implementation built upon the SAC API. My extension is calling back to a document handler SAC implementation which I will make as a module to be able to override only the methods interesting if one might want to make a customized handling or implementation. Actually, this idea came to my mind when thinking about doing a Ruby Markdown to PDF conversion utility. Then I thought that one should be able to customize the fonts, colors etc, and since Markdown converts to XHTML and CSS can be used to style that... Well, you get the point. Cheers, Christer -- Posted via http://www.ruby-forum.com/.