Subject: Re: Accessing hash key values in ruby from c extension
	Date: ven 07 mar 14 08:44:59 +0100

Quoting Vitesh Jaiswal (lists / ruby-forum.com):

> /***On C side****/
> VALUE func (VALUE self, VALUE obj)
> {
>        /***SAY if self corresponds to object of class AA***/
>        VALUE test  = rb_iv_get(self, "@Anchor");
>        ID    id    = rb_intern("anchorAA");
>        VALUE test1 = rb_hash_aref(test, ID2SYM(id));
> 
> }
> 
> Is the above correct Carlo?

"@Anchor" means nothing. Anchor is a class constant, not an instance
variable. 

The function to access class constants from C is rb_const_get. Search
for examples in the same way.

I personally never needed to access ruby class constants from C. I try
to make as neat a separation between the two worlds as possible. I use
C only when I need raw speed, or when I have to access C libraries. 

If I were you, I'd pass all info I need to transfer from Ruby to C as
separate parameters. It is nifty to be ruby=ish under C, but it
obfuscates things a lot.

Carlo

-- 
  *         Se la Strada e la sua Virtu' non fossero state messe da parte,
* K * Carlo E. Prelz - fluido / fluido.as             che bisogno ci sarebbe
  *               di parlare tanto di amore e di rettitudine? (Chuang-Tzu)