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,1221 @@
1
+ /*******************************************************/
2
+ /* "C" Language Integrated Production System */
3
+ /* */
4
+ /* CLIPS Version 6.41 01/29/23 */
5
+ /* */
6
+ /* OBJECT MESSAGE COMMANDS */
7
+ /*******************************************************/
8
+
9
+ /*************************************************************/
10
+ /* Purpose: */
11
+ /* */
12
+ /* Principal Programmer(s): */
13
+ /* Brian L. Dantes */
14
+ /* */
15
+ /* Contributing Programmer(s): */
16
+ /* */
17
+ /* Revision History: */
18
+ /* */
19
+ /* 6.23: Changed name of variable log to logName */
20
+ /* because of Unix compiler warnings of shadowed */
21
+ /* definitions. */
22
+ /* */
23
+ /* 6.24: Removed IMPERATIVE_MESSAGE_HANDLERS */
24
+ /* compilation flag. */
25
+ /* */
26
+ /* Corrected code to remove run-time program */
27
+ /* compiler warnings. */
28
+ /* */
29
+ /* 6.30: Changed integer type/precision. */
30
+ /* */
31
+ /* Removed conditional code for unsupported */
32
+ /* compilers/operating systems (IBM_MCW, */
33
+ /* MAC_MCW, and IBM_TBC). */
34
+ /* */
35
+ /* Added DeallocateMessageHandlerData to */
36
+ /* deallocate message handler environment data. */
37
+ /* */
38
+ /* Added const qualifiers to remove C++ */
39
+ /* deprecation warnings. */
40
+ /* */
41
+ /* Converted API macros to function calls. */
42
+ /* */
43
+ /* 6.40: Added Env prefix to GetEvaluationError and */
44
+ /* SetEvaluationError functions. */
45
+ /* */
46
+ /* Pragma once and other inclusion changes. */
47
+ /* */
48
+ /* Added support for booleans with <stdbool.h>. */
49
+ /* */
50
+ /* Removed use of void pointers for specific */
51
+ /* data structures. */
52
+ /* */
53
+ /* ALLOW_ENVIRONMENT_GLOBALS no longer supported. */
54
+ /* */
55
+ /* UDF redesign. */
56
+ /* */
57
+ /* Pretty print functions accept optional logical */
58
+ /* name argument. */
59
+ /* */
60
+ /* 6.41: Changed function ListDefmessageHandlers to */
61
+ /* dynamically allocate storage to remove */
62
+ /* compiler warning for -Warray-bounds. */
63
+ /* */
64
+ /*************************************************************/
65
+
66
+ /* =========================================
67
+ *****************************************
68
+ EXTERNAL DEFINITIONS
69
+ =========================================
70
+ ***************************************** */
71
+ #include "setup.h"
72
+
73
+ #if OBJECT_SYSTEM
74
+
75
+ #include <string.h>
76
+
77
+ #include "argacces.h"
78
+ #if BLOAD || BLOAD_AND_BSAVE
79
+ #include "bload.h"
80
+ #endif
81
+ #include "classcom.h"
82
+ #include "classfun.h"
83
+ #include "classinf.h"
84
+ #if (! BLOAD_ONLY) && (! RUN_TIME)
85
+ #include "constrct.h"
86
+ #include "msgpsr.h"
87
+ #endif
88
+ #include "envrnmnt.h"
89
+ #if ! RUN_TIME
90
+ #include "extnfunc.h"
91
+ #endif
92
+ #include "insfun.h"
93
+ #include "insmoddp.h"
94
+ #include "msgfun.h"
95
+ #include "msgpass.h"
96
+ #include "memalloc.h"
97
+ #include "prccode.h"
98
+ #include "prntutil.h"
99
+ #include "router.h"
100
+ #if DEBUGGING_FUNCTIONS
101
+ #include "watch.h"
102
+ #endif
103
+
104
+ #include "msgcom.h"
105
+
106
+ /***************************************/
107
+ /* LOCAL INTERNAL FUNCTION DEFINITIONS */
108
+ /***************************************/
109
+
110
+ #if ! RUN_TIME
111
+ static void CreateSystemHandlers(Environment *,void *);
112
+ #endif
113
+
114
+ #if (! BLOAD_ONLY) && (! RUN_TIME)
115
+ static bool WildDeleteHandler(Environment *,Defclass *,CLIPSLexeme *,const char *);
116
+ #endif
117
+
118
+ #if DEBUGGING_FUNCTIONS
119
+ static bool DefmessageHandlerWatchAccess(Environment *,int,bool,Expression *);
120
+ static bool DefmessageHandlerWatchPrint(Environment *,const char *,int,Expression *);
121
+ static bool DefmessageHandlerWatchSupport(Environment *,const char *,const char *,bool,
122
+ void (*)(Environment *,const char *,Defclass *,unsigned),
123
+ void (*)(Defclass *,unsigned,bool),
124
+ Expression *);
125
+ static bool WatchClassHandlers(Environment *,Defclass *,const char *,int,const char *,bool,bool,
126
+ void (*)(Environment *,const char *,Defclass *,unsigned),
127
+ void (*)(Defclass *,unsigned,bool));
128
+ static void PrintHandlerWatchFlag(Environment *,const char *,Defclass *,unsigned);
129
+ #endif
130
+
131
+ static void DeallocateMessageHandlerData(Environment *);
132
+
133
+ /* =========================================
134
+ *****************************************
135
+ EXTERNALLY VISIBLE FUNCTIONS
136
+ =========================================
137
+ ***************************************** */
138
+
139
+ /***************************************************
140
+ NAME : SetupMessageHandlers
141
+ DESCRIPTION : Sets up internal symbols and
142
+ fucntion definitions pertaining to
143
+ message-handlers. Also creates
144
+ system handlers
145
+ INPUTS : None
146
+ RETURNS : Nothing useful
147
+ SIDE EFFECTS : Functions and data structures
148
+ initialized
149
+ NOTES : Should be called before
150
+ SetupInstanceModDupCommands() in
151
+ INSMODDP.C
152
+ ***************************************************/
153
+ void SetupMessageHandlers(
154
+ Environment *theEnv)
155
+ {
156
+ EntityRecord handlerGetInfo = { "HANDLER_GET", HANDLER_GET,0,1,1,
157
+ PrintHandlerSlotGetFunction,
158
+ PrintHandlerSlotGetFunction,NULL,
159
+ HandlerSlotGetFunction,
160
+ NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL },
161
+
162
+ handlerPutInfo = { "HANDLER_PUT", HANDLER_PUT,0,1,1,
163
+ PrintHandlerSlotPutFunction,
164
+ PrintHandlerSlotPutFunction,NULL,
165
+ HandlerSlotPutFunction,
166
+ NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
167
+
168
+ AllocateEnvironmentData(theEnv,MESSAGE_HANDLER_DATA,sizeof(struct messageHandlerData),DeallocateMessageHandlerData);
169
+ memcpy(&MessageHandlerData(theEnv)->HandlerGetInfo,&handlerGetInfo,sizeof(struct entityRecord));
170
+ memcpy(&MessageHandlerData(theEnv)->HandlerPutInfo,&handlerPutInfo,sizeof(struct entityRecord));
171
+
172
+ MessageHandlerData(theEnv)->hndquals[0] = "around";
173
+ MessageHandlerData(theEnv)->hndquals[1] = "before";
174
+ MessageHandlerData(theEnv)->hndquals[2] = "primary";
175
+ MessageHandlerData(theEnv)->hndquals[3] = "after";
176
+
177
+ InstallPrimitive(theEnv,&MessageHandlerData(theEnv)->HandlerGetInfo,HANDLER_GET);
178
+ InstallPrimitive(theEnv,&MessageHandlerData(theEnv)->HandlerPutInfo,HANDLER_PUT);
179
+
180
+ #if ! RUN_TIME
181
+ MessageHandlerData(theEnv)->INIT_SYMBOL = CreateSymbol(theEnv,INIT_STRING);
182
+ IncrementLexemeCount(MessageHandlerData(theEnv)->INIT_SYMBOL);
183
+
184
+ MessageHandlerData(theEnv)->DELETE_SYMBOL = CreateSymbol(theEnv,DELETE_STRING);
185
+ IncrementLexemeCount(MessageHandlerData(theEnv)->DELETE_SYMBOL);
186
+
187
+ MessageHandlerData(theEnv)->CREATE_SYMBOL = CreateSymbol(theEnv,CREATE_STRING);
188
+ IncrementLexemeCount(MessageHandlerData(theEnv)->CREATE_SYMBOL);
189
+
190
+ AddClearFunction(theEnv,"defclass",CreateSystemHandlers,-100,NULL);
191
+
192
+ #if ! BLOAD_ONLY
193
+ MessageHandlerData(theEnv)->SELF_SYMBOL = CreateSymbol(theEnv,SELF_STRING);
194
+ IncrementLexemeCount(MessageHandlerData(theEnv)->SELF_SYMBOL);
195
+
196
+ AddConstruct(theEnv,"defmessage-handler","defmessage-handlers",
197
+ ParseDefmessageHandler,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
198
+ AddUDF(theEnv,"undefmessage-handler","v",2,3,"y",UndefmessageHandlerCommand,"UndefmessageHandlerCommand",NULL);
199
+
200
+ #endif
201
+
202
+ AddUDF(theEnv,"send","*",2,UNBOUNDED,"*;*;y",SendCommand,"SendCommand",NULL);
203
+
204
+ #if DEBUGGING_FUNCTIONS
205
+ AddUDF(theEnv,"preview-send","v",2,2,"y",PreviewSendCommand,"PreviewSendCommand",NULL);
206
+
207
+ AddUDF(theEnv,"ppdefmessage-handler","v",2,4,"y",PPDefmessageHandlerCommand,"PPDefmessageHandlerCommand",NULL);
208
+ AddUDF(theEnv,"list-defmessage-handlers","v",0,2,"y",ListDefmessageHandlersCommand,"ListDefmessageHandlersCommand",NULL);
209
+ #endif
210
+
211
+ AddUDF(theEnv,"next-handlerp","b",0,0,NULL,NextHandlerAvailableFunction,"NextHandlerAvailableFunction",NULL);
212
+ FuncSeqOvlFlags(theEnv,"next-handlerp",true,false);
213
+ AddUDF(theEnv,"call-next-handler","*",0,0,NULL,CallNextHandler,"CallNextHandler",NULL);
214
+ FuncSeqOvlFlags(theEnv,"call-next-handler",true,false);
215
+ AddUDF(theEnv,"override-next-handler","*",0,UNBOUNDED,NULL,CallNextHandler,"CallNextHandler",NULL);
216
+ FuncSeqOvlFlags(theEnv,"override-next-handler",true,false);
217
+
218
+ AddUDF(theEnv,"dynamic-get","*",1,1,"y",DynamicHandlerGetSlot,"DynamicHandlerGetSlot",NULL);
219
+ AddUDF(theEnv,"dynamic-put","*",1,UNBOUNDED,"*;y",DynamicHandlerPutSlot,"DynamicHandlerPutSlot",NULL);
220
+ AddUDF(theEnv,"get","*",1,1,"y",DynamicHandlerGetSlot,"DynamicHandlerGetSlot",NULL);
221
+ AddUDF(theEnv,"put","*",1,UNBOUNDED,"*;y",DynamicHandlerPutSlot,"DynamicHandlerPutSlot",NULL);
222
+ #endif
223
+
224
+ #if DEBUGGING_FUNCTIONS
225
+ AddWatchItem(theEnv,"messages",0,&MessageHandlerData(theEnv)->WatchMessages,36,NULL,NULL);
226
+ AddWatchItem(theEnv,"message-handlers",0,&MessageHandlerData(theEnv)->WatchHandlers,35,
227
+ DefmessageHandlerWatchAccess,DefmessageHandlerWatchPrint);
228
+ #endif
229
+ }
230
+
231
+ /*******************************************************/
232
+ /* DeallocateMessageHandlerData: Deallocates environment */
233
+ /* data for the message handler functionality. */
234
+ /******************************************************/
235
+ static void DeallocateMessageHandlerData(
236
+ Environment *theEnv)
237
+ {
238
+ HANDLER_LINK *tmp, *mhead, *chead;
239
+
240
+ mhead = MessageHandlerData(theEnv)->TopOfCore;
241
+ while (mhead != NULL)
242
+ {
243
+ tmp = mhead;
244
+ mhead = mhead->nxt;
245
+ rtn_struct(theEnv,messageHandlerLink,tmp);
246
+ }
247
+
248
+ chead = MessageHandlerData(theEnv)->OldCore;
249
+ while (chead != NULL)
250
+ {
251
+ mhead = chead;
252
+ chead = chead->nxtInStack;
253
+
254
+ while (mhead != NULL)
255
+ {
256
+ tmp = mhead;
257
+ mhead = mhead->nxt;
258
+ rtn_struct(theEnv,messageHandlerLink,tmp);
259
+ }
260
+ }
261
+ }
262
+
263
+ /*****************************************************
264
+ NAME : DefmessageHandlerName
265
+ DESCRIPTION : Gets the name of a message-handler
266
+ INPUTS : 1) Pointer to a class
267
+ 2) Array index of handler in class's
268
+ message-handler array (+1)
269
+ RETURNS : Name-string of message-handler
270
+ SIDE EFFECTS : None
271
+ NOTES : None
272
+ *****************************************************/
273
+ const char *DefmessageHandlerName(
274
+ Defclass *theDefclass,
275
+ unsigned theIndex)
276
+ {
277
+ return theDefclass->handlers[theIndex-1].header.name->contents;
278
+ }
279
+
280
+ /*****************************************************
281
+ NAME : DefmessageHandlerType
282
+ DESCRIPTION : Gets the type of a message-handler
283
+ INPUTS : 1) Pointer to a class
284
+ 2) Array index of handler in class's
285
+ message-handler array (+1)
286
+ RETURNS : Type-string of message-handler
287
+ SIDE EFFECTS : None
288
+ NOTES : None
289
+ *****************************************************/
290
+ const char *DefmessageHandlerType(
291
+ Defclass *theDefclass,
292
+ unsigned theIndex)
293
+ {
294
+ Environment *theEnv = theDefclass->header.env;
295
+
296
+ return MessageHandlerData(theEnv)->hndquals[theDefclass->handlers[theIndex-1].type];
297
+ }
298
+
299
+ /**************************************************************
300
+ NAME : GetNextDefmessageHandler
301
+ DESCRIPTION : Finds first or next handler for a class
302
+ INPUTS : 1) The address of the handler's class
303
+ 2) The array index of the current handler (+1)
304
+ RETURNS : The array index (+1) of the next handler, or 0
305
+ if there is none
306
+ SIDE EFFECTS : None
307
+ NOTES : If index == 0, the first handler array index
308
+ (i.e. 1) returned
309
+ **************************************************************/
310
+ unsigned GetNextDefmessageHandler(
311
+ Defclass *theDefclass,
312
+ unsigned theIndex)
313
+ {
314
+ if (theIndex == 0)
315
+ { return (theDefclass->handlers != NULL) ? 1 : 0; }
316
+
317
+ if (theIndex == theDefclass->handlerCount)
318
+ { return 0; }
319
+
320
+ return theIndex+1;
321
+ }
322
+
323
+ /*****************************************************
324
+ NAME : GetDefmessageHandlerPointer
325
+ DESCRIPTION : Returns a pointer to a handler
326
+ INPUTS : 1) Pointer to a class
327
+ 2) Array index of handler in class's
328
+ message-handler array (+1)
329
+ RETURNS : Pointer to the handler.
330
+ SIDE EFFECTS : None
331
+ NOTES : None
332
+ *****************************************************/
333
+ DefmessageHandler *GetDefmessageHandlerPointer(
334
+ Defclass *theDefclass,
335
+ unsigned int theIndex)
336
+ {
337
+ return &theDefclass->handlers[theIndex-1];
338
+ }
339
+
340
+ #if DEBUGGING_FUNCTIONS
341
+
342
+ /*********************************************************
343
+ NAME : DefmessageHandlerGetWatch
344
+ DESCRIPTION : Determines if trace messages for calls
345
+ to this handler will be generated or not
346
+ INPUTS : 1) A pointer to the class
347
+ 2) The index of the handler
348
+ RETURNS : True if a trace is active,
349
+ false otherwise
350
+ SIDE EFFECTS : None
351
+ NOTES : None
352
+ *********************************************************/
353
+ bool DefmessageHandlerGetWatch(
354
+ Defclass *theDefclass,
355
+ unsigned theIndex)
356
+ {
357
+ return theDefclass->handlers[theIndex-1].trace;
358
+ }
359
+
360
+ /*********************************************************
361
+ NAME : DefmessageHandlerSetWatch
362
+ DESCRIPTION : Sets the trace to ON/OFF for the
363
+ calling of the handler
364
+ INPUTS : 1) True to set the trace on,
365
+ false to set it off
366
+ 2) A pointer to the class
367
+ 3) The index of the handler
368
+ RETURNS : Nothing useful
369
+ SIDE EFFECTS : Watch flag for the handler set
370
+ NOTES : None
371
+ *********************************************************/
372
+ void DefmessageHandlerSetWatch(
373
+ Defclass *theClass,
374
+ unsigned theIndex,
375
+ bool newState)
376
+ {
377
+ theClass->handlers[theIndex-1].trace = newState;
378
+ }
379
+
380
+ #endif
381
+
382
+ /***************************************************
383
+ NAME : FindDefmessageHandler
384
+ DESCRIPTION : Determines the index of a specfied
385
+ message-handler
386
+ INPUTS : 1) A pointer to the class
387
+ 2) Name-string of the handler
388
+ 3) Handler-type: "around","before",
389
+ "primary", or "after"
390
+ RETURNS : The index of the handler
391
+ (0 if not found)
392
+ SIDE EFFECTS : None
393
+ NOTES : None
394
+ ***************************************************/
395
+ unsigned FindDefmessageHandler(
396
+ Defclass *theDefclass,
397
+ const char *hname,
398
+ const char *htypestr)
399
+ {
400
+ unsigned htype;
401
+ CLIPSLexeme *hsym;
402
+ int theIndex;
403
+ Environment *theEnv = theDefclass->header.env;
404
+
405
+ htype = HandlerType(theEnv,"handler-lookup",false,htypestr);
406
+ if (htype == MERROR)
407
+ { return 0; }
408
+
409
+ hsym = FindSymbolHN(theEnv,hname,SYMBOL_BIT);
410
+ if (hsym == NULL)
411
+ { return 0; }
412
+
413
+ theIndex = FindHandlerByIndex(theDefclass,hsym,htype);
414
+ return (unsigned) (theIndex+1);
415
+ }
416
+
417
+ /***************************************************
418
+ NAME : DefmessageHandlerIsDeletable
419
+ DESCRIPTION : Determines if a message-handler
420
+ can be deleted
421
+ INPUTS : 1) Address of the handler's class
422
+ 2) Index of the handler
423
+ RETURNS : True if deletable, false otherwise
424
+ SIDE EFFECTS : None
425
+ NOTES : None
426
+ ***************************************************/
427
+ bool DefmessageHandlerIsDeletable(
428
+ Defclass *theDefclass,
429
+ unsigned theIndex)
430
+ {
431
+ Environment *theEnv = theDefclass->header.env;
432
+
433
+ if (! ConstructsDeletable(theEnv))
434
+ { return false; }
435
+
436
+ if (theDefclass->handlers[theIndex-1].system == 1)
437
+ { return false; }
438
+
439
+ #if (! BLOAD_ONLY) && (! RUN_TIME)
440
+ return (HandlersExecuting(theDefclass) == false) ? true : false;
441
+ #else
442
+ return false;
443
+ #endif
444
+ }
445
+
446
+ /******************************************************************************
447
+ NAME : UndefmessageHandlerCommand
448
+ DESCRIPTION : Deletes a handler from a class
449
+ INPUTS : None
450
+ RETURNS : Nothing useful
451
+ SIDE EFFECTS : Handler deleted if possible
452
+ NOTES : H/L Syntax: (undefmessage-handler <class> <handler> [<type>])
453
+ ******************************************************************************/
454
+ void UndefmessageHandlerCommand(
455
+ Environment *theEnv,
456
+ UDFContext *context,
457
+ UDFValue *returnValue)
458
+ {
459
+ #if RUN_TIME || BLOAD_ONLY
460
+ PrintErrorID(theEnv,"MSGCOM",3,false);
461
+ WriteString(theEnv,STDERR,"Unable to delete message-handlers.\n");
462
+ #else
463
+ CLIPSLexeme *mname;
464
+ const char *tname;
465
+ UDFValue theArg;
466
+ Defclass *cls;
467
+
468
+ #if BLOAD || BLOAD_AND_BSAVE
469
+ if (Bloaded(theEnv))
470
+ {
471
+ PrintErrorID(theEnv,"MSGCOM",3,false);
472
+ WriteString(theEnv,STDERR,"Unable to delete message-handlers.\n");
473
+ return;
474
+ }
475
+ #endif
476
+ if (! UDFFirstArgument(context,SYMBOL_BIT,&theArg)) return;
477
+
478
+ cls = LookupDefclassByMdlOrScope(theEnv,theArg.lexemeValue->contents);
479
+ if ((cls == NULL) ? (strcmp(theArg.lexemeValue->contents,"*") != 0) : false)
480
+ {
481
+ ClassExistError(theEnv,"undefmessage-handler",theArg.lexemeValue->contents);
482
+ return;
483
+ }
484
+ if (! UDFNextArgument(context,SYMBOL_BIT,&theArg)) return;
485
+
486
+ mname = theArg.lexemeValue;
487
+ if (UDFHasNextArgument(context))
488
+ {
489
+ if (! UDFNextArgument(context,SYMBOL_BIT,&theArg)) return;
490
+
491
+ tname = theArg.lexemeValue->contents;
492
+ if (strcmp(tname,"*") == 0)
493
+ tname = NULL;
494
+ }
495
+ else
496
+ tname = MessageHandlerData(theEnv)->hndquals[MPRIMARY];
497
+ WildDeleteHandler(theEnv,cls,mname,tname);
498
+ #endif
499
+ }
500
+
501
+ /***********************************************************
502
+ NAME : UndefmessageHandler
503
+ DESCRIPTION : Deletes a handler from a class
504
+ INPUTS : 1) Class address (Can be NULL)
505
+ 2) Handler index (can be 0)
506
+ RETURNS : 1 if successful, 0 otherwise
507
+ SIDE EFFECTS : Handler deleted if possible
508
+ NOTES : None
509
+ ***********************************************************/
510
+ bool UndefmessageHandler(
511
+ Defclass *theDefclass,
512
+ unsigned mhi,
513
+ Environment *allEnv)
514
+ {
515
+ Environment *theEnv;
516
+ #if (! RUN_TIME) && (! BLOAD_ONLY)
517
+ bool success;
518
+ GCBlock gcb;
519
+ #endif
520
+
521
+ if (theDefclass == NULL)
522
+ { theEnv = allEnv; }
523
+ else
524
+ { theEnv = theDefclass->header.env; }
525
+
526
+ #if RUN_TIME || BLOAD_ONLY
527
+ PrintErrorID(theEnv,"MSGCOM",3,false);
528
+ WriteString(theEnv,STDERR,"Unable to delete message-handlers.\n");
529
+ return false;
530
+ #else
531
+
532
+ #if BLOAD || BLOAD_AND_BSAVE
533
+ if (Bloaded(theEnv))
534
+ {
535
+ PrintErrorID(theEnv,"MSGCOM",3,false);
536
+ WriteString(theEnv,STDERR,"Unable to delete message-handlers.\n");
537
+ return false;
538
+ }
539
+ #endif
540
+ GCBlockStart(theEnv,&gcb);
541
+ if (theDefclass == NULL)
542
+ {
543
+ if (mhi != 0)
544
+ {
545
+ PrintErrorID(theEnv,"MSGCOM",1,false);
546
+ WriteString(theEnv,STDERR,"Incomplete message-handler specification for deletion.\n");
547
+ GCBlockEnd(theEnv,&gcb);
548
+ return false;
549
+ }
550
+ success = WildDeleteHandler(theEnv,NULL,NULL,NULL);
551
+ GCBlockEnd(theEnv,&gcb);
552
+ return success;
553
+ }
554
+
555
+ if (mhi == 0)
556
+ {
557
+ success = WildDeleteHandler(theEnv,theDefclass,NULL,NULL);
558
+ GCBlockEnd(theEnv,&gcb);
559
+ return success;
560
+ }
561
+
562
+ if (HandlersExecuting(theDefclass))
563
+ {
564
+ HandlerDeleteError(theEnv,DefclassName(theDefclass));
565
+ GCBlockEnd(theEnv,&gcb);
566
+ return false;
567
+ }
568
+
569
+ theDefclass->handlers[mhi-1].mark = 1;
570
+ DeallocateMarkedHandlers(theEnv,theDefclass);
571
+ GCBlockEnd(theEnv,&gcb);
572
+ return true;
573
+ #endif
574
+ }
575
+
576
+ #if DEBUGGING_FUNCTIONS
577
+
578
+ /*******************************************************************************
579
+ NAME : PPDefmessageHandlerCommand
580
+ DESCRIPTION : Displays the pretty-print form (if any) for a handler
581
+ INPUTS : None
582
+ RETURNS : Nothing useful
583
+ SIDE EFFECTS : None
584
+ NOTES : H/L Syntax: (ppdefmessage-handler <class> <message> [<type>])
585
+ *******************************************************************************/
586
+ void PPDefmessageHandlerCommand(
587
+ Environment *theEnv,
588
+ UDFContext *context,
589
+ UDFValue *returnValue)
590
+ {
591
+ UDFValue theArg;
592
+ CLIPSLexeme *csym, *msym;
593
+ const char *tname;
594
+ const char *logicalName;
595
+ Defclass *cls = NULL;
596
+ unsigned mtype;
597
+ DefmessageHandler *hnd = NULL;
598
+
599
+ if (! UDFFirstArgument(context,SYMBOL_BIT,&theArg))
600
+ { return; }
601
+
602
+ csym = FindSymbolHN(theEnv,theArg.lexemeValue->contents,SYMBOL_BIT);
603
+
604
+ if (! UDFNextArgument(context,SYMBOL_BIT,&theArg))
605
+ { return; }
606
+
607
+ msym = FindSymbolHN(theEnv,theArg.lexemeValue->contents,SYMBOL_BIT);
608
+
609
+ if (UDFHasNextArgument(context))
610
+ {
611
+ if (! UDFNextArgument(context,SYMBOL_BIT,&theArg))
612
+ { return; }
613
+ tname = theArg.lexemeValue->contents;
614
+ }
615
+ else
616
+ tname = MessageHandlerData(theEnv)->hndquals[MPRIMARY];
617
+
618
+ mtype = HandlerType(theEnv,"ppdefmessage-handler",true,tname);
619
+ if (mtype == MERROR)
620
+ {
621
+ SetEvaluationError(theEnv,true);
622
+ return;
623
+ }
624
+
625
+ if (UDFHasNextArgument(context))
626
+ {
627
+ logicalName = GetLogicalName(context,STDOUT);
628
+ if (logicalName == NULL)
629
+ {
630
+ IllegalLogicalNameMessage(theEnv,"ppdefmessage-handler");
631
+ SetHaltExecution(theEnv,true);
632
+ SetEvaluationError(theEnv,true);
633
+ return;
634
+ }
635
+ }
636
+ else
637
+ { logicalName = STDOUT; }
638
+
639
+ if (csym != NULL)
640
+ cls = LookupDefclassByMdlOrScope(theEnv,csym->contents);
641
+ if (((cls == NULL) || (msym == NULL)) ? true :
642
+ ((hnd = FindHandlerByAddress(cls,msym,mtype)) == NULL))
643
+ {
644
+ PrintErrorID(theEnv,"MSGCOM",2,false);
645
+ WriteString(theEnv,STDERR,"Unable to find message-handler '");
646
+ WriteString(theEnv,STDERR,msym->contents);
647
+ WriteString(theEnv,STDERR,"' ");
648
+ WriteString(theEnv,STDERR,tname);
649
+ WriteString(theEnv,STDERR," for class '");
650
+ WriteString(theEnv,STDERR,csym->contents);
651
+ WriteString(theEnv,STDERR,"' in function 'ppdefmessage-handler'.\n");
652
+ SetEvaluationError(theEnv,true);
653
+ return;
654
+ }
655
+
656
+ if (strcmp(logicalName,"nil") == 0)
657
+ {
658
+ if (hnd->header.ppForm != NULL)
659
+ { returnValue->lexemeValue = CreateString(theEnv,hnd->header.ppForm); }
660
+ else
661
+ { returnValue->lexemeValue = CreateString(theEnv,""); }
662
+ }
663
+ else
664
+ {
665
+ if (hnd->header.ppForm != NULL)
666
+ WriteString(theEnv,logicalName,hnd->header.ppForm);
667
+ }
668
+ }
669
+
670
+ /*****************************************************************************
671
+ NAME : ListDefmessageHandlersCommand
672
+ DESCRIPTION : Depending on arguments, does lists handlers which
673
+ match restrictions
674
+ INPUTS : None
675
+ RETURNS : Nothing useful
676
+ SIDE EFFECTS : None
677
+ NOTES : H/L Syntax: (list-defmessage-handlers [<class> [inherit]]))
678
+ *****************************************************************************/
679
+ void ListDefmessageHandlersCommand(
680
+ Environment *theEnv,
681
+ UDFContext *context,
682
+ UDFValue *returnValue)
683
+ {
684
+ bool inhp;
685
+ Defclass *clsptr;
686
+
687
+ if (UDFArgumentCount(context) == 0)
688
+ ListDefmessageHandlers(theEnv,NULL,STDOUT,false);
689
+ else
690
+ {
691
+ clsptr = ClassInfoFnxArgs(context,"list-defmessage-handlers",&inhp);
692
+ if (clsptr == NULL)
693
+ return;
694
+ ListDefmessageHandlers(theEnv,clsptr,STDOUT,inhp);
695
+ }
696
+ }
697
+
698
+ /********************************************************************
699
+ NAME : PreviewSendCommand
700
+ DESCRIPTION : Displays a list of the core for a message describing
701
+ shadows,etc.
702
+ INPUTS : None
703
+ RETURNS : Nothing useful
704
+ SIDE EFFECTS : Temporary core created and destroyed
705
+ NOTES : H/L Syntax: (preview-send <class> <msg>)
706
+ ********************************************************************/
707
+ void PreviewSendCommand(
708
+ Environment *theEnv,
709
+ UDFContext *context,
710
+ UDFValue *returnValue)
711
+ {
712
+ Defclass *cls;
713
+ UDFValue theArg;
714
+
715
+ /* =============================
716
+ Get the class for the message
717
+ ============================= */
718
+
719
+ if (! UDFFirstArgument(context,SYMBOL_BIT,&theArg))
720
+ { return; }
721
+
722
+ cls = LookupDefclassByMdlOrScope(theEnv,theArg.lexemeValue->contents);
723
+
724
+ if (cls == NULL)
725
+ {
726
+ ClassExistError(theEnv,"preview-send",theArg.lexemeValue->contents);
727
+ return;
728
+ }
729
+
730
+ if (! UDFNextArgument(context,SYMBOL_BIT,&theArg))
731
+ { return; }
732
+
733
+ PreviewSend(cls,STDOUT,theArg.lexemeValue->contents);
734
+ }
735
+
736
+ /********************************************************
737
+ NAME : DefmessageHandlerPPForm
738
+ DESCRIPTION : Gets a message-handler pretty print form
739
+ INPUTS : 1) Address of the handler's class
740
+ 2) Index of the handler
741
+ RETURNS : True if printable, false otherwise
742
+ SIDE EFFECTS : None
743
+ NOTES : None
744
+ ********************************************************/
745
+ const char *DefmessageHandlerPPForm(
746
+ Defclass *theDefclass,
747
+ unsigned theIndex)
748
+ {
749
+ return theDefclass->handlers[theIndex-1].header.ppForm;
750
+ }
751
+
752
+ /*******************************************************************
753
+ NAME : ListDefmessageHandlers
754
+ DESCRIPTION : Lists message-handlers for a class
755
+ INPUTS : 1) The logical name of the output
756
+ 2) Class name (NULL to display all handlers)
757
+ 3) A flag indicating whether to list inherited
758
+ handlers or not
759
+ RETURNS : Nothing useful
760
+ SIDE EFFECTS : None
761
+ NOTES : None
762
+ *******************************************************************/
763
+ void ListDefmessageHandlers(
764
+ Environment *theEnv,
765
+ Defclass *theDefclass,
766
+ const char *logName,
767
+ bool inhp)
768
+ {
769
+ unsigned long cnt;
770
+ PACKED_CLASS_LINKS plinks;
771
+
772
+ if (theDefclass != NULL)
773
+ {
774
+ if (inhp)
775
+ { cnt = DisplayHandlersInLinks(theEnv,logName,&theDefclass->allSuperclasses,0); }
776
+ else
777
+ {
778
+ plinks.classCount = 1;
779
+ plinks.classArray = (Defclass **) gm2(theEnv,(sizeof(Defclass *)));
780
+ plinks.classArray[0] = theDefclass;
781
+ cnt = DisplayHandlersInLinks(theEnv,logName,&plinks,0);
782
+ rm(theEnv,plinks.classArray,(sizeof(Defclass *)));
783
+ }
784
+ }
785
+ else
786
+ {
787
+ plinks.classCount = 1;
788
+ plinks.classArray = (Defclass **) gm2(theEnv,(sizeof(Defclass *)));
789
+ cnt = 0L;
790
+ for (theDefclass = GetNextDefclass(theEnv,NULL) ;
791
+ theDefclass != NULL ;
792
+ theDefclass = GetNextDefclass(theEnv,theDefclass))
793
+ {
794
+ plinks.classArray[0] = theDefclass;
795
+ cnt += DisplayHandlersInLinks(theEnv,logName,&plinks,0);
796
+ }
797
+ rm(theEnv,plinks.classArray,(sizeof(Defclass *)));
798
+ }
799
+ PrintTally(theEnv,logName,cnt,"message-handler","message-handlers");
800
+ }
801
+
802
+ /********************************************************************
803
+ NAME : PreviewSend
804
+ DESCRIPTION : Displays a list of the core for a message describing
805
+ shadows,etc.
806
+ INPUTS : 1) Logical name of output
807
+ 2) Class pointer
808
+ 3) Message name-string
809
+ RETURNS : Nothing useful
810
+ SIDE EFFECTS : Temporary core created and destroyed
811
+ NOTES : None
812
+ ********************************************************************/
813
+ void PreviewSend(
814
+ Defclass *theDefclass,
815
+ const char *logicalName,
816
+ const char *msgname)
817
+ {
818
+ HANDLER_LINK *core;
819
+ CLIPSLexeme *msym;
820
+ Environment *theEnv = theDefclass->header.env;
821
+
822
+ msym = FindSymbolHN(theEnv,msgname,SYMBOL_BIT);
823
+ if (msym == NULL)
824
+ { return; }
825
+
826
+ core = FindPreviewApplicableHandlers(theEnv,theDefclass,msym);
827
+ if (core != NULL)
828
+ {
829
+ DisplayCore(theEnv,logicalName,core,0);
830
+ DestroyHandlerLinks(theEnv,core);
831
+ }
832
+ }
833
+
834
+ /****************************************************
835
+ NAME : DisplayHandlersInLinks
836
+ DESCRIPTION : Recursively displays all handlers
837
+ for an array of classes
838
+ INPUTS : 1) The logical name of the output
839
+ 2) The packed class links
840
+ 3) The index to print from the links
841
+ RETURNS : The number of handlers printed
842
+ SIDE EFFECTS : None
843
+ NOTES : Used by DescribeClass()
844
+ ****************************************************/
845
+ unsigned long DisplayHandlersInLinks(
846
+ Environment *theEnv,
847
+ const char *logName,
848
+ PACKED_CLASS_LINKS *plinks,
849
+ unsigned int theIndex)
850
+ {
851
+ unsigned long i;
852
+ unsigned long cnt;
853
+
854
+ cnt = plinks->classArray[theIndex]->handlerCount;
855
+ if ((theIndex + 1) < plinks->classCount)
856
+ cnt += DisplayHandlersInLinks(theEnv,logName,plinks,theIndex + 1);
857
+ for (i = 0 ; i < plinks->classArray[theIndex]->handlerCount ; i++)
858
+ PrintHandler(theEnv,logName,&plinks->classArray[theIndex]->handlers[i],false,true);
859
+ return cnt;
860
+ }
861
+
862
+ #endif
863
+
864
+ /* =========================================
865
+ *****************************************
866
+ INTERNALLY VISIBLE FUNCTIONS
867
+ =========================================
868
+ ***************************************** */
869
+
870
+ #if ! RUN_TIME
871
+
872
+ /**********************************************************
873
+ NAME : CreateSystemHandlers
874
+ DESCRIPTION : Attachess the system message-handlers
875
+ after a (clear)
876
+ INPUTS : None
877
+ RETURNS : Nothing useful
878
+ SIDE EFFECTS : System handlers created
879
+ NOTES : Must be called after CreateSystemClasses()
880
+ **********************************************************/
881
+ static void CreateSystemHandlers(
882
+ Environment *theEnv,
883
+ void *context)
884
+ {
885
+ NewSystemHandler(theEnv,USER_TYPE_NAME,INIT_STRING,"init-slots",0);
886
+ NewSystemHandler(theEnv,USER_TYPE_NAME,DELETE_STRING,"delete-instance",0);
887
+ NewSystemHandler(theEnv,USER_TYPE_NAME,CREATE_STRING,"(create-instance)",0);
888
+
889
+ #if DEBUGGING_FUNCTIONS
890
+ NewSystemHandler(theEnv,USER_TYPE_NAME,PRINT_STRING,"ppinstance",0);
891
+ #endif
892
+
893
+ NewSystemHandler(theEnv,USER_TYPE_NAME,DIRECT_MODIFY_STRING,"(direct-modify)",1);
894
+ NewSystemHandler(theEnv,USER_TYPE_NAME,MSG_MODIFY_STRING,"(message-modify)",1);
895
+ NewSystemHandler(theEnv,USER_TYPE_NAME,DIRECT_DUPLICATE_STRING,"(direct-duplicate)",2);
896
+ NewSystemHandler(theEnv,USER_TYPE_NAME,MSG_DUPLICATE_STRING,"(message-duplicate)",2);
897
+ }
898
+
899
+ #endif
900
+
901
+ #if (! BLOAD_ONLY) && (! RUN_TIME)
902
+
903
+ /************************************************************
904
+ NAME : WildDeleteHandler
905
+ DESCRIPTION : Deletes a handler from a class
906
+ INPUTS : 1) Class address (Can be NULL)
907
+ 2) Message Handler Name (Can be NULL)
908
+ 3) Type name ("primary", etc.)
909
+ RETURNS : 1 if successful, 0 otherwise
910
+ SIDE EFFECTS : Handler deleted if possible
911
+ NOTES : None
912
+ ************************************************************/
913
+ static bool WildDeleteHandler(
914
+ Environment *theEnv,
915
+ Defclass *cls,
916
+ CLIPSLexeme *msym,
917
+ const char *tname)
918
+ {
919
+ int mtype;
920
+
921
+ if (msym == NULL)
922
+ msym = CreateSymbol(theEnv,"*");
923
+ if (tname != NULL)
924
+ {
925
+ mtype = (int) HandlerType(theEnv,"undefmessage-handler",true,tname);
926
+ if (mtype == MERROR)
927
+ return false;
928
+ }
929
+ else
930
+ mtype = -1;
931
+ if (cls == NULL)
932
+ {
933
+ bool success = true;
934
+
935
+ for (cls = GetNextDefclass(theEnv,NULL) ;
936
+ cls != NULL ;
937
+ cls = GetNextDefclass(theEnv,cls))
938
+ if (DeleteHandler(theEnv,cls,msym,mtype,false) == false)
939
+ success = false;
940
+ return(success);
941
+ }
942
+ return(DeleteHandler(theEnv,cls,msym,mtype,true));
943
+ }
944
+
945
+ #endif
946
+
947
+ #if DEBUGGING_FUNCTIONS
948
+
949
+ /******************************************************************
950
+ NAME : DefmessageHandlerWatchAccess
951
+ DESCRIPTION : Parses a list of class names passed by
952
+ AddWatchItem() and sets the traces accordingly
953
+ INPUTS : 1) A code indicating which trace flag is to be set
954
+ 0 - Watch instance creation/deletion
955
+ 1 - Watch slot changes to instances
956
+ 2) The value to which to set the trace flags
957
+ 3) A list of expressions containing the names
958
+ of the classes for which to set traces
959
+ RETURNS : True if all OK, false otherwise
960
+ SIDE EFFECTS : Watch flags set in specified classes
961
+ NOTES : Accessory function for AddWatchItem()
962
+ ******************************************************************/
963
+ static bool DefmessageHandlerWatchAccess(
964
+ Environment *theEnv,
965
+ int code,
966
+ bool newState,
967
+ Expression *argExprs)
968
+ {
969
+ #if MAC_XCD
970
+ #pragma unused(code)
971
+ #endif
972
+ if (newState)
973
+ return(DefmessageHandlerWatchSupport(theEnv,"watch",NULL,newState,
974
+ NULL,DefmessageHandlerSetWatch,argExprs));
975
+ else
976
+ return(DefmessageHandlerWatchSupport(theEnv,"unwatch",NULL,newState,
977
+ NULL,DefmessageHandlerSetWatch,argExprs));
978
+ }
979
+
980
+ /***********************************************************************
981
+ NAME : DefmessageHandlerWatchPrint
982
+ DESCRIPTION : Parses a list of class names passed by
983
+ AddWatchItem() and displays the traces accordingly
984
+ INPUTS : 1) The logical name of the output
985
+ 2) A code indicating which trace flag is to be examined
986
+ 0 - Watch instance creation/deletion
987
+ 1 - Watch slot changes to instances
988
+ 3) A list of expressions containing the names
989
+ of the classes for which to examine traces
990
+ RETURNS : True if all OK, false otherwise
991
+ SIDE EFFECTS : Watch flags displayed for specified classes
992
+ NOTES : Accessory function for AddWatchItem()
993
+ ***********************************************************************/
994
+ static bool DefmessageHandlerWatchPrint(
995
+ Environment *theEnv,
996
+ const char *logName,
997
+ int code,
998
+ Expression *argExprs)
999
+ {
1000
+ #if MAC_XCD
1001
+ #pragma unused(code)
1002
+ #endif
1003
+ return DefmessageHandlerWatchSupport(theEnv,"list-watch-items",logName,false,
1004
+ PrintHandlerWatchFlag,NULL,argExprs);
1005
+ }
1006
+
1007
+ /*******************************************************
1008
+ NAME : DefmessageHandlerWatchSupport
1009
+ DESCRIPTION : Sets or displays handlers specified
1010
+ INPUTS : 1) The calling function name
1011
+ 2) The logical output name for displays
1012
+ (can be NULL)
1013
+ 4) The new set state (can be -1)
1014
+ 5) The print function (can be NULL)
1015
+ 6) The trace function (can be NULL)
1016
+ 7) The handlers expression list
1017
+ RETURNS : True if all OK,
1018
+ false otherwise
1019
+ SIDE EFFECTS : Handler trace flags set or displayed
1020
+ NOTES : None
1021
+ *******************************************************/
1022
+ static bool DefmessageHandlerWatchSupport(
1023
+ Environment *theEnv,
1024
+ const char *funcName,
1025
+ const char *logName,
1026
+ bool newState,
1027
+ void (*printFunc)(Environment *,const char *,Defclass *,unsigned),
1028
+ void (*traceFunc)(Defclass *,unsigned,bool),
1029
+ Expression *argExprs)
1030
+ {
1031
+ Defmodule *theModule;
1032
+ Defclass *theClass;
1033
+ const char *theHandlerStr;
1034
+ int theType;
1035
+ unsigned int argIndex = 2;
1036
+ UDFValue tmpData;
1037
+
1038
+ /* ===============================
1039
+ If no handlers are specified,
1040
+ show the trace for all handlers
1041
+ in all handlers
1042
+ =============================== */
1043
+ if (argExprs == NULL)
1044
+ {
1045
+ SaveCurrentModule(theEnv);
1046
+ theModule = GetNextDefmodule(theEnv,NULL);
1047
+ while (theModule != NULL)
1048
+ {
1049
+ SetCurrentModule(theEnv,theModule);
1050
+ if (traceFunc == NULL)
1051
+ {
1052
+ WriteString(theEnv,logName,DefmoduleName(theModule));
1053
+ WriteString(theEnv,logName,":\n");
1054
+ }
1055
+ theClass = GetNextDefclass(theEnv,NULL);
1056
+ while (theClass != NULL)
1057
+ {
1058
+ if (WatchClassHandlers(theEnv,theClass,NULL,-1,logName,newState,
1059
+ true,printFunc,traceFunc) == false)
1060
+ return false;
1061
+ theClass = GetNextDefclass(theEnv,theClass);
1062
+ }
1063
+ theModule = GetNextDefmodule(theEnv,theModule);
1064
+ }
1065
+ RestoreCurrentModule(theEnv);
1066
+ return true;
1067
+ }
1068
+
1069
+ /* ================================================
1070
+ Set or show the traces for the specified handler
1071
+ ================================================ */
1072
+ while (argExprs != NULL)
1073
+ {
1074
+ if (EvaluateExpression(theEnv,argExprs,&tmpData))
1075
+ return false;
1076
+ if (tmpData.header->type != SYMBOL_TYPE)
1077
+ {
1078
+ ExpectedTypeError1(theEnv,funcName,argIndex,"'class name'");
1079
+ return false;
1080
+ }
1081
+ theClass = LookupDefclassByMdlOrScope(theEnv,tmpData.lexemeValue->contents);
1082
+ if (theClass == NULL)
1083
+ {
1084
+ ExpectedTypeError1(theEnv,funcName,argIndex,"'class name'");
1085
+ return false;
1086
+ }
1087
+ if (GetNextArgument(argExprs) != NULL)
1088
+ {
1089
+ argExprs = GetNextArgument(argExprs);
1090
+ argIndex++;
1091
+ if (EvaluateExpression(theEnv,argExprs,&tmpData))
1092
+ return false;
1093
+ if (tmpData.header->type != SYMBOL_TYPE)
1094
+ {
1095
+ ExpectedTypeError1(theEnv,funcName,argIndex,"'handler name'");
1096
+ return false;
1097
+ }
1098
+ theHandlerStr = tmpData.lexemeValue->contents;
1099
+ if (GetNextArgument(argExprs) != NULL)
1100
+ {
1101
+ argExprs = GetNextArgument(argExprs);
1102
+ argIndex++;
1103
+ if (EvaluateExpression(theEnv,argExprs,&tmpData))
1104
+ return false;
1105
+ if (tmpData.header->type != SYMBOL_TYPE)
1106
+ {
1107
+ ExpectedTypeError1(theEnv,funcName,argIndex,"'handler type'");
1108
+ return false;
1109
+ }
1110
+ if ((theType = (int) HandlerType(theEnv,funcName,true,tmpData.lexemeValue->contents)) == MERROR)
1111
+ return false;
1112
+ }
1113
+ else
1114
+ theType = -1;
1115
+ }
1116
+ else
1117
+ {
1118
+ theHandlerStr = NULL;
1119
+ theType = -1;
1120
+ }
1121
+ if (WatchClassHandlers(theEnv,theClass,theHandlerStr,theType,logName,
1122
+ newState,false,printFunc,traceFunc) == false)
1123
+ {
1124
+ ExpectedTypeError1(theEnv,funcName,argIndex,"handler");
1125
+ return false;
1126
+ }
1127
+ argIndex++;
1128
+ argExprs = GetNextArgument(argExprs);
1129
+ }
1130
+ return true;
1131
+ }
1132
+
1133
+ /*******************************************************
1134
+ NAME : WatchClassHandlers
1135
+ DESCRIPTION : Sets or displays handlers specified
1136
+ INPUTS : 1) The class
1137
+ 2) The handler name (or NULL wildcard)
1138
+ 3) The handler type (or -1 wildcard)
1139
+ 4) The logical output name for displays
1140
+ (can be NULL)
1141
+ 5) The new set state (can be -1)
1142
+ 6) The print function (can be NULL)
1143
+ 7) The trace function (can be NULL)
1144
+ RETURNS : True if all OK,
1145
+ false otherwise
1146
+ SIDE EFFECTS : Handler trace flags set or displayed
1147
+ NOTES : None
1148
+ *******************************************************/
1149
+ static bool WatchClassHandlers(
1150
+ Environment *theEnv,
1151
+ Defclass *theClass,
1152
+ const char *theHandlerStr,
1153
+ int theType,
1154
+ const char *logName,
1155
+ bool newState,
1156
+ bool indentp,
1157
+ void (*printFunc)(Environment *,const char *,Defclass *,unsigned),
1158
+ void (*traceFunc)(Defclass *,unsigned,bool))
1159
+ {
1160
+ unsigned theHandler;
1161
+ bool found = false;
1162
+
1163
+ theHandler = GetNextDefmessageHandler(theClass,0);
1164
+ while (theHandler != 0)
1165
+ {
1166
+ if ((theType == -1) ? true :
1167
+ (theType == (int) theClass->handlers[theHandler-1].type))
1168
+ {
1169
+ if ((theHandlerStr == NULL) ? true :
1170
+ (strcmp(theHandlerStr,DefmessageHandlerName(theClass,theHandler)) == 0))
1171
+ {
1172
+ if (traceFunc != NULL)
1173
+ (*traceFunc)(theClass,theHandler,newState);
1174
+ else
1175
+ {
1176
+ if (indentp)
1177
+ WriteString(theEnv,logName," ");
1178
+ (*printFunc)(theEnv,logName,theClass,theHandler);
1179
+ }
1180
+ found = true;
1181
+ }
1182
+ }
1183
+ theHandler = GetNextDefmessageHandler(theClass,theHandler);
1184
+ }
1185
+ if ((theHandlerStr != NULL) && (theType != -1) && (found == false))
1186
+ return false;
1187
+ return true;
1188
+ }
1189
+
1190
+ /***************************************************
1191
+ NAME : PrintHandlerWatchFlag
1192
+ DESCRIPTION : Displays trace value for handler
1193
+ INPUTS : 1) The logical name of the output
1194
+ 2) The class
1195
+ 3) The handler index
1196
+ RETURNS : Nothing useful
1197
+ SIDE EFFECTS : None
1198
+ NOTES : None
1199
+ ***************************************************/
1200
+ static void PrintHandlerWatchFlag(
1201
+ Environment *theEnv,
1202
+ const char *logName,
1203
+ Defclass *theClass,
1204
+ unsigned theHandler)
1205
+ {
1206
+ WriteString(theEnv,logName,DefclassName(theClass));
1207
+ WriteString(theEnv,logName," ");
1208
+ WriteString(theEnv,logName,DefmessageHandlerName(theClass,theHandler));
1209
+ WriteString(theEnv,logName," ");
1210
+ WriteString(theEnv,logName,DefmessageHandlerType(theClass,theHandler));
1211
+
1212
+ if (DefmessageHandlerGetWatch(theClass,theHandler))
1213
+ WriteString(theEnv,logName," = on\n");
1214
+ else
1215
+ WriteString(theEnv,logName," = off\n");
1216
+ }
1217
+
1218
+ #endif /* DEBUGGING_FUNCTIONS */
1219
+
1220
+ #endif /* OBJECT_SYSTEM */
1221
+