clipsruby 0.0.25 → 0.0.27
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.
- checksums.yaml +4 -4
- data/README.md +95 -0
- data/ext/clipsruby/clipsruby.c +237 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78727d42b56ea442a2ff5b487d3cc209bcfda2068724a7507021fa44845dee9c
|
4
|
+
data.tar.gz: f22f44dc57cdf4d8e1491b1b9790c45a15264b9fcad34b3b768e6deb9655a475
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abd28dcfe9303c838636a209fdcd1d043ae7c0fa72b84ae49ea52c2e79aed9f2d65c58cd02746cdfd9bc4230476dcb4289ea32cc36f2e335ba54371008146e3b
|
7
|
+
data.tar.gz: a9dd833a9d045713eb20ab356d65bb80c7a61d528518f5b7dd83482a059042a3499f3fb33f06259ab667af3fc2dea22102bcb103acf50f41900537301980d5d0
|
data/README.md
CHANGED
@@ -621,6 +621,101 @@ 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
|
+
|
669
|
+
### `CLIPS::Environment::Deftemplate.slot_existp`
|
670
|
+
### `CLIPS::Environment::Deftemplate#slot_existp`
|
671
|
+
|
672
|
+
Returns a boolean for whether or not the slot with a given name
|
673
|
+
exists on the Deftemplate.
|
674
|
+
|
675
|
+
```ruby
|
676
|
+
CLIPS::Environment::Deftemplate.slot_existp(deftemplate, :foo)
|
677
|
+
deftemplate.slot_existp('bar')
|
678
|
+
```
|
679
|
+
|
680
|
+
### `CLIPS::Environment::Deftemplate.slot_singlep`
|
681
|
+
### `CLIPS::Environment::Deftemplate#slot_singlep`
|
682
|
+
|
683
|
+
Returns a boolean for whether or not the slot with a given name
|
684
|
+
on the Deftemplate is a single slot.
|
685
|
+
|
686
|
+
```ruby
|
687
|
+
CLIPS::Environment::Deftemplate.slot_singlep(deftemplate, :foo)
|
688
|
+
deftemplate.slot_singlep('bar')
|
689
|
+
```
|
690
|
+
|
691
|
+
### `CLIPS::Environment::Deftemplate.slot_multip`
|
692
|
+
### `CLIPS::Environment::Deftemplate#slot_multip`
|
693
|
+
|
694
|
+
Returns a boolean for whether or not the slot with a given name
|
695
|
+
on the Deftemplate is a multislot.
|
696
|
+
|
697
|
+
```ruby
|
698
|
+
CLIPS::Environment::Deftemplate.slot_multip(deftemplate, :foo)
|
699
|
+
deftemplate.slot_multip('bar')
|
700
|
+
```
|
701
|
+
|
702
|
+
### `CLIPS::Environment::Deftemplate.slot_defaultp`
|
703
|
+
### `CLIPS::Environment::Deftemplate#slot_defaultp`
|
704
|
+
|
705
|
+
Returns a symbol representing the type of default value a slot has
|
706
|
+
on the Deftemplate. Possible return values are as follows:
|
707
|
+
|
708
|
+
```ruby
|
709
|
+
:NO_DEFAULT
|
710
|
+
:STATIC_DEFAULT
|
711
|
+
:DYNAMIC_DEFAULT
|
712
|
+
```
|
713
|
+
|
714
|
+
```ruby
|
715
|
+
CLIPS::Environment::Deftemplate.slot_defaultp(deftemplate, :foo)
|
716
|
+
deftemplate.slot_defaultp('bar')
|
717
|
+
```
|
718
|
+
|
624
719
|
### `CLIPS::Environment::Defmodule.get_deftemplate_list`
|
625
720
|
### `CLIPS::Environment::Defmodule#get_deftemplate_list`
|
626
721
|
|
data/ext/clipsruby/clipsruby.c
CHANGED
@@ -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;
|
@@ -1999,6 +2092,136 @@ static VALUE clips_environment_deftemplate_static_is_deletable(VALUE self, VALUE
|
|
1999
2092
|
return clips_environment_deftemplate_is_deletable(rbDeftemplate);
|
2000
2093
|
}
|
2001
2094
|
|
2095
|
+
static VALUE clips_environment_deftemplate_slot_existp(VALUE self, VALUE slot_name)
|
2096
|
+
{
|
2097
|
+
Deftemplate *deftemplate;
|
2098
|
+
const char *cslot_name;
|
2099
|
+
switch(TYPE(slot_name))
|
2100
|
+
{
|
2101
|
+
case T_SYMBOL:
|
2102
|
+
cslot_name = rb_id2name(SYM2ID(slot_name));
|
2103
|
+
break;
|
2104
|
+
case T_STRING:
|
2105
|
+
cslot_name = StringValueCStr(slot_name);
|
2106
|
+
break;
|
2107
|
+
default:
|
2108
|
+
rb_raise(rb_eTypeError, "Slot name must be a String or a Symbol");
|
2109
|
+
return ST_CONTINUE;
|
2110
|
+
}
|
2111
|
+
|
2112
|
+
TypedData_Get_Struct(self, Deftemplate, &Deftemplate_type, deftemplate);
|
2113
|
+
|
2114
|
+
if (DeftemplateSlotExistP(deftemplate, cslot_name)) {
|
2115
|
+
return Qtrue;
|
2116
|
+
} else {
|
2117
|
+
return Qfalse;
|
2118
|
+
}
|
2119
|
+
}
|
2120
|
+
|
2121
|
+
static VALUE clips_environment_deftemplate_static_slot_existp(VALUE self, VALUE rbDeftemplate, VALUE slot_name)
|
2122
|
+
{
|
2123
|
+
return clips_environment_deftemplate_slot_existp(rbDeftemplate, slot_name);
|
2124
|
+
}
|
2125
|
+
|
2126
|
+
static VALUE clips_environment_deftemplate_slot_singlep(VALUE self, VALUE slot_name)
|
2127
|
+
{
|
2128
|
+
Deftemplate *deftemplate;
|
2129
|
+
const char *cslot_name;
|
2130
|
+
switch(TYPE(slot_name))
|
2131
|
+
{
|
2132
|
+
case T_SYMBOL:
|
2133
|
+
cslot_name = rb_id2name(SYM2ID(slot_name));
|
2134
|
+
break;
|
2135
|
+
case T_STRING:
|
2136
|
+
cslot_name = StringValueCStr(slot_name);
|
2137
|
+
break;
|
2138
|
+
default:
|
2139
|
+
rb_raise(rb_eTypeError, "Slot name must be a String or a Symbol");
|
2140
|
+
return ST_CONTINUE;
|
2141
|
+
}
|
2142
|
+
|
2143
|
+
TypedData_Get_Struct(self, Deftemplate, &Deftemplate_type, deftemplate);
|
2144
|
+
|
2145
|
+
if (DeftemplateSlotSingleP(deftemplate, cslot_name)) {
|
2146
|
+
return Qtrue;
|
2147
|
+
} else {
|
2148
|
+
return Qfalse;
|
2149
|
+
}
|
2150
|
+
}
|
2151
|
+
|
2152
|
+
static VALUE clips_environment_deftemplate_static_slot_singlep(VALUE self, VALUE rbDeftemplate, VALUE slot_name)
|
2153
|
+
{
|
2154
|
+
return clips_environment_deftemplate_slot_singlep(rbDeftemplate, slot_name);
|
2155
|
+
}
|
2156
|
+
|
2157
|
+
static VALUE clips_environment_deftemplate_slot_multip(VALUE self, VALUE slot_name)
|
2158
|
+
{
|
2159
|
+
Deftemplate *deftemplate;
|
2160
|
+
const char *cslot_name;
|
2161
|
+
switch(TYPE(slot_name))
|
2162
|
+
{
|
2163
|
+
case T_SYMBOL:
|
2164
|
+
cslot_name = rb_id2name(SYM2ID(slot_name));
|
2165
|
+
break;
|
2166
|
+
case T_STRING:
|
2167
|
+
cslot_name = StringValueCStr(slot_name);
|
2168
|
+
break;
|
2169
|
+
default:
|
2170
|
+
rb_raise(rb_eTypeError, "Slot name must be a String or a Symbol");
|
2171
|
+
return ST_CONTINUE;
|
2172
|
+
}
|
2173
|
+
|
2174
|
+
TypedData_Get_Struct(self, Deftemplate, &Deftemplate_type, deftemplate);
|
2175
|
+
|
2176
|
+
if (DeftemplateSlotMultiP(deftemplate, cslot_name)) {
|
2177
|
+
return Qtrue;
|
2178
|
+
} else {
|
2179
|
+
return Qfalse;
|
2180
|
+
}
|
2181
|
+
}
|
2182
|
+
|
2183
|
+
static VALUE clips_environment_deftemplate_static_slot_multip(VALUE self, VALUE rbDeftemplate, VALUE slot_name)
|
2184
|
+
{
|
2185
|
+
return clips_environment_deftemplate_slot_multip(rbDeftemplate, slot_name);
|
2186
|
+
}
|
2187
|
+
|
2188
|
+
static VALUE clips_environment_deftemplate_slot_defaultp(VALUE self, VALUE slot_name)
|
2189
|
+
{
|
2190
|
+
Deftemplate *deftemplate;
|
2191
|
+
const char *cslot_name;
|
2192
|
+
switch(TYPE(slot_name))
|
2193
|
+
{
|
2194
|
+
case T_SYMBOL:
|
2195
|
+
cslot_name = rb_id2name(SYM2ID(slot_name));
|
2196
|
+
break;
|
2197
|
+
case T_STRING:
|
2198
|
+
cslot_name = StringValueCStr(slot_name);
|
2199
|
+
break;
|
2200
|
+
default:
|
2201
|
+
rb_warn("Slot name must be a String or a Symbol");
|
2202
|
+
return Qnil;
|
2203
|
+
}
|
2204
|
+
|
2205
|
+
TypedData_Get_Struct(self, Deftemplate, &Deftemplate_type, deftemplate);
|
2206
|
+
|
2207
|
+
switch (DeftemplateSlotDefaultP(deftemplate, cslot_name)) {
|
2208
|
+
case NO_DEFAULT:
|
2209
|
+
return ID2SYM(rb_intern("NO_DEFAULT"));
|
2210
|
+
case STATIC_DEFAULT:
|
2211
|
+
return ID2SYM(rb_intern("STATIC_DEFAULT"));
|
2212
|
+
case DYNAMIC_DEFAULT:
|
2213
|
+
return ID2SYM(rb_intern("DYNAMIC_DEFAULT"));
|
2214
|
+
default:
|
2215
|
+
rb_warn("CLIPS returned something we didn't expect for slot_defaultp...");
|
2216
|
+
return Qnil;
|
2217
|
+
}
|
2218
|
+
}
|
2219
|
+
|
2220
|
+
static VALUE clips_environment_deftemplate_static_slot_defaultp(VALUE self, VALUE rbDeftemplate, VALUE slot_name)
|
2221
|
+
{
|
2222
|
+
return clips_environment_deftemplate_slot_defaultp(rbDeftemplate, slot_name);
|
2223
|
+
}
|
2224
|
+
|
2002
2225
|
static VALUE clips_environment_defrule_has_breakpoint(VALUE self)
|
2003
2226
|
{
|
2004
2227
|
Defrule *defrule;
|
@@ -2844,6 +3067,20 @@ void Init_clipsruby(void)
|
|
2844
3067
|
rb_define_method(rbDeftemplate, "slot_allowed_values", clips_environment_deftemplate_slot_allowed_values, 1);
|
2845
3068
|
rb_define_singleton_method(rbDeftemplate, "slot_default_value", clips_environment_deftemplate_static_slot_default_value, 2);
|
2846
3069
|
rb_define_method(rbDeftemplate, "slot_default_value", clips_environment_deftemplate_slot_default_value, 1);
|
3070
|
+
rb_define_singleton_method(rbDeftemplate, "slot_types", clips_environment_deftemplate_static_slot_types, 2);
|
3071
|
+
rb_define_method(rbDeftemplate, "slot_types", clips_environment_deftemplate_slot_types, 1);
|
3072
|
+
rb_define_singleton_method(rbDeftemplate, "slot_range", clips_environment_deftemplate_static_slot_range, 2);
|
3073
|
+
rb_define_method(rbDeftemplate, "slot_range", clips_environment_deftemplate_slot_range, 1);
|
3074
|
+
rb_define_singleton_method(rbDeftemplate, "slot_cardinality", clips_environment_deftemplate_static_slot_cardinality, 2);
|
3075
|
+
rb_define_method(rbDeftemplate, "slot_cardinality", clips_environment_deftemplate_slot_cardinality, 1);
|
3076
|
+
rb_define_singleton_method(rbDeftemplate, "slot_existp", clips_environment_deftemplate_static_slot_existp, 2);
|
3077
|
+
rb_define_method(rbDeftemplate, "slot_existp", clips_environment_deftemplate_slot_existp, 1);
|
3078
|
+
rb_define_singleton_method(rbDeftemplate, "slot_singlep", clips_environment_deftemplate_static_slot_singlep, 2);
|
3079
|
+
rb_define_method(rbDeftemplate, "slot_singlep", clips_environment_deftemplate_slot_singlep, 1);
|
3080
|
+
rb_define_singleton_method(rbDeftemplate, "slot_multip", clips_environment_deftemplate_static_slot_multip, 2);
|
3081
|
+
rb_define_method(rbDeftemplate, "slot_multip", clips_environment_deftemplate_slot_multip, 1);
|
3082
|
+
rb_define_singleton_method(rbDeftemplate, "slot_defaultp", clips_environment_deftemplate_static_slot_defaultp, 2);
|
3083
|
+
rb_define_method(rbDeftemplate, "slot_defaultp", clips_environment_deftemplate_slot_defaultp, 1);
|
2847
3084
|
|
2848
3085
|
VALUE rbDefmodule = rb_define_class_under(rbEnvironment, "Defmodule", rb_cObject);
|
2849
3086
|
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.
|
4
|
+
version: 0.0.27
|
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-
|
11
|
+
date: 2024-09-18 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
|