clipsruby 0.0.17 → 0.0.18
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 +40 -0
- data/ext/clipsruby/clipsruby.c +71 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33891d80ffdc546c56d9cfa73c522f9b53ebbe666f21da00239aebb184d1f424
|
4
|
+
data.tar.gz: 10fae8b4acc60835743bbb301e936c21ed96a989fdc90d8119313494d406d3f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b212ee718009840bd627f666ec1cb16ea1732386dc3a3dc8bd12f39aac2ae24c9ccf207a0247e37298ba1411518c44bfb450cec70568c4db141bc0da6ddb8e28
|
7
|
+
data.tar.gz: ebc27064ab0edd3113683de4d6b75889b12ed4b2522b3d1e2de7598223526caf67dba7199c3520d22c712bb5e821981d99904b0ba228e9ded9b5cdfd5417d678
|
data/README.md
CHANGED
@@ -266,6 +266,26 @@ CLIPS::Environment.facts(env)
|
|
266
266
|
env.facts
|
267
267
|
```
|
268
268
|
|
269
|
+
### `CLIPS::Environment.get_current_module`
|
270
|
+
### `CLIPS::Environment#get_current_module`
|
271
|
+
|
272
|
+
Get the current module in the CLIPS environment
|
273
|
+
|
274
|
+
```ruby
|
275
|
+
CLIPS::Environment.get_current_module(env)
|
276
|
+
env.get_current_module
|
277
|
+
```
|
278
|
+
|
279
|
+
### `CLIPS::Environment.set_current_module`
|
280
|
+
### `CLIPS::Environment#set_current_module`
|
281
|
+
|
282
|
+
Set the current module in the CLIPS environment
|
283
|
+
|
284
|
+
```ruby
|
285
|
+
CLIPS::Environment.set_current_module(env, defmodule)
|
286
|
+
env.set_current_module(defmodule)
|
287
|
+
```
|
288
|
+
|
269
289
|
### `CLIPS::Environment::Fact.to_h`
|
270
290
|
### `CLIPS::Environment::Fact#to_h`
|
271
291
|
|
@@ -408,6 +428,16 @@ CLIPS::Environment::Defrule.remove_break(defrule)
|
|
408
428
|
defrule.remove_break
|
409
429
|
```
|
410
430
|
|
431
|
+
### `CLIPS::Environment.find_defmodule`
|
432
|
+
### `CLIPS::Environment#find_defmodule`
|
433
|
+
|
434
|
+
Finds a defmodule by name and returns a CLIPS::Environment::Defmodule object
|
435
|
+
|
436
|
+
```ruby
|
437
|
+
CLIPS::Environment.find_defmodule(:a)
|
438
|
+
env.find_defmodule("foo")
|
439
|
+
```
|
440
|
+
|
411
441
|
### `CLIPS::Environment::Defmodule.name`
|
412
442
|
### `CLIPS::Environment::Defmodule#name`
|
413
443
|
|
@@ -428,6 +458,16 @@ CLIPS::Environment::Defmodule.pp_form(defmodule)
|
|
428
458
|
defmodule.pp_form
|
429
459
|
```
|
430
460
|
|
461
|
+
### `CLIPS::Environment::Defmodule.set_current`
|
462
|
+
### `CLIPS::Environment::Defmodule#set_current`
|
463
|
+
|
464
|
+
Sets the Defmodule as the current module of the environment
|
465
|
+
|
466
|
+
```ruby
|
467
|
+
CLIPS::Environment::Defmodule.set_current(defmodule)
|
468
|
+
defmodule.set_current
|
469
|
+
```
|
470
|
+
|
431
471
|
## Running the tests
|
432
472
|
|
433
473
|
Simply do `rake compile` and then `rake test` in order to run the tests.
|
data/ext/clipsruby/clipsruby.c
CHANGED
@@ -1238,6 +1238,47 @@ static VALUE clips_environment_static_find_defrule(VALUE self, VALUE rbEnvironme
|
|
1238
1238
|
return clips_environment_find_defrule(rbEnvironment, defrule_name);
|
1239
1239
|
}
|
1240
1240
|
|
1241
|
+
static VALUE clips_environment_get_current_module(VALUE self)
|
1242
|
+
{
|
1243
|
+
Environment *env;
|
1244
|
+
Defmodule *module;
|
1245
|
+
|
1246
|
+
TypedData_Get_Struct(self, Environment, &Environment_type, env);
|
1247
|
+
module = GetCurrentModule(env);
|
1248
|
+
|
1249
|
+
if (module == NULL) {
|
1250
|
+
return Qnil;
|
1251
|
+
} else {
|
1252
|
+
VALUE rbDefmodule;
|
1253
|
+
rbDefmodule = TypedData_Wrap_Struct(rb_const_get(CLASS_OF(self), rb_intern("Defmodule")), &Defmodule_type, module);
|
1254
|
+
rb_iv_set(rbDefmodule, "@environment", self);
|
1255
|
+
return rbDefmodule;
|
1256
|
+
}
|
1257
|
+
}
|
1258
|
+
|
1259
|
+
static VALUE clips_environment_static_get_current_module(VALUE self, VALUE rbEnvironment)
|
1260
|
+
{
|
1261
|
+
return clips_environment_get_current_module(rbEnvironment);
|
1262
|
+
}
|
1263
|
+
|
1264
|
+
static VALUE clips_environment_set_current_module(VALUE self, VALUE rbDefmodule)
|
1265
|
+
{
|
1266
|
+
Environment *env;
|
1267
|
+
Defmodule *module;
|
1268
|
+
|
1269
|
+
TypedData_Get_Struct(self, Environment, &Environment_type, env);
|
1270
|
+
TypedData_Get_Struct(rbDefmodule, Defmodule, &Defmodule_type, module);
|
1271
|
+
|
1272
|
+
SetCurrentModule(env, module);
|
1273
|
+
|
1274
|
+
return rbDefmodule;
|
1275
|
+
}
|
1276
|
+
|
1277
|
+
static VALUE clips_environment_static_set_current_module(VALUE self, VALUE rbEnvironment, VALUE defmodule_name)
|
1278
|
+
{
|
1279
|
+
return clips_environment_set_current_module(rbEnvironment, defmodule_name);
|
1280
|
+
}
|
1281
|
+
|
1241
1282
|
static VALUE clips_environment_find_defmodule(VALUE self, VALUE defmodule_name)
|
1242
1283
|
{
|
1243
1284
|
Environment *env;
|
@@ -1260,7 +1301,10 @@ static VALUE clips_environment_find_defmodule(VALUE self, VALUE defmodule_name)
|
|
1260
1301
|
if (module == NULL) {
|
1261
1302
|
return Qnil;
|
1262
1303
|
} else {
|
1263
|
-
|
1304
|
+
VALUE rbDefmodule;
|
1305
|
+
rbDefmodule = TypedData_Wrap_Struct(rb_const_get(CLASS_OF(self), rb_intern("Defmodule")), &Defmodule_type, module);
|
1306
|
+
rb_iv_set(rbDefmodule, "@environment", self);
|
1307
|
+
return rbDefmodule;
|
1264
1308
|
}
|
1265
1309
|
}
|
1266
1310
|
|
@@ -1297,6 +1341,26 @@ static VALUE clips_environment_defmodule_static_pp_form(VALUE self, VALUE rbDefm
|
|
1297
1341
|
return clips_environment_defmodule_pp_form(rbDefmodule);
|
1298
1342
|
}
|
1299
1343
|
|
1344
|
+
static VALUE clips_environment_defmodule_set_current(VALUE self)
|
1345
|
+
{
|
1346
|
+
Defmodule *module;
|
1347
|
+
Environment *env;
|
1348
|
+
|
1349
|
+
VALUE rbEnvironment = rb_iv_get(self, "@environment");
|
1350
|
+
|
1351
|
+
TypedData_Get_Struct(self, Defmodule, &Defmodule_type, module);
|
1352
|
+
TypedData_Get_Struct(rbEnvironment, Environment, &Environment_type, env);
|
1353
|
+
|
1354
|
+
SetCurrentModule(env, module);
|
1355
|
+
|
1356
|
+
return self;
|
1357
|
+
}
|
1358
|
+
|
1359
|
+
static VALUE clips_environment_defmodule_static_set_current(VALUE self, VALUE rbDefmodule)
|
1360
|
+
{
|
1361
|
+
return clips_environment_defmodule_set_current(rbDefmodule);
|
1362
|
+
}
|
1363
|
+
|
1300
1364
|
static VALUE clips_environment_defrule_name(VALUE self)
|
1301
1365
|
{
|
1302
1366
|
Defrule *defrule;
|
@@ -1446,6 +1510,10 @@ void Init_clipsruby(void)
|
|
1446
1510
|
rb_define_method(rbEnvironment, "find_defrule", clips_environment_find_defrule, 1);
|
1447
1511
|
rb_define_singleton_method(rbEnvironment, "find_defmodule", clips_environment_static_find_defmodule, 2);
|
1448
1512
|
rb_define_method(rbEnvironment, "find_defmodule", clips_environment_find_defmodule, 1);
|
1513
|
+
rb_define_singleton_method(rbEnvironment, "get_current_module", clips_environment_static_get_current_module, 1);
|
1514
|
+
rb_define_method(rbEnvironment, "get_current_module", clips_environment_get_current_module, 0);
|
1515
|
+
rb_define_singleton_method(rbEnvironment, "set_current_module", clips_environment_static_set_current_module, 2);
|
1516
|
+
rb_define_method(rbEnvironment, "set_current_module", clips_environment_set_current_module, 1);
|
1449
1517
|
|
1450
1518
|
VALUE rbDefmodule = rb_define_class_under(rbEnvironment, "Defmodule", rb_cObject);
|
1451
1519
|
rb_define_alloc_func(rbDefmodule, defmodule_alloc);
|
@@ -1453,6 +1521,8 @@ void Init_clipsruby(void)
|
|
1453
1521
|
rb_define_method(rbDefmodule, "name", clips_environment_defmodule_name, 0);
|
1454
1522
|
rb_define_singleton_method(rbDefmodule, "pp_form", clips_environment_defmodule_static_pp_form, 1);
|
1455
1523
|
rb_define_method(rbDefmodule, "pp_form", clips_environment_defmodule_pp_form, 0);
|
1524
|
+
rb_define_singleton_method(rbDefmodule, "set_current", clips_environment_defmodule_static_set_current, 1);
|
1525
|
+
rb_define_method(rbDefmodule, "set_current", clips_environment_defmodule_set_current, 0);
|
1456
1526
|
|
1457
1527
|
VALUE rbFact = rb_define_class_under(rbEnvironment, "Fact", rb_cObject);
|
1458
1528
|
rb_define_alloc_func(rbFact, fact_alloc);
|