include PL_get_intptr

This commit is contained in:
Vítor Manuel de Morais Santos Costa 2010-01-15 16:21:43 +00:00
parent 0c29616bc2
commit d3f0410c7d
2 changed files with 15 additions and 3 deletions

View File

@ -19,8 +19,8 @@ extern "C" {
//=== includes ===============================================================
#ifdef _YAP_NOT_INSTALLED_
#include <config.h>
#include <YapInterface.h>
#include "config.h"
#include "YapInterface.h"
#else
#include <Yap/config.h>
#include <Yap/YapInterface.h>
@ -333,6 +333,7 @@ extern X_API module_t PL_new_module(atom_t);
extern X_API int PL_get_name_arity(term_t, atom_t *, int *);
extern X_API int PL_get_nil(term_t);
extern X_API int PL_get_pointer(term_t, void **);
extern X_API int PL_get_intptr(term_t, intptr_t *);
extern X_API int PL_get_string(term_t, char **, int *);
extern X_API int PL_get_tail(term_t, term_t);
/* end PL_get_* functions =============================*/

View File

@ -248,6 +248,17 @@ X_API int PL_get_atom(term_t ts, atom_t *a)
return 1;
}
/* SWI: int PL_get_atom(term_t t, YAP_Atom *a)
YAP: YAP_Atom YAP_AtomOfTerm(Term) */
X_API int PL_get_intptr(term_t ts, intptr_t *a)
{
Term t = Yap_GetFromSlot(ts);
if ( !IsIntegerTerm(t) )
return 0;
*a = (intptr_t)(IntegerOfTerm(t));
return 1;
}
/* SWI: int PL_get_atom_chars(term_t t, char **s)
YAP: char* AtomName(Atom) */
X_API int PL_get_atom_chars(term_t ts, char **a) /* SAM check type */
@ -2088,7 +2099,7 @@ X_API void PL_register_foreign_in_module(const char *module, const char *name, i
nflags |= CArgsPredFlag;
}
if (flags & PL_FA_NONDETERMINISTIC) {
Yap_InitCutCPredBack((char *)name, arity, sizeof(struct foreign_context)/sizeof(CELL), (CPredicate)function, (CPredicate)function, (CPredicate)function, UserCPredFlag|nflags);
Yap_InitCPredBackCut((char *)name, arity, sizeof(struct foreign_context)/sizeof(CELL), (CPredicate)function, (CPredicate)function, (CPredicate)function, UserCPredFlag|nflags);
} else {
UserCPredicate((char *)name,(CPredicate)function,arity,tmod,nflags);
}