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,1245 @@
1
+ /*******************************************************/
2
+ /* "C" Language Integrated Production System */
3
+ /* */
4
+ /* CLIPS Version 6.40 08/25/16 */
5
+ /* */
6
+ /* CLASS INFO PROGRAMMATIC ACCESS MODULE */
7
+ /*******************************************************/
8
+
9
+ /**************************************************************/
10
+ /* Purpose: Class Information Interface Support Routines */
11
+ /* */
12
+ /* Principal Programmer(s): */
13
+ /* Brian L. Dantes */
14
+ /* */
15
+ /* Contributing Programmer(s): */
16
+ /* */
17
+ /* Revision History: */
18
+ /* */
19
+ /* 6.23: Correction for FalseSymbol/TrueSymbol. DR0859 */
20
+ /* */
21
+ /* Changed name of variable exp to theExp */
22
+ /* because of Unix compiler warnings of shadowed */
23
+ /* definitions. */
24
+ /* */
25
+ /* 6.24: Added allowed-classes slot facet. */
26
+ /* */
27
+ /* Converted INSTANCE_PATTERN_MATCHING to */
28
+ /* DEFRULE_CONSTRUCT. */
29
+ /* */
30
+ /* Renamed BOOLEAN macro type to intBool. */
31
+ /* */
32
+ /* 6.30: Borland C (IBM_TBC) and Metrowerks CodeWarrior */
33
+ /* (MAC_MCW, IBM_MCW) are no longer supported. */
34
+ /* */
35
+ /* Changed integer type/precision. */
36
+ /* */
37
+ /* Added const qualifiers to remove C++ */
38
+ /* deprecation warnings. */
39
+ /* */
40
+ /* Converted API macros to function calls. */
41
+ /* */
42
+ /* 6.40: Added Env prefix to GetEvaluationError and */
43
+ /* SetEvaluationError functions. */
44
+ /* */
45
+ /* Pragma once and other inclusion changes. */
46
+ /* */
47
+ /* Added support for booleans with <stdbool.h>. */
48
+ /* */
49
+ /* Removed use of void pointers for specific */
50
+ /* data structures. */
51
+ /* */
52
+ /* ALLOW_ENVIRONMENT_GLOBALS no longer supported. */
53
+ /* */
54
+ /* UDF redesign. */
55
+ /* */
56
+ /**************************************************************/
57
+
58
+ /* =========================================
59
+ *****************************************
60
+ EXTERNAL DEFINITIONS
61
+ =========================================
62
+ ***************************************** */
63
+ #include "setup.h"
64
+
65
+ #if OBJECT_SYSTEM
66
+
67
+ #include <stdio.h>
68
+ #include <string.h>
69
+
70
+ #include "argacces.h"
71
+ #include "classcom.h"
72
+ #include "classexm.h"
73
+ #include "classfun.h"
74
+ #include "classini.h"
75
+ #include "envrnmnt.h"
76
+ #include "memalloc.h"
77
+ #include "insfun.h"
78
+ #include "msgcom.h"
79
+ #include "msgfun.h"
80
+ #include "multifld.h"
81
+ #include "prntutil.h"
82
+
83
+ #include "classinf.h"
84
+
85
+ /***************************************/
86
+ /* LOCAL INTERNAL FUNCTION DEFINITIONS */
87
+ /***************************************/
88
+
89
+ static void SlotInfoSupportFunction(UDFContext *,UDFValue *,const char *,bool (*)(Defclass *,const char *,CLIPSValue *));
90
+ static unsigned CountSubclasses(Defclass *,bool,int);
91
+ static unsigned StoreSubclasses(Multifield *,unsigned,Defclass *,int,int,bool);
92
+ static SlotDescriptor *SlotInfoSlot(Environment *,UDFValue *,Defclass *,const char *,const char *);
93
+
94
+ /*********************************************************************
95
+ NAME : ClassAbstractPCommand
96
+ DESCRIPTION : Determines if direct instances of a class can be made
97
+ INPUTS : None
98
+ RETURNS : True (1) if class is abstract, false (0) if concrete
99
+ SIDE EFFECTS : None
100
+ NOTES : Syntax: (class-abstractp <class>)
101
+ *********************************************************************/
102
+ void ClassAbstractPCommand(
103
+ Environment *theEnv,
104
+ UDFContext *context,
105
+ UDFValue *returnValue)
106
+ {
107
+ UDFValue theArg;
108
+ Defclass *cls;
109
+
110
+ if (! UDFFirstArgument(context,SYMBOL_BIT,&theArg))
111
+ { return; }
112
+
113
+ cls = LookupDefclassByMdlOrScope(theEnv,theArg.lexemeValue->contents);
114
+ if (cls == NULL)
115
+ {
116
+ ClassExistError(theEnv,"class-abstractp",theArg.lexemeValue->contents);
117
+ returnValue->lexemeValue = FalseSymbol(theEnv);
118
+ return;
119
+ }
120
+
121
+ returnValue->lexemeValue = CreateBoolean(theEnv,(ClassAbstractP(cls)));
122
+ }
123
+
124
+ #if DEFRULE_CONSTRUCT
125
+
126
+ /*****************************************************************
127
+ NAME : ClassReactivePCommand
128
+ DESCRIPTION : Determines if instances of a class can match rule
129
+ patterns
130
+ INPUTS : None
131
+ RETURNS : True (1) if class is reactive, false (0)
132
+ if non-reactive
133
+ SIDE EFFECTS : None
134
+ NOTES : Syntax: (class-reactivep <class>)
135
+ *****************************************************************/
136
+ void ClassReactivePCommand(
137
+ Environment *theEnv,
138
+ UDFContext *context,
139
+ UDFValue *returnValue)
140
+ {
141
+ UDFValue theArg;
142
+ Defclass *cls;
143
+
144
+ if (! UDFFirstArgument(context,SYMBOL_BIT,&theArg))
145
+ { return; }
146
+
147
+ cls = LookupDefclassByMdlOrScope(theEnv,theArg.lexemeValue->contents);
148
+ if (cls == NULL)
149
+ {
150
+ ClassExistError(theEnv,"class-reactivep",theArg.lexemeValue->contents);
151
+ returnValue->lexemeValue = FalseSymbol(theEnv);
152
+ return;
153
+ }
154
+
155
+ returnValue->lexemeValue = CreateBoolean(theEnv,ClassReactiveP(cls));
156
+ }
157
+
158
+ #endif
159
+
160
+ /***********************************************************
161
+ NAME : ClassInfoFnxArgs
162
+ DESCRIPTION : Examines arguments for:
163
+ class-slots, get-defmessage-handler-list,
164
+ class-superclasses and class-subclasses
165
+ INPUTS : 1) Name of function
166
+ 2) A buffer to hold a flag indicating if
167
+ the inherit keyword was specified
168
+ RETURNS : Pointer to the class on success,
169
+ NULL on errors
170
+ SIDE EFFECTS : inhp flag set
171
+ error flag set
172
+ NOTES : None
173
+ ***********************************************************/
174
+ Defclass *ClassInfoFnxArgs(
175
+ UDFContext *context,
176
+ const char *fnx,
177
+ bool *inhp)
178
+ {
179
+ Defclass *clsptr;
180
+ UDFValue theArg;
181
+ Environment *theEnv = context->environment;
182
+
183
+ *inhp = false;
184
+
185
+ if (! UDFFirstArgument(context,SYMBOL_BIT,&theArg))
186
+ { return NULL; }
187
+
188
+ clsptr = LookupDefclassByMdlOrScope(theEnv,theArg.lexemeValue->contents);
189
+ if (clsptr == NULL)
190
+ {
191
+ ClassExistError(theEnv,fnx,theArg.lexemeValue->contents);
192
+ return NULL;
193
+ }
194
+
195
+ if (UDFHasNextArgument(context))
196
+ {
197
+ if (! UDFNextArgument(context,SYMBOL_BIT,&theArg))
198
+ { return NULL; }
199
+
200
+ if (strcmp(theArg.lexemeValue->contents,"inherit") == 0)
201
+ { *inhp = true; }
202
+ else
203
+ {
204
+ SyntaxErrorMessage(theEnv,fnx);
205
+ SetEvaluationError(theEnv,true);
206
+ return NULL;
207
+ }
208
+ }
209
+
210
+ return clsptr;
211
+ }
212
+
213
+ /********************************************************************
214
+ NAME : ClassSlotsCommand
215
+ DESCRIPTION : Groups slot info for a class into a multifield value
216
+ for dynamic perusal
217
+ INPUTS : Data object buffer to hold the slots of the class
218
+ RETURNS : Nothing useful
219
+ SIDE EFFECTS : Creates a multifield storing the names of
220
+ the slots of the class
221
+ NOTES : Syntax: (class-slots <class> [inherit])
222
+ ********************************************************************/
223
+ void ClassSlotsCommand(
224
+ Environment *theEnv,
225
+ UDFContext *context,
226
+ UDFValue *returnValue)
227
+ {
228
+ bool inhp;
229
+ Defclass *clsptr;
230
+ CLIPSValue result;
231
+
232
+ clsptr = ClassInfoFnxArgs(context,"class-slots",&inhp);
233
+ if (clsptr == NULL)
234
+ {
235
+ SetMultifieldErrorValue(theEnv,returnValue);
236
+ return;
237
+ }
238
+ ClassSlots(clsptr,&result,inhp);
239
+ CLIPSToUDFValue(&result,returnValue);
240
+ }
241
+
242
+ /************************************************************************
243
+ NAME : ClassSuperclassesCommand
244
+ DESCRIPTION : Groups superclasses for a class into a multifield value
245
+ for dynamic perusal
246
+ INPUTS : Data object buffer to hold the superclasses of the class
247
+ RETURNS : Nothing useful
248
+ SIDE EFFECTS : Creates a multifield storing the names of
249
+ the superclasses of the class
250
+ NOTES : Syntax: (class-superclasses <class> [inherit])
251
+ ************************************************************************/
252
+ void ClassSuperclassesCommand(
253
+ Environment *theEnv,
254
+ UDFContext *context,
255
+ UDFValue *returnValue)
256
+ {
257
+ bool inhp;
258
+ Defclass *clsptr;
259
+ CLIPSValue result;
260
+
261
+ clsptr = ClassInfoFnxArgs(context,"class-superclasses",&inhp);
262
+ if (clsptr == NULL)
263
+ {
264
+ SetMultifieldErrorValue(theEnv,returnValue);
265
+ return;
266
+ }
267
+ ClassSuperclasses(clsptr,&result,inhp);
268
+ CLIPSToUDFValue(&result,returnValue);
269
+ }
270
+
271
+ /************************************************************************
272
+ NAME : ClassSubclassesCommand
273
+ DESCRIPTION : Groups subclasses for a class into a multifield value
274
+ for dynamic perusal
275
+ INPUTS : Data object buffer to hold the subclasses of the class
276
+ RETURNS : Nothing useful
277
+ SIDE EFFECTS : Creates a multifield storing the names of
278
+ the subclasses of the class
279
+ NOTES : Syntax: (class-subclasses <class> [inherit])
280
+ ************************************************************************/
281
+ void ClassSubclassesCommand(
282
+ Environment *theEnv,
283
+ UDFContext *context,
284
+ UDFValue *returnValue)
285
+ {
286
+ bool inhp;
287
+ Defclass *clsptr;
288
+ CLIPSValue result;
289
+
290
+ clsptr = ClassInfoFnxArgs(context,"class-subclasses",&inhp);
291
+ if (clsptr == NULL)
292
+ {
293
+ SetMultifieldErrorValue(theEnv,returnValue);
294
+ return;
295
+ }
296
+ ClassSubclasses(clsptr,&result,inhp);
297
+ CLIPSToUDFValue(&result,returnValue);
298
+ }
299
+
300
+ /***********************************************************************
301
+ NAME : GetDefmessageHandlersListCmd
302
+ DESCRIPTION : Groups message-handlers for a class into a multifield
303
+ value for dynamic perusal
304
+ INPUTS : Data object buffer to hold the handlers of the class
305
+ RETURNS : Nothing useful
306
+ SIDE EFFECTS : Creates a multifield storing the names of
307
+ the message-handlers of the class
308
+ NOTES : Syntax: (get-defmessage-handler-list <class> [inherit])
309
+ ***********************************************************************/
310
+ void GetDefmessageHandlersListCmd(
311
+ Environment *theEnv,
312
+ UDFContext *context,
313
+ UDFValue *returnValue)
314
+ {
315
+ bool inhp;
316
+ Defclass *clsptr;
317
+ CLIPSValue result;
318
+
319
+ if (! UDFHasNextArgument(context))
320
+ {
321
+ GetDefmessageHandlerList(theEnv,NULL,&result,false);
322
+ CLIPSToUDFValue(&result,returnValue);
323
+ }
324
+ else
325
+ {
326
+ clsptr = ClassInfoFnxArgs(context,"get-defmessage-handler-list",&inhp);
327
+ if (clsptr == NULL)
328
+ {
329
+ SetMultifieldErrorValue(theEnv,returnValue);
330
+ return;
331
+ }
332
+
333
+ GetDefmessageHandlerList(theEnv,clsptr,&result,inhp);
334
+ CLIPSToUDFValue(&result,returnValue);
335
+ }
336
+ }
337
+
338
+ /*********************************
339
+ Slot Information Access Functions
340
+ *********************************/
341
+ void SlotFacetsCommand(
342
+ Environment *theEnv,
343
+ UDFContext *context,
344
+ UDFValue *returnValue)
345
+ {
346
+ SlotInfoSupportFunction(context,returnValue,"slot-facets",SlotFacets);
347
+ }
348
+
349
+ void SlotSourcesCommand(
350
+ Environment *theEnv,
351
+ UDFContext *context,
352
+ UDFValue *returnValue)
353
+ {
354
+ SlotInfoSupportFunction(context,returnValue,"slot-sources",SlotSources);
355
+ }
356
+
357
+ void SlotTypesCommand(
358
+ Environment *theEnv,
359
+ UDFContext *context,
360
+ UDFValue *returnValue)
361
+ {
362
+ SlotInfoSupportFunction(context,returnValue,"slot-types",SlotTypes);
363
+ }
364
+
365
+ void SlotAllowedValuesCommand(
366
+ Environment *theEnv,
367
+ UDFContext *context,
368
+ UDFValue *returnValue)
369
+ {
370
+ SlotInfoSupportFunction(context,returnValue,"slot-allowed-values",SlotAllowedValues);
371
+ }
372
+
373
+ void SlotAllowedClassesCommand(
374
+ Environment *theEnv,
375
+ UDFContext *context,
376
+ UDFValue *returnValue)
377
+ {
378
+ SlotInfoSupportFunction(context,returnValue,"slot-allowed-classes",SlotAllowedClasses);
379
+ }
380
+
381
+ void SlotRangeCommand(
382
+ Environment *theEnv,
383
+ UDFContext *context,
384
+ UDFValue *returnValue)
385
+ {
386
+ SlotInfoSupportFunction(context,returnValue,"slot-range",SlotRange);
387
+ }
388
+
389
+ void SlotCardinalityCommand(
390
+ Environment *theEnv,
391
+ UDFContext *context,
392
+ UDFValue *returnValue)
393
+ {
394
+ SlotInfoSupportFunction(context,returnValue,"slot-cardinality",SlotCardinality);
395
+ }
396
+
397
+ /********************************************************************
398
+ NAME : ClassAbstractP
399
+ DESCRIPTION : Determines if a class is abstract or not
400
+ INPUTS : Generic pointer to class
401
+ RETURNS : 1 if class is abstract, 0 otherwise
402
+ SIDE EFFECTS : None
403
+ NOTES : None
404
+ ********************************************************************/
405
+ bool ClassAbstractP(
406
+ Defclass *theDefclass)
407
+ {
408
+ return theDefclass->abstract;
409
+ }
410
+
411
+ #if DEFRULE_CONSTRUCT
412
+
413
+ /********************************************************************
414
+ NAME : ClassReactiveP
415
+ DESCRIPTION : Determines if a class is reactive or not
416
+ INPUTS : Generic pointer to class
417
+ RETURNS : 1 if class is reactive, 0 otherwise
418
+ SIDE EFFECTS : None
419
+ NOTES : None
420
+ ********************************************************************/
421
+ bool ClassReactiveP(
422
+ Defclass *theDefclass)
423
+ {
424
+ return theDefclass->reactive;
425
+ }
426
+
427
+ #endif
428
+
429
+ /********************************************************************
430
+ NAME : ClassSlots
431
+ DESCRIPTION : Groups slot info for a class into a multifield value
432
+ for dynamic perusal
433
+ INPUTS : 1) Generic pointer to class
434
+ 2) Data object buffer to hold the slots of the class
435
+ 3) Include (1) or exclude (0) inherited slots
436
+ RETURNS : Nothing useful
437
+ SIDE EFFECTS : Creates a multifield storing the names of
438
+ the slots of the class
439
+ NOTES : None
440
+ ********************************************************************/
441
+ void ClassSlots(
442
+ Defclass *theDefclass,
443
+ CLIPSValue *returnValue,
444
+ bool inhp)
445
+ {
446
+ size_t size;
447
+ unsigned i;
448
+ Environment *theEnv = theDefclass->header.env;
449
+
450
+ size = inhp ? theDefclass->instanceSlotCount : theDefclass->slotCount;
451
+
452
+ returnValue->value = CreateMultifield(theEnv,size);
453
+
454
+ if (size == 0)
455
+ { return; }
456
+
457
+ if (inhp)
458
+ {
459
+ for (i = 0 ; i < theDefclass->instanceSlotCount ; i++)
460
+ {
461
+ returnValue->multifieldValue->contents[i].value =
462
+ theDefclass->instanceTemplate[i]->slotName->name;
463
+ }
464
+ }
465
+ else
466
+ {
467
+ for (i = 0 ; i < theDefclass->slotCount ; i++)
468
+ {
469
+ returnValue->multifieldValue->contents[i].value =
470
+ theDefclass->slots[i].slotName->name;
471
+ }
472
+ }
473
+ }
474
+
475
+ /************************************************************************
476
+ NAME : GetDefmessageHandlerList
477
+ DESCRIPTION : Groups handler info for a class into a multifield value
478
+ for dynamic perusal
479
+ INPUTS : 1) Generic pointer to class (NULL to get handlers for
480
+ all classes)
481
+ 2) Data object buffer to hold the handlers of the class
482
+ 3) Include (1) or exclude (0) inherited handlers
483
+ RETURNS : Nothing useful
484
+ SIDE EFFECTS : Creates a multifield storing the names and types of
485
+ the message-handlers of the class
486
+ NOTES : None
487
+ ************************************************************************/
488
+ void GetDefmessageHandlerList(
489
+ Environment *theEnv,
490
+ Defclass *theDefclass,
491
+ CLIPSValue *returnValue,
492
+ bool inhp)
493
+ {
494
+ Defclass *cls,*svcls,*svnxt,*supcls;
495
+ long j;
496
+ unsigned long classi, classiLimit;
497
+ unsigned long i, sublen, len;
498
+
499
+ if (theDefclass == NULL)
500
+ {
501
+ inhp = 0;
502
+ cls = GetNextDefclass(theEnv,NULL);
503
+ svnxt = GetNextDefclass(theEnv,cls);
504
+ }
505
+ else
506
+ {
507
+ cls = theDefclass;
508
+ svnxt = GetNextDefclass(theEnv,theDefclass);
509
+ SetNextDefclass(cls,NULL);
510
+ }
511
+
512
+ for (svcls = cls , i = 0 ;
513
+ cls != NULL ;
514
+ cls = GetNextDefclass(theEnv,cls))
515
+ {
516
+ classiLimit = inhp ? cls->allSuperclasses.classCount : 1;
517
+ for (classi = 0 ; classi < classiLimit ; classi++)
518
+ { i += cls->allSuperclasses.classArray[classi]->handlerCount; }
519
+ }
520
+
521
+ len = i * 3;
522
+
523
+ returnValue->value = CreateMultifield(theEnv,len);
524
+
525
+ for (cls = svcls , sublen = 0 ;
526
+ cls != NULL ;
527
+ cls = GetNextDefclass(theEnv,cls))
528
+ {
529
+ classiLimit = inhp ? cls->allSuperclasses.classCount : 1;
530
+ for (classi = 0 ; classi < classiLimit ; classi++)
531
+ {
532
+ supcls = cls->allSuperclasses.classArray[classi];
533
+
534
+ if (inhp == 0)
535
+ { i = sublen; }
536
+ else
537
+ { i = len - (supcls->handlerCount * 3) - sublen; }
538
+
539
+ for (j = 0 ; j < supcls->handlerCount ; j++)
540
+ {
541
+ returnValue->multifieldValue->contents[i++].value = GetDefclassNamePointer(supcls);
542
+ returnValue->multifieldValue->contents[i++].value = supcls->handlers[j].header.name;
543
+ returnValue->multifieldValue->contents[i++].value = CreateSymbol(theEnv,MessageHandlerData(theEnv)->hndquals[supcls->handlers[j].type]);
544
+ }
545
+
546
+ sublen += supcls->handlerCount * 3;
547
+ }
548
+ }
549
+
550
+ if (svcls != NULL)
551
+ { SetNextDefclass(svcls,svnxt); }
552
+ }
553
+
554
+ /***************************************************************************
555
+ NAME : ClassSuperclasses
556
+ DESCRIPTION : Groups the names of superclasses into a multifield
557
+ value for dynamic perusal
558
+ INPUTS : 1) Generic pointer to class
559
+ 2) Data object buffer to hold the superclasses of the class
560
+ 3) Include (1) or exclude (0) indirect superclasses
561
+ RETURNS : Nothing useful
562
+ SIDE EFFECTS : Creates a multifield storing the names of
563
+ the superclasses of the class
564
+ NOTES : None
565
+ ***************************************************************************/
566
+ void ClassSuperclasses(
567
+ Defclass *theDefclass,
568
+ CLIPSValue *returnValue,
569
+ bool inhp)
570
+ {
571
+ PACKED_CLASS_LINKS *plinks;
572
+ unsigned offset;
573
+ unsigned long i, j;
574
+ Environment *theEnv = theDefclass->header.env;
575
+
576
+ if (inhp)
577
+ {
578
+ plinks = &theDefclass->allSuperclasses;
579
+ offset = 1;
580
+ }
581
+ else
582
+ {
583
+ plinks = &theDefclass->directSuperclasses;
584
+ offset = 0;
585
+ }
586
+
587
+ returnValue->value = CreateMultifield(theEnv,(plinks->classCount - offset));
588
+
589
+ if (returnValue->multifieldValue->length == 0)
590
+ { return; }
591
+
592
+ for (i = offset, j = 0 ; i < plinks->classCount; i++, j++)
593
+ {
594
+ returnValue->multifieldValue->contents[j].value = GetDefclassNamePointer(plinks->classArray[i]);
595
+ }
596
+ }
597
+
598
+ /**************************************************************************
599
+ NAME : ClassSubclasses
600
+ DESCRIPTION : Groups the names of subclasses for a class into a
601
+ multifield value for dynamic perusal
602
+ INPUTS : 1) Generic pointer to class
603
+ 2) Data object buffer to hold the sublclasses of the class
604
+ 3) Include (1) or exclude (0) indirect subclasses
605
+ RETURNS : Nothing useful
606
+ SIDE EFFECTS : Creates a multifield storing the names
607
+ the subclasses of the class
608
+ NOTES : None
609
+ **************************************************************************/
610
+ void ClassSubclasses(
611
+ Defclass *theDefclass,
612
+ CLIPSValue *returnValue,
613
+ bool inhp)
614
+ {
615
+ unsigned i;
616
+ int id;
617
+ Environment *theEnv = theDefclass->header.env;
618
+
619
+ if ((id = GetTraversalID(theEnv)) == -1)
620
+ { return; }
621
+
622
+ i = CountSubclasses(theDefclass,inhp,id);
623
+
624
+ ReleaseTraversalID(theEnv);
625
+
626
+ returnValue->value = CreateMultifield(theEnv,i);
627
+
628
+ if (i == 0)
629
+ { return; }
630
+
631
+ if ((id = GetTraversalID(theEnv)) == -1)
632
+ { return; }
633
+
634
+ StoreSubclasses(returnValue->multifieldValue,0,theDefclass,inhp,id,true);
635
+ ReleaseTraversalID(theEnv);
636
+ }
637
+
638
+ /**************************************************************************
639
+ NAME : ClassSubclassAddresses
640
+ DESCRIPTION : Groups the class addresses of subclasses for a class into a
641
+ multifield value for dynamic perusal
642
+ INPUTS : 1) Generic pointer to class
643
+ 2) Data object buffer to hold the sublclasses of the class
644
+ 3) Include (1) or exclude (0) indirect subclasses
645
+ RETURNS : Nothing useful
646
+ SIDE EFFECTS : Creates a multifield storing the subclass
647
+ addresss of the class
648
+ NOTES : None
649
+ **************************************************************************/
650
+ void ClassSubclassAddresses(
651
+ Environment *theEnv,
652
+ Defclass *theDefclass,
653
+ UDFValue *returnValue,
654
+ bool inhp)
655
+ {
656
+ unsigned i;
657
+ int id;
658
+
659
+ if ((id = GetTraversalID(theEnv)) == -1)
660
+ { return; }
661
+
662
+ i = CountSubclasses(theDefclass,inhp,id);
663
+
664
+ ReleaseTraversalID(theEnv);
665
+
666
+ returnValue->begin = 0;
667
+ returnValue->range = i;
668
+ returnValue->value = CreateMultifield(theEnv,i);
669
+
670
+ if (i == 0)
671
+ { return; }
672
+
673
+ if ((id = GetTraversalID(theEnv)) == -1)
674
+ { return; }
675
+
676
+ StoreSubclasses(returnValue->multifieldValue,0,theDefclass,inhp,id,false);
677
+ ReleaseTraversalID(theEnv);
678
+ }
679
+ /**************************************************************************
680
+ NAME : Slot... Slot information access functions
681
+ DESCRIPTION : Groups the sources/facets/types/allowed-values/range or
682
+ cardinality of a slot for a class into a multifield
683
+ value for dynamic perusal
684
+ INPUTS : 1) Generic pointer to class
685
+ 2) Name of the slot
686
+ 3) Data object buffer to hold the attributes of the class
687
+ RETURNS : Nothing useful
688
+ SIDE EFFECTS : Creates a multifield storing the attributes for the slot
689
+ of the class
690
+ NOTES : None
691
+ **************************************************************************/
692
+
693
+ /**************/
694
+ /* SlotFacets */
695
+ /**************/
696
+ bool SlotFacets(
697
+ Defclass *theDefclass,
698
+ const char *sname,
699
+ CLIPSValue *returnValue)
700
+ {
701
+ SlotDescriptor *sp;
702
+ UDFValue result;
703
+ Environment *theEnv = theDefclass->header.env;
704
+
705
+ if ((sp = SlotInfoSlot(theEnv,&result,theDefclass,sname,"slot-facets")) == NULL)
706
+ {
707
+ NormalizeMultifield(theEnv,&result);
708
+ returnValue->value = result.value;
709
+ return false;
710
+ }
711
+
712
+ #if DEFRULE_CONSTRUCT
713
+ returnValue->value = CreateMultifield(theEnv,10L);
714
+ #else
715
+ returnValue->value = CreateMultifield(theEnv,9L);
716
+ #endif
717
+
718
+ if (sp->multiple)
719
+ { returnValue->multifieldValue->contents[0].lexemeValue = CreateSymbol(theEnv,"MLT"); }
720
+ else
721
+ { returnValue->multifieldValue->contents[0].lexemeValue = CreateSymbol(theEnv,"SGL"); }
722
+
723
+ if (sp->noDefault)
724
+ returnValue->multifieldValue->contents[1].lexemeValue = CreateSymbol(theEnv,"NIL");
725
+ else
726
+ {
727
+ if (sp->dynamicDefault)
728
+ { returnValue->multifieldValue->contents[1].lexemeValue = CreateSymbol(theEnv,"DYN"); }
729
+ else
730
+ { returnValue->multifieldValue->contents[1].lexemeValue = CreateSymbol(theEnv,"STC"); }
731
+ }
732
+
733
+ if (sp->noInherit)
734
+ returnValue->multifieldValue->contents[2].lexemeValue = CreateSymbol(theEnv,"NIL");
735
+ else
736
+ returnValue->multifieldValue->contents[2].lexemeValue = CreateSymbol(theEnv,"INH");
737
+
738
+ if (sp->initializeOnly)
739
+ returnValue->multifieldValue->contents[3].lexemeValue = CreateSymbol(theEnv,"INT");
740
+ else if (sp->noWrite)
741
+ returnValue->multifieldValue->contents[3].lexemeValue = CreateSymbol(theEnv,"R");
742
+ else
743
+ returnValue->multifieldValue->contents[3].lexemeValue = CreateSymbol(theEnv,"RW");
744
+
745
+ if (sp->shared)
746
+ returnValue->multifieldValue->contents[4].lexemeValue = CreateSymbol(theEnv,"SHR");
747
+ else
748
+ returnValue->multifieldValue->contents[4].lexemeValue = CreateSymbol(theEnv,"LCL");
749
+
750
+ #if DEFRULE_CONSTRUCT
751
+ if (sp->reactive)
752
+ returnValue->multifieldValue->contents[5].lexemeValue = CreateSymbol(theEnv,"RCT");
753
+ else
754
+ returnValue->multifieldValue->contents[5].lexemeValue = CreateSymbol(theEnv,"NIL");
755
+
756
+ if (sp->composite)
757
+ returnValue->multifieldValue->contents[6].lexemeValue = CreateSymbol(theEnv,"CMP");
758
+ else
759
+ returnValue->multifieldValue->contents[6].lexemeValue = CreateSymbol(theEnv,"EXC");
760
+
761
+ if (sp->publicVisibility)
762
+ returnValue->multifieldValue->contents[7].lexemeValue = CreateSymbol(theEnv,"PUB");
763
+ else
764
+ returnValue->multifieldValue->contents[7].lexemeValue = CreateSymbol(theEnv,"PRV");
765
+
766
+ returnValue->multifieldValue->contents[8].lexemeValue = CreateSymbol(theEnv,GetCreateAccessorString(sp));
767
+ returnValue->multifieldValue->contents[9].lexemeValue = (sp->noWrite ? CreateSymbol(theEnv,"NIL") : sp->overrideMessage);
768
+ #else
769
+ if (sp->composite)
770
+ returnValue->multifieldValue->contents[5].lexemeValue = CreateSymbol(theEnv,"CMP");
771
+ else
772
+ returnValue->multifieldValue->contents[5].lexemeValue = CreateSymbol(theEnv,"EXC");
773
+
774
+ if (sp->publicVisibility)
775
+ returnValue->multifieldValue->contents[6].lexemeValue = CreateSymbol(theEnv,"PUB");
776
+ else
777
+ returnValue->multifieldValue->contents[6].lexemeValue = CreateSymbol(theEnv,"PRV");
778
+
779
+ returnValue->multifieldValue->contents[7].lexemeValue = CreateSymbol(theEnv,GetCreateAccessorString(sp));
780
+ returnValue->multifieldValue->contents[8].lexemeValue = (sp->noWrite ? CreateSymbol(theEnv,"NIL") : sp->overrideMessage);
781
+ #endif
782
+
783
+ return true;
784
+ }
785
+
786
+ /***************/
787
+ /* SlotSources */
788
+ /***************/
789
+ bool SlotSources(
790
+ Defclass *theDefclass,
791
+ const char *sname,
792
+ CLIPSValue *returnValue)
793
+ {
794
+ unsigned i;
795
+ unsigned classi;
796
+ SlotDescriptor *sp, *csp;
797
+ CLASS_LINK *ctop,*ctmp;
798
+ Defclass *cls;
799
+ UDFValue result;
800
+ Environment *theEnv = theDefclass->header.env;
801
+
802
+ if ((sp = SlotInfoSlot(theEnv,&result,theDefclass,sname,"slot-sources")) == NULL)
803
+ {
804
+ NormalizeMultifield(theEnv,&result);
805
+ returnValue->value = result.value;
806
+ return false;
807
+ }
808
+ i = 1;
809
+ ctop = get_struct(theEnv,classLink);
810
+ ctop->cls = sp->cls;
811
+ ctop->nxt = NULL;
812
+ if (sp->composite)
813
+ {
814
+ for (classi = 1 ; classi < sp->cls->allSuperclasses.classCount ; classi++)
815
+ {
816
+ cls = sp->cls->allSuperclasses.classArray[classi];
817
+ csp = FindClassSlot(cls,sp->slotName->name);
818
+ if ((csp != NULL) ? (csp->noInherit == 0) : false)
819
+ {
820
+ ctmp = get_struct(theEnv,classLink);
821
+ ctmp->cls = cls;
822
+ ctmp->nxt = ctop;
823
+ ctop = ctmp;
824
+ i++;
825
+ if (csp->composite == 0)
826
+ break;
827
+ }
828
+ }
829
+ }
830
+
831
+ returnValue->value = CreateMultifield(theEnv,i);
832
+ for (ctmp = ctop , i = 0 ; ctmp != NULL ; ctmp = ctmp->nxt , i++)
833
+ {
834
+ returnValue->multifieldValue->contents[i].value = GetDefclassNamePointer(ctmp->cls);
835
+ }
836
+ DeleteClassLinks(theEnv,ctop);
837
+
838
+ return true;
839
+ }
840
+
841
+ /*************/
842
+ /* SlotTypes */
843
+ /*************/
844
+ bool SlotTypes(
845
+ Defclass *theDefclass,
846
+ const char *sname,
847
+ CLIPSValue *returnValue)
848
+ {
849
+ unsigned i,j;
850
+ SlotDescriptor *sp;
851
+ char typemap[2];
852
+ unsigned msize;
853
+ UDFValue result;
854
+ Environment *theEnv = theDefclass->header.env;
855
+
856
+ if ((sp = SlotInfoSlot(theEnv,&result,theDefclass,sname,"slot-types")) == NULL)
857
+ {
858
+ NormalizeMultifield(theEnv,&result);
859
+ returnValue->value = result.value;
860
+ return false;
861
+ }
862
+
863
+ if ((sp->constraint != NULL) ? sp->constraint->anyAllowed : true)
864
+ {
865
+ typemap[0] = typemap[1] = (char) 0xFF;
866
+ ClearBitMap(typemap,MULTIFIELD_TYPE);
867
+ msize = 8;
868
+ }
869
+ else
870
+ {
871
+ typemap[0] = typemap[1] = (char) 0x00;
872
+ msize = 0;
873
+ if (sp->constraint->symbolsAllowed)
874
+ {
875
+ msize++;
876
+ SetBitMap(typemap,SYMBOL_TYPE);
877
+ }
878
+ if (sp->constraint->stringsAllowed)
879
+ {
880
+ msize++;
881
+ SetBitMap(typemap,STRING_TYPE);
882
+ }
883
+ if (sp->constraint->floatsAllowed)
884
+ {
885
+ msize++;
886
+ SetBitMap(typemap,FLOAT_TYPE);
887
+ }
888
+ if (sp->constraint->integersAllowed)
889
+ {
890
+ msize++;
891
+ SetBitMap(typemap,INTEGER_TYPE);
892
+ }
893
+ if (sp->constraint->instanceNamesAllowed)
894
+ {
895
+ msize++;
896
+ SetBitMap(typemap,INSTANCE_NAME_TYPE);
897
+ }
898
+ if (sp->constraint->instanceAddressesAllowed)
899
+ {
900
+ msize++;
901
+ SetBitMap(typemap,INSTANCE_ADDRESS_TYPE);
902
+ }
903
+ if (sp->constraint->externalAddressesAllowed)
904
+ {
905
+ msize++;
906
+ SetBitMap(typemap,EXTERNAL_ADDRESS_TYPE);
907
+ }
908
+ if (sp->constraint->factAddressesAllowed)
909
+ {
910
+ msize++;
911
+ SetBitMap(typemap,FACT_ADDRESS_TYPE);
912
+ }
913
+ }
914
+
915
+ returnValue->value = CreateMultifield(theEnv,msize);
916
+ i = 0;
917
+ j = 0;
918
+ while (i < msize)
919
+ {
920
+ if (TestBitMap(typemap,j))
921
+ {
922
+ returnValue->multifieldValue->contents[i].value =
923
+ GetDefclassNamePointer(DefclassData(theEnv)->PrimitiveClassMap[j]);
924
+ i++;
925
+ }
926
+ j++;
927
+ }
928
+
929
+ return true;
930
+ }
931
+
932
+ /*********************/
933
+ /* SlotAllowedValues */
934
+ /*********************/
935
+ bool SlotAllowedValues(
936
+ Defclass *theDefclass,
937
+ const char *sname,
938
+ CLIPSValue *returnValue)
939
+ {
940
+ int i;
941
+ SlotDescriptor *sp;
942
+ Expression *theExp;
943
+ UDFValue result;
944
+ Environment *theEnv = theDefclass->header.env;
945
+
946
+ if ((sp = SlotInfoSlot(theEnv,&result,theDefclass,sname,"slot-allowed-values")) == NULL)
947
+ {
948
+ NormalizeMultifield(theEnv,&result);
949
+ returnValue->value = result.value;
950
+ return false;
951
+ }
952
+
953
+ if ((sp->constraint != NULL) ? (sp->constraint->restrictionList == NULL) : true)
954
+ {
955
+ returnValue->value = FalseSymbol(theEnv);
956
+ return true;
957
+ }
958
+
959
+ returnValue->value = CreateMultifield(theEnv,ExpressionSize(sp->constraint->restrictionList));
960
+ i = 0;
961
+ theExp = sp->constraint->restrictionList;
962
+ while (theExp != NULL)
963
+ {
964
+ returnValue->multifieldValue->contents[i].value = theExp->value;
965
+ theExp = theExp->nextArg;
966
+ i++;
967
+ }
968
+
969
+ return true;
970
+ }
971
+
972
+ /**********************/
973
+ /* SlotAllowedClasses */
974
+ /**********************/
975
+ bool SlotAllowedClasses(
976
+ Defclass *theDefclass,
977
+ const char *sname,
978
+ CLIPSValue *returnValue)
979
+ {
980
+ int i;
981
+ SlotDescriptor *sp;
982
+ Expression *theExp;
983
+ UDFValue result;
984
+ Environment *theEnv = theDefclass->header.env;
985
+
986
+ if ((sp = SlotInfoSlot(theEnv,&result,theDefclass,sname,"slot-allowed-classes")) == NULL)
987
+ {
988
+ NormalizeMultifield(theEnv,&result);
989
+ returnValue->value = result.value;
990
+ return false;
991
+ }
992
+ if ((sp->constraint != NULL) ? (sp->constraint->classList == NULL) : true)
993
+ {
994
+ returnValue->value = FalseSymbol(theEnv);
995
+ return true;
996
+ }
997
+ returnValue->value = CreateMultifield(theEnv,ExpressionSize(sp->constraint->classList));
998
+ i = 0;
999
+ theExp = sp->constraint->classList;
1000
+ while (theExp != NULL)
1001
+ {
1002
+ returnValue->multifieldValue->contents[i].value = theExp->value;
1003
+ theExp = theExp->nextArg;
1004
+ i++;
1005
+ }
1006
+
1007
+ return true;
1008
+ }
1009
+
1010
+ /*************/
1011
+ /* SlotRange */
1012
+ /*************/
1013
+ bool SlotRange(
1014
+ Defclass *theDefclass,
1015
+ const char *sname,
1016
+ CLIPSValue *returnValue)
1017
+ {
1018
+ SlotDescriptor *sp;
1019
+ UDFValue result;
1020
+ Environment *theEnv = theDefclass->header.env;
1021
+
1022
+ if ((sp = SlotInfoSlot(theEnv,&result,theDefclass,sname,"slot-range")) == NULL)
1023
+ {
1024
+ NormalizeMultifield(theEnv,&result);
1025
+ returnValue->value = result.value;
1026
+ return false;
1027
+ }
1028
+ if ((sp->constraint == NULL) ? false :
1029
+ (sp->constraint->anyAllowed || sp->constraint->floatsAllowed ||
1030
+ sp->constraint->integersAllowed))
1031
+ {
1032
+ returnValue->value = CreateMultifield(theEnv,2L);
1033
+ returnValue->multifieldValue->contents[0].value = sp->constraint->minValue->value;
1034
+ returnValue->multifieldValue->contents[1].value = sp->constraint->maxValue->value;
1035
+ }
1036
+ else
1037
+ {
1038
+ returnValue->value = FalseSymbol(theEnv);
1039
+ }
1040
+ return true;
1041
+ }
1042
+
1043
+ /*******************/
1044
+ /* SlotCardinality */
1045
+ /*******************/
1046
+ bool SlotCardinality(
1047
+ Defclass *theDefclass,
1048
+ const char *sname,
1049
+ CLIPSValue *returnValue)
1050
+ {
1051
+ SlotDescriptor *sp;
1052
+ UDFValue result;
1053
+ Environment *theEnv = theDefclass->header.env;
1054
+
1055
+ if ((sp = SlotInfoSlot(theEnv,&result,theDefclass,sname,"slot-cardinality")) == NULL)
1056
+ {
1057
+ NormalizeMultifield(theEnv,&result);
1058
+ returnValue->value = result.value;
1059
+ return false;
1060
+ }
1061
+
1062
+ if (sp->multiple == 0)
1063
+ {
1064
+ returnValue->multifieldValue = CreateMultifield(theEnv,0L);
1065
+ return true;
1066
+ }
1067
+
1068
+ returnValue->value = CreateMultifield(theEnv,2L);
1069
+ if (sp->constraint != NULL)
1070
+ {
1071
+ returnValue->multifieldValue->contents[0].value = sp->constraint->minFields->value;
1072
+ returnValue->multifieldValue->contents[1].value = sp->constraint->maxFields->value;
1073
+ }
1074
+ else
1075
+ {
1076
+ returnValue->multifieldValue->contents[0].value = SymbolData(theEnv)->Zero;
1077
+ returnValue->multifieldValue->contents[1].value = SymbolData(theEnv)->PositiveInfinity;
1078
+ }
1079
+
1080
+ return true;
1081
+ }
1082
+
1083
+ /* =========================================
1084
+ *****************************************
1085
+ INTERNALLY VISIBLE FUNCTIONS
1086
+ =========================================
1087
+ ***************************************** */
1088
+
1089
+ /*****************************************************
1090
+ NAME : SlotInfoSupportFunction
1091
+ DESCRIPTION : Support routine for slot-sources,
1092
+ slot-facets, et. al.
1093
+ INPUTS : 1) Data object buffer
1094
+ 2) Name of the H/L caller
1095
+ 3) Pointer to support function to call
1096
+ RETURNS : Nothing useful
1097
+ SIDE EFFECTS : Support function called and data
1098
+ object buffer set
1099
+ NOTES : None
1100
+ *****************************************************/
1101
+ static void SlotInfoSupportFunction(
1102
+ UDFContext *context,
1103
+ UDFValue *returnValue,
1104
+ const char *fnxname,
1105
+ bool (*fnx)(Defclass *,const char *,CLIPSValue *))
1106
+ {
1107
+ CLIPSLexeme *ssym;
1108
+ Defclass *cls;
1109
+ CLIPSValue result;
1110
+
1111
+ ssym = CheckClassAndSlot(context,fnxname,&cls);
1112
+ if (ssym == NULL)
1113
+ {
1114
+ SetMultifieldErrorValue(context->environment,returnValue);
1115
+ return;
1116
+ }
1117
+ (*fnx)(cls,ssym->contents,&result);
1118
+ CLIPSToUDFValue(&result,returnValue);
1119
+ }
1120
+
1121
+ /*****************************************************************
1122
+ NAME : CountSubclasses
1123
+ DESCRIPTION : Counts the number of direct or indirect
1124
+ subclasses for a class
1125
+ INPUTS : 1) Address of class
1126
+ 2) Include (1) or exclude (0) indirect subclasses
1127
+ 3) Traversal id
1128
+ RETURNS : The number of subclasses
1129
+ SIDE EFFECTS : None
1130
+ NOTES : None
1131
+ *****************************************************************/
1132
+ static unsigned CountSubclasses(
1133
+ Defclass *cls,
1134
+ bool inhp,
1135
+ int tvid)
1136
+ {
1137
+ unsigned i, cnt;
1138
+ Defclass *subcls;
1139
+
1140
+ for (cnt = 0 , i = 0 ; i < cls->directSubclasses.classCount ; i++)
1141
+ {
1142
+ subcls = cls->directSubclasses.classArray[i];
1143
+ if (TestTraversalID(subcls->traversalRecord,tvid) == 0)
1144
+ {
1145
+ cnt++;
1146
+ SetTraversalID(subcls->traversalRecord,tvid);
1147
+ if (inhp && (subcls->directSubclasses.classCount != 0))
1148
+ cnt += CountSubclasses(subcls,inhp,tvid);
1149
+ }
1150
+ }
1151
+ return cnt;
1152
+ }
1153
+
1154
+ /*********************************************************************
1155
+ NAME : StoreSubclasses
1156
+ DESCRIPTION : Stores the names of direct or indirect
1157
+ subclasses for a class in a mutlifield
1158
+ INPUTS : 1) Caller's multifield buffer
1159
+ 2) Starting index
1160
+ 3) Address of the class
1161
+ 4) Include (1) or exclude (0) indirect subclasses
1162
+ 5) Traversal id
1163
+ RETURNS : The number of subclass names stored in the multifield
1164
+ SIDE EFFECTS : Multifield set with subclass names
1165
+ NOTES : Assumes multifield is big enough to hold subclasses
1166
+ *********************************************************************/
1167
+ static unsigned StoreSubclasses(
1168
+ Multifield *mfval,
1169
+ unsigned si,
1170
+ Defclass *cls,
1171
+ int inhp,
1172
+ int tvid,
1173
+ bool storeName)
1174
+ {
1175
+ unsigned i, classi;
1176
+ Defclass *subcls;
1177
+
1178
+ for (i = si , classi = 0 ; classi < cls->directSubclasses.classCount ; classi++)
1179
+ {
1180
+ subcls = cls->directSubclasses.classArray[classi];
1181
+ if (TestTraversalID(subcls->traversalRecord,tvid) == 0)
1182
+ {
1183
+ SetTraversalID(subcls->traversalRecord,tvid);
1184
+ if (storeName)
1185
+ {
1186
+ mfval->contents[i++].value = GetDefclassNamePointer(subcls);
1187
+ }
1188
+ else
1189
+ {
1190
+ mfval->contents[i++].value = subcls;
1191
+ }
1192
+
1193
+ if (inhp && (subcls->directSubclasses.classCount != 0))
1194
+ i += StoreSubclasses(mfval,i,subcls,inhp,tvid,storeName);
1195
+ }
1196
+ }
1197
+ return i - si;
1198
+ }
1199
+
1200
+ /*********************************************************
1201
+ NAME : SlotInfoSlot
1202
+ DESCRIPTION : Runtime support routine for slot-sources,
1203
+ slot-facets, et. al. which looks up
1204
+ a slot
1205
+ INPUTS : 1) Data object buffer
1206
+ 2) Class pointer
1207
+ 3) Name-string of slot to find
1208
+ 4) The name of the calling function
1209
+ RETURNS : Nothing useful
1210
+ SIDE EFFECTS : Support function called and data object
1211
+ buffer initialized
1212
+ NOTES : None
1213
+ *********************************************************/
1214
+ static SlotDescriptor *SlotInfoSlot(
1215
+ Environment *theEnv,
1216
+ UDFValue *returnValue,
1217
+ Defclass *cls,
1218
+ const char *sname,
1219
+ const char *fnxname)
1220
+ {
1221
+ CLIPSLexeme *ssym;
1222
+ int i;
1223
+
1224
+ if ((ssym = FindSymbolHN(theEnv,sname,SYMBOL_BIT)) == NULL)
1225
+ {
1226
+ SetEvaluationError(theEnv,true);
1227
+ SetMultifieldErrorValue(theEnv,returnValue);
1228
+ return NULL;
1229
+ }
1230
+
1231
+ i = FindInstanceTemplateSlot(theEnv,cls,ssym);
1232
+ if (i == -1)
1233
+ {
1234
+ SlotExistError(theEnv,sname,fnxname);
1235
+ SetEvaluationError(theEnv,true);
1236
+ SetMultifieldErrorValue(theEnv,returnValue);
1237
+ return NULL;
1238
+ }
1239
+
1240
+ returnValue->begin = 0;
1241
+
1242
+ return cls->instanceTemplate[i];
1243
+ }
1244
+
1245
+ #endif