del_attrs/1 (for SWI compatibility).

This commit is contained in:
Vítor Santos Costa II 2010-03-03 19:08:17 +00:00
parent 9e5a25c61e
commit 8f41517e24
2 changed files with 28 additions and 0 deletions

View File

@ -357,6 +357,15 @@ DelAtts(attvar_record *attv, Term oatt)
}
}
static void
DelAllAtts(attvar_record *attv)
{
if (RepAppl(attv->Atts) >= HB)
RESET_VARIABLE(&attv->Atts);
else
MaBind(&(attv->Atts), MkVarTerm());
}
static void
PutAtt(Int pos, Term atts, Term att)
{
@ -638,6 +647,21 @@ p_del_atts(void) {
}
}
static Int
p_del_all_atts(void) {
/* receive a variable in ARG1 */
Term inp = Deref(ARG1);
/* if this is unbound, ok */
if (IsVarTerm(inp) && IsAttachedTerm(inp)) {
attvar_record *attv;
attv = (attvar_record *)VarOfTerm(inp);
DelAllAtts(attv);
}
return TRUE;
}
static Int
p_get_att(void) {
/* receive a variable in ARG1 */
@ -1010,6 +1034,7 @@ void Yap_InitAttVarPreds(void)
Yap_InitCPred("put_att_term", 2, p_put_att_term, 0);
Yap_InitCPred("put_module_atts", 2, p_put_atts, 0);
Yap_InitCPred("del_all_module_atts", 2, p_del_atts, 0);
Yap_InitCPred("del_all_atts", 1, p_del_all_atts, 0);
Yap_InitCPred("rm_att", 4, p_rm_att, 0);
Yap_InitCPred("bind_attvar", 1, p_bind_attvar, SafePredFlag);
Yap_InitCPred("unbind_attvar", 1, p_unbind_attvar, SafePredFlag);

View File

@ -284,6 +284,9 @@ prolog:del_attr(Var, Mod) :-
functor(AttTerm, Mod, 2),
attributes:del_all_module_atts(Var, AttTerm).
prolog:del_attrs(Var) :-
attributes:del_all_atts(Var).
prolog:get_attrs(AttVar, SWIAtts) :-
get_all_swi_atts(AttVar,SWIAtts).