imake call_foreign_function module aware.
This commit is contained in:
parent
22c27e0d5e
commit
514758e65b
@ -148,11 +148,11 @@ p_close_shared_object(void) {
|
|||||||
void *handle;
|
void *handle;
|
||||||
|
|
||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR,t,"open_shared_object/3");
|
Yap_Error(INSTANTIATION_ERROR,t,"close_shared_object/1");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!IsIntegerTerm(t)) {
|
if (!IsIntegerTerm(t)) {
|
||||||
Yap_Error(TYPE_ERROR_INTEGER,t,"open_shared_object/3");
|
Yap_Error(TYPE_ERROR_INTEGER,t,"close_shared_object/1");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
handle = (char *)IntegerOfTerm(t);
|
handle = (char *)IntegerOfTerm(t);
|
||||||
@ -164,27 +164,48 @@ static Int
|
|||||||
p_call_shared_object_function(void) {
|
p_call_shared_object_function(void) {
|
||||||
Term t = Deref(ARG1);
|
Term t = Deref(ARG1);
|
||||||
Term tfunc = Deref(ARG2);
|
Term tfunc = Deref(ARG2);
|
||||||
|
Term tmod;
|
||||||
void *handle;
|
void *handle;
|
||||||
|
Term OldCurrentModule = CurrentModule;
|
||||||
|
Int res;
|
||||||
|
|
||||||
|
tmod = CurrentModule;
|
||||||
|
restart:
|
||||||
if (IsVarTerm(t)) {
|
if (IsVarTerm(t)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR,t,"open_shared_object/3");
|
Yap_Error(INSTANTIATION_ERROR,t,"call_shared_object_function/2");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
} else if (IsApplTerm(t)) {
|
||||||
if (!IsIntegerTerm(t)) {
|
Functor fun = FunctorOfTerm(t);
|
||||||
Yap_Error(TYPE_ERROR_INTEGER,t,"open_shared_object/3");
|
if (fun == FunctorModule) {
|
||||||
|
tmod = ArgOfTerm(1, t);
|
||||||
|
if (IsVarTerm(tmod) ) {
|
||||||
|
Yap_Error(INSTANTIATION_ERROR,t,"call_shared_object_function/2");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (!IsAtomTerm(tmod) ) {
|
||||||
|
Yap_Error(TYPE_ERROR_ATOM,ARG1,"call_shared_object_function/2");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
t = ArgOfTerm(2, t);
|
||||||
|
goto restart;
|
||||||
|
}
|
||||||
|
} else if (!IsIntegerTerm(t)) {
|
||||||
|
Yap_Error(TYPE_ERROR_INTEGER,t,"call_shared_object_function/2");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
handle = (void *)IntegerOfTerm(t);
|
handle = (void *)IntegerOfTerm(t);
|
||||||
if (IsVarTerm(tfunc)) {
|
if (IsVarTerm(tfunc)) {
|
||||||
Yap_Error(INSTANTIATION_ERROR,t,"open_shared_object/3");
|
Yap_Error(INSTANTIATION_ERROR,t,"call_shared_object_function/2");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!IsAtomTerm(tfunc)) {
|
if (!IsAtomTerm(tfunc)) {
|
||||||
Yap_Error(TYPE_ERROR_ATOM,t,"open_shared_object/3");
|
Yap_Error(TYPE_ERROR_ATOM,t,"call_shared_object_function/2/3");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
CurrentModule = tmod;
|
||||||
return Yap_CallForeignFile(handle, RepAtom(AtomOfTerm(tfunc))->StrOfAE);
|
res = Yap_CallForeignFile(handle, RepAtom(AtomOfTerm(tfunc))->StrOfAE);
|
||||||
|
CurrentModule = OldCurrentModule;
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
|
@ -565,6 +565,7 @@ source_module(Mod) :-
|
|||||||
call_cleanup(0,?,0),
|
call_cleanup(0,?,0),
|
||||||
call_residue(0,?),
|
call_residue(0,?),
|
||||||
call_residue_vars(0,?),
|
call_residue_vars(0,?),
|
||||||
|
call_shared_object_function(:,+),
|
||||||
catch(0,?,0),
|
catch(0,?,0),
|
||||||
clause(:,?),
|
clause(:,?),
|
||||||
clause(:,?,?),
|
clause(:,?,?),
|
||||||
|
Reference in New Issue
Block a user