On 8/17/07, unbewust <yvon.thoraval / gmail.com> wrote:
> On 17 ao?t, 11:16, Eric Hodel <drbr... / segment7.net> wrote:
>
> >
> > > but how to retrieve them ???
> >
> > Use rb_hash_aset and rb_hash_aref from hash.c.  Jump down to the
> > Init_Hash() to get a list of what you can do.
>
>
> it's OK now for hash keys being strings NOT symbol, i did'nt found a
> way to produce a Ruby symbol (as :verbose) from C.
>
> thought i've seen ID2SYM and SYM2ID in ruby.h
>
>
> also not all of the rb_xxx methods found in hash.c are working from C,
> surprisingly ????
>

If any of the methods in hash.c are preceded by the keyword "static",
then they cannot be called from outside the hash.c file.


> for example :
>
> ~/work/C/Cext2Ruby/SYMBOL_TEST/ext%> ruby sample.rb
> dyld: NSLinkModule() error
> dyld: Symbol not found: _rb_hash_keys
>   Referenced from: ./symbol_test.bundle
>   Expected in: flat namespace
>

VALUE keys = rb_funcall( hash, rb_intern( "keys" ), 0 );

> ~/work/C/Cext2Ruby/SYMBOL_TEST/ext%> ruby sample.rb
> dyld: NSLinkModule() error
> dyld: Symbol not found: _rb_hash_size
>   Referenced from: ./symbol_test.bundle
>   Expected in: flat namespace
>

long size = RHASH(hash)->tbl->num_entries;


Blessings,
TwP