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,804 @@
|
|
1
|
+
/*******************************************************/
|
2
|
+
/* "C" Language Integrated Production System */
|
3
|
+
/* */
|
4
|
+
/* CLIPS Version 6.40 11/07/17 */
|
5
|
+
/* */
|
6
|
+
/* INSTANCE MULTIFIELD_TYPE SLOT MODULE */
|
7
|
+
/*******************************************************/
|
8
|
+
|
9
|
+
/*************************************************************/
|
10
|
+
/* Purpose: Access routines for Instance Multifield Slots */
|
11
|
+
/* */
|
12
|
+
/* Principal Programmer(s): */
|
13
|
+
/* Brian L. Dantes */
|
14
|
+
/* */
|
15
|
+
/* Contributing Programmer(s): */
|
16
|
+
/* */
|
17
|
+
/* Revision History: */
|
18
|
+
/* */
|
19
|
+
/* 6.23: Correction for FalseSymbol/TrueSymbol. DR0859 */
|
20
|
+
/* */
|
21
|
+
/* 6.24: Renamed BOOLEAN macro type to intBool. */
|
22
|
+
/* */
|
23
|
+
/* 6.30: Added const qualifiers to remove C++ */
|
24
|
+
/* deprecation warnings. */
|
25
|
+
/* */
|
26
|
+
/* Changed integer type/precision. */
|
27
|
+
/* */
|
28
|
+
/* 6.40: Added Env prefix to GetEvaluationError and */
|
29
|
+
/* SetEvaluationError functions. */
|
30
|
+
/* */
|
31
|
+
/* Pragma once and other inclusion changes. */
|
32
|
+
/* */
|
33
|
+
/* Added support for booleans with <stdbool.h>. */
|
34
|
+
/* */
|
35
|
+
/* Removed use of void pointers for specific */
|
36
|
+
/* data structures. */
|
37
|
+
/* */
|
38
|
+
/* Removed direct-mv-replace, direct-mv-insert, */
|
39
|
+
/* direct-mv-delete, mv-slot-replace, */
|
40
|
+
/* mv-slot-insert, and mv-slot-delete functions. */
|
41
|
+
/* */
|
42
|
+
/* UDF redesign. */
|
43
|
+
/* */
|
44
|
+
/* Eval support for run time and bload only. */
|
45
|
+
/* */
|
46
|
+
/*************************************************************/
|
47
|
+
|
48
|
+
/* =========================================
|
49
|
+
*****************************************
|
50
|
+
EXTERNAL DEFINITIONS
|
51
|
+
=========================================
|
52
|
+
***************************************** */
|
53
|
+
#include "setup.h"
|
54
|
+
|
55
|
+
#if OBJECT_SYSTEM
|
56
|
+
|
57
|
+
#include "argacces.h"
|
58
|
+
#include "envrnmnt.h"
|
59
|
+
#include "extnfunc.h"
|
60
|
+
#include "insfun.h"
|
61
|
+
#include "msgfun.h"
|
62
|
+
#include "msgpass.h"
|
63
|
+
#include "multifun.h"
|
64
|
+
#include "prntutil.h"
|
65
|
+
#include "router.h"
|
66
|
+
|
67
|
+
#include "insmult.h"
|
68
|
+
|
69
|
+
/* =========================================
|
70
|
+
*****************************************
|
71
|
+
CONSTANTS
|
72
|
+
=========================================
|
73
|
+
***************************************** */
|
74
|
+
#define INSERT 0
|
75
|
+
#define REPLACE 1
|
76
|
+
#define DELETE_OP 2
|
77
|
+
|
78
|
+
/***************************************/
|
79
|
+
/* LOCAL INTERNAL FUNCTION DEFINITIONS */
|
80
|
+
/***************************************/
|
81
|
+
|
82
|
+
static Instance *CheckMultifieldSlotInstance(UDFContext *);
|
83
|
+
static InstanceSlot *CheckMultifieldSlotModify(Environment *,int,const char *,Instance *,
|
84
|
+
Expression *,long long *,long long *,UDFValue *);
|
85
|
+
static void AssignSlotToDataObject(UDFValue *,InstanceSlot *);
|
86
|
+
|
87
|
+
/* =========================================
|
88
|
+
*****************************************
|
89
|
+
EXTERNALLY VISIBLE FUNCTIONS
|
90
|
+
=========================================
|
91
|
+
***************************************** */
|
92
|
+
|
93
|
+
/***************************************************
|
94
|
+
NAME : SetupInstanceMultifieldCommands
|
95
|
+
DESCRIPTION : Defines function interfaces for
|
96
|
+
manipulating instance multislots
|
97
|
+
INPUTS : None
|
98
|
+
RETURNS : Nothing useful
|
99
|
+
SIDE EFFECTS : Functions defined to KB
|
100
|
+
NOTES : None
|
101
|
+
***************************************************/
|
102
|
+
void SetupInstanceMultifieldCommands(
|
103
|
+
Environment *theEnv)
|
104
|
+
{
|
105
|
+
#if (! RUN_TIME)
|
106
|
+
AddUDF(theEnv,"slot-direct-replace$","b",4,UNBOUNDED,"*;y;l;l",DirectMVReplaceCommand,"DirectMVReplaceCommand",NULL);
|
107
|
+
AddUDF(theEnv,"slot-direct-insert$","b",3,UNBOUNDED,"*;y;l",DirectMVInsertCommand,"DirectMVInsertCommand",NULL);
|
108
|
+
AddUDF(theEnv,"slot-direct-delete$","b",3,3,"l;y",DirectMVDeleteCommand,"DirectMVDeleteCommand",NULL);
|
109
|
+
AddUDF(theEnv,"slot-replace$","*",5,UNBOUNDED,"*;iny;y;l;l",MVSlotReplaceCommand,"MVSlotReplaceCommand",NULL);
|
110
|
+
AddUDF(theEnv,"slot-insert$","*",4,UNBOUNDED,"*;iny;y;l",MVSlotInsertCommand,"MVSlotInsertCommand",NULL);
|
111
|
+
AddUDF(theEnv,"slot-delete$","*",4,4,"l;iny;y",MVSlotDeleteCommand,"MVSlotDeleteCommand",NULL);
|
112
|
+
#endif
|
113
|
+
}
|
114
|
+
|
115
|
+
/***********************************************************************************
|
116
|
+
NAME : MVSlotReplaceCommand
|
117
|
+
DESCRIPTION : Allows user to replace a specified field of a multi-value slot
|
118
|
+
The slot is directly read (w/o a get- message) and the new
|
119
|
+
slot-value is placed via a put- message.
|
120
|
+
This function is not valid for single-value slots.
|
121
|
+
INPUTS : Caller's result buffer
|
122
|
+
RETURNS : True if multi-value slot successfully modified,
|
123
|
+
false otherwise
|
124
|
+
SIDE EFFECTS : Put messsage sent for slot
|
125
|
+
NOTES : H/L Syntax : (slot-replace$ <instance> <slot>
|
126
|
+
<range-begin> <range-end> <value>)
|
127
|
+
***********************************************************************************/
|
128
|
+
void MVSlotReplaceCommand(
|
129
|
+
Environment *theEnv,
|
130
|
+
UDFContext *context,
|
131
|
+
UDFValue *returnValue)
|
132
|
+
{
|
133
|
+
UDFValue newval,newseg,oldseg;
|
134
|
+
Instance *ins;
|
135
|
+
InstanceSlot *sp;
|
136
|
+
long long start, end;
|
137
|
+
size_t rs, re, srcLen, dstLen;
|
138
|
+
size_t i, j, k;
|
139
|
+
Expression arg;
|
140
|
+
|
141
|
+
returnValue->lexemeValue = FalseSymbol(theEnv);
|
142
|
+
ins = CheckMultifieldSlotInstance(context);
|
143
|
+
if (ins == NULL)
|
144
|
+
return;
|
145
|
+
sp = CheckMultifieldSlotModify(theEnv,REPLACE,"slot-replace$",ins,
|
146
|
+
GetFirstArgument()->nextArg,&start,&end,&newval);
|
147
|
+
if (sp == NULL)
|
148
|
+
return;
|
149
|
+
AssignSlotToDataObject(&oldseg,sp);
|
150
|
+
|
151
|
+
/*===========================================*/
|
152
|
+
/* Verify the start and end index arguments. */
|
153
|
+
/*===========================================*/
|
154
|
+
|
155
|
+
if ((end < start) || (start < 1) || (end < 1) || // TBD Refactor
|
156
|
+
(((long long) ((size_t) start)) != start) ||
|
157
|
+
(((long long) ((size_t) end)) != end))
|
158
|
+
{
|
159
|
+
MVRangeError(theEnv,start,end,oldseg.range,"slot-replace$");
|
160
|
+
return;
|
161
|
+
}
|
162
|
+
|
163
|
+
/*============================================*/
|
164
|
+
/* Convert the indices to unsigned zero-based */
|
165
|
+
/* values including the begin value. */
|
166
|
+
/*============================================*/
|
167
|
+
|
168
|
+
rs = (size_t) start;
|
169
|
+
re = (size_t) end;
|
170
|
+
srcLen = oldseg.range;
|
171
|
+
|
172
|
+
if ((rs > srcLen) || (re > srcLen))
|
173
|
+
{
|
174
|
+
MVRangeError(theEnv,start,end,oldseg.range,"slot-replace$");
|
175
|
+
return;
|
176
|
+
}
|
177
|
+
|
178
|
+
rs--;
|
179
|
+
re--;
|
180
|
+
rs += oldseg.begin;
|
181
|
+
re += oldseg.begin;
|
182
|
+
|
183
|
+
dstLen = srcLen - (re - rs + 1); // TBD Refactor
|
184
|
+
newseg.begin = 0;
|
185
|
+
newseg.range = dstLen;
|
186
|
+
newseg.multifieldValue = CreateMultifield(theEnv,dstLen);
|
187
|
+
|
188
|
+
|
189
|
+
/*===================================*/
|
190
|
+
/* Delete the members from the slot. */
|
191
|
+
/*===================================*/
|
192
|
+
|
193
|
+
if (newval.header->type == MULTIFIELD_TYPE) // TBD Refactor
|
194
|
+
{ dstLen = srcLen - (re - rs + 1) + newval.range; }
|
195
|
+
else
|
196
|
+
{ dstLen = srcLen - (re - rs); }
|
197
|
+
|
198
|
+
newseg.begin = 0;
|
199
|
+
newseg.range = dstLen;
|
200
|
+
newseg.multifieldValue = CreateMultifield(theEnv,dstLen);
|
201
|
+
|
202
|
+
for (i = oldseg.begin, j = 0; i < (oldseg.begin + oldseg.range); i++)
|
203
|
+
{
|
204
|
+
if (i == rs)
|
205
|
+
{
|
206
|
+
if (newval.header->type == MULTIFIELD_TYPE)
|
207
|
+
{
|
208
|
+
for (k = newval.begin; k < (newval.begin + newval.range); k++)
|
209
|
+
{ newseg.multifieldValue->contents[j++].value = newval.multifieldValue->contents[k].value; }
|
210
|
+
}
|
211
|
+
else
|
212
|
+
{ newseg.multifieldValue->contents[j++].value = newval.value; }
|
213
|
+
|
214
|
+
continue;
|
215
|
+
}
|
216
|
+
else if ((i > rs) && (i <= re))
|
217
|
+
{ continue; }
|
218
|
+
|
219
|
+
newseg.multifieldValue->contents[j++].value = oldseg.multifieldValue->contents[i].value;
|
220
|
+
}
|
221
|
+
|
222
|
+
arg.type = MULTIFIELD_TYPE;
|
223
|
+
arg.value = &newseg;
|
224
|
+
arg.nextArg = NULL;
|
225
|
+
arg.argList = NULL;
|
226
|
+
DirectMessage(theEnv,sp->desc->overrideMessage,ins,returnValue,&arg);
|
227
|
+
}
|
228
|
+
|
229
|
+
/***********************************************************************************
|
230
|
+
NAME : MVSlotInsertCommand
|
231
|
+
DESCRIPTION : Allows user to insert a specified field of a multi-value slot
|
232
|
+
The slot is directly read (w/o a get- message) and the new
|
233
|
+
slot-value is placed via a put- message.
|
234
|
+
This function is not valid for single-value slots.
|
235
|
+
INPUTS : Caller's result buffer
|
236
|
+
RETURNS : True if multi-value slot successfully modified, false otherwise
|
237
|
+
SIDE EFFECTS : Put messsage sent for slot
|
238
|
+
NOTES : H/L Syntax : (slot-insert$ <instance> <slot> <index> <value>)
|
239
|
+
***********************************************************************************/
|
240
|
+
void MVSlotInsertCommand(
|
241
|
+
Environment *theEnv,
|
242
|
+
UDFContext *context,
|
243
|
+
UDFValue *returnValue)
|
244
|
+
{
|
245
|
+
UDFValue newval,newseg,oldseg;
|
246
|
+
Instance *ins;
|
247
|
+
InstanceSlot *sp;
|
248
|
+
long long theIndex;
|
249
|
+
Expression arg;
|
250
|
+
size_t uindex;
|
251
|
+
|
252
|
+
returnValue->lexemeValue = FalseSymbol(theEnv);
|
253
|
+
ins = CheckMultifieldSlotInstance(context);
|
254
|
+
if (ins == NULL)
|
255
|
+
return;
|
256
|
+
sp = CheckMultifieldSlotModify(theEnv,INSERT,"slot-insert$",ins,
|
257
|
+
GetFirstArgument()->nextArg,&theIndex,NULL,&newval);
|
258
|
+
if (sp == NULL)
|
259
|
+
return;
|
260
|
+
|
261
|
+
AssignSlotToDataObject(&oldseg,sp);
|
262
|
+
|
263
|
+
if ((((long long) ((size_t) theIndex)) != theIndex) ||
|
264
|
+
(theIndex < 1))
|
265
|
+
{
|
266
|
+
MVRangeError(theEnv,theIndex,theIndex,oldseg.range,"slot-insert$");
|
267
|
+
return;
|
268
|
+
}
|
269
|
+
|
270
|
+
uindex = (size_t) theIndex;
|
271
|
+
|
272
|
+
if (InsertMultiValueField(theEnv,&newseg,&oldseg,uindex,&newval,"slot-insert$") == false)
|
273
|
+
return;
|
274
|
+
|
275
|
+
arg.type = MULTIFIELD_TYPE;
|
276
|
+
arg.value = &newseg;
|
277
|
+
arg.nextArg = NULL;
|
278
|
+
arg.argList = NULL;
|
279
|
+
DirectMessage(theEnv,sp->desc->overrideMessage,ins,returnValue,&arg);
|
280
|
+
}
|
281
|
+
|
282
|
+
/***********************************************************************************
|
283
|
+
NAME : MVSlotDeleteCommand
|
284
|
+
DESCRIPTION : Allows user to delete a specified field of a multi-value slot
|
285
|
+
The slot is directly read (w/o a get- message) and the new
|
286
|
+
slot-value is placed via a put- message.
|
287
|
+
This function is not valid for single-value slots.
|
288
|
+
INPUTS : Caller's result buffer
|
289
|
+
RETURNS : True if multi-value slot successfully modified, false otherwise
|
290
|
+
SIDE EFFECTS : Put message sent for slot
|
291
|
+
NOTES : H/L Syntax : (slot-delete$ <instance> <slot>
|
292
|
+
<range-begin> <range-end>)
|
293
|
+
***********************************************************************************/
|
294
|
+
void MVSlotDeleteCommand(
|
295
|
+
Environment *theEnv,
|
296
|
+
UDFContext *context,
|
297
|
+
UDFValue *returnValue)
|
298
|
+
{
|
299
|
+
UDFValue newseg,oldseg;
|
300
|
+
Instance *ins;
|
301
|
+
InstanceSlot *sp;
|
302
|
+
long long start, end;
|
303
|
+
Expression arg;
|
304
|
+
size_t rs, re, srcLen, dstLen, i, j;
|
305
|
+
|
306
|
+
returnValue->lexemeValue = FalseSymbol(theEnv);
|
307
|
+
ins = CheckMultifieldSlotInstance(context);
|
308
|
+
if (ins == NULL)
|
309
|
+
return;
|
310
|
+
sp = CheckMultifieldSlotModify(theEnv,DELETE_OP,"slot-delete$",ins,
|
311
|
+
GetFirstArgument()->nextArg,&start,&end,NULL);
|
312
|
+
if (sp == NULL)
|
313
|
+
return;
|
314
|
+
AssignSlotToDataObject(&oldseg,sp);
|
315
|
+
|
316
|
+
/*===========================================*/
|
317
|
+
/* Verify the start and end index arguments. */
|
318
|
+
/*===========================================*/
|
319
|
+
|
320
|
+
if ((end < start) || (start < 1) || (end < 1) || // TBD Refactor
|
321
|
+
(((long long) ((size_t) start)) != start) ||
|
322
|
+
(((long long) ((size_t) end)) != end))
|
323
|
+
{
|
324
|
+
MVRangeError(theEnv,start,end,oldseg.range,"slot-delete$");
|
325
|
+
SetEvaluationError(theEnv,true);
|
326
|
+
SetMultifieldErrorValue(theEnv,returnValue);
|
327
|
+
return;
|
328
|
+
}
|
329
|
+
|
330
|
+
/*============================================*/
|
331
|
+
/* Convert the indices to unsigned zero-based */
|
332
|
+
/* values including the begin value. */
|
333
|
+
/*============================================*/
|
334
|
+
|
335
|
+
rs = (size_t) start;
|
336
|
+
re = (size_t) end;
|
337
|
+
srcLen = oldseg.range;
|
338
|
+
|
339
|
+
if ((rs > srcLen) || (re > srcLen))
|
340
|
+
{
|
341
|
+
MVRangeError(theEnv,start,end,oldseg.range,"slot-delete$");
|
342
|
+
SetEvaluationError(theEnv,true);
|
343
|
+
SetMultifieldErrorValue(theEnv,returnValue);
|
344
|
+
return;
|
345
|
+
}
|
346
|
+
|
347
|
+
rs--;
|
348
|
+
re--;
|
349
|
+
rs += oldseg.begin;
|
350
|
+
re += oldseg.begin;
|
351
|
+
|
352
|
+
/*===================================*/
|
353
|
+
/* Delete the members from the slot. */
|
354
|
+
/*===================================*/
|
355
|
+
|
356
|
+
dstLen = srcLen - (re - rs + 1); // TBD Refactor
|
357
|
+
newseg.begin = 0;
|
358
|
+
newseg.range = dstLen;
|
359
|
+
newseg.multifieldValue = CreateMultifield(theEnv,dstLen);
|
360
|
+
|
361
|
+
for (i = oldseg.begin, j = 0; i < (oldseg.begin + oldseg.range); i++)
|
362
|
+
{
|
363
|
+
if ((i >= rs) && (i <= re)) continue;
|
364
|
+
|
365
|
+
newseg.multifieldValue->contents[j++].value = oldseg.multifieldValue->contents[i].value;
|
366
|
+
}
|
367
|
+
|
368
|
+
arg.type = MULTIFIELD_TYPE;
|
369
|
+
arg.value = &newseg;
|
370
|
+
arg.nextArg = NULL;
|
371
|
+
arg.argList = NULL;
|
372
|
+
DirectMessage(theEnv,sp->desc->overrideMessage,ins,returnValue,&arg);
|
373
|
+
}
|
374
|
+
|
375
|
+
/*****************************************************************
|
376
|
+
NAME : DirectMVReplaceCommand
|
377
|
+
DESCRIPTION : Directly replaces a slot's value
|
378
|
+
INPUTS : None
|
379
|
+
RETURNS : True if put OK, false otherwise
|
380
|
+
SIDE EFFECTS : Slot modified
|
381
|
+
NOTES : H/L Syntax: (direct-slot-replace$ <slot>
|
382
|
+
<range-begin> <range-end> <value>)
|
383
|
+
*****************************************************************/
|
384
|
+
void DirectMVReplaceCommand(
|
385
|
+
Environment *theEnv,
|
386
|
+
UDFContext *context,
|
387
|
+
UDFValue *returnValue)
|
388
|
+
{
|
389
|
+
InstanceSlot *sp;
|
390
|
+
Instance *ins;
|
391
|
+
long long start, end;
|
392
|
+
size_t rs, re, srcLen, dstLen;
|
393
|
+
size_t i, j, k;
|
394
|
+
UDFValue newval, newseg, oldseg;
|
395
|
+
|
396
|
+
if (CheckCurrentMessage(theEnv,"direct-slot-replace$",true) == false)
|
397
|
+
{
|
398
|
+
returnValue->lexemeValue = FalseSymbol(theEnv);
|
399
|
+
return;
|
400
|
+
}
|
401
|
+
|
402
|
+
ins = GetActiveInstance(theEnv);
|
403
|
+
sp = CheckMultifieldSlotModify(theEnv,REPLACE,"direct-slot-replace$",ins,
|
404
|
+
GetFirstArgument(),&start,&end,&newval);
|
405
|
+
if (sp == NULL)
|
406
|
+
{
|
407
|
+
returnValue->lexemeValue = FalseSymbol(theEnv);
|
408
|
+
return;
|
409
|
+
}
|
410
|
+
|
411
|
+
AssignSlotToDataObject(&oldseg,sp);
|
412
|
+
|
413
|
+
/*===========================================*/
|
414
|
+
/* Verify the start and end index arguments. */
|
415
|
+
/*===========================================*/
|
416
|
+
|
417
|
+
if ((end < start) || (start < 1) || (end < 1) || // TBD Refactor
|
418
|
+
(((long long) ((size_t) start)) != start) ||
|
419
|
+
(((long long) ((size_t) end)) != end))
|
420
|
+
{
|
421
|
+
MVRangeError(theEnv,start,end,oldseg.range,"direct-slot-replace$");
|
422
|
+
returnValue->lexemeValue = FalseSymbol(theEnv);
|
423
|
+
return;
|
424
|
+
}
|
425
|
+
|
426
|
+
/*============================================*/
|
427
|
+
/* Convert the indices to unsigned zero-based */
|
428
|
+
/* values including the begin value. */
|
429
|
+
/*============================================*/
|
430
|
+
|
431
|
+
rs = (size_t) start;
|
432
|
+
re = (size_t) end;
|
433
|
+
srcLen = oldseg.range;
|
434
|
+
|
435
|
+
if ((rs > srcLen) || (re > srcLen))
|
436
|
+
{
|
437
|
+
MVRangeError(theEnv,start,end,oldseg.range,"direct-slot-replace$");
|
438
|
+
returnValue->lexemeValue = FalseSymbol(theEnv);
|
439
|
+
return;
|
440
|
+
}
|
441
|
+
|
442
|
+
rs--;
|
443
|
+
re--;
|
444
|
+
rs += oldseg.begin;
|
445
|
+
re += oldseg.begin;
|
446
|
+
|
447
|
+
dstLen = srcLen - (re - rs + 1); // TBD Refactor
|
448
|
+
newseg.begin = 0;
|
449
|
+
newseg.range = dstLen;
|
450
|
+
newseg.multifieldValue = CreateMultifield(theEnv,dstLen);
|
451
|
+
|
452
|
+
/*===================================*/
|
453
|
+
/* Delete the members from the slot. */
|
454
|
+
/*===================================*/
|
455
|
+
|
456
|
+
if (newval.header->type == MULTIFIELD_TYPE) // TBD Refactor
|
457
|
+
{ dstLen = srcLen - (re - rs + 1) + newval.range; }
|
458
|
+
else
|
459
|
+
{ dstLen = srcLen - (re - rs); }
|
460
|
+
|
461
|
+
newseg.begin = 0;
|
462
|
+
newseg.range = dstLen;
|
463
|
+
newseg.multifieldValue = CreateMultifield(theEnv,dstLen);
|
464
|
+
|
465
|
+
for (i = oldseg.begin, j = 0; i < (oldseg.begin + oldseg.range); i++)
|
466
|
+
{
|
467
|
+
if (i == rs)
|
468
|
+
{
|
469
|
+
if (newval.header->type == MULTIFIELD_TYPE)
|
470
|
+
{
|
471
|
+
for (k = newval.begin; k < (newval.begin + newval.range); k++)
|
472
|
+
{ newseg.multifieldValue->contents[j++].value = newval.multifieldValue->contents[k].value; }
|
473
|
+
}
|
474
|
+
else
|
475
|
+
{ newseg.multifieldValue->contents[j++].value = newval.value; }
|
476
|
+
|
477
|
+
continue;
|
478
|
+
}
|
479
|
+
else if ((i > rs) && (i <= re))
|
480
|
+
{ continue; }
|
481
|
+
|
482
|
+
newseg.multifieldValue->contents[j++].value = oldseg.multifieldValue->contents[i].value;
|
483
|
+
}
|
484
|
+
|
485
|
+
if (PutSlotValue(theEnv,ins,sp,&newseg,&newval,"function direct-slot-replace$") == PSE_NO_ERROR)
|
486
|
+
{ returnValue->lexemeValue = TrueSymbol(theEnv); }
|
487
|
+
else
|
488
|
+
{ returnValue->lexemeValue = FalseSymbol(theEnv); }
|
489
|
+
}
|
490
|
+
|
491
|
+
/************************************************************************
|
492
|
+
NAME : DirectMVInsertCommand
|
493
|
+
DESCRIPTION : Directly inserts a slot's value
|
494
|
+
INPUTS : None
|
495
|
+
RETURNS : True if put OK, false otherwise
|
496
|
+
SIDE EFFECTS : Slot modified
|
497
|
+
NOTES : H/L Syntax: (direct-slot-insert$ <slot> <index> <value>)
|
498
|
+
************************************************************************/
|
499
|
+
void DirectMVInsertCommand(
|
500
|
+
Environment *theEnv,
|
501
|
+
UDFContext *context,
|
502
|
+
UDFValue *returnValue)
|
503
|
+
{
|
504
|
+
InstanceSlot *sp;
|
505
|
+
Instance *ins;
|
506
|
+
long long theIndex;
|
507
|
+
UDFValue newval,newseg,oldseg;
|
508
|
+
size_t uindex;
|
509
|
+
|
510
|
+
if (CheckCurrentMessage(theEnv,"direct-slot-insert$",true) == false)
|
511
|
+
{
|
512
|
+
returnValue->lexemeValue = FalseSymbol(theEnv);
|
513
|
+
return;
|
514
|
+
}
|
515
|
+
|
516
|
+
ins = GetActiveInstance(theEnv);
|
517
|
+
sp = CheckMultifieldSlotModify(theEnv,INSERT,"direct-slot-insert$",ins,
|
518
|
+
GetFirstArgument(),&theIndex,NULL,&newval);
|
519
|
+
if (sp == NULL)
|
520
|
+
{
|
521
|
+
returnValue->lexemeValue = FalseSymbol(theEnv);
|
522
|
+
return;
|
523
|
+
}
|
524
|
+
|
525
|
+
AssignSlotToDataObject(&oldseg,sp);
|
526
|
+
|
527
|
+
if ((((long long) ((size_t) theIndex)) != theIndex) ||
|
528
|
+
(theIndex < 1))
|
529
|
+
{
|
530
|
+
MVRangeError(theEnv,theIndex,theIndex,oldseg.range,"direct-slot-insert$");
|
531
|
+
return;
|
532
|
+
}
|
533
|
+
|
534
|
+
uindex = (size_t) theIndex;
|
535
|
+
|
536
|
+
if (! InsertMultiValueField(theEnv,&newseg,&oldseg,uindex,&newval,"direct-slot-insert$"))
|
537
|
+
{
|
538
|
+
returnValue->lexemeValue = FalseSymbol(theEnv);
|
539
|
+
return;
|
540
|
+
}
|
541
|
+
|
542
|
+
if (PutSlotValue(theEnv,ins,sp,&newseg,&newval,"function direct-slot-insert$") == PSE_NO_ERROR)
|
543
|
+
{ returnValue->lexemeValue = TrueSymbol(theEnv); }
|
544
|
+
else
|
545
|
+
{ returnValue->lexemeValue = FalseSymbol(theEnv); }
|
546
|
+
}
|
547
|
+
|
548
|
+
/*****************************************************************
|
549
|
+
NAME : DirectMVDeleteCommand
|
550
|
+
DESCRIPTION : Directly deletes a slot's value
|
551
|
+
INPUTS : None
|
552
|
+
RETURNS : True if put OK, false otherwise
|
553
|
+
SIDE EFFECTS : Slot modified
|
554
|
+
NOTES : H/L Syntax: (direct-slot-delete$ <slot>
|
555
|
+
<range-begin> <range-end>)
|
556
|
+
*****************************************************************/
|
557
|
+
void DirectMVDeleteCommand(
|
558
|
+
Environment *theEnv,
|
559
|
+
UDFContext *context,
|
560
|
+
UDFValue *returnValue)
|
561
|
+
{
|
562
|
+
InstanceSlot *sp;
|
563
|
+
Instance *ins;
|
564
|
+
size_t rs, re, dstLen, srcLen, i, j;
|
565
|
+
UDFValue newseg, oldseg;
|
566
|
+
long long start, end;
|
567
|
+
|
568
|
+
if (CheckCurrentMessage(theEnv,"direct-slot-delete$",true) == false)
|
569
|
+
{
|
570
|
+
returnValue->lexemeValue = FalseSymbol(theEnv);
|
571
|
+
return;
|
572
|
+
}
|
573
|
+
|
574
|
+
ins = GetActiveInstance(theEnv);
|
575
|
+
sp = CheckMultifieldSlotModify(theEnv,DELETE_OP,"direct-slot-delete$",ins,
|
576
|
+
GetFirstArgument(),&start,&end,NULL);
|
577
|
+
if (sp == NULL)
|
578
|
+
{
|
579
|
+
returnValue->lexemeValue = FalseSymbol(theEnv);
|
580
|
+
return;
|
581
|
+
}
|
582
|
+
|
583
|
+
AssignSlotToDataObject(&oldseg,sp);
|
584
|
+
|
585
|
+
/*===========================================*/
|
586
|
+
/* Verify the start and end index arguments. */
|
587
|
+
/*===========================================*/
|
588
|
+
|
589
|
+
if ((end < start) || (start < 1) || (end < 1) || // TBD Refactor
|
590
|
+
(((long long) ((size_t) start)) != start) ||
|
591
|
+
(((long long) ((size_t) end)) != end))
|
592
|
+
{
|
593
|
+
MVRangeError(theEnv,start,end,oldseg.range,"direct-slot-delete$");
|
594
|
+
returnValue->lexemeValue = FalseSymbol(theEnv);
|
595
|
+
return;
|
596
|
+
}
|
597
|
+
|
598
|
+
/*============================================*/
|
599
|
+
/* Convert the indices to unsigned zero-based */
|
600
|
+
/* values including the begin value. */
|
601
|
+
/*============================================*/
|
602
|
+
|
603
|
+
rs = (size_t) start;
|
604
|
+
re = (size_t) end;
|
605
|
+
srcLen = oldseg.range;
|
606
|
+
|
607
|
+
if ((rs > srcLen) || (re > srcLen))
|
608
|
+
{
|
609
|
+
MVRangeError(theEnv,start,end,oldseg.range,"direct-slot-delete$");
|
610
|
+
SetEvaluationError(theEnv,true);
|
611
|
+
SetMultifieldErrorValue(theEnv,returnValue);
|
612
|
+
return;
|
613
|
+
}
|
614
|
+
|
615
|
+
rs--;
|
616
|
+
re--;
|
617
|
+
rs += oldseg.begin;
|
618
|
+
re += oldseg.begin;
|
619
|
+
|
620
|
+
/*=================================================*/
|
621
|
+
/* Delete the section out of the multifield value. */
|
622
|
+
/*=================================================*/
|
623
|
+
|
624
|
+
dstLen = srcLen - (re - rs + 1); // TBD Refactor
|
625
|
+
newseg.begin = 0;
|
626
|
+
newseg.range = dstLen;
|
627
|
+
newseg.multifieldValue = CreateMultifield(theEnv,dstLen);
|
628
|
+
|
629
|
+
for (i = oldseg.begin, j = 0; i < (oldseg.begin + oldseg.range); i++)
|
630
|
+
{
|
631
|
+
if ((i >= rs) && (i <= re)) continue;
|
632
|
+
|
633
|
+
newseg.multifieldValue->contents[j++].value = oldseg.multifieldValue->contents[i].value;
|
634
|
+
}
|
635
|
+
|
636
|
+
if (PutSlotValue(theEnv,ins,sp,&newseg,&oldseg,"function direct-slot-delete$") == PSE_NO_ERROR)
|
637
|
+
{ returnValue->lexemeValue = TrueSymbol(theEnv); }
|
638
|
+
else
|
639
|
+
{ returnValue->lexemeValue = FalseSymbol(theEnv); }
|
640
|
+
}
|
641
|
+
|
642
|
+
/* =========================================
|
643
|
+
*****************************************
|
644
|
+
INTERNALLY VISIBLE FUNCTIONS
|
645
|
+
=========================================
|
646
|
+
***************************************** */
|
647
|
+
|
648
|
+
/**********************************************************************
|
649
|
+
NAME : CheckMultifieldSlotInstance
|
650
|
+
DESCRIPTION : Gets the instance for the functions slot-replace$,
|
651
|
+
insert and delete
|
652
|
+
INPUTS : The function name
|
653
|
+
RETURNS : The instance address, NULL on errors
|
654
|
+
SIDE EFFECTS : None
|
655
|
+
NOTES : None
|
656
|
+
**********************************************************************/
|
657
|
+
static Instance *CheckMultifieldSlotInstance(
|
658
|
+
UDFContext *context)
|
659
|
+
{
|
660
|
+
Instance *ins;
|
661
|
+
UDFValue temp;
|
662
|
+
Environment *theEnv = context->environment;
|
663
|
+
|
664
|
+
if (! UDFFirstArgument(context,INSTANCE_BITS | SYMBOL_BIT,&temp))
|
665
|
+
{ return NULL; }
|
666
|
+
|
667
|
+
if (temp.header->type == INSTANCE_ADDRESS_TYPE)
|
668
|
+
{
|
669
|
+
ins = temp.instanceValue;
|
670
|
+
if (ins->garbage == 1)
|
671
|
+
{
|
672
|
+
StaleInstanceAddress(theEnv,UDFContextFunctionName(context),0);
|
673
|
+
SetEvaluationError(theEnv,true);
|
674
|
+
return NULL;
|
675
|
+
}
|
676
|
+
}
|
677
|
+
else
|
678
|
+
{
|
679
|
+
ins = FindInstanceBySymbol(theEnv,temp.lexemeValue);
|
680
|
+
if (ins == NULL)
|
681
|
+
NoInstanceError(theEnv,temp.lexemeValue->contents,UDFContextFunctionName(context));
|
682
|
+
}
|
683
|
+
return ins;
|
684
|
+
}
|
685
|
+
|
686
|
+
/*********************************************************************
|
687
|
+
NAME : CheckMultifieldSlotModify
|
688
|
+
DESCRIPTION : For the functions slot-replace$, insert, & delete
|
689
|
+
as well as direct-slot-replace$, insert, & delete
|
690
|
+
this function gets the slot, index, and optional
|
691
|
+
field-value for these functions
|
692
|
+
INPUTS : 1) A code indicating the type of operation
|
693
|
+
INSERT (0) : Requires one index
|
694
|
+
REPLACE (1) : Requires two indices
|
695
|
+
DELETE_OP (2) : Requires two indices
|
696
|
+
2) Function name-string
|
697
|
+
3) Instance address
|
698
|
+
4) Argument expression chain
|
699
|
+
5) Caller's buffer for index (or beginning of range)
|
700
|
+
6) Caller's buffer for end of range
|
701
|
+
(can be NULL for INSERT)
|
702
|
+
7) Caller's new-field value buffer
|
703
|
+
(can be NULL for DELETE_OP)
|
704
|
+
RETURNS : The address of the instance-slot,
|
705
|
+
NULL on errors
|
706
|
+
SIDE EFFECTS : Caller's index buffer set
|
707
|
+
Caller's new-field value buffer set (if not NULL)
|
708
|
+
Will allocate an ephemeral segment to store more
|
709
|
+
than 1 new field value
|
710
|
+
EvaluationError set on errors
|
711
|
+
NOTES : Assume the argument chain is at least 2
|
712
|
+
expressions deep - slot, index, and optional values
|
713
|
+
*********************************************************************/
|
714
|
+
static InstanceSlot *CheckMultifieldSlotModify(
|
715
|
+
Environment *theEnv,
|
716
|
+
int code,
|
717
|
+
const char *func,
|
718
|
+
Instance *ins,
|
719
|
+
Expression *args,
|
720
|
+
long long *rb,
|
721
|
+
long long *re,
|
722
|
+
UDFValue *newval)
|
723
|
+
{
|
724
|
+
UDFValue temp;
|
725
|
+
InstanceSlot *sp;
|
726
|
+
unsigned int start;
|
727
|
+
|
728
|
+
start = (args == GetFirstArgument()) ? 1 : 2;
|
729
|
+
EvaluationData(theEnv)->EvaluationError = false;
|
730
|
+
EvaluateExpression(theEnv,args,&temp);
|
731
|
+
if (temp.header->type != SYMBOL_TYPE)
|
732
|
+
{
|
733
|
+
ExpectedTypeError1(theEnv,func,start,"symbol");
|
734
|
+
SetEvaluationError(theEnv,true);
|
735
|
+
return NULL;
|
736
|
+
}
|
737
|
+
sp = FindInstanceSlot(theEnv,ins,temp.lexemeValue);
|
738
|
+
if (sp == NULL)
|
739
|
+
{
|
740
|
+
SlotExistError(theEnv,temp.lexemeValue->contents,func);
|
741
|
+
return NULL;
|
742
|
+
}
|
743
|
+
if (sp->desc->multiple == 0)
|
744
|
+
{
|
745
|
+
PrintErrorID(theEnv,"INSMULT",1,false);
|
746
|
+
WriteString(theEnv,STDERR,"Function ");
|
747
|
+
WriteString(theEnv,STDERR,func);
|
748
|
+
WriteString(theEnv,STDERR," cannot be used on single-field slot '");
|
749
|
+
WriteString(theEnv,STDERR,sp->desc->slotName->name->contents);
|
750
|
+
WriteString(theEnv,STDERR,"' in instance [");
|
751
|
+
WriteString(theEnv,STDERR,ins->name->contents);
|
752
|
+
WriteString(theEnv,STDERR,"].\n");
|
753
|
+
SetEvaluationError(theEnv,true);
|
754
|
+
return NULL;
|
755
|
+
}
|
756
|
+
EvaluateExpression(theEnv,args->nextArg,&temp);
|
757
|
+
if (temp.header->type != INTEGER_TYPE)
|
758
|
+
{
|
759
|
+
ExpectedTypeError1(theEnv,func,start+1,"integer");
|
760
|
+
SetEvaluationError(theEnv,true);
|
761
|
+
return NULL;
|
762
|
+
}
|
763
|
+
args = args->nextArg->nextArg;
|
764
|
+
*rb = temp.integerValue->contents;
|
765
|
+
if ((code == REPLACE) || (code == DELETE_OP))
|
766
|
+
{
|
767
|
+
EvaluateExpression(theEnv,args,&temp);
|
768
|
+
if (temp.header->type != INTEGER_TYPE)
|
769
|
+
{
|
770
|
+
ExpectedTypeError1(theEnv,func,start+2,"integer");
|
771
|
+
SetEvaluationError(theEnv,true);
|
772
|
+
return NULL;
|
773
|
+
}
|
774
|
+
*re = temp.integerValue->contents;
|
775
|
+
args = args->nextArg;
|
776
|
+
}
|
777
|
+
if ((code == INSERT) || (code == REPLACE))
|
778
|
+
{
|
779
|
+
if (EvaluateAndStoreInDataObject(theEnv,1,args,newval,true) == false)
|
780
|
+
return NULL;
|
781
|
+
}
|
782
|
+
return(sp);
|
783
|
+
}
|
784
|
+
|
785
|
+
/***************************************************
|
786
|
+
NAME : AssignSlotToDataObject
|
787
|
+
DESCRIPTION : Assigns the value of a multifield
|
788
|
+
slot to a data object
|
789
|
+
INPUTS : 1) The data object buffer
|
790
|
+
2) The instance slot
|
791
|
+
RETURNS : Nothing useful
|
792
|
+
SIDE EFFECTS : Data object fields set
|
793
|
+
NOTES : Assumes slot is a multislot
|
794
|
+
***************************************************/
|
795
|
+
static void AssignSlotToDataObject(
|
796
|
+
UDFValue *theDataObject,
|
797
|
+
InstanceSlot *theSlot)
|
798
|
+
{
|
799
|
+
theDataObject->value = theSlot->value;
|
800
|
+
theDataObject->begin = 0;
|
801
|
+
theDataObject->range = theSlot->multifieldValue->length;
|
802
|
+
}
|
803
|
+
|
804
|
+
#endif
|