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.
Files changed (346) hide show
  1. checksums.yaml +7 -0
  2. data/ext/clipsruby/agenda.c +1373 -0
  3. data/ext/clipsruby/agenda.h +169 -0
  4. data/ext/clipsruby/analysis.c +1142 -0
  5. data/ext/clipsruby/analysis.h +61 -0
  6. data/ext/clipsruby/argacces.c +526 -0
  7. data/ext/clipsruby/argacces.h +77 -0
  8. data/ext/clipsruby/bload.c +884 -0
  9. data/ext/clipsruby/bload.h +94 -0
  10. data/ext/clipsruby/bmathfun.c +557 -0
  11. data/ext/clipsruby/bmathfun.h +66 -0
  12. data/ext/clipsruby/bsave.c +634 -0
  13. data/ext/clipsruby/bsave.h +130 -0
  14. data/ext/clipsruby/classcom.c +976 -0
  15. data/ext/clipsruby/classcom.h +115 -0
  16. data/ext/clipsruby/classexm.c +1376 -0
  17. data/ext/clipsruby/classexm.h +97 -0
  18. data/ext/clipsruby/classfun.c +1392 -0
  19. data/ext/clipsruby/classfun.h +164 -0
  20. data/ext/clipsruby/classinf.c +1245 -0
  21. data/ext/clipsruby/classinf.h +94 -0
  22. data/ext/clipsruby/classini.c +843 -0
  23. data/ext/clipsruby/classini.h +75 -0
  24. data/ext/clipsruby/classpsr.c +957 -0
  25. data/ext/clipsruby/classpsr.h +73 -0
  26. data/ext/clipsruby/clips.h +133 -0
  27. data/ext/clipsruby/clipsruby.c +619 -0
  28. data/ext/clipsruby/clsltpsr.c +931 -0
  29. data/ext/clipsruby/clsltpsr.h +72 -0
  30. data/ext/clipsruby/commline.c +1217 -0
  31. data/ext/clipsruby/commline.h +131 -0
  32. data/ext/clipsruby/conscomp.c +1593 -0
  33. data/ext/clipsruby/conscomp.h +150 -0
  34. data/ext/clipsruby/constant.h +264 -0
  35. data/ext/clipsruby/constrct.c +1090 -0
  36. data/ext/clipsruby/constrct.h +216 -0
  37. data/ext/clipsruby/constrnt.c +554 -0
  38. data/ext/clipsruby/constrnt.h +132 -0
  39. data/ext/clipsruby/crstrtgy.c +1088 -0
  40. data/ext/clipsruby/crstrtgy.h +85 -0
  41. data/ext/clipsruby/cstrcbin.c +185 -0
  42. data/ext/clipsruby/cstrcbin.h +61 -0
  43. data/ext/clipsruby/cstrccmp.h +43 -0
  44. data/ext/clipsruby/cstrccom.c +1791 -0
  45. data/ext/clipsruby/cstrccom.h +115 -0
  46. data/ext/clipsruby/cstrcpsr.c +835 -0
  47. data/ext/clipsruby/cstrcpsr.h +97 -0
  48. data/ext/clipsruby/cstrnbin.c +282 -0
  49. data/ext/clipsruby/cstrnbin.h +55 -0
  50. data/ext/clipsruby/cstrnchk.c +826 -0
  51. data/ext/clipsruby/cstrnchk.h +91 -0
  52. data/ext/clipsruby/cstrncmp.c +238 -0
  53. data/ext/clipsruby/cstrncmp.h +57 -0
  54. data/ext/clipsruby/cstrnops.c +1176 -0
  55. data/ext/clipsruby/cstrnops.h +47 -0
  56. data/ext/clipsruby/cstrnpsr.c +1394 -0
  57. data/ext/clipsruby/cstrnpsr.h +88 -0
  58. data/ext/clipsruby/cstrnutl.c +564 -0
  59. data/ext/clipsruby/cstrnutl.h +54 -0
  60. data/ext/clipsruby/default.c +454 -0
  61. data/ext/clipsruby/default.h +57 -0
  62. data/ext/clipsruby/defins.c +971 -0
  63. data/ext/clipsruby/defins.h +127 -0
  64. data/ext/clipsruby/developr.c +677 -0
  65. data/ext/clipsruby/developr.h +69 -0
  66. data/ext/clipsruby/dffctbin.c +477 -0
  67. data/ext/clipsruby/dffctbin.h +76 -0
  68. data/ext/clipsruby/dffctbsc.c +308 -0
  69. data/ext/clipsruby/dffctbsc.h +72 -0
  70. data/ext/clipsruby/dffctcmp.c +297 -0
  71. data/ext/clipsruby/dffctcmp.h +44 -0
  72. data/ext/clipsruby/dffctdef.c +364 -0
  73. data/ext/clipsruby/dffctdef.h +104 -0
  74. data/ext/clipsruby/dffctpsr.c +179 -0
  75. data/ext/clipsruby/dffctpsr.h +49 -0
  76. data/ext/clipsruby/dffnxbin.c +520 -0
  77. data/ext/clipsruby/dffnxbin.h +67 -0
  78. data/ext/clipsruby/dffnxcmp.c +378 -0
  79. data/ext/clipsruby/dffnxcmp.h +54 -0
  80. data/ext/clipsruby/dffnxexe.c +241 -0
  81. data/ext/clipsruby/dffnxexe.h +58 -0
  82. data/ext/clipsruby/dffnxfun.c +1192 -0
  83. data/ext/clipsruby/dffnxfun.h +155 -0
  84. data/ext/clipsruby/dffnxpsr.c +514 -0
  85. data/ext/clipsruby/dffnxpsr.h +57 -0
  86. data/ext/clipsruby/dfinsbin.c +509 -0
  87. data/ext/clipsruby/dfinsbin.h +66 -0
  88. data/ext/clipsruby/dfinscmp.c +345 -0
  89. data/ext/clipsruby/dfinscmp.h +48 -0
  90. data/ext/clipsruby/drive.c +1191 -0
  91. data/ext/clipsruby/drive.h +65 -0
  92. data/ext/clipsruby/emathfun.c +1213 -0
  93. data/ext/clipsruby/emathfun.h +99 -0
  94. data/ext/clipsruby/engine.c +1568 -0
  95. data/ext/clipsruby/engine.h +203 -0
  96. data/ext/clipsruby/entities.h +276 -0
  97. data/ext/clipsruby/envrnbld.c +514 -0
  98. data/ext/clipsruby/envrnbld.h +40 -0
  99. data/ext/clipsruby/envrnmnt.c +257 -0
  100. data/ext/clipsruby/envrnmnt.h +112 -0
  101. data/ext/clipsruby/evaluatn.c +1736 -0
  102. data/ext/clipsruby/evaluatn.h +211 -0
  103. data/ext/clipsruby/expressn.c +494 -0
  104. data/ext/clipsruby/expressn.h +154 -0
  105. data/ext/clipsruby/exprnbin.c +538 -0
  106. data/ext/clipsruby/exprnbin.h +60 -0
  107. data/ext/clipsruby/exprnops.c +564 -0
  108. data/ext/clipsruby/exprnops.h +67 -0
  109. data/ext/clipsruby/exprnpsr.c +1112 -0
  110. data/ext/clipsruby/exprnpsr.h +98 -0
  111. data/ext/clipsruby/extconf.rb +2 -0
  112. data/ext/clipsruby/extnfunc.c +1015 -0
  113. data/ext/clipsruby/extnfunc.h +157 -0
  114. data/ext/clipsruby/factbin.c +447 -0
  115. data/ext/clipsruby/factbin.h +56 -0
  116. data/ext/clipsruby/factbld.c +1035 -0
  117. data/ext/clipsruby/factbld.h +63 -0
  118. data/ext/clipsruby/factcmp.c +386 -0
  119. data/ext/clipsruby/factcmp.h +46 -0
  120. data/ext/clipsruby/factcom.c +759 -0
  121. data/ext/clipsruby/factcom.h +80 -0
  122. data/ext/clipsruby/factfile.c +1761 -0
  123. data/ext/clipsruby/factfile.h +54 -0
  124. data/ext/clipsruby/factfun.c +682 -0
  125. data/ext/clipsruby/factfun.h +77 -0
  126. data/ext/clipsruby/factgen.c +1305 -0
  127. data/ext/clipsruby/factgen.h +229 -0
  128. data/ext/clipsruby/facthsh.c +438 -0
  129. data/ext/clipsruby/facthsh.h +81 -0
  130. data/ext/clipsruby/factlhs.c +250 -0
  131. data/ext/clipsruby/factlhs.h +54 -0
  132. data/ext/clipsruby/factmch.c +905 -0
  133. data/ext/clipsruby/factmch.h +68 -0
  134. data/ext/clipsruby/factmngr.c +3373 -0
  135. data/ext/clipsruby/factmngr.h +325 -0
  136. data/ext/clipsruby/factprt.c +498 -0
  137. data/ext/clipsruby/factprt.h +60 -0
  138. data/ext/clipsruby/factqpsr.c +796 -0
  139. data/ext/clipsruby/factqpsr.h +61 -0
  140. data/ext/clipsruby/factqury.c +1267 -0
  141. data/ext/clipsruby/factqury.h +112 -0
  142. data/ext/clipsruby/factrete.c +978 -0
  143. data/ext/clipsruby/factrete.h +70 -0
  144. data/ext/clipsruby/factrhs.c +667 -0
  145. data/ext/clipsruby/factrhs.h +55 -0
  146. data/ext/clipsruby/filecom.c +353 -0
  147. data/ext/clipsruby/filecom.h +137 -0
  148. data/ext/clipsruby/filertr.c +481 -0
  149. data/ext/clipsruby/filertr.h +94 -0
  150. data/ext/clipsruby/fileutil.c +1020 -0
  151. data/ext/clipsruby/fileutil.h +50 -0
  152. data/ext/clipsruby/generate.c +1079 -0
  153. data/ext/clipsruby/generate.h +57 -0
  154. data/ext/clipsruby/genrcbin.c +902 -0
  155. data/ext/clipsruby/genrcbin.h +69 -0
  156. data/ext/clipsruby/genrccmp.c +640 -0
  157. data/ext/clipsruby/genrccmp.h +59 -0
  158. data/ext/clipsruby/genrccom.c +2017 -0
  159. data/ext/clipsruby/genrccom.h +119 -0
  160. data/ext/clipsruby/genrcexe.c +737 -0
  161. data/ext/clipsruby/genrcexe.h +73 -0
  162. data/ext/clipsruby/genrcfun.c +890 -0
  163. data/ext/clipsruby/genrcfun.h +185 -0
  164. data/ext/clipsruby/genrcpsr.c +1618 -0
  165. data/ext/clipsruby/genrcpsr.h +80 -0
  166. data/ext/clipsruby/globlbin.c +458 -0
  167. data/ext/clipsruby/globlbin.h +71 -0
  168. data/ext/clipsruby/globlbsc.c +361 -0
  169. data/ext/clipsruby/globlbsc.h +83 -0
  170. data/ext/clipsruby/globlcmp.c +330 -0
  171. data/ext/clipsruby/globlcmp.h +52 -0
  172. data/ext/clipsruby/globlcom.c +289 -0
  173. data/ext/clipsruby/globlcom.h +63 -0
  174. data/ext/clipsruby/globldef.c +1087 -0
  175. data/ext/clipsruby/globldef.h +151 -0
  176. data/ext/clipsruby/globlpsr.c +530 -0
  177. data/ext/clipsruby/globlpsr.h +59 -0
  178. data/ext/clipsruby/immthpsr.c +431 -0
  179. data/ext/clipsruby/immthpsr.h +55 -0
  180. data/ext/clipsruby/incrrset.c +530 -0
  181. data/ext/clipsruby/incrrset.h +73 -0
  182. data/ext/clipsruby/inherpsr.c +850 -0
  183. data/ext/clipsruby/inherpsr.h +52 -0
  184. data/ext/clipsruby/inscom.c +2076 -0
  185. data/ext/clipsruby/inscom.h +182 -0
  186. data/ext/clipsruby/insfile.c +1764 -0
  187. data/ext/clipsruby/insfile.h +96 -0
  188. data/ext/clipsruby/insfun.c +1451 -0
  189. data/ext/clipsruby/insfun.h +134 -0
  190. data/ext/clipsruby/insmngr.c +2550 -0
  191. data/ext/clipsruby/insmngr.h +125 -0
  192. data/ext/clipsruby/insmoddp.c +1041 -0
  193. data/ext/clipsruby/insmoddp.h +91 -0
  194. data/ext/clipsruby/insmult.c +804 -0
  195. data/ext/clipsruby/insmult.h +62 -0
  196. data/ext/clipsruby/inspsr.c +602 -0
  197. data/ext/clipsruby/inspsr.h +60 -0
  198. data/ext/clipsruby/insquery.c +1278 -0
  199. data/ext/clipsruby/insquery.h +115 -0
  200. data/ext/clipsruby/insqypsr.c +729 -0
  201. data/ext/clipsruby/insqypsr.h +63 -0
  202. data/ext/clipsruby/iofun.c +2045 -0
  203. data/ext/clipsruby/iofun.h +116 -0
  204. data/ext/clipsruby/lgcldpnd.c +644 -0
  205. data/ext/clipsruby/lgcldpnd.h +75 -0
  206. data/ext/clipsruby/main.c +112 -0
  207. data/ext/clipsruby/match.h +142 -0
  208. data/ext/clipsruby/memalloc.c +481 -0
  209. data/ext/clipsruby/memalloc.h +197 -0
  210. data/ext/clipsruby/miscfun.c +1801 -0
  211. data/ext/clipsruby/miscfun.h +132 -0
  212. data/ext/clipsruby/modulbin.c +607 -0
  213. data/ext/clipsruby/modulbin.h +84 -0
  214. data/ext/clipsruby/modulbsc.c +347 -0
  215. data/ext/clipsruby/modulbsc.h +67 -0
  216. data/ext/clipsruby/modulcmp.c +499 -0
  217. data/ext/clipsruby/modulcmp.h +54 -0
  218. data/ext/clipsruby/moduldef.c +817 -0
  219. data/ext/clipsruby/moduldef.h +271 -0
  220. data/ext/clipsruby/modulpsr.c +1150 -0
  221. data/ext/clipsruby/modulpsr.h +69 -0
  222. data/ext/clipsruby/modulutl.c +1036 -0
  223. data/ext/clipsruby/modulutl.h +84 -0
  224. data/ext/clipsruby/msgcom.c +1221 -0
  225. data/ext/clipsruby/msgcom.h +125 -0
  226. data/ext/clipsruby/msgfun.c +1076 -0
  227. data/ext/clipsruby/msgfun.h +118 -0
  228. data/ext/clipsruby/msgpass.c +1441 -0
  229. data/ext/clipsruby/msgpass.h +103 -0
  230. data/ext/clipsruby/msgpsr.c +698 -0
  231. data/ext/clipsruby/msgpsr.h +73 -0
  232. data/ext/clipsruby/multifld.c +1404 -0
  233. data/ext/clipsruby/multifld.h +130 -0
  234. data/ext/clipsruby/multifun.c +2182 -0
  235. data/ext/clipsruby/multifun.h +102 -0
  236. data/ext/clipsruby/network.h +142 -0
  237. data/ext/clipsruby/objbin.c +1522 -0
  238. data/ext/clipsruby/objbin.h +79 -0
  239. data/ext/clipsruby/objcmp.c +1507 -0
  240. data/ext/clipsruby/objcmp.h +71 -0
  241. data/ext/clipsruby/object.h +260 -0
  242. data/ext/clipsruby/objrtbin.c +701 -0
  243. data/ext/clipsruby/objrtbin.h +79 -0
  244. data/ext/clipsruby/objrtbld.c +2393 -0
  245. data/ext/clipsruby/objrtbld.h +66 -0
  246. data/ext/clipsruby/objrtcmp.c +734 -0
  247. data/ext/clipsruby/objrtcmp.h +66 -0
  248. data/ext/clipsruby/objrtfnx.c +1330 -0
  249. data/ext/clipsruby/objrtfnx.h +222 -0
  250. data/ext/clipsruby/objrtgen.c +736 -0
  251. data/ext/clipsruby/objrtgen.h +63 -0
  252. data/ext/clipsruby/objrtmch.c +1524 -0
  253. data/ext/clipsruby/objrtmch.h +160 -0
  254. data/ext/clipsruby/parsefun.c +415 -0
  255. data/ext/clipsruby/parsefun.h +67 -0
  256. data/ext/clipsruby/pattern.c +1265 -0
  257. data/ext/clipsruby/pattern.h +163 -0
  258. data/ext/clipsruby/pprint.c +328 -0
  259. data/ext/clipsruby/pprint.h +79 -0
  260. data/ext/clipsruby/prccode.c +1478 -0
  261. data/ext/clipsruby/prccode.h +145 -0
  262. data/ext/clipsruby/prcdrfun.c +640 -0
  263. data/ext/clipsruby/prcdrfun.h +95 -0
  264. data/ext/clipsruby/prcdrpsr.c +1068 -0
  265. data/ext/clipsruby/prcdrpsr.h +79 -0
  266. data/ext/clipsruby/prdctfun.c +869 -0
  267. data/ext/clipsruby/prdctfun.h +77 -0
  268. data/ext/clipsruby/prntutil.c +878 -0
  269. data/ext/clipsruby/prntutil.h +125 -0
  270. data/ext/clipsruby/proflfun.c +827 -0
  271. data/ext/clipsruby/proflfun.h +118 -0
  272. data/ext/clipsruby/reorder.c +2082 -0
  273. data/ext/clipsruby/reorder.h +172 -0
  274. data/ext/clipsruby/reteutil.c +1732 -0
  275. data/ext/clipsruby/reteutil.h +111 -0
  276. data/ext/clipsruby/retract.c +710 -0
  277. data/ext/clipsruby/retract.h +74 -0
  278. data/ext/clipsruby/router.c +737 -0
  279. data/ext/clipsruby/router.h +147 -0
  280. data/ext/clipsruby/rulebin.c +1136 -0
  281. data/ext/clipsruby/rulebin.h +153 -0
  282. data/ext/clipsruby/rulebld.c +1328 -0
  283. data/ext/clipsruby/rulebld.h +62 -0
  284. data/ext/clipsruby/rulebsc.c +517 -0
  285. data/ext/clipsruby/rulebsc.h +91 -0
  286. data/ext/clipsruby/rulecmp.c +733 -0
  287. data/ext/clipsruby/rulecmp.h +63 -0
  288. data/ext/clipsruby/rulecom.c +1583 -0
  289. data/ext/clipsruby/rulecom.h +116 -0
  290. data/ext/clipsruby/rulecstr.c +892 -0
  291. data/ext/clipsruby/rulecstr.h +53 -0
  292. data/ext/clipsruby/ruledef.c +559 -0
  293. data/ext/clipsruby/ruledef.h +179 -0
  294. data/ext/clipsruby/ruledlt.c +599 -0
  295. data/ext/clipsruby/ruledlt.h +58 -0
  296. data/ext/clipsruby/rulelhs.c +1216 -0
  297. data/ext/clipsruby/rulelhs.h +52 -0
  298. data/ext/clipsruby/rulepsr.c +1073 -0
  299. data/ext/clipsruby/rulepsr.h +61 -0
  300. data/ext/clipsruby/scanner.c +856 -0
  301. data/ext/clipsruby/scanner.h +112 -0
  302. data/ext/clipsruby/setup.h +488 -0
  303. data/ext/clipsruby/sortfun.c +433 -0
  304. data/ext/clipsruby/sortfun.h +55 -0
  305. data/ext/clipsruby/strngfun.c +1173 -0
  306. data/ext/clipsruby/strngfun.h +96 -0
  307. data/ext/clipsruby/strngrtr.c +523 -0
  308. data/ext/clipsruby/strngrtr.h +97 -0
  309. data/ext/clipsruby/symblbin.c +648 -0
  310. data/ext/clipsruby/symblbin.h +64 -0
  311. data/ext/clipsruby/symblcmp.c +893 -0
  312. data/ext/clipsruby/symblcmp.h +61 -0
  313. data/ext/clipsruby/symbol.c +1961 -0
  314. data/ext/clipsruby/symbol.h +243 -0
  315. data/ext/clipsruby/sysdep.c +894 -0
  316. data/ext/clipsruby/sysdep.h +164 -0
  317. data/ext/clipsruby/textpro.c +1388 -0
  318. data/ext/clipsruby/textpro.h +77 -0
  319. data/ext/clipsruby/tmpltbin.c +609 -0
  320. data/ext/clipsruby/tmpltbin.h +108 -0
  321. data/ext/clipsruby/tmpltbsc.c +327 -0
  322. data/ext/clipsruby/tmpltbsc.h +87 -0
  323. data/ext/clipsruby/tmpltcmp.c +450 -0
  324. data/ext/clipsruby/tmpltcmp.h +57 -0
  325. data/ext/clipsruby/tmpltdef.c +584 -0
  326. data/ext/clipsruby/tmpltdef.h +155 -0
  327. data/ext/clipsruby/tmpltfun.c +2477 -0
  328. data/ext/clipsruby/tmpltfun.h +122 -0
  329. data/ext/clipsruby/tmpltlhs.c +379 -0
  330. data/ext/clipsruby/tmpltlhs.h +50 -0
  331. data/ext/clipsruby/tmpltpsr.c +819 -0
  332. data/ext/clipsruby/tmpltpsr.h +59 -0
  333. data/ext/clipsruby/tmpltrhs.c +595 -0
  334. data/ext/clipsruby/tmpltrhs.h +55 -0
  335. data/ext/clipsruby/tmpltutl.c +637 -0
  336. data/ext/clipsruby/tmpltutl.h +82 -0
  337. data/ext/clipsruby/userdata.c +156 -0
  338. data/ext/clipsruby/userdata.h +72 -0
  339. data/ext/clipsruby/userfunctions.c +70 -0
  340. data/ext/clipsruby/usrsetup.h +7 -0
  341. data/ext/clipsruby/utility.c +1594 -0
  342. data/ext/clipsruby/utility.h +250 -0
  343. data/ext/clipsruby/watch.c +865 -0
  344. data/ext/clipsruby/watch.h +124 -0
  345. data/lib/clipsruby.rb +1 -0
  346. metadata +388 -0
@@ -0,0 +1,931 @@
1
+ /*******************************************************/
2
+ /* "C" Language Integrated Production System */
3
+ /* */
4
+ /* CLIPS Version 6.41 05/26/21 */
5
+ /* */
6
+ /* CLASS PARSER MODULE */
7
+ /*******************************************************/
8
+
9
+ /**************************************************************/
10
+ /* Purpose: Parsing Routines for Defclass Construct */
11
+ /* */
12
+ /* Principal Programmer(s): */
13
+ /* Brian L. Dantes */
14
+ /* */
15
+ /* Contributing Programmer(s): */
16
+ /* */
17
+ /* Revision History: */
18
+ /* */
19
+ /* 6.24: Converted INSTANCE_PATTERN_MATCHING to */
20
+ /* DEFRULE_CONSTRUCT. */
21
+ /* */
22
+ /* Renamed BOOLEAN macro type to intBool. */
23
+ /* */
24
+ /* 6.30: Changed integer type/precision. */
25
+ /* */
26
+ /* Support for long long integers. */
27
+ /* */
28
+ /* Added const qualifiers to remove C++ */
29
+ /* deprecation warnings. */
30
+ /* */
31
+ /* 6.31: Changed allocation of multifield slot default */
32
+ /* from ephemeral to explicit deallocation. */
33
+ /* */
34
+ /* 6.40: Pragma once and other inclusion changes. */
35
+ /* */
36
+ /* Added support for booleans with <stdbool.h>. */
37
+ /* */
38
+ /* Removed use of void pointers for specific */
39
+ /* data structures. */
40
+ /* */
41
+ /* Static constraint checking is always enabled. */
42
+ /* */
43
+ /* UDF redesign. */
44
+ /* */
45
+ /* 6.41: Fixed MEM_TABLE_SIZE=0 duplicate slot crash. */
46
+ /* */
47
+ /**************************************************************/
48
+
49
+ /* =========================================
50
+ *****************************************
51
+ EXTERNAL DEFINITIONS
52
+ =========================================
53
+ ***************************************** */
54
+ #include "setup.h"
55
+
56
+ #if OBJECT_SYSTEM && (! BLOAD_ONLY) && (! RUN_TIME)
57
+
58
+ #include <string.h>
59
+
60
+ #include "classcom.h"
61
+ #include "classfun.h"
62
+ #include "cstrnchk.h"
63
+ #include "cstrnpsr.h"
64
+ #include "cstrnutl.h"
65
+ #include "default.h"
66
+ #include "envrnmnt.h"
67
+ #include "insfun.h"
68
+ #include "memalloc.h"
69
+ #include "pprint.h"
70
+ #include "prntutil.h"
71
+ #include "router.h"
72
+ #include "scanner.h"
73
+
74
+ #include "clsltpsr.h"
75
+
76
+ /* =========================================
77
+ *****************************************
78
+ CONSTANTS
79
+ =========================================
80
+ ***************************************** */
81
+ #define DEFAULT_FACET "default"
82
+ #define DYNAMIC_FACET "default-dynamic"
83
+ #define VARIABLE_VAR "VARIABLE"
84
+
85
+ #define STORAGE_FACET "storage"
86
+ #define SLOT_SHARE_RLN "shared"
87
+ #define SLOT_LOCAL_RLN "local"
88
+
89
+ #define ACCESS_FACET "access"
90
+ #define SLOT_RDONLY_RLN "read-only"
91
+ #define SLOT_RDWRT_RLN "read-write"
92
+ #define SLOT_INIT_RLN "initialize-only"
93
+
94
+ #define PROPAGATION_FACET "propagation"
95
+ #define SLOT_NO_INH_RLN "no-inherit"
96
+ #define SLOT_INH_RLN "inherit"
97
+
98
+ #define SOURCE_FACET "source"
99
+ #define SLOT_COMPOSITE_RLN "composite"
100
+ #define SLOT_EXCLUSIVE_RLN "exclusive"
101
+
102
+ #define MATCH_FACET MATCH_RLN
103
+ #define SLOT_REACTIVE_RLN REACTIVE_RLN
104
+ #define SLOT_NONREACTIVE_RLN NONREACTIVE_RLN
105
+
106
+ #define VISIBILITY_FACET "visibility"
107
+ #define SLOT_PUBLIC_RLN "public"
108
+ #define SLOT_PRIVATE_RLN "private"
109
+
110
+ #define CREATE_ACCESSOR_FACET "create-accessor"
111
+ #define SLOT_READ_RLN "read"
112
+ #define SLOT_WRITE_RLN "write"
113
+ #define SLOT_NONE_RLN "NONE"
114
+
115
+ #define OVERRIDE_MSG_FACET "override-message"
116
+ #define SLOT_DEFAULT_RLN "DEFAULT"
117
+
118
+ #define STORAGE_BIT 0
119
+ #define FIELD_BIT 1
120
+ #define ACCESS_BIT 2
121
+ #define PROPAGATION_BIT 3
122
+ #define SOURCE_BIT 4
123
+ #define MATCH_BIT 5
124
+ #define DEFAULT_BIT 6
125
+ #define DEFAULT_DYNAMIC_BIT 7
126
+ #define VISIBILITY_BIT 8
127
+ #define CREATE_ACCESSOR_BIT 9
128
+ #define OVERRIDE_MSG_BIT 10
129
+
130
+ /***************************************/
131
+ /* LOCAL INTERNAL FUNCTION DEFINITIONS */
132
+ /***************************************/
133
+
134
+ static SlotDescriptor *NewSlot(Environment *,CLIPSLexeme *);
135
+ static TEMP_SLOT_LINK *InsertSlot(Environment *,const char *,TEMP_SLOT_LINK *,SlotDescriptor *);
136
+ static int ParseSimpleFacet(Environment *,const char *,SlotDescriptor *,char*,const char *,int,const char *,
137
+ const char *,const char *,const char *,CLIPSLexeme **);
138
+ static bool ParseDefaultFacet(Environment *,const char *,char *,SlotDescriptor *);
139
+ static void BuildCompositeFacets(Environment *,SlotDescriptor *,PACKED_CLASS_LINKS *,const char *,
140
+ CONSTRAINT_PARSE_RECORD *);
141
+ static bool CheckForFacetConflicts(Environment *,SlotDescriptor *,CONSTRAINT_PARSE_RECORD *);
142
+ static bool EvaluateSlotDefaultValue(Environment *,SlotDescriptor *,const char *);
143
+
144
+ /* =========================================
145
+ *****************************************
146
+ EXTERNALLY VISIBLE FUNCTIONS
147
+ =========================================
148
+ ***************************************** */
149
+
150
+ /************************************************************
151
+ NAME : ParseSlot
152
+ DESCRIPTION : Parses slot definitions for a
153
+ defclass statement
154
+ INPUTS : 1) The logical name of the input source
155
+ 2) The current slot list
156
+ 3) The class precedence list for the class
157
+ to which this slot is being attached
158
+ (used to find facets for composite slots)
159
+ 4) A flag indicating if this is a multifield
160
+ slot or not
161
+ 5) A flag indicating if the type of slot
162
+ (single or multi) was explicitly
163
+ specified or not
164
+ RETURNS : The address of the list of slots,
165
+ NULL if there was an error
166
+ SIDE EFFECTS : The slot list is allocated
167
+ NOTES : Assumes "(slot" has already been parsed.
168
+ ************************************************************/
169
+ TEMP_SLOT_LINK *ParseSlot(
170
+ Environment *theEnv,
171
+ const char *readSource,
172
+ const char *className,
173
+ TEMP_SLOT_LINK *slist,
174
+ PACKED_CLASS_LINKS *preclist,
175
+ bool multiSlot)
176
+ {
177
+ SlotDescriptor *slot;
178
+ CONSTRAINT_PARSE_RECORD parsedConstraint;
179
+ char specbits[2];
180
+ int rtnCode;
181
+ CLIPSLexeme *newOverrideMsg;
182
+
183
+ /* ===============================================================
184
+ Bits in specbits are when slot qualifiers are specified so that
185
+ duplicate or conflicting qualifiers can be detected.
186
+
187
+ Shared/local bit-0
188
+ Single/multiple bit-1
189
+ Read-only/Read-write/Initialize-Only bit-2
190
+ Inherit/No-inherit bit-3
191
+ Composite/Exclusive bit-4
192
+ Reactive/Nonreactive bit-5
193
+ Default bit-6
194
+ Default-dynamic bit-7
195
+ Visibility bit-8
196
+ Override-message bit-9
197
+ =============================================================== */
198
+ SavePPBuffer(theEnv," ");
199
+ specbits[0] = specbits[1] = '\0';
200
+ GetToken(theEnv,readSource,&DefclassData(theEnv)->ObjectParseToken);
201
+ if (DefclassData(theEnv)->ObjectParseToken.tknType != SYMBOL_TOKEN)
202
+ {
203
+ DeleteSlots(theEnv,slist);
204
+ SyntaxErrorMessage(theEnv,"defclass slot");
205
+ return NULL;
206
+ }
207
+ if ((DefclassData(theEnv)->ObjectParseToken.value == (void *) DefclassData(theEnv)->ISA_SYMBOL) ||
208
+ (DefclassData(theEnv)->ObjectParseToken.value == (void *) DefclassData(theEnv)->NAME_SYMBOL))
209
+ {
210
+ DeleteSlots(theEnv,slist);
211
+ SyntaxErrorMessage(theEnv,"defclass slot");
212
+ return NULL;
213
+ }
214
+ slot = NewSlot(theEnv,DefclassData(theEnv)->ObjectParseToken.lexemeValue);
215
+ slist = InsertSlot(theEnv,className,slist,slot);
216
+ if (slist == NULL)
217
+ return NULL;
218
+ if (multiSlot)
219
+ {
220
+ slot->multiple = true;
221
+ SetBitMap(specbits,FIELD_BIT);
222
+ }
223
+
224
+ GetToken(theEnv,readSource,&DefclassData(theEnv)->ObjectParseToken);
225
+ IncrementIndentDepth(theEnv,3);
226
+ InitializeConstraintParseRecord(&parsedConstraint);
227
+ while (DefclassData(theEnv)->ObjectParseToken.tknType == LEFT_PARENTHESIS_TOKEN)
228
+ {
229
+ PPBackup(theEnv);
230
+ PPCRAndIndent(theEnv);
231
+ SavePPBuffer(theEnv,"(");
232
+ GetToken(theEnv,readSource,&DefclassData(theEnv)->ObjectParseToken);
233
+ if (DefclassData(theEnv)->ObjectParseToken.tknType != SYMBOL_TOKEN)
234
+ {
235
+ SyntaxErrorMessage(theEnv,"defclass slot");
236
+ goto ParseSlotError;
237
+ }
238
+ else if (strcmp(DefclassData(theEnv)->ObjectParseToken.lexemeValue->contents,DEFAULT_FACET) == 0)
239
+ {
240
+ if (ParseDefaultFacet(theEnv,readSource,specbits,slot) == false)
241
+ goto ParseSlotError;
242
+ }
243
+ else if (strcmp(DefclassData(theEnv)->ObjectParseToken.lexemeValue->contents,DYNAMIC_FACET) == 0)
244
+ {
245
+ SetBitMap(specbits,DEFAULT_DYNAMIC_BIT);
246
+ if (ParseDefaultFacet(theEnv,readSource,specbits,slot) == false)
247
+ goto ParseSlotError;
248
+ }
249
+ else if (strcmp(DefclassData(theEnv)->ObjectParseToken.lexemeValue->contents,ACCESS_FACET) == 0)
250
+ {
251
+ rtnCode = ParseSimpleFacet(theEnv,readSource,slot,specbits,ACCESS_FACET,ACCESS_BIT,
252
+ SLOT_RDWRT_RLN,SLOT_RDONLY_RLN,SLOT_INIT_RLN,
253
+ NULL,NULL);
254
+ if (rtnCode == -1)
255
+ goto ParseSlotError;
256
+ else if (rtnCode == 1)
257
+ slot->noWrite = 1;
258
+ else if (rtnCode == 2)
259
+ slot->initializeOnly = 1;
260
+ }
261
+ else if (strcmp(DefclassData(theEnv)->ObjectParseToken.lexemeValue->contents,STORAGE_FACET) == 0)
262
+ {
263
+ rtnCode = ParseSimpleFacet(theEnv,readSource,slot,specbits,STORAGE_FACET,STORAGE_BIT,
264
+ SLOT_LOCAL_RLN,SLOT_SHARE_RLN,NULL,NULL,NULL);
265
+ if (rtnCode == -1)
266
+ goto ParseSlotError;
267
+ slot->shared = (rtnCode == 0) ? false : true;
268
+ }
269
+ else if (strcmp(DefclassData(theEnv)->ObjectParseToken.lexemeValue->contents,PROPAGATION_FACET) == 0)
270
+ {
271
+ rtnCode = ParseSimpleFacet(theEnv,readSource,slot,specbits,PROPAGATION_FACET,PROPAGATION_BIT,
272
+ SLOT_INH_RLN,SLOT_NO_INH_RLN,NULL,NULL,NULL);
273
+ if (rtnCode == -1)
274
+ goto ParseSlotError;
275
+ slot->noInherit = (rtnCode == 0) ? false : true;
276
+ }
277
+ else if (strcmp(DefclassData(theEnv)->ObjectParseToken.lexemeValue->contents,SOURCE_FACET) == 0)
278
+ {
279
+ rtnCode = ParseSimpleFacet(theEnv,readSource,slot,specbits,SOURCE_FACET,SOURCE_BIT,
280
+ SLOT_EXCLUSIVE_RLN,SLOT_COMPOSITE_RLN,NULL,NULL,NULL);
281
+ if (rtnCode == -1)
282
+ goto ParseSlotError;
283
+ slot->composite = (rtnCode == 0) ? false : true;
284
+ }
285
+ #if DEFRULE_CONSTRUCT
286
+ else if (strcmp(DefclassData(theEnv)->ObjectParseToken.lexemeValue->contents,MATCH_FACET) == 0)
287
+ {
288
+ rtnCode = ParseSimpleFacet(theEnv,readSource,slot,specbits,MATCH_FACET,MATCH_BIT,
289
+ SLOT_NONREACTIVE_RLN,SLOT_REACTIVE_RLN,NULL,NULL,NULL);
290
+ if (rtnCode == -1)
291
+ goto ParseSlotError;
292
+ slot->reactive = (rtnCode == 0) ? false : true;
293
+ }
294
+ #endif
295
+ else if (strcmp(DefclassData(theEnv)->ObjectParseToken.lexemeValue->contents,VISIBILITY_FACET) == 0)
296
+ {
297
+ rtnCode = ParseSimpleFacet(theEnv,readSource,slot,specbits,VISIBILITY_FACET,VISIBILITY_BIT,
298
+ SLOT_PRIVATE_RLN,SLOT_PUBLIC_RLN,NULL,NULL,NULL);
299
+ if (rtnCode == -1)
300
+ goto ParseSlotError;
301
+ slot->publicVisibility = (rtnCode == 0) ? false : true;
302
+ }
303
+ else if (strcmp(DefclassData(theEnv)->ObjectParseToken.lexemeValue->contents,CREATE_ACCESSOR_FACET) == 0)
304
+ {
305
+ rtnCode = ParseSimpleFacet(theEnv,readSource,slot,specbits,CREATE_ACCESSOR_FACET,
306
+ CREATE_ACCESSOR_BIT,
307
+ SLOT_READ_RLN,SLOT_WRITE_RLN,SLOT_RDWRT_RLN,
308
+ SLOT_NONE_RLN,NULL);
309
+ if (rtnCode == -1)
310
+ goto ParseSlotError;
311
+ if ((rtnCode == 0) || (rtnCode == 2))
312
+ slot->createReadAccessor = true;
313
+ if ((rtnCode == 1) || (rtnCode == 2))
314
+ slot->createWriteAccessor = true;
315
+ }
316
+ else if (strcmp(DefclassData(theEnv)->ObjectParseToken.lexemeValue->contents,OVERRIDE_MSG_FACET) == 0)
317
+ {
318
+ rtnCode = ParseSimpleFacet(theEnv,readSource,slot,specbits,OVERRIDE_MSG_FACET,OVERRIDE_MSG_BIT,
319
+ NULL,NULL,NULL,SLOT_DEFAULT_RLN,&newOverrideMsg);
320
+ if (rtnCode == -1)
321
+ goto ParseSlotError;
322
+ if (rtnCode == 4)
323
+ {
324
+ ReleaseLexeme(theEnv,slot->overrideMessage);
325
+ slot->overrideMessage = newOverrideMsg;
326
+ IncrementLexemeCount(slot->overrideMessage);
327
+ }
328
+ slot->overrideMessageSpecified = true;
329
+ }
330
+ else if (StandardConstraint(DefclassData(theEnv)->ObjectParseToken.lexemeValue->contents))
331
+ {
332
+ if (ParseStandardConstraint(theEnv,readSource,DefclassData(theEnv)->ObjectParseToken.lexemeValue->contents,
333
+ slot->constraint,&parsedConstraint,true) == false)
334
+ goto ParseSlotError;
335
+ }
336
+ else
337
+ {
338
+ SyntaxErrorMessage(theEnv,"defclass slot");
339
+ goto ParseSlotError;
340
+ }
341
+ GetToken(theEnv,readSource,&DefclassData(theEnv)->ObjectParseToken);
342
+ }
343
+ if (DefclassData(theEnv)->ObjectParseToken.tknType != RIGHT_PARENTHESIS_TOKEN)
344
+ {
345
+ SyntaxErrorMessage(theEnv,"defclass slot");
346
+ goto ParseSlotError;
347
+ }
348
+
349
+ if (DefclassData(theEnv)->ClassDefaultsModeValue == CONVENIENCE_MODE)
350
+ {
351
+ if (! TestBitMap(specbits,CREATE_ACCESSOR_BIT))
352
+ {
353
+ slot->createReadAccessor = true;
354
+
355
+ if (! slot->noWrite)
356
+ { slot->createWriteAccessor = true; }
357
+ }
358
+ }
359
+
360
+ if (slot->composite)
361
+ BuildCompositeFacets(theEnv,slot,preclist,specbits,&parsedConstraint);
362
+ if (CheckForFacetConflicts(theEnv,slot,&parsedConstraint) == false)
363
+ goto ParseSlotError;
364
+ if (CheckConstraintParseConflicts(theEnv,slot->constraint) == false)
365
+ goto ParseSlotError;
366
+ if (EvaluateSlotDefaultValue(theEnv,slot,specbits) == false)
367
+ goto ParseSlotError;
368
+ if ((slot->dynamicDefault == 0) && (slot->noWrite == 1) &&
369
+ (slot->initializeOnly == 0))
370
+ slot->shared = 1;
371
+ slot->constraint = AddConstraint(theEnv,slot->constraint);
372
+ DecrementIndentDepth(theEnv,3);
373
+ return(slist);
374
+
375
+ ParseSlotError:
376
+ DecrementIndentDepth(theEnv,3);
377
+ DeleteSlots(theEnv,slist);
378
+ return NULL;
379
+ }
380
+
381
+ /***************************************************
382
+ NAME : DeleteSlots
383
+ DESCRIPTION : Deallocates a list of slots and
384
+ their values
385
+ INPUTS : The address of the slot list
386
+ RETURNS : Nothing useful
387
+ SIDE EFFECTS : The slot list is destroyed
388
+ NOTES : None
389
+ ***************************************************/
390
+ void DeleteSlots(
391
+ Environment *theEnv,
392
+ TEMP_SLOT_LINK *slots)
393
+ {
394
+ TEMP_SLOT_LINK *stmp;
395
+
396
+ while (slots != NULL)
397
+ {
398
+ stmp = slots;
399
+ slots = slots->nxt;
400
+ DeleteSlotName(theEnv,stmp->desc->slotName);
401
+ ReleaseLexeme(theEnv,stmp->desc->overrideMessage);
402
+ RemoveConstraint(theEnv,stmp->desc->constraint);
403
+ if (stmp->desc->dynamicDefault == 1)
404
+ {
405
+ ExpressionDeinstall(theEnv,(Expression *) stmp->desc->defaultValue);
406
+ ReturnPackedExpression(theEnv,(Expression *) stmp->desc->defaultValue);
407
+ }
408
+ else if (stmp->desc->defaultValue != NULL)
409
+ {
410
+ UDFValue *theValue = (UDFValue *) stmp->desc->defaultValue;
411
+ ReleaseUDFV(theEnv,theValue);
412
+ if (theValue->header->type == MULTIFIELD_TYPE)
413
+ { ReturnMultifield(theEnv,theValue->multifieldValue); }
414
+ rtn_struct(theEnv,udfValue,theValue);
415
+ }
416
+ rtn_struct(theEnv,slotDescriptor,stmp->desc);
417
+ rtn_struct(theEnv,tempSlotLink,stmp);
418
+ }
419
+ }
420
+
421
+ /* =========================================
422
+ *****************************************
423
+ INTERNALLY VISIBLE FUNCTIONS
424
+ =========================================
425
+ ***************************************** */
426
+
427
+ /**************************************************************
428
+ NAME : NewSlot
429
+ DESCRIPTION : Allocates and initalizes a new slot structure
430
+ INPUTS : The symbolic name of the new slot
431
+ RETURNS : The address of the new slot
432
+ SIDE EFFECTS : None
433
+ NOTES : Also adds symbols of the form get-<name> and
434
+ put-<name> for slot accessors
435
+ **************************************************************/
436
+ static SlotDescriptor *NewSlot(
437
+ Environment *theEnv,
438
+ CLIPSLexeme *name)
439
+ {
440
+ SlotDescriptor *slot;
441
+
442
+ slot = get_struct(theEnv,slotDescriptor);
443
+ slot->dynamicDefault = 1;
444
+ slot->defaultSpecified = 0;
445
+ slot->noDefault = 0;
446
+ #if DEFRULE_CONSTRUCT
447
+ slot->reactive = 1;
448
+ #endif
449
+ slot->noInherit = 0;
450
+ slot->noWrite = 0;
451
+ slot->initializeOnly = 0;
452
+ slot->shared = 0;
453
+ slot->multiple = 0;
454
+ slot->composite = 0;
455
+ slot->sharedCount = 0;
456
+ slot->publicVisibility = 0;
457
+ slot->createReadAccessor = false;
458
+ slot->createWriteAccessor = false;
459
+ slot->overrideMessageSpecified = 0;
460
+ slot->cls = NULL;
461
+ slot->defaultValue = NULL;
462
+ slot->constraint = GetConstraintRecord(theEnv);
463
+ slot->slotName = AddSlotName(theEnv,name,0,false);
464
+ slot->overrideMessage = slot->slotName->putHandlerName;
465
+ IncrementLexemeCount(slot->overrideMessage);
466
+ return(slot);
467
+ }
468
+
469
+ /**********************************************************
470
+ NAME : InsertSlot
471
+ DESCRIPTION : Inserts a slot into the list of slots
472
+ INPUTS : 1) The current head of the slot list
473
+ 2) The slot to be inserted
474
+ RETURNS : The head of the slot list
475
+ SIDE EFFECTS : The slot is inserted if no errors,
476
+ otherwise the original list and the
477
+ new slot are destroyed
478
+ NOTES : None
479
+ **********************************************************/
480
+ static TEMP_SLOT_LINK *InsertSlot(
481
+ Environment *theEnv,
482
+ const char *className,
483
+ TEMP_SLOT_LINK *slist,
484
+ SlotDescriptor *slot)
485
+ {
486
+ TEMP_SLOT_LINK *stmp,*sprv,*tmp;
487
+
488
+ tmp = get_struct(theEnv,tempSlotLink);
489
+ tmp->desc = slot;
490
+ tmp->nxt = NULL;
491
+ if (slist == NULL)
492
+ slist = tmp;
493
+ else
494
+ {
495
+ stmp = slist;
496
+ sprv = NULL;
497
+ while (stmp != NULL)
498
+ {
499
+ if (stmp->desc->slotName == slot->slotName)
500
+ {
501
+ tmp->nxt = slist;
502
+ PrintErrorID(theEnv,"CLSLTPSR",1,false);
503
+ WriteString(theEnv,STDERR,"The '");
504
+ WriteString(theEnv,STDERR,slot->slotName->name->contents);
505
+ WriteString(theEnv,STDERR,"' slot for class '");
506
+ WriteString(theEnv,STDERR,className);
507
+ WriteString(theEnv,STDERR,"' is already specified.\n");
508
+ DeleteSlots(theEnv,tmp);
509
+ return NULL;
510
+ }
511
+ sprv = stmp;
512
+ stmp = stmp->nxt;
513
+ }
514
+ sprv->nxt = tmp;
515
+ }
516
+ return(slist);
517
+ }
518
+
519
+ /****************************************************************
520
+ NAME : ParseSimpleFacet
521
+ DESCRIPTION : Parses the following facets for a slot:
522
+ access, source, propagation, storage,
523
+ pattern-match, visibility and override-message
524
+ INPUTS : 1) The input logical name
525
+ 2) The bitmap indicating which facets have
526
+ already been parsed
527
+ 3) The name of the facet
528
+ 4) The bit to test/set in arg #2 for this facet
529
+ 5) The facet value string which indicates the
530
+ facet should be false
531
+ 6) The facet value string which indicates the
532
+ facet should be true
533
+ 7) An alternate value string for use when the
534
+ first two don't match (can be NULL)
535
+ 7) An alternate value string for use when the
536
+ first three don't match (can be NULL)
537
+ (will be an SF_VARIABLE type)
538
+ 9) A buffer to hold the facet value symbol
539
+ (can be NULL - only set if args #5 and #6
540
+ are both NULL)
541
+ RETURNS : -1 on errors
542
+ 0 if first value string matched
543
+ 1 if second value string matched
544
+ 2 if alternate value string matched
545
+ 3 if variable value string matched
546
+ 4 if facet value buffer was set
547
+ SIDE EFFECTS : Messages printed on errors
548
+ Bitmap marked indicating facet was parsed
549
+ Facet value symbol buffer set, if appropriate
550
+ NOTES : None
551
+ *****************************************************************/
552
+ static int ParseSimpleFacet(
553
+ Environment *theEnv,
554
+ const char *readSource,
555
+ SlotDescriptor *slot,
556
+ char *specbits,
557
+ const char *facetName,
558
+ int testBit,
559
+ const char *clearRelation,
560
+ const char *setRelation,
561
+ const char *alternateRelation,
562
+ const char *varRelation,
563
+ CLIPSLexeme **facetSymbolicValue)
564
+ {
565
+ int rtnCode;
566
+
567
+ if (TestBitMap(specbits,testBit))
568
+ {
569
+ PrintErrorID(theEnv,"CLSLTPSR",2,false);
570
+ WriteString(theEnv,STDERR,"The '");
571
+ WriteString(theEnv,STDERR,facetName);
572
+ WriteString(theEnv,STDERR,"' facet for slot '");
573
+ WriteString(theEnv,STDERR,slot->slotName->name->contents);
574
+ WriteString(theEnv,STDERR,"' is already specified.\n");
575
+ return -1;
576
+ }
577
+ SetBitMap(specbits,testBit);
578
+ SavePPBuffer(theEnv," ");
579
+ GetToken(theEnv,readSource,&DefclassData(theEnv)->ObjectParseToken);
580
+
581
+ /* ===============================
582
+ Check for the variable relation
583
+ =============================== */
584
+ if (DefclassData(theEnv)->ObjectParseToken.tknType == SF_VARIABLE_TOKEN)
585
+ {
586
+ if ((varRelation == NULL) ? false :
587
+ (strcmp(DefclassData(theEnv)->ObjectParseToken.lexemeValue->contents,varRelation) == 0))
588
+ rtnCode = 3;
589
+ else
590
+ goto ParseSimpleFacetError;
591
+ }
592
+ else
593
+ {
594
+ if (DefclassData(theEnv)->ObjectParseToken.tknType != SYMBOL_TOKEN)
595
+ goto ParseSimpleFacetError;
596
+
597
+ /* ===================================================
598
+ If the facet value buffer is non-NULL
599
+ simply get the value and do not check any relations
600
+ =================================================== */
601
+ if (facetSymbolicValue == NULL)
602
+ {
603
+ if (strcmp(DefclassData(theEnv)->ObjectParseToken.lexemeValue->contents,clearRelation) == 0)
604
+ rtnCode = 0;
605
+ else if (strcmp(DefclassData(theEnv)->ObjectParseToken.lexemeValue->contents,setRelation) == 0)
606
+ rtnCode = 1;
607
+ else if ((alternateRelation == NULL) ? false :
608
+ (strcmp(DefclassData(theEnv)->ObjectParseToken.lexemeValue->contents,alternateRelation) == 0))
609
+ rtnCode = 2;
610
+ else
611
+ goto ParseSimpleFacetError;
612
+ }
613
+ else
614
+ {
615
+ rtnCode = 4;
616
+ *facetSymbolicValue = DefclassData(theEnv)->ObjectParseToken.lexemeValue;
617
+ }
618
+ }
619
+ GetToken(theEnv,readSource,&DefclassData(theEnv)->ObjectParseToken);
620
+ if (DefclassData(theEnv)->ObjectParseToken.tknType != RIGHT_PARENTHESIS_TOKEN)
621
+ goto ParseSimpleFacetError;
622
+ return(rtnCode);
623
+
624
+ ParseSimpleFacetError:
625
+ SyntaxErrorMessage(theEnv,"slot facet");
626
+ return(-1);
627
+ }
628
+
629
+ /*************************************************************
630
+ NAME : ParseDefaultFacet
631
+ DESCRIPTION : Parses the facet for a slot
632
+ INPUTS : 1) The input logical name
633
+ 2) The bitmap indicating which facets have
634
+ already been parsed
635
+ 3) The slot descriptor to set
636
+ RETURNS : True if all OK, false otherwise
637
+ SIDE EFFECTS : Slot set and parsed facet bitmap set
638
+ NOTES : Syntax: (default ?NONE|<expression>*)
639
+ (default-dynamic <expression>*)
640
+ *************************************************************/
641
+ static bool ParseDefaultFacet(
642
+ Environment *theEnv,
643
+ const char *readSource,
644
+ char *specbits,
645
+ SlotDescriptor *slot)
646
+ {
647
+ Expression *tmp;
648
+ bool error, noneSpecified, deriveSpecified;
649
+
650
+ if (TestBitMap(specbits,DEFAULT_BIT))
651
+ {
652
+ PrintErrorID(theEnv,"CLSLTPSR",2,false);
653
+ WriteString(theEnv,STDERR,"The 'default' facet for slot '");
654
+ WriteString(theEnv,STDERR,slot->slotName->name->contents);
655
+ WriteString(theEnv,STDERR,"' is already specified.\n");
656
+ return false;
657
+ }
658
+ SetBitMap(specbits,DEFAULT_BIT);
659
+ error = false;
660
+ tmp = ParseDefault(theEnv,readSource,true,TestBitMap(specbits,DEFAULT_DYNAMIC_BIT),
661
+ false,&noneSpecified,&deriveSpecified,&error);
662
+ if (error == true)
663
+ return false;
664
+ if (noneSpecified || deriveSpecified)
665
+ {
666
+ if (noneSpecified)
667
+ {
668
+ slot->noDefault = 1;
669
+ slot->defaultSpecified = 1;
670
+ }
671
+ else
672
+ ClearBitMap(specbits,DEFAULT_BIT);
673
+ }
674
+ else
675
+ {
676
+ slot->defaultValue = PackExpression(theEnv,tmp);
677
+ ReturnExpression(theEnv,tmp);
678
+ ExpressionInstall(theEnv,(Expression *) slot->defaultValue);
679
+ slot->defaultSpecified = 1;
680
+ }
681
+ return true;
682
+ }
683
+
684
+ /**************************************************************************
685
+ NAME : BuildCompositeFacets
686
+ DESCRIPTION : Composite slots are ones that get their facets
687
+ from more than one class. By default, the most
688
+ specific class in object's precedence list specifies
689
+ the complete set of facets for a slot. The composite
690
+ facet in a slot allows facets that are not overridden
691
+ by the most specific class to be obtained from other
692
+ classes.
693
+
694
+ Since all superclasses are predetermined before creating
695
+ a new class based on them, this routine need only
696
+ examine the immediately next most specific class for
697
+ extra facets. Even if that slot is also composite, the
698
+ other facets have already been filtered down. If the
699
+ slot is no-inherit, the next most specific class must
700
+ be examined.
701
+ INPUTS : 1) The slot descriptor
702
+ 2) The class precedence list
703
+ 3) The bitmap marking which facets were specified in
704
+ the original slot definition
705
+ RETURNS : Nothing useful
706
+ SIDE EFFECTS : Composite slot is updated to reflect facets from
707
+ a less specific class
708
+ NOTES : Assumes slot is composite
709
+ *************************************************************************/
710
+ static void BuildCompositeFacets(
711
+ Environment *theEnv,
712
+ SlotDescriptor *sd,
713
+ PACKED_CLASS_LINKS *preclist,
714
+ const char *specbits,
715
+ CONSTRAINT_PARSE_RECORD *parsedConstraint)
716
+ {
717
+ SlotDescriptor *compslot = NULL;
718
+ unsigned long i;
719
+
720
+ for (i = 1 ; i < preclist->classCount ; i++)
721
+ {
722
+ compslot = FindClassSlot(preclist->classArray[i],sd->slotName->name);
723
+ if ((compslot != NULL) ? (compslot->noInherit == 0) : false)
724
+ break;
725
+ }
726
+ if (compslot != NULL)
727
+ {
728
+ if ((sd->defaultSpecified == 0) && (compslot->defaultSpecified == 1))
729
+ {
730
+ sd->dynamicDefault = compslot->dynamicDefault;
731
+ sd->noDefault = compslot->noDefault;
732
+ sd->defaultSpecified = 1;
733
+ if (compslot->defaultValue != NULL)
734
+ {
735
+ if (sd->dynamicDefault)
736
+ {
737
+ sd->defaultValue = PackExpression(theEnv,(Expression *) compslot->defaultValue);
738
+ ExpressionInstall(theEnv,(Expression *) sd->defaultValue);
739
+ }
740
+ else
741
+ {
742
+ UDFValue *newValue;
743
+ UDFValue *oldValue = (UDFValue *) compslot->defaultValue;
744
+ sd->defaultValue = get_struct(theEnv,udfValue);
745
+ GenCopyMemory(UDFValue,1,sd->defaultValue,oldValue);
746
+ newValue = (UDFValue *) sd->defaultValue;
747
+ if (oldValue->header->type == MULTIFIELD_TYPE)
748
+ { newValue->multifieldValue = CopyMultifield(theEnv,oldValue->multifieldValue); }
749
+ RetainUDFV(theEnv,newValue);
750
+ }
751
+ }
752
+ }
753
+ if (! TestBitMap(specbits,FIELD_BIT))
754
+ sd->multiple = compslot->multiple;
755
+ if (! TestBitMap(specbits,STORAGE_BIT))
756
+ sd->shared = compslot->shared;
757
+ if (! TestBitMap(specbits,ACCESS_BIT))
758
+ {
759
+ sd->noWrite = compslot->noWrite;
760
+ sd->initializeOnly = compslot->initializeOnly;
761
+ }
762
+ #if DEFRULE_CONSTRUCT
763
+ if (! TestBitMap(specbits,MATCH_BIT))
764
+ sd->reactive = compslot->reactive;
765
+ #endif
766
+ if (! TestBitMap(specbits,VISIBILITY_BIT))
767
+ sd->publicVisibility = compslot->publicVisibility;
768
+ if (! TestBitMap(specbits,CREATE_ACCESSOR_BIT))
769
+ {
770
+ sd->createReadAccessor = compslot->createReadAccessor;
771
+ sd->createWriteAccessor = compslot->createWriteAccessor;
772
+ }
773
+ if ((! TestBitMap(specbits,OVERRIDE_MSG_BIT)) &&
774
+ compslot->overrideMessageSpecified)
775
+ {
776
+ ReleaseLexeme(theEnv,sd->overrideMessage);
777
+ sd->overrideMessage = compslot->overrideMessage;
778
+ IncrementLexemeCount(sd->overrideMessage);
779
+ sd->overrideMessageSpecified = true;
780
+ }
781
+ OverlayConstraint(theEnv,parsedConstraint,sd->constraint,compslot->constraint);
782
+ }
783
+ }
784
+
785
+ /***************************************************
786
+ NAME : CheckForFacetConflicts
787
+ DESCRIPTION : Determines if all facets specified
788
+ (and inherited) for a slot are
789
+ consistent
790
+ INPUTS : 1) The slot descriptor
791
+ 2) The parse record for the
792
+ type constraints on the slot
793
+ RETURNS : True if all OK,
794
+ false otherwise
795
+ SIDE EFFECTS : Min and Max fields replaced in
796
+ constraint for single-field slot
797
+ NOTES : None
798
+ ***************************************************/
799
+ static bool CheckForFacetConflicts(
800
+ Environment *theEnv,
801
+ SlotDescriptor *sd,
802
+ CONSTRAINT_PARSE_RECORD *parsedConstraint)
803
+ {
804
+ if (sd->multiple == 0)
805
+ {
806
+ if (parsedConstraint->cardinality)
807
+ {
808
+ PrintErrorID(theEnv,"CLSLTPSR",3,true);
809
+ WriteString(theEnv,STDERR,"The 'cardinality' facet can only be used with multifield slots.\n");
810
+ return false;
811
+ }
812
+ else
813
+ {
814
+ ReturnExpression(theEnv,sd->constraint->minFields);
815
+ ReturnExpression(theEnv,sd->constraint->maxFields);
816
+ sd->constraint->minFields = GenConstant(theEnv,INTEGER_TYPE,CreateInteger(theEnv,1LL));
817
+ sd->constraint->maxFields = GenConstant(theEnv,INTEGER_TYPE,CreateInteger(theEnv,1LL));
818
+ }
819
+ }
820
+ if (sd->noDefault && sd->noWrite)
821
+ {
822
+ PrintErrorID(theEnv,"CLSLTPSR",4,true);
823
+ WriteString(theEnv,STDERR,"Slots with an 'access' facet value of 'read-only' must have a default value.\n");
824
+ return false;
825
+ }
826
+ if (sd->noWrite && (sd->createWriteAccessor || sd->overrideMessageSpecified))
827
+ {
828
+ PrintErrorID(theEnv,"CLSLTPSR",5,true);
829
+ WriteString(theEnv,STDERR,"Slots with an 'access' facet value of 'read-only' cannot have a write accessor.\n");
830
+ return false;
831
+ }
832
+ if (sd->noInherit && sd->publicVisibility)
833
+ {
834
+ PrintErrorID(theEnv,"CLSLTPSR",6,true);
835
+ WriteString(theEnv,STDERR,"Slots with a 'propagation' facet value of 'no-inherit' cannot have a 'visibility' facet value of 'public'.\n");
836
+ return false;
837
+ }
838
+ return true;
839
+ }
840
+
841
+ /********************************************************************
842
+ NAME : EvaluateSlotDefaultValue
843
+ DESCRIPTION : Checks the default value against the slot
844
+ constraints and evaluates static default values
845
+ INPUTS : 1) The slot descriptor
846
+ 2) The bitmap marking which facets were specified in
847
+ the original slot definition
848
+ RETURNS : True if all OK, false otherwise
849
+ SIDE EFFECTS : Static default value expressions deleted and
850
+ replaced with data object evaluation
851
+ NOTES : On errors, slot is marked as dynamix so that
852
+ DeleteSlots() will erase the slot expression
853
+ ********************************************************************/
854
+ static bool EvaluateSlotDefaultValue(
855
+ Environment *theEnv,
856
+ SlotDescriptor *sd,
857
+ const char *specbits)
858
+ {
859
+ UDFValue temp;
860
+ bool oldce,olddcc, vPass;
861
+ ConstraintViolationType vCode;
862
+
863
+ /* ===================================================================
864
+ Slot default value expression is marked as dynamic until now so
865
+ that DeleteSlots() would erase in the event of an error. The delay
866
+ was so that the evaluation of a static default value could be
867
+ delayed until all the constraints were parsed.
868
+ =================================================================== */
869
+ if (! TestBitMap(specbits,DEFAULT_DYNAMIC_BIT))
870
+ sd->dynamicDefault = 0;
871
+
872
+ if (sd->noDefault)
873
+ return true;
874
+
875
+ if (sd->dynamicDefault == 0)
876
+ {
877
+ if (TestBitMap(specbits,DEFAULT_BIT))
878
+ {
879
+ oldce = ExecutingConstruct(theEnv);
880
+ SetExecutingConstruct(theEnv,true);
881
+ olddcc = SetDynamicConstraintChecking(theEnv,true);
882
+ vPass = EvaluateAndStoreInDataObject(theEnv,sd->multiple,
883
+ (Expression *) sd->defaultValue,&temp,true);
884
+ if (vPass != false)
885
+ vPass = (ValidSlotValue(theEnv,&temp,sd,NULL,"the 'default' facet") == PSE_NO_ERROR);
886
+ SetDynamicConstraintChecking(theEnv,olddcc);
887
+ SetExecutingConstruct(theEnv,oldce);
888
+ if (vPass)
889
+ {
890
+ UDFValue *newValue;
891
+ ExpressionDeinstall(theEnv,(Expression *) sd->defaultValue);
892
+ ReturnPackedExpression(theEnv,(Expression *) sd->defaultValue);
893
+ sd->defaultValue = get_struct(theEnv,udfValue);
894
+ newValue = (UDFValue *) sd->defaultValue;
895
+ GenCopyMemory(UDFValue,1,sd->defaultValue,&temp);
896
+ if (temp.header->type == MULTIFIELD_TYPE)
897
+ { newValue->multifieldValue = CopyMultifield(theEnv,temp.multifieldValue); }
898
+ RetainUDFV(theEnv,(UDFValue *) sd->defaultValue);
899
+ }
900
+ else
901
+ {
902
+ sd->dynamicDefault = 1;
903
+ return false;
904
+ }
905
+ }
906
+ else if (sd->defaultSpecified == 0)
907
+ {
908
+ sd->defaultValue = get_struct(theEnv,udfValue);
909
+ DeriveDefaultFromConstraints(theEnv,sd->constraint,
910
+ (UDFValue *) sd->defaultValue,sd->multiple,false);
911
+ RetainUDFV(theEnv,(UDFValue *) sd->defaultValue);
912
+ }
913
+ }
914
+ else
915
+ {
916
+ vCode = ConstraintCheckExpressionChain(theEnv,(Expression *) sd->defaultValue,sd->constraint);
917
+ if (vCode != NO_VIOLATION)
918
+ {
919
+ PrintErrorID(theEnv,"CSTRNCHK",1,false);
920
+ WriteString(theEnv,STDERR,"Expression for ");
921
+ PrintSlot(theEnv,STDERR,sd,NULL,"dynamic default value");
922
+ ConstraintViolationErrorMessage(theEnv,NULL,NULL,0,0,NULL,0,
923
+ vCode,sd->constraint,false);
924
+ return false;
925
+ }
926
+ }
927
+ return true;
928
+ }
929
+
930
+ #endif
931
+