clipsruby 0.0.26 → 0.0.28

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 +60 -0
  3. data/ext/clipsruby/clipsruby.c +158 -0
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb3538a29ed740232a6a18314da3443bf632274e06fcb893cba9c70b0797353d
4
- data.tar.gz: 49d5cf4c8e4435fb0b35cfe2434f2aeb12f0563e859c9b0fc93fb8d64b47ee29
3
+ metadata.gz: c3422d24e21cf31d89d413801a5804b91bdca8cfab4adc230bcdaeb6d4da3085
4
+ data.tar.gz: f34d498c8130445406058e05073abe0d48cc7c7a1c2fe5b4e2fb799bf4836f7a
5
5
  SHA512:
6
- metadata.gz: 1bb0d0617bcf972ca6cbad967ff271e697920e21442d978ce9ee289c0f7e81f53b30fe1b722e334649ed274b62f10e2728683f8e5df84853f3ca6575f8a11444
7
- data.tar.gz: 66b6617635f3ba892008749dee6645cbc6652e3815b19c37bea2eb752a231d342c0d0ab1873faae8bc14e07b238c2b298f3574907ef4fae7d7dae0a0cd0a30bd
6
+ metadata.gz: 9b22a805380544262da7bf544c163159a5b5846a8ce2c0da2754f2bcdabaea6c8209cf6c5b8154606bb14498a38e0fac9751e51926e03cddab7f120018905291
7
+ data.tar.gz: f13099a933300723e7e1062d6c4e144e286726476e942f172457cbc38c6e4957f982caf007cf0acbdb41b2a0c7713ce494712794670883a934580a4fd101b556
data/README.md CHANGED
@@ -312,6 +312,16 @@ CLIPS::Environment::Fact.pp_form(fact)
312
312
  fact.pp_form
313
313
  ```
314
314
 
315
+ ### `CLIPS::Environment::Fact.existp`
316
+ ### `CLIPS::Environment::Fact#existp`
317
+
318
+ Returns a boolean representing whether or not a Fact has been retracted
319
+
320
+ ```ruby
321
+ CLIPS::Environment::Fact.existp(fact)
322
+ fact.existp
323
+ ```
324
+
315
325
  ### `CLIPS::Environment::Fact.to_h`
316
326
  ### `CLIPS::Environment::Fact#to_h`
317
327
 
@@ -666,6 +676,56 @@ CLIPS::Environment::Deftemplate.slot_cardinality(deftemplate, :foo)
666
676
  deftemplate.slot_cardinality('bar')
667
677
  ```
668
678
 
679
+ ### `CLIPS::Environment::Deftemplate.slot_existp`
680
+ ### `CLIPS::Environment::Deftemplate#slot_existp`
681
+
682
+ Returns a boolean for whether or not the slot with a given name
683
+ exists on the Deftemplate.
684
+
685
+ ```ruby
686
+ CLIPS::Environment::Deftemplate.slot_existp(deftemplate, :foo)
687
+ deftemplate.slot_existp('bar')
688
+ ```
689
+
690
+ ### `CLIPS::Environment::Deftemplate.slot_singlep`
691
+ ### `CLIPS::Environment::Deftemplate#slot_singlep`
692
+
693
+ Returns a boolean for whether or not the slot with a given name
694
+ on the Deftemplate is a single slot.
695
+
696
+ ```ruby
697
+ CLIPS::Environment::Deftemplate.slot_singlep(deftemplate, :foo)
698
+ deftemplate.slot_singlep('bar')
699
+ ```
700
+
701
+ ### `CLIPS::Environment::Deftemplate.slot_multip`
702
+ ### `CLIPS::Environment::Deftemplate#slot_multip`
703
+
704
+ Returns a boolean for whether or not the slot with a given name
705
+ on the Deftemplate is a multislot.
706
+
707
+ ```ruby
708
+ CLIPS::Environment::Deftemplate.slot_multip(deftemplate, :foo)
709
+ deftemplate.slot_multip('bar')
710
+ ```
711
+
712
+ ### `CLIPS::Environment::Deftemplate.slot_defaultp`
713
+ ### `CLIPS::Environment::Deftemplate#slot_defaultp`
714
+
715
+ Returns a symbol representing the type of default value a slot has
716
+ on the Deftemplate. Possible return values are as follows:
717
+
718
+ ```ruby
719
+ :NO_DEFAULT
720
+ :STATIC_DEFAULT
721
+ :DYNAMIC_DEFAULT
722
+ ```
723
+
724
+ ```ruby
725
+ CLIPS::Environment::Deftemplate.slot_defaultp(deftemplate, :foo)
726
+ deftemplate.slot_defaultp('bar')
727
+ ```
728
+
669
729
  ### `CLIPS::Environment::Defmodule.get_deftemplate_list`
670
730
  ### `CLIPS::Environment::Defmodule#get_deftemplate_list`
671
731
 
@@ -1796,6 +1796,24 @@ static VALUE clips_environment_fact_static_pp_form(int argc, VALUE *argv, VALUE
1796
1796
  return toReturn;
1797
1797
  }
1798
1798
 
1799
+ static VALUE clips_environment_fact_existp(VALUE self)
1800
+ {
1801
+ Fact *fact;
1802
+
1803
+ TypedData_Get_Struct(self, Fact, &Fact_type, fact);
1804
+
1805
+ if (FactExistp(fact)) {
1806
+ return Qtrue;
1807
+ } else {
1808
+ return Qfalse;
1809
+ }
1810
+ }
1811
+
1812
+ static VALUE clips_environment_fact_static_existp(VALUE self, VALUE rbFact)
1813
+ {
1814
+ return clips_environment_fact_existp(rbFact);
1815
+ }
1816
+
1799
1817
  static VALUE clips_environment_get_fact_list(int argc, VALUE *argv, VALUE rbEnvironment) {
1800
1818
  VALUE defmodule_or_defmodule_name;
1801
1819
  Environment *env;
@@ -2092,6 +2110,136 @@ static VALUE clips_environment_deftemplate_static_is_deletable(VALUE self, VALUE
2092
2110
  return clips_environment_deftemplate_is_deletable(rbDeftemplate);
2093
2111
  }
2094
2112
 
2113
+ static VALUE clips_environment_deftemplate_slot_existp(VALUE self, VALUE slot_name)
2114
+ {
2115
+ Deftemplate *deftemplate;
2116
+ const char *cslot_name;
2117
+ switch(TYPE(slot_name))
2118
+ {
2119
+ case T_SYMBOL:
2120
+ cslot_name = rb_id2name(SYM2ID(slot_name));
2121
+ break;
2122
+ case T_STRING:
2123
+ cslot_name = StringValueCStr(slot_name);
2124
+ break;
2125
+ default:
2126
+ rb_raise(rb_eTypeError, "Slot name must be a String or a Symbol");
2127
+ return ST_CONTINUE;
2128
+ }
2129
+
2130
+ TypedData_Get_Struct(self, Deftemplate, &Deftemplate_type, deftemplate);
2131
+
2132
+ if (DeftemplateSlotExistP(deftemplate, cslot_name)) {
2133
+ return Qtrue;
2134
+ } else {
2135
+ return Qfalse;
2136
+ }
2137
+ }
2138
+
2139
+ static VALUE clips_environment_deftemplate_static_slot_existp(VALUE self, VALUE rbDeftemplate, VALUE slot_name)
2140
+ {
2141
+ return clips_environment_deftemplate_slot_existp(rbDeftemplate, slot_name);
2142
+ }
2143
+
2144
+ static VALUE clips_environment_deftemplate_slot_singlep(VALUE self, VALUE slot_name)
2145
+ {
2146
+ Deftemplate *deftemplate;
2147
+ const char *cslot_name;
2148
+ switch(TYPE(slot_name))
2149
+ {
2150
+ case T_SYMBOL:
2151
+ cslot_name = rb_id2name(SYM2ID(slot_name));
2152
+ break;
2153
+ case T_STRING:
2154
+ cslot_name = StringValueCStr(slot_name);
2155
+ break;
2156
+ default:
2157
+ rb_raise(rb_eTypeError, "Slot name must be a String or a Symbol");
2158
+ return ST_CONTINUE;
2159
+ }
2160
+
2161
+ TypedData_Get_Struct(self, Deftemplate, &Deftemplate_type, deftemplate);
2162
+
2163
+ if (DeftemplateSlotSingleP(deftemplate, cslot_name)) {
2164
+ return Qtrue;
2165
+ } else {
2166
+ return Qfalse;
2167
+ }
2168
+ }
2169
+
2170
+ static VALUE clips_environment_deftemplate_static_slot_singlep(VALUE self, VALUE rbDeftemplate, VALUE slot_name)
2171
+ {
2172
+ return clips_environment_deftemplate_slot_singlep(rbDeftemplate, slot_name);
2173
+ }
2174
+
2175
+ static VALUE clips_environment_deftemplate_slot_multip(VALUE self, VALUE slot_name)
2176
+ {
2177
+ Deftemplate *deftemplate;
2178
+ const char *cslot_name;
2179
+ switch(TYPE(slot_name))
2180
+ {
2181
+ case T_SYMBOL:
2182
+ cslot_name = rb_id2name(SYM2ID(slot_name));
2183
+ break;
2184
+ case T_STRING:
2185
+ cslot_name = StringValueCStr(slot_name);
2186
+ break;
2187
+ default:
2188
+ rb_raise(rb_eTypeError, "Slot name must be a String or a Symbol");
2189
+ return ST_CONTINUE;
2190
+ }
2191
+
2192
+ TypedData_Get_Struct(self, Deftemplate, &Deftemplate_type, deftemplate);
2193
+
2194
+ if (DeftemplateSlotMultiP(deftemplate, cslot_name)) {
2195
+ return Qtrue;
2196
+ } else {
2197
+ return Qfalse;
2198
+ }
2199
+ }
2200
+
2201
+ static VALUE clips_environment_deftemplate_static_slot_multip(VALUE self, VALUE rbDeftemplate, VALUE slot_name)
2202
+ {
2203
+ return clips_environment_deftemplate_slot_multip(rbDeftemplate, slot_name);
2204
+ }
2205
+
2206
+ static VALUE clips_environment_deftemplate_slot_defaultp(VALUE self, VALUE slot_name)
2207
+ {
2208
+ Deftemplate *deftemplate;
2209
+ const char *cslot_name;
2210
+ switch(TYPE(slot_name))
2211
+ {
2212
+ case T_SYMBOL:
2213
+ cslot_name = rb_id2name(SYM2ID(slot_name));
2214
+ break;
2215
+ case T_STRING:
2216
+ cslot_name = StringValueCStr(slot_name);
2217
+ break;
2218
+ default:
2219
+ rb_warn("Slot name must be a String or a Symbol");
2220
+ return Qnil;
2221
+ }
2222
+
2223
+ TypedData_Get_Struct(self, Deftemplate, &Deftemplate_type, deftemplate);
2224
+
2225
+ switch (DeftemplateSlotDefaultP(deftemplate, cslot_name)) {
2226
+ case NO_DEFAULT:
2227
+ return ID2SYM(rb_intern("NO_DEFAULT"));
2228
+ case STATIC_DEFAULT:
2229
+ return ID2SYM(rb_intern("STATIC_DEFAULT"));
2230
+ case DYNAMIC_DEFAULT:
2231
+ return ID2SYM(rb_intern("DYNAMIC_DEFAULT"));
2232
+ default:
2233
+ rb_warn("CLIPS returned something we didn't expect for slot_defaultp...");
2234
+ return Qnil;
2235
+ }
2236
+ }
2237
+
2238
+ static VALUE clips_environment_deftemplate_static_slot_defaultp(VALUE self, VALUE rbDeftemplate, VALUE slot_name)
2239
+ {
2240
+ return clips_environment_deftemplate_slot_defaultp(rbDeftemplate, slot_name);
2241
+ }
2242
+
2095
2243
  static VALUE clips_environment_defrule_has_breakpoint(VALUE self)
2096
2244
  {
2097
2245
  Defrule *defrule;
@@ -2943,6 +3091,14 @@ void Init_clipsruby(void)
2943
3091
  rb_define_method(rbDeftemplate, "slot_range", clips_environment_deftemplate_slot_range, 1);
2944
3092
  rb_define_singleton_method(rbDeftemplate, "slot_cardinality", clips_environment_deftemplate_static_slot_cardinality, 2);
2945
3093
  rb_define_method(rbDeftemplate, "slot_cardinality", clips_environment_deftemplate_slot_cardinality, 1);
3094
+ rb_define_singleton_method(rbDeftemplate, "slot_existp", clips_environment_deftemplate_static_slot_existp, 2);
3095
+ rb_define_method(rbDeftemplate, "slot_existp", clips_environment_deftemplate_slot_existp, 1);
3096
+ rb_define_singleton_method(rbDeftemplate, "slot_singlep", clips_environment_deftemplate_static_slot_singlep, 2);
3097
+ rb_define_method(rbDeftemplate, "slot_singlep", clips_environment_deftemplate_slot_singlep, 1);
3098
+ rb_define_singleton_method(rbDeftemplate, "slot_multip", clips_environment_deftemplate_static_slot_multip, 2);
3099
+ rb_define_method(rbDeftemplate, "slot_multip", clips_environment_deftemplate_slot_multip, 1);
3100
+ rb_define_singleton_method(rbDeftemplate, "slot_defaultp", clips_environment_deftemplate_static_slot_defaultp, 2);
3101
+ rb_define_method(rbDeftemplate, "slot_defaultp", clips_environment_deftemplate_slot_defaultp, 1);
2946
3102
 
2947
3103
  VALUE rbDefmodule = rb_define_class_under(rbEnvironment, "Defmodule", rb_cObject);
2948
3104
  rb_define_alloc_func(rbDefmodule, defmodule_alloc);
@@ -2977,6 +3133,8 @@ void Init_clipsruby(void)
2977
3133
  rb_define_method(rbFact, "index", clips_environment_fact_index, 0);
2978
3134
  rb_define_singleton_method(rbFact, "pp_form", clips_environment_fact_static_pp_form, -1);
2979
3135
  rb_define_method(rbFact, "pp_form", clips_environment_fact_pp_form, -1);
3136
+ rb_define_singleton_method(rbFact, "existp", clips_environment_fact_static_existp, 1);
3137
+ rb_define_method(rbFact, "existp", clips_environment_fact_existp, 0);
2980
3138
 
2981
3139
  VALUE rbDefrule = rb_define_class_under(rbEnvironment, "Defrule", rb_cObject);
2982
3140
  rb_define_alloc_func(rbDefrule, defrule_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.26
4
+ version: 0.0.28
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-17 00:00:00.000000000 Z
11
+ date: 2024-09-19 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