[C ext to Ruby] how to read a ruby symbol from C ?

U

unbewusst

I'm now able to produce a ruby symbol from C

I'm also able to read the keys of a hash, i need to know how to
transform a key being a T_SYMBOL into a cstring (the reverse) ???

also using :


long size = RHASH( ( VALUE )options_hash )->tbl->num_entries;

i get the following error at compil time :
symbol_test.c: In function m_symbol_test_init:
symbol_test.c:109: error: dereferencing pointer to incomplete type

i don't understand very much this message.
however i can get the hash size by :

hlen = RARRAY( keys )->len;

with :

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

my "options_hash" is coming from :

rb_scan_args( argc, argv, "11", &src_path, &options_hash );

it is a VALUE :

VALUE src_path, options_hash, noop, verbose;


help appreciated,

Yvon
 
N

Nobuyoshi Nakada

Hi,

At Sat, 18 Aug 2007 20:59:59 +0900,
unbewusst wrote in [ruby-talk:265267]:
I'm now able to produce a ruby symbol from C

I'm also able to read the keys of a hash, i need to know how to
transform a key being a T_SYMBOL into a cstring (the reverse) ???

also using :


long size = RHASH( ( VALUE )options_hash )->tbl->num_entries;

i get the following error at compil time :
symbol_test.c: In function m_symbol_test_init:
symbol_test.c:109: error: dereferencing pointer to incomplete type

i don't understand very much this message.

You need to include st.h too.

But I guess what you need first is the knowledge of C.
 
U

unbewusst

You need to include st.h too.

But I guess what you need first is the knowledge of C.


OK, thanks, including st.h is OK, BUT using :

rb_id2name( SYM2ID( a key T_SYMBOL from a RHASH ))

i get allways (null) even if i'm sure, from ruby side the, symbols
are :

:verbose and :noop

isn't the above the correct way to get the name of a symbol ???

Yvon
 
N

Nobuyoshi Nakada

Hi,

At Mon, 20 Aug 2007 01:44:57 +0900,
unbewusst wrote in [ruby-talk:265404]:
rb_id2name( SYM2ID( a key T_SYMBOL from a RHASH ))

i get allways (null) even if i'm sure, from ruby side the, symbols
are :

:verbose and :noop

isn't the above the correct way to get the name of a symbol ???

That portion you mentioned is correct. So something is wrong
where you didn't.
 
U

unbewusst

Hi,

At Mon, 20 Aug 2007 01:44:57 +0900,
unbewusst wrote in [ruby-talk:265404]:
rb_id2name( SYM2ID( a key T_SYMBOL from a RHASH ))
i get allways (null) even if i'm sure, from ruby side the, symbols
are :
:verbose and :noop
isn't the above the correct way to get the name of a symbol ???

That portion you mentioned is correct. So something is wrong
where you didn't.


OK, i'll look again at that...

thanks,

Yvon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top