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,682 @@
|
|
1
|
+
/*******************************************************/
|
2
|
+
/* "C" Language Integrated Production System */
|
3
|
+
/* */
|
4
|
+
/* CLIPS Version 6.41 12/04/22 */
|
5
|
+
/* */
|
6
|
+
/* FACT FUNCTIONS MODULE */
|
7
|
+
/*******************************************************/
|
8
|
+
|
9
|
+
/*************************************************************/
|
10
|
+
/* Purpose: */
|
11
|
+
/* */
|
12
|
+
/* */
|
13
|
+
/* (fact-existp <fact-address-or-index>) */
|
14
|
+
/* Returns TRUE if the fact exists, otherwise FALSE is */
|
15
|
+
/* returned. */
|
16
|
+
/* */
|
17
|
+
/* (fact-relation <fact-address-or-index>) */
|
18
|
+
/* Returns the deftemplate name of the fact. Returns */
|
19
|
+
/* FALSE if the specified fact doesn't exist. */
|
20
|
+
/* */
|
21
|
+
/* (fact-slot-value <fact-address-or-index> <slot-name>) */
|
22
|
+
/* Returns the contents of a slot (use the slot name */
|
23
|
+
/* implied for the implied multifield slot of an ordered */
|
24
|
+
/* fact). Returns the value FALSE if the slot name is */
|
25
|
+
/* invalid or the fact doesn't exist. */
|
26
|
+
/* */
|
27
|
+
/* (fact-slot-names <fact-address-or-index>) */
|
28
|
+
/* Returns the slot names associated with a fact in a */
|
29
|
+
/* multifield value. Returns FALSE if the fact doesn't */
|
30
|
+
/* exist. */
|
31
|
+
/* */
|
32
|
+
/* (get-fact-list [<module-name>]) */
|
33
|
+
/* Returns the list of facts visible to the specified */
|
34
|
+
/* module or to the current module if none is specified. */
|
35
|
+
/* If * is specified then all facts are returned. */
|
36
|
+
/* */
|
37
|
+
/* Principal Programmer(s): */
|
38
|
+
/* Gary D. Riley */
|
39
|
+
/* */
|
40
|
+
/* Contributing Programmer(s): */
|
41
|
+
/* */
|
42
|
+
/* Revision History: */
|
43
|
+
/* */
|
44
|
+
/* 6.23: Correction for FalseSymbol/TrueSymbol. DR0859 */
|
45
|
+
/* */
|
46
|
+
/* Corrected compilation errors for files */
|
47
|
+
/* generated by constructs-to-c. DR0861 */
|
48
|
+
/* */
|
49
|
+
/* 6.24: Added ppfact function. */
|
50
|
+
/* */
|
51
|
+
/* 6.30: Support for long long integers. */
|
52
|
+
/* */
|
53
|
+
/* Removed conditional code for unsupported */
|
54
|
+
/* compilers/operating systems (IBM_MCW, */
|
55
|
+
/* MAC_MCW, and IBM_TBC). */
|
56
|
+
/* */
|
57
|
+
/* Added const qualifiers to remove C++ */
|
58
|
+
/* deprecation warnings. */
|
59
|
+
/* */
|
60
|
+
/* Converted API macros to function calls. */
|
61
|
+
/* */
|
62
|
+
/* Added STDOUT and STDIN logical name */
|
63
|
+
/* definitions. */
|
64
|
+
/* */
|
65
|
+
/* 6.31: Calling EnvFactExistp for a fact that has */
|
66
|
+
/* been created, but not asserted now returns */
|
67
|
+
/* FALSE. */
|
68
|
+
/* */
|
69
|
+
/* Error messages are now generated when the */
|
70
|
+
/* fact-relation, fact-slot-value, */
|
71
|
+
/* fact-slot-names, and ppfact functions are */
|
72
|
+
/* given a retracted fact. */
|
73
|
+
/* */
|
74
|
+
/* 6.40: Added Env prefix to GetEvaluationError and */
|
75
|
+
/* SetEvaluationError functions. */
|
76
|
+
/* */
|
77
|
+
/* Added Env prefix to GetHaltExecution and */
|
78
|
+
/* SetHaltExecution functions. */
|
79
|
+
/* */
|
80
|
+
/* Pragma once and other inclusion changes. */
|
81
|
+
/* */
|
82
|
+
/* Added support for booleans with <stdbool.h>. */
|
83
|
+
/* */
|
84
|
+
/* Removed use of void pointers for specific */
|
85
|
+
/* data structures. */
|
86
|
+
/* */
|
87
|
+
/* ALLOW_ENVIRONMENT_GLOBALS no longer supported. */
|
88
|
+
/* */
|
89
|
+
/* UDF redesign. */
|
90
|
+
/* */
|
91
|
+
/* Watch facts for modify command only prints */
|
92
|
+
/* changed slots. */
|
93
|
+
/* */
|
94
|
+
/* Pretty print functions accept optional logical */
|
95
|
+
/* name argument. */
|
96
|
+
/* */
|
97
|
+
/* Added fact-addressp function. */
|
98
|
+
/* */
|
99
|
+
/* 6.41: Used gensnprintf in place of gensprintf and. */
|
100
|
+
/* sprintf. */
|
101
|
+
/* */
|
102
|
+
/*************************************************************/
|
103
|
+
|
104
|
+
#include <stdio.h>
|
105
|
+
#include <string.h>
|
106
|
+
|
107
|
+
#include "setup.h"
|
108
|
+
|
109
|
+
#if DEFTEMPLATE_CONSTRUCT
|
110
|
+
|
111
|
+
#include "argacces.h"
|
112
|
+
#include "envrnmnt.h"
|
113
|
+
#include "extnfunc.h"
|
114
|
+
#include "multifld.h"
|
115
|
+
#include "prntutil.h"
|
116
|
+
#include "router.h"
|
117
|
+
#include "sysdep.h"
|
118
|
+
#include "tmpltutl.h"
|
119
|
+
|
120
|
+
#include "factfun.h"
|
121
|
+
|
122
|
+
/****************************************************/
|
123
|
+
/* FactFunctionDefinitions: Defines fact functions. */
|
124
|
+
/****************************************************/
|
125
|
+
void FactFunctionDefinitions(
|
126
|
+
Environment *theEnv)
|
127
|
+
{
|
128
|
+
#if ! RUN_TIME
|
129
|
+
AddUDF(theEnv,"fact-existp","b",1,1,"lf",FactExistpFunction,"FactExistpFunction",NULL);
|
130
|
+
AddUDF(theEnv,"fact-relation","y",1,1,"lf",FactRelationFunction,"FactRelationFunction",NULL);
|
131
|
+
AddUDF(theEnv,"fact-slot-value","*",2,2,";lf;y",FactSlotValueFunction,"FactSlotValueFunction",NULL);
|
132
|
+
AddUDF(theEnv,"fact-slot-names","*",1,1,"lf",FactSlotNamesFunction,"FactSlotNamesFunction",NULL);
|
133
|
+
AddUDF(theEnv,"get-fact-list","m",0,1,"y",GetFactListFunction,"GetFactListFunction",NULL);
|
134
|
+
AddUDF(theEnv,"ppfact","vs",1,3,"*;lf;ldsyn",PPFactFunction,"PPFactFunction",NULL);
|
135
|
+
AddUDF(theEnv,"fact-addressp","b",1,1,NULL,FactAddresspFunction,"FactAddresspFunction",NULL);
|
136
|
+
#else
|
137
|
+
#if MAC_XCD
|
138
|
+
#pragma unused(theEnv)
|
139
|
+
#endif
|
140
|
+
#endif
|
141
|
+
}
|
142
|
+
|
143
|
+
/**********************************************/
|
144
|
+
/* FactRelationFunction: H/L access routine */
|
145
|
+
/* for the fact-relation function. */
|
146
|
+
/**********************************************/
|
147
|
+
void FactRelationFunction(
|
148
|
+
Environment *theEnv,
|
149
|
+
UDFContext *context,
|
150
|
+
UDFValue *returnValue)
|
151
|
+
{
|
152
|
+
Fact *theFact;
|
153
|
+
|
154
|
+
theFact = GetFactAddressOrIndexArgument(context,true);
|
155
|
+
|
156
|
+
if (theFact == NULL)
|
157
|
+
{
|
158
|
+
returnValue->lexemeValue = FalseSymbol(theEnv);
|
159
|
+
return;
|
160
|
+
}
|
161
|
+
|
162
|
+
returnValue->value = FactRelation(theFact);
|
163
|
+
}
|
164
|
+
|
165
|
+
/**************************************/
|
166
|
+
/* FactRelation: C access routine for */
|
167
|
+
/* the fact-relation function. */
|
168
|
+
/**************************************/
|
169
|
+
CLIPSLexeme *FactRelation(
|
170
|
+
Fact *theFact)
|
171
|
+
{
|
172
|
+
return theFact->whichDeftemplate->header.name;
|
173
|
+
}
|
174
|
+
|
175
|
+
/***************************************/
|
176
|
+
/* FactDeftemplate: C access routine */
|
177
|
+
/* to retrieve a fact's deftemplate. */
|
178
|
+
/***************************************/
|
179
|
+
Deftemplate *FactDeftemplate(
|
180
|
+
Fact *theFact)
|
181
|
+
{
|
182
|
+
return theFact->whichDeftemplate;
|
183
|
+
}
|
184
|
+
|
185
|
+
/********************************************/
|
186
|
+
/* FactExistpFunction: H/L access routine */
|
187
|
+
/* for the fact-existp function. */
|
188
|
+
/********************************************/
|
189
|
+
void FactExistpFunction(
|
190
|
+
Environment *theEnv,
|
191
|
+
UDFContext *context,
|
192
|
+
UDFValue *returnValue)
|
193
|
+
{
|
194
|
+
Fact *theFact;
|
195
|
+
|
196
|
+
theFact = GetFactAddressOrIndexArgument(context,false);
|
197
|
+
|
198
|
+
returnValue->lexemeValue = CreateBoolean(theEnv,FactExistp(theFact));
|
199
|
+
}
|
200
|
+
|
201
|
+
/***********************************/
|
202
|
+
/* FactExistp: C access routine */
|
203
|
+
/* for the fact-existp function. */
|
204
|
+
/***********************************/
|
205
|
+
bool FactExistp(
|
206
|
+
Fact *theFact)
|
207
|
+
{
|
208
|
+
if (theFact == NULL) return false;
|
209
|
+
|
210
|
+
if (theFact->garbage) return false;
|
211
|
+
|
212
|
+
if (theFact->factIndex == 0LL) return false;
|
213
|
+
|
214
|
+
return true;
|
215
|
+
}
|
216
|
+
|
217
|
+
/********************************************/
|
218
|
+
/* FactAddresspFunction: H/L access routine */
|
219
|
+
/* for the fact-addressp function. */
|
220
|
+
/********************************************/
|
221
|
+
void FactAddresspFunction(
|
222
|
+
Environment *theEnv,
|
223
|
+
UDFContext *context,
|
224
|
+
UDFValue *returnValue)
|
225
|
+
{
|
226
|
+
UDFValue item;
|
227
|
+
|
228
|
+
if (! UDFFirstArgument(context,ANY_TYPE_BITS,&item))
|
229
|
+
{ return; }
|
230
|
+
|
231
|
+
if (CVIsType(&item,FACT_ADDRESS_BIT))
|
232
|
+
{ returnValue->lexemeValue = TrueSymbol(theEnv); }
|
233
|
+
else
|
234
|
+
{ returnValue->lexemeValue = FalseSymbol(theEnv); }
|
235
|
+
}
|
236
|
+
|
237
|
+
/***********************************************/
|
238
|
+
/* FactSlotValueFunction: H/L access routine */
|
239
|
+
/* for the fact-slot-value function. */
|
240
|
+
/***********************************************/
|
241
|
+
void FactSlotValueFunction(
|
242
|
+
Environment *theEnv,
|
243
|
+
UDFContext *context,
|
244
|
+
UDFValue *returnValue)
|
245
|
+
{
|
246
|
+
Fact *theFact;
|
247
|
+
UDFValue theArg;
|
248
|
+
CLIPSValue result;
|
249
|
+
|
250
|
+
/*================================*/
|
251
|
+
/* Get the reference to the fact. */
|
252
|
+
/*================================*/
|
253
|
+
|
254
|
+
theFact = GetFactAddressOrIndexArgument(context,true);
|
255
|
+
if (theFact == NULL)
|
256
|
+
{
|
257
|
+
returnValue->lexemeValue = FalseSymbol(theEnv);
|
258
|
+
return;
|
259
|
+
}
|
260
|
+
|
261
|
+
/*===========================*/
|
262
|
+
/* Get the name of the slot. */
|
263
|
+
/*===========================*/
|
264
|
+
|
265
|
+
if (! UDFNextArgument(context,SYMBOL_BIT,&theArg))
|
266
|
+
{ return; }
|
267
|
+
|
268
|
+
/*=======================*/
|
269
|
+
/* Get the slot's value. */
|
270
|
+
/*=======================*/
|
271
|
+
|
272
|
+
FactSlotValue(theEnv,theFact,theArg.lexemeValue->contents,&result);
|
273
|
+
CLIPSToUDFValue(&result,returnValue);
|
274
|
+
}
|
275
|
+
|
276
|
+
/***************************************/
|
277
|
+
/* FactSlotValue: C access routine for */
|
278
|
+
/* the fact-slot-value function. */
|
279
|
+
/***************************************/
|
280
|
+
void FactSlotValue(
|
281
|
+
Environment *theEnv,
|
282
|
+
Fact *theFact,
|
283
|
+
const char *theSlotName,
|
284
|
+
CLIPSValue *returnValue)
|
285
|
+
{
|
286
|
+
/*==================================================*/
|
287
|
+
/* Make sure the slot exists (the symbol implied is */
|
288
|
+
/* used for the implied slot of an ordered fact). */
|
289
|
+
/*==================================================*/
|
290
|
+
|
291
|
+
if (theFact->whichDeftemplate->implied)
|
292
|
+
{
|
293
|
+
if (strcmp(theSlotName,"implied") != 0)
|
294
|
+
{
|
295
|
+
SetEvaluationError(theEnv,true);
|
296
|
+
InvalidDeftemplateSlotMessage(theEnv,theSlotName,
|
297
|
+
theFact->whichDeftemplate->header.name->contents,false);
|
298
|
+
returnValue->lexemeValue = FalseSymbol(theEnv);
|
299
|
+
return;
|
300
|
+
}
|
301
|
+
}
|
302
|
+
|
303
|
+
else if (FindSlot(theFact->whichDeftemplate,CreateSymbol(theEnv,theSlotName),NULL) == NULL)
|
304
|
+
{
|
305
|
+
SetEvaluationError(theEnv,true);
|
306
|
+
InvalidDeftemplateSlotMessage(theEnv,theSlotName,
|
307
|
+
theFact->whichDeftemplate->header.name->contents,false);
|
308
|
+
returnValue->lexemeValue = FalseSymbol(theEnv);
|
309
|
+
return;
|
310
|
+
}
|
311
|
+
|
312
|
+
/*==========================*/
|
313
|
+
/* Return the slot's value. */
|
314
|
+
/*==========================*/
|
315
|
+
|
316
|
+
if (theFact->whichDeftemplate->implied)
|
317
|
+
{ GetFactSlot(theFact,NULL,returnValue); }
|
318
|
+
else
|
319
|
+
{ GetFactSlot(theFact,theSlotName,returnValue); }
|
320
|
+
}
|
321
|
+
|
322
|
+
/***********************************************/
|
323
|
+
/* FactSlotNamesFunction: H/L access routine */
|
324
|
+
/* for the fact-slot-names function. */
|
325
|
+
/***********************************************/
|
326
|
+
void FactSlotNamesFunction(
|
327
|
+
Environment *theEnv,
|
328
|
+
UDFContext *context,
|
329
|
+
UDFValue *returnValue)
|
330
|
+
{
|
331
|
+
Fact *theFact;
|
332
|
+
CLIPSValue result;
|
333
|
+
|
334
|
+
/*================================*/
|
335
|
+
/* Get the reference to the fact. */
|
336
|
+
/*================================*/
|
337
|
+
|
338
|
+
theFact = GetFactAddressOrIndexArgument(context,true);
|
339
|
+
if (theFact == NULL)
|
340
|
+
{
|
341
|
+
returnValue->lexemeValue = FalseSymbol(theEnv);
|
342
|
+
return;
|
343
|
+
}
|
344
|
+
|
345
|
+
/*=====================*/
|
346
|
+
/* Get the slot names. */
|
347
|
+
/*=====================*/
|
348
|
+
|
349
|
+
FactSlotNames(theFact,&result);
|
350
|
+
CLIPSToUDFValue(&result,returnValue);
|
351
|
+
}
|
352
|
+
|
353
|
+
/***************************************/
|
354
|
+
/* FactSlotNames: C access routine */
|
355
|
+
/* for the fact-slot-names function. */
|
356
|
+
/***************************************/
|
357
|
+
void FactSlotNames(
|
358
|
+
Fact *theFact,
|
359
|
+
CLIPSValue *returnValue)
|
360
|
+
{
|
361
|
+
Multifield *theList;
|
362
|
+
struct templateSlot *theSlot;
|
363
|
+
unsigned long count;
|
364
|
+
Environment *theEnv = theFact->whichDeftemplate->header.env;
|
365
|
+
|
366
|
+
/*===============================================*/
|
367
|
+
/* If we're dealing with an implied deftemplate, */
|
368
|
+
/* then the only slot names is "implied." */
|
369
|
+
/*===============================================*/
|
370
|
+
|
371
|
+
if (theFact->whichDeftemplate->implied)
|
372
|
+
{
|
373
|
+
theList = CreateMultifield(theEnv,1);
|
374
|
+
theList->contents[0].lexemeValue = CreateSymbol(theEnv,"implied");
|
375
|
+
returnValue->value = theList;
|
376
|
+
return;
|
377
|
+
}
|
378
|
+
|
379
|
+
/*=================================*/
|
380
|
+
/* Count the number of slot names. */
|
381
|
+
/*=================================*/
|
382
|
+
|
383
|
+
for (count = 0, theSlot = theFact->whichDeftemplate->slotList;
|
384
|
+
theSlot != NULL;
|
385
|
+
count++, theSlot = theSlot->next)
|
386
|
+
{ /* Do Nothing */ }
|
387
|
+
|
388
|
+
/*=============================================================*/
|
389
|
+
/* Create a multifield value in which to store the slot names. */
|
390
|
+
/*=============================================================*/
|
391
|
+
|
392
|
+
theList = CreateMultifield(theEnv,count);
|
393
|
+
returnValue->value = theList;
|
394
|
+
|
395
|
+
/*===============================================*/
|
396
|
+
/* Store the slot names in the multifield value. */
|
397
|
+
/*===============================================*/
|
398
|
+
|
399
|
+
for (count = 0, theSlot = theFact->whichDeftemplate->slotList;
|
400
|
+
theSlot != NULL;
|
401
|
+
count++, theSlot = theSlot->next)
|
402
|
+
{
|
403
|
+
theList->contents[count].lexemeValue = theSlot->slotName;
|
404
|
+
}
|
405
|
+
}
|
406
|
+
|
407
|
+
/*********************************************/
|
408
|
+
/* GetFactListFunction: H/L access routine */
|
409
|
+
/* for the get-fact-list function. */
|
410
|
+
/*********************************************/
|
411
|
+
void GetFactListFunction(
|
412
|
+
Environment *theEnv,
|
413
|
+
UDFContext *context,
|
414
|
+
UDFValue *returnValue)
|
415
|
+
{
|
416
|
+
Defmodule *theModule;
|
417
|
+
UDFValue theArg;
|
418
|
+
CLIPSValue result;
|
419
|
+
|
420
|
+
/*===========================================*/
|
421
|
+
/* Determine if a module name was specified. */
|
422
|
+
/*===========================================*/
|
423
|
+
|
424
|
+
if (UDFHasNextArgument(context))
|
425
|
+
{
|
426
|
+
if (! UDFFirstArgument(context,SYMBOL_BIT,&theArg))
|
427
|
+
{ return; }
|
428
|
+
|
429
|
+
if ((theModule = FindDefmodule(theEnv,theArg.lexemeValue->contents)) == NULL)
|
430
|
+
{
|
431
|
+
if (strcmp("*",theArg.lexemeValue->contents) != 0)
|
432
|
+
{
|
433
|
+
SetMultifieldErrorValue(theEnv,returnValue);
|
434
|
+
UDFInvalidArgumentMessage(context,"defmodule name");
|
435
|
+
return;
|
436
|
+
}
|
437
|
+
|
438
|
+
theModule = NULL;
|
439
|
+
}
|
440
|
+
}
|
441
|
+
else
|
442
|
+
{ theModule = GetCurrentModule(theEnv); }
|
443
|
+
|
444
|
+
/*=====================*/
|
445
|
+
/* Get the constructs. */
|
446
|
+
/*=====================*/
|
447
|
+
|
448
|
+
GetFactList(theEnv,&result,theModule);
|
449
|
+
CLIPSToUDFValue(&result,returnValue);
|
450
|
+
}
|
451
|
+
|
452
|
+
/*************************************/
|
453
|
+
/* GetFactList: C access routine */
|
454
|
+
/* for the get-fact-list function. */
|
455
|
+
/*************************************/
|
456
|
+
void GetFactList(
|
457
|
+
Environment *theEnv,
|
458
|
+
CLIPSValue *returnValue,
|
459
|
+
Defmodule *theModule)
|
460
|
+
{
|
461
|
+
Fact *theFact;
|
462
|
+
unsigned long count;
|
463
|
+
Multifield *theList;
|
464
|
+
|
465
|
+
/*==========================*/
|
466
|
+
/* Save the current module. */
|
467
|
+
/*==========================*/
|
468
|
+
|
469
|
+
SaveCurrentModule(theEnv);
|
470
|
+
|
471
|
+
/*============================================*/
|
472
|
+
/* Count the number of facts to be retrieved. */
|
473
|
+
/*============================================*/
|
474
|
+
|
475
|
+
if (theModule == NULL)
|
476
|
+
{
|
477
|
+
for (theFact = GetNextFact(theEnv,NULL), count = 0;
|
478
|
+
theFact != NULL;
|
479
|
+
theFact = GetNextFact(theEnv,theFact), count++)
|
480
|
+
{ /* Do Nothing */ }
|
481
|
+
}
|
482
|
+
else
|
483
|
+
{
|
484
|
+
SetCurrentModule(theEnv,theModule);
|
485
|
+
UpdateDeftemplateScope(theEnv);
|
486
|
+
for (theFact = GetNextFactInScope(theEnv,NULL), count = 0;
|
487
|
+
theFact != NULL;
|
488
|
+
theFact = GetNextFactInScope(theEnv,theFact), count++)
|
489
|
+
{ /* Do Nothing */ }
|
490
|
+
}
|
491
|
+
|
492
|
+
/*===========================================================*/
|
493
|
+
/* Create the multifield value to store the construct names. */
|
494
|
+
/*===========================================================*/
|
495
|
+
|
496
|
+
theList = CreateMultifield(theEnv,count);
|
497
|
+
returnValue->value = theList;
|
498
|
+
|
499
|
+
/*==================================================*/
|
500
|
+
/* Store the fact pointers in the multifield value. */
|
501
|
+
/*==================================================*/
|
502
|
+
|
503
|
+
if (theModule == NULL)
|
504
|
+
{
|
505
|
+
for (theFact = GetNextFact(theEnv,NULL), count = 0;
|
506
|
+
theFact != NULL;
|
507
|
+
theFact = GetNextFact(theEnv,theFact), count++)
|
508
|
+
{
|
509
|
+
theList->contents[count].factValue = theFact;
|
510
|
+
}
|
511
|
+
}
|
512
|
+
else
|
513
|
+
{
|
514
|
+
for (theFact = GetNextFactInScope(theEnv,NULL), count = 0;
|
515
|
+
theFact != NULL;
|
516
|
+
theFact = GetNextFactInScope(theEnv,theFact), count++)
|
517
|
+
{
|
518
|
+
theList->contents[count].factValue = theFact;
|
519
|
+
}
|
520
|
+
}
|
521
|
+
|
522
|
+
/*=============================*/
|
523
|
+
/* Restore the current module. */
|
524
|
+
/*=============================*/
|
525
|
+
|
526
|
+
RestoreCurrentModule(theEnv);
|
527
|
+
UpdateDeftemplateScope(theEnv);
|
528
|
+
}
|
529
|
+
|
530
|
+
/**************************************/
|
531
|
+
/* PPFactFunction: H/L access routine */
|
532
|
+
/* for the ppfact function. */
|
533
|
+
/**************************************/
|
534
|
+
void PPFactFunction(
|
535
|
+
Environment *theEnv,
|
536
|
+
UDFContext *context,
|
537
|
+
UDFValue *returnValue)
|
538
|
+
{
|
539
|
+
Fact *theFact;
|
540
|
+
const char *logicalName = NULL; /* Avoids warning */
|
541
|
+
bool ignoreDefaults = false;
|
542
|
+
UDFValue theArg;
|
543
|
+
|
544
|
+
theFact = GetFactAddressOrIndexArgument(context,true);
|
545
|
+
if (theFact == NULL) return;
|
546
|
+
|
547
|
+
/*===============================================================*/
|
548
|
+
/* Determine the logical name to which the fact will be printed. */
|
549
|
+
/*===============================================================*/
|
550
|
+
|
551
|
+
if (UDFHasNextArgument(context))
|
552
|
+
{
|
553
|
+
logicalName = GetLogicalName(context,STDOUT);
|
554
|
+
if (logicalName == NULL)
|
555
|
+
{
|
556
|
+
IllegalLogicalNameMessage(theEnv,"ppfact");
|
557
|
+
SetHaltExecution(theEnv,true);
|
558
|
+
SetEvaluationError(theEnv,true);
|
559
|
+
return;
|
560
|
+
}
|
561
|
+
}
|
562
|
+
else
|
563
|
+
{ logicalName = STDOUT; }
|
564
|
+
|
565
|
+
/*=========================================*/
|
566
|
+
/* Should slot values be printed if they */
|
567
|
+
/* are the same as the default slot value. */
|
568
|
+
/*=========================================*/
|
569
|
+
|
570
|
+
if (UDFHasNextArgument(context))
|
571
|
+
{
|
572
|
+
UDFNextArgument(context,ANY_TYPE_BITS,&theArg);
|
573
|
+
|
574
|
+
if (theArg.value == FalseSymbol(theEnv))
|
575
|
+
{ ignoreDefaults = false; }
|
576
|
+
else
|
577
|
+
{ ignoreDefaults = true; }
|
578
|
+
}
|
579
|
+
|
580
|
+
/*============================================================*/
|
581
|
+
/* Determine if any router recognizes the output destination. */
|
582
|
+
/*============================================================*/
|
583
|
+
|
584
|
+
if (strcmp(logicalName,"nil") == 0)
|
585
|
+
{
|
586
|
+
StringBuilder *theSB;
|
587
|
+
|
588
|
+
theSB = CreateStringBuilder(theEnv,256);
|
589
|
+
|
590
|
+
FactPPForm(theFact,theSB,ignoreDefaults);
|
591
|
+
returnValue->lexemeValue = CreateString(theEnv,theSB->contents);
|
592
|
+
|
593
|
+
SBDispose(theSB);
|
594
|
+
|
595
|
+
return;
|
596
|
+
}
|
597
|
+
else if (QueryRouters(theEnv,logicalName) == false)
|
598
|
+
{
|
599
|
+
UnrecognizedRouterMessage(theEnv,logicalName);
|
600
|
+
return;
|
601
|
+
}
|
602
|
+
|
603
|
+
PPFact(theFact,logicalName,ignoreDefaults);
|
604
|
+
}
|
605
|
+
|
606
|
+
/******************************/
|
607
|
+
/* PPFact: C access routine */
|
608
|
+
/* for the ppfact function. */
|
609
|
+
/******************************/
|
610
|
+
void PPFact(
|
611
|
+
Fact *theFact,
|
612
|
+
const char *logicalName,
|
613
|
+
bool ignoreDefaults)
|
614
|
+
{
|
615
|
+
Environment *theEnv = theFact->whichDeftemplate->header.env;
|
616
|
+
|
617
|
+
if (theFact == NULL) return;
|
618
|
+
|
619
|
+
if (theFact->garbage) return;
|
620
|
+
|
621
|
+
PrintFact(theEnv,logicalName,theFact,true,ignoreDefaults,NULL);
|
622
|
+
|
623
|
+
WriteString(theEnv,logicalName,"\n");
|
624
|
+
}
|
625
|
+
|
626
|
+
/**************************************************************/
|
627
|
+
/* GetFactAddressOrIndexArgument: Retrieves an argument for a */
|
628
|
+
/* function which should be a reference to a valid fact. */
|
629
|
+
/**************************************************************/
|
630
|
+
Fact *GetFactAddressOrIndexArgument(
|
631
|
+
UDFContext *context,
|
632
|
+
bool noFactError)
|
633
|
+
{
|
634
|
+
UDFValue theArg;
|
635
|
+
long long factIndex;
|
636
|
+
Fact *theFact;
|
637
|
+
Environment *theEnv = context->environment;
|
638
|
+
char tempBuffer[20];
|
639
|
+
|
640
|
+
if (! UDFNextArgument(context,ANY_TYPE_BITS,&theArg))
|
641
|
+
{ return NULL; }
|
642
|
+
|
643
|
+
if (theArg.header->type == FACT_ADDRESS_TYPE)
|
644
|
+
{
|
645
|
+
if (theArg.factValue->garbage)
|
646
|
+
{
|
647
|
+
if (noFactError)
|
648
|
+
{
|
649
|
+
FactRetractedErrorMessage(theEnv,theArg.factValue);
|
650
|
+
SetEvaluationError(theEnv,true);
|
651
|
+
}
|
652
|
+
return NULL;
|
653
|
+
}
|
654
|
+
else return theArg.factValue;
|
655
|
+
}
|
656
|
+
else if (theArg.header->type == INTEGER_TYPE)
|
657
|
+
{
|
658
|
+
factIndex = theArg.integerValue->contents;
|
659
|
+
if (factIndex < 0)
|
660
|
+
{
|
661
|
+
UDFInvalidArgumentMessage(context,"fact-address or fact-index");
|
662
|
+
return NULL;
|
663
|
+
}
|
664
|
+
|
665
|
+
theFact = FindIndexedFact(theEnv,factIndex);
|
666
|
+
if ((theFact == NULL) && noFactError)
|
667
|
+
{
|
668
|
+
gensnprintf(tempBuffer,sizeof(tempBuffer),"f-%lld",factIndex);
|
669
|
+
CantFindItemErrorMessage(theEnv,"fact",tempBuffer,false);
|
670
|
+
return NULL;
|
671
|
+
}
|
672
|
+
|
673
|
+
return theFact;
|
674
|
+
}
|
675
|
+
|
676
|
+
UDFInvalidArgumentMessage(context,"fact-address or fact-index");
|
677
|
+
return NULL;
|
678
|
+
}
|
679
|
+
|
680
|
+
#endif /* DEFTEMPLATE_CONSTRUCT */
|
681
|
+
|
682
|
+
|