def link_downstream_of_kb(kb, child): child_meminfo = _meminfo_from_struct(child) kb_meminfo = _meminfo_from_struct(kb) child.kb_meminfo = kb_meminfo parent.children.append(child_meminfo) upstream = parent.upstream.copy() upstream.append(parent_meminfo) child.upstream = upstream
def link_downstream(parent, child): child_meminfo = _meminfo_from_struct(child) parent_meminfo = _meminfo_from_struct(parent) child.kb_meminfo = parent.kb_meminfo parent.children.append(child_meminfo) upstream = parent.upstream.copy() upstream.append(parent_meminfo) child.upstream = upstream
def add_subscriber(kb, subscriber): l = len(kb.kb_data.subscribers) base_subscriber = _cast_structref(BaseSubscriberType, subscriber) kb.kb_data.subscribers.append(base_subscriber) if (subscriber.kb_meminfo is None): subscriber.kb_meminfo = _meminfo_from_struct(kb) else: raise RuntimeError( "Subscriber can only be linked to one KnowledgeBase.") return l
def rip_meminfo_inc(st): # _incref_structref(st) return _meminfo_from_struct(st)
def filter_beta(term, l_inds, r_inds): png = cast_structref(GenericBetaPredicateNodeType, term.pred_node) mi = _meminfo_from_struct(png) return png.filter_func(mi, term.link_data, l_inds, r_inds, term.negated)
def filter_beta(pn,link_data, left_inds, right_inds, negated=False): # print(pn.filter_func) mi = _meminfo_from_struct(pn) return pn.filter_func(mi, link_data, left_inds, right_inds, negated)
def filter_alpha(pn,link_data, inds, negated=False): # print(pn.filter_func) mi = _meminfo_from_struct(pn) return pn.filter_func(mi, link_data, inds, negated)
def njit_update(pt): meminfo = _meminfo_from_struct(pt) subscriber = _struct_from_meminfo(BaseSubscriberType,meminfo) subscriber.update_func(meminfo)