fix swi call leak

improve yapi
reformat
This commit is contained in:
Vitor Santos Costa
2017-06-19 19:02:36 +01:00
parent 6b545c8f71
commit d7e21c80df
35 changed files with 2412 additions and 2334 deletions

View File

@@ -1,11 +1,48 @@
import yap
import os.path
import sys
# debugging support.
# import pdb
from collections import namedtuple
from yap import *
class Engine( YAPEngine ):
def __init__(self, args=None):
# type: (object) -> object
if not args:
args = YAPEngineArgs()
yap_lib_path = os.path.dirname(__file__)
args.setYapShareDir(os.path.join(yap_lib_path,"prolog"))
args.setYapLibDir(yap_lib_path)
args.setSavedState(os.path.join(yap_lib_path,"startup.yss"))
YAPEngine.__init__(self,args)
self.goal( set_prolog_flag('verbose', 'silent' ) )
self.goal( use_module(library('yapi') ) )
def run(self, g, m=None):
if m:
self.mgoal(g, m)
else:
self.goal(g)
def f(self, g):
self.E.fun(g)
class EngineArgs( YAPEngineArgs ):
""" Interface to Engine Options class"""
class Predicate( YAPPredicate ):
""" Interface to Generic Predicate"""
class PrologPredicate( YAPPrologPredicate ):
""" Interface to Prolog Predicate"""
global engine, handler
yap_lib_path = os.path.dirname(__file__)
@@ -19,6 +56,7 @@ jupyter_query = namedtuple( 'jupyter_query', 'vars dict')
python_query = namedtuple( 'python_query', 'vars dict')
yapi_query = namedtuple( 'yapi_query', 'vars dict')
show_answer = namedtuple( 'show_answer', 'vars dict')
set_prolog_flag = namedtuple('set_prolog_flag', 'flag new_value')
def v():
return yap.YAPVarTerm()
@@ -97,16 +135,6 @@ def query_prolog(engine, s):
q.close()
return
def boot_yap(**kwargs):
yap_lib_path = os.path.dirname(__file__)
args = yap.YAPEngineArgs()
args.setYapShareDir(os.path.join(yap_lib_path,"prolog"))
args.setYapLibDir(yap_lib_path)
args.setSavedState(os.path.join(yap_lib_path,"startup.yss"))
engine = yap.YAPEngine(args)
engine.goal( use_module(library('yapi') ) )
return engine
def live(**kwargs):
loop = True
while loop: