clipsruby 0.0.24 → 0.0.26

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 (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +93 -0
  3. data/ext/clipsruby/clipsruby.c +803 -0
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1efd15213fd7f558c0b75e64869e6518a12c1c55da8d6d94bf306235f4879a67
4
- data.tar.gz: b30352c0431948b03849579a92a0e96dde42368f6e78b051adc2f02b68c8c4c8
3
+ metadata.gz: fb3538a29ed740232a6a18314da3443bf632274e06fcb893cba9c70b0797353d
4
+ data.tar.gz: 49d5cf4c8e4435fb0b35cfe2434f2aeb12f0563e859c9b0fc93fb8d64b47ee29
5
5
  SHA512:
6
- metadata.gz: 5e55eac1476475ecb1f5b5b998cab1aa108dc0fcbe86905565c3b9256c4855ac796cdd9a28602289dec062c9481ac6340d17c7d22b98b1baf2b0b9e3f338136a
7
- data.tar.gz: 31c41a7c633cc0707bdfc77e9e9c5b97b2d97d75f8202ce0d7450f7366ec9ee0e2939bcd91d7c228d3d96459ff516eb6f81959981cb1414b53f8c8ee514c6dea
6
+ metadata.gz: 1bb0d0617bcf972ca6cbad967ff271e697920e21442d978ce9ee289c0f7e81f53b30fe1b722e334649ed274b62f10e2728683f8e5df84853f3ca6575f8a11444
7
+ data.tar.gz: 66b6617635f3ba892008749dee6645cbc6652e3815b19c37bea2eb752a231d342c0d0ab1873faae8bc14e07b238c2b298f3574907ef4fae7d7dae0a0cd0a30bd
data/README.md CHANGED
@@ -621,6 +621,51 @@ CLIPS::Environment::Deftemplate.slot_default_value(deftemplate, :foo)
621
621
  deftemplate.slot_default_value('bar')
622
622
  ```
623
623
 
624
+ ### `CLIPS::Environment::Deftemplate.slot_types`
625
+ ### `CLIPS::Environment::Deftemplate#slot_types`
626
+
627
+ Returns the slot type(s) for the named slot of a deftemplate as symbols.
628
+ Possible types are as follows:
629
+
630
+ ```ruby
631
+ :SYMBOL
632
+ :STRING
633
+ :LEXEME
634
+ :INTEGER
635
+ :FLOAT
636
+ :NUMBER
637
+ :"INSTANCE-NAME"
638
+ :"INSTANCE-ADDRESS"
639
+ :INSTANCE
640
+ :"EXTERNAL-ADDRESS"
641
+ :"FACT-ADDRESS"
642
+ ```
643
+
644
+ ```ruby
645
+ CLIPS::Environment::Deftemplate.slot_types(deftemplate, :foo)
646
+ deftemplate.slot_types('bar')
647
+ ```
648
+
649
+ ### `CLIPS::Environment::Deftemplate.slot_range`
650
+ ### `CLIPS::Environment::Deftemplate#slot_range`
651
+
652
+ Returns the range of a named slot of a deftemplate as integers or symbols (in case of infinity).
653
+
654
+ ```ruby
655
+ CLIPS::Environment::Deftemplate.slot_range(deftemplate, :foo)
656
+ deftemplate.slot_range('bar')
657
+ ```
658
+
659
+ ### `CLIPS::Environment::Deftemplate.slot_cardinality`
660
+ ### `CLIPS::Environment::Deftemplate#slot_cardinality`
661
+
662
+ Returns the cardinality of a named slot of a deftemplate as integers or symbols (in case of infinity).
663
+
664
+ ```ruby
665
+ CLIPS::Environment::Deftemplate.slot_cardinality(deftemplate, :foo)
666
+ deftemplate.slot_cardinality('bar')
667
+ ```
668
+
624
669
  ### `CLIPS::Environment::Defmodule.get_deftemplate_list`
625
670
  ### `CLIPS::Environment::Defmodule#get_deftemplate_list`
626
671
 
@@ -661,6 +706,54 @@ CLIPS::Environment::Deffacts.pp_form(deffacts)
661
706
  deffacts.pp_form
662
707
  ```
663
708
 
709
+ ### `CLIPS::Environment.watch`
710
+ ### `env.watch`
711
+ ### `CLIPS::Environment.unwatch`
712
+ ### `env.unwatch`
713
+
714
+ "Watch" or "Unwatch" a specific thing that happens in the CLIPS environment.
715
+ There are several things that may be watched (or unwatched) such that CLIPS will
716
+ report debugging information to `STDOUT`. This gem provides two ways to watch
717
+ or unwatch a debug item: either pass the watch item as a symbol to `watch` or
718
+ `unwatch`, or use the corresponding `watch_foo` or `unwatch_foo` methods where
719
+ `foo` is replaced by the watch item (as listed):
720
+
721
+ ```ruby
722
+ :all
723
+ :facts
724
+ :instances
725
+ :slots
726
+ :rules
727
+ :activations
728
+ :messages
729
+ :message_handlers
730
+ :generic_functions
731
+ :methods
732
+ :deffunctions
733
+ :compilations
734
+ :statistics
735
+ :globals
736
+ :focus
737
+ ```
738
+
739
+ ```ruby
740
+ CLIPS::Environment.watch_facts
741
+ env.watch_statistics
742
+ CLIPS::Environment.unwatch(:facts)
743
+ env.unwatch(:statistics)
744
+ ```
745
+
746
+ ### `CLIPS::Environment.get_watch_state`
747
+ ### `env.get_watch_state`
748
+
749
+ Returns a bool representing whether or not the given debug item
750
+ is currently being watched in the environment.
751
+
752
+ ```ruby
753
+ CLIPS::Environment.get_watch_state(env, :facts)
754
+ env.get_watch_state(:methods)
755
+ ```
756
+
664
757
  ## Running the tests
665
758
 
666
759
  Simply do `rake compile` and then `rake test` in order to run the tests.
@@ -1300,6 +1300,99 @@ static VALUE clips_environment_deftemplate_static_slot_default_value(VALUE self,
1300
1300
  }
1301
1301
 
1302
1302
 
1303
+ static VALUE clips_environment_deftemplate_slot_types(VALUE self, VALUE slot_name)
1304
+ {
1305
+ Deftemplate *template;
1306
+ CLIPSValue slot_types;
1307
+ VALUE out;
1308
+ VALUE rbEnvironment = rb_iv_get(self, "@environment");
1309
+
1310
+ TypedData_Get_Struct(self, Deftemplate, &Deftemplate_type, template);
1311
+
1312
+ switch (TYPE(slot_name)) {
1313
+ case T_STRING:
1314
+ DeftemplateSlotTypes(template, StringValueCStr(slot_name), &slot_types);
1315
+ break;
1316
+ case T_SYMBOL:
1317
+ DeftemplateSlotTypes(template, rb_id2name(SYM2ID(slot_name)), &slot_types);
1318
+ break;
1319
+ default:
1320
+ rb_warn("slot name must be string or symbol in call to slot_types!");
1321
+ return Qnil;
1322
+ }
1323
+
1324
+ CLIPSValue_to_VALUE(&slot_types, &out, &rbEnvironment);
1325
+
1326
+ return out;
1327
+ }
1328
+
1329
+ static VALUE clips_environment_deftemplate_static_slot_types(VALUE self, VALUE rbEnvironment, VALUE slot_name)
1330
+ {
1331
+ return clips_environment_deftemplate_slot_types(rbEnvironment, slot_name);
1332
+ }
1333
+
1334
+ static VALUE clips_environment_deftemplate_slot_range(VALUE self, VALUE slot_name)
1335
+ {
1336
+ Deftemplate *template;
1337
+ CLIPSValue slot_range;
1338
+ VALUE out;
1339
+ VALUE rbEnvironment = rb_iv_get(self, "@environment");
1340
+
1341
+ TypedData_Get_Struct(self, Deftemplate, &Deftemplate_type, template);
1342
+
1343
+ switch (TYPE(slot_name)) {
1344
+ case T_STRING:
1345
+ DeftemplateSlotRange(template, StringValueCStr(slot_name), &slot_range);
1346
+ break;
1347
+ case T_SYMBOL:
1348
+ DeftemplateSlotRange(template, rb_id2name(SYM2ID(slot_name)), &slot_range);
1349
+ break;
1350
+ default:
1351
+ rb_warn("slot name must be string or symbol in call to slot_range!");
1352
+ return Qnil;
1353
+ }
1354
+
1355
+ CLIPSValue_to_VALUE(&slot_range, &out, &rbEnvironment);
1356
+
1357
+ return out;
1358
+ }
1359
+
1360
+ static VALUE clips_environment_deftemplate_static_slot_range(VALUE self, VALUE rbEnvironment, VALUE slot_name)
1361
+ {
1362
+ return clips_environment_deftemplate_slot_range(rbEnvironment, slot_name);
1363
+ }
1364
+
1365
+ static VALUE clips_environment_deftemplate_slot_cardinality(VALUE self, VALUE slot_name)
1366
+ {
1367
+ Deftemplate *template;
1368
+ CLIPSValue slot_cardinality;
1369
+ VALUE out;
1370
+ VALUE rbEnvironment = rb_iv_get(self, "@environment");
1371
+
1372
+ TypedData_Get_Struct(self, Deftemplate, &Deftemplate_type, template);
1373
+
1374
+ switch (TYPE(slot_name)) {
1375
+ case T_STRING:
1376
+ DeftemplateSlotCardinality(template, StringValueCStr(slot_name), &slot_cardinality);
1377
+ break;
1378
+ case T_SYMBOL:
1379
+ DeftemplateSlotCardinality(template, rb_id2name(SYM2ID(slot_name)), &slot_cardinality);
1380
+ break;
1381
+ default:
1382
+ rb_warn("slot name must be string or symbol in call to slot_cardinality!");
1383
+ return Qnil;
1384
+ }
1385
+
1386
+ CLIPSValue_to_VALUE(&slot_cardinality, &out, &rbEnvironment);
1387
+
1388
+ return out;
1389
+ }
1390
+
1391
+ static VALUE clips_environment_deftemplate_static_slot_cardinality(VALUE self, VALUE rbEnvironment, VALUE slot_name)
1392
+ {
1393
+ return clips_environment_deftemplate_slot_cardinality(rbEnvironment, slot_name);
1394
+ }
1395
+
1303
1396
  static VALUE clips_environment_fact_retract(VALUE self)
1304
1397
  {
1305
1398
  Fact *fact;
@@ -2051,6 +2144,644 @@ static VALUE clips_environment_defrule_static_remove_break(VALUE self, VALUE rbD
2051
2144
  return clips_environment_defrule_remove_break(rbDefrule);
2052
2145
  }
2053
2146
 
2147
+ static VALUE clips_environment_watch(VALUE self, VALUE item)
2148
+ {
2149
+ Environment *env;
2150
+ WatchItem watchItem;
2151
+
2152
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2153
+
2154
+ if (item == ID2SYM(rb_intern("all"))) {
2155
+ watchItem = ALL;
2156
+ } else if (item == ID2SYM(rb_intern("facts"))) {
2157
+ watchItem = FACTS;
2158
+ } else if (item == ID2SYM(rb_intern("instances"))) {
2159
+ watchItem = INSTANCES;
2160
+ } else if (item == ID2SYM(rb_intern("slots"))) {
2161
+ watchItem = SLOTS;
2162
+ } else if (item == ID2SYM(rb_intern("rules"))) {
2163
+ watchItem = RULES;
2164
+ } else if (item == ID2SYM(rb_intern("activations"))) {
2165
+ watchItem = ACTIVATIONS;
2166
+ } else if (item == ID2SYM(rb_intern("messages"))) {
2167
+ watchItem = MESSAGES;
2168
+ } else if (item == ID2SYM(rb_intern("message_handlers"))) {
2169
+ watchItem = MESSAGE_HANDLERS;
2170
+ } else if (item == ID2SYM(rb_intern("generic_functions"))) {
2171
+ watchItem = GENERIC_FUNCTIONS;
2172
+ } else if (item == ID2SYM(rb_intern("methods"))) {
2173
+ watchItem = METHODS;
2174
+ } else if (item == ID2SYM(rb_intern("deffunctions"))) {
2175
+ watchItem = DEFFUNCTIONS;
2176
+ } else if (item == ID2SYM(rb_intern("compilations"))) {
2177
+ watchItem = COMPILATIONS;
2178
+ } else if (item == ID2SYM(rb_intern("statistics"))) {
2179
+ watchItem = STATISTICS;
2180
+ } else if (item == ID2SYM(rb_intern("globals"))) {
2181
+ watchItem = GLOBALS;
2182
+ } else if (item == ID2SYM(rb_intern("focus"))) {
2183
+ watchItem = FOCUS;
2184
+ } else {
2185
+ rb_warn("unknown watch item");
2186
+ return Qnil;
2187
+ }
2188
+
2189
+ Watch(env, watchItem);
2190
+
2191
+ return Qnil;
2192
+ }
2193
+
2194
+ static VALUE clips_environment_static_watch(VALUE self, VALUE rbEnvironment, VALUE item)
2195
+ {
2196
+ return clips_environment_watch(rbEnvironment, item);
2197
+ }
2198
+
2199
+ static VALUE clips_environment_unwatch(VALUE self, VALUE item)
2200
+ {
2201
+ Environment *env;
2202
+ WatchItem watchItem;
2203
+
2204
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2205
+
2206
+ if (item == ID2SYM(rb_intern("all"))) {
2207
+ watchItem = ALL;
2208
+ } else if (item == ID2SYM(rb_intern("facts"))) {
2209
+ watchItem = FACTS;
2210
+ } else if (item == ID2SYM(rb_intern("instances"))) {
2211
+ watchItem = INSTANCES;
2212
+ } else if (item == ID2SYM(rb_intern("slots"))) {
2213
+ watchItem = SLOTS;
2214
+ } else if (item == ID2SYM(rb_intern("rules"))) {
2215
+ watchItem = RULES;
2216
+ } else if (item == ID2SYM(rb_intern("activations"))) {
2217
+ watchItem = ACTIVATIONS;
2218
+ } else if (item == ID2SYM(rb_intern("messages"))) {
2219
+ watchItem = MESSAGES;
2220
+ } else if (item == ID2SYM(rb_intern("message_handlers"))) {
2221
+ watchItem = MESSAGE_HANDLERS;
2222
+ } else if (item == ID2SYM(rb_intern("generic_functions"))) {
2223
+ watchItem = GENERIC_FUNCTIONS;
2224
+ } else if (item == ID2SYM(rb_intern("methods"))) {
2225
+ watchItem = METHODS;
2226
+ } else if (item == ID2SYM(rb_intern("deffunctions"))) {
2227
+ watchItem = DEFFUNCTIONS;
2228
+ } else if (item == ID2SYM(rb_intern("compilations"))) {
2229
+ watchItem = COMPILATIONS;
2230
+ } else if (item == ID2SYM(rb_intern("statistics"))) {
2231
+ watchItem = STATISTICS;
2232
+ } else if (item == ID2SYM(rb_intern("globals"))) {
2233
+ watchItem = GLOBALS;
2234
+ } else if (item == ID2SYM(rb_intern("focus"))) {
2235
+ watchItem = FOCUS;
2236
+ } else {
2237
+ rb_warn("unknown watch item");
2238
+ return Qnil;
2239
+ }
2240
+
2241
+ Unwatch(env, watchItem);
2242
+
2243
+ return Qnil;
2244
+ }
2245
+
2246
+ static VALUE clips_environment_static_unwatch(VALUE self, VALUE rbEnvironment, VALUE item)
2247
+ {
2248
+ return clips_environment_unwatch(rbEnvironment, item);
2249
+ }
2250
+
2251
+ static VALUE clips_environment_watch_all(VALUE self)
2252
+ {
2253
+ Environment *env;
2254
+
2255
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2256
+
2257
+ Watch(env, ALL);
2258
+
2259
+ return Qnil;
2260
+ }
2261
+
2262
+ static VALUE clips_environment_static_watch_all(VALUE self, VALUE rbEnvironment)
2263
+ {
2264
+ return clips_environment_watch_all(rbEnvironment);
2265
+ }
2266
+
2267
+ static VALUE clips_environment_watch_facts(VALUE self)
2268
+ {
2269
+ Environment *env;
2270
+
2271
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2272
+
2273
+ Watch(env, FACTS);
2274
+
2275
+ return Qnil;
2276
+ }
2277
+
2278
+ static VALUE clips_environment_static_watch_facts(VALUE self, VALUE rbEnvironment)
2279
+ {
2280
+ return clips_environment_watch_facts(rbEnvironment);
2281
+ }
2282
+
2283
+ static VALUE clips_environment_watch_instances(VALUE self)
2284
+ {
2285
+ Environment *env;
2286
+
2287
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2288
+
2289
+ Watch(env, INSTANCES);
2290
+
2291
+ return Qnil;
2292
+ }
2293
+
2294
+ static VALUE clips_environment_static_watch_instances(VALUE self, VALUE rbEnvironment)
2295
+ {
2296
+ return clips_environment_watch_instances(rbEnvironment);
2297
+ }
2298
+
2299
+ static VALUE clips_environment_watch_slots(VALUE self)
2300
+ {
2301
+ Environment *env;
2302
+
2303
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2304
+
2305
+ Watch(env, SLOTS);
2306
+
2307
+ return Qnil;
2308
+ }
2309
+
2310
+ static VALUE clips_environment_static_watch_slots(VALUE self, VALUE rbEnvironment)
2311
+ {
2312
+ return clips_environment_watch_slots(rbEnvironment);
2313
+ }
2314
+
2315
+ static VALUE clips_environment_watch_rules(VALUE self)
2316
+ {
2317
+ Environment *env;
2318
+
2319
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2320
+
2321
+ Watch(env, RULES);
2322
+
2323
+ return Qnil;
2324
+ }
2325
+
2326
+ static VALUE clips_environment_static_watch_rules(VALUE self, VALUE rbEnvironment)
2327
+ {
2328
+ return clips_environment_watch_rules(rbEnvironment);
2329
+ }
2330
+
2331
+ static VALUE clips_environment_watch_activations(VALUE self)
2332
+ {
2333
+ Environment *env;
2334
+
2335
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2336
+
2337
+ Watch(env, ACTIVATIONS);
2338
+
2339
+ return Qnil;
2340
+ }
2341
+
2342
+ static VALUE clips_environment_static_watch_activations(VALUE self, VALUE rbEnvironment)
2343
+ {
2344
+ return clips_environment_watch_activations(rbEnvironment);
2345
+ }
2346
+
2347
+ static VALUE clips_environment_watch_messages(VALUE self)
2348
+ {
2349
+ Environment *env;
2350
+
2351
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2352
+
2353
+ Watch(env, MESSAGES);
2354
+
2355
+ return Qnil;
2356
+ }
2357
+
2358
+ static VALUE clips_environment_static_watch_messages(VALUE self, VALUE rbEnvironment)
2359
+ {
2360
+ return clips_environment_watch_messages(rbEnvironment);
2361
+ }
2362
+
2363
+ static VALUE clips_environment_watch_message_handlers(VALUE self)
2364
+ {
2365
+ Environment *env;
2366
+
2367
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2368
+
2369
+ Watch(env, MESSAGE_HANDLERS);
2370
+
2371
+ return Qnil;
2372
+ }
2373
+
2374
+ static VALUE clips_environment_static_watch_message_handlers(VALUE self, VALUE rbEnvironment)
2375
+ {
2376
+ return clips_environment_watch_message_handlers(rbEnvironment);
2377
+ }
2378
+
2379
+ static VALUE clips_environment_watch_generic_functions(VALUE self)
2380
+ {
2381
+ Environment *env;
2382
+
2383
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2384
+
2385
+ Watch(env, GENERIC_FUNCTIONS);
2386
+
2387
+ return Qnil;
2388
+ }
2389
+
2390
+ static VALUE clips_environment_static_watch_generic_functions(VALUE self, VALUE rbEnvironment)
2391
+ {
2392
+ return clips_environment_watch_generic_functions(rbEnvironment);
2393
+ }
2394
+
2395
+ static VALUE clips_environment_watch_methods(VALUE self)
2396
+ {
2397
+ Environment *env;
2398
+
2399
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2400
+
2401
+ Watch(env, METHODS);
2402
+
2403
+ return Qnil;
2404
+ }
2405
+
2406
+ static VALUE clips_environment_static_watch_methods(VALUE self, VALUE rbEnvironment)
2407
+ {
2408
+ return clips_environment_watch_methods(rbEnvironment);
2409
+ }
2410
+
2411
+ static VALUE clips_environment_watch_deffunctions(VALUE self)
2412
+ {
2413
+ Environment *env;
2414
+
2415
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2416
+
2417
+ Watch(env, DEFFUNCTIONS);
2418
+
2419
+ return Qnil;
2420
+ }
2421
+
2422
+ static VALUE clips_environment_static_watch_deffunctions(VALUE self, VALUE rbEnvironment)
2423
+ {
2424
+ return clips_environment_watch_deffunctions(rbEnvironment);
2425
+ }
2426
+
2427
+ static VALUE clips_environment_watch_compilations(VALUE self)
2428
+ {
2429
+ Environment *env;
2430
+
2431
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2432
+
2433
+ Watch(env, COMPILATIONS);
2434
+
2435
+ return Qnil;
2436
+ }
2437
+
2438
+ static VALUE clips_environment_static_watch_compilations(VALUE self, VALUE rbEnvironment)
2439
+ {
2440
+ return clips_environment_watch_compilations(rbEnvironment);
2441
+ }
2442
+
2443
+ static VALUE clips_environment_watch_statistics(VALUE self)
2444
+ {
2445
+ Environment *env;
2446
+
2447
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2448
+
2449
+ Watch(env, STATISTICS);
2450
+
2451
+ return Qnil;
2452
+ }
2453
+
2454
+ static VALUE clips_environment_static_watch_statistics(VALUE self, VALUE rbEnvironment)
2455
+ {
2456
+ return clips_environment_watch_statistics(rbEnvironment);
2457
+ }
2458
+
2459
+ static VALUE clips_environment_watch_globals(VALUE self)
2460
+ {
2461
+ Environment *env;
2462
+
2463
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2464
+
2465
+ Watch(env, GLOBALS);
2466
+
2467
+ return Qnil;
2468
+ }
2469
+
2470
+ static VALUE clips_environment_static_watch_globals(VALUE self, VALUE rbEnvironment)
2471
+ {
2472
+ return clips_environment_watch_globals(rbEnvironment);
2473
+ }
2474
+
2475
+ static VALUE clips_environment_watch_focus(VALUE self)
2476
+ {
2477
+ Environment *env;
2478
+
2479
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2480
+
2481
+ Watch(env, FOCUS);
2482
+
2483
+ return Qnil;
2484
+ }
2485
+
2486
+ static VALUE clips_environment_static_watch_focus(VALUE self, VALUE rbEnvironment)
2487
+ {
2488
+ return clips_environment_watch_focus(rbEnvironment);
2489
+ }
2490
+
2491
+ static VALUE clips_environment_unwatch_all(VALUE self)
2492
+ {
2493
+ Environment *env;
2494
+
2495
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2496
+
2497
+ Unwatch(env, ALL);
2498
+
2499
+ return Qnil;
2500
+ }
2501
+
2502
+ static VALUE clips_environment_static_unwatch_all(VALUE self, VALUE rbEnvironment)
2503
+ {
2504
+ return clips_environment_unwatch_all(rbEnvironment);
2505
+ }
2506
+
2507
+ static VALUE clips_environment_unwatch_facts(VALUE self)
2508
+ {
2509
+ Environment *env;
2510
+
2511
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2512
+
2513
+ Unwatch(env, FACTS);
2514
+
2515
+ return Qnil;
2516
+ }
2517
+
2518
+ static VALUE clips_environment_static_unwatch_facts(VALUE self, VALUE rbEnvironment)
2519
+ {
2520
+ return clips_environment_unwatch_facts(rbEnvironment);
2521
+ }
2522
+
2523
+ static VALUE clips_environment_unwatch_instances(VALUE self)
2524
+ {
2525
+ Environment *env;
2526
+
2527
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2528
+
2529
+ Unwatch(env, INSTANCES);
2530
+
2531
+ return Qnil;
2532
+ }
2533
+
2534
+ static VALUE clips_environment_static_unwatch_instances(VALUE self, VALUE rbEnvironment)
2535
+ {
2536
+ return clips_environment_unwatch_instances(rbEnvironment);
2537
+ }
2538
+
2539
+ static VALUE clips_environment_unwatch_slots(VALUE self)
2540
+ {
2541
+ Environment *env;
2542
+
2543
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2544
+
2545
+ Unwatch(env, SLOTS);
2546
+
2547
+ return Qnil;
2548
+ }
2549
+
2550
+ static VALUE clips_environment_static_unwatch_slots(VALUE self, VALUE rbEnvironment)
2551
+ {
2552
+ return clips_environment_unwatch_slots(rbEnvironment);
2553
+ }
2554
+
2555
+ static VALUE clips_environment_unwatch_rules(VALUE self)
2556
+ {
2557
+ Environment *env;
2558
+
2559
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2560
+
2561
+ Unwatch(env, RULES);
2562
+
2563
+ return Qnil;
2564
+ }
2565
+
2566
+ static VALUE clips_environment_static_unwatch_rules(VALUE self, VALUE rbEnvironment)
2567
+ {
2568
+ return clips_environment_unwatch_rules(rbEnvironment);
2569
+ }
2570
+
2571
+ static VALUE clips_environment_unwatch_activations(VALUE self)
2572
+ {
2573
+ Environment *env;
2574
+
2575
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2576
+
2577
+ Unwatch(env, ACTIVATIONS);
2578
+
2579
+ return Qnil;
2580
+ }
2581
+
2582
+ static VALUE clips_environment_static_unwatch_activations(VALUE self, VALUE rbEnvironment)
2583
+ {
2584
+ return clips_environment_unwatch_activations(rbEnvironment);
2585
+ }
2586
+
2587
+ static VALUE clips_environment_unwatch_messages(VALUE self)
2588
+ {
2589
+ Environment *env;
2590
+
2591
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2592
+
2593
+ Unwatch(env, MESSAGES);
2594
+
2595
+ return Qnil;
2596
+ }
2597
+
2598
+ static VALUE clips_environment_static_unwatch_messages(VALUE self, VALUE rbEnvironment)
2599
+ {
2600
+ return clips_environment_unwatch_messages(rbEnvironment);
2601
+ }
2602
+
2603
+ static VALUE clips_environment_unwatch_message_handlers(VALUE self)
2604
+ {
2605
+ Environment *env;
2606
+
2607
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2608
+
2609
+ Unwatch(env, MESSAGE_HANDLERS);
2610
+
2611
+ return Qnil;
2612
+ }
2613
+
2614
+ static VALUE clips_environment_static_unwatch_message_handlers(VALUE self, VALUE rbEnvironment)
2615
+ {
2616
+ return clips_environment_unwatch_message_handlers(rbEnvironment);
2617
+ }
2618
+
2619
+ static VALUE clips_environment_unwatch_generic_functions(VALUE self)
2620
+ {
2621
+ Environment *env;
2622
+
2623
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2624
+
2625
+ Unwatch(env, GENERIC_FUNCTIONS);
2626
+
2627
+ return Qnil;
2628
+ }
2629
+
2630
+ static VALUE clips_environment_static_unwatch_generic_functions(VALUE self, VALUE rbEnvironment)
2631
+ {
2632
+ return clips_environment_unwatch_generic_functions(rbEnvironment);
2633
+ }
2634
+
2635
+ static VALUE clips_environment_unwatch_methods(VALUE self)
2636
+ {
2637
+ Environment *env;
2638
+
2639
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2640
+
2641
+ Unwatch(env, METHODS);
2642
+
2643
+ return Qnil;
2644
+ }
2645
+
2646
+ static VALUE clips_environment_static_unwatch_methods(VALUE self, VALUE rbEnvironment)
2647
+ {
2648
+ return clips_environment_unwatch_methods(rbEnvironment);
2649
+ }
2650
+
2651
+ static VALUE clips_environment_unwatch_deffunctions(VALUE self)
2652
+ {
2653
+ Environment *env;
2654
+
2655
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2656
+
2657
+ Unwatch(env, DEFFUNCTIONS);
2658
+
2659
+ return Qnil;
2660
+ }
2661
+
2662
+ static VALUE clips_environment_static_unwatch_deffunctions(VALUE self, VALUE rbEnvironment)
2663
+ {
2664
+ return clips_environment_unwatch_deffunctions(rbEnvironment);
2665
+ }
2666
+
2667
+ static VALUE clips_environment_unwatch_compilations(VALUE self)
2668
+ {
2669
+ Environment *env;
2670
+
2671
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2672
+
2673
+ Unwatch(env, COMPILATIONS);
2674
+
2675
+ return Qnil;
2676
+ }
2677
+
2678
+ static VALUE clips_environment_static_unwatch_compilations(VALUE self, VALUE rbEnvironment)
2679
+ {
2680
+ return clips_environment_unwatch_compilations(rbEnvironment);
2681
+ }
2682
+
2683
+ static VALUE clips_environment_unwatch_statistics(VALUE self)
2684
+ {
2685
+ Environment *env;
2686
+
2687
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2688
+
2689
+ Unwatch(env, STATISTICS);
2690
+
2691
+ return Qnil;
2692
+ }
2693
+
2694
+ static VALUE clips_environment_static_unwatch_statistics(VALUE self, VALUE rbEnvironment)
2695
+ {
2696
+ return clips_environment_unwatch_statistics(rbEnvironment);
2697
+ }
2698
+
2699
+ static VALUE clips_environment_unwatch_globals(VALUE self)
2700
+ {
2701
+ Environment *env;
2702
+
2703
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2704
+
2705
+ Unwatch(env, GLOBALS);
2706
+
2707
+ return Qnil;
2708
+ }
2709
+
2710
+ static VALUE clips_environment_static_unwatch_globals(VALUE self, VALUE rbEnvironment)
2711
+ {
2712
+ return clips_environment_unwatch_globals(rbEnvironment);
2713
+ }
2714
+
2715
+ static VALUE clips_environment_unwatch_focus(VALUE self)
2716
+ {
2717
+ Environment *env;
2718
+
2719
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2720
+
2721
+ Unwatch(env, FOCUS);
2722
+
2723
+ return Qnil;
2724
+ }
2725
+
2726
+ static VALUE clips_environment_static_unwatch_focus(VALUE self, VALUE rbEnvironment)
2727
+ {
2728
+ return clips_environment_unwatch_focus(rbEnvironment);
2729
+ }
2730
+
2731
+ static VALUE clips_environment_get_watch_state(VALUE self, VALUE item)
2732
+ {
2733
+ Environment *env;
2734
+ WatchItem watchItem;
2735
+
2736
+ TypedData_Get_Struct(self, Environment, &Environment_type, env);
2737
+
2738
+ if (item == ID2SYM(rb_intern("all"))) {
2739
+ watchItem = ALL;
2740
+ } else if (item == ID2SYM(rb_intern("facts"))) {
2741
+ watchItem = FACTS;
2742
+ } else if (item == ID2SYM(rb_intern("instances"))) {
2743
+ watchItem = INSTANCES;
2744
+ } else if (item == ID2SYM(rb_intern("slots"))) {
2745
+ watchItem = SLOTS;
2746
+ } else if (item == ID2SYM(rb_intern("rules"))) {
2747
+ watchItem = RULES;
2748
+ } else if (item == ID2SYM(rb_intern("activations"))) {
2749
+ watchItem = ACTIVATIONS;
2750
+ } else if (item == ID2SYM(rb_intern("messages"))) {
2751
+ watchItem = MESSAGES;
2752
+ } else if (item == ID2SYM(rb_intern("message_handlers"))) {
2753
+ watchItem = MESSAGE_HANDLERS;
2754
+ } else if (item == ID2SYM(rb_intern("generic_functions"))) {
2755
+ watchItem = GENERIC_FUNCTIONS;
2756
+ } else if (item == ID2SYM(rb_intern("methods"))) {
2757
+ watchItem = METHODS;
2758
+ } else if (item == ID2SYM(rb_intern("deffunctions"))) {
2759
+ watchItem = DEFFUNCTIONS;
2760
+ } else if (item == ID2SYM(rb_intern("compilations"))) {
2761
+ watchItem = COMPILATIONS;
2762
+ } else if (item == ID2SYM(rb_intern("statistics"))) {
2763
+ watchItem = STATISTICS;
2764
+ } else if (item == ID2SYM(rb_intern("globals"))) {
2765
+ watchItem = GLOBALS;
2766
+ } else if (item == ID2SYM(rb_intern("focus"))) {
2767
+ watchItem = FOCUS;
2768
+ } else {
2769
+ rb_warn("unknown watch item");
2770
+ return Qnil;
2771
+ }
2772
+
2773
+ if (GetWatchState(env, watchItem)) {
2774
+ return Qtrue;
2775
+ } else {
2776
+ return Qfalse;
2777
+ }
2778
+ }
2779
+
2780
+ static VALUE clips_environment_static_get_watch_state(VALUE self, VALUE rbEnvironment, VALUE item)
2781
+ {
2782
+ return clips_environment_get_watch_state(rbEnvironment, item);
2783
+ }
2784
+
2054
2785
  void Init_clipsruby(void)
2055
2786
  {
2056
2787
  VALUE rbCLIPS = rb_define_module("CLIPS");
@@ -2114,6 +2845,72 @@ void Init_clipsruby(void)
2114
2845
  rb_define_method(rbEnvironment, "get_deftemplate_list", clips_environment_get_deftemplate_list, -1);
2115
2846
  rb_define_singleton_method(rbEnvironment, "find_deffacts", clips_environment_static_find_deffacts, 2);
2116
2847
  rb_define_method(rbEnvironment, "find_deffacts", clips_environment_find_deffacts, 1);
2848
+ rb_define_singleton_method(rbEnvironment, "watch", clips_environment_static_watch, 2);
2849
+ rb_define_method(rbEnvironment, "watch", clips_environment_watch, 1);
2850
+ rb_define_singleton_method(rbEnvironment, "watch_all", clips_environment_static_watch_all, 1);
2851
+ rb_define_method(rbEnvironment, "watch_all", clips_environment_watch_all, 0);
2852
+ rb_define_singleton_method(rbEnvironment, "watch_facts", clips_environment_static_watch_facts, 1);
2853
+ rb_define_method(rbEnvironment, "watch_facts", clips_environment_watch_facts, 0);
2854
+ rb_define_singleton_method(rbEnvironment, "watch_instances", clips_environment_static_watch_instances, 1);
2855
+ rb_define_method(rbEnvironment, "watch_instances", clips_environment_watch_instances, 0);
2856
+ rb_define_singleton_method(rbEnvironment, "watch_slots", clips_environment_static_watch_slots, 1);
2857
+ rb_define_method(rbEnvironment, "watch_slots", clips_environment_watch_slots, 0);
2858
+ rb_define_singleton_method(rbEnvironment, "watch_rules", clips_environment_static_watch_rules, 1);
2859
+ rb_define_method(rbEnvironment, "watch_rules", clips_environment_watch_rules, 0);
2860
+ rb_define_singleton_method(rbEnvironment, "watch_activations", clips_environment_static_watch_activations, 1);
2861
+ rb_define_method(rbEnvironment, "watch_activations", clips_environment_watch_activations, 0);
2862
+ rb_define_singleton_method(rbEnvironment, "watch_messages", clips_environment_static_watch_messages, 1);
2863
+ rb_define_method(rbEnvironment, "watch_messages", clips_environment_watch_messages, 0);
2864
+ rb_define_singleton_method(rbEnvironment, "watch_message_handlers", clips_environment_static_watch_message_handlers, 1);
2865
+ rb_define_method(rbEnvironment, "watch_message_handlers", clips_environment_watch_message_handlers, 0);
2866
+ rb_define_singleton_method(rbEnvironment, "watch_generic_functions", clips_environment_static_watch_generic_functions, 1);
2867
+ rb_define_method(rbEnvironment, "watch_generic_functions", clips_environment_watch_generic_functions, 0);
2868
+ rb_define_singleton_method(rbEnvironment, "watch_methods", clips_environment_static_watch_methods, 1);
2869
+ rb_define_method(rbEnvironment, "watch_methods", clips_environment_watch_methods, 0);
2870
+ rb_define_singleton_method(rbEnvironment, "watch_deffunctions", clips_environment_static_watch_deffunctions, 1);
2871
+ rb_define_method(rbEnvironment, "watch_deffunctions", clips_environment_watch_deffunctions, 0);
2872
+ rb_define_singleton_method(rbEnvironment, "watch_compilations", clips_environment_static_watch_compilations, 1);
2873
+ rb_define_method(rbEnvironment, "watch_compilations", clips_environment_watch_compilations, 0);
2874
+ rb_define_singleton_method(rbEnvironment, "watch_statistics", clips_environment_static_watch_statistics, 1);
2875
+ rb_define_method(rbEnvironment, "watch_statistics", clips_environment_watch_statistics, 0);
2876
+ rb_define_singleton_method(rbEnvironment, "watch_globals", clips_environment_static_watch_globals, 1);
2877
+ rb_define_method(rbEnvironment, "watch_globals", clips_environment_watch_globals, 0);
2878
+ rb_define_singleton_method(rbEnvironment, "watch_focus", clips_environment_static_watch_focus, 1);
2879
+ rb_define_method(rbEnvironment, "watch_focus", clips_environment_watch_focus, 0);
2880
+ rb_define_singleton_method(rbEnvironment, "unwatch", clips_environment_static_unwatch, 2);
2881
+ rb_define_method(rbEnvironment, "unwatch", clips_environment_unwatch, 1);
2882
+ rb_define_singleton_method(rbEnvironment, "unwatch_all", clips_environment_static_unwatch_all, 1);
2883
+ rb_define_method(rbEnvironment, "unwatch_all", clips_environment_unwatch_all, 0);
2884
+ rb_define_singleton_method(rbEnvironment, "unwatch_facts", clips_environment_static_unwatch_facts, 1);
2885
+ rb_define_method(rbEnvironment, "unwatch_facts", clips_environment_unwatch_facts, 0);
2886
+ rb_define_singleton_method(rbEnvironment, "unwatch_instances", clips_environment_static_unwatch_instances, 1);
2887
+ rb_define_method(rbEnvironment, "unwatch_instances", clips_environment_unwatch_instances, 0);
2888
+ rb_define_singleton_method(rbEnvironment, "unwatch_slots", clips_environment_static_unwatch_slots, 1);
2889
+ rb_define_method(rbEnvironment, "unwatch_slots", clips_environment_unwatch_slots, 0);
2890
+ rb_define_singleton_method(rbEnvironment, "unwatch_rules", clips_environment_static_unwatch_rules, 1);
2891
+ rb_define_method(rbEnvironment, "unwatch_rules", clips_environment_unwatch_rules, 0);
2892
+ rb_define_singleton_method(rbEnvironment, "unwatch_activations", clips_environment_static_unwatch_activations, 1);
2893
+ rb_define_method(rbEnvironment, "unwatch_activations", clips_environment_unwatch_activations, 0);
2894
+ rb_define_singleton_method(rbEnvironment, "unwatch_messages", clips_environment_static_unwatch_messages, 1);
2895
+ rb_define_method(rbEnvironment, "unwatch_messages", clips_environment_unwatch_messages, 0);
2896
+ rb_define_singleton_method(rbEnvironment, "unwatch_message_handlers", clips_environment_static_unwatch_message_handlers, 1);
2897
+ rb_define_method(rbEnvironment, "unwatch_message_handlers", clips_environment_unwatch_message_handlers, 0);
2898
+ rb_define_singleton_method(rbEnvironment, "unwatch_generic_functions", clips_environment_static_unwatch_generic_functions, 1);
2899
+ rb_define_method(rbEnvironment, "unwatch_generic_functions", clips_environment_unwatch_generic_functions, 0);
2900
+ rb_define_singleton_method(rbEnvironment, "unwatch_methods", clips_environment_static_unwatch_methods, 1);
2901
+ rb_define_method(rbEnvironment, "unwatch_methods", clips_environment_unwatch_methods, 0);
2902
+ rb_define_singleton_method(rbEnvironment, "unwatch_deffunctions", clips_environment_static_unwatch_deffunctions, 1);
2903
+ rb_define_method(rbEnvironment, "unwatch_deffunctions", clips_environment_unwatch_deffunctions, 0);
2904
+ rb_define_singleton_method(rbEnvironment, "unwatch_compilations", clips_environment_static_unwatch_compilations, 1);
2905
+ rb_define_method(rbEnvironment, "unwatch_compilations", clips_environment_unwatch_compilations, 0);
2906
+ rb_define_singleton_method(rbEnvironment, "unwatch_statistics", clips_environment_static_unwatch_statistics, 1);
2907
+ rb_define_method(rbEnvironment, "unwatch_statistics", clips_environment_unwatch_statistics, 0);
2908
+ rb_define_singleton_method(rbEnvironment, "unwatch_globals", clips_environment_static_unwatch_globals, 1);
2909
+ rb_define_method(rbEnvironment, "unwatch_globals", clips_environment_unwatch_globals, 0);
2910
+ rb_define_singleton_method(rbEnvironment, "unwatch_focus", clips_environment_static_unwatch_focus, 1);
2911
+ rb_define_method(rbEnvironment, "unwatch_focus", clips_environment_unwatch_focus, 0);
2912
+ rb_define_singleton_method(rbEnvironment, "get_watch_state", clips_environment_static_get_watch_state, 2);
2913
+ rb_define_method(rbEnvironment, "get_watch_state", clips_environment_get_watch_state, 1);
2117
2914
 
2118
2915
  VALUE rbDeffacts = rb_define_class_under(rbEnvironment, "Deffacts", rb_cObject);
2119
2916
  rb_define_alloc_func(rbDeffacts, deffacts_alloc);
@@ -2140,6 +2937,12 @@ void Init_clipsruby(void)
2140
2937
  rb_define_method(rbDeftemplate, "slot_allowed_values", clips_environment_deftemplate_slot_allowed_values, 1);
2141
2938
  rb_define_singleton_method(rbDeftemplate, "slot_default_value", clips_environment_deftemplate_static_slot_default_value, 2);
2142
2939
  rb_define_method(rbDeftemplate, "slot_default_value", clips_environment_deftemplate_slot_default_value, 1);
2940
+ rb_define_singleton_method(rbDeftemplate, "slot_types", clips_environment_deftemplate_static_slot_types, 2);
2941
+ rb_define_method(rbDeftemplate, "slot_types", clips_environment_deftemplate_slot_types, 1);
2942
+ rb_define_singleton_method(rbDeftemplate, "slot_range", clips_environment_deftemplate_static_slot_range, 2);
2943
+ rb_define_method(rbDeftemplate, "slot_range", clips_environment_deftemplate_slot_range, 1);
2944
+ rb_define_singleton_method(rbDeftemplate, "slot_cardinality", clips_environment_deftemplate_static_slot_cardinality, 2);
2945
+ rb_define_method(rbDeftemplate, "slot_cardinality", clips_environment_deftemplate_slot_cardinality, 1);
2143
2946
 
2144
2947
  VALUE rbDefmodule = rb_define_class_under(rbEnvironment, "Defmodule", rb_cObject);
2145
2948
  rb_define_alloc_func(rbDefmodule, defmodule_alloc);
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clipsruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.24
4
+ version: 0.0.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Johnston
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-15 00:00:00.000000000 Z
11
+ date: 2024-09-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Calling the CLIPS programming language from within Ruby
14
14
  email: mrryanjohnston@gmail.com