clipsruby 0.0.36 → 0.0.38
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 +30 -0
- data/ext/clipsruby/clipsruby.c +119 -14
- 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: 2d5b2eff6dfde994a41ed4226415ed61cc22f4a60164ca7f0adb14f2913ed831
|
4
|
+
data.tar.gz: 18f6b5748632239dac343f0b91b41620a2973699e27a9d52a2aef28bde921a0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 634dd08bc164e971d4484e18a2fadc51a56e7b7976994b3cfb3bad903445157da9b6bc1ef4dc424faacef0a68217f774c6c3ec9f9fd717c3d579df04d0e6525e
|
7
|
+
data.tar.gz: b31052a98c2238d3d97bf6938193202ca6b05333286e61500000da33dd4baaeddc915b5bd53c53cf989c366bcc51d5469428632766ad625e616249f9eb996655
|
data/README.md
CHANGED
@@ -494,6 +494,16 @@ CLIPS::Environment::Defclass.defmodule_name(defclass)
|
|
494
494
|
defclass.defmodule_name
|
495
495
|
```
|
496
496
|
|
497
|
+
### `CLIPS::Environment::Defclass.defmodule`
|
498
|
+
### `CLIPS::Environment::Defclass#defmodule`
|
499
|
+
|
500
|
+
Returns the defmodule in which the defclass is defined
|
501
|
+
|
502
|
+
```ruby
|
503
|
+
CLIPS::Environment::Defclass.defmodule(defclass)
|
504
|
+
defclass.defmodule
|
505
|
+
```
|
506
|
+
|
497
507
|
### `CLIPS::Environment::Defclass.get_instance_list`
|
498
508
|
### `CLIPS::Environment::Defclass#get_instance_list`
|
499
509
|
|
@@ -582,6 +592,16 @@ CLIPS::Environment::Defrule.defmodule_name(defrule)
|
|
582
592
|
defrule.defmodule_name
|
583
593
|
```
|
584
594
|
|
595
|
+
### `CLIPS::Environment::Defrule.defmodule`
|
596
|
+
### `CLIPS::Environment::Defrule#defmodule`
|
597
|
+
|
598
|
+
Returns the defmodule in which the defrule is defined
|
599
|
+
|
600
|
+
```ruby
|
601
|
+
CLIPS::Environment::Defrule.defmodule(defrule)
|
602
|
+
defrule.defmodule
|
603
|
+
```
|
604
|
+
|
585
605
|
### `CLIPS::Environment::Defrule.is_deletable`
|
586
606
|
### `CLIPS::Environment::Defrule#is_deletable`
|
587
607
|
|
@@ -846,6 +866,16 @@ CLIPS::Environment::Deftemplate.defmodule_name(deftemplate)
|
|
846
866
|
deftemplate.defmodule_name
|
847
867
|
```
|
848
868
|
|
869
|
+
### `CLIPS::Environment::Deftemplate.defmodule`
|
870
|
+
### `CLIPS::Environment::Deftemplate#defmodule`
|
871
|
+
|
872
|
+
Returns the defmodule in which the deftemplate is defined
|
873
|
+
|
874
|
+
```ruby
|
875
|
+
CLIPS::Environment::Deftemplate.defmodule(deftemplate)
|
876
|
+
deftemplate.defmodule
|
877
|
+
```
|
878
|
+
|
849
879
|
### `CLIPS::Environment::Deftemplate.slot_names`
|
850
880
|
### `CLIPS::Environment::Deftemplate#slot_names`
|
851
881
|
|
data/ext/clipsruby/clipsruby.c
CHANGED
@@ -1,6 +1,24 @@
|
|
1
1
|
#include "clips.h"
|
2
2
|
#include "ruby.h"
|
3
3
|
|
4
|
+
void environment_free(void *data)
|
5
|
+
{
|
6
|
+
DestroyEnvironment((Environment*) data);
|
7
|
+
}
|
8
|
+
|
9
|
+
size_t environment_size(const void *data)
|
10
|
+
{
|
11
|
+
return MemUsed((Environment*) data);
|
12
|
+
}
|
13
|
+
|
14
|
+
static const rb_data_type_t Environment_type = {
|
15
|
+
.function = {
|
16
|
+
.dfree = environment_free,
|
17
|
+
.dsize = environment_size
|
18
|
+
},
|
19
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY
|
20
|
+
};
|
21
|
+
|
4
22
|
size_t deffacts_size(const void *data)
|
5
23
|
{
|
6
24
|
return sizeof(Deffacts);
|
@@ -133,6 +151,36 @@ static VALUE clips_environment_deftemplate_static_defmodule_name(VALUE self, VAL
|
|
133
151
|
return clips_environment_deftemplate_defmodule_name(rbDeftemplate);
|
134
152
|
}
|
135
153
|
|
154
|
+
static VALUE clips_environment_deftemplate_defmodule(VALUE self)
|
155
|
+
{
|
156
|
+
Deftemplate *template;
|
157
|
+
const char *defmoduleName;
|
158
|
+
Defmodule *defmodule = NULL;
|
159
|
+
Environment *env;
|
160
|
+
|
161
|
+
VALUE rbEnvironment = rb_iv_get(self, "@environment");
|
162
|
+
TypedData_Get_Struct(rbEnvironment, Environment, &Environment_type, env);
|
163
|
+
|
164
|
+
TypedData_Get_Struct(self, Deftemplate, &Deftemplate_type, template);
|
165
|
+
|
166
|
+
defmoduleName = DeftemplateModule(template);
|
167
|
+
|
168
|
+
if (defmoduleName != NULL) {
|
169
|
+
defmodule = FindDefmodule(env, defmoduleName);
|
170
|
+
}
|
171
|
+
|
172
|
+
if (defmodule != NULL) {
|
173
|
+
return TypedData_Wrap_Struct(rb_const_get(CLASS_OF(rbEnvironment), rb_intern("Defmodule")), &Defmodule_type, defmodule);
|
174
|
+
} else {
|
175
|
+
return Qnil;
|
176
|
+
}
|
177
|
+
}
|
178
|
+
|
179
|
+
static VALUE clips_environment_deftemplate_static_defmodule(VALUE self, VALUE rbDeftemplate)
|
180
|
+
{
|
181
|
+
return clips_environment_deftemplate_defmodule(rbDeftemplate);
|
182
|
+
}
|
183
|
+
|
136
184
|
static VALUE clips_environment_defrule_defmodule_name(VALUE self)
|
137
185
|
{
|
138
186
|
Defrule *rule;
|
@@ -147,24 +195,36 @@ static VALUE clips_environment_defrule_static_defmodule_name(VALUE self, VALUE r
|
|
147
195
|
return clips_environment_defrule_defmodule_name(rbDefrule);
|
148
196
|
}
|
149
197
|
|
150
|
-
|
198
|
+
static VALUE clips_environment_defrule_defmodule(VALUE self)
|
151
199
|
{
|
152
|
-
|
200
|
+
Defrule *rule;
|
201
|
+
const char *defmoduleName;
|
202
|
+
Defmodule *defmodule = NULL;
|
203
|
+
Environment *env;
|
204
|
+
|
205
|
+
VALUE rbEnvironment = rb_iv_get(self, "@environment");
|
206
|
+
TypedData_Get_Struct(rbEnvironment, Environment, &Environment_type, env);
|
207
|
+
|
208
|
+
TypedData_Get_Struct(self, Defrule, &Defrule_type, rule);
|
209
|
+
|
210
|
+
defmoduleName = DefruleModule(rule);
|
211
|
+
|
212
|
+
if (defmoduleName != NULL) {
|
213
|
+
defmodule = FindDefmodule(env, defmoduleName);
|
214
|
+
}
|
215
|
+
|
216
|
+
if (defmodule != NULL) {
|
217
|
+
return TypedData_Wrap_Struct(rb_const_get(CLASS_OF(rbEnvironment), rb_intern("Defmodule")), &Defmodule_type, defmodule);
|
218
|
+
} else {
|
219
|
+
return Qnil;
|
220
|
+
}
|
153
221
|
}
|
154
222
|
|
155
|
-
|
223
|
+
static VALUE clips_environment_defrule_static_defmodule(VALUE self, VALUE rbDefrule)
|
156
224
|
{
|
157
|
-
return
|
225
|
+
return clips_environment_defrule_defmodule(rbDefrule);
|
158
226
|
}
|
159
227
|
|
160
|
-
static const rb_data_type_t Environment_type = {
|
161
|
-
.function = {
|
162
|
-
.dfree = environment_free,
|
163
|
-
.dsize = environment_size
|
164
|
-
},
|
165
|
-
.flags = RUBY_TYPED_FREE_IMMEDIATELY
|
166
|
-
};
|
167
|
-
|
168
228
|
static VALUE clips_environment_facts(VALUE self)
|
169
229
|
{
|
170
230
|
Environment *env;
|
@@ -279,13 +339,49 @@ static VALUE clips_environment_defclass_static_defmodule_name(VALUE self, VALUE
|
|
279
339
|
return clips_environment_defclass_defmodule_name(rbDefclass);
|
280
340
|
}
|
281
341
|
|
342
|
+
static VALUE clips_environment_defclass_defmodule(VALUE self)
|
343
|
+
{
|
344
|
+
Defclass *class;
|
345
|
+
const char *defmoduleName;
|
346
|
+
Defmodule *defmodule = NULL;
|
347
|
+
Environment *env;
|
348
|
+
|
349
|
+
VALUE rbEnvironment = rb_iv_get(self, "@environment");
|
350
|
+
TypedData_Get_Struct(rbEnvironment, Environment, &Environment_type, env);
|
351
|
+
|
352
|
+
TypedData_Get_Struct(self, Defclass, &Defclass_type, class);
|
353
|
+
|
354
|
+
defmoduleName = DefclassModule(class);
|
355
|
+
|
356
|
+
if (defmoduleName != NULL) {
|
357
|
+
defmodule = FindDefmodule(env, defmoduleName);
|
358
|
+
}
|
359
|
+
|
360
|
+
if (defmodule != NULL) {
|
361
|
+
return TypedData_Wrap_Struct(rb_const_get(CLASS_OF(rbEnvironment), rb_intern("Defmodule")), &Defmodule_type, defmodule);
|
362
|
+
} else {
|
363
|
+
return Qnil;
|
364
|
+
}
|
365
|
+
}
|
366
|
+
|
367
|
+
static VALUE clips_environment_defclass_static_defmodule(VALUE self, VALUE rbDefclass)
|
368
|
+
{
|
369
|
+
return clips_environment_defclass_defmodule(rbDefclass);
|
370
|
+
}
|
371
|
+
|
282
372
|
static VALUE clips_environment_defclass_pp_form(VALUE self)
|
283
373
|
{
|
284
374
|
Defclass *defclass;
|
375
|
+
const char *pp_form;
|
285
376
|
|
286
377
|
TypedData_Get_Struct(self, Defclass, &Defclass_type, defclass);
|
287
378
|
|
288
|
-
|
379
|
+
pp_form = DefclassPPForm(defclass);
|
380
|
+
if (pp_form == NULL) {
|
381
|
+
return Qnil;
|
382
|
+
} else {
|
383
|
+
return rb_str_new2(pp_form);
|
384
|
+
}
|
289
385
|
}
|
290
386
|
|
291
387
|
static VALUE clips_environment_defclass_static_pp_form(VALUE self, VALUE rbDefclass)
|
@@ -1946,6 +2042,7 @@ static VALUE clips_environment_fact_static_index(VALUE self, VALUE rbFact)
|
|
1946
2042
|
|
1947
2043
|
static VALUE clips_environment_find_defrule(VALUE self, VALUE defrule_name)
|
1948
2044
|
{
|
2045
|
+
VALUE rbDefrule;
|
1949
2046
|
Environment *env;
|
1950
2047
|
Defrule *rule;
|
1951
2048
|
|
@@ -1966,7 +2063,9 @@ static VALUE clips_environment_find_defrule(VALUE self, VALUE defrule_name)
|
|
1966
2063
|
if (rule == NULL) {
|
1967
2064
|
return Qnil;
|
1968
2065
|
} else {
|
1969
|
-
|
2066
|
+
rbDefrule = TypedData_Wrap_Struct(rb_const_get(CLASS_OF(self), rb_intern("Defrule")), &Defrule_type, rule);
|
2067
|
+
rb_iv_set(rbDefrule, "@environment", self);
|
2068
|
+
return rbDefrule;
|
1970
2069
|
}
|
1971
2070
|
}
|
1972
2071
|
|
@@ -4191,6 +4290,8 @@ void Init_clipsruby(void)
|
|
4191
4290
|
rb_define_method(rbDeftemplate, "pp_form", clips_environment_deftemplate_pp_form, 0);
|
4192
4291
|
rb_define_singleton_method(rbDeftemplate, "assert_hash", clips_environment_deftemplate_static_assert_hash, 2);
|
4193
4292
|
rb_define_method(rbDeftemplate, "assert_hash", clips_environment_deftemplate_assert_hash, 1);
|
4293
|
+
rb_define_singleton_method(rbDeftemplate, "defmodule", clips_environment_deftemplate_static_defmodule, 1);
|
4294
|
+
rb_define_method(rbDeftemplate, "defmodule", clips_environment_deftemplate_defmodule, 0);
|
4194
4295
|
rb_define_singleton_method(rbDeftemplate, "defmodule_name", clips_environment_deftemplate_static_defmodule_name, 1);
|
4195
4296
|
rb_define_method(rbDeftemplate, "defmodule_name", clips_environment_deftemplate_defmodule_name, 0);
|
4196
4297
|
rb_define_singleton_method(rbDeftemplate, "slot_names", clips_environment_deftemplate_static_slot_names, 1);
|
@@ -4278,6 +4379,8 @@ void Init_clipsruby(void)
|
|
4278
4379
|
rb_define_method(rbDefrule, "salience", clips_environment_defrule_salience, 0);
|
4279
4380
|
rb_define_singleton_method(rbDefrule, "defmodule_name", clips_environment_defrule_static_defmodule_name, 1);
|
4280
4381
|
rb_define_method(rbDefrule, "defmodule_name", clips_environment_defrule_defmodule_name, 0);
|
4382
|
+
rb_define_singleton_method(rbDefrule, "defmodule", clips_environment_defrule_static_defmodule, 1);
|
4383
|
+
rb_define_method(rbDefrule, "defmodule", clips_environment_defrule_defmodule, 0);
|
4281
4384
|
|
4282
4385
|
VALUE rbDefclass = rb_define_class_under(rbEnvironment, "Defclass", rb_cObject);
|
4283
4386
|
rb_define_alloc_func(rbDefclass, defclass_alloc);
|
@@ -4285,6 +4388,8 @@ void Init_clipsruby(void)
|
|
4285
4388
|
rb_define_method(rbDefclass, "name", clips_environment_defclass_name, 0);
|
4286
4389
|
rb_define_singleton_method(rbDefclass, "defmodule_name", clips_environment_defclass_static_defmodule_name, 1);
|
4287
4390
|
rb_define_method(rbDefclass, "defmodule_name", clips_environment_defclass_defmodule_name, 0);
|
4391
|
+
rb_define_singleton_method(rbDefclass, "defmodule", clips_environment_defclass_static_defmodule, 1);
|
4392
|
+
rb_define_method(rbDefclass, "defmodule", clips_environment_defclass_defmodule, 0);
|
4288
4393
|
rb_define_singleton_method(rbDefclass, "pp_form", clips_environment_defclass_static_pp_form, 1);
|
4289
4394
|
rb_define_method(rbDefclass, "pp_form", clips_environment_defclass_pp_form, 0);
|
4290
4395
|
rb_define_singleton_method(rbDefclass, "get_instance_list", clips_environment_defclass_static_get_instance_list, -1);
|
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.38
|
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-29 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
|