def clips_value(env: ffi.CData, value: type = ffi.NULL) -> ffi.CData: """Convert a Python value into CLIPS. If no value is provided, an empty value is returned. """ val = ffi.new("CLIPSValue *") if value is not ffi.NULL: val.value = CLIPS_VALUES.get(type(value))(env, value) return val
def clips_udf_value(env: ffi.CData, value: type = ffi.NULL, udf_value: ffi.CData = ffi.NULL) -> ffi.CData: """Convert a Python value into a CLIPS UDFValue. If no value is provided, an empty value is returned. """ if udf_value is ffi.NULL: return ffi.new("UDFValue *") udf_value.value = CLIPS_VALUES.get(type(value))(env, value) return udf_value
def activation_pp_string(env, activation): buf = ffi.new('char[1024]') lib.EnvGetActivationPPForm(env, buf, 1024, activation) return ffi.string(buf).decode()
def __init__(self, env, data=None, dtype=None): self._env = env self._type = dtype self._data = data if data is not None else ffi.new("DATA_OBJECT *")
def description(self): buf = ffi.new('char[1024]') lib.EnvGetDefmethodDescription( self._env, buf, 1024, self._gnc, self._idx) return ffi.string(buf).decode()
def instance_pp_string(env, ist): buf = ffi.new('char[1024]') lib.EnvGetInstancePPForm(env, buf, 1024, ist) return ffi.string(buf).decode()
def fact_pp_string(env, fact): buf = ffi.new('char[1024]') lib.EnvGetFactPPForm(env, buf, 1024, fact) return ffi.string(buf).decode()