From: "Iñaki Baz Castillo" Date: 2009-10-13T02:39:08+09:00 Subject: Re: Any "easy" example of using T_HASH in a C extension? El Lunes, 12 de Octubre de 2009, Dirkjan Bussink escribió: > On 12 Oct 2009, at 18:24, Iñaki Baz Castillo wrote: > > Hi, I've found some tutorials explaining how to create and manipulat > > a Ruby > > array from a C extension using T_ARRAY and its realted functions. > > However I find nothing about T_HASH, and trying to extract the > > functions from > > Ruby "hash.c" code is... not very cool. > > I'd advise against using T_ARRAY, RARRAY_PTR etc, writing stuff with > the following methods makes life a lot easier for other Ruby > implementations that also support MRI C extensions: > > rb_ary_new(void); > rb_ary_push(VALUE array, VALUE element); > rb_ary_entry(VALUE array, long i); > rb_ary_store(VALUE array, long i, VALUE element); Yes, finally I used just "rb_hash_new" and "rb_hash_aset" functions. -- Iñaki Baz Castillo