[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

DL usage

Stephan Kämper

3/28/2005 11:25:00 AM

Hi all,

when using DL to generate some code to access dynamic library functions,
I noticed that it doesn't find a symbol, if the given prototype has a
space character just before the right parenthesis (or right after the
left parenthesis).

int DocumentGetErrorNumber(extHandle )
C:/ruby/lib/ruby/1.8/dl/import.rb:125:in `symbol': can't find the symbol
`DocumentGetErrorNumber' (RuntimeError)
from C:/ruby/lib/ruby/1.8/dl/import.rb:144:in `import'
from C:/ruby/lib/ruby/1.8/dl/import.rb:61:in `extern'

After changing the prototype to

int DocumentGetErrorNumber(extHandle)

everything's fine.

Although is just a little bit inconvenient (I just applied 'strip' to
the argument list of the prototype), I wonder if it's possible to make
DL even more helpful, by changing this behaviour?

For example changing line 41 of 'dl/import.rb' to

args = $2.strip

would that. Is that an ugly hack? I don't know. Perhaps tweaking the
regular expression would be more elegant.
Of course, I don't dare to make a prediction about breaking other code
by doing this. But then, if the white space isn't stripped, the
prototype isn't going to work anyway. On the other hand, the way it is
may be intended behaviour...

Happy rubying

Stephan