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,902 @@
|
|
1
|
+
/*******************************************************/
|
2
|
+
/* "C" Language Integrated Production System */
|
3
|
+
/* */
|
4
|
+
/* CLIPS Version 6.40 02/20/20 */
|
5
|
+
/* */
|
6
|
+
/* */
|
7
|
+
/*******************************************************/
|
8
|
+
|
9
|
+
/*************************************************************/
|
10
|
+
/* Purpose: Binary Load/Save Functions for Generic Functions */
|
11
|
+
/* */
|
12
|
+
/* Principal Programmer(s): */
|
13
|
+
/* Brian L. Dantes */
|
14
|
+
/* */
|
15
|
+
/* Contributing Programmer(s): */
|
16
|
+
/* */
|
17
|
+
/* Revision History: */
|
18
|
+
/* */
|
19
|
+
/* 6.30: Removed conditional code for unsupported */
|
20
|
+
/* compilers/operating systems (IBM_MCW, */
|
21
|
+
/* MAC_MCW, and IBM_TBC). */
|
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
|
+
/* =========================================
|
35
|
+
*****************************************
|
36
|
+
EXTERNAL DEFINITIONS
|
37
|
+
=========================================
|
38
|
+
***************************************** */
|
39
|
+
|
40
|
+
#include "setup.h"
|
41
|
+
|
42
|
+
#if DEFGENERIC_CONSTRUCT && (BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE)
|
43
|
+
|
44
|
+
#include "bload.h"
|
45
|
+
#include "bsave.h"
|
46
|
+
#include "constant.h"
|
47
|
+
#include "cstrcbin.h"
|
48
|
+
#include "cstrccom.h"
|
49
|
+
#include "envrnmnt.h"
|
50
|
+
#include "genrccom.h"
|
51
|
+
#include "memalloc.h"
|
52
|
+
#include "modulbin.h"
|
53
|
+
#if OBJECT_SYSTEM
|
54
|
+
#include "objbin.h"
|
55
|
+
#else
|
56
|
+
#include "prntutil.h"
|
57
|
+
#endif
|
58
|
+
#include "router.h"
|
59
|
+
|
60
|
+
#include "genrcbin.h"
|
61
|
+
|
62
|
+
/* =========================================
|
63
|
+
*****************************************
|
64
|
+
MACROS AND TYPES
|
65
|
+
=========================================
|
66
|
+
***************************************** */
|
67
|
+
|
68
|
+
#define MethodPointer(i) (((i) == ULONG_MAX) ? NULL : (&DefgenericBinaryData(theEnv)->MethodArray[i]))
|
69
|
+
#define RestrictionPointer(i) (((i) == ULONG_MAX) ? NULL : (RESTRICTION *) &DefgenericBinaryData(theEnv)->RestrictionArray[i])
|
70
|
+
#define TypePointer(i) (((i) == ULONG_MAX) ? NULL : (void **) &DefgenericBinaryData(theEnv)->TypeArray[i])
|
71
|
+
|
72
|
+
typedef struct bsaveRestriction
|
73
|
+
{
|
74
|
+
unsigned long types;
|
75
|
+
unsigned long query;
|
76
|
+
unsigned short tcnt;
|
77
|
+
} BSAVE_RESTRICTION;
|
78
|
+
|
79
|
+
typedef struct bsaveMethod
|
80
|
+
{
|
81
|
+
struct bsaveConstructHeader header;
|
82
|
+
unsigned short index;
|
83
|
+
unsigned short restrictionCount;
|
84
|
+
unsigned short minRestrictions, maxRestrictions;
|
85
|
+
unsigned short localVarCount;
|
86
|
+
unsigned system;
|
87
|
+
unsigned long restrictions;
|
88
|
+
unsigned long actions;
|
89
|
+
} BSAVE_METHOD;
|
90
|
+
|
91
|
+
typedef struct bsaveGenericFunc
|
92
|
+
{
|
93
|
+
struct bsaveConstructHeader header;
|
94
|
+
unsigned long methods;
|
95
|
+
unsigned short mcnt;
|
96
|
+
} BSAVE_GENERIC;
|
97
|
+
|
98
|
+
typedef struct bsaveGenericModule
|
99
|
+
{
|
100
|
+
struct bsaveDefmoduleItemHeader header;
|
101
|
+
} BSAVE_DEFGENERIC_MODULE;
|
102
|
+
|
103
|
+
/***************************************/
|
104
|
+
/* LOCAL INTERNAL FUNCTION DEFINITIONS */
|
105
|
+
/***************************************/
|
106
|
+
|
107
|
+
#if BLOAD_AND_BSAVE
|
108
|
+
|
109
|
+
static void BsaveGenericsFind(Environment *);
|
110
|
+
static void MarkDefgenericItems(Environment *,ConstructHeader *,void *);
|
111
|
+
static void BsaveGenericsExpressions(Environment *,FILE *);
|
112
|
+
static void BsaveMethodExpressions(Environment *,ConstructHeader *,void *);
|
113
|
+
static void BsaveRestrictionExpressions(Environment *,ConstructHeader *,void *);
|
114
|
+
static void BsaveGenerics(Environment *,FILE *);
|
115
|
+
static void BsaveDefgenericHeader(Environment *,ConstructHeader *,void *);
|
116
|
+
static void BsaveMethods(Environment *,ConstructHeader *,void *);
|
117
|
+
static void BsaveMethodRestrictions(Environment *,ConstructHeader *,void *);
|
118
|
+
static void BsaveRestrictionTypes(Environment *,ConstructHeader *,void *);
|
119
|
+
static void BsaveStorageGenerics(Environment *,FILE *);
|
120
|
+
|
121
|
+
#endif
|
122
|
+
|
123
|
+
static void BloadStorageGenerics(Environment *);
|
124
|
+
static void BloadGenerics(Environment *);
|
125
|
+
static void UpdateGenericModule(Environment *,void *,unsigned long);
|
126
|
+
static void UpdateGeneric(Environment *,void *,unsigned long);
|
127
|
+
static void UpdateMethod(Environment *,void *,unsigned long);
|
128
|
+
static void UpdateRestriction(Environment *,void *,unsigned long);
|
129
|
+
static void UpdateType(Environment *,void *,unsigned long);
|
130
|
+
static void ClearBloadGenerics(Environment *);
|
131
|
+
static void DeallocateDefgenericBinaryData(Environment *);
|
132
|
+
|
133
|
+
/* =========================================
|
134
|
+
*****************************************
|
135
|
+
EXTERNALLY VISIBLE FUNCTIONS
|
136
|
+
=========================================
|
137
|
+
***************************************** */
|
138
|
+
|
139
|
+
/***********************************************************
|
140
|
+
NAME : SetupGenericsBload
|
141
|
+
DESCRIPTION : Initializes data structures and
|
142
|
+
routines for binary loads of
|
143
|
+
generic function constructs
|
144
|
+
INPUTS : None
|
145
|
+
RETURNS : Nothing useful
|
146
|
+
SIDE EFFECTS : Routines defined and structures initialized
|
147
|
+
NOTES : None
|
148
|
+
***********************************************************/
|
149
|
+
void SetupGenericsBload(
|
150
|
+
Environment *theEnv)
|
151
|
+
{
|
152
|
+
AllocateEnvironmentData(theEnv,GENRCBIN_DATA,sizeof(struct defgenericBinaryData),DeallocateDefgenericBinaryData);
|
153
|
+
#if BLOAD_AND_BSAVE
|
154
|
+
AddBinaryItem(theEnv,"generic functions",0,BsaveGenericsFind,BsaveGenericsExpressions,
|
155
|
+
BsaveStorageGenerics,BsaveGenerics,
|
156
|
+
BloadStorageGenerics,BloadGenerics,
|
157
|
+
ClearBloadGenerics);
|
158
|
+
#endif
|
159
|
+
#if BLOAD || BLOAD_ONLY
|
160
|
+
AddBinaryItem(theEnv,"generic functions",0,NULL,NULL,NULL,NULL,
|
161
|
+
BloadStorageGenerics,BloadGenerics,
|
162
|
+
ClearBloadGenerics);
|
163
|
+
#endif
|
164
|
+
}
|
165
|
+
|
166
|
+
/***********************************************************/
|
167
|
+
/* DeallocateDefgenericBinaryData: Deallocates environment */
|
168
|
+
/* data for the defgeneric binary functionality. */
|
169
|
+
/***********************************************************/
|
170
|
+
static void DeallocateDefgenericBinaryData(
|
171
|
+
Environment *theEnv)
|
172
|
+
{
|
173
|
+
#if (BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE) && (! RUN_TIME)
|
174
|
+
size_t space;
|
175
|
+
|
176
|
+
space = DefgenericBinaryData(theEnv)->GenericCount * sizeof(Defgeneric);
|
177
|
+
if (space != 0) genfree(theEnv,DefgenericBinaryData(theEnv)->DefgenericArray,space);
|
178
|
+
|
179
|
+
space = DefgenericBinaryData(theEnv)->MethodCount * sizeof(Defmethod);
|
180
|
+
if (space != 0) genfree(theEnv,DefgenericBinaryData(theEnv)->MethodArray,space);
|
181
|
+
|
182
|
+
space = DefgenericBinaryData(theEnv)->RestrictionCount * sizeof(struct restriction);
|
183
|
+
if (space != 0) genfree(theEnv,DefgenericBinaryData(theEnv)->RestrictionArray,space);
|
184
|
+
|
185
|
+
space = DefgenericBinaryData(theEnv)->TypeCount * sizeof(void *);
|
186
|
+
if (space != 0) genfree(theEnv,DefgenericBinaryData(theEnv)->TypeArray,space);
|
187
|
+
|
188
|
+
space = DefgenericBinaryData(theEnv)->ModuleCount * sizeof(struct defgenericModule);
|
189
|
+
if (space != 0) genfree(theEnv,DefgenericBinaryData(theEnv)->ModuleArray,space);
|
190
|
+
#endif
|
191
|
+
}
|
192
|
+
|
193
|
+
/***************************************************
|
194
|
+
NAME : BloadDefgenericModuleReference
|
195
|
+
DESCRIPTION : Returns a pointer to the
|
196
|
+
appropriate defgeneric module
|
197
|
+
INPUTS : The index of the module
|
198
|
+
RETURNS : A pointer to the module
|
199
|
+
SIDE EFFECTS : None
|
200
|
+
NOTES : None
|
201
|
+
***************************************************/
|
202
|
+
void *BloadDefgenericModuleReference(
|
203
|
+
Environment *theEnv,
|
204
|
+
unsigned long theIndex)
|
205
|
+
{
|
206
|
+
return ((void *) &DefgenericBinaryData(theEnv)->ModuleArray[theIndex]);
|
207
|
+
}
|
208
|
+
|
209
|
+
/* =========================================
|
210
|
+
*****************************************
|
211
|
+
INTERNALLY VISIBLE FUNCTIONS
|
212
|
+
=========================================
|
213
|
+
***************************************** */
|
214
|
+
|
215
|
+
#if BLOAD_AND_BSAVE
|
216
|
+
|
217
|
+
/***************************************************************************
|
218
|
+
NAME : BsaveGenericsFind
|
219
|
+
DESCRIPTION : For all generic functions and their
|
220
|
+
methods, this routine marks all
|
221
|
+
the needed symbols and system functions.
|
222
|
+
Also, it also counts the number of
|
223
|
+
expression structures needed.
|
224
|
+
Also, counts total number of generics, methods,
|
225
|
+
restrictions and types.
|
226
|
+
INPUTS : None
|
227
|
+
RETURNS : Nothing useful
|
228
|
+
SIDE EFFECTS : ExpressionCount (a global from BSAVE.C) is incremented
|
229
|
+
for every expression needed
|
230
|
+
Symbols and system function are marked in their structures
|
231
|
+
NOTES : Also sets bsaveIndex for each generic function (assumes
|
232
|
+
generic functions will be bsaved in order of binary list)
|
233
|
+
***************************************************************************/
|
234
|
+
static void BsaveGenericsFind(
|
235
|
+
Environment *theEnv)
|
236
|
+
{
|
237
|
+
SaveBloadCount(theEnv,DefgenericBinaryData(theEnv)->ModuleCount);
|
238
|
+
SaveBloadCount(theEnv,DefgenericBinaryData(theEnv)->GenericCount);
|
239
|
+
SaveBloadCount(theEnv,DefgenericBinaryData(theEnv)->MethodCount);
|
240
|
+
SaveBloadCount(theEnv,DefgenericBinaryData(theEnv)->RestrictionCount);
|
241
|
+
SaveBloadCount(theEnv,DefgenericBinaryData(theEnv)->TypeCount);
|
242
|
+
|
243
|
+
DefgenericBinaryData(theEnv)->GenericCount = 0L;
|
244
|
+
DefgenericBinaryData(theEnv)->MethodCount = 0L;
|
245
|
+
DefgenericBinaryData(theEnv)->RestrictionCount = 0L;
|
246
|
+
DefgenericBinaryData(theEnv)->TypeCount = 0L;
|
247
|
+
|
248
|
+
DefgenericBinaryData(theEnv)->ModuleCount = GetNumberOfDefmodules(theEnv);
|
249
|
+
|
250
|
+
DoForAllConstructs(theEnv,MarkDefgenericItems,
|
251
|
+
DefgenericData(theEnv)->DefgenericModuleIndex,
|
252
|
+
false,NULL);
|
253
|
+
}
|
254
|
+
|
255
|
+
/***************************************************
|
256
|
+
NAME : MarkDefgenericItems
|
257
|
+
DESCRIPTION : Marks the needed items for
|
258
|
+
a defgeneric (and methods) bsave
|
259
|
+
INPUTS : 1) The defgeneric
|
260
|
+
2) User data buffer (ignored)
|
261
|
+
RETURNS : Nothing useful
|
262
|
+
SIDE EFFECTS : Needed items marked
|
263
|
+
NOTES : None
|
264
|
+
***************************************************/
|
265
|
+
static void MarkDefgenericItems(
|
266
|
+
Environment *theEnv,
|
267
|
+
ConstructHeader *theDefgeneric,
|
268
|
+
void *userBuffer)
|
269
|
+
{
|
270
|
+
#if MAC_XCD
|
271
|
+
#pragma unused(userBuffer)
|
272
|
+
#endif
|
273
|
+
Defgeneric *gfunc = (Defgeneric *) theDefgeneric;
|
274
|
+
long i,j;
|
275
|
+
Defmethod *meth;
|
276
|
+
RESTRICTION *rptr;
|
277
|
+
|
278
|
+
MarkConstructHeaderNeededItems(&gfunc->header,DefgenericBinaryData(theEnv)->GenericCount++);
|
279
|
+
DefgenericBinaryData(theEnv)->MethodCount += gfunc->mcnt;
|
280
|
+
for (i = 0 ; i < gfunc->mcnt ; i++)
|
281
|
+
{
|
282
|
+
meth = &gfunc->methods[i];
|
283
|
+
ExpressionData(theEnv)->ExpressionCount += ExpressionSize(meth->actions);
|
284
|
+
MarkNeededItems(theEnv,meth->actions);
|
285
|
+
DefgenericBinaryData(theEnv)->RestrictionCount += meth->restrictionCount;
|
286
|
+
for (j = 0 ; j < meth->restrictionCount ; j++)
|
287
|
+
{
|
288
|
+
rptr = &meth->restrictions[j];
|
289
|
+
ExpressionData(theEnv)->ExpressionCount += ExpressionSize(rptr->query);
|
290
|
+
MarkNeededItems(theEnv,rptr->query);
|
291
|
+
DefgenericBinaryData(theEnv)->TypeCount += rptr->tcnt;
|
292
|
+
}
|
293
|
+
}
|
294
|
+
}
|
295
|
+
|
296
|
+
/***************************************************
|
297
|
+
NAME : BsaveGenericsExpressions
|
298
|
+
DESCRIPTION : Writes out all expressions needed
|
299
|
+
by generic functions
|
300
|
+
INPUTS : The file pointer of the binary file
|
301
|
+
RETURNS : Nothing useful
|
302
|
+
SIDE EFFECTS : File updated
|
303
|
+
NOTES : None
|
304
|
+
***************************************************/
|
305
|
+
static void BsaveGenericsExpressions(
|
306
|
+
Environment *theEnv,
|
307
|
+
FILE *fp)
|
308
|
+
{
|
309
|
+
/*===================================================================*/
|
310
|
+
/* Important to save all expressions for methods before any */
|
311
|
+
/* expressions for restrictions, since methods will be stored first. */
|
312
|
+
/*===================================================================*/
|
313
|
+
|
314
|
+
DoForAllConstructs(theEnv,BsaveMethodExpressions,DefgenericData(theEnv)->DefgenericModuleIndex,
|
315
|
+
false,fp);
|
316
|
+
|
317
|
+
DoForAllConstructs(theEnv,BsaveRestrictionExpressions,DefgenericData(theEnv)->DefgenericModuleIndex,
|
318
|
+
false,fp);
|
319
|
+
}
|
320
|
+
|
321
|
+
/***************************************************
|
322
|
+
NAME : BsaveMethodExpressions
|
323
|
+
DESCRIPTION : Saves the needed expressions for
|
324
|
+
a defgeneric methods bsave
|
325
|
+
INPUTS : 1) The defgeneric
|
326
|
+
2) Output data file pointer
|
327
|
+
RETURNS : Nothing useful
|
328
|
+
SIDE EFFECTS : Method action expressions saved
|
329
|
+
NOTES : None
|
330
|
+
***************************************************/
|
331
|
+
static void BsaveMethodExpressions(
|
332
|
+
Environment *theEnv,
|
333
|
+
ConstructHeader *theDefgeneric,
|
334
|
+
void *userBuffer)
|
335
|
+
{
|
336
|
+
Defgeneric *gfunc = (Defgeneric *) theDefgeneric;
|
337
|
+
long i;
|
338
|
+
|
339
|
+
for (i = 0 ; i < gfunc->mcnt ; i++)
|
340
|
+
BsaveExpression(theEnv,gfunc->methods[i].actions,(FILE *) userBuffer);
|
341
|
+
}
|
342
|
+
|
343
|
+
/***************************************************
|
344
|
+
NAME : BsaveRestrictionExpressions
|
345
|
+
DESCRIPTION : Saves the needed expressions for
|
346
|
+
a defgeneric method restriction
|
347
|
+
queries bsave
|
348
|
+
INPUTS : 1) The defgeneric
|
349
|
+
2) Output data file pointer
|
350
|
+
RETURNS : Nothing useful
|
351
|
+
SIDE EFFECTS : Method restriction query
|
352
|
+
expressions saved
|
353
|
+
NOTES : None
|
354
|
+
***************************************************/
|
355
|
+
static void BsaveRestrictionExpressions(
|
356
|
+
Environment *theEnv,
|
357
|
+
ConstructHeader *theDefgeneric,
|
358
|
+
void *userBuffer)
|
359
|
+
{
|
360
|
+
Defgeneric *gfunc = (Defgeneric *) theDefgeneric;
|
361
|
+
long i,j;
|
362
|
+
Defmethod *meth;
|
363
|
+
|
364
|
+
for (i = 0 ; i < gfunc->mcnt ; i++)
|
365
|
+
{
|
366
|
+
meth = &gfunc->methods[i];
|
367
|
+
for (j = 0 ; j < meth->restrictionCount ; j++)
|
368
|
+
BsaveExpression(theEnv,meth->restrictions[j].query,(FILE *) userBuffer);
|
369
|
+
}
|
370
|
+
}
|
371
|
+
|
372
|
+
/***********************************************************
|
373
|
+
NAME : BsaveStorageGenerics
|
374
|
+
DESCRIPTION : Writes out number of each type of structure
|
375
|
+
required for generics
|
376
|
+
Space required for counts (unsigned long)
|
377
|
+
INPUTS : File pointer of binary file
|
378
|
+
RETURNS : Nothing useful
|
379
|
+
SIDE EFFECTS : Binary file adjusted
|
380
|
+
NOTES : None
|
381
|
+
***********************************************************/
|
382
|
+
static void BsaveStorageGenerics(
|
383
|
+
Environment *theEnv,
|
384
|
+
FILE *fp)
|
385
|
+
{
|
386
|
+
size_t space;
|
387
|
+
|
388
|
+
space = sizeof(long) * 5;
|
389
|
+
GenWrite(&space,sizeof(size_t),fp);
|
390
|
+
GenWrite(&DefgenericBinaryData(theEnv)->ModuleCount,sizeof(long),fp);
|
391
|
+
GenWrite(&DefgenericBinaryData(theEnv)->GenericCount,sizeof(long),fp);
|
392
|
+
GenWrite(&DefgenericBinaryData(theEnv)->MethodCount,sizeof(long),fp);
|
393
|
+
GenWrite(&DefgenericBinaryData(theEnv)->RestrictionCount,sizeof(long),fp);
|
394
|
+
GenWrite(&DefgenericBinaryData(theEnv)->TypeCount,sizeof(long),fp);
|
395
|
+
}
|
396
|
+
|
397
|
+
/****************************************************************************************
|
398
|
+
NAME : BsaveGenerics
|
399
|
+
DESCRIPTION : Writes out generic function in binary format
|
400
|
+
Space required (unsigned long)
|
401
|
+
All generic modules (sizeof(DEFGENERIC_MODULE) * Number of generic modules)
|
402
|
+
All generic headers (sizeof(Defgeneric) * Number of generics)
|
403
|
+
All methods (sizeof(Defmethod) * Number of methods)
|
404
|
+
All method restrictions (sizeof(RESTRICTION) * Number of restriction
|
405
|
+
All restriction type arrays (sizeof(void *) * # of types)
|
406
|
+
INPUTS : File pointer of binary file
|
407
|
+
RETURNS : Nothing useful
|
408
|
+
SIDE EFFECTS : Binary file adjusted
|
409
|
+
NOTES : None
|
410
|
+
****************************************************************************************/
|
411
|
+
static void BsaveGenerics(
|
412
|
+
Environment *theEnv,
|
413
|
+
FILE *fp)
|
414
|
+
{
|
415
|
+
Defmodule *theModule;
|
416
|
+
DEFGENERIC_MODULE *theModuleItem;
|
417
|
+
size_t space;
|
418
|
+
BSAVE_DEFGENERIC_MODULE dummy_generic_module;
|
419
|
+
|
420
|
+
/* =====================================================================
|
421
|
+
Space is: Sum over all structures(sizeof(structure) * structure-cnt))
|
422
|
+
===================================================================== */
|
423
|
+
space = (DefgenericBinaryData(theEnv)->ModuleCount * sizeof(BSAVE_DEFGENERIC_MODULE)) +
|
424
|
+
(DefgenericBinaryData(theEnv)->GenericCount * sizeof(BSAVE_GENERIC)) +
|
425
|
+
(DefgenericBinaryData(theEnv)->MethodCount * sizeof(BSAVE_METHOD)) +
|
426
|
+
(DefgenericBinaryData(theEnv)->RestrictionCount * sizeof(BSAVE_RESTRICTION)) +
|
427
|
+
(DefgenericBinaryData(theEnv)->TypeCount * sizeof(unsigned long));
|
428
|
+
|
429
|
+
/* ================================================================
|
430
|
+
Write out the total amount of space required: modules,headers,
|
431
|
+
methods, restrictions, types
|
432
|
+
================================================================ */
|
433
|
+
GenWrite(&space,sizeof(size_t),fp);
|
434
|
+
|
435
|
+
/* ======================================
|
436
|
+
Write out the generic function modules
|
437
|
+
====================================== */
|
438
|
+
DefgenericBinaryData(theEnv)->GenericCount = 0L;
|
439
|
+
theModule = GetNextDefmodule(theEnv,NULL);
|
440
|
+
while (theModule != NULL)
|
441
|
+
{
|
442
|
+
theModuleItem = (DEFGENERIC_MODULE *)
|
443
|
+
GetModuleItem(theEnv,theModule,FindModuleItem(theEnv,"defgeneric")->moduleIndex);
|
444
|
+
AssignBsaveDefmdlItemHdrVals(&dummy_generic_module.header,
|
445
|
+
&theModuleItem->header);
|
446
|
+
GenWrite(&dummy_generic_module,
|
447
|
+
sizeof(BSAVE_DEFGENERIC_MODULE),fp);
|
448
|
+
theModule = GetNextDefmodule(theEnv,theModule);
|
449
|
+
}
|
450
|
+
|
451
|
+
|
452
|
+
/* ======================================
|
453
|
+
Write out the generic function headers
|
454
|
+
====================================== */
|
455
|
+
DefgenericBinaryData(theEnv)->MethodCount = 0L;
|
456
|
+
DoForAllConstructs(theEnv,BsaveDefgenericHeader,DefgenericData(theEnv)->DefgenericModuleIndex,
|
457
|
+
false,fp);
|
458
|
+
|
459
|
+
/* =====================
|
460
|
+
Write out the methods
|
461
|
+
===================== */
|
462
|
+
DefgenericBinaryData(theEnv)->RestrictionCount = 0L;
|
463
|
+
DoForAllConstructs(theEnv,BsaveMethods,DefgenericData(theEnv)->DefgenericModuleIndex,
|
464
|
+
false,fp);
|
465
|
+
|
466
|
+
/* =================================
|
467
|
+
Write out the method restrictions
|
468
|
+
================================= */
|
469
|
+
DefgenericBinaryData(theEnv)->TypeCount = 0L;
|
470
|
+
DoForAllConstructs(theEnv,BsaveMethodRestrictions,DefgenericData(theEnv)->DefgenericModuleIndex,
|
471
|
+
false,fp);
|
472
|
+
|
473
|
+
/* =============================================================
|
474
|
+
Finally, write out the type lists for the method restrictions
|
475
|
+
============================================================= */
|
476
|
+
DoForAllConstructs(theEnv,BsaveRestrictionTypes,DefgenericData(theEnv)->DefgenericModuleIndex,
|
477
|
+
false,fp);
|
478
|
+
|
479
|
+
RestoreBloadCount(theEnv,&DefgenericBinaryData(theEnv)->ModuleCount);
|
480
|
+
RestoreBloadCount(theEnv,&DefgenericBinaryData(theEnv)->GenericCount);
|
481
|
+
RestoreBloadCount(theEnv,&DefgenericBinaryData(theEnv)->MethodCount);
|
482
|
+
RestoreBloadCount(theEnv,&DefgenericBinaryData(theEnv)->RestrictionCount);
|
483
|
+
RestoreBloadCount(theEnv,&DefgenericBinaryData(theEnv)->TypeCount);
|
484
|
+
}
|
485
|
+
|
486
|
+
/***************************************************
|
487
|
+
NAME : BsaveDefgenericHeader
|
488
|
+
DESCRIPTION : Bsaves a generic function header
|
489
|
+
INPUTS : 1) The defgeneric
|
490
|
+
2) Output data file pointer
|
491
|
+
RETURNS : Nothing useful
|
492
|
+
SIDE EFFECTS : Defgeneric header saved
|
493
|
+
NOTES : None
|
494
|
+
***************************************************/
|
495
|
+
static void BsaveDefgenericHeader(
|
496
|
+
Environment *theEnv,
|
497
|
+
ConstructHeader *theDefgeneric,
|
498
|
+
void *userBuffer)
|
499
|
+
{
|
500
|
+
Defgeneric *gfunc = (Defgeneric *) theDefgeneric;
|
501
|
+
BSAVE_GENERIC dummy_generic;
|
502
|
+
|
503
|
+
AssignBsaveConstructHeaderVals(&dummy_generic.header,&gfunc->header);
|
504
|
+
dummy_generic.mcnt = gfunc->mcnt;
|
505
|
+
if (gfunc->methods != NULL)
|
506
|
+
{
|
507
|
+
dummy_generic.methods = DefgenericBinaryData(theEnv)->MethodCount;
|
508
|
+
DefgenericBinaryData(theEnv)->MethodCount += gfunc->mcnt;
|
509
|
+
}
|
510
|
+
else
|
511
|
+
dummy_generic.methods = ULONG_MAX;
|
512
|
+
GenWrite(&dummy_generic,sizeof(BSAVE_GENERIC),(FILE *) userBuffer);
|
513
|
+
}
|
514
|
+
|
515
|
+
/***************************************************
|
516
|
+
NAME : BsaveMethods
|
517
|
+
DESCRIPTION : Bsaves defgeneric methods
|
518
|
+
INPUTS : 1) The defgeneric
|
519
|
+
2) Output data file pointer
|
520
|
+
RETURNS : Nothing useful
|
521
|
+
SIDE EFFECTS : Defgeneric methods saved
|
522
|
+
NOTES : None
|
523
|
+
***************************************************/
|
524
|
+
static void BsaveMethods(
|
525
|
+
Environment *theEnv,
|
526
|
+
ConstructHeader *theDefgeneric,
|
527
|
+
void *userBuffer)
|
528
|
+
{
|
529
|
+
Defgeneric *gfunc = (Defgeneric *) theDefgeneric;
|
530
|
+
Defmethod *meth;
|
531
|
+
BSAVE_METHOD dummy_method;
|
532
|
+
long i;
|
533
|
+
|
534
|
+
for (i = 0 ; i < gfunc->mcnt ; i++)
|
535
|
+
{
|
536
|
+
meth = &gfunc->methods[i];
|
537
|
+
|
538
|
+
AssignBsaveConstructHeaderVals(&dummy_method.header,&meth->header);
|
539
|
+
|
540
|
+
dummy_method.index = meth->index;
|
541
|
+
dummy_method.restrictionCount = meth->restrictionCount;
|
542
|
+
dummy_method.minRestrictions = meth->minRestrictions;
|
543
|
+
dummy_method.maxRestrictions = meth->maxRestrictions;
|
544
|
+
dummy_method.localVarCount = meth->localVarCount;
|
545
|
+
dummy_method.system = meth->system;
|
546
|
+
if (meth->restrictions != NULL)
|
547
|
+
{
|
548
|
+
dummy_method.restrictions = DefgenericBinaryData(theEnv)->RestrictionCount;
|
549
|
+
DefgenericBinaryData(theEnv)->RestrictionCount += meth->restrictionCount;
|
550
|
+
}
|
551
|
+
else
|
552
|
+
dummy_method.restrictions = ULONG_MAX;
|
553
|
+
if (meth->actions != NULL)
|
554
|
+
{
|
555
|
+
dummy_method.actions = ExpressionData(theEnv)->ExpressionCount;
|
556
|
+
ExpressionData(theEnv)->ExpressionCount += ExpressionSize(meth->actions);
|
557
|
+
}
|
558
|
+
else
|
559
|
+
dummy_method.actions = ULONG_MAX;
|
560
|
+
GenWrite(&dummy_method,sizeof(BSAVE_METHOD),(FILE *) userBuffer);
|
561
|
+
}
|
562
|
+
}
|
563
|
+
|
564
|
+
/******************************************************
|
565
|
+
NAME : BsaveMethodRestrictions
|
566
|
+
DESCRIPTION : Bsaves defgeneric methods' retrictions
|
567
|
+
INPUTS : 1) The defgeneric
|
568
|
+
2) Output data file pointer
|
569
|
+
RETURNS : Nothing useful
|
570
|
+
SIDE EFFECTS : Defgeneric methods' restrictions saved
|
571
|
+
NOTES : None
|
572
|
+
******************************************************/
|
573
|
+
static void BsaveMethodRestrictions(
|
574
|
+
Environment *theEnv,
|
575
|
+
ConstructHeader *theDefgeneric,
|
576
|
+
void *userBuffer)
|
577
|
+
{
|
578
|
+
Defgeneric *gfunc = (Defgeneric *) theDefgeneric;
|
579
|
+
BSAVE_RESTRICTION dummy_restriction;
|
580
|
+
RESTRICTION *rptr;
|
581
|
+
short i,j;
|
582
|
+
|
583
|
+
for (i = 0 ; i < gfunc->mcnt ; i++)
|
584
|
+
{
|
585
|
+
for (j = 0 ; j < gfunc->methods[i].restrictionCount ; j++)
|
586
|
+
{
|
587
|
+
rptr = &gfunc->methods[i].restrictions[j];
|
588
|
+
dummy_restriction.tcnt = rptr->tcnt;
|
589
|
+
if (rptr->types != NULL)
|
590
|
+
{
|
591
|
+
dummy_restriction.types = DefgenericBinaryData(theEnv)->TypeCount;
|
592
|
+
DefgenericBinaryData(theEnv)->TypeCount += rptr->tcnt;
|
593
|
+
}
|
594
|
+
else
|
595
|
+
dummy_restriction.types = ULONG_MAX;
|
596
|
+
if (rptr->query != NULL)
|
597
|
+
{
|
598
|
+
dummy_restriction.query = ExpressionData(theEnv)->ExpressionCount;
|
599
|
+
ExpressionData(theEnv)->ExpressionCount += ExpressionSize(rptr->query);
|
600
|
+
}
|
601
|
+
else
|
602
|
+
dummy_restriction.query = ULONG_MAX;
|
603
|
+
GenWrite(&dummy_restriction,
|
604
|
+
sizeof(BSAVE_RESTRICTION),(FILE *) userBuffer);
|
605
|
+
}
|
606
|
+
}
|
607
|
+
}
|
608
|
+
|
609
|
+
/*************************************************************
|
610
|
+
NAME : BsaveRestrictionTypes
|
611
|
+
DESCRIPTION : Bsaves defgeneric methods' retrictions' types
|
612
|
+
INPUTS : 1) The defgeneric
|
613
|
+
2) Output data file pointer
|
614
|
+
RETURNS : Nothing useful
|
615
|
+
SIDE EFFECTS : Defgeneric methods' restrictions' types saved
|
616
|
+
NOTES : None
|
617
|
+
*************************************************************/
|
618
|
+
static void BsaveRestrictionTypes(
|
619
|
+
Environment *theEnv,
|
620
|
+
ConstructHeader *theDefgeneric,
|
621
|
+
void *userBuffer)
|
622
|
+
{
|
623
|
+
Defgeneric *gfunc = (Defgeneric *) theDefgeneric;
|
624
|
+
unsigned long dummy_type;
|
625
|
+
RESTRICTION *rptr;
|
626
|
+
short i,j,k;
|
627
|
+
#if MAC_XCD
|
628
|
+
#pragma unused(theEnv)
|
629
|
+
#endif
|
630
|
+
|
631
|
+
for (i = 0 ; i < gfunc->mcnt ; i++)
|
632
|
+
{
|
633
|
+
for (j = 0 ; j < gfunc->methods[i].restrictionCount ; j++)
|
634
|
+
{
|
635
|
+
rptr = &gfunc->methods[i].restrictions[j];
|
636
|
+
for (k = 0 ; k < rptr->tcnt ; k++)
|
637
|
+
{
|
638
|
+
#if OBJECT_SYSTEM
|
639
|
+
dummy_type = DefclassIndex(rptr->types[k]);
|
640
|
+
#else
|
641
|
+
dummy_type = (unsigned long) ((CLIPSInteger *) rptr->types[k])->contents;
|
642
|
+
#endif
|
643
|
+
GenWrite(&dummy_type,sizeof(unsigned long),(FILE *) userBuffer);
|
644
|
+
}
|
645
|
+
}
|
646
|
+
}
|
647
|
+
}
|
648
|
+
|
649
|
+
#endif
|
650
|
+
|
651
|
+
/***********************************************************************
|
652
|
+
NAME : BloadStorageGenerics
|
653
|
+
DESCRIPTION : This routine space required for generic function
|
654
|
+
structures and allocates space for them
|
655
|
+
INPUTS : Nothing
|
656
|
+
RETURNS : Nothing useful
|
657
|
+
SIDE EFFECTS : Arrays allocated and set
|
658
|
+
NOTES : This routine makes no attempt to reset any pointers
|
659
|
+
within the structures
|
660
|
+
***********************************************************************/
|
661
|
+
static void BloadStorageGenerics(
|
662
|
+
Environment *theEnv)
|
663
|
+
{
|
664
|
+
size_t space;
|
665
|
+
unsigned long counts[5];
|
666
|
+
|
667
|
+
GenReadBinary(theEnv,&space,sizeof(size_t));
|
668
|
+
if (space == 0L)
|
669
|
+
return;
|
670
|
+
GenReadBinary(theEnv,counts,space);
|
671
|
+
DefgenericBinaryData(theEnv)->ModuleCount = counts[0];
|
672
|
+
DefgenericBinaryData(theEnv)->GenericCount = counts[1];
|
673
|
+
DefgenericBinaryData(theEnv)->MethodCount = counts[2];
|
674
|
+
DefgenericBinaryData(theEnv)->RestrictionCount = counts[3];
|
675
|
+
DefgenericBinaryData(theEnv)->TypeCount = counts[4];
|
676
|
+
if (DefgenericBinaryData(theEnv)->ModuleCount != 0L)
|
677
|
+
{
|
678
|
+
space = (sizeof(DEFGENERIC_MODULE) * DefgenericBinaryData(theEnv)->ModuleCount);
|
679
|
+
DefgenericBinaryData(theEnv)->ModuleArray = (DEFGENERIC_MODULE *) genalloc(theEnv,space);
|
680
|
+
}
|
681
|
+
else
|
682
|
+
return;
|
683
|
+
if (DefgenericBinaryData(theEnv)->GenericCount != 0L)
|
684
|
+
{
|
685
|
+
space = (sizeof(Defgeneric) * DefgenericBinaryData(theEnv)->GenericCount);
|
686
|
+
DefgenericBinaryData(theEnv)->DefgenericArray = (Defgeneric *) genalloc(theEnv,space);
|
687
|
+
}
|
688
|
+
else
|
689
|
+
return;
|
690
|
+
if (DefgenericBinaryData(theEnv)->MethodCount != 0L)
|
691
|
+
{
|
692
|
+
space = (sizeof(Defmethod) * DefgenericBinaryData(theEnv)->MethodCount);
|
693
|
+
DefgenericBinaryData(theEnv)->MethodArray = (Defmethod *) genalloc(theEnv,space);
|
694
|
+
}
|
695
|
+
else
|
696
|
+
return;
|
697
|
+
if (DefgenericBinaryData(theEnv)->RestrictionCount != 0L)
|
698
|
+
{
|
699
|
+
space = (sizeof(RESTRICTION) * DefgenericBinaryData(theEnv)->RestrictionCount);
|
700
|
+
DefgenericBinaryData(theEnv)->RestrictionArray = (RESTRICTION *) genalloc(theEnv,space);
|
701
|
+
}
|
702
|
+
else
|
703
|
+
return;
|
704
|
+
if (DefgenericBinaryData(theEnv)->TypeCount != 0L)
|
705
|
+
{
|
706
|
+
space = (sizeof(void *) * DefgenericBinaryData(theEnv)->TypeCount);
|
707
|
+
DefgenericBinaryData(theEnv)->TypeArray = (void * *) genalloc(theEnv,space);
|
708
|
+
}
|
709
|
+
}
|
710
|
+
|
711
|
+
/*********************************************************************
|
712
|
+
NAME : BloadGenerics
|
713
|
+
DESCRIPTION : This routine reads generic function information from
|
714
|
+
a binary file in four chunks:
|
715
|
+
Generic-header array
|
716
|
+
Method array
|
717
|
+
Method restrictions array
|
718
|
+
Restriction types array
|
719
|
+
|
720
|
+
This routine moves through the generic function
|
721
|
+
binary arrays updating pointers
|
722
|
+
INPUTS : None
|
723
|
+
RETURNS : Nothing useful
|
724
|
+
SIDE EFFECTS : Pointers reset from array indices
|
725
|
+
NOTES : Assumes all loading is finished
|
726
|
+
********************************************************************/
|
727
|
+
static void BloadGenerics(
|
728
|
+
Environment *theEnv)
|
729
|
+
{
|
730
|
+
size_t space;
|
731
|
+
|
732
|
+
GenReadBinary(theEnv,&space,sizeof(size_t));
|
733
|
+
if (DefgenericBinaryData(theEnv)->ModuleCount == 0L)
|
734
|
+
return;
|
735
|
+
BloadandRefresh(theEnv,DefgenericBinaryData(theEnv)->ModuleCount,sizeof(BSAVE_DEFGENERIC_MODULE),UpdateGenericModule);
|
736
|
+
if (DefgenericBinaryData(theEnv)->GenericCount == 0L)
|
737
|
+
return;
|
738
|
+
BloadandRefresh(theEnv,DefgenericBinaryData(theEnv)->GenericCount,sizeof(BSAVE_GENERIC),UpdateGeneric);
|
739
|
+
BloadandRefresh(theEnv,DefgenericBinaryData(theEnv)->MethodCount,sizeof(BSAVE_METHOD),UpdateMethod);
|
740
|
+
BloadandRefresh(theEnv,DefgenericBinaryData(theEnv)->RestrictionCount,sizeof(BSAVE_RESTRICTION),UpdateRestriction);
|
741
|
+
BloadandRefresh(theEnv,DefgenericBinaryData(theEnv)->TypeCount,sizeof(long),UpdateType);
|
742
|
+
}
|
743
|
+
|
744
|
+
/*********************************************
|
745
|
+
Bload update routines for generic structures
|
746
|
+
*********************************************/
|
747
|
+
static void UpdateGenericModule(
|
748
|
+
Environment *theEnv,
|
749
|
+
void *buf,
|
750
|
+
unsigned long obji)
|
751
|
+
{
|
752
|
+
BSAVE_DEFGENERIC_MODULE *bdptr;
|
753
|
+
|
754
|
+
bdptr = (BSAVE_DEFGENERIC_MODULE *) buf;
|
755
|
+
UpdateDefmoduleItemHeader(theEnv,&bdptr->header,&DefgenericBinaryData(theEnv)->ModuleArray[obji].header,
|
756
|
+
sizeof(Defgeneric),DefgenericBinaryData(theEnv)->DefgenericArray);
|
757
|
+
}
|
758
|
+
|
759
|
+
static void UpdateGeneric(
|
760
|
+
Environment *theEnv,
|
761
|
+
void *buf,
|
762
|
+
unsigned long obji)
|
763
|
+
{
|
764
|
+
BSAVE_GENERIC *bgp;
|
765
|
+
Defgeneric *gp;
|
766
|
+
|
767
|
+
bgp = (BSAVE_GENERIC *) buf;
|
768
|
+
gp = &DefgenericBinaryData(theEnv)->DefgenericArray[obji];
|
769
|
+
|
770
|
+
UpdateConstructHeader(theEnv,&bgp->header,&gp->header,DEFGENERIC,
|
771
|
+
sizeof(DEFGENERIC_MODULE),DefgenericBinaryData(theEnv)->ModuleArray,
|
772
|
+
sizeof(Defgeneric),DefgenericBinaryData(theEnv)->DefgenericArray);
|
773
|
+
DefgenericBinaryData(theEnv)->DefgenericArray[obji].busy = 0;
|
774
|
+
#if DEBUGGING_FUNCTIONS
|
775
|
+
DefgenericBinaryData(theEnv)->DefgenericArray[obji].trace = DefgenericData(theEnv)->WatchGenerics;
|
776
|
+
#endif
|
777
|
+
DefgenericBinaryData(theEnv)->DefgenericArray[obji].methods = MethodPointer(bgp->methods);
|
778
|
+
DefgenericBinaryData(theEnv)->DefgenericArray[obji].mcnt = bgp->mcnt;
|
779
|
+
DefgenericBinaryData(theEnv)->DefgenericArray[obji].new_index = 0;
|
780
|
+
}
|
781
|
+
|
782
|
+
static void UpdateMethod(
|
783
|
+
Environment *theEnv,
|
784
|
+
void *buf,
|
785
|
+
unsigned long obji)
|
786
|
+
{
|
787
|
+
BSAVE_METHOD *bmth;
|
788
|
+
|
789
|
+
bmth = (BSAVE_METHOD *) buf;
|
790
|
+
DefgenericBinaryData(theEnv)->MethodArray[obji].index = bmth->index;
|
791
|
+
DefgenericBinaryData(theEnv)->MethodArray[obji].busy = 0;
|
792
|
+
#if DEBUGGING_FUNCTIONS
|
793
|
+
DefgenericBinaryData(theEnv)->MethodArray[obji].trace = DefgenericData(theEnv)->WatchMethods;
|
794
|
+
#endif
|
795
|
+
DefgenericBinaryData(theEnv)->MethodArray[obji].restrictionCount = bmth->restrictionCount;
|
796
|
+
DefgenericBinaryData(theEnv)->MethodArray[obji].minRestrictions = bmth->minRestrictions;
|
797
|
+
DefgenericBinaryData(theEnv)->MethodArray[obji].maxRestrictions = bmth->maxRestrictions;
|
798
|
+
DefgenericBinaryData(theEnv)->MethodArray[obji].localVarCount = bmth->localVarCount;
|
799
|
+
DefgenericBinaryData(theEnv)->MethodArray[obji].system = bmth->system;
|
800
|
+
DefgenericBinaryData(theEnv)->MethodArray[obji].restrictions = RestrictionPointer(bmth->restrictions);
|
801
|
+
DefgenericBinaryData(theEnv)->MethodArray[obji].actions = ExpressionPointer(bmth->actions);
|
802
|
+
|
803
|
+
UpdateConstructHeader(theEnv,&bmth->header,&DefgenericBinaryData(theEnv)->MethodArray[obji].header,DEFMETHOD,
|
804
|
+
sizeof(DEFGENERIC_MODULE),DefgenericBinaryData(theEnv)->ModuleArray,
|
805
|
+
sizeof(Defmethod),DefgenericBinaryData(theEnv)->MethodArray);
|
806
|
+
}
|
807
|
+
|
808
|
+
static void UpdateRestriction(
|
809
|
+
Environment *theEnv,
|
810
|
+
void *buf,
|
811
|
+
unsigned long obji)
|
812
|
+
{
|
813
|
+
BSAVE_RESTRICTION *brp;
|
814
|
+
|
815
|
+
brp = (BSAVE_RESTRICTION *) buf;
|
816
|
+
DefgenericBinaryData(theEnv)->RestrictionArray[obji].tcnt = brp->tcnt;
|
817
|
+
DefgenericBinaryData(theEnv)->RestrictionArray[obji].types = TypePointer(brp->types);
|
818
|
+
DefgenericBinaryData(theEnv)->RestrictionArray[obji].query = ExpressionPointer(brp->query);
|
819
|
+
}
|
820
|
+
|
821
|
+
static void UpdateType(
|
822
|
+
Environment *theEnv,
|
823
|
+
void *buf,
|
824
|
+
unsigned long obji)
|
825
|
+
{
|
826
|
+
#if OBJECT_SYSTEM
|
827
|
+
DefgenericBinaryData(theEnv)->TypeArray[obji] = DefclassPointer(* (unsigned long *) buf);
|
828
|
+
#else
|
829
|
+
if ((* (long *) buf) > INSTANCE_TYPE_CODE)
|
830
|
+
{
|
831
|
+
PrintWarningID(theEnv,"GENRCBIN",1,false);
|
832
|
+
WriteString(theEnv,STDWRN,"COOL not installed! User-defined class\n");
|
833
|
+
WriteString(theEnv,STDWRN," in method restriction substituted with OBJECT.\n");
|
834
|
+
DefgenericBinaryData(theEnv)->TypeArray[obji] = CreateInteger(theEnv,OBJECT_TYPE_CODE);
|
835
|
+
}
|
836
|
+
else
|
837
|
+
DefgenericBinaryData(theEnv)->TypeArray[obji] = CreateInteger(theEnv,* (long *) buf);
|
838
|
+
IncrementIntegerCount((CLIPSInteger *) DefgenericBinaryData(theEnv)->TypeArray[obji]);
|
839
|
+
#endif
|
840
|
+
}
|
841
|
+
|
842
|
+
/***************************************************************
|
843
|
+
NAME : ClearBloadGenerics
|
844
|
+
DESCRIPTION : Release all binary-loaded generic function
|
845
|
+
structure arrays
|
846
|
+
Resets generic function list to NULL
|
847
|
+
INPUTS : None
|
848
|
+
RETURNS : Nothing useful
|
849
|
+
SIDE EFFECTS : Memory cleared
|
850
|
+
NOTES : Generic function name symbol counts decremented
|
851
|
+
***************************************************************/
|
852
|
+
static void ClearBloadGenerics(
|
853
|
+
Environment *theEnv)
|
854
|
+
{
|
855
|
+
unsigned long i;
|
856
|
+
size_t space;
|
857
|
+
|
858
|
+
space = (sizeof(DEFGENERIC_MODULE) * DefgenericBinaryData(theEnv)->ModuleCount);
|
859
|
+
if (space == 0L)
|
860
|
+
return;
|
861
|
+
genfree(theEnv,DefgenericBinaryData(theEnv)->ModuleArray,space);
|
862
|
+
DefgenericBinaryData(theEnv)->ModuleArray = NULL;
|
863
|
+
DefgenericBinaryData(theEnv)->ModuleCount = 0L;
|
864
|
+
|
865
|
+
for (i = 0 ; i < DefgenericBinaryData(theEnv)->GenericCount ; i++)
|
866
|
+
UnmarkConstructHeader(theEnv,&DefgenericBinaryData(theEnv)->DefgenericArray[i].header);
|
867
|
+
|
868
|
+
space = (sizeof(Defgeneric) * DefgenericBinaryData(theEnv)->GenericCount);
|
869
|
+
if (space == 0L)
|
870
|
+
return;
|
871
|
+
genfree(theEnv,DefgenericBinaryData(theEnv)->DefgenericArray,space);
|
872
|
+
DefgenericBinaryData(theEnv)->DefgenericArray = NULL;
|
873
|
+
DefgenericBinaryData(theEnv)->GenericCount = 0L;
|
874
|
+
|
875
|
+
space = (sizeof(Defmethod) * DefgenericBinaryData(theEnv)->MethodCount);
|
876
|
+
if (space == 0L)
|
877
|
+
return;
|
878
|
+
genfree(theEnv,DefgenericBinaryData(theEnv)->MethodArray,space);
|
879
|
+
DefgenericBinaryData(theEnv)->MethodArray = NULL;
|
880
|
+
DefgenericBinaryData(theEnv)->MethodCount = 0L;
|
881
|
+
|
882
|
+
space = (sizeof(RESTRICTION) * DefgenericBinaryData(theEnv)->RestrictionCount);
|
883
|
+
if (space == 0L)
|
884
|
+
return;
|
885
|
+
genfree(theEnv,DefgenericBinaryData(theEnv)->RestrictionArray,space);
|
886
|
+
DefgenericBinaryData(theEnv)->RestrictionArray = NULL;
|
887
|
+
DefgenericBinaryData(theEnv)->RestrictionCount = 0L;
|
888
|
+
|
889
|
+
#if ! OBJECT_SYSTEM
|
890
|
+
for (i = 0 ; i < DefgenericBinaryData(theEnv)->TypeCount ; i++)
|
891
|
+
ReleaseInteger(theEnv,(CLIPSInteger *) DefgenericBinaryData(theEnv)->TypeArray[i]);
|
892
|
+
#endif
|
893
|
+
space = (sizeof(void *) * DefgenericBinaryData(theEnv)->TypeCount);
|
894
|
+
if (space == 0L)
|
895
|
+
return;
|
896
|
+
genfree(theEnv,DefgenericBinaryData(theEnv)->TypeArray,space);
|
897
|
+
DefgenericBinaryData(theEnv)->TypeArray = NULL;
|
898
|
+
DefgenericBinaryData(theEnv)->TypeCount = 0L;
|
899
|
+
}
|
900
|
+
|
901
|
+
#endif
|
902
|
+
|