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,843 @@
1
+ /*******************************************************/
2
+ /* "C" Language Integrated Production System */
3
+ /* */
4
+ /* CLIPS Version 6.40 04/03/19 */
5
+ /* */
6
+ /* CLASS INITIALIZATION MODULE */
7
+ /*******************************************************/
8
+
9
+ /**************************************************************/
10
+ /* Purpose: Defclass Initialization Routines */
11
+ /* */
12
+ /* Principal Programmer(s): */
13
+ /* Brian L. Dantes */
14
+ /* */
15
+ /* Contributing Programmer(s): */
16
+ /* */
17
+ /* Revision History: */
18
+ /* */
19
+ /* 6.23: Corrected compilation errors for files */
20
+ /* generated by constructs-to-c. DR0861 */
21
+ /* */
22
+ /* 6.24: Added allowed-classes slot facet. */
23
+ /* */
24
+ /* Converted INSTANCE_PATTERN_MATCHING to */
25
+ /* DEFRULE_CONSTRUCT. */
26
+ /* */
27
+ /* Corrected code to remove run-time program */
28
+ /* compiler warning. */
29
+ /* */
30
+ /* 6.30: Borland C (IBM_TBC) and Metrowerks CodeWarrior */
31
+ /* (MAC_MCW, IBM_MCW) are no longer supported. */
32
+ /* */
33
+ /* Changed integer type/precision. */
34
+ /* */
35
+ /* Support for hashed alpha memories. */
36
+ /* */
37
+ /* Added const qualifiers to remove C++ */
38
+ /* deprecation warnings. */
39
+ /* */
40
+ /* Changed find construct functionality so that */
41
+ /* imported modules are search when locating a */
42
+ /* named construct. */
43
+ /* */
44
+ /* 6.31: Optimization of slot ID creation previously */
45
+ /* provided by NewSlotNameID function. */
46
+ /* */
47
+ /* Changed allocation of multifield slot default */
48
+ /* from ephemeral to explicit deallocation. */
49
+ /* */
50
+ /* 6.40: Pragma once and other inclusion changes. */
51
+ /* */
52
+ /* Added support for booleans with <stdbool.h>. */
53
+ /* */
54
+ /* Removed use of void pointers for specific */
55
+ /* data structures. */
56
+ /* */
57
+ /* UDF redesign. */
58
+ /* */
59
+ /* Removed initial-object support. */
60
+ /* */
61
+ /* Pretty print functions accept optional logical */
62
+ /* name argument. */
63
+ /* */
64
+ /**************************************************************/
65
+
66
+ /* =========================================
67
+ *****************************************
68
+ EXTERNAL DEFINITIONS
69
+ =========================================
70
+ ***************************************** */
71
+ #include "setup.h"
72
+
73
+ #if OBJECT_SYSTEM
74
+
75
+ #include <stdio.h>
76
+
77
+ #include "classcom.h"
78
+ #include "classexm.h"
79
+ #include "classfun.h"
80
+ #include "classinf.h"
81
+ #include "classpsr.h"
82
+ #include "cstrccom.h"
83
+ #include "cstrcpsr.h"
84
+ #include "envrnmnt.h"
85
+ #include "extnfunc.h"
86
+ #include "inscom.h"
87
+ #include "memalloc.h"
88
+ #include "modulpsr.h"
89
+ #include "modulutl.h"
90
+ #include "msgcom.h"
91
+ #include "watch.h"
92
+
93
+ #if DEFINSTANCES_CONSTRUCT
94
+ #include "defins.h"
95
+ #endif
96
+
97
+ #if INSTANCE_SET_QUERIES
98
+ #include "insquery.h"
99
+ #endif
100
+
101
+ #if BLOAD_AND_BSAVE || BLOAD || BLOAD_ONLY
102
+ #include "bload.h"
103
+ #include "objbin.h"
104
+ #endif
105
+
106
+ #if CONSTRUCT_COMPILER && (! RUN_TIME)
107
+ #include "objcmp.h"
108
+ #endif
109
+
110
+ #if DEFRULE_CONSTRUCT
111
+ #include "objrtbld.h"
112
+ #include "objrtfnx.h"
113
+ #include "objrtmch.h"
114
+ #endif
115
+
116
+ #if RUN_TIME
117
+ #include "insfun.h"
118
+ #include "msgfun.h"
119
+ #include "pattern.h"
120
+ #endif
121
+
122
+ #include "classini.h"
123
+
124
+ /* =========================================
125
+ *****************************************
126
+ CONSTANTS
127
+ =========================================
128
+ ***************************************** */
129
+ #define SUPERCLASS_RLN "is-a"
130
+ #define NAME_RLN "name"
131
+
132
+ /* =========================================
133
+ *****************************************
134
+ INTERNALLY VISIBLE FUNCTION HEADERS
135
+ =========================================
136
+ ***************************************** */
137
+
138
+ static void SetupDefclasses(Environment *);
139
+ static void DeallocateDefclassData(Environment *);
140
+
141
+ #if (! RUN_TIME)
142
+ static void DestroyDefclassAction(Environment *,ConstructHeader *,void *);
143
+ static Defclass *AddSystemClass(Environment *,const char *,Defclass *);
144
+ static void *AllocateModule(Environment *);
145
+ static void ReturnModule(Environment *,void *);
146
+ #else
147
+ static void SearchForHashedPatternNodes(Environment *,OBJECT_PATTERN_NODE *);
148
+ #endif
149
+
150
+ #if (! BLOAD_ONLY) && (! RUN_TIME) && DEFMODULE_CONSTRUCT
151
+ static void UpdateDefclassesScope(Environment *,void *);
152
+ #endif
153
+
154
+ /* =========================================
155
+ *****************************************
156
+ EXTERNALLY VISIBLE FUNCTIONS
157
+ =========================================
158
+ ***************************************** */
159
+
160
+ /**********************************************************
161
+ NAME : SetupObjectSystem
162
+ DESCRIPTION : Initializes all COOL constructs, functions,
163
+ and data structures
164
+ INPUTS : None
165
+ RETURNS : Nothing useful
166
+ SIDE EFFECTS : COOL initialized
167
+ NOTES : Order of setup calls is important
168
+ **********************************************************/
169
+ void SetupObjectSystem(
170
+ Environment *theEnv)
171
+ {
172
+ EntityRecord defclassEntityRecord = { "DEFCLASS_PTR", DEFCLASS_PTR,1,0,0,
173
+ NULL,NULL,NULL,NULL,NULL,
174
+ (EntityBusyCountFunction *) DecrementDefclassBusyCount,
175
+ (EntityBusyCountFunction *) IncrementDefclassBusyCount,
176
+ NULL,NULL,NULL,NULL,NULL };
177
+
178
+ AllocateEnvironmentData(theEnv,DEFCLASS_DATA,sizeof(struct defclassData),NULL);
179
+ AddEnvironmentCleanupFunction(theEnv,"defclasses",DeallocateDefclassData,-500);
180
+
181
+ memcpy(&DefclassData(theEnv)->DefclassEntityRecord,&defclassEntityRecord,sizeof(struct entityRecord));
182
+
183
+ DefclassData(theEnv)->newSlotID = 2; // IS_A and NAME assigned 0 and 1
184
+
185
+ #if ! RUN_TIME
186
+ DefclassData(theEnv)->ClassDefaultsModeValue = CONVENIENCE_MODE;
187
+ DefclassData(theEnv)->ISA_SYMBOL = CreateSymbol(theEnv,SUPERCLASS_RLN);
188
+ IncrementLexemeCount(DefclassData(theEnv)->ISA_SYMBOL);
189
+ DefclassData(theEnv)->NAME_SYMBOL = CreateSymbol(theEnv,NAME_RLN);
190
+ IncrementLexemeCount(DefclassData(theEnv)->NAME_SYMBOL);
191
+ #endif
192
+
193
+ SetupDefclasses(theEnv);
194
+ SetupInstances(theEnv);
195
+ SetupMessageHandlers(theEnv);
196
+
197
+ #if DEFINSTANCES_CONSTRUCT
198
+ SetupDefinstances(theEnv);
199
+ #endif
200
+
201
+ #if INSTANCE_SET_QUERIES
202
+ SetupQuery(theEnv);
203
+ #endif
204
+
205
+ #if BLOAD_AND_BSAVE || BLOAD || BLOAD_ONLY
206
+ SetupObjectsBload(theEnv);
207
+ #endif
208
+
209
+ #if CONSTRUCT_COMPILER && (! RUN_TIME)
210
+ SetupObjectsCompiler(theEnv);
211
+ #endif
212
+
213
+ #if DEFRULE_CONSTRUCT
214
+ SetupObjectPatternStuff(theEnv);
215
+ #endif
216
+ }
217
+
218
+ /***************************************************/
219
+ /* DeallocateDefclassData: Deallocates environment */
220
+ /* data for the defclass construct. */
221
+ /***************************************************/
222
+ static void DeallocateDefclassData(
223
+ Environment *theEnv)
224
+ {
225
+ #if ! RUN_TIME
226
+ SLOT_NAME *tmpSNPPtr, *nextSNPPtr;
227
+ int i;
228
+ struct defclassModule *theModuleItem;
229
+ Defmodule *theModule;
230
+ bool bloaded = false;
231
+
232
+ #if BLOAD || BLOAD_AND_BSAVE
233
+ if (Bloaded(theEnv)) bloaded = true;
234
+ #endif
235
+
236
+ /*=============================*/
237
+ /* Destroy all the defclasses. */
238
+ /*=============================*/
239
+
240
+ if (! bloaded)
241
+ {
242
+ DoForAllConstructs(theEnv,DestroyDefclassAction,DefclassData(theEnv)->DefclassModuleIndex,false,NULL);
243
+
244
+ for (theModule = GetNextDefmodule(theEnv,NULL);
245
+ theModule != NULL;
246
+ theModule = GetNextDefmodule(theEnv,theModule))
247
+ {
248
+ theModuleItem = (struct defclassModule *)
249
+ GetModuleItem(theEnv,theModule,
250
+ DefclassData(theEnv)->DefclassModuleIndex);
251
+ rtn_struct(theEnv,defclassModule,theModuleItem);
252
+ }
253
+ }
254
+
255
+ /*==========================*/
256
+ /* Remove the class tables. */
257
+ /*==========================*/
258
+
259
+ if (! bloaded)
260
+ {
261
+ if (DefclassData(theEnv)->ClassIDMap != NULL)
262
+ {
263
+ genfree(theEnv,DefclassData(theEnv)->ClassIDMap,DefclassData(theEnv)->AvailClassID * sizeof(Defclass *));
264
+ }
265
+ }
266
+
267
+ if (DefclassData(theEnv)->ClassTable != NULL)
268
+ {
269
+ genfree(theEnv,DefclassData(theEnv)->ClassTable,sizeof(Defclass *) * CLASS_TABLE_HASH_SIZE);
270
+ }
271
+
272
+ /*==============================*/
273
+ /* Free up the slot name table. */
274
+ /*==============================*/
275
+
276
+ if (! bloaded)
277
+ {
278
+ for (i = 0; i < SLOT_NAME_TABLE_HASH_SIZE; i++)
279
+ {
280
+ tmpSNPPtr = DefclassData(theEnv)->SlotNameTable[i];
281
+
282
+ while (tmpSNPPtr != NULL)
283
+ {
284
+ nextSNPPtr = tmpSNPPtr->nxt;
285
+ rtn_struct(theEnv,slotName,tmpSNPPtr);
286
+ tmpSNPPtr = nextSNPPtr;
287
+ }
288
+ }
289
+ }
290
+
291
+ if (DefclassData(theEnv)->SlotNameTable != NULL)
292
+ {
293
+ genfree(theEnv,DefclassData(theEnv)->SlotNameTable,sizeof(SLOT_NAME *) * SLOT_NAME_TABLE_HASH_SIZE);
294
+ }
295
+ #else
296
+ Defclass *cls;
297
+ void *tmpexp;
298
+ unsigned int i;
299
+ int j;
300
+
301
+ if (DefclassData(theEnv)->ClassTable != NULL)
302
+ {
303
+ for (j = 0 ; j < CLASS_TABLE_HASH_SIZE ; j++)
304
+ for (cls = DefclassData(theEnv)->ClassTable[j] ; cls != NULL ; cls = cls->nxtHash)
305
+ {
306
+ for (i = 0 ; i < cls->slotCount ; i++)
307
+ {
308
+ if ((cls->slots[i].defaultValue != NULL) && (cls->slots[i].dynamicDefault == 0))
309
+ {
310
+ UDFValue *theValue = (UDFValue *) cls->slots[i].defaultValue;
311
+ tmpexp = theValue->supplementalInfo;
312
+ if (theValue->header->type == MULTIFIELD_TYPE)
313
+ { ReturnMultifield(theEnv,theValue->multifieldValue); }
314
+ rtn_struct(theEnv,udfValue,cls->slots[i].defaultValue);
315
+ cls->slots[i].defaultValue = tmpexp;
316
+ }
317
+ }
318
+ }
319
+ }
320
+ #endif
321
+ }
322
+
323
+ #if ! RUN_TIME
324
+ /*********************************************************/
325
+ /* DestroyDefclassAction: Action used to remove defclass */
326
+ /* as a result of DestroyEnvironment. */
327
+ /*********************************************************/
328
+ static void DestroyDefclassAction(
329
+ Environment *theEnv,
330
+ ConstructHeader *theConstruct,
331
+ void *buffer)
332
+ {
333
+ #if MAC_XCD
334
+ #pragma unused(buffer)
335
+ #endif
336
+ Defclass *theDefclass = (Defclass *) theConstruct;
337
+
338
+ if (theDefclass == NULL) return;
339
+
340
+ #if (! BLOAD_ONLY)
341
+ DestroyDefclass(theEnv,theDefclass);
342
+ #else
343
+ #if MAC_XCD
344
+ #pragma unused(theEnv)
345
+ #endif
346
+ #endif
347
+ }
348
+ #endif
349
+
350
+ #if RUN_TIME
351
+
352
+ /***************************************************
353
+ NAME : ObjectsRunTimeInitialize
354
+ DESCRIPTION : Initializes objects system lists
355
+ in a run-time module
356
+ INPUTS : 1) Pointer to new class hash table
357
+ 2) Pointer to new slot name table
358
+ RETURNS : Nothing useful
359
+ SIDE EFFECTS : Global pointers set
360
+ NOTES : None
361
+ ***************************************************/
362
+ void ObjectsRunTimeInitialize(
363
+ Environment *theEnv,
364
+ Defclass *ctable[],
365
+ SLOT_NAME *sntable[],
366
+ Defclass **cidmap,
367
+ unsigned short mid)
368
+ {
369
+ Defclass *cls;
370
+ void *tmpexp;
371
+ unsigned int i,j;
372
+
373
+ if (DefclassData(theEnv)->ClassTable != NULL)
374
+ {
375
+ for (j = 0 ; j < CLASS_TABLE_HASH_SIZE ; j++)
376
+ for (cls = DefclassData(theEnv)->ClassTable[j] ; cls != NULL ; cls = cls->nxtHash)
377
+ {
378
+ for (i = 0 ; i < cls->slotCount ; i++)
379
+ {
380
+ /* =====================================================================
381
+ For static default values, the data object value needs to deinstalled
382
+ and deallocated, and the expression needs to be restored (which was
383
+ temporarily stored in the supplementalInfo field of the data object)
384
+ ===================================================================== */
385
+ if ((cls->slots[i].defaultValue != NULL) && (cls->slots[i].dynamicDefault == 0))
386
+ {
387
+ UDFValue *theValue = (UDFValue *) cls->slots[i].defaultValue;
388
+ tmpexp = theValue->supplementalInfo;
389
+ ReleaseUDFV(theEnv,theValue);
390
+ if (theValue->header->type == MULTIFIELD_TYPE)
391
+ { ReturnMultifield(theEnv,theValue->multifieldValue); }
392
+ rtn_struct(theEnv,udfValue,cls->slots[i].defaultValue);
393
+ cls->slots[i].defaultValue = tmpexp;
394
+ }
395
+ }
396
+ }
397
+ }
398
+
399
+ InstanceQueryData(theEnv)->QUERY_DELIMITER_SYMBOL = FindSymbolHN(theEnv,QUERY_DELIMITER_STRING,SYMBOL_BIT);
400
+ MessageHandlerData(theEnv)->INIT_SYMBOL = FindSymbolHN(theEnv,INIT_STRING,SYMBOL_BIT);
401
+ MessageHandlerData(theEnv)->DELETE_SYMBOL = FindSymbolHN(theEnv,DELETE_STRING,SYMBOL_BIT);
402
+ MessageHandlerData(theEnv)->CREATE_SYMBOL = FindSymbolHN(theEnv,CREATE_STRING,SYMBOL_BIT);
403
+ DefclassData(theEnv)->ISA_SYMBOL = FindSymbolHN(theEnv,SUPERCLASS_RLN,SYMBOL_BIT);
404
+ DefclassData(theEnv)->NAME_SYMBOL = FindSymbolHN(theEnv,NAME_RLN,SYMBOL_BIT);
405
+
406
+ DefclassData(theEnv)->ClassTable = (Defclass **) ctable;
407
+ DefclassData(theEnv)->SlotNameTable = (SLOT_NAME **) sntable;
408
+ DefclassData(theEnv)->ClassIDMap = (Defclass **) cidmap;
409
+ DefclassData(theEnv)->MaxClassID = mid;
410
+ DefclassData(theEnv)->PrimitiveClassMap[FLOAT_TYPE] =
411
+ LookupDefclassByMdlOrScope(theEnv,FLOAT_TYPE_NAME);
412
+ DefclassData(theEnv)->PrimitiveClassMap[INTEGER_TYPE] =
413
+ LookupDefclassByMdlOrScope(theEnv,INTEGER_TYPE_NAME);
414
+ DefclassData(theEnv)->PrimitiveClassMap[STRING_TYPE] =
415
+ LookupDefclassByMdlOrScope(theEnv,STRING_TYPE_NAME);
416
+ DefclassData(theEnv)->PrimitiveClassMap[SYMBOL_TYPE] =
417
+ LookupDefclassByMdlOrScope(theEnv,SYMBOL_TYPE_NAME);
418
+ DefclassData(theEnv)->PrimitiveClassMap[MULTIFIELD_TYPE] =
419
+ LookupDefclassByMdlOrScope(theEnv,MULTIFIELD_TYPE_NAME);
420
+ DefclassData(theEnv)->PrimitiveClassMap[EXTERNAL_ADDRESS_TYPE] =
421
+ LookupDefclassByMdlOrScope(theEnv,EXTERNAL_ADDRESS_TYPE_NAME);
422
+ DefclassData(theEnv)->PrimitiveClassMap[FACT_ADDRESS_TYPE] =
423
+ LookupDefclassByMdlOrScope(theEnv,FACT_ADDRESS_TYPE_NAME);
424
+ DefclassData(theEnv)->PrimitiveClassMap[INSTANCE_NAME_TYPE] =
425
+ LookupDefclassByMdlOrScope(theEnv,INSTANCE_NAME_TYPE_NAME);
426
+ DefclassData(theEnv)->PrimitiveClassMap[INSTANCE_ADDRESS_TYPE] =
427
+ LookupDefclassByMdlOrScope(theEnv,INSTANCE_ADDRESS_TYPE_NAME);
428
+
429
+ for (j = 0 ; j < CLASS_TABLE_HASH_SIZE ; j++)
430
+ for (cls = DefclassData(theEnv)->ClassTable[j] ; cls != NULL ; cls = cls->nxtHash)
431
+ {
432
+ cls->header.env = theEnv;
433
+
434
+ for (i = 0; i < cls->handlerCount; i++)
435
+ { cls->handlers[i].header.env = theEnv; }
436
+
437
+ for (i = 0 ; i < cls->slotCount ; i++)
438
+ {
439
+ if ((cls->slots[i].defaultValue != NULL) && (cls->slots[i].dynamicDefault == 0))
440
+ {
441
+ tmpexp = cls->slots[i].defaultValue;
442
+ cls->slots[i].defaultValue = get_struct(theEnv,udfValue);
443
+ EvaluateAndStoreInDataObject(theEnv,cls->slots[i].multiple,(Expression *) tmpexp,
444
+ (UDFValue *) cls->slots[i].defaultValue,false);
445
+ RetainUDFV(theEnv,(UDFValue *) cls->slots[i].defaultValue);
446
+ ((UDFValue *) cls->slots[i].defaultValue)->supplementalInfo = tmpexp;
447
+ }
448
+ }
449
+ }
450
+
451
+ SearchForHashedPatternNodes(theEnv,ObjectReteData(theEnv)->ObjectPatternNetworkPointer);
452
+ }
453
+
454
+ /********************************/
455
+ /* SearchForHashedPatternNodes: */
456
+ /********************************/
457
+ static void SearchForHashedPatternNodes(
458
+ Environment *theEnv,
459
+ OBJECT_PATTERN_NODE *theNode)
460
+ {
461
+ while (theNode != NULL)
462
+ {
463
+ if ((theNode->lastLevel != NULL) && (theNode->lastLevel->selector))
464
+ { AddHashedPatternNode(theEnv,theNode->lastLevel,theNode,theNode->networkTest->type,theNode->networkTest->value); }
465
+
466
+ SearchForHashedPatternNodes(theEnv,theNode->nextLevel);
467
+
468
+ theNode = theNode->rightNode;
469
+ }
470
+ }
471
+
472
+ #else
473
+
474
+ /***************************************************************
475
+ NAME : CreateSystemClasses
476
+ DESCRIPTION : Creates the built-in system classes
477
+ INPUTS : None
478
+ RETURNS : Nothing useful
479
+ SIDE EFFECTS : System classes inserted in the
480
+ class hash table
481
+ NOTES : The binary/load save indices for the primitive
482
+ types (integer, float, symbol and string,
483
+ multifield, external-address and fact-address)
484
+ are very important. Need to be able to refer
485
+ to types with the same index regardless of
486
+ whether the object system is installed or
487
+ not. Thus, the bsave/blaod indices of these
488
+ classes match their integer codes.
489
+ WARNING!!: Assumes no classes exist yet!
490
+ ***************************************************************/
491
+ void CreateSystemClasses(
492
+ Environment *theEnv,
493
+ void *context)
494
+ {
495
+ Defclass *user,*any,*primitive,*number,*lexeme,*address,*instance;
496
+
497
+ /* ===================================
498
+ Add canonical slot name entries for
499
+ the is-a and name fields - used for
500
+ object patterns
501
+ =================================== */
502
+ AddSlotName(theEnv,DefclassData(theEnv)->ISA_SYMBOL,ISA_ID,true);
503
+ AddSlotName(theEnv,DefclassData(theEnv)->NAME_SYMBOL,NAME_ID,true);
504
+
505
+ DefclassData(theEnv)->newSlotID = 2; // IS_A and NAME assigned 0 and 1
506
+
507
+ /* =========================================================
508
+ Bsave Indices for non-primitive classes start at 9
509
+ Object is 9, Primitive is 10, Number is 11,
510
+ Lexeme is 12, Address is 13, and Instance is 14.
511
+ because: float = 0, integer = 1, symbol = 2, string = 3,
512
+ multifield = 4, and external-address = 5 and
513
+ fact-address = 6, instance-adress = 7 and
514
+ instance-name = 8.
515
+ ========================================================= */
516
+ any = AddSystemClass(theEnv,OBJECT_TYPE_NAME,NULL);
517
+ primitive = AddSystemClass(theEnv,PRIMITIVE_TYPE_NAME,any);
518
+ user = AddSystemClass(theEnv,USER_TYPE_NAME,any);
519
+
520
+ number = AddSystemClass(theEnv,NUMBER_TYPE_NAME,primitive);
521
+ DefclassData(theEnv)->PrimitiveClassMap[INTEGER_TYPE] = AddSystemClass(theEnv,INTEGER_TYPE_NAME,number);
522
+ DefclassData(theEnv)->PrimitiveClassMap[FLOAT_TYPE] = AddSystemClass(theEnv,FLOAT_TYPE_NAME,number);
523
+ lexeme = AddSystemClass(theEnv,LEXEME_TYPE_NAME,primitive);
524
+ DefclassData(theEnv)->PrimitiveClassMap[SYMBOL_TYPE] = AddSystemClass(theEnv,SYMBOL_TYPE_NAME,lexeme);
525
+ DefclassData(theEnv)->PrimitiveClassMap[STRING_TYPE] = AddSystemClass(theEnv,STRING_TYPE_NAME,lexeme);
526
+ DefclassData(theEnv)->PrimitiveClassMap[MULTIFIELD_TYPE] = AddSystemClass(theEnv,MULTIFIELD_TYPE_NAME,primitive);
527
+ address = AddSystemClass(theEnv,ADDRESS_TYPE_NAME,primitive);
528
+ DefclassData(theEnv)->PrimitiveClassMap[EXTERNAL_ADDRESS_TYPE] = AddSystemClass(theEnv,EXTERNAL_ADDRESS_TYPE_NAME,address);
529
+ DefclassData(theEnv)->PrimitiveClassMap[FACT_ADDRESS_TYPE] = AddSystemClass(theEnv,FACT_ADDRESS_TYPE_NAME,address);
530
+ instance = AddSystemClass(theEnv,INSTANCE_TYPE_NAME,primitive);
531
+ DefclassData(theEnv)->PrimitiveClassMap[INSTANCE_ADDRESS_TYPE] = AddSystemClass(theEnv,INSTANCE_ADDRESS_TYPE_NAME,instance);
532
+ DefclassData(theEnv)->PrimitiveClassMap[INSTANCE_NAME_TYPE] = AddSystemClass(theEnv,INSTANCE_NAME_TYPE_NAME,instance);
533
+
534
+ /* ================================================================================
535
+ INSTANCE-ADDRESS is-a INSTANCE and ADDRESS. The links between INSTANCE-ADDRESS
536
+ and ADDRESS still need to be made.
537
+ =============================================================================== */
538
+ AddClassLink(theEnv,&DefclassData(theEnv)->PrimitiveClassMap[INSTANCE_ADDRESS_TYPE]->directSuperclasses,address,true,0);
539
+ AddClassLink(theEnv,&DefclassData(theEnv)->PrimitiveClassMap[INSTANCE_ADDRESS_TYPE]->allSuperclasses,address,false,2);
540
+ AddClassLink(theEnv,&address->directSubclasses,DefclassData(theEnv)->PrimitiveClassMap[INSTANCE_ADDRESS_TYPE],true,0);
541
+
542
+ /* =======================================================================
543
+ The order of the class in the list MUST correspond to their type codes!
544
+ See CONSTANT.H
545
+ ======================================================================= */
546
+ AddConstructToModule(&DefclassData(theEnv)->PrimitiveClassMap[FLOAT_TYPE]->header);
547
+ AddConstructToModule(&DefclassData(theEnv)->PrimitiveClassMap[INTEGER_TYPE]->header);
548
+ AddConstructToModule(&DefclassData(theEnv)->PrimitiveClassMap[SYMBOL_TYPE]->header);
549
+ AddConstructToModule(&DefclassData(theEnv)->PrimitiveClassMap[STRING_TYPE]->header);
550
+ AddConstructToModule(&DefclassData(theEnv)->PrimitiveClassMap[MULTIFIELD_TYPE]->header);
551
+ AddConstructToModule(&DefclassData(theEnv)->PrimitiveClassMap[EXTERNAL_ADDRESS_TYPE]->header);
552
+ AddConstructToModule(&DefclassData(theEnv)->PrimitiveClassMap[FACT_ADDRESS_TYPE]->header);
553
+ AddConstructToModule(&DefclassData(theEnv)->PrimitiveClassMap[INSTANCE_ADDRESS_TYPE]->header);
554
+ AddConstructToModule(&DefclassData(theEnv)->PrimitiveClassMap[INSTANCE_NAME_TYPE]->header);
555
+ AddConstructToModule(&any->header);
556
+ AddConstructToModule(&primitive->header);
557
+ AddConstructToModule(&number->header);
558
+ AddConstructToModule(&lexeme->header);
559
+ AddConstructToModule(&address->header);
560
+ AddConstructToModule(&instance->header);
561
+ AddConstructToModule(&user->header);
562
+
563
+ for (any = GetNextDefclass(theEnv,NULL) ;
564
+ any != NULL ;
565
+ any = GetNextDefclass(theEnv,any))
566
+ AssignClassID(theEnv,any);
567
+ }
568
+
569
+ #endif
570
+
571
+ /* =========================================
572
+ *****************************************
573
+ INTERNALLY VISIBLE FUNCTIONS
574
+ =========================================
575
+ ***************************************** */
576
+
577
+ /*********************************************************
578
+ NAME : SetupDefclasses
579
+ DESCRIPTION : Initializes Class Hash Table,
580
+ Function Parsers, and Data Structures
581
+ INPUTS : None
582
+ RETURNS : Nothing useful
583
+ SIDE EFFECTS :
584
+ NOTES : None
585
+ *********************************************************/
586
+ static void SetupDefclasses(
587
+ Environment *theEnv)
588
+ {
589
+ InstallPrimitive(theEnv,&DefclassData(theEnv)->DefclassEntityRecord,DEFCLASS_PTR);
590
+
591
+ DefclassData(theEnv)->DefclassModuleIndex =
592
+ RegisterModuleItem(theEnv,"defclass",
593
+ #if (! RUN_TIME)
594
+ AllocateModule,
595
+ ReturnModule,
596
+ #else
597
+ NULL,NULL,
598
+ #endif
599
+ #if BLOAD_AND_BSAVE || BLOAD || BLOAD_ONLY
600
+ BloadDefclassModuleReference,
601
+ #else
602
+ NULL,
603
+ #endif
604
+ #if CONSTRUCT_COMPILER && (! RUN_TIME)
605
+ DefclassCModuleReference,
606
+ #else
607
+ NULL,
608
+ #endif
609
+ (FindConstructFunction *) FindDefclassInModule);
610
+
611
+ DefclassData(theEnv)->DefclassConstruct = AddConstruct(theEnv,"defclass","defclasses",
612
+ #if (! BLOAD_ONLY) && (! RUN_TIME)
613
+ ParseDefclass,
614
+ #else
615
+ NULL,
616
+ #endif
617
+ (FindConstructFunction *) FindDefclass,
618
+ GetConstructNamePointer,GetConstructPPForm,
619
+ GetConstructModuleItem,
620
+ (GetNextConstructFunction *) GetNextDefclass,
621
+ SetNextConstruct,
622
+ (IsConstructDeletableFunction *) DefclassIsDeletable,
623
+ (DeleteConstructFunction *) Undefclass,
624
+ #if (! RUN_TIME)
625
+ (FreeConstructFunction *) RemoveDefclass
626
+ #else
627
+ NULL
628
+ #endif
629
+ );
630
+
631
+ AddClearReadyFunction(theEnv,"defclass",InstancesPurge,0,NULL);
632
+
633
+ #if ! RUN_TIME
634
+ AddClearFunction(theEnv,"defclass",CreateSystemClasses,0,NULL);
635
+ InitializeClasses(theEnv);
636
+
637
+ #if ! BLOAD_ONLY
638
+ #if DEFMODULE_CONSTRUCT
639
+ AddPortConstructItem(theEnv,"defclass",SYMBOL_TOKEN);
640
+ AddAfterModuleDefinedFunction(theEnv,"defclass",UpdateDefclassesScope,0,NULL);
641
+ #endif
642
+ AddUDF(theEnv,"undefclass","v",1,1,"y",UndefclassCommand,"UndefclassCommand",NULL);
643
+
644
+ AddSaveFunction(theEnv,"defclass",SaveDefclasses,10,NULL);
645
+ #endif
646
+
647
+ #if DEBUGGING_FUNCTIONS
648
+ AddUDF(theEnv,"list-defclasses","v",0,1,"y",ListDefclassesCommand,"ListDefclassesCommand",NULL);
649
+ AddUDF(theEnv,"ppdefclass","vs",1,2,";y;ldsyn",PPDefclassCommand,"PPDefclassCommand",NULL);
650
+ AddUDF(theEnv,"describe-class","v",1,1,"y",DescribeClassCommand,"DescribeClassCommand",NULL);
651
+ AddUDF(theEnv,"browse-classes","v",0,1,"y",BrowseClassesCommand,"BrowseClassesCommand",NULL);
652
+ #endif
653
+
654
+ AddUDF(theEnv,"get-defclass-list","m",0,1,"y",GetDefclassListFunction,"GetDefclassListFunction",NULL);
655
+ AddUDF(theEnv,"superclassp","b",2,2,"y",SuperclassPCommand,"SuperclassPCommand",NULL);
656
+ AddUDF(theEnv,"subclassp","b",2,2,"y",SubclassPCommand,"SubclassPCommand",NULL);
657
+ AddUDF(theEnv,"class-existp","b", 1,1,"y",ClassExistPCommand,"ClassExistPCommand",NULL);
658
+ AddUDF(theEnv,"message-handler-existp","b",2,3,"y",MessageHandlerExistPCommand,"MessageHandlerExistPCommand",NULL);
659
+ AddUDF(theEnv,"class-abstractp","b",1,1,"y",ClassAbstractPCommand,"ClassAbstractPCommand",NULL);
660
+ #if DEFRULE_CONSTRUCT
661
+ AddUDF(theEnv,"class-reactivep","b",1,1,"y",ClassReactivePCommand,"ClassReactivePCommand",NULL);
662
+ #endif
663
+ AddUDF(theEnv,"class-slots","m",1,2,"y",ClassSlotsCommand,"ClassSlotsCommand",NULL);
664
+ AddUDF(theEnv,"class-superclasses","m",1,2,"y",ClassSuperclassesCommand,"ClassSuperclassesCommand",NULL);
665
+ AddUDF(theEnv,"class-subclasses","m",1,2,"y",ClassSubclassesCommand,"ClassSubclassesCommand",NULL);
666
+ AddUDF(theEnv,"get-defmessage-handler-list","m",0,2,"y",GetDefmessageHandlersListCmd,"GetDefmessageHandlersListCmd",NULL);
667
+ AddUDF(theEnv,"slot-existp","b",2,3,"y",SlotExistPCommand,"SlotExistPCommand",NULL);
668
+ AddUDF(theEnv,"slot-facets","m",2,2,"y",SlotFacetsCommand,"SlotFacetsCommand",NULL);
669
+ AddUDF(theEnv,"slot-sources","m",2,2,"y",SlotSourcesCommand,"SlotSourcesCommand",NULL);
670
+ AddUDF(theEnv,"slot-types","m",2,2,"y",SlotTypesCommand,"SlotTypesCommand",NULL);
671
+ AddUDF(theEnv,"slot-allowed-values","m",2,2,"y",SlotAllowedValuesCommand,"SlotAllowedValuesCommand",NULL);
672
+ AddUDF(theEnv,"slot-allowed-classes","m",2,2,"y",SlotAllowedClassesCommand,"SlotAllowedClassesCommand",NULL);
673
+ AddUDF(theEnv,"slot-range","m",2,2,"y",SlotRangeCommand,"SlotRangeCommand",NULL);
674
+ AddUDF(theEnv,"slot-cardinality","m",2,2,"y",SlotCardinalityCommand,"SlotCardinalityCommand",NULL);
675
+ AddUDF(theEnv,"slot-writablep","b",2,2,"y",SlotWritablePCommand,"SlotWritablePCommand",NULL);
676
+ AddUDF(theEnv,"slot-initablep","b",2,2,"y",SlotInitablePCommand,"SlotInitablePCommand",NULL);
677
+ AddUDF(theEnv,"slot-publicp","b",2,2,"y",SlotPublicPCommand,"SlotPublicPCommand",NULL);
678
+ AddUDF(theEnv,"slot-direct-accessp","b",2,2,"y",SlotDirectAccessPCommand,"SlotDirectAccessPCommand",NULL);
679
+ AddUDF(theEnv,"slot-default-value","*",2,2,"y",SlotDefaultValueCommand,"SlotDefaultValueCommand",NULL);
680
+ AddUDF(theEnv,"defclass-module","y",1,1,"y",GetDefclassModuleCommand,"GetDefclassModuleCommand",NULL);
681
+ AddUDF(theEnv,"get-class-defaults-mode","y",0,0,NULL,GetClassDefaultsModeCommand,"GetClassDefaultsModeCommand",NULL);
682
+ AddUDF(theEnv,"set-class-defaults-mode","y",1,1,"y",SetClassDefaultsModeCommand,"SetClassDefaultsModeCommand",NULL);
683
+ #endif
684
+
685
+ #if DEBUGGING_FUNCTIONS
686
+ AddWatchItem(theEnv,"instances",0,&DefclassData(theEnv)->WatchInstances,75,DefclassWatchAccess,DefclassWatchPrint);
687
+ AddWatchItem(theEnv,"slots",1,&DefclassData(theEnv)->WatchSlots,74,DefclassWatchAccess,DefclassWatchPrint);
688
+ #endif
689
+ }
690
+
691
+ #if (! RUN_TIME)
692
+
693
+ /*********************************************************
694
+ NAME : AddSystemClass
695
+ DESCRIPTION : Performs all necessary allocations
696
+ for adding a system class
697
+ INPUTS : 1) The name-string of the system class
698
+ 2) The address of the parent class
699
+ (NULL if none)
700
+ RETURNS : The address of the new system class
701
+ SIDE EFFECTS : Allocations performed
702
+ NOTES : Assumes system-class name is unique
703
+ Also assumes SINGLE INHERITANCE for
704
+ system classes to simplify precedence
705
+ list determination
706
+ Adds classes to has table but NOT to
707
+ class list (this is responsibility
708
+ of caller)
709
+ *********************************************************/
710
+ static Defclass *AddSystemClass(
711
+ Environment *theEnv,
712
+ const char *name,
713
+ Defclass *parent)
714
+ {
715
+ Defclass *sys;
716
+ unsigned long i;
717
+ char defaultScopeMap[1];
718
+
719
+ sys = NewClass(theEnv,CreateSymbol(theEnv,name));
720
+ sys->abstract = 1;
721
+ #if DEFRULE_CONSTRUCT
722
+ sys->reactive = 0;
723
+ #endif
724
+ IncrementLexemeCount(sys->header.name);
725
+ sys->installed = 1;
726
+ sys->system = 1;
727
+ sys->hashTableIndex = HashClass(sys->header.name);
728
+
729
+ AddClassLink(theEnv,&sys->allSuperclasses,sys,true,0);
730
+ if (parent != NULL)
731
+ {
732
+ AddClassLink(theEnv,&sys->directSuperclasses,parent,true,0);
733
+ AddClassLink(theEnv,&parent->directSubclasses,sys,true,0);
734
+ AddClassLink(theEnv,&sys->allSuperclasses,parent,true,0);
735
+ for (i = 1 ; i < parent->allSuperclasses.classCount ; i++)
736
+ AddClassLink(theEnv,&sys->allSuperclasses,parent->allSuperclasses.classArray[i],true,0);
737
+ }
738
+ sys->nxtHash = DefclassData(theEnv)->ClassTable[sys->hashTableIndex];
739
+ DefclassData(theEnv)->ClassTable[sys->hashTableIndex] = sys;
740
+
741
+ /* =========================================
742
+ Add default scope maps for a system class
743
+ There is only one module (MAIN) so far -
744
+ which has an id of 0
745
+ ========================================= */
746
+ ClearBitString(defaultScopeMap,sizeof(char));
747
+ SetBitMap(defaultScopeMap,0);
748
+ #if DEFMODULE_CONSTRUCT
749
+ sys->scopeMap = (CLIPSBitMap *) AddBitMap(theEnv,defaultScopeMap,sizeof(char));
750
+ IncrementBitMapCount(sys->scopeMap);
751
+ #endif
752
+ return(sys);
753
+ }
754
+
755
+ /*****************************************************
756
+ NAME : AllocateModule
757
+ DESCRIPTION : Creates and initializes a
758
+ list of defclasses for a new module
759
+ INPUTS : None
760
+ RETURNS : The new defclass module
761
+ SIDE EFFECTS : Defclass module created
762
+ NOTES : None
763
+ *****************************************************/
764
+ static void *AllocateModule(
765
+ Environment *theEnv)
766
+ {
767
+ return (void *) get_struct(theEnv,defclassModule);
768
+ }
769
+
770
+ /***************************************************
771
+ NAME : ReturnModule
772
+ DESCRIPTION : Removes a defclass module and
773
+ all associated defclasses
774
+ INPUTS : The defclass module
775
+ RETURNS : Nothing useful
776
+ SIDE EFFECTS : Module and defclasses deleted
777
+ NOTES : None
778
+ ***************************************************/
779
+ static void ReturnModule(
780
+ Environment *theEnv,
781
+ void *theItem)
782
+ {
783
+ FreeConstructHeaderModule(theEnv,(struct defmoduleItemHeader *) theItem,DefclassData(theEnv)->DefclassConstruct);
784
+ DeleteSlotName(theEnv,FindIDSlotNameHash(theEnv,ISA_ID));
785
+ DeleteSlotName(theEnv,FindIDSlotNameHash(theEnv,NAME_ID));
786
+ rtn_struct(theEnv,defclassModule,theItem);
787
+ }
788
+
789
+ #endif
790
+
791
+ #if (! BLOAD_ONLY) && (! RUN_TIME) && DEFMODULE_CONSTRUCT
792
+
793
+ /***************************************************
794
+ NAME : UpdateDefclassesScope
795
+ DESCRIPTION : This function updates the scope
796
+ bitmaps for existing classes when
797
+ a new module is defined
798
+ INPUTS : None
799
+ RETURNS : Nothing
800
+ SIDE EFFECTS : Class scope bitmaps are updated
801
+ NOTES : None
802
+ ***************************************************/
803
+ static void UpdateDefclassesScope(
804
+ Environment *theEnv,
805
+ void *context)
806
+ {
807
+ unsigned i;
808
+ Defclass *theDefclass;
809
+ unsigned long newModuleID;
810
+ unsigned int count;
811
+ char *newScopeMap;
812
+ unsigned short newScopeMapSize;
813
+ const char *className;
814
+ Defmodule *matchModule;
815
+
816
+ newModuleID = GetCurrentModule(theEnv)->header.bsaveID;
817
+ newScopeMapSize = (sizeof(char) * ((GetNumberOfDefmodules(theEnv) / BITS_PER_BYTE) + 1));
818
+ newScopeMap = (char *) gm2(theEnv,newScopeMapSize);
819
+ for (i = 0 ; i < CLASS_TABLE_HASH_SIZE ; i++)
820
+ for (theDefclass = DefclassData(theEnv)->ClassTable[i] ;
821
+ theDefclass != NULL ;
822
+ theDefclass = theDefclass->nxtHash)
823
+ {
824
+ matchModule = theDefclass->header.whichModule->theModule;
825
+ className = theDefclass->header.name->contents;
826
+ ClearBitString(newScopeMap,newScopeMapSize);
827
+ GenCopyMemory(char,theDefclass->scopeMap->size,
828
+ newScopeMap,theDefclass->scopeMap->contents);
829
+ DecrementBitMapReferenceCount(theEnv,theDefclass->scopeMap);
830
+ if (theDefclass->system)
831
+ SetBitMap(newScopeMap,newModuleID);
832
+ else if (FindImportedConstruct(theEnv,"defclass",matchModule,
833
+ className,&count,true,NULL) != NULL)
834
+ SetBitMap(newScopeMap,newModuleID);
835
+ theDefclass->scopeMap = (CLIPSBitMap *) AddBitMap(theEnv,newScopeMap,newScopeMapSize);
836
+ IncrementBitMapCount(theDefclass->scopeMap);
837
+ }
838
+ rm(theEnv,newScopeMap,newScopeMapSize);
839
+ }
840
+
841
+ #endif
842
+
843
+ #endif