clipsruby 0.0.23 → 0.0.24

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 +50 -0
  3. data/ext/clipsruby/clipsruby.c +133 -0
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 994b076d823d294b992d1621ec327e72cd415602c744d3214b16e15b6624dcbd
4
- data.tar.gz: 864a892fb3405400362b6ceeea13d24f3c22bf4508f4013b14c6f3a6dd102e4f
3
+ metadata.gz: 1efd15213fd7f558c0b75e64869e6518a12c1c55da8d6d94bf306235f4879a67
4
+ data.tar.gz: b30352c0431948b03849579a92a0e96dde42368f6e78b051adc2f02b68c8c4c8
5
5
  SHA512:
6
- metadata.gz: 0a2bbd8b165667a1a2b07b19b8099ec0dfae9ccbf4b669d469421f5db66c53840a00a0855f07479b272e030b0fb06430f28382340af1e3efe60af13858542ca4
7
- data.tar.gz: 918c4ffd67a5623d761805e4f60920c4ac250e321cb33fca2f61ad26ff5ac28b4cc92acaaeaa1478e8110c3697d719a9c8e69da5da96fcda88d5b2a4d078bef0
6
+ metadata.gz: 5e55eac1476475ecb1f5b5b998cab1aa108dc0fcbe86905565c3b9256c4855ac796cdd9a28602289dec062c9481ac6340d17c7d22b98b1baf2b0b9e3f338136a
7
+ data.tar.gz: 31c41a7c633cc0707bdfc77e9e9c5b97b2d97d75f8202ce0d7450f7366ec9ee0e2939bcd91d7c228d3d96459ff516eb6f81959981cb1414b53f8c8ee514c6dea
data/README.md CHANGED
@@ -571,6 +571,56 @@ CLIPS::Environment::Deftemplate.assert_hash(deftemplate, foo: :bar)
571
571
  deftemplate.assert_hash(foo: :bar)
572
572
  ```
573
573
 
574
+ ### `CLIPS::Environment::Deftemplate.defmodule_name`
575
+ ### `CLIPS::Environment::Deftemplate#defmodule_name`
576
+
577
+ Returns the name of the defmodule in which the deftemplate is defined
578
+
579
+ ```ruby
580
+ CLIPS::Environment::Deftemplate.defmodule_name(deftemplate)
581
+ deftemplate.defmodule_name
582
+ ```
583
+
584
+ ### `CLIPS::Environment::Deftemplate.slot_names`
585
+ ### `CLIPS::Environment::Deftemplate#slot_names`
586
+
587
+ Returns the slot names of a deftemplate as symbols
588
+
589
+ ```ruby
590
+ CLIPS::Environment::Deftemplate.slot_names(deftemplate)
591
+ deftemplate.slot_names
592
+ ```
593
+
594
+ ### `CLIPS::Environment::Deftemplate.is_deletable`
595
+ ### `CLIPS::Environment::Deftemplate#is_deletable`
596
+
597
+ Returns a boolean whether the Deftemplate is deletable or not
598
+
599
+ ```ruby
600
+ CLIPS::Environment::Deftemplate.is_deletable(deftemplate)
601
+ deftemplate.is_deletable
602
+ ```
603
+
604
+ ### `CLIPS::Environment::Deftemplate.slot_allowed_values`
605
+ ### `CLIPS::Environment::Deftemplate#slot_allowed_values`
606
+
607
+ Returns the allowed values for the slot of a deftemplate as symbols
608
+
609
+ ```ruby
610
+ CLIPS::Environment::Deftemplate.slot_allowed_values(deftemplate, :foo)
611
+ deftemplate.slot_allowed_values('bar')
612
+ ```
613
+
614
+ ### `CLIPS::Environment::Deftemplate.slot_default_value`
615
+ ### `CLIPS::Environment::Deftemplate#slot_default_value`
616
+
617
+ Returns the default value(s) for the slot of a deftemplate as symbols
618
+
619
+ ```ruby
620
+ CLIPS::Environment::Deftemplate.slot_default_value(deftemplate, :foo)
621
+ deftemplate.slot_default_value('bar')
622
+ ```
623
+
574
624
  ### `CLIPS::Environment::Defmodule.get_deftemplate_list`
575
625
  ### `CLIPS::Environment::Defmodule#get_deftemplate_list`
576
626
 
@@ -96,6 +96,21 @@ static VALUE clips_environment_fact_static_deftemplate_name(VALUE self, VALUE rb
96
96
  return clips_environment_fact_deftemplate_name(rbFact);
97
97
  }
98
98
 
99
+ static VALUE clips_environment_deftemplate_defmodule_name(VALUE self)
100
+ {
101
+ Deftemplate *template;
102
+
103
+ TypedData_Get_Struct(self, Deftemplate, &Deftemplate_type, template);
104
+
105
+ return ID2SYM(rb_intern(DeftemplateModule(template)));
106
+ }
107
+
108
+ static VALUE clips_environment_deftemplate_static_defmodule_name(VALUE self, VALUE rbDeftemplate)
109
+ {
110
+ return clips_environment_deftemplate_defmodule_name(rbDeftemplate);
111
+ }
112
+
113
+
99
114
  void environment_free(void *data)
100
115
  {
101
116
  DestroyEnvironment((Environment*) data);
@@ -736,6 +751,31 @@ static VALUE clips_environment_static_add_udf(int argc, VALUE *argv, VALUE klass
736
751
  return _clips_environment_add_udf(environment, method_name, clips_function_name);
737
752
  }
738
753
 
754
+ static VALUE clips_environment_deftemplate_slot_names(VALUE self)
755
+ {
756
+ Deftemplate *template;
757
+ Environment *env;
758
+ CLIPSValue value;
759
+ VALUE out;
760
+
761
+ VALUE rbEnvironment = rb_iv_get(self, "@environment");
762
+
763
+ TypedData_Get_Struct(self, Deftemplate, &Deftemplate_type, template);
764
+ TypedData_Get_Struct(rbEnvironment, Environment, &Environment_type, env);
765
+
766
+ DeftemplateSlotNames(template, &value);
767
+
768
+ CLIPSValue_to_VALUE(&value, &out, &rbEnvironment);
769
+
770
+ return out;
771
+ }
772
+
773
+ static VALUE clips_environment_deftemplate_static_slot_names(VALUE self, VALUE rbDeftemplate)
774
+ {
775
+ return clips_environment_deftemplate_slot_names(rbDeftemplate);
776
+ }
777
+
778
+
739
779
  static VALUE clips_environment_run(int argc, VALUE *argv, VALUE environment) {
740
780
  VALUE integer;
741
781
  Environment *env;
@@ -1195,6 +1235,71 @@ static VALUE clips_environment_fact_static_get_slot(VALUE self, VALUE rbFact, VA
1195
1235
  return clips_environment_fact_get_slot(rbFact, slot_name);
1196
1236
  }
1197
1237
 
1238
+ static VALUE clips_environment_deftemplate_slot_allowed_values(VALUE self, VALUE slot_name)
1239
+ {
1240
+ Deftemplate *template;
1241
+ CLIPSValue slot_allowed_values;
1242
+ VALUE rbEnvironment = rb_iv_get(self, "@environment");
1243
+
1244
+ TypedData_Get_Struct(self, Deftemplate, &Deftemplate_type, template);
1245
+
1246
+ switch (TYPE(slot_name)) {
1247
+ case T_STRING:
1248
+ DeftemplateSlotAllowedValues(template, StringValueCStr(slot_name), &slot_allowed_values);
1249
+ break;
1250
+ case T_SYMBOL:
1251
+ DeftemplateSlotAllowedValues(template, rb_id2name(SYM2ID(slot_name)), &slot_allowed_values);
1252
+ break;
1253
+ default:
1254
+ rb_warn("slot name must be string or symbol in call to slot_allowed_values!");
1255
+ return Qnil;
1256
+ }
1257
+
1258
+ VALUE out;
1259
+
1260
+ CLIPSValue_to_VALUE(&slot_allowed_values, &out, &rbEnvironment);
1261
+
1262
+ return out;
1263
+ }
1264
+
1265
+ static VALUE clips_environment_deftemplate_static_slot_allowed_values(VALUE self, VALUE rbDeftemplate, VALUE slot_name)
1266
+ {
1267
+ return clips_environment_deftemplate_slot_allowed_values(rbDeftemplate, slot_name);
1268
+ }
1269
+
1270
+ static VALUE clips_environment_deftemplate_slot_default_value(VALUE self, VALUE slot_name)
1271
+ {
1272
+ Deftemplate *template;
1273
+ CLIPSValue slot_default_value;
1274
+ VALUE rbEnvironment = rb_iv_get(self, "@environment");
1275
+
1276
+ TypedData_Get_Struct(self, Deftemplate, &Deftemplate_type, template);
1277
+
1278
+ switch (TYPE(slot_name)) {
1279
+ case T_STRING:
1280
+ DeftemplateSlotDefaultValue(template, StringValueCStr(slot_name), &slot_default_value);
1281
+ break;
1282
+ case T_SYMBOL:
1283
+ DeftemplateSlotDefaultValue(template, rb_id2name(SYM2ID(slot_name)), &slot_default_value);
1284
+ break;
1285
+ default:
1286
+ rb_warn("slot name must be string or symbol in call to slot_default_value!");
1287
+ return Qnil;
1288
+ }
1289
+
1290
+ VALUE out;
1291
+
1292
+ CLIPSValue_to_VALUE(&slot_default_value, &out, &rbEnvironment);
1293
+
1294
+ return out;
1295
+ }
1296
+
1297
+ static VALUE clips_environment_deftemplate_static_slot_default_value(VALUE self, VALUE rbDeftemplate, VALUE slot_name)
1298
+ {
1299
+ return clips_environment_deftemplate_slot_default_value(rbDeftemplate, slot_name);
1300
+ }
1301
+
1302
+
1198
1303
  static VALUE clips_environment_fact_retract(VALUE self)
1199
1304
  {
1200
1305
  Fact *fact;
@@ -1876,6 +1981,24 @@ static VALUE clips_environment_defrule_static_is_deletable(VALUE self, VALUE rbD
1876
1981
  return clips_environment_defrule_is_deletable(rbDefrule);
1877
1982
  }
1878
1983
 
1984
+ static VALUE clips_environment_deftemplate_is_deletable(VALUE self)
1985
+ {
1986
+ Deftemplate *deftemplate;
1987
+
1988
+ TypedData_Get_Struct(self, Deftemplate, &Deftemplate_type, deftemplate);
1989
+
1990
+ if (DeftemplateIsDeletable(deftemplate)) {
1991
+ return Qtrue;
1992
+ } else {
1993
+ return Qfalse;
1994
+ }
1995
+ }
1996
+
1997
+ static VALUE clips_environment_deftemplate_static_is_deletable(VALUE self, VALUE rbDeftemplate)
1998
+ {
1999
+ return clips_environment_deftemplate_is_deletable(rbDeftemplate);
2000
+ }
2001
+
1879
2002
  static VALUE clips_environment_defrule_has_breakpoint(VALUE self)
1880
2003
  {
1881
2004
  Defrule *defrule;
@@ -2007,6 +2130,16 @@ void Init_clipsruby(void)
2007
2130
  rb_define_method(rbDeftemplate, "pp_form", clips_environment_deftemplate_pp_form, 0);
2008
2131
  rb_define_singleton_method(rbDeftemplate, "assert_hash", clips_environment_deftemplate_static_assert_hash, 2);
2009
2132
  rb_define_method(rbDeftemplate, "assert_hash", clips_environment_deftemplate_assert_hash, 1);
2133
+ rb_define_singleton_method(rbDeftemplate, "defmodule_name", clips_environment_deftemplate_static_defmodule_name, 1);
2134
+ rb_define_method(rbDeftemplate, "defmodule_name", clips_environment_deftemplate_defmodule_name, 0);
2135
+ rb_define_singleton_method(rbDeftemplate, "slot_names", clips_environment_deftemplate_static_slot_names, 1);
2136
+ rb_define_method(rbDeftemplate, "slot_names", clips_environment_deftemplate_slot_names, 0);
2137
+ rb_define_singleton_method(rbDeftemplate, "is_deletable", clips_environment_deftemplate_static_is_deletable, 1);
2138
+ rb_define_method(rbDeftemplate, "is_deletable", clips_environment_deftemplate_is_deletable, 0);
2139
+ rb_define_singleton_method(rbDeftemplate, "slot_allowed_values", clips_environment_deftemplate_static_slot_allowed_values, 2);
2140
+ rb_define_method(rbDeftemplate, "slot_allowed_values", clips_environment_deftemplate_slot_allowed_values, 1);
2141
+ rb_define_singleton_method(rbDeftemplate, "slot_default_value", clips_environment_deftemplate_static_slot_default_value, 2);
2142
+ rb_define_method(rbDeftemplate, "slot_default_value", clips_environment_deftemplate_slot_default_value, 1);
2010
2143
 
2011
2144
  VALUE rbDefmodule = rb_define_class_under(rbEnvironment, "Defmodule", rb_cObject);
2012
2145
  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.23
4
+ version: 0.0.24
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-14 00:00:00.000000000 Z
11
+ date: 2024-09-15 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