clipspyx-ffi 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- clipspyx_ffi-0.1.0/PKG-INFO +9 -0
- clipspyx_ffi-0.1.0/clipspyx_ffi/__init__.py +5 -0
- clipspyx_ffi-0.1.0/clipspyx_ffi/build.py +285 -0
- clipspyx_ffi-0.1.0/clipspyx_ffi/clips-70x.cdef +56 -0
- clipspyx_ffi-0.1.0/clipspyx_ffi/clips.cdef +639 -0
- clipspyx_ffi-0.1.0/clipspyx_ffi.egg-info/PKG-INFO +9 -0
- clipspyx_ffi-0.1.0/clipspyx_ffi.egg-info/SOURCES.txt +10 -0
- clipspyx_ffi-0.1.0/clipspyx_ffi.egg-info/dependency_links.txt +1 -0
- clipspyx_ffi-0.1.0/clipspyx_ffi.egg-info/requires.txt +1 -0
- clipspyx_ffi-0.1.0/clipspyx_ffi.egg-info/top_level.txt +1 -0
- clipspyx_ffi-0.1.0/pyproject.toml +21 -0
- clipspyx_ffi-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: clipspyx-ffi
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Shared CFFI build infrastructure for clipspyx
|
|
5
|
+
License-Expression: BSD-3-Clause
|
|
6
|
+
Project-URL: Homepage, https://github.com/inferal-oss/clipspyx
|
|
7
|
+
Project-URL: Repository, https://github.com/inferal-oss/clipspyx
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Requires-Dist: cffi>=1.0.0
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
# Copyright (c) 2016-2025, Matteo Cafasso
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
|
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
# 1. Redistributions of source code must retain the above copyright notice,
|
|
8
|
+
# this list of conditions and the following disclaimer.
|
|
9
|
+
|
|
10
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
12
|
+
# and/or other materials provided with the distribution.
|
|
13
|
+
|
|
14
|
+
# 3. Neither the name of the copyright holder nor the names of its contributors
|
|
15
|
+
# may be used to endorse or promote products derived from this software without
|
|
16
|
+
# specific prior written permission.
|
|
17
|
+
|
|
18
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
19
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
20
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
21
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
|
|
22
|
+
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
|
23
|
+
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
|
24
|
+
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
25
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
26
|
+
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
|
27
|
+
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
28
|
+
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
29
|
+
|
|
30
|
+
import glob
|
|
31
|
+
import hashlib
|
|
32
|
+
import os
|
|
33
|
+
import re
|
|
34
|
+
import subprocess
|
|
35
|
+
import sys
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _subdir_for_branch(branch: str) -> str:
|
|
39
|
+
"""Return subdirectory name for a CLIPS branch.
|
|
40
|
+
|
|
41
|
+
Known branches like clips-64x map to '64x'; arbitrary names
|
|
42
|
+
are hashed to an 8-char hex prefix.
|
|
43
|
+
"""
|
|
44
|
+
prefix = "clips-"
|
|
45
|
+
if branch.startswith(prefix):
|
|
46
|
+
return branch[len(prefix):]
|
|
47
|
+
return hashlib.sha256(branch.encode()).hexdigest()[:8]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _find_repo_root() -> str | None:
|
|
51
|
+
"""Find the git repository root using git rev-parse.
|
|
52
|
+
|
|
53
|
+
Returns None if not inside a git repository.
|
|
54
|
+
"""
|
|
55
|
+
try:
|
|
56
|
+
result = subprocess.run(
|
|
57
|
+
["git", "rev-parse", "--show-toplevel"],
|
|
58
|
+
capture_output=True, text=True, check=True)
|
|
59
|
+
return result.stdout.strip()
|
|
60
|
+
except (subprocess.CalledProcessError, FileNotFoundError):
|
|
61
|
+
return None
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def resolve_clips_source(default_branch=None):
|
|
65
|
+
"""Resolve CLIPS C source directory.
|
|
66
|
+
|
|
67
|
+
Priority:
|
|
68
|
+
1. CLIPS_SOURCE_DIR env var - arbitrary checkout path
|
|
69
|
+
2. CLIPS_BRANCH env var - checkout that orphan branch
|
|
70
|
+
3. default_branch argument
|
|
71
|
+
4. Default - auto-checkout clips-64x branch
|
|
72
|
+
|
|
73
|
+
Each branch gets its own subdirectory under .clips-source/<suffix>/
|
|
74
|
+
so multiple source checkouts coexist without switching.
|
|
75
|
+
"""
|
|
76
|
+
# Priority 1: explicit source directory
|
|
77
|
+
src_dir = os.environ.get("CLIPS_SOURCE_DIR")
|
|
78
|
+
if src_dir:
|
|
79
|
+
src_dir = os.path.abspath(src_dir)
|
|
80
|
+
if not os.path.isdir(src_dir):
|
|
81
|
+
raise FileNotFoundError(
|
|
82
|
+
f"CLIPS_SOURCE_DIR={src_dir} does not exist")
|
|
83
|
+
return src_dir
|
|
84
|
+
|
|
85
|
+
# Priority 2/3/4: checkout from local orphan branch
|
|
86
|
+
branch = os.environ.get("CLIPS_BRANCH", default_branch or "clips-64x")
|
|
87
|
+
repo_root = _find_repo_root()
|
|
88
|
+
if repo_root is None:
|
|
89
|
+
raise FileNotFoundError(
|
|
90
|
+
"Not inside a git repository. "
|
|
91
|
+
"Set CLIPS_SOURCE_DIR to point to CLIPS source.")
|
|
92
|
+
|
|
93
|
+
base_dir = os.path.join(repo_root, ".clips-source")
|
|
94
|
+
subdir = _subdir_for_branch(branch)
|
|
95
|
+
checkout_dir = os.path.join(base_dir, subdir)
|
|
96
|
+
|
|
97
|
+
# Migration: if .clips-source is an old single-worktree layout, remove it
|
|
98
|
+
git_file = os.path.join(base_dir, ".git")
|
|
99
|
+
if os.path.isfile(git_file):
|
|
100
|
+
import shutil
|
|
101
|
+
subprocess.run(
|
|
102
|
+
["git", "worktree", "remove", base_dir],
|
|
103
|
+
capture_output=True, text=True, cwd=repo_root)
|
|
104
|
+
if os.path.exists(base_dir):
|
|
105
|
+
shutil.rmtree(base_dir, ignore_errors=True)
|
|
106
|
+
subprocess.run(
|
|
107
|
+
["git", "worktree", "prune"],
|
|
108
|
+
capture_output=True, text=True, cwd=repo_root)
|
|
109
|
+
|
|
110
|
+
# Already checked out: return immediately
|
|
111
|
+
if os.path.isdir(checkout_dir):
|
|
112
|
+
return checkout_dir
|
|
113
|
+
|
|
114
|
+
# Create parent directory and prune stale worktrees
|
|
115
|
+
os.makedirs(base_dir, exist_ok=True)
|
|
116
|
+
subprocess.run(
|
|
117
|
+
["git", "worktree", "prune"],
|
|
118
|
+
capture_output=True, text=True, cwd=repo_root)
|
|
119
|
+
|
|
120
|
+
# Attempt git worktree checkout
|
|
121
|
+
try:
|
|
122
|
+
subprocess.run(
|
|
123
|
+
["git", "worktree", "add", checkout_dir, branch],
|
|
124
|
+
check=True, capture_output=True, text=True,
|
|
125
|
+
cwd=repo_root)
|
|
126
|
+
except subprocess.CalledProcessError as e:
|
|
127
|
+
# Check if branch exists locally
|
|
128
|
+
result = subprocess.run(
|
|
129
|
+
["git", "branch", "--list", branch],
|
|
130
|
+
capture_output=True, text=True, cwd=repo_root)
|
|
131
|
+
if not result.stdout.strip():
|
|
132
|
+
# Branch missing locally — try fetching from origin
|
|
133
|
+
# (common when installed as a git dependency: uv only clones the default branch)
|
|
134
|
+
print(f" Branch '{branch}' not found locally, fetching from origin...")
|
|
135
|
+
fetch = subprocess.run(
|
|
136
|
+
["git", "fetch", "origin", f"{branch}:{branch}"],
|
|
137
|
+
capture_output=True, text=True, cwd=repo_root)
|
|
138
|
+
if fetch.returncode == 0:
|
|
139
|
+
print(f" Fetched '{branch}' from origin")
|
|
140
|
+
try:
|
|
141
|
+
subprocess.run(
|
|
142
|
+
["git", "worktree", "add", checkout_dir, branch],
|
|
143
|
+
check=True, capture_output=True, text=True,
|
|
144
|
+
cwd=repo_root)
|
|
145
|
+
return checkout_dir
|
|
146
|
+
except subprocess.CalledProcessError as e2:
|
|
147
|
+
raise FileNotFoundError(
|
|
148
|
+
f"Cannot checkout CLIPS source from branch '{branch}': "
|
|
149
|
+
f"{e2.stderr.strip()}")
|
|
150
|
+
else:
|
|
151
|
+
print(
|
|
152
|
+
f"Error: Branch '{branch}' not found locally or on origin.\n"
|
|
153
|
+
f"Run: ./scripts/sync-svn.sh 64x\n"
|
|
154
|
+
f"Or set CLIPS_SOURCE_DIR to point to CLIPS source.",
|
|
155
|
+
file=sys.stderr)
|
|
156
|
+
raise FileNotFoundError(
|
|
157
|
+
f"Cannot checkout CLIPS source from branch '{branch}': "
|
|
158
|
+
f"{e.stderr.strip()}")
|
|
159
|
+
|
|
160
|
+
return checkout_dir
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def _detect_clips_major(clips_src: str) -> int:
|
|
164
|
+
"""Detect CLIPS major version from constant.h in the source directory."""
|
|
165
|
+
constant_h = os.path.join(clips_src, "constant.h")
|
|
166
|
+
if os.path.exists(constant_h):
|
|
167
|
+
with open(constant_h) as f:
|
|
168
|
+
m = re.search(r'#define\s+VERSION_STRING\s+"(\d+)', f.read())
|
|
169
|
+
if m:
|
|
170
|
+
return int(m.group(1))
|
|
171
|
+
return 6
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
CLIPS_SOURCE = """
|
|
175
|
+
#include <clips.h>
|
|
176
|
+
|
|
177
|
+
const int CLIPSPYX_CLIPS_MAJOR = CLIPS_MAJOR;
|
|
178
|
+
|
|
179
|
+
/* CLIPS 7.0 renamed DeftemplateGet/SetWatch -> DeftemplateGet/SetWatchFacts. */
|
|
180
|
+
#if CLIPS_MAJOR >= 7
|
|
181
|
+
#define DeftemplateGetWatch DeftemplateGetWatchFacts
|
|
182
|
+
#define DeftemplateSetWatch DeftemplateSetWatchFacts
|
|
183
|
+
|
|
184
|
+
#include "tabledef.h"
|
|
185
|
+
#include "tablebsc.h"
|
|
186
|
+
#endif
|
|
187
|
+
|
|
188
|
+
/* Return true if the template is implied. */
|
|
189
|
+
bool ImpliedDeftemplate(Deftemplate *template)
|
|
190
|
+
{
|
|
191
|
+
return template->implied;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
#if CLIPS_MAJOR >= 7
|
|
195
|
+
/* Return the row count for a deftable. */
|
|
196
|
+
unsigned long DeftableRowCount(Deftable *table)
|
|
197
|
+
{
|
|
198
|
+
return table->rowCount;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/* Return the column count for a deftable. */
|
|
202
|
+
unsigned long DeftableColumnCount(Deftable *table)
|
|
203
|
+
{
|
|
204
|
+
return table->columnCount;
|
|
205
|
+
}
|
|
206
|
+
#endif
|
|
207
|
+
|
|
208
|
+
/* User Defined Functions support. */
|
|
209
|
+
static void python_function(Environment *env, UDFContext *udfc, UDFValue *out);
|
|
210
|
+
|
|
211
|
+
int DefinePythonFunction(Environment *environment)
|
|
212
|
+
{
|
|
213
|
+
return AddUDF(
|
|
214
|
+
environment, "python-function",
|
|
215
|
+
NULL, UNBOUNDED, UNBOUNDED, NULL,
|
|
216
|
+
python_function, "python_function", NULL);
|
|
217
|
+
}
|
|
218
|
+
"""
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def make_ffibuilder(module_name="clipspyx._clipspyx",
|
|
222
|
+
default_branch=None,
|
|
223
|
+
cdef_dir=None):
|
|
224
|
+
"""Create and configure a CFFI FFIBuilder for CLIPS.
|
|
225
|
+
|
|
226
|
+
Args:
|
|
227
|
+
module_name: Dotted module name for the compiled extension
|
|
228
|
+
(e.g. "clipspyx_ffi_64x._clipspyx").
|
|
229
|
+
default_branch: Default CLIPS source branch to use if neither
|
|
230
|
+
CLIPS_SOURCE_DIR nor CLIPS_BRANCH is set.
|
|
231
|
+
cdef_dir: Directory containing .cdef files. Defaults to this
|
|
232
|
+
package's own directory.
|
|
233
|
+
|
|
234
|
+
Returns:
|
|
235
|
+
Configured cffi.FFI instance ready for compilation.
|
|
236
|
+
"""
|
|
237
|
+
from cffi import FFI
|
|
238
|
+
|
|
239
|
+
clips_src = resolve_clips_source(default_branch)
|
|
240
|
+
|
|
241
|
+
# setuptools requires relative paths; compute relative to CWD
|
|
242
|
+
# (which is the package directory during build)
|
|
243
|
+
clips_src_rel = os.path.relpath(clips_src)
|
|
244
|
+
|
|
245
|
+
# Collect all .c files from CLIPS source (as relative paths)
|
|
246
|
+
clips_c_files = sorted(glob.glob(os.path.join(clips_src_rel, "*.c")))
|
|
247
|
+
if not clips_c_files:
|
|
248
|
+
raise FileNotFoundError(
|
|
249
|
+
f"No .c files found in {clips_src}. "
|
|
250
|
+
f"Is this a valid CLIPS source directory?")
|
|
251
|
+
|
|
252
|
+
clips_major = _detect_clips_major(clips_src)
|
|
253
|
+
|
|
254
|
+
ffibuilder = FFI()
|
|
255
|
+
|
|
256
|
+
if sys.platform == "win32":
|
|
257
|
+
extra_compile_args = [f"/DCLIPS_MAJOR={clips_major}"]
|
|
258
|
+
extra_link_args = []
|
|
259
|
+
else:
|
|
260
|
+
extra_compile_args = ["-std=c99", "-O2", "-fno-strict-aliasing",
|
|
261
|
+
f"-DCLIPS_MAJOR={clips_major}"]
|
|
262
|
+
extra_link_args = ["-lm"]
|
|
263
|
+
|
|
264
|
+
ffibuilder.set_source(
|
|
265
|
+
module_name,
|
|
266
|
+
CLIPS_SOURCE,
|
|
267
|
+
sources=clips_c_files,
|
|
268
|
+
include_dirs=[clips_src_rel],
|
|
269
|
+
extra_compile_args=extra_compile_args,
|
|
270
|
+
extra_link_args=extra_link_args)
|
|
271
|
+
|
|
272
|
+
# Read CFFI definitions from the .cdef files
|
|
273
|
+
if cdef_dir is None:
|
|
274
|
+
cdef_dir = os.path.dirname(os.path.abspath(__file__))
|
|
275
|
+
|
|
276
|
+
cdef_path = os.path.join(cdef_dir, "clips.cdef")
|
|
277
|
+
with open(cdef_path) as cdef_file:
|
|
278
|
+
ffibuilder.cdef(cdef_file.read())
|
|
279
|
+
|
|
280
|
+
if clips_major >= 7:
|
|
281
|
+
cdef_70x_path = os.path.join(cdef_dir, "clips-70x.cdef")
|
|
282
|
+
with open(cdef_70x_path) as cdef_70x_file:
|
|
283
|
+
ffibuilder.cdef(cdef_70x_file.read())
|
|
284
|
+
|
|
285
|
+
return ffibuilder
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**********************/
|
|
2
|
+
/* CLIPS 7.0 Deftable */
|
|
3
|
+
/**********************/
|
|
4
|
+
|
|
5
|
+
typedef struct deftable Deftable;
|
|
6
|
+
|
|
7
|
+
Deftable *FindDeftable(Environment *, const char *);
|
|
8
|
+
Deftable *GetNextDeftable(Environment *, Deftable *);
|
|
9
|
+
const char *DeftableName(Deftable *);
|
|
10
|
+
const char *DeftableModule(Deftable *);
|
|
11
|
+
const char *DeftablePPForm(Deftable *);
|
|
12
|
+
bool DeftableIsDeletable(Deftable *);
|
|
13
|
+
bool Undeftable(Deftable *, Environment *);
|
|
14
|
+
void GetDeftableList(Environment *, CLIPSValue *, Defmodule *);
|
|
15
|
+
void GetTableValue(Environment *, Deftable *, unsigned int, unsigned int,
|
|
16
|
+
UDFValue *);
|
|
17
|
+
unsigned long DeftableRowCount(Deftable *);
|
|
18
|
+
unsigned long DeftableColumnCount(Deftable *);
|
|
19
|
+
|
|
20
|
+
/*******************/
|
|
21
|
+
/* CLIPS 7.0 Goals */
|
|
22
|
+
/*******************/
|
|
23
|
+
|
|
24
|
+
Fact *GetNextGoal(Environment *, Fact *);
|
|
25
|
+
Fact *FindIndexedGoal(Environment *, long long);
|
|
26
|
+
RetractError RetractAllGoals(Environment *);
|
|
27
|
+
bool GetGoalListChanged(Environment *);
|
|
28
|
+
void SetGoalListChanged(Environment *, bool);
|
|
29
|
+
void Goals(Environment *, const char *, Defmodule *,
|
|
30
|
+
long long, long long, long long);
|
|
31
|
+
|
|
32
|
+
/*************************************/
|
|
33
|
+
/* CLIPS 7.0 Deftemplate Watch Goals */
|
|
34
|
+
/*************************************/
|
|
35
|
+
|
|
36
|
+
bool DeftemplateGetWatchGoals(Deftemplate *);
|
|
37
|
+
void DeftemplateSetWatchGoals(Deftemplate *, bool);
|
|
38
|
+
|
|
39
|
+
/*************************************/
|
|
40
|
+
/* CLIPS 7.0 Deftemplate Inheritance */
|
|
41
|
+
/*************************************/
|
|
42
|
+
|
|
43
|
+
bool HasSupertemplate(Deftemplate *, Deftemplate *);
|
|
44
|
+
bool CanMatchGoal(Deftemplate *);
|
|
45
|
+
|
|
46
|
+
/*********************************/
|
|
47
|
+
/* CLIPS 7.0 Certainty Factors */
|
|
48
|
+
/*********************************/
|
|
49
|
+
|
|
50
|
+
short GetFactCertaintyFactor(Fact *);
|
|
51
|
+
|
|
52
|
+
/*********************************/
|
|
53
|
+
/* CLIPS 7.0 FMUpdate */
|
|
54
|
+
/*********************************/
|
|
55
|
+
|
|
56
|
+
Fact *FMUpdate(FactModifier *);
|
|
@@ -0,0 +1,639 @@
|
|
|
1
|
+
typedef enum {
|
|
2
|
+
LE_NO_ERROR,
|
|
3
|
+
LE_OPEN_FILE_ERROR,
|
|
4
|
+
LE_PARSING_ERROR
|
|
5
|
+
} LoadError;
|
|
6
|
+
|
|
7
|
+
typedef enum {
|
|
8
|
+
EE_NO_ERROR,
|
|
9
|
+
EE_PARSING_ERROR,
|
|
10
|
+
EE_PROCESSING_ERROR
|
|
11
|
+
} EvalError;
|
|
12
|
+
|
|
13
|
+
typedef enum {
|
|
14
|
+
BE_NO_ERROR,
|
|
15
|
+
BE_COULD_NOT_BUILD_ERROR,
|
|
16
|
+
BE_CONSTRUCT_NOT_FOUND_ERROR,
|
|
17
|
+
BE_PARSING_ERROR,
|
|
18
|
+
} BuildError;
|
|
19
|
+
|
|
20
|
+
typedef enum {
|
|
21
|
+
ASE_NO_ERROR,
|
|
22
|
+
ASE_NULL_POINTER_ERROR,
|
|
23
|
+
ASE_PARSING_ERROR,
|
|
24
|
+
ASE_COULD_NOT_ASSERT_ERROR,
|
|
25
|
+
ASE_RULE_NETWORK_ERROR
|
|
26
|
+
} AssertStringError;
|
|
27
|
+
|
|
28
|
+
typedef enum {
|
|
29
|
+
RE_NO_ERROR,
|
|
30
|
+
RE_NULL_POINTER_ERROR,
|
|
31
|
+
RE_COULD_NOT_RETRACT_ERROR,
|
|
32
|
+
RE_RULE_NETWORK_ERROR
|
|
33
|
+
} RetractError;
|
|
34
|
+
|
|
35
|
+
typedef enum {
|
|
36
|
+
MIE_NO_ERROR,
|
|
37
|
+
MIE_NULL_POINTER_ERROR,
|
|
38
|
+
MIE_PARSING_ERROR,
|
|
39
|
+
MIE_COULD_NOT_CREATE_ERROR,
|
|
40
|
+
MIE_RULE_NETWORK_ERROR
|
|
41
|
+
} MakeInstanceError;
|
|
42
|
+
|
|
43
|
+
typedef enum {
|
|
44
|
+
UIE_NO_ERROR,
|
|
45
|
+
UIE_NULL_POINTER_ERROR,
|
|
46
|
+
UIE_COULD_NOT_DELETE_ERROR,
|
|
47
|
+
UIE_DELETED_ERROR,
|
|
48
|
+
UIE_RULE_NETWORK_ERROR
|
|
49
|
+
} UnmakeInstanceError;
|
|
50
|
+
|
|
51
|
+
typedef enum {
|
|
52
|
+
FBE_NO_ERROR,
|
|
53
|
+
FBE_NULL_POINTER_ERROR,
|
|
54
|
+
FBE_DEFTEMPLATE_NOT_FOUND_ERROR,
|
|
55
|
+
FBE_IMPLIED_DEFTEMPLATE_ERROR,
|
|
56
|
+
FBE_COULD_NOT_ASSERT_ERROR,
|
|
57
|
+
FBE_RULE_NETWORK_ERROR
|
|
58
|
+
} FactBuilderError;
|
|
59
|
+
|
|
60
|
+
typedef enum {
|
|
61
|
+
FME_NO_ERROR,
|
|
62
|
+
FME_NULL_POINTER_ERROR,
|
|
63
|
+
FME_RETRACTED_ERROR,
|
|
64
|
+
FME_IMPLIED_DEFTEMPLATE_ERROR,
|
|
65
|
+
FME_COULD_NOT_MODIFY_ERROR,
|
|
66
|
+
FME_RULE_NETWORK_ERROR
|
|
67
|
+
} FactModifierError;
|
|
68
|
+
|
|
69
|
+
typedef enum {
|
|
70
|
+
PSE_NO_ERROR,
|
|
71
|
+
PSE_NULL_POINTER_ERROR,
|
|
72
|
+
PSE_INVALID_TARGET_ERROR,
|
|
73
|
+
PSE_SLOT_NOT_FOUND_ERROR,
|
|
74
|
+
PSE_TYPE_ERROR,
|
|
75
|
+
PSE_RANGE_ERROR,
|
|
76
|
+
PSE_ALLOWED_VALUES_ERROR,
|
|
77
|
+
PSE_CARDINALITY_ERROR,
|
|
78
|
+
PSE_ALLOWED_CLASSES_ERROR
|
|
79
|
+
} PutSlotError;
|
|
80
|
+
|
|
81
|
+
typedef enum {
|
|
82
|
+
GSE_NO_ERROR,
|
|
83
|
+
GSE_NULL_POINTER_ERROR,
|
|
84
|
+
GSE_INVALID_TARGET_ERROR,
|
|
85
|
+
GSE_SLOT_NOT_FOUND_ERROR
|
|
86
|
+
} GetSlotError;
|
|
87
|
+
|
|
88
|
+
typedef enum {
|
|
89
|
+
LOCAL_SAVE,
|
|
90
|
+
VISIBLE_SAVE
|
|
91
|
+
} SaveScope;
|
|
92
|
+
|
|
93
|
+
typedef enum {
|
|
94
|
+
NO_DEFAULT,
|
|
95
|
+
STATIC_DEFAULT,
|
|
96
|
+
DYNAMIC_DEFAULT
|
|
97
|
+
} DefaultType;
|
|
98
|
+
|
|
99
|
+
typedef enum {
|
|
100
|
+
IBE_NO_ERROR,
|
|
101
|
+
IBE_NULL_POINTER_ERROR,
|
|
102
|
+
IBE_DEFCLASS_NOT_FOUND_ERROR,
|
|
103
|
+
IBE_COULD_NOT_CREATE_ERROR,
|
|
104
|
+
IBE_RULE_NETWORK_ERROR
|
|
105
|
+
} InstanceBuilderError;
|
|
106
|
+
|
|
107
|
+
typedef enum {
|
|
108
|
+
IME_NO_ERROR,
|
|
109
|
+
IME_NULL_POINTER_ERROR,
|
|
110
|
+
IME_DELETED_ERROR,
|
|
111
|
+
IME_COULD_NOT_MODIFY_ERROR,
|
|
112
|
+
IME_RULE_NETWORK_ERROR
|
|
113
|
+
} InstanceModifierError;
|
|
114
|
+
|
|
115
|
+
typedef enum {
|
|
116
|
+
CONVENIENCE_MODE,
|
|
117
|
+
CONSERVATION_MODE
|
|
118
|
+
} ClassDefaultsMode;
|
|
119
|
+
|
|
120
|
+
typedef enum {
|
|
121
|
+
WHEN_DEFINED,
|
|
122
|
+
WHEN_ACTIVATED,
|
|
123
|
+
EVERY_CYCLE
|
|
124
|
+
} SalienceEvaluationType;
|
|
125
|
+
|
|
126
|
+
typedef enum {
|
|
127
|
+
DEPTH_STRATEGY,
|
|
128
|
+
BREADTH_STRATEGY,
|
|
129
|
+
LEX_STRATEGY,
|
|
130
|
+
MEA_STRATEGY,
|
|
131
|
+
COMPLEXITY_STRATEGY,
|
|
132
|
+
SIMPLICITY_STRATEGY,
|
|
133
|
+
RANDOM_STRATEGY
|
|
134
|
+
} StrategyType;
|
|
135
|
+
|
|
136
|
+
typedef enum {
|
|
137
|
+
VERBOSE,
|
|
138
|
+
SUCCINCT,
|
|
139
|
+
TERSE
|
|
140
|
+
} Verbosity;
|
|
141
|
+
|
|
142
|
+
typedef enum {
|
|
143
|
+
FCBE_NO_ERROR,
|
|
144
|
+
FCBE_NULL_POINTER_ERROR,
|
|
145
|
+
FCBE_FUNCTION_NOT_FOUND_ERROR,
|
|
146
|
+
FCBE_INVALID_FUNCTION_ERROR,
|
|
147
|
+
FCBE_ARGUMENT_COUNT_ERROR,
|
|
148
|
+
FCBE_ARGUMENT_TYPE_ERROR,
|
|
149
|
+
FCBE_PROCESSING_ERROR
|
|
150
|
+
} FunctionCallBuilderError;
|
|
151
|
+
|
|
152
|
+
typedef enum {
|
|
153
|
+
AUE_NO_ERROR,
|
|
154
|
+
AUE_MIN_EXCEEDS_MAX_ERROR,
|
|
155
|
+
AUE_FUNCTION_NAME_IN_USE_ERROR,
|
|
156
|
+
AUE_INVALID_ARGUMENT_TYPE_ERROR,
|
|
157
|
+
AUE_INVALID_RETURN_TYPE_ERROR
|
|
158
|
+
} AddUDFError;
|
|
159
|
+
|
|
160
|
+
typedef enum {
|
|
161
|
+
FLOAT_BIT = 1,
|
|
162
|
+
INTEGER_BIT = 2,
|
|
163
|
+
SYMBOL_BIT = 4,
|
|
164
|
+
STRING_BIT = 8,
|
|
165
|
+
MULTIFIELD_BIT = 16,
|
|
166
|
+
EXTERNAL_ADDRESS_BIT = 32,
|
|
167
|
+
FACT_ADDRESS_BIT = 64,
|
|
168
|
+
INSTANCE_ADDRESS_BIT = 128,
|
|
169
|
+
INSTANCE_NAME_BIT = 256,
|
|
170
|
+
VOID_BIT = 512,
|
|
171
|
+
BOOLEAN_BIT = 1024
|
|
172
|
+
} CLIPSType;
|
|
173
|
+
|
|
174
|
+
typedef struct environment Environment;
|
|
175
|
+
typedef struct defrule Defrule;
|
|
176
|
+
typedef struct fact Fact;
|
|
177
|
+
typedef struct deftemplate Deftemplate;
|
|
178
|
+
typedef struct deffacts Deffacts;
|
|
179
|
+
typedef struct instance Instance;
|
|
180
|
+
typedef struct defclass Defclass;
|
|
181
|
+
typedef struct definstances Definstances;
|
|
182
|
+
typedef struct deffunction Deffunction;
|
|
183
|
+
typedef struct defgeneric Defgeneric;
|
|
184
|
+
typedef struct defmodule Defmodule;
|
|
185
|
+
typedef struct defglobal Defglobal;
|
|
186
|
+
typedef struct activation Activation;
|
|
187
|
+
typedef struct clipsValue CLIPSValue;
|
|
188
|
+
typedef struct factBuilder FactBuilder;
|
|
189
|
+
typedef struct factModifier FactModifier;
|
|
190
|
+
typedef struct instanceModifier InstanceModifier;
|
|
191
|
+
typedef struct instanceBuilder InstanceBuilder;
|
|
192
|
+
typedef struct multifieldBuilder MultifieldBuilder;
|
|
193
|
+
typedef struct functionCallBuilder FunctionCallBuilder;
|
|
194
|
+
|
|
195
|
+
typedef struct stringBuilder {
|
|
196
|
+
char *contents;
|
|
197
|
+
size_t length;
|
|
198
|
+
...;
|
|
199
|
+
} StringBuilder;
|
|
200
|
+
|
|
201
|
+
typedef struct typeHeader {
|
|
202
|
+
unsigned short type;
|
|
203
|
+
} TypeHeader;
|
|
204
|
+
|
|
205
|
+
typedef struct clipsLexeme {
|
|
206
|
+
TypeHeader header;
|
|
207
|
+
const char *contents;
|
|
208
|
+
...;
|
|
209
|
+
} CLIPSLexeme;
|
|
210
|
+
|
|
211
|
+
typedef struct clipsInteger {
|
|
212
|
+
TypeHeader header;
|
|
213
|
+
long long contents;
|
|
214
|
+
...;
|
|
215
|
+
} CLIPSInteger;
|
|
216
|
+
|
|
217
|
+
typedef struct clipsFloat {
|
|
218
|
+
TypeHeader header;
|
|
219
|
+
double contents;
|
|
220
|
+
...;
|
|
221
|
+
} CLIPSFloat;
|
|
222
|
+
|
|
223
|
+
typedef struct multifield {
|
|
224
|
+
TypeHeader header;
|
|
225
|
+
size_t length;
|
|
226
|
+
CLIPSValue contents[1];
|
|
227
|
+
...;
|
|
228
|
+
} Multifield;
|
|
229
|
+
|
|
230
|
+
typedef struct clipsExternalAddress {
|
|
231
|
+
TypeHeader header;
|
|
232
|
+
void *contents;
|
|
233
|
+
...;
|
|
234
|
+
} CLIPSExternalAddress;
|
|
235
|
+
|
|
236
|
+
typedef struct clipsVoid {
|
|
237
|
+
TypeHeader header;
|
|
238
|
+
} CLIPSVoid;
|
|
239
|
+
|
|
240
|
+
typedef struct clipsValue {
|
|
241
|
+
union {
|
|
242
|
+
void *value;
|
|
243
|
+
TypeHeader *header;
|
|
244
|
+
CLIPSLexeme *lexemeValue;
|
|
245
|
+
CLIPSFloat *floatValue;
|
|
246
|
+
CLIPSInteger *integerValue;
|
|
247
|
+
CLIPSVoid *voidValue;
|
|
248
|
+
Fact *factValue;
|
|
249
|
+
Instance *instanceValue;
|
|
250
|
+
Multifield *multifieldValue;
|
|
251
|
+
CLIPSExternalAddress *externalAddressValue;
|
|
252
|
+
};
|
|
253
|
+
} CLIPSValue;
|
|
254
|
+
|
|
255
|
+
typedef struct udfContext {
|
|
256
|
+
Environment *environment;
|
|
257
|
+
void *context;
|
|
258
|
+
...;
|
|
259
|
+
} UDFContext;
|
|
260
|
+
|
|
261
|
+
typedef struct udfValue {
|
|
262
|
+
union {
|
|
263
|
+
void *value;
|
|
264
|
+
TypeHeader *header;
|
|
265
|
+
CLIPSLexeme *lexemeValue;
|
|
266
|
+
CLIPSFloat *floatValue;
|
|
267
|
+
CLIPSInteger *integerValue;
|
|
268
|
+
CLIPSVoid *voidValue;
|
|
269
|
+
Multifield *multifieldValue;
|
|
270
|
+
Fact *factValue;
|
|
271
|
+
Instance *instanceValue;
|
|
272
|
+
CLIPSExternalAddress *externalAddressValue;
|
|
273
|
+
};
|
|
274
|
+
size_t begin;
|
|
275
|
+
size_t range;
|
|
276
|
+
} UDFValue;
|
|
277
|
+
|
|
278
|
+
/*****************/
|
|
279
|
+
/* Version Query */
|
|
280
|
+
/*****************/
|
|
281
|
+
|
|
282
|
+
const int CLIPSPYX_CLIPS_MAJOR;
|
|
283
|
+
|
|
284
|
+
/***************/
|
|
285
|
+
/* Environment */
|
|
286
|
+
/***************/
|
|
287
|
+
|
|
288
|
+
Environment *CreateEnvironment();
|
|
289
|
+
bool DestroyEnvironment(Environment *);
|
|
290
|
+
BuildError Build(Environment *, const char *);
|
|
291
|
+
EvalError Eval(Environment *, const char *, CLIPSValue *);
|
|
292
|
+
bool Clear(Environment *);
|
|
293
|
+
void Reset(Environment *);
|
|
294
|
+
bool BatchStar(Environment *, const char *);
|
|
295
|
+
bool Save(Environment *, const char *);
|
|
296
|
+
bool Bsave(Environment *, const char *);
|
|
297
|
+
LoadError Load(Environment *, const char *);
|
|
298
|
+
bool Bload(Environment *, const char *);
|
|
299
|
+
|
|
300
|
+
/****************************/
|
|
301
|
+
/* Primitive Types Creation */
|
|
302
|
+
/****************************/
|
|
303
|
+
|
|
304
|
+
CLIPSLexeme *CreateSymbol(Environment *, const char *);
|
|
305
|
+
CLIPSLexeme *CreateString(Environment *, const char *);
|
|
306
|
+
CLIPSLexeme *CreateInstanceName(Environment *, const char *);
|
|
307
|
+
CLIPSLexeme *CreateBoolean(Environment *, bool);
|
|
308
|
+
CLIPSLexeme *FalseSymbol(Environment *);
|
|
309
|
+
CLIPSLexeme *TrueSymbol(Environment *);
|
|
310
|
+
CLIPSInteger *CreateInteger(Environment *, long long);
|
|
311
|
+
CLIPSFloat *CreateFloat(Environment *, double);
|
|
312
|
+
Multifield *EmptyMultifield(Environment *);
|
|
313
|
+
MultifieldBuilder *CreateMultifieldBuilder(Environment *, size_t);
|
|
314
|
+
Multifield *MBCreate(MultifieldBuilder *);
|
|
315
|
+
void MBReset(MultifieldBuilder *);
|
|
316
|
+
void MBDispose(MultifieldBuilder *);
|
|
317
|
+
void MBAppend(MultifieldBuilder *, CLIPSValue *);
|
|
318
|
+
CLIPSVoid *VoidConstant(Environment *);
|
|
319
|
+
CLIPSExternalAddress *CreateCExternalAddress(Environment *, void *);
|
|
320
|
+
StringBuilder *CreateStringBuilder(Environment *, size_t);
|
|
321
|
+
void SBReset(StringBuilder *);
|
|
322
|
+
void SBDispose(StringBuilder *);
|
|
323
|
+
|
|
324
|
+
/*********/
|
|
325
|
+
/* Facts */
|
|
326
|
+
/*********/
|
|
327
|
+
|
|
328
|
+
void RetainFact(Fact *);
|
|
329
|
+
void ReleaseFact(Fact *);
|
|
330
|
+
Fact *AssertString(Environment *, const char *);
|
|
331
|
+
AssertStringError GetAssertStringError(Environment *);
|
|
332
|
+
RetractError Retract(Fact *);
|
|
333
|
+
FactBuilder *CreateFactBuilder(Environment *, const char *);
|
|
334
|
+
Fact *FBAssert(FactBuilder *);
|
|
335
|
+
void FBDispose(FactBuilder *);
|
|
336
|
+
FactBuilderError FBSetDeftemplate(FactBuilder *, const char *);
|
|
337
|
+
void FBAbort(FactBuilder *);
|
|
338
|
+
FactBuilderError FBError(Environment *);
|
|
339
|
+
FactModifier *CreateFactModifier(Environment *, Fact *);
|
|
340
|
+
Fact *FMModify(FactModifier *);
|
|
341
|
+
void FMDispose(FactModifier *);
|
|
342
|
+
FactModifierError FMSetFact(FactModifier *, Fact *);
|
|
343
|
+
void FMAbort(FactModifier *);
|
|
344
|
+
FactModifierError FMError(Environment *);
|
|
345
|
+
RetractError RetractAllFacts(Environment *);
|
|
346
|
+
bool FactExistp(Fact *);
|
|
347
|
+
Deftemplate *FactDeftemplate(Fact *);
|
|
348
|
+
long long FactIndex(Fact *);
|
|
349
|
+
const char *DeftemplateName(Deftemplate *);
|
|
350
|
+
bool ImpliedDeftemplate(Deftemplate *);
|
|
351
|
+
bool DeftemplateIsDeletable(Deftemplate *);
|
|
352
|
+
bool Undeftemplate(Deftemplate *, Environment *);
|
|
353
|
+
void FactSlotNames(Fact *, CLIPSValue *);
|
|
354
|
+
void DeftemplateSlotNames(Deftemplate *, CLIPSValue *);
|
|
355
|
+
Deftemplate *FindDeftemplate(Environment *, const char *);
|
|
356
|
+
Fact *GetNextFact(Environment *, Fact *);
|
|
357
|
+
Fact *GetNextFactInTemplate(Deftemplate *, Fact *);
|
|
358
|
+
bool LoadFacts(Environment *, const char *);
|
|
359
|
+
bool LoadFactsFromString(Environment *, const char *, size_t);
|
|
360
|
+
bool SaveFacts(Environment *, const char *, SaveScope);
|
|
361
|
+
const char *DeftemplatePPForm(Deftemplate *);
|
|
362
|
+
bool DeftemplateSlotAllowedValues(Deftemplate *, const char *, CLIPSValue *);
|
|
363
|
+
bool DeftemplateSlotCardinality(Deftemplate *, const char *, CLIPSValue *);
|
|
364
|
+
bool DeftemplateSlotRange(Deftemplate *, const char *, CLIPSValue *);
|
|
365
|
+
bool DeftemplateSlotDefaultValue(Deftemplate *, const char *, CLIPSValue *);
|
|
366
|
+
bool DeftemplateSlotTypes(Deftemplate *, const char *, CLIPSValue *);
|
|
367
|
+
bool DeftemplateSlotExistP(Deftemplate *, const char *);
|
|
368
|
+
bool DeftemplateSlotMultiP(Deftemplate *, const char *);
|
|
369
|
+
bool DeftemplateSlotSingleP(Deftemplate *, const char *);
|
|
370
|
+
DefaultType DeftemplateSlotDefaultP(Deftemplate *, const char *);
|
|
371
|
+
bool GetFactDuplication(Environment *);
|
|
372
|
+
bool SetFactDuplication(Environment *, bool);
|
|
373
|
+
const char *DeftemplateModule(Deftemplate *);
|
|
374
|
+
Deftemplate *GetNextDeftemplate(Environment *, Deftemplate *);
|
|
375
|
+
bool DeftemplateGetWatch(Deftemplate *);
|
|
376
|
+
void DeftemplateSetWatch(Deftemplate *, bool);
|
|
377
|
+
void FactPPForm(Fact *, StringBuilder *, bool);
|
|
378
|
+
Deffacts *FindDeffacts(Environment *, const char *);
|
|
379
|
+
Deffacts *GetNextDeffacts(Environment *, Deffacts *);
|
|
380
|
+
const char *DeffactsModule(Deffacts *);
|
|
381
|
+
const char *DeffactsName(Deffacts *);
|
|
382
|
+
const char *DeffactsPPForm(Deffacts *);
|
|
383
|
+
bool DeffactsIsDeletable(Deffacts *);
|
|
384
|
+
bool Undeffacts(Deffacts *, Environment *);
|
|
385
|
+
|
|
386
|
+
/*************/
|
|
387
|
+
/* Instances */
|
|
388
|
+
/*************/
|
|
389
|
+
|
|
390
|
+
void RetainInstance(Instance *);
|
|
391
|
+
void ReleaseInstance(Instance *);
|
|
392
|
+
Instance *MakeInstance(Environment *, const char *);
|
|
393
|
+
MakeInstanceError GetMakeInstanceError(Environment *);
|
|
394
|
+
UnmakeInstanceError UnmakeInstance(Instance *);
|
|
395
|
+
UnmakeInstanceError DeleteInstance(Instance *);
|
|
396
|
+
InstanceBuilder *CreateInstanceBuilder(Environment *, const char *);
|
|
397
|
+
Instance *IBMake(InstanceBuilder *, const char *);
|
|
398
|
+
void IBDispose(InstanceBuilder *);
|
|
399
|
+
InstanceBuilderError IBSetDefclass(InstanceBuilder *, const char *);
|
|
400
|
+
InstanceBuilderError IBError(Environment *);
|
|
401
|
+
InstanceModifier *CreateInstanceModifier(Environment *, Instance *);
|
|
402
|
+
Instance *IMModify(InstanceModifier *);
|
|
403
|
+
void IMDispose(InstanceModifier *);
|
|
404
|
+
InstanceModifierError IMSetInstance(InstanceModifier *, Instance *);
|
|
405
|
+
InstanceModifierError IMError(Environment *);
|
|
406
|
+
Defclass *FindDefclass(Environment *, const char *);
|
|
407
|
+
Defclass *GetNextDefclass(Environment *, Defclass *);
|
|
408
|
+
const char *DefclassModule(Defclass *);
|
|
409
|
+
const char *DefclassName(Defclass *);
|
|
410
|
+
const char *DefclassPPForm(Defclass *);
|
|
411
|
+
void ClassSlots(Defclass *, CLIPSValue *, bool);
|
|
412
|
+
void ClassSubclasses(Defclass *, CLIPSValue *, bool);
|
|
413
|
+
void ClassSuperclasses(Defclass *, CLIPSValue *, bool);
|
|
414
|
+
bool DefclassIsDeletable(Defclass *);
|
|
415
|
+
bool Undefclass(Defclass *, Environment *);
|
|
416
|
+
bool DefclassGetWatchInstances(Defclass *);
|
|
417
|
+
bool DefclassGetWatchSlots(Defclass *);
|
|
418
|
+
void DefclassSetWatchInstances(Defclass *, bool);
|
|
419
|
+
void DefclassSetWatchSlots(Defclass *, bool);
|
|
420
|
+
bool ClassAbstractP(Defclass *);
|
|
421
|
+
bool ClassReactiveP(Defclass *);
|
|
422
|
+
bool SubclassP(Defclass *, Defclass *);
|
|
423
|
+
bool SuperclassP(Defclass *, Defclass *);
|
|
424
|
+
bool SlotAllowedClasses(Defclass *, const char *, CLIPSValue *);
|
|
425
|
+
bool SlotAllowedValues(Defclass *, const char *, CLIPSValue *);
|
|
426
|
+
bool SlotCardinality(Defclass *, const char *, CLIPSValue *);
|
|
427
|
+
bool SlotDefaultValue(Defclass *, const char *, CLIPSValue *);
|
|
428
|
+
bool SlotFacets(Defclass *, const char *, CLIPSValue *);
|
|
429
|
+
bool SlotRange(Defclass *, const char *, CLIPSValue *);
|
|
430
|
+
bool SlotSources(Defclass *, const char *, CLIPSValue *);
|
|
431
|
+
bool SlotTypes(Defclass *, const char *, CLIPSValue *);
|
|
432
|
+
bool SlotDirectAccessP(Defclass *, const char *);
|
|
433
|
+
bool SlotExistP(Defclass *, const char *, bool);
|
|
434
|
+
bool SlotInitableP(Defclass *, const char *);
|
|
435
|
+
bool SlotPublicP(Defclass *, const char *);
|
|
436
|
+
bool SlotWritableP(Defclass *, const char *);
|
|
437
|
+
ClassDefaultsMode GetClassDefaultsMode(Environment *);
|
|
438
|
+
ClassDefaultsMode SetClassDefaultsMode(Environment *, ClassDefaultsMode);
|
|
439
|
+
Instance *FindInstance(Environment *, Defmodule *, const char *, bool);
|
|
440
|
+
Instance *GetNextInstance(Environment *, Instance *);
|
|
441
|
+
Instance *GetNextInstanceInClass(Defclass *, Instance *);
|
|
442
|
+
Defclass *InstanceClass(Instance *);
|
|
443
|
+
const char *InstanceName(Instance *);
|
|
444
|
+
void InstancePPForm(Instance *, StringBuilder *);
|
|
445
|
+
void Send(Environment *, CLIPSValue *, const char *,
|
|
446
|
+
const char *, CLIPSValue *);
|
|
447
|
+
unsigned FindDefmessageHandler(Defclass *, const char *, const char *);
|
|
448
|
+
unsigned GetNextDefmessageHandler(Defclass *, unsigned);
|
|
449
|
+
const char *DefmessageHandlerName(Defclass *, unsigned);
|
|
450
|
+
const char *DefmessageHandlerPPForm(Defclass *, unsigned);
|
|
451
|
+
const char *DefmessageHandlerType(Defclass *, unsigned);
|
|
452
|
+
bool DefmessageHandlerIsDeletable(Defclass *, unsigned);
|
|
453
|
+
bool UndefmessageHandler(Defclass *, unsigned, Environment *);
|
|
454
|
+
bool DefmessageHandlerGetWatch(Defclass *, unsigned);
|
|
455
|
+
void DefmessageHandlerSetWatch(Defclass *, unsigned, bool);
|
|
456
|
+
Definstances *FindDefinstances(Environment *, const char *);
|
|
457
|
+
Definstances *GetNextDefinstances(Environment *, Definstances *);
|
|
458
|
+
const char *DefinstancesModule(Definstances *);
|
|
459
|
+
const char *DefinstancesName(Definstances *);
|
|
460
|
+
const char *DefinstancesPPForm(Definstances *);
|
|
461
|
+
bool DefinstancesIsDeletable(Definstances *);
|
|
462
|
+
bool Undefinstances(Definstances *, Environment *);
|
|
463
|
+
bool GetInstancesChanged(Environment *);
|
|
464
|
+
void SetInstancesChanged(Environment *, bool);
|
|
465
|
+
long BinaryLoadInstances(Environment *, const char *);
|
|
466
|
+
long LoadInstances(Environment *, const char *);
|
|
467
|
+
long LoadInstancesFromString(Environment *, const char *, size_t);
|
|
468
|
+
long RestoreInstances(Environment *, const char *);
|
|
469
|
+
long RestoreInstancesFromString(Environment *, const char *, size_t);
|
|
470
|
+
long BinarySaveInstances(Environment *, const char *, SaveScope);
|
|
471
|
+
long SaveInstances(Environment *, const char *, SaveScope);
|
|
472
|
+
|
|
473
|
+
/*********/
|
|
474
|
+
/* Slots */
|
|
475
|
+
/*********/
|
|
476
|
+
|
|
477
|
+
PutSlotError IBPutSlot(InstanceBuilder *, const char *, CLIPSValue *);
|
|
478
|
+
PutSlotError IMPutSlot(InstanceModifier *, const char *, CLIPSValue *);
|
|
479
|
+
PutSlotError FBPutSlot(FactBuilder *, const char *, CLIPSValue *);
|
|
480
|
+
PutSlotError FMPutSlot(FactModifier *, const char *, CLIPSValue *);
|
|
481
|
+
GetSlotError GetFactSlot(Fact *, const char *, CLIPSValue *);
|
|
482
|
+
GetSlotError DirectGetSlot(Instance *, const char *, CLIPSValue *);
|
|
483
|
+
|
|
484
|
+
/**********/
|
|
485
|
+
/* Agenda */
|
|
486
|
+
/**********/
|
|
487
|
+
|
|
488
|
+
Activation *GetNextActivation(Environment *, Activation *);
|
|
489
|
+
const char *ActivationRuleName(Activation *);
|
|
490
|
+
void ActivationPPForm(Activation *, StringBuilder *);
|
|
491
|
+
int ActivationGetSalience(Activation *);
|
|
492
|
+
int ActivationSetSalience(Activation *, int);
|
|
493
|
+
void RefreshAgenda(Defmodule *);
|
|
494
|
+
void RefreshAllAgendas(Environment *);
|
|
495
|
+
void ReorderAgenda(Defmodule *);
|
|
496
|
+
void ReorderAllAgendas(Environment *);
|
|
497
|
+
void DeleteActivation(Activation *);
|
|
498
|
+
bool GetAgendaChanged(Environment *);
|
|
499
|
+
void SetAgendaChanged(Environment *, bool);
|
|
500
|
+
SalienceEvaluationType GetSalienceEvaluation(Environment *);
|
|
501
|
+
SalienceEvaluationType SetSalienceEvaluation(Environment *,
|
|
502
|
+
SalienceEvaluationType);
|
|
503
|
+
StrategyType GetStrategy(Environment *);
|
|
504
|
+
StrategyType SetStrategy(Environment *, StrategyType);
|
|
505
|
+
Defrule *FindDefrule(Environment *, const char *);
|
|
506
|
+
Defrule *GetNextDefrule(Environment *, Defrule *);
|
|
507
|
+
const char *DefruleModule(Defrule *);
|
|
508
|
+
const char *DefruleName(Defrule *);
|
|
509
|
+
const char *DefrulePPForm(Defrule *);
|
|
510
|
+
bool DefruleIsDeletable(Defrule *);
|
|
511
|
+
bool Undefrule(Defrule *, Environment *);
|
|
512
|
+
bool DefruleGetWatchActivations(Defrule *);
|
|
513
|
+
bool DefruleGetWatchFirings(Defrule *);
|
|
514
|
+
void DefruleSetWatchActivations(Defrule *, bool);
|
|
515
|
+
void DefruleSetWatchFirings(Defrule *, bool);
|
|
516
|
+
bool DefruleHasBreakpoint(Defrule *);
|
|
517
|
+
bool RemoveBreak(Defrule *);
|
|
518
|
+
void SetBreak(Defrule *);
|
|
519
|
+
void Matches(Defrule *, Verbosity, CLIPSValue *);
|
|
520
|
+
void Refresh(Defrule *);
|
|
521
|
+
void ClearFocusStack(Environment *);
|
|
522
|
+
void Focus(Defmodule *);
|
|
523
|
+
Defmodule *PopFocus(Environment *);
|
|
524
|
+
Defmodule *GetFocus(Environment *);
|
|
525
|
+
void DeleteAllActivations(Defmodule *);
|
|
526
|
+
long long Run(Environment *, long long);
|
|
527
|
+
|
|
528
|
+
/*********************/
|
|
529
|
+
/* Modules & Globals */
|
|
530
|
+
/*********************/
|
|
531
|
+
|
|
532
|
+
Defmodule *FindDefmodule(Environment *, const char *);
|
|
533
|
+
Defmodule *GetNextDefmodule(Environment *, Defmodule *);
|
|
534
|
+
const char *DefmoduleName(Defmodule *);
|
|
535
|
+
const char *DefmodulePPForm(Defmodule *);
|
|
536
|
+
Defmodule *GetCurrentModule(Environment *);
|
|
537
|
+
Defmodule *SetCurrentModule(Environment *, Defmodule *);
|
|
538
|
+
Defglobal *FindDefglobal(Environment *, const char *);
|
|
539
|
+
Defglobal *GetNextDefglobal(Environment *, Defglobal *);
|
|
540
|
+
const char *DefglobalModule(Defglobal *);
|
|
541
|
+
const char *DefglobalName(Defglobal *);
|
|
542
|
+
const char *DefglobalPPForm(Defglobal *);
|
|
543
|
+
void DefglobalValueForm(Defglobal *, StringBuilder *);
|
|
544
|
+
void DefglobalGetValue(Defglobal *, CLIPSValue *);
|
|
545
|
+
void DefglobalSetValue(Defglobal *, CLIPSValue *);
|
|
546
|
+
bool DefglobalIsDeletable(Defglobal *);
|
|
547
|
+
bool Undefglobal(Defglobal *, Environment *);
|
|
548
|
+
bool DefglobalGetWatch(Defglobal *);
|
|
549
|
+
void DefglobalSetWatch(Defglobal *, bool);
|
|
550
|
+
bool GetGlobalsChanged(Environment *);
|
|
551
|
+
void SetGlobalsChanged(Environment *, bool);
|
|
552
|
+
bool GetResetGlobals(Environment *);
|
|
553
|
+
bool SetResetGlobals(Environment *, bool);
|
|
554
|
+
|
|
555
|
+
/*********************************/
|
|
556
|
+
/* Functions, Generics & Methods */
|
|
557
|
+
/*********************************/
|
|
558
|
+
|
|
559
|
+
Deffunction *FindDeffunction(Environment *, const char *);
|
|
560
|
+
Deffunction *GetNextDeffunction(Environment *, Deffunction *);
|
|
561
|
+
const char *DeffunctionModule(Deffunction *);
|
|
562
|
+
const char *DeffunctionName(Deffunction *);
|
|
563
|
+
const char *DeffunctionPPForm(Deffunction *);
|
|
564
|
+
bool DeffunctionIsDeletable(Deffunction *);
|
|
565
|
+
bool Undeffunction(Deffunction *, Environment *);
|
|
566
|
+
bool DeffunctionGetWatch(Deffunction *);
|
|
567
|
+
void DeffunctionSetWatch(Deffunction *, bool);
|
|
568
|
+
Defgeneric *FindDefgeneric(Environment *, const char *);
|
|
569
|
+
Defgeneric *GetNextDefgeneric(Environment *, Defgeneric *);
|
|
570
|
+
const char *DefgenericModule(Defgeneric *);
|
|
571
|
+
const char *DefgenericName(Defgeneric *);
|
|
572
|
+
const char *DefgenericPPForm(Defgeneric *);
|
|
573
|
+
bool DefgenericIsDeletable(Defgeneric *);
|
|
574
|
+
bool Undefgeneric(Defgeneric *, Environment *);
|
|
575
|
+
bool DefgenericGetWatch(Defgeneric *);
|
|
576
|
+
void DefgenericSetWatch(Defgeneric *, bool);
|
|
577
|
+
unsigned GetNextDefmethod(Defgeneric *, unsigned);
|
|
578
|
+
void DefmethodDescription(Defgeneric *, unsigned, StringBuilder *);
|
|
579
|
+
const char *DefmethodPPForm(Defgeneric *, unsigned);
|
|
580
|
+
void GetMethodRestrictions(Defgeneric *, unsigned, CLIPSValue *);
|
|
581
|
+
bool DefmethodIsDeletable(Defgeneric *, unsigned);
|
|
582
|
+
bool Undefmethod(Defgeneric *, unsigned, Environment *);
|
|
583
|
+
bool DefmethodGetWatch(Defgeneric *, unsigned);
|
|
584
|
+
void DefmethodSetWatch(Defgeneric *, unsigned, bool);
|
|
585
|
+
FunctionCallBuilder *CreateFunctionCallBuilder(Environment *, size_t);
|
|
586
|
+
FunctionCallBuilderError FCBCall(FunctionCallBuilder *, const char *,
|
|
587
|
+
CLIPSValue *);
|
|
588
|
+
void FCBReset(FunctionCallBuilder *);
|
|
589
|
+
void FCBDispose(FunctionCallBuilder *);
|
|
590
|
+
void FCBAppend(FunctionCallBuilder *, CLIPSValue *);
|
|
591
|
+
|
|
592
|
+
/***********/
|
|
593
|
+
/* Routers */
|
|
594
|
+
/***********/
|
|
595
|
+
|
|
596
|
+
typedef bool RouterQueryFunction(Environment *, const char *, void *);
|
|
597
|
+
typedef void RouterWriteFunction(Environment *, const char *, const char *,
|
|
598
|
+
void *);
|
|
599
|
+
typedef int RouterReadFunction(Environment *, const char *, void *);
|
|
600
|
+
typedef int RouterUnreadFunction(Environment *, const char *, int, void *);
|
|
601
|
+
typedef void RouterExitFunction(Environment *, int, void *);
|
|
602
|
+
extern "Python" bool query_function(Environment *, const char *, void *);
|
|
603
|
+
extern "Python" void write_function(Environment *, const char *, const char *,
|
|
604
|
+
void *);
|
|
605
|
+
extern "Python" int read_function(Environment *, const char *, void *);
|
|
606
|
+
extern "Python" int unread_function(Environment *, const char *, int, void *);
|
|
607
|
+
extern "Python" void exit_function(Environment *, int, void *);
|
|
608
|
+
bool AddRouter(Environment *, const char *, int, RouterQueryFunction *,
|
|
609
|
+
RouterWriteFunction *, RouterReadFunction *,
|
|
610
|
+
RouterUnreadFunction *, RouterExitFunction *, void *);
|
|
611
|
+
bool DeleteRouter(Environment *, const char *);
|
|
612
|
+
void WriteString(Environment *, const char *, const char *);
|
|
613
|
+
void WriteCLIPSValue(Environment *, const char *, CLIPSValue *);
|
|
614
|
+
int ReadRouter(Environment *, const char *);
|
|
615
|
+
int UnreadRouter(Environment *, const char *, int);
|
|
616
|
+
void ExitRouter(Environment *, int);
|
|
617
|
+
bool ActivateRouter(Environment *, const char *);
|
|
618
|
+
bool DeactivateRouter(Environment *, const char *);
|
|
619
|
+
|
|
620
|
+
/**************************/
|
|
621
|
+
/* User Defined Functions */
|
|
622
|
+
/**************************/
|
|
623
|
+
|
|
624
|
+
typedef void UserDefinedFunction(Environment *, UDFContext *, UDFValue *);
|
|
625
|
+
AddUDFError AddUDF(Environment *, const char *, const char *,
|
|
626
|
+
unsigned short, unsigned short, const char *,
|
|
627
|
+
UserDefinedFunction *, const char *, void *);
|
|
628
|
+
unsigned UDFArgumentCount(UDFContext *);
|
|
629
|
+
bool UDFFirstArgument(UDFContext *, unsigned, UDFValue *);
|
|
630
|
+
bool UDFNextArgument(UDFContext *, unsigned, UDFValue *);
|
|
631
|
+
bool UDFNthArgument(UDFContext *, unsigned, unsigned, UDFValue *);
|
|
632
|
+
bool UDFHasNextArgument(UDFContext *);
|
|
633
|
+
void UDFThrowError(UDFContext *);
|
|
634
|
+
void SetErrorValue(Environment *, TypeHeader *);
|
|
635
|
+
void GetErrorFunction(Environment *, UDFContext *, UDFValue *);
|
|
636
|
+
void ClearErrorValue(Environment *);
|
|
637
|
+
int DefinePythonFunction(Environment *);
|
|
638
|
+
extern "Python" static void python_function(Environment *, UDFContext *,
|
|
639
|
+
UDFValue *);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: clipspyx-ffi
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Shared CFFI build infrastructure for clipspyx
|
|
5
|
+
License-Expression: BSD-3-Clause
|
|
6
|
+
Project-URL: Homepage, https://github.com/inferal-oss/clipspyx
|
|
7
|
+
Project-URL: Repository, https://github.com/inferal-oss/clipspyx
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Requires-Dist: cffi>=1.0.0
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
pyproject.toml
|
|
2
|
+
clipspyx_ffi/__init__.py
|
|
3
|
+
clipspyx_ffi/build.py
|
|
4
|
+
clipspyx_ffi/clips-70x.cdef
|
|
5
|
+
clipspyx_ffi/clips.cdef
|
|
6
|
+
clipspyx_ffi.egg-info/PKG-INFO
|
|
7
|
+
clipspyx_ffi.egg-info/SOURCES.txt
|
|
8
|
+
clipspyx_ffi.egg-info/dependency_links.txt
|
|
9
|
+
clipspyx_ffi.egg-info/requires.txt
|
|
10
|
+
clipspyx_ffi.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cffi>=1.0.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
clipspyx_ffi
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "clipspyx-ffi"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Shared CFFI build infrastructure for clipspyx"
|
|
5
|
+
license = "BSD-3-Clause"
|
|
6
|
+
requires-python = ">=3.10"
|
|
7
|
+
dependencies = ["cffi>=1.0.0"]
|
|
8
|
+
|
|
9
|
+
[project.urls]
|
|
10
|
+
Homepage = "https://github.com/inferal-oss/clipspyx"
|
|
11
|
+
Repository = "https://github.com/inferal-oss/clipspyx"
|
|
12
|
+
|
|
13
|
+
[build-system]
|
|
14
|
+
requires = ["setuptools>=42"]
|
|
15
|
+
build-backend = "setuptools.build_meta"
|
|
16
|
+
|
|
17
|
+
[tool.setuptools.packages.find]
|
|
18
|
+
include = ["clipspyx_ffi*"]
|
|
19
|
+
|
|
20
|
+
[tool.setuptools.package-data]
|
|
21
|
+
clipspyx_ffi = ["*.cdef"]
|