I have to make a ruby c extension for the following function Abc_NtkCreateNodeAnd
:
Abc_Obj_t * Abc_NtkCreateNodeAnd( Abc_Ntk_t * pNtk, Vec_Ptr_t * vFanins )
{
Abc_Obj_t * pNode;
int i;
pNode = Abc_NtkCreateNode( pNtk );
return pNode;
}
Here is an example of the ruby c extension.
*Original C function*
Abc_Ntk_t * Io_ReadBlif( char * pFileName, int fCheck )
{
Io_ReadBlif_t * p;
Abc_Ntk_t * pNtk;
p = Io_ReadBlifFile( pFileName );
return pNtk;
}
*Ruby C extension*
static VALUE IO_read_blif(VALUE self, VALUE file_name)
{
int index;
char *file_name_str = StringValueCStr(file_name);
Abc_Ntk_t *network = Io_ReadBlif(file_name_str, IO_FILE_BLIF, 1);
}
Now my main problem is how do you pass the pointer from c to ruby.I have tried to write the extension like this :
static VALUE Abc_NtkCreateNode_And(VALUE self, VALUE netw ,VALUE vfan_ins)
{
Abc_Ntk_t *netw_str = StringValueCStr(netw);
Vec_Ptr_t *vfan_ins_str = StringValueCStr(vfan_ins);
Abc_Obj_t *network = Abc_NtkCreateNodeAnd(netw_str,vfan_ins_str, IO_FILE_BLIF, 1);
return make_Network(network);
}
but the code Abc_Ntk_t *netw_str = StringValueCStr(netw);
is wrong in my opinion.So what should be the proper code ?