clipsruby 0.0.2
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.
- checksums.yaml +7 -0
- data/ext/clipsruby/agenda.c +1373 -0
- data/ext/clipsruby/agenda.h +169 -0
- data/ext/clipsruby/analysis.c +1142 -0
- data/ext/clipsruby/analysis.h +61 -0
- data/ext/clipsruby/argacces.c +526 -0
- data/ext/clipsruby/argacces.h +77 -0
- data/ext/clipsruby/bload.c +884 -0
- data/ext/clipsruby/bload.h +94 -0
- data/ext/clipsruby/bmathfun.c +557 -0
- data/ext/clipsruby/bmathfun.h +66 -0
- data/ext/clipsruby/bsave.c +634 -0
- data/ext/clipsruby/bsave.h +130 -0
- data/ext/clipsruby/classcom.c +976 -0
- data/ext/clipsruby/classcom.h +115 -0
- data/ext/clipsruby/classexm.c +1376 -0
- data/ext/clipsruby/classexm.h +97 -0
- data/ext/clipsruby/classfun.c +1392 -0
- data/ext/clipsruby/classfun.h +164 -0
- data/ext/clipsruby/classinf.c +1245 -0
- data/ext/clipsruby/classinf.h +94 -0
- data/ext/clipsruby/classini.c +843 -0
- data/ext/clipsruby/classini.h +75 -0
- data/ext/clipsruby/classpsr.c +957 -0
- data/ext/clipsruby/classpsr.h +73 -0
- data/ext/clipsruby/clips.h +133 -0
- data/ext/clipsruby/clipsruby.c +619 -0
- data/ext/clipsruby/clsltpsr.c +931 -0
- data/ext/clipsruby/clsltpsr.h +72 -0
- data/ext/clipsruby/commline.c +1217 -0
- data/ext/clipsruby/commline.h +131 -0
- data/ext/clipsruby/conscomp.c +1593 -0
- data/ext/clipsruby/conscomp.h +150 -0
- data/ext/clipsruby/constant.h +264 -0
- data/ext/clipsruby/constrct.c +1090 -0
- data/ext/clipsruby/constrct.h +216 -0
- data/ext/clipsruby/constrnt.c +554 -0
- data/ext/clipsruby/constrnt.h +132 -0
- data/ext/clipsruby/crstrtgy.c +1088 -0
- data/ext/clipsruby/crstrtgy.h +85 -0
- data/ext/clipsruby/cstrcbin.c +185 -0
- data/ext/clipsruby/cstrcbin.h +61 -0
- data/ext/clipsruby/cstrccmp.h +43 -0
- data/ext/clipsruby/cstrccom.c +1791 -0
- data/ext/clipsruby/cstrccom.h +115 -0
- data/ext/clipsruby/cstrcpsr.c +835 -0
- data/ext/clipsruby/cstrcpsr.h +97 -0
- data/ext/clipsruby/cstrnbin.c +282 -0
- data/ext/clipsruby/cstrnbin.h +55 -0
- data/ext/clipsruby/cstrnchk.c +826 -0
- data/ext/clipsruby/cstrnchk.h +91 -0
- data/ext/clipsruby/cstrncmp.c +238 -0
- data/ext/clipsruby/cstrncmp.h +57 -0
- data/ext/clipsruby/cstrnops.c +1176 -0
- data/ext/clipsruby/cstrnops.h +47 -0
- data/ext/clipsruby/cstrnpsr.c +1394 -0
- data/ext/clipsruby/cstrnpsr.h +88 -0
- data/ext/clipsruby/cstrnutl.c +564 -0
- data/ext/clipsruby/cstrnutl.h +54 -0
- data/ext/clipsruby/default.c +454 -0
- data/ext/clipsruby/default.h +57 -0
- data/ext/clipsruby/defins.c +971 -0
- data/ext/clipsruby/defins.h +127 -0
- data/ext/clipsruby/developr.c +677 -0
- data/ext/clipsruby/developr.h +69 -0
- data/ext/clipsruby/dffctbin.c +477 -0
- data/ext/clipsruby/dffctbin.h +76 -0
- data/ext/clipsruby/dffctbsc.c +308 -0
- data/ext/clipsruby/dffctbsc.h +72 -0
- data/ext/clipsruby/dffctcmp.c +297 -0
- data/ext/clipsruby/dffctcmp.h +44 -0
- data/ext/clipsruby/dffctdef.c +364 -0
- data/ext/clipsruby/dffctdef.h +104 -0
- data/ext/clipsruby/dffctpsr.c +179 -0
- data/ext/clipsruby/dffctpsr.h +49 -0
- data/ext/clipsruby/dffnxbin.c +520 -0
- data/ext/clipsruby/dffnxbin.h +67 -0
- data/ext/clipsruby/dffnxcmp.c +378 -0
- data/ext/clipsruby/dffnxcmp.h +54 -0
- data/ext/clipsruby/dffnxexe.c +241 -0
- data/ext/clipsruby/dffnxexe.h +58 -0
- data/ext/clipsruby/dffnxfun.c +1192 -0
- data/ext/clipsruby/dffnxfun.h +155 -0
- data/ext/clipsruby/dffnxpsr.c +514 -0
- data/ext/clipsruby/dffnxpsr.h +57 -0
- data/ext/clipsruby/dfinsbin.c +509 -0
- data/ext/clipsruby/dfinsbin.h +66 -0
- data/ext/clipsruby/dfinscmp.c +345 -0
- data/ext/clipsruby/dfinscmp.h +48 -0
- data/ext/clipsruby/drive.c +1191 -0
- data/ext/clipsruby/drive.h +65 -0
- data/ext/clipsruby/emathfun.c +1213 -0
- data/ext/clipsruby/emathfun.h +99 -0
- data/ext/clipsruby/engine.c +1568 -0
- data/ext/clipsruby/engine.h +203 -0
- data/ext/clipsruby/entities.h +276 -0
- data/ext/clipsruby/envrnbld.c +514 -0
- data/ext/clipsruby/envrnbld.h +40 -0
- data/ext/clipsruby/envrnmnt.c +257 -0
- data/ext/clipsruby/envrnmnt.h +112 -0
- data/ext/clipsruby/evaluatn.c +1736 -0
- data/ext/clipsruby/evaluatn.h +211 -0
- data/ext/clipsruby/expressn.c +494 -0
- data/ext/clipsruby/expressn.h +154 -0
- data/ext/clipsruby/exprnbin.c +538 -0
- data/ext/clipsruby/exprnbin.h +60 -0
- data/ext/clipsruby/exprnops.c +564 -0
- data/ext/clipsruby/exprnops.h +67 -0
- data/ext/clipsruby/exprnpsr.c +1112 -0
- data/ext/clipsruby/exprnpsr.h +98 -0
- data/ext/clipsruby/extconf.rb +2 -0
- data/ext/clipsruby/extnfunc.c +1015 -0
- data/ext/clipsruby/extnfunc.h +157 -0
- data/ext/clipsruby/factbin.c +447 -0
- data/ext/clipsruby/factbin.h +56 -0
- data/ext/clipsruby/factbld.c +1035 -0
- data/ext/clipsruby/factbld.h +63 -0
- data/ext/clipsruby/factcmp.c +386 -0
- data/ext/clipsruby/factcmp.h +46 -0
- data/ext/clipsruby/factcom.c +759 -0
- data/ext/clipsruby/factcom.h +80 -0
- data/ext/clipsruby/factfile.c +1761 -0
- data/ext/clipsruby/factfile.h +54 -0
- data/ext/clipsruby/factfun.c +682 -0
- data/ext/clipsruby/factfun.h +77 -0
- data/ext/clipsruby/factgen.c +1305 -0
- data/ext/clipsruby/factgen.h +229 -0
- data/ext/clipsruby/facthsh.c +438 -0
- data/ext/clipsruby/facthsh.h +81 -0
- data/ext/clipsruby/factlhs.c +250 -0
- data/ext/clipsruby/factlhs.h +54 -0
- data/ext/clipsruby/factmch.c +905 -0
- data/ext/clipsruby/factmch.h +68 -0
- data/ext/clipsruby/factmngr.c +3373 -0
- data/ext/clipsruby/factmngr.h +325 -0
- data/ext/clipsruby/factprt.c +498 -0
- data/ext/clipsruby/factprt.h +60 -0
- data/ext/clipsruby/factqpsr.c +796 -0
- data/ext/clipsruby/factqpsr.h +61 -0
- data/ext/clipsruby/factqury.c +1267 -0
- data/ext/clipsruby/factqury.h +112 -0
- data/ext/clipsruby/factrete.c +978 -0
- data/ext/clipsruby/factrete.h +70 -0
- data/ext/clipsruby/factrhs.c +667 -0
- data/ext/clipsruby/factrhs.h +55 -0
- data/ext/clipsruby/filecom.c +353 -0
- data/ext/clipsruby/filecom.h +137 -0
- data/ext/clipsruby/filertr.c +481 -0
- data/ext/clipsruby/filertr.h +94 -0
- data/ext/clipsruby/fileutil.c +1020 -0
- data/ext/clipsruby/fileutil.h +50 -0
- data/ext/clipsruby/generate.c +1079 -0
- data/ext/clipsruby/generate.h +57 -0
- data/ext/clipsruby/genrcbin.c +902 -0
- data/ext/clipsruby/genrcbin.h +69 -0
- data/ext/clipsruby/genrccmp.c +640 -0
- data/ext/clipsruby/genrccmp.h +59 -0
- data/ext/clipsruby/genrccom.c +2017 -0
- data/ext/clipsruby/genrccom.h +119 -0
- data/ext/clipsruby/genrcexe.c +737 -0
- data/ext/clipsruby/genrcexe.h +73 -0
- data/ext/clipsruby/genrcfun.c +890 -0
- data/ext/clipsruby/genrcfun.h +185 -0
- data/ext/clipsruby/genrcpsr.c +1618 -0
- data/ext/clipsruby/genrcpsr.h +80 -0
- data/ext/clipsruby/globlbin.c +458 -0
- data/ext/clipsruby/globlbin.h +71 -0
- data/ext/clipsruby/globlbsc.c +361 -0
- data/ext/clipsruby/globlbsc.h +83 -0
- data/ext/clipsruby/globlcmp.c +330 -0
- data/ext/clipsruby/globlcmp.h +52 -0
- data/ext/clipsruby/globlcom.c +289 -0
- data/ext/clipsruby/globlcom.h +63 -0
- data/ext/clipsruby/globldef.c +1087 -0
- data/ext/clipsruby/globldef.h +151 -0
- data/ext/clipsruby/globlpsr.c +530 -0
- data/ext/clipsruby/globlpsr.h +59 -0
- data/ext/clipsruby/immthpsr.c +431 -0
- data/ext/clipsruby/immthpsr.h +55 -0
- data/ext/clipsruby/incrrset.c +530 -0
- data/ext/clipsruby/incrrset.h +73 -0
- data/ext/clipsruby/inherpsr.c +850 -0
- data/ext/clipsruby/inherpsr.h +52 -0
- data/ext/clipsruby/inscom.c +2076 -0
- data/ext/clipsruby/inscom.h +182 -0
- data/ext/clipsruby/insfile.c +1764 -0
- data/ext/clipsruby/insfile.h +96 -0
- data/ext/clipsruby/insfun.c +1451 -0
- data/ext/clipsruby/insfun.h +134 -0
- data/ext/clipsruby/insmngr.c +2550 -0
- data/ext/clipsruby/insmngr.h +125 -0
- data/ext/clipsruby/insmoddp.c +1041 -0
- data/ext/clipsruby/insmoddp.h +91 -0
- data/ext/clipsruby/insmult.c +804 -0
- data/ext/clipsruby/insmult.h +62 -0
- data/ext/clipsruby/inspsr.c +602 -0
- data/ext/clipsruby/inspsr.h +60 -0
- data/ext/clipsruby/insquery.c +1278 -0
- data/ext/clipsruby/insquery.h +115 -0
- data/ext/clipsruby/insqypsr.c +729 -0
- data/ext/clipsruby/insqypsr.h +63 -0
- data/ext/clipsruby/iofun.c +2045 -0
- data/ext/clipsruby/iofun.h +116 -0
- data/ext/clipsruby/lgcldpnd.c +644 -0
- data/ext/clipsruby/lgcldpnd.h +75 -0
- data/ext/clipsruby/main.c +112 -0
- data/ext/clipsruby/match.h +142 -0
- data/ext/clipsruby/memalloc.c +481 -0
- data/ext/clipsruby/memalloc.h +197 -0
- data/ext/clipsruby/miscfun.c +1801 -0
- data/ext/clipsruby/miscfun.h +132 -0
- data/ext/clipsruby/modulbin.c +607 -0
- data/ext/clipsruby/modulbin.h +84 -0
- data/ext/clipsruby/modulbsc.c +347 -0
- data/ext/clipsruby/modulbsc.h +67 -0
- data/ext/clipsruby/modulcmp.c +499 -0
- data/ext/clipsruby/modulcmp.h +54 -0
- data/ext/clipsruby/moduldef.c +817 -0
- data/ext/clipsruby/moduldef.h +271 -0
- data/ext/clipsruby/modulpsr.c +1150 -0
- data/ext/clipsruby/modulpsr.h +69 -0
- data/ext/clipsruby/modulutl.c +1036 -0
- data/ext/clipsruby/modulutl.h +84 -0
- data/ext/clipsruby/msgcom.c +1221 -0
- data/ext/clipsruby/msgcom.h +125 -0
- data/ext/clipsruby/msgfun.c +1076 -0
- data/ext/clipsruby/msgfun.h +118 -0
- data/ext/clipsruby/msgpass.c +1441 -0
- data/ext/clipsruby/msgpass.h +103 -0
- data/ext/clipsruby/msgpsr.c +698 -0
- data/ext/clipsruby/msgpsr.h +73 -0
- data/ext/clipsruby/multifld.c +1404 -0
- data/ext/clipsruby/multifld.h +130 -0
- data/ext/clipsruby/multifun.c +2182 -0
- data/ext/clipsruby/multifun.h +102 -0
- data/ext/clipsruby/network.h +142 -0
- data/ext/clipsruby/objbin.c +1522 -0
- data/ext/clipsruby/objbin.h +79 -0
- data/ext/clipsruby/objcmp.c +1507 -0
- data/ext/clipsruby/objcmp.h +71 -0
- data/ext/clipsruby/object.h +260 -0
- data/ext/clipsruby/objrtbin.c +701 -0
- data/ext/clipsruby/objrtbin.h +79 -0
- data/ext/clipsruby/objrtbld.c +2393 -0
- data/ext/clipsruby/objrtbld.h +66 -0
- data/ext/clipsruby/objrtcmp.c +734 -0
- data/ext/clipsruby/objrtcmp.h +66 -0
- data/ext/clipsruby/objrtfnx.c +1330 -0
- data/ext/clipsruby/objrtfnx.h +222 -0
- data/ext/clipsruby/objrtgen.c +736 -0
- data/ext/clipsruby/objrtgen.h +63 -0
- data/ext/clipsruby/objrtmch.c +1524 -0
- data/ext/clipsruby/objrtmch.h +160 -0
- data/ext/clipsruby/parsefun.c +415 -0
- data/ext/clipsruby/parsefun.h +67 -0
- data/ext/clipsruby/pattern.c +1265 -0
- data/ext/clipsruby/pattern.h +163 -0
- data/ext/clipsruby/pprint.c +328 -0
- data/ext/clipsruby/pprint.h +79 -0
- data/ext/clipsruby/prccode.c +1478 -0
- data/ext/clipsruby/prccode.h +145 -0
- data/ext/clipsruby/prcdrfun.c +640 -0
- data/ext/clipsruby/prcdrfun.h +95 -0
- data/ext/clipsruby/prcdrpsr.c +1068 -0
- data/ext/clipsruby/prcdrpsr.h +79 -0
- data/ext/clipsruby/prdctfun.c +869 -0
- data/ext/clipsruby/prdctfun.h +77 -0
- data/ext/clipsruby/prntutil.c +878 -0
- data/ext/clipsruby/prntutil.h +125 -0
- data/ext/clipsruby/proflfun.c +827 -0
- data/ext/clipsruby/proflfun.h +118 -0
- data/ext/clipsruby/reorder.c +2082 -0
- data/ext/clipsruby/reorder.h +172 -0
- data/ext/clipsruby/reteutil.c +1732 -0
- data/ext/clipsruby/reteutil.h +111 -0
- data/ext/clipsruby/retract.c +710 -0
- data/ext/clipsruby/retract.h +74 -0
- data/ext/clipsruby/router.c +737 -0
- data/ext/clipsruby/router.h +147 -0
- data/ext/clipsruby/rulebin.c +1136 -0
- data/ext/clipsruby/rulebin.h +153 -0
- data/ext/clipsruby/rulebld.c +1328 -0
- data/ext/clipsruby/rulebld.h +62 -0
- data/ext/clipsruby/rulebsc.c +517 -0
- data/ext/clipsruby/rulebsc.h +91 -0
- data/ext/clipsruby/rulecmp.c +733 -0
- data/ext/clipsruby/rulecmp.h +63 -0
- data/ext/clipsruby/rulecom.c +1583 -0
- data/ext/clipsruby/rulecom.h +116 -0
- data/ext/clipsruby/rulecstr.c +892 -0
- data/ext/clipsruby/rulecstr.h +53 -0
- data/ext/clipsruby/ruledef.c +559 -0
- data/ext/clipsruby/ruledef.h +179 -0
- data/ext/clipsruby/ruledlt.c +599 -0
- data/ext/clipsruby/ruledlt.h +58 -0
- data/ext/clipsruby/rulelhs.c +1216 -0
- data/ext/clipsruby/rulelhs.h +52 -0
- data/ext/clipsruby/rulepsr.c +1073 -0
- data/ext/clipsruby/rulepsr.h +61 -0
- data/ext/clipsruby/scanner.c +856 -0
- data/ext/clipsruby/scanner.h +112 -0
- data/ext/clipsruby/setup.h +488 -0
- data/ext/clipsruby/sortfun.c +433 -0
- data/ext/clipsruby/sortfun.h +55 -0
- data/ext/clipsruby/strngfun.c +1173 -0
- data/ext/clipsruby/strngfun.h +96 -0
- data/ext/clipsruby/strngrtr.c +523 -0
- data/ext/clipsruby/strngrtr.h +97 -0
- data/ext/clipsruby/symblbin.c +648 -0
- data/ext/clipsruby/symblbin.h +64 -0
- data/ext/clipsruby/symblcmp.c +893 -0
- data/ext/clipsruby/symblcmp.h +61 -0
- data/ext/clipsruby/symbol.c +1961 -0
- data/ext/clipsruby/symbol.h +243 -0
- data/ext/clipsruby/sysdep.c +894 -0
- data/ext/clipsruby/sysdep.h +164 -0
- data/ext/clipsruby/textpro.c +1388 -0
- data/ext/clipsruby/textpro.h +77 -0
- data/ext/clipsruby/tmpltbin.c +609 -0
- data/ext/clipsruby/tmpltbin.h +108 -0
- data/ext/clipsruby/tmpltbsc.c +327 -0
- data/ext/clipsruby/tmpltbsc.h +87 -0
- data/ext/clipsruby/tmpltcmp.c +450 -0
- data/ext/clipsruby/tmpltcmp.h +57 -0
- data/ext/clipsruby/tmpltdef.c +584 -0
- data/ext/clipsruby/tmpltdef.h +155 -0
- data/ext/clipsruby/tmpltfun.c +2477 -0
- data/ext/clipsruby/tmpltfun.h +122 -0
- data/ext/clipsruby/tmpltlhs.c +379 -0
- data/ext/clipsruby/tmpltlhs.h +50 -0
- data/ext/clipsruby/tmpltpsr.c +819 -0
- data/ext/clipsruby/tmpltpsr.h +59 -0
- data/ext/clipsruby/tmpltrhs.c +595 -0
- data/ext/clipsruby/tmpltrhs.h +55 -0
- data/ext/clipsruby/tmpltutl.c +637 -0
- data/ext/clipsruby/tmpltutl.h +82 -0
- data/ext/clipsruby/userdata.c +156 -0
- data/ext/clipsruby/userdata.h +72 -0
- data/ext/clipsruby/userfunctions.c +70 -0
- data/ext/clipsruby/usrsetup.h +7 -0
- data/ext/clipsruby/utility.c +1594 -0
- data/ext/clipsruby/utility.h +250 -0
- data/ext/clipsruby/watch.c +865 -0
- data/ext/clipsruby/watch.h +124 -0
- data/lib/clipsruby.rb +1 -0
- metadata +388 -0
@@ -0,0 +1,157 @@
|
|
1
|
+
/*******************************************************/
|
2
|
+
/* "C" Language Integrated Production System */
|
3
|
+
/* */
|
4
|
+
/* CLIPS Version 6.40 10/24/17 */
|
5
|
+
/* */
|
6
|
+
/* EXTERNAL FUNCTIONS HEADER FILE */
|
7
|
+
/*******************************************************/
|
8
|
+
|
9
|
+
/*************************************************************/
|
10
|
+
/* Purpose: Routines for adding new user or system defined */
|
11
|
+
/* functions. */
|
12
|
+
/* */
|
13
|
+
/* Principal Programmer(s): */
|
14
|
+
/* Gary D. Riley */
|
15
|
+
/* */
|
16
|
+
/* Contributing Programmer(s): */
|
17
|
+
/* */
|
18
|
+
/* Revision History: */
|
19
|
+
/* */
|
20
|
+
/* 6.24: Renamed BOOLEAN macro type to intBool. */
|
21
|
+
/* */
|
22
|
+
/* 6.30: Added support for passing context information */
|
23
|
+
/* to user defined functions. */
|
24
|
+
/* */
|
25
|
+
/* Support for long long integers. */
|
26
|
+
/* */
|
27
|
+
/* Added const qualifiers to remove C++ */
|
28
|
+
/* deprecation warnings. */
|
29
|
+
/* */
|
30
|
+
/* Replaced ALLOW_ENVIRONMENT_GLOBALS macros */
|
31
|
+
/* with functions. */
|
32
|
+
/* */
|
33
|
+
/* 6.40: Changed restrictions from char * to */
|
34
|
+
/* CLIPSLexeme * to support strings */
|
35
|
+
/* originating from sources that are not */
|
36
|
+
/* statically allocated. */
|
37
|
+
/* */
|
38
|
+
/* Removed LOCALE definition. */
|
39
|
+
/* */
|
40
|
+
/* Pragma once and other inclusion changes. */
|
41
|
+
/* */
|
42
|
+
/* Added support for booleans with <stdbool.h>. */
|
43
|
+
/* */
|
44
|
+
/* Removed use of void pointers for specific */
|
45
|
+
/* data structures. */
|
46
|
+
/* */
|
47
|
+
/* ALLOW_ENVIRONMENT_GLOBALS no longer supported. */
|
48
|
+
/* */
|
49
|
+
/* Callbacks must be environment aware. */
|
50
|
+
/* */
|
51
|
+
/* UDF redesign. */
|
52
|
+
/* */
|
53
|
+
/*************************************************************/
|
54
|
+
|
55
|
+
#ifndef _H_extnfunc
|
56
|
+
|
57
|
+
#pragma once
|
58
|
+
|
59
|
+
#define _H_extnfunc
|
60
|
+
|
61
|
+
#include "entities.h"
|
62
|
+
|
63
|
+
#include "evaluatn.h"
|
64
|
+
#include "expressn.h"
|
65
|
+
#include "symbol.h"
|
66
|
+
#include "userdata.h"
|
67
|
+
|
68
|
+
typedef void UserDefinedFunction(Environment *,UDFContext *,UDFValue *);
|
69
|
+
|
70
|
+
struct functionDefinition
|
71
|
+
{
|
72
|
+
CLIPSLexeme *callFunctionName;
|
73
|
+
const char *actualFunctionName;
|
74
|
+
unsigned unknownReturnValueType;
|
75
|
+
void (*functionPointer)(Environment *,UDFContext *,UDFValue *);
|
76
|
+
struct expr *(*parser)(Environment *,struct expr *,const char *);
|
77
|
+
CLIPSLexeme *restrictions;
|
78
|
+
unsigned short minArgs;
|
79
|
+
unsigned short maxArgs;
|
80
|
+
bool overloadable;
|
81
|
+
bool sequenceuseok;
|
82
|
+
bool neededFunction;
|
83
|
+
unsigned long bsaveIndex;
|
84
|
+
struct functionDefinition *next;
|
85
|
+
struct userData *usrData;
|
86
|
+
void *context;
|
87
|
+
};
|
88
|
+
|
89
|
+
#define UnknownFunctionType(target) (((struct functionDefinition *) target)->unknownReturnValueType)
|
90
|
+
#define ExpressionFunctionPointer(target) ((target)->functionValue->functionPointer)
|
91
|
+
#define ExpressionFunctionCallName(target) ((target)->functionValue->callFunctionName)
|
92
|
+
#define ExpressionFunctionRealName(target) ((target)->functionValue->actualFunctionName)
|
93
|
+
#define ExpressionUnknownFunctionType(target) ((target)->functionValue->unknownReturnValueType)
|
94
|
+
|
95
|
+
/*==================*/
|
96
|
+
/* ENVIRONMENT DATA */
|
97
|
+
/*==================*/
|
98
|
+
|
99
|
+
#define EXTERNAL_FUNCTION_DATA 50
|
100
|
+
|
101
|
+
struct externalFunctionData
|
102
|
+
{
|
103
|
+
struct functionDefinition *ListOfFunctions;
|
104
|
+
struct FunctionHash **FunctionHashtable;
|
105
|
+
};
|
106
|
+
|
107
|
+
#define ExternalFunctionData(theEnv) ((struct externalFunctionData *) GetEnvironmentData(theEnv,EXTERNAL_FUNCTION_DATA))
|
108
|
+
|
109
|
+
typedef enum
|
110
|
+
{
|
111
|
+
AUE_NO_ERROR = 0,
|
112
|
+
AUE_MIN_EXCEEDS_MAX_ERROR,
|
113
|
+
AUE_FUNCTION_NAME_IN_USE_ERROR,
|
114
|
+
AUE_INVALID_ARGUMENT_TYPE_ERROR,
|
115
|
+
AUE_INVALID_RETURN_TYPE_ERROR
|
116
|
+
} AddUDFError;
|
117
|
+
|
118
|
+
struct FunctionHash
|
119
|
+
{
|
120
|
+
struct functionDefinition *fdPtr;
|
121
|
+
struct FunctionHash *next;
|
122
|
+
};
|
123
|
+
|
124
|
+
#define SIZE_FUNCTION_HASH 517
|
125
|
+
|
126
|
+
void InitializeExternalFunctionData(Environment *);
|
127
|
+
AddUDFError AddUDF(Environment *,const char *,const char *,
|
128
|
+
unsigned short,unsigned short,const char *,
|
129
|
+
UserDefinedFunction *,
|
130
|
+
const char *,void *);
|
131
|
+
bool AddFunctionParser(Environment *,const char *,
|
132
|
+
struct expr *(*)( Environment *,struct expr *,const char *));
|
133
|
+
bool RemoveFunctionParser(Environment *,const char *);
|
134
|
+
bool FuncSeqOvlFlags(Environment *,const char *,bool,bool);
|
135
|
+
struct functionDefinition *GetFunctionList(Environment *);
|
136
|
+
void InstallFunctionList(Environment *,struct functionDefinition *);
|
137
|
+
struct functionDefinition *FindFunction(Environment *,const char *);
|
138
|
+
unsigned GetNthRestriction(Environment *,struct functionDefinition *,unsigned int);
|
139
|
+
bool RemoveUDF(Environment *,const char *);
|
140
|
+
int GetMinimumArgs(struct functionDefinition *);
|
141
|
+
int GetMaximumArgs(struct functionDefinition *);
|
142
|
+
unsigned int UDFArgumentCount(UDFContext *);
|
143
|
+
bool UDFNthArgument(UDFContext *,unsigned int,unsigned,UDFValue *);
|
144
|
+
void UDFInvalidArgumentMessage(UDFContext *,const char *);
|
145
|
+
const char *UDFContextFunctionName(UDFContext *);
|
146
|
+
void PrintTypesString(Environment *,const char *,unsigned,bool);
|
147
|
+
bool UDFFirstArgument(UDFContext *,unsigned,UDFValue *);
|
148
|
+
bool UDFNextArgument(UDFContext *,unsigned,UDFValue *);
|
149
|
+
void UDFThrowError(UDFContext *);
|
150
|
+
void *GetUDFContext(Environment *,const char *);
|
151
|
+
|
152
|
+
#define UDFHasNextArgument(context) (context->lastArg != NULL)
|
153
|
+
|
154
|
+
#endif /* _H_extnfunc */
|
155
|
+
|
156
|
+
|
157
|
+
|
@@ -0,0 +1,447 @@
|
|
1
|
+
/*******************************************************/
|
2
|
+
/* "C" Language Integrated Production System */
|
3
|
+
/* */
|
4
|
+
/* CLIPS Version 6.40 11/01/16 */
|
5
|
+
/* */
|
6
|
+
/* FACT BSAVE/BLOAD MODULE */
|
7
|
+
/*******************************************************/
|
8
|
+
|
9
|
+
/*************************************************************/
|
10
|
+
/* Purpose: Implements the binary save/load feature for the */
|
11
|
+
/* fact pattern network. */
|
12
|
+
/* */
|
13
|
+
/* Principal Programmer(s): */
|
14
|
+
/* Gary D. Riley */
|
15
|
+
/* */
|
16
|
+
/* Contributing Programmer(s): */
|
17
|
+
/* Brian L. Dantes */
|
18
|
+
/* */
|
19
|
+
/* Revision History: */
|
20
|
+
/* */
|
21
|
+
/* 6.30: Added support for hashed alpha memories. */
|
22
|
+
/* */
|
23
|
+
/* Changed integer type/precision. */
|
24
|
+
/* */
|
25
|
+
/* 6.40: Pragma once and other inclusion changes. */
|
26
|
+
/* */
|
27
|
+
/* Added support for booleans with <stdbool.h>. */
|
28
|
+
/* */
|
29
|
+
/* Removed use of void pointers for specific */
|
30
|
+
/* data structures. */
|
31
|
+
/* */
|
32
|
+
/*************************************************************/
|
33
|
+
|
34
|
+
#include "setup.h"
|
35
|
+
|
36
|
+
#if DEFTEMPLATE_CONSTRUCT && (BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE) && (! RUN_TIME)
|
37
|
+
|
38
|
+
#include <stdio.h>
|
39
|
+
|
40
|
+
#include "bload.h"
|
41
|
+
#include "bsave.h"
|
42
|
+
#include "envrnmnt.h"
|
43
|
+
#include "factmngr.h"
|
44
|
+
#include "memalloc.h"
|
45
|
+
#include "moduldef.h"
|
46
|
+
#include "pattern.h"
|
47
|
+
#include "reteutil.h"
|
48
|
+
#include "rulebin.h"
|
49
|
+
#include "tmpltdef.h"
|
50
|
+
|
51
|
+
#include "factbin.h"
|
52
|
+
|
53
|
+
/********************************************/
|
54
|
+
/* INTERNAL DATA STRUCTURES AND DEFINITIONS */
|
55
|
+
/********************************************/
|
56
|
+
|
57
|
+
struct bsaveFactPatternNode
|
58
|
+
{
|
59
|
+
struct bsavePatternNodeHeader header;
|
60
|
+
unsigned short whichSlot;
|
61
|
+
unsigned short whichField;
|
62
|
+
unsigned short leaveFields;
|
63
|
+
unsigned long networkTest;
|
64
|
+
unsigned long nextLevel;
|
65
|
+
unsigned long lastLevel;
|
66
|
+
unsigned long leftNode;
|
67
|
+
unsigned long rightNode;
|
68
|
+
};
|
69
|
+
|
70
|
+
#define BSAVE_FIND 0
|
71
|
+
#define BSAVE_PATTERNS 1
|
72
|
+
|
73
|
+
/***************************************/
|
74
|
+
/* LOCAL INTERNAL FUNCTION DEFINITIONS */
|
75
|
+
/***************************************/
|
76
|
+
|
77
|
+
#if BLOAD_AND_BSAVE
|
78
|
+
static void BsaveDriver(Environment *,int,FILE *,struct factPatternNode *);
|
79
|
+
static void BsaveFind(Environment *);
|
80
|
+
static void BsaveStorage(Environment *,FILE *);
|
81
|
+
static void BsaveFactPatterns(Environment *,FILE *);
|
82
|
+
static void BsavePatternNode(Environment *,struct factPatternNode *,FILE *);
|
83
|
+
#endif
|
84
|
+
static void BloadStorage(Environment *);
|
85
|
+
static void BloadBinaryItem(Environment *);
|
86
|
+
static void UpdateFactPatterns(Environment *,void *,unsigned long);
|
87
|
+
static void ClearBload(Environment *);
|
88
|
+
static void DeallocateFactBloadData(Environment *);
|
89
|
+
|
90
|
+
/*****************************************************/
|
91
|
+
/* FactBinarySetup: Initializes the binary load/save */
|
92
|
+
/* feature for the fact pattern network. */
|
93
|
+
/*****************************************************/
|
94
|
+
void FactBinarySetup(
|
95
|
+
Environment *theEnv)
|
96
|
+
{
|
97
|
+
AllocateEnvironmentData(theEnv,FACTBIN_DATA,sizeof(struct factBinaryData),DeallocateFactBloadData);
|
98
|
+
|
99
|
+
#if BLOAD_AND_BSAVE
|
100
|
+
AddBinaryItem(theEnv,"facts",0,BsaveFind,NULL,
|
101
|
+
BsaveStorage,BsaveFactPatterns,
|
102
|
+
BloadStorage,BloadBinaryItem,
|
103
|
+
ClearBload);
|
104
|
+
#endif
|
105
|
+
#if BLOAD || BLOAD_ONLY
|
106
|
+
AddBinaryItem(theEnv,"facts",0,NULL,NULL,NULL,NULL,
|
107
|
+
BloadStorage,BloadBinaryItem,
|
108
|
+
ClearBload);
|
109
|
+
#endif
|
110
|
+
}
|
111
|
+
|
112
|
+
/****************************************************/
|
113
|
+
/* DeallocateFactBloadData: Deallocates environment */
|
114
|
+
/* data for the fact bsave functionality. */
|
115
|
+
/****************************************************/
|
116
|
+
static void DeallocateFactBloadData(
|
117
|
+
Environment *theEnv)
|
118
|
+
{
|
119
|
+
size_t space;
|
120
|
+
unsigned long i;
|
121
|
+
|
122
|
+
for (i = 0; i < FactBinaryData(theEnv)->NumberOfPatterns; i++)
|
123
|
+
{ DestroyAlphaMemory(theEnv,&FactBinaryData(theEnv)->FactPatternArray[i].header,false); }
|
124
|
+
|
125
|
+
space = FactBinaryData(theEnv)->NumberOfPatterns * sizeof(struct factPatternNode);
|
126
|
+
if (space != 0) genfree(theEnv,FactBinaryData(theEnv)->FactPatternArray,space);
|
127
|
+
}
|
128
|
+
|
129
|
+
#if BLOAD_AND_BSAVE
|
130
|
+
|
131
|
+
/*********************************************************/
|
132
|
+
/* BsaveFind: Counts the number of data structures which */
|
133
|
+
/* must be saved in the binary image for the fact */
|
134
|
+
/* pattern network in the current environment. */
|
135
|
+
/*********************************************************/
|
136
|
+
static void BsaveFind(
|
137
|
+
Environment *theEnv)
|
138
|
+
{
|
139
|
+
Deftemplate *theDeftemplate;
|
140
|
+
Defmodule *theModule;
|
141
|
+
|
142
|
+
/*=======================================================*/
|
143
|
+
/* If a binary image is already loaded, then temporarily */
|
144
|
+
/* save the count values since these will be overwritten */
|
145
|
+
/* in the process of saving the binary image. */
|
146
|
+
/*=======================================================*/
|
147
|
+
|
148
|
+
SaveBloadCount(theEnv,FactBinaryData(theEnv)->NumberOfPatterns);
|
149
|
+
|
150
|
+
/*=======================================*/
|
151
|
+
/* Set the count of fact pattern network */
|
152
|
+
/* data structures to zero. */
|
153
|
+
/*=======================================*/
|
154
|
+
|
155
|
+
FactBinaryData(theEnv)->NumberOfPatterns = 0L;
|
156
|
+
|
157
|
+
/*===========================*/
|
158
|
+
/* Loop through each module. */
|
159
|
+
/*===========================*/
|
160
|
+
|
161
|
+
for (theModule = GetNextDefmodule(theEnv,NULL);
|
162
|
+
theModule != NULL;
|
163
|
+
theModule = GetNextDefmodule(theEnv,theModule))
|
164
|
+
{
|
165
|
+
/*===============================*/
|
166
|
+
/* Set the current module to the */
|
167
|
+
/* module being examined. */
|
168
|
+
/*===============================*/
|
169
|
+
|
170
|
+
SetCurrentModule(theEnv,theModule);
|
171
|
+
|
172
|
+
/*=====================================================*/
|
173
|
+
/* Loop through each deftemplate in the current module */
|
174
|
+
/* and count the number of data structures which must */
|
175
|
+
/* be saved for its pattern network. */
|
176
|
+
/*=====================================================*/
|
177
|
+
|
178
|
+
for (theDeftemplate = GetNextDeftemplate(theEnv,NULL);
|
179
|
+
theDeftemplate != NULL;
|
180
|
+
theDeftemplate = GetNextDeftemplate(theEnv,theDeftemplate))
|
181
|
+
{ BsaveDriver(theEnv,BSAVE_FIND,NULL,theDeftemplate->patternNetwork); }
|
182
|
+
}
|
183
|
+
}
|
184
|
+
|
185
|
+
/**********************************************************/
|
186
|
+
/* BsaveDriver: Binary save driver routine which handles */
|
187
|
+
/* both finding/marking the data structures to be saved */
|
188
|
+
/* and saving the data structures to a file. */
|
189
|
+
/**********************************************************/
|
190
|
+
static void BsaveDriver(
|
191
|
+
Environment *theEnv,
|
192
|
+
int action,
|
193
|
+
FILE *fp,
|
194
|
+
struct factPatternNode *thePattern)
|
195
|
+
{
|
196
|
+
while (thePattern != NULL)
|
197
|
+
{
|
198
|
+
switch(action)
|
199
|
+
{
|
200
|
+
case BSAVE_FIND:
|
201
|
+
thePattern->bsaveID = FactBinaryData(theEnv)->NumberOfPatterns++;
|
202
|
+
break;
|
203
|
+
|
204
|
+
case BSAVE_PATTERNS:
|
205
|
+
BsavePatternNode(theEnv,thePattern,fp);
|
206
|
+
break;
|
207
|
+
|
208
|
+
default:
|
209
|
+
break;
|
210
|
+
}
|
211
|
+
|
212
|
+
if (thePattern->nextLevel == NULL)
|
213
|
+
{
|
214
|
+
while (thePattern->rightNode == NULL)
|
215
|
+
{
|
216
|
+
thePattern = thePattern->lastLevel;
|
217
|
+
if (thePattern == NULL) return;
|
218
|
+
}
|
219
|
+
thePattern = thePattern->rightNode;
|
220
|
+
}
|
221
|
+
else
|
222
|
+
{ thePattern = thePattern->nextLevel; }
|
223
|
+
}
|
224
|
+
}
|
225
|
+
|
226
|
+
/*********************************************************/
|
227
|
+
/* BsaveStorage: Writes out storage requirements for all */
|
228
|
+
/* factPatternNode data structures to the binary file */
|
229
|
+
/*********************************************************/
|
230
|
+
static void BsaveStorage(
|
231
|
+
Environment *theEnv,
|
232
|
+
FILE *fp)
|
233
|
+
{
|
234
|
+
size_t space;
|
235
|
+
|
236
|
+
space = sizeof(long);
|
237
|
+
GenWrite(&space,sizeof(size_t),fp);
|
238
|
+
GenWrite(&FactBinaryData(theEnv)->NumberOfPatterns,sizeof(long),fp);
|
239
|
+
}
|
240
|
+
|
241
|
+
/*****************************************************/
|
242
|
+
/* BsaveFactPatterns: Writes out all factPatternNode */
|
243
|
+
/* data structures to the binary file. */
|
244
|
+
/*****************************************************/
|
245
|
+
static void BsaveFactPatterns(
|
246
|
+
Environment *theEnv,
|
247
|
+
FILE *fp)
|
248
|
+
{
|
249
|
+
size_t space;
|
250
|
+
Deftemplate *theDeftemplate;
|
251
|
+
Defmodule *theModule;
|
252
|
+
|
253
|
+
/*========================================*/
|
254
|
+
/* Write out the amount of space taken up */
|
255
|
+
/* by the factPatternNode data structures */
|
256
|
+
/* in the binary image. */
|
257
|
+
/*========================================*/
|
258
|
+
|
259
|
+
space = FactBinaryData(theEnv)->NumberOfPatterns * sizeof(struct bsaveFactPatternNode);
|
260
|
+
GenWrite(&space,sizeof(size_t),fp);
|
261
|
+
|
262
|
+
/*===========================*/
|
263
|
+
/* Loop through each module. */
|
264
|
+
/*===========================*/
|
265
|
+
|
266
|
+
for (theModule = GetNextDefmodule(theEnv,NULL);
|
267
|
+
theModule != NULL;
|
268
|
+
theModule = GetNextDefmodule(theEnv,theModule))
|
269
|
+
{
|
270
|
+
/*=====================================================*/
|
271
|
+
/* Loop through each deftemplate in the current module */
|
272
|
+
/* and save its fact pattern network to the file. */
|
273
|
+
/*=====================================================*/
|
274
|
+
|
275
|
+
SetCurrentModule(theEnv,theModule);
|
276
|
+
for (theDeftemplate = GetNextDeftemplate(theEnv,NULL);
|
277
|
+
theDeftemplate != NULL;
|
278
|
+
theDeftemplate = GetNextDeftemplate(theEnv,theDeftemplate))
|
279
|
+
{ BsaveDriver(theEnv,BSAVE_PATTERNS,fp,theDeftemplate->patternNetwork); }
|
280
|
+
}
|
281
|
+
|
282
|
+
/*=============================================================*/
|
283
|
+
/* If a binary image was already loaded when the bsave command */
|
284
|
+
/* was issued, then restore the counts indicating the number */
|
285
|
+
/* of factPatternNode data structures in the binary image */
|
286
|
+
/* (these were overwritten by the binary save). */
|
287
|
+
/*=============================================================*/
|
288
|
+
|
289
|
+
RestoreBloadCount(theEnv,&FactBinaryData(theEnv)->NumberOfPatterns);
|
290
|
+
}
|
291
|
+
|
292
|
+
/******************************************************/
|
293
|
+
/* BsavePatternNode: Writes out a single fact pattern */
|
294
|
+
/* node to the binary image save file. */
|
295
|
+
/******************************************************/
|
296
|
+
static void BsavePatternNode(
|
297
|
+
Environment *theEnv,
|
298
|
+
struct factPatternNode *thePattern,
|
299
|
+
FILE *fp)
|
300
|
+
{
|
301
|
+
struct bsaveFactPatternNode tempNode;
|
302
|
+
|
303
|
+
AssignBsavePatternHeaderValues(theEnv,&tempNode.header,&thePattern->header);
|
304
|
+
|
305
|
+
tempNode.whichField = thePattern->whichField;
|
306
|
+
tempNode.leaveFields = thePattern->leaveFields;
|
307
|
+
tempNode.whichSlot = thePattern->whichSlot;
|
308
|
+
tempNode.networkTest = HashedExpressionIndex(theEnv,thePattern->networkTest);
|
309
|
+
tempNode.nextLevel = BsaveFactPatternIndex(thePattern->nextLevel);
|
310
|
+
tempNode.lastLevel = BsaveFactPatternIndex(thePattern->lastLevel);
|
311
|
+
tempNode.leftNode = BsaveFactPatternIndex(thePattern->leftNode);
|
312
|
+
tempNode.rightNode = BsaveFactPatternIndex(thePattern->rightNode);
|
313
|
+
|
314
|
+
GenWrite(&tempNode,sizeof(struct bsaveFactPatternNode),fp);
|
315
|
+
}
|
316
|
+
|
317
|
+
#endif /* BLOAD_AND_BSAVE */
|
318
|
+
|
319
|
+
/*****************************************************/
|
320
|
+
/* BloadStorage: Allocates storage requirements for */
|
321
|
+
/* the factPatternNodes used by this binary image. */
|
322
|
+
/*****************************************************/
|
323
|
+
static void BloadStorage(
|
324
|
+
Environment *theEnv)
|
325
|
+
{
|
326
|
+
size_t space;
|
327
|
+
|
328
|
+
/*=========================================*/
|
329
|
+
/* Determine the number of factPatternNode */
|
330
|
+
/* data structures to be read. */
|
331
|
+
/*=========================================*/
|
332
|
+
|
333
|
+
GenReadBinary(theEnv,&space,sizeof(size_t));
|
334
|
+
GenReadBinary(theEnv,&FactBinaryData(theEnv)->NumberOfPatterns,sizeof(long));
|
335
|
+
|
336
|
+
/*===================================*/
|
337
|
+
/* Allocate the space needed for the */
|
338
|
+
/* factPatternNode data structures. */
|
339
|
+
/*===================================*/
|
340
|
+
|
341
|
+
if (FactBinaryData(theEnv)->NumberOfPatterns == 0)
|
342
|
+
{
|
343
|
+
FactBinaryData(theEnv)->FactPatternArray = NULL;
|
344
|
+
return;
|
345
|
+
}
|
346
|
+
|
347
|
+
space = FactBinaryData(theEnv)->NumberOfPatterns * sizeof(struct factPatternNode);
|
348
|
+
FactBinaryData(theEnv)->FactPatternArray = (struct factPatternNode *) genalloc(theEnv,space);
|
349
|
+
}
|
350
|
+
|
351
|
+
/************************************************************/
|
352
|
+
/* BloadBinaryItem: Loads and refreshes the factPatternNode */
|
353
|
+
/* data structures used by this binary image. */
|
354
|
+
/************************************************************/
|
355
|
+
static void BloadBinaryItem(
|
356
|
+
Environment *theEnv)
|
357
|
+
{
|
358
|
+
size_t space;
|
359
|
+
unsigned long i;
|
360
|
+
|
361
|
+
/*======================================================*/
|
362
|
+
/* Read in the amount of space used by the binary image */
|
363
|
+
/* (this is used to skip the construct in the event it */
|
364
|
+
/* is not available in the version being run). */
|
365
|
+
/*======================================================*/
|
366
|
+
|
367
|
+
GenReadBinary(theEnv,&space,sizeof(size_t));
|
368
|
+
|
369
|
+
/*=============================================*/
|
370
|
+
/* Read in the factPatternNode data structures */
|
371
|
+
/* and refresh the pointers. */
|
372
|
+
/*=============================================*/
|
373
|
+
|
374
|
+
BloadandRefresh(theEnv,FactBinaryData(theEnv)->NumberOfPatterns,sizeof(struct bsaveFactPatternNode),
|
375
|
+
UpdateFactPatterns);
|
376
|
+
|
377
|
+
for (i = 0; i < FactBinaryData(theEnv)->NumberOfPatterns; i++)
|
378
|
+
{
|
379
|
+
if ((FactBinaryData(theEnv)->FactPatternArray[i].lastLevel != NULL) &&
|
380
|
+
(FactBinaryData(theEnv)->FactPatternArray[i].lastLevel->header.selector))
|
381
|
+
{
|
382
|
+
AddHashedPatternNode(theEnv,FactBinaryData(theEnv)->FactPatternArray[i].lastLevel,
|
383
|
+
&FactBinaryData(theEnv)->FactPatternArray[i],
|
384
|
+
FactBinaryData(theEnv)->FactPatternArray[i].networkTest->type,
|
385
|
+
FactBinaryData(theEnv)->FactPatternArray[i].networkTest->value);
|
386
|
+
}
|
387
|
+
}
|
388
|
+
}
|
389
|
+
|
390
|
+
/*************************************************/
|
391
|
+
/* UpdateFactPatterns: Bload refresh routine for */
|
392
|
+
/* the factPatternNode structure. */
|
393
|
+
/*************************************************/
|
394
|
+
static void UpdateFactPatterns(
|
395
|
+
Environment *theEnv,
|
396
|
+
void *buf,
|
397
|
+
unsigned long obji)
|
398
|
+
{
|
399
|
+
struct bsaveFactPatternNode *bp;
|
400
|
+
|
401
|
+
bp = (struct bsaveFactPatternNode *) buf;
|
402
|
+
|
403
|
+
UpdatePatternNodeHeader(theEnv,&FactBinaryData(theEnv)->FactPatternArray[obji].header,&bp->header);
|
404
|
+
|
405
|
+
FactBinaryData(theEnv)->FactPatternArray[obji].bsaveID = 0L;
|
406
|
+
FactBinaryData(theEnv)->FactPatternArray[obji].whichField = bp->whichField;
|
407
|
+
FactBinaryData(theEnv)->FactPatternArray[obji].leaveFields = bp->leaveFields;
|
408
|
+
FactBinaryData(theEnv)->FactPatternArray[obji].whichSlot = bp->whichSlot;
|
409
|
+
|
410
|
+
FactBinaryData(theEnv)->FactPatternArray[obji].networkTest = HashedExpressionPointer(bp->networkTest);
|
411
|
+
FactBinaryData(theEnv)->FactPatternArray[obji].rightNode = BloadFactPatternPointer(bp->rightNode);
|
412
|
+
FactBinaryData(theEnv)->FactPatternArray[obji].nextLevel = BloadFactPatternPointer(bp->nextLevel);
|
413
|
+
FactBinaryData(theEnv)->FactPatternArray[obji].lastLevel = BloadFactPatternPointer(bp->lastLevel);
|
414
|
+
FactBinaryData(theEnv)->FactPatternArray[obji].leftNode = BloadFactPatternPointer(bp->leftNode);
|
415
|
+
}
|
416
|
+
|
417
|
+
/***************************************************/
|
418
|
+
/* ClearBload: Fact pattern network clear routine */
|
419
|
+
/* when a binary load is in effect. */
|
420
|
+
/***************************************************/
|
421
|
+
static void ClearBload(
|
422
|
+
Environment *theEnv)
|
423
|
+
{
|
424
|
+
size_t space;
|
425
|
+
unsigned long i;
|
426
|
+
|
427
|
+
for (i = 0; i < FactBinaryData(theEnv)->NumberOfPatterns; i++)
|
428
|
+
{
|
429
|
+
if ((FactBinaryData(theEnv)->FactPatternArray[i].lastLevel != NULL) &&
|
430
|
+
(FactBinaryData(theEnv)->FactPatternArray[i].lastLevel->header.selector))
|
431
|
+
{
|
432
|
+
RemoveHashedPatternNode(theEnv,FactBinaryData(theEnv)->FactPatternArray[i].lastLevel,
|
433
|
+
&FactBinaryData(theEnv)->FactPatternArray[i],
|
434
|
+
FactBinaryData(theEnv)->FactPatternArray[i].networkTest->type,
|
435
|
+
FactBinaryData(theEnv)->FactPatternArray[i].networkTest->value);
|
436
|
+
}
|
437
|
+
}
|
438
|
+
|
439
|
+
|
440
|
+
space = FactBinaryData(theEnv)->NumberOfPatterns * sizeof(struct factPatternNode);
|
441
|
+
if (space != 0) genfree(theEnv,FactBinaryData(theEnv)->FactPatternArray,space);
|
442
|
+
FactBinaryData(theEnv)->NumberOfPatterns = 0;
|
443
|
+
}
|
444
|
+
|
445
|
+
#endif /* DEFTEMPLATE_CONSTRUCT && (BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE) && (! RUN_TIME) */
|
446
|
+
|
447
|
+
|
@@ -0,0 +1,56 @@
|
|
1
|
+
/*******************************************************/
|
2
|
+
/* "C" Language Integrated Production System */
|
3
|
+
/* */
|
4
|
+
/* CLIPS Version 6.40 07/30/16 */
|
5
|
+
/* */
|
6
|
+
/* FACT BLOAD/BSAVE HEADER FILE */
|
7
|
+
/*******************************************************/
|
8
|
+
|
9
|
+
/*************************************************************/
|
10
|
+
/* Purpose: */
|
11
|
+
/* */
|
12
|
+
/* Principal Programmer(s): */
|
13
|
+
/* Gary D. Riley */
|
14
|
+
/* */
|
15
|
+
/* Contributing Programmer(s): */
|
16
|
+
/* */
|
17
|
+
/* Revision History: */
|
18
|
+
/* */
|
19
|
+
/* 6.30: Added support for hashed alpha memories. */
|
20
|
+
/* */
|
21
|
+
/* Changed integer type/precision. */
|
22
|
+
/* */
|
23
|
+
/* 6.40: Removed LOCALE definition. */
|
24
|
+
/* */
|
25
|
+
/* Pragma once and other inclusion changes. */
|
26
|
+
/* */
|
27
|
+
/* Removed use of void pointers for specific */
|
28
|
+
/* data structures. */
|
29
|
+
/* */
|
30
|
+
/*************************************************************/
|
31
|
+
|
32
|
+
#ifndef _H_factbin
|
33
|
+
|
34
|
+
#pragma once
|
35
|
+
|
36
|
+
#define _H_factbin
|
37
|
+
|
38
|
+
#include "factbld.h"
|
39
|
+
|
40
|
+
#define FACTBIN_DATA 62
|
41
|
+
|
42
|
+
struct factBinaryData
|
43
|
+
{
|
44
|
+
struct factPatternNode *FactPatternArray;
|
45
|
+
unsigned long NumberOfPatterns;
|
46
|
+
};
|
47
|
+
|
48
|
+
#define FactBinaryData(theEnv) ((struct factBinaryData *) GetEnvironmentData(theEnv,FACTBIN_DATA))
|
49
|
+
|
50
|
+
void FactBinarySetup(Environment *);
|
51
|
+
|
52
|
+
#define BsaveFactPatternIndex(patPtr) ((patPtr == NULL) ? ULONG_MAX : ((struct factPatternNode *) patPtr)->bsaveID)
|
53
|
+
#define BloadFactPatternPointer(i) ((struct factPatternNode *) ((i == ULONG_MAX) ? NULL : &FactBinaryData(theEnv)->FactPatternArray[i]))
|
54
|
+
|
55
|
+
#endif
|
56
|
+
|