Creates a term-references holding a Prolog pointer. A pointer is
represented in Prolog as a mangled integer. The mangling is designed to
make most pointers fit into a tagged-integer. Any valid pointer
can be represented. This mechanism can be used to represent pointers to
C++ objects in Prolog. Please note that‘myclass’should
define conversion to and from void *
.
PREDICATE(make_my_object, 1)
{ myclass *myobj = new myclass();
return A1 = (void *)myobj;
}
PREDICATE(free_my_object, 1)
{ myclass *myobj = (void *)A1;
delete(myobj);
return TRUE;
}