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,976 @@
|
|
1
|
+
/*******************************************************/
|
2
|
+
/* "C" Language Integrated Production System */
|
3
|
+
/* */
|
4
|
+
/* CLIPS Version 6.40 02/03/21 */
|
5
|
+
/* */
|
6
|
+
/* CLASS COMMANDS MODULE */
|
7
|
+
/*******************************************************/
|
8
|
+
|
9
|
+
/**************************************************************/
|
10
|
+
/* Purpose: Kernel Interface Commands for Object System */
|
11
|
+
/* */
|
12
|
+
/* Principal Programmer(s): */
|
13
|
+
/* Brian L. Dantes */
|
14
|
+
/* */
|
15
|
+
/* Contributing Programmer(s): */
|
16
|
+
/* */
|
17
|
+
/* Revision History: */
|
18
|
+
/* */
|
19
|
+
/* 6.23: Corrected compilation errors for files */
|
20
|
+
/* generated by constructs-to-c. DR0861 */
|
21
|
+
/* */
|
22
|
+
/* Changed name of variable log to logName */
|
23
|
+
/* because of Unix compiler warnings of shadowed */
|
24
|
+
/* definitions. */
|
25
|
+
/* */
|
26
|
+
/* 6.24: Renamed BOOLEAN macro type to intBool. */
|
27
|
+
/* */
|
28
|
+
/* Added pragmas to remove compilation warnings. */
|
29
|
+
/* */
|
30
|
+
/* 6.30: Borland C (IBM_TBC) and Metrowerks CodeWarrior */
|
31
|
+
/* (MAC_MCW, IBM_MCW) are no longer supported. */
|
32
|
+
/* */
|
33
|
+
/* Added const qualifiers to remove C++ */
|
34
|
+
/* deprecation warnings. */
|
35
|
+
/* */
|
36
|
+
/* Converted API macros to function calls. */
|
37
|
+
/* */
|
38
|
+
/* Changed find construct functionality so that */
|
39
|
+
/* imported modules are search when locating a */
|
40
|
+
/* named construct. */
|
41
|
+
/* */
|
42
|
+
/* 6.40: Pragma once and other inclusion changes. */
|
43
|
+
/* */
|
44
|
+
/* Added support for booleans with <stdbool.h>. */
|
45
|
+
/* */
|
46
|
+
/* Removed use of void pointers for specific */
|
47
|
+
/* data structures. */
|
48
|
+
/* */
|
49
|
+
/* ALLOW_ENVIRONMENT_GLOBALS no longer supported. */
|
50
|
+
/* */
|
51
|
+
/* UDF redesign. */
|
52
|
+
/* */
|
53
|
+
/* Pretty print functions accept optional logical */
|
54
|
+
/* name argument. */
|
55
|
+
/* */
|
56
|
+
/*************************************************************/
|
57
|
+
|
58
|
+
/* =========================================
|
59
|
+
*****************************************
|
60
|
+
EXTERNAL DEFINITIONS
|
61
|
+
=========================================
|
62
|
+
***************************************** */
|
63
|
+
|
64
|
+
#include <string.h>
|
65
|
+
|
66
|
+
#include "setup.h"
|
67
|
+
|
68
|
+
#if OBJECT_SYSTEM
|
69
|
+
|
70
|
+
#if BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE
|
71
|
+
#include "bload.h"
|
72
|
+
#endif
|
73
|
+
|
74
|
+
#include "argacces.h"
|
75
|
+
#include "classfun.h"
|
76
|
+
#include "classini.h"
|
77
|
+
#include "envrnmnt.h"
|
78
|
+
#include "modulutl.h"
|
79
|
+
#include "msgcom.h"
|
80
|
+
#include "prntutil.h"
|
81
|
+
#include "router.h"
|
82
|
+
|
83
|
+
#include "classcom.h"
|
84
|
+
|
85
|
+
/***************************************/
|
86
|
+
/* LOCAL INTERNAL FUNCTION DEFINITIONS */
|
87
|
+
/***************************************/
|
88
|
+
|
89
|
+
#if (! BLOAD_ONLY) && (! RUN_TIME) && DEBUGGING_FUNCTIONS
|
90
|
+
static void SaveDefclass(Environment *,ConstructHeader *,void *);
|
91
|
+
#endif
|
92
|
+
static const char *GetClassDefaultsModeName(ClassDefaultsMode);
|
93
|
+
|
94
|
+
/* =========================================
|
95
|
+
*****************************************
|
96
|
+
EXTERNALLY VISIBLE FUNCTIONS
|
97
|
+
=========================================
|
98
|
+
***************************************** */
|
99
|
+
|
100
|
+
/*******************************************************************
|
101
|
+
NAME : FindDefclass
|
102
|
+
DESCRIPTION : Looks up a specified class in the class hash table
|
103
|
+
(Only looks in current or specified module)
|
104
|
+
INPUTS : The name-string of the class (including module)
|
105
|
+
RETURNS : The address of the found class, NULL otherwise
|
106
|
+
SIDE EFFECTS : None
|
107
|
+
NOTES : None
|
108
|
+
******************************************************************/
|
109
|
+
Defclass *FindDefclass( // TBD Needs to look in imported
|
110
|
+
Environment *theEnv,
|
111
|
+
const char *classAndModuleName)
|
112
|
+
{
|
113
|
+
CLIPSLexeme *classSymbol = NULL;
|
114
|
+
Defclass *cls;
|
115
|
+
Defmodule *theModule = NULL;
|
116
|
+
const char *className;
|
117
|
+
|
118
|
+
SaveCurrentModule(theEnv);
|
119
|
+
|
120
|
+
className = ExtractModuleAndConstructName(theEnv,classAndModuleName);
|
121
|
+
if (className != NULL)
|
122
|
+
{
|
123
|
+
classSymbol = FindSymbolHN(theEnv,ExtractModuleAndConstructName(theEnv,classAndModuleName),SYMBOL_BIT);
|
124
|
+
theModule = GetCurrentModule(theEnv);
|
125
|
+
}
|
126
|
+
|
127
|
+
RestoreCurrentModule(theEnv);
|
128
|
+
|
129
|
+
if (classSymbol == NULL)
|
130
|
+
{ return NULL; }
|
131
|
+
|
132
|
+
cls = DefclassData(theEnv)->ClassTable[HashClass(classSymbol)];
|
133
|
+
while (cls != NULL)
|
134
|
+
{
|
135
|
+
if (cls->header.name == classSymbol)
|
136
|
+
{
|
137
|
+
if (cls->system || (cls->header.whichModule->theModule == theModule))
|
138
|
+
{ return cls->installed ? cls : NULL; }
|
139
|
+
}
|
140
|
+
cls = cls->nxtHash;
|
141
|
+
}
|
142
|
+
|
143
|
+
return NULL;
|
144
|
+
}
|
145
|
+
|
146
|
+
/*******************************************************************
|
147
|
+
NAME : FindDefclassInModule
|
148
|
+
DESCRIPTION : Looks up a specified class in the class hash table
|
149
|
+
(Only looks in current or specified module)
|
150
|
+
INPUTS : The name-string of the class (including module)
|
151
|
+
RETURNS : The address of the found class, NULL otherwise
|
152
|
+
SIDE EFFECTS : None
|
153
|
+
NOTES : None
|
154
|
+
******************************************************************/
|
155
|
+
Defclass *FindDefclassInModule(
|
156
|
+
Environment *theEnv,
|
157
|
+
const char *classAndModuleName)
|
158
|
+
{
|
159
|
+
CLIPSLexeme *classSymbol = NULL;
|
160
|
+
Defclass *cls;
|
161
|
+
Defmodule *theModule = NULL;
|
162
|
+
const char *className;
|
163
|
+
|
164
|
+
SaveCurrentModule(theEnv);
|
165
|
+
className = ExtractModuleAndConstructName(theEnv,classAndModuleName);
|
166
|
+
if (className != NULL)
|
167
|
+
{
|
168
|
+
classSymbol = FindSymbolHN(theEnv,ExtractModuleAndConstructName(theEnv,classAndModuleName),SYMBOL_BIT);
|
169
|
+
theModule = GetCurrentModule(theEnv);
|
170
|
+
}
|
171
|
+
RestoreCurrentModule(theEnv);
|
172
|
+
|
173
|
+
if (classSymbol == NULL)
|
174
|
+
{ return NULL; }
|
175
|
+
|
176
|
+
cls = DefclassData(theEnv)->ClassTable[HashClass(classSymbol)];
|
177
|
+
while (cls != NULL)
|
178
|
+
{
|
179
|
+
if (cls->header.name == classSymbol)
|
180
|
+
{
|
181
|
+
if (cls->system || (cls->header.whichModule->theModule == theModule))
|
182
|
+
{ return cls->installed ? cls : NULL; }
|
183
|
+
}
|
184
|
+
cls = cls->nxtHash;
|
185
|
+
}
|
186
|
+
|
187
|
+
return NULL;
|
188
|
+
}
|
189
|
+
|
190
|
+
/***************************************************
|
191
|
+
NAME : LookupDefclassByMdlOrScope
|
192
|
+
DESCRIPTION : Finds a class anywhere (if module
|
193
|
+
is specified) or in current or
|
194
|
+
imported modules
|
195
|
+
INPUTS : The class name
|
196
|
+
RETURNS : The class (NULL if not found)
|
197
|
+
SIDE EFFECTS : Error message printed on
|
198
|
+
ambiguous references
|
199
|
+
NOTES : Assumes no two classes of the same
|
200
|
+
name are ever in the same scope
|
201
|
+
***************************************************/
|
202
|
+
Defclass *LookupDefclassByMdlOrScope(
|
203
|
+
Environment *theEnv,
|
204
|
+
const char *classAndModuleName)
|
205
|
+
{
|
206
|
+
Defclass *cls;
|
207
|
+
const char *className;
|
208
|
+
CLIPSLexeme *classSymbol;
|
209
|
+
Defmodule *theModule;
|
210
|
+
|
211
|
+
if (FindModuleSeparator(classAndModuleName) == 0)
|
212
|
+
{ return LookupDefclassInScope(theEnv,classAndModuleName); }
|
213
|
+
|
214
|
+
SaveCurrentModule(theEnv);
|
215
|
+
className = ExtractModuleAndConstructName(theEnv,classAndModuleName);
|
216
|
+
theModule = GetCurrentModule(theEnv);
|
217
|
+
RestoreCurrentModule(theEnv);
|
218
|
+
|
219
|
+
if (className == NULL)
|
220
|
+
{ return NULL; }
|
221
|
+
|
222
|
+
if ((classSymbol = FindSymbolHN(theEnv,className,SYMBOL_BIT)) == NULL)
|
223
|
+
{ return NULL; }
|
224
|
+
|
225
|
+
cls = DefclassData(theEnv)->ClassTable[HashClass(classSymbol)];
|
226
|
+
while (cls != NULL)
|
227
|
+
{
|
228
|
+
if ((cls->header.name == classSymbol) &&
|
229
|
+
(cls->header.whichModule->theModule == theModule))
|
230
|
+
return(cls->installed ? cls : NULL);
|
231
|
+
cls = cls->nxtHash;
|
232
|
+
}
|
233
|
+
|
234
|
+
return NULL;
|
235
|
+
}
|
236
|
+
|
237
|
+
/****************************************************
|
238
|
+
NAME : LookupDefclassInScope
|
239
|
+
DESCRIPTION : Finds a class in current or imported
|
240
|
+
modules (module specifier
|
241
|
+
is not allowed)
|
242
|
+
INPUTS : The class name
|
243
|
+
RETURNS : The class (NULL if not found)
|
244
|
+
SIDE EFFECTS : Error message printed on
|
245
|
+
ambiguous references
|
246
|
+
NOTES : Assumes no two classes of the same
|
247
|
+
name are ever in the same scope
|
248
|
+
****************************************************/
|
249
|
+
Defclass *LookupDefclassInScope(
|
250
|
+
Environment *theEnv,
|
251
|
+
const char *className)
|
252
|
+
{
|
253
|
+
Defclass *cls;
|
254
|
+
CLIPSLexeme *classSymbol;
|
255
|
+
|
256
|
+
if ((classSymbol = FindSymbolHN(theEnv,className,SYMBOL_BIT)) == NULL)
|
257
|
+
{ return NULL; }
|
258
|
+
|
259
|
+
cls = DefclassData(theEnv)->ClassTable[HashClass(classSymbol)];
|
260
|
+
while (cls != NULL)
|
261
|
+
{
|
262
|
+
if ((cls->header.name == classSymbol) && DefclassInScope(theEnv,cls,NULL))
|
263
|
+
return cls->installed ? cls : NULL;
|
264
|
+
cls = cls->nxtHash;
|
265
|
+
}
|
266
|
+
|
267
|
+
return NULL;
|
268
|
+
}
|
269
|
+
|
270
|
+
/******************************************************
|
271
|
+
NAME : LookupDefclassAnywhere
|
272
|
+
DESCRIPTION : Finds a class in specified
|
273
|
+
(or any) module
|
274
|
+
INPUTS : 1) The module (NULL if don't care)
|
275
|
+
2) The class name (module specifier
|
276
|
+
in name not allowed)
|
277
|
+
RETURNS : The class (NULL if not found)
|
278
|
+
SIDE EFFECTS : None
|
279
|
+
NOTES : Does *not* generate an error if
|
280
|
+
multiple classes of the same name
|
281
|
+
exist as do the other lookup functions
|
282
|
+
******************************************************/
|
283
|
+
Defclass *LookupDefclassAnywhere(
|
284
|
+
Environment *theEnv,
|
285
|
+
Defmodule *theModule,
|
286
|
+
const char *className)
|
287
|
+
{
|
288
|
+
Defclass *cls;
|
289
|
+
CLIPSLexeme *classSymbol;
|
290
|
+
|
291
|
+
if ((classSymbol = FindSymbolHN(theEnv,className,SYMBOL_BIT)) == NULL)
|
292
|
+
{ return NULL; }
|
293
|
+
|
294
|
+
cls = DefclassData(theEnv)->ClassTable[HashClass(classSymbol)];
|
295
|
+
while (cls != NULL)
|
296
|
+
{
|
297
|
+
if ((cls->header.name == classSymbol) &&
|
298
|
+
((theModule == NULL) ||
|
299
|
+
(cls->header.whichModule->theModule == theModule)))
|
300
|
+
{ return cls->installed ? cls : NULL; }
|
301
|
+
cls = cls->nxtHash;
|
302
|
+
}
|
303
|
+
|
304
|
+
return NULL;
|
305
|
+
}
|
306
|
+
|
307
|
+
/***************************************************
|
308
|
+
NAME : DefclassInScope
|
309
|
+
DESCRIPTION : Determines if a defclass is in
|
310
|
+
scope of the given module
|
311
|
+
INPUTS : 1) The defclass
|
312
|
+
2) The module (NULL for current
|
313
|
+
module)
|
314
|
+
RETURNS : True if in scope,
|
315
|
+
false otherwise
|
316
|
+
SIDE EFFECTS : None
|
317
|
+
NOTES : None
|
318
|
+
***************************************************/
|
319
|
+
bool DefclassInScope(
|
320
|
+
Environment *theEnv,
|
321
|
+
Defclass *theDefclass,
|
322
|
+
Defmodule *theModule)
|
323
|
+
{
|
324
|
+
#if DEFMODULE_CONSTRUCT
|
325
|
+
unsigned long moduleID;
|
326
|
+
const char *scopeMap;
|
327
|
+
|
328
|
+
scopeMap = (const char *) theDefclass->scopeMap->contents;
|
329
|
+
if (theModule == NULL)
|
330
|
+
{ theModule = GetCurrentModule(theEnv); }
|
331
|
+
moduleID = theModule->header.bsaveID;
|
332
|
+
|
333
|
+
return TestBitMap(scopeMap,moduleID);
|
334
|
+
#else
|
335
|
+
#if MAC_XCD
|
336
|
+
#pragma unused(theEnv,theDefclass,theModule)
|
337
|
+
#endif
|
338
|
+
return true;
|
339
|
+
#endif
|
340
|
+
}
|
341
|
+
|
342
|
+
/***********************************************************
|
343
|
+
NAME : GetNextDefclass
|
344
|
+
DESCRIPTION : Finds first or next defclass
|
345
|
+
INPUTS : The address of the current defclass
|
346
|
+
RETURNS : The address of the next defclass
|
347
|
+
(NULL if none)
|
348
|
+
SIDE EFFECTS : None
|
349
|
+
NOTES : If ptr == NULL, the first defclass
|
350
|
+
is returned.
|
351
|
+
***********************************************************/
|
352
|
+
Defclass *GetNextDefclass(
|
353
|
+
Environment *theEnv,
|
354
|
+
Defclass *theDefclass)
|
355
|
+
{
|
356
|
+
return (Defclass *) GetNextConstructItem(theEnv,&theDefclass->header,
|
357
|
+
DefclassData(theEnv)->DefclassModuleIndex);
|
358
|
+
}
|
359
|
+
|
360
|
+
/***************************************************
|
361
|
+
NAME : DefclassIsDeletable
|
362
|
+
DESCRIPTION : Determines if a defclass
|
363
|
+
can be deleted
|
364
|
+
INPUTS : Address of the defclass
|
365
|
+
RETURNS : True if deletable,
|
366
|
+
false otherwise
|
367
|
+
SIDE EFFECTS : None
|
368
|
+
NOTES : None
|
369
|
+
***************************************************/
|
370
|
+
bool DefclassIsDeletable(
|
371
|
+
Defclass *theDefclass)
|
372
|
+
{
|
373
|
+
Environment *theEnv = theDefclass->header.env;
|
374
|
+
|
375
|
+
if (! ConstructsDeletable(theEnv))
|
376
|
+
{ return false; }
|
377
|
+
|
378
|
+
if (theDefclass->system == 1)
|
379
|
+
{ return false; }
|
380
|
+
|
381
|
+
#if (! BLOAD_ONLY) && (! RUN_TIME)
|
382
|
+
return (IsClassBeingUsed(theDefclass) == false) ? true : false;
|
383
|
+
#else
|
384
|
+
return false;
|
385
|
+
#endif
|
386
|
+
}
|
387
|
+
|
388
|
+
/*************************************************************
|
389
|
+
NAME : UndefclassCommand
|
390
|
+
DESCRIPTION : Deletes a class and its subclasses, as
|
391
|
+
well as their associated instances
|
392
|
+
INPUTS : None
|
393
|
+
RETURNS : Nothing useful
|
394
|
+
SIDE EFFECTS : None
|
395
|
+
NOTES : Syntax : (undefclass <class-name> | *)
|
396
|
+
*************************************************************/
|
397
|
+
void UndefclassCommand(
|
398
|
+
Environment *theEnv,
|
399
|
+
UDFContext *context,
|
400
|
+
UDFValue *returnValue)
|
401
|
+
{
|
402
|
+
UndefconstructCommand(context,"undefclass",DefclassData(theEnv)->DefclassConstruct);
|
403
|
+
}
|
404
|
+
|
405
|
+
/********************************************************
|
406
|
+
NAME : Undefclass
|
407
|
+
DESCRIPTION : Deletes the named defclass
|
408
|
+
INPUTS : None
|
409
|
+
RETURNS : True if deleted, or false
|
410
|
+
SIDE EFFECTS : Defclass and handlers removed
|
411
|
+
NOTES : Interface for AddConstruct()
|
412
|
+
********************************************************/
|
413
|
+
bool Undefclass(
|
414
|
+
Defclass *theDefclass,
|
415
|
+
Environment *allEnv)
|
416
|
+
{
|
417
|
+
#if RUN_TIME || BLOAD_ONLY
|
418
|
+
return false;
|
419
|
+
#else
|
420
|
+
Environment *theEnv;
|
421
|
+
bool success;
|
422
|
+
GCBlock gcb;
|
423
|
+
|
424
|
+
if (theDefclass == NULL)
|
425
|
+
{ theEnv = allEnv; }
|
426
|
+
else
|
427
|
+
{ theEnv = theDefclass->header.env; }
|
428
|
+
|
429
|
+
#if BLOAD || BLOAD_AND_BSAVE
|
430
|
+
if (Bloaded(theEnv))
|
431
|
+
return false;
|
432
|
+
#endif
|
433
|
+
|
434
|
+
GCBlockStart(theEnv,&gcb);
|
435
|
+
if (theDefclass == NULL)
|
436
|
+
{
|
437
|
+
success = RemoveAllUserClasses(theEnv);
|
438
|
+
GCBlockEnd(theEnv,&gcb);
|
439
|
+
return success;
|
440
|
+
}
|
441
|
+
|
442
|
+
success = DeleteClassUAG(theEnv,theDefclass);
|
443
|
+
GCBlockEnd(theEnv,&gcb);
|
444
|
+
return success;
|
445
|
+
#endif
|
446
|
+
}
|
447
|
+
|
448
|
+
|
449
|
+
#if DEBUGGING_FUNCTIONS
|
450
|
+
|
451
|
+
/*********************************************************
|
452
|
+
NAME : PPDefclassCommand
|
453
|
+
DESCRIPTION : Displays the pretty print form of
|
454
|
+
a class to stdout.
|
455
|
+
INPUTS : None
|
456
|
+
RETURNS : Nothing useful
|
457
|
+
SIDE EFFECTS : None
|
458
|
+
NOTES : Syntax : (ppdefclass <class-name>)
|
459
|
+
*********************************************************/
|
460
|
+
void PPDefclassCommand(
|
461
|
+
Environment *theEnv,
|
462
|
+
UDFContext *context,
|
463
|
+
UDFValue *returnValue)
|
464
|
+
{
|
465
|
+
PPConstructCommand(context,"ppdefclass",DefclassData(theEnv)->DefclassConstruct,returnValue);
|
466
|
+
}
|
467
|
+
|
468
|
+
/***************************************************
|
469
|
+
NAME : ListDefclassesCommand
|
470
|
+
DESCRIPTION : Displays all defclass names
|
471
|
+
INPUTS : None
|
472
|
+
RETURNS : Nothing useful
|
473
|
+
SIDE EFFECTS : Defclass names printed
|
474
|
+
NOTES : H/L Interface
|
475
|
+
***************************************************/
|
476
|
+
void ListDefclassesCommand(
|
477
|
+
Environment *theEnv,
|
478
|
+
UDFContext *context,
|
479
|
+
UDFValue *returnValue)
|
480
|
+
{
|
481
|
+
ListConstructCommand(context,DefclassData(theEnv)->DefclassConstruct);
|
482
|
+
}
|
483
|
+
|
484
|
+
/***************************************************
|
485
|
+
NAME : ListDefclasses
|
486
|
+
DESCRIPTION : Displays all defclass names
|
487
|
+
INPUTS : 1) The logical name of the output
|
488
|
+
2) The module
|
489
|
+
RETURNS : Nothing useful
|
490
|
+
SIDE EFFECTS : Defclass names printed
|
491
|
+
NOTES : C Interface
|
492
|
+
***************************************************/
|
493
|
+
void ListDefclasses(
|
494
|
+
Environment *theEnv,
|
495
|
+
const char *logicalName,
|
496
|
+
Defmodule *theModule)
|
497
|
+
{
|
498
|
+
ListConstruct(theEnv,DefclassData(theEnv)->DefclassConstruct,logicalName,theModule);
|
499
|
+
}
|
500
|
+
|
501
|
+
/*********************************************************
|
502
|
+
NAME : DefclassGetWatchInstances
|
503
|
+
DESCRIPTION : Determines if deletions/creations of
|
504
|
+
instances of this class will generate
|
505
|
+
trace messages or not
|
506
|
+
INPUTS : A pointer to the class
|
507
|
+
RETURNS : True if a trace is active,
|
508
|
+
false otherwise
|
509
|
+
SIDE EFFECTS : None
|
510
|
+
NOTES : None
|
511
|
+
*********************************************************/
|
512
|
+
bool DefclassGetWatchInstances(
|
513
|
+
Defclass *theDefclass)
|
514
|
+
{
|
515
|
+
return theDefclass->traceInstances;
|
516
|
+
}
|
517
|
+
|
518
|
+
/*********************************************************
|
519
|
+
NAME : DefclassSetWatchInstances
|
520
|
+
DESCRIPTION : Sets the trace to ON/OFF for the
|
521
|
+
creation/deletion of instances
|
522
|
+
of the class
|
523
|
+
INPUTS : 1) true to set the trace on,
|
524
|
+
false to set it off
|
525
|
+
2) A pointer to the class
|
526
|
+
RETURNS : Nothing useful
|
527
|
+
SIDE EFFECTS : Watch flag for the class set
|
528
|
+
NOTES : None
|
529
|
+
*********************************************************/
|
530
|
+
void DefclassSetWatchInstances(
|
531
|
+
Defclass *theDefclass,
|
532
|
+
bool newState)
|
533
|
+
{
|
534
|
+
if (theDefclass->abstract)
|
535
|
+
{ return; }
|
536
|
+
|
537
|
+
theDefclass->traceInstances = newState;
|
538
|
+
}
|
539
|
+
|
540
|
+
/*********************************************************
|
541
|
+
NAME : DefclassGetWatchSlots
|
542
|
+
DESCRIPTION : Determines if changes to slots of
|
543
|
+
instances of this class will generate
|
544
|
+
trace messages or not
|
545
|
+
INPUTS : A pointer to the class
|
546
|
+
RETURNS : True if a trace is active,
|
547
|
+
false otherwise
|
548
|
+
SIDE EFFECTS : None
|
549
|
+
NOTES : None
|
550
|
+
*********************************************************/
|
551
|
+
bool DefclassGetWatchSlots(
|
552
|
+
Defclass *theDefclass)
|
553
|
+
{
|
554
|
+
return theDefclass->traceSlots;
|
555
|
+
}
|
556
|
+
|
557
|
+
/**********************************************************
|
558
|
+
NAME : SetDefclassWatchSlots
|
559
|
+
DESCRIPTION : Sets the trace to ON/OFF for the
|
560
|
+
changes to slots of instances of the class
|
561
|
+
INPUTS : 1) true to set the trace on,
|
562
|
+
false to set it off
|
563
|
+
2) A pointer to the class
|
564
|
+
RETURNS : Nothing useful
|
565
|
+
SIDE EFFECTS : Watch flag for the class set
|
566
|
+
NOTES : None
|
567
|
+
**********************************************************/
|
568
|
+
void DefclassSetWatchSlots(
|
569
|
+
Defclass *theDefclass,
|
570
|
+
bool newState)
|
571
|
+
{
|
572
|
+
theDefclass->traceSlots = newState;
|
573
|
+
}
|
574
|
+
|
575
|
+
/******************************************************************
|
576
|
+
NAME : DefclassWatchAccess
|
577
|
+
DESCRIPTION : Parses a list of class names passed by
|
578
|
+
AddWatchItem() and sets the traces accordingly
|
579
|
+
INPUTS : 1) A code indicating which trace flag is to be set
|
580
|
+
0 - Watch instance creation/deletion
|
581
|
+
1 - Watch slot changes to instances
|
582
|
+
2) The value to which to set the trace flags
|
583
|
+
3) A list of expressions containing the names
|
584
|
+
of the classes for which to set traces
|
585
|
+
RETURNS : True if all OK, false otherwise
|
586
|
+
SIDE EFFECTS : Watch flags set in specified classes
|
587
|
+
NOTES : Accessory function for AddWatchItem()
|
588
|
+
******************************************************************/
|
589
|
+
bool DefclassWatchAccess(
|
590
|
+
Environment *theEnv,
|
591
|
+
int code,
|
592
|
+
bool newState,
|
593
|
+
Expression *argExprs)
|
594
|
+
{
|
595
|
+
if (code)
|
596
|
+
return(ConstructSetWatchAccess(theEnv,DefclassData(theEnv)->DefclassConstruct,newState,argExprs,
|
597
|
+
(ConstructGetWatchFunction *) DefclassGetWatchSlots,
|
598
|
+
(ConstructSetWatchFunction *) DefclassSetWatchSlots));
|
599
|
+
else
|
600
|
+
return(ConstructSetWatchAccess(theEnv,DefclassData(theEnv)->DefclassConstruct,newState,argExprs,
|
601
|
+
(ConstructGetWatchFunction *) DefclassGetWatchInstances,
|
602
|
+
(ConstructSetWatchFunction *) DefclassSetWatchInstances));
|
603
|
+
}
|
604
|
+
|
605
|
+
/***********************************************************************
|
606
|
+
NAME : DefclassWatchPrint
|
607
|
+
DESCRIPTION : Parses a list of class names passed by
|
608
|
+
AddWatchItem() and displays the traces accordingly
|
609
|
+
INPUTS : 1) The logical name of the output
|
610
|
+
2) A code indicating which trace flag is to be examined
|
611
|
+
0 - Watch instance creation/deletion
|
612
|
+
1 - Watch slot changes to instances
|
613
|
+
3) A list of expressions containing the names
|
614
|
+
of the classes for which to examine traces
|
615
|
+
RETURNS : True if all OK, false otherwise
|
616
|
+
SIDE EFFECTS : Watch flags displayed for specified classes
|
617
|
+
NOTES : Accessory function for AddWatchItem()
|
618
|
+
***********************************************************************/
|
619
|
+
bool DefclassWatchPrint(
|
620
|
+
Environment *theEnv,
|
621
|
+
const char *logName,
|
622
|
+
int code,
|
623
|
+
Expression *argExprs)
|
624
|
+
{
|
625
|
+
if (code)
|
626
|
+
return(ConstructPrintWatchAccess(theEnv,DefclassData(theEnv)->DefclassConstruct,logName,argExprs,
|
627
|
+
(ConstructGetWatchFunction *) DefclassGetWatchSlots,
|
628
|
+
(ConstructSetWatchFunction *) DefclassSetWatchSlots));
|
629
|
+
else
|
630
|
+
return(ConstructPrintWatchAccess(theEnv,DefclassData(theEnv)->DefclassConstruct,logName,argExprs,
|
631
|
+
(ConstructGetWatchFunction *) DefclassGetWatchInstances,
|
632
|
+
(ConstructSetWatchFunction *) DefclassSetWatchInstances));
|
633
|
+
}
|
634
|
+
|
635
|
+
#endif /* DEBUGGING_FUNCTIONS */
|
636
|
+
|
637
|
+
/*********************************************************
|
638
|
+
NAME : GetDefclassListFunction
|
639
|
+
DESCRIPTION : Groups names of all defclasses into
|
640
|
+
a multifield variable
|
641
|
+
INPUTS : A data object buffer
|
642
|
+
RETURNS : Nothing useful
|
643
|
+
SIDE EFFECTS : Multifield set to list of classes
|
644
|
+
NOTES : None
|
645
|
+
*********************************************************/
|
646
|
+
void GetDefclassListFunction(
|
647
|
+
Environment *theEnv,
|
648
|
+
UDFContext *context,
|
649
|
+
UDFValue *returnValue)
|
650
|
+
{
|
651
|
+
GetConstructListFunction(context,returnValue,DefclassData(theEnv)->DefclassConstruct);
|
652
|
+
}
|
653
|
+
|
654
|
+
/***************************************************************
|
655
|
+
NAME : GetDefclassList
|
656
|
+
DESCRIPTION : Groups all defclass names into
|
657
|
+
a multifield list
|
658
|
+
INPUTS : 1) A data object buffer to hold
|
659
|
+
the multifield result
|
660
|
+
2) The module from which to obtain defclasses
|
661
|
+
RETURNS : Nothing useful
|
662
|
+
SIDE EFFECTS : Multifield allocated and filled
|
663
|
+
NOTES : External C access
|
664
|
+
***************************************************************/
|
665
|
+
void GetDefclassList(
|
666
|
+
Environment *theEnv,
|
667
|
+
CLIPSValue *returnValue,
|
668
|
+
Defmodule *theModule)
|
669
|
+
{
|
670
|
+
UDFValue result;
|
671
|
+
|
672
|
+
GetConstructList(theEnv,&result,DefclassData(theEnv)->DefclassConstruct,theModule);
|
673
|
+
NormalizeMultifield(theEnv,&result);
|
674
|
+
returnValue->value = result.value;
|
675
|
+
}
|
676
|
+
|
677
|
+
/*****************************************************
|
678
|
+
NAME : HasSuperclass
|
679
|
+
DESCRIPTION : Determines if class-2 is a superclass
|
680
|
+
of class-1
|
681
|
+
INPUTS : 1) Class-1
|
682
|
+
2) Class-2
|
683
|
+
RETURNS : True if class-2 is a superclass of
|
684
|
+
class-1, false otherwise
|
685
|
+
SIDE EFFECTS : None
|
686
|
+
NOTES : None
|
687
|
+
*****************************************************/
|
688
|
+
bool HasSuperclass(
|
689
|
+
Defclass *c1,
|
690
|
+
Defclass *c2)
|
691
|
+
{
|
692
|
+
unsigned long i;
|
693
|
+
|
694
|
+
for (i = 1 ; i < c1->allSuperclasses.classCount ; i++)
|
695
|
+
if (c1->allSuperclasses.classArray[i] == c2)
|
696
|
+
return true;
|
697
|
+
return false;
|
698
|
+
}
|
699
|
+
|
700
|
+
/********************************************************************
|
701
|
+
NAME : CheckClassAndSlot
|
702
|
+
DESCRIPTION : Checks class and slot argument for various functions
|
703
|
+
INPUTS : 1) Name of the calling function
|
704
|
+
2) Buffer for class address
|
705
|
+
RETURNS : Slot symbol, NULL on errors
|
706
|
+
SIDE EFFECTS : None
|
707
|
+
NOTES : None
|
708
|
+
********************************************************************/
|
709
|
+
CLIPSLexeme *CheckClassAndSlot(
|
710
|
+
UDFContext *context,
|
711
|
+
const char *func,
|
712
|
+
Defclass **cls)
|
713
|
+
{
|
714
|
+
UDFValue theArg;
|
715
|
+
Environment *theEnv = context->environment;
|
716
|
+
|
717
|
+
if (! UDFFirstArgument(context,SYMBOL_BIT,&theArg))
|
718
|
+
return NULL;
|
719
|
+
|
720
|
+
*cls = LookupDefclassByMdlOrScope(theEnv,theArg.lexemeValue->contents);
|
721
|
+
if (*cls == NULL)
|
722
|
+
{
|
723
|
+
ClassExistError(theEnv,func,theArg.lexemeValue->contents);
|
724
|
+
return NULL;
|
725
|
+
}
|
726
|
+
|
727
|
+
if (! UDFNextArgument(context,SYMBOL_BIT,&theArg))
|
728
|
+
return NULL;
|
729
|
+
|
730
|
+
return theArg.lexemeValue;
|
731
|
+
}
|
732
|
+
|
733
|
+
#if (! BLOAD_ONLY) && (! RUN_TIME)
|
734
|
+
|
735
|
+
/***************************************************
|
736
|
+
NAME : SaveDefclasses
|
737
|
+
DESCRIPTION : Prints pretty print form of
|
738
|
+
defclasses to specified output
|
739
|
+
INPUTS : The logical name of the output
|
740
|
+
RETURNS : Nothing useful
|
741
|
+
SIDE EFFECTS : None
|
742
|
+
NOTES : None
|
743
|
+
***************************************************/
|
744
|
+
void SaveDefclasses(
|
745
|
+
Environment *theEnv,
|
746
|
+
Defmodule *theModule,
|
747
|
+
const char *logName,
|
748
|
+
void *context)
|
749
|
+
{
|
750
|
+
#if DEBUGGING_FUNCTIONS
|
751
|
+
DoForAllConstructsInModule(theEnv,theModule,SaveDefclass,
|
752
|
+
DefclassData(theEnv)->DefclassModuleIndex,
|
753
|
+
false,(void *) logName);
|
754
|
+
#else
|
755
|
+
#if MAC_XCD
|
756
|
+
#pragma unused(theEnv,theModule,logName)
|
757
|
+
#endif
|
758
|
+
#endif
|
759
|
+
}
|
760
|
+
|
761
|
+
#endif
|
762
|
+
|
763
|
+
/* =========================================
|
764
|
+
*****************************************
|
765
|
+
INTERNALLY VISIBLE FUNCTIONS
|
766
|
+
=========================================
|
767
|
+
***************************************** */
|
768
|
+
|
769
|
+
#if (! BLOAD_ONLY) && (! RUN_TIME) && DEBUGGING_FUNCTIONS
|
770
|
+
|
771
|
+
/***************************************************
|
772
|
+
NAME : SaveDefclass
|
773
|
+
DESCRIPTION : Writes out the pretty-print forms
|
774
|
+
of a class and all its handlers
|
775
|
+
INPUTS : 1) The class
|
776
|
+
2) The logical name of the output
|
777
|
+
RETURNS : Nothing useful
|
778
|
+
SIDE EFFECTS : Class and handlers written
|
779
|
+
NOTES : None
|
780
|
+
***************************************************/
|
781
|
+
static void SaveDefclass(
|
782
|
+
Environment *theEnv,
|
783
|
+
ConstructHeader *theConstruct,
|
784
|
+
void *userBuffer)
|
785
|
+
{
|
786
|
+
const char *logName = (const char *) userBuffer;
|
787
|
+
Defclass *theDefclass = (Defclass *) theConstruct;
|
788
|
+
unsigned hnd;
|
789
|
+
const char *ppForm;
|
790
|
+
|
791
|
+
ppForm = DefclassPPForm(theDefclass);
|
792
|
+
if (ppForm != NULL)
|
793
|
+
{
|
794
|
+
WriteString(theEnv,logName,ppForm);
|
795
|
+
WriteString(theEnv,logName,"\n");
|
796
|
+
hnd = GetNextDefmessageHandler(theDefclass,0);
|
797
|
+
while (hnd != 0)
|
798
|
+
{
|
799
|
+
ppForm = DefmessageHandlerPPForm(theDefclass,hnd);
|
800
|
+
if (ppForm != NULL)
|
801
|
+
{
|
802
|
+
WriteString(theEnv,logName,ppForm);
|
803
|
+
WriteString(theEnv,logName,"\n");
|
804
|
+
}
|
805
|
+
hnd = GetNextDefmessageHandler(theDefclass,hnd);
|
806
|
+
}
|
807
|
+
}
|
808
|
+
}
|
809
|
+
|
810
|
+
#endif
|
811
|
+
|
812
|
+
/********************************************/
|
813
|
+
/* SetClassDefaultsMode: Allows the setting */
|
814
|
+
/* of the class defaults mode. */
|
815
|
+
/********************************************/
|
816
|
+
ClassDefaultsMode SetClassDefaultsMode(
|
817
|
+
Environment *theEnv,
|
818
|
+
ClassDefaultsMode value)
|
819
|
+
{
|
820
|
+
ClassDefaultsMode ov;
|
821
|
+
|
822
|
+
ov = DefclassData(theEnv)->ClassDefaultsModeValue;
|
823
|
+
DefclassData(theEnv)->ClassDefaultsModeValue = value;
|
824
|
+
return ov;
|
825
|
+
}
|
826
|
+
|
827
|
+
/****************************************/
|
828
|
+
/* GetClassDefaultsMode: Returns the */
|
829
|
+
/* value of the class defaults mode. */
|
830
|
+
/****************************************/
|
831
|
+
ClassDefaultsMode GetClassDefaultsMode(
|
832
|
+
Environment *theEnv)
|
833
|
+
{
|
834
|
+
return DefclassData(theEnv)->ClassDefaultsModeValue;
|
835
|
+
}
|
836
|
+
|
837
|
+
/***************************************************/
|
838
|
+
/* GetClassDefaultsModeCommand: H/L access routine */
|
839
|
+
/* for the get-class-defaults-mode command. */
|
840
|
+
/***************************************************/
|
841
|
+
void GetClassDefaultsModeCommand(
|
842
|
+
Environment *theEnv,
|
843
|
+
UDFContext *context,
|
844
|
+
UDFValue *returnValue)
|
845
|
+
{
|
846
|
+
returnValue->lexemeValue = CreateSymbol(theEnv,GetClassDefaultsModeName(GetClassDefaultsMode(theEnv)));
|
847
|
+
}
|
848
|
+
|
849
|
+
/***************************************************/
|
850
|
+
/* SetClassDefaultsModeCommand: H/L access routine */
|
851
|
+
/* for the set-class-defaults-mode command. */
|
852
|
+
/***************************************************/
|
853
|
+
void SetClassDefaultsModeCommand(
|
854
|
+
Environment *theEnv,
|
855
|
+
UDFContext *context,
|
856
|
+
UDFValue *returnValue)
|
857
|
+
{
|
858
|
+
UDFValue theArg;
|
859
|
+
const char *argument;
|
860
|
+
ClassDefaultsMode oldMode;
|
861
|
+
|
862
|
+
oldMode = DefclassData(theEnv)->ClassDefaultsModeValue;
|
863
|
+
|
864
|
+
/*=====================================================*/
|
865
|
+
/* Check for the correct number and type of arguments. */
|
866
|
+
/*=====================================================*/
|
867
|
+
|
868
|
+
if (! UDFFirstArgument(context,SYMBOL_BIT,&theArg))
|
869
|
+
{ return; }
|
870
|
+
|
871
|
+
argument = theArg.lexemeValue->contents;
|
872
|
+
|
873
|
+
/*=============================================*/
|
874
|
+
/* Set the strategy to the specified strategy. */
|
875
|
+
/*=============================================*/
|
876
|
+
|
877
|
+
if (strcmp(argument,"conservation") == 0)
|
878
|
+
{ SetClassDefaultsMode(theEnv,CONSERVATION_MODE); }
|
879
|
+
else if (strcmp(argument,"convenience") == 0)
|
880
|
+
{ SetClassDefaultsMode(theEnv,CONVENIENCE_MODE); }
|
881
|
+
else
|
882
|
+
{
|
883
|
+
UDFInvalidArgumentMessage(context,"symbol with value conservation or convenience");
|
884
|
+
returnValue->lexemeValue = CreateSymbol(theEnv,GetClassDefaultsModeName(GetClassDefaultsMode(theEnv)));
|
885
|
+
return;
|
886
|
+
}
|
887
|
+
|
888
|
+
/*===================================*/
|
889
|
+
/* Return the old value of the mode. */
|
890
|
+
/*===================================*/
|
891
|
+
|
892
|
+
returnValue->lexemeValue = CreateSymbol(theEnv,GetClassDefaultsModeName(oldMode));
|
893
|
+
}
|
894
|
+
|
895
|
+
/*******************************************************************/
|
896
|
+
/* GetClassDefaultsModeName: Given the integer value corresponding */
|
897
|
+
/* to a specified class defaults mode, return a character string */
|
898
|
+
/* of the class defaults mode's name. */
|
899
|
+
/*******************************************************************/
|
900
|
+
static const char *GetClassDefaultsModeName(
|
901
|
+
ClassDefaultsMode mode)
|
902
|
+
{
|
903
|
+
const char *sname;
|
904
|
+
|
905
|
+
switch (mode)
|
906
|
+
{
|
907
|
+
case CONSERVATION_MODE:
|
908
|
+
sname = "conservation";
|
909
|
+
break;
|
910
|
+
case CONVENIENCE_MODE:
|
911
|
+
sname = "convenience";
|
912
|
+
break;
|
913
|
+
default:
|
914
|
+
sname = "unknown";
|
915
|
+
break;
|
916
|
+
}
|
917
|
+
|
918
|
+
return(sname);
|
919
|
+
}
|
920
|
+
|
921
|
+
/*#############################*/
|
922
|
+
/* Additional Access Functions */
|
923
|
+
/*#############################*/
|
924
|
+
|
925
|
+
CLIPSLexeme *GetDefclassNamePointer(
|
926
|
+
Defclass *theClass)
|
927
|
+
{
|
928
|
+
return GetConstructNamePointer(&theClass->header);
|
929
|
+
}
|
930
|
+
|
931
|
+
void SetNextDefclass(
|
932
|
+
Defclass *theClass,
|
933
|
+
Defclass *targetClass)
|
934
|
+
{
|
935
|
+
SetNextConstruct(&theClass->header,
|
936
|
+
&targetClass->header);
|
937
|
+
}
|
938
|
+
|
939
|
+
/*##################################*/
|
940
|
+
/* Additional Environment Functions */
|
941
|
+
/*##################################*/
|
942
|
+
|
943
|
+
const char *DefclassName(
|
944
|
+
Defclass *theClass)
|
945
|
+
{
|
946
|
+
return GetConstructNameString(&theClass->header);
|
947
|
+
}
|
948
|
+
|
949
|
+
const char *DefclassPPForm(
|
950
|
+
Defclass *theClass)
|
951
|
+
{
|
952
|
+
return GetConstructPPForm(&theClass->header);
|
953
|
+
}
|
954
|
+
|
955
|
+
struct defmoduleItemHeader *GetDefclassModule(
|
956
|
+
Environment *theEnv,
|
957
|
+
Defclass *theClass)
|
958
|
+
{
|
959
|
+
return GetConstructModuleItem(&theClass->header);
|
960
|
+
}
|
961
|
+
|
962
|
+
const char *DefclassModule(
|
963
|
+
Defclass *theClass)
|
964
|
+
{
|
965
|
+
return GetConstructModuleName(&theClass->header);
|
966
|
+
}
|
967
|
+
|
968
|
+
void SetDefclassPPForm(
|
969
|
+
Environment *theEnv,
|
970
|
+
Defclass *theClass,
|
971
|
+
char *thePPForm)
|
972
|
+
{
|
973
|
+
SetConstructPPForm(theEnv,&theClass->header,thePPForm);
|
974
|
+
}
|
975
|
+
|
976
|
+
#endif /* OBJECT_SYSTEM */
|