我必须使用Ruby包装此C函数Abc_NtkCreateNodeAnd
:
Abc_Obj_t * Abc_NtkCreateNodeAnd( Abc_Ntk_t * pNtk, Vec_Ptr_t * vFanins )
{
Abc_Obj_t * pNode;
int i;
assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
pNode = Abc_NtkCreateNode( pNtk );
for ( i = 0; i < vFanins->nSize; i++ )
Abc_ObjAddFanin( pNode, (Abc_Obj_t *)vFanins->pArray[i] );
if ( Abc_NtkHasSop(pNtk) )
pNode->pData = Abc_SopCreateAnd( (Mem_Flex_t *)pNtk->pManFunc, Vec_PtrSize(vFanins), NULL );
else if ( Abc_NtkHasBdd(pNtk) )
pNode->pData = Extra_bddCreateAnd( (DdManager *)pNtk->pManFunc, Vec_PtrSize(vFanins) ), Cudd_Ref((DdNode *)pNode->pData);
else if ( Abc_NtkHasAig(pNtk) )
pNode->pData = Hop_CreateAnd( (Hop_Man_t *)pNtk->pManFunc, Vec_PtrSize(vFanins) );
else
assert( 0 );
return pNode;
}
我写的代码是:
static VALUE Abc_NtkCreateNode_And(VALUE self, VALUE netw ,VALUE vfan_ins)
{
Abc_Ntk_t *netw_str;
Vec_Ptr_t *vfan_ins_str;
Data_Get_Struct(netw, Abc_Ntk_t, netw_str);
Data_Get_Struct(vfan_ins, Abc_Ntk_t, vfan_ins_str );
Abc_Obj_t *network = Abc_NtkCreateNodeAnd(netw_str,vfan_ins_str);
return make_Network(network);
}
我想使用Ruby传递参数并直接调用C函数。是否可以这样做?