Re: C++ casting: object type -> char *
actually i've been working on this and have made some progress:
static sm_matrix* convertNodeToSM(const NodePtr& n)
{
sm_matrix *sm;
sm_element *elem;
sm_col *col;
sm = sm_alloc();
unsigned int j;
NodePtr fanin;
for (unsigned int i = 0; i < n->numCubes(); ++i)
{
foreach_fanin(n, j, fanin)
{
switch (n->getLiteral(i, j))
{
case VZERO:
elem = sm_insert(sm, i, j);
sm_put(elem, 1);
col = sm_get_col(sm, static_cast<int>(j));
sm_put(col, reinterpret_cast<char *>(fanin.get())); <-- put
Node * in matrix
break;
case VONE:
elem = sm_insert(sm, i, j);
sm_put(elem, 0);
col = sm_get_col(sm, static_cast<int>(j));
sm_put(col, reinterpret_cast<char *>(fanin.get())); <-- put
Node * in matrix
break;
case VDASH:
break;
default:
bailOut("convertNodeToSM()", ERROR_INVALID_INPUT_VALUE);
}
}
}
return sm;
}
static NodePtr convertSMToNode(const sm_matrix *sm)
{
NodePtr fanin, lit, orn = Node::constant(0);
sm_row *row;
sm_col *col;
sm_element *elem;
sm_foreach_row(sm, row)
{
NodePtr andn = Node::constant(1);
sm_foreach_row_element(row, elem)
{
col = sm_get_col(sm, elem->col_num);
Node *tmp = reinterpret_cast<Node *>(sm_get(char *, col));
<-- get it back from matrix;
do stuff here..
}
this seems to work OK. i think i've got the casts right now. unless
i'm still doing it wrong, please ignore. thanks