clipsruby 0.0.15 → 0.0.17
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 +50 -0
- data/ext/clipsruby/clipsruby.c +156 -0
- 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: de97045f9a1a8a525b3749c820e21addf2bdbf4edbfefc3fd6d02e4d611560bc
|
4
|
+
data.tar.gz: d364bf452cf66ca60d9acc12d794fdc25ed613ef2db5c5af194a982b9beff1e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ed356daccf5a65e12ee6ac3c516efcf6035852eb70a4aab2a2b619ffc7a78c7dfba99c7c5d49bc7127b76ff5c6432e2709bbcc7b196160d55329411abbd892e
|
7
|
+
data.tar.gz: 99712624df319cf372755ada70bf503d5bd99a8a4bb336d3da8968fae9669b4482065259ebf337dc43b8820b9207e3afb08e80c88f43cb62b6bc90077b64113c
|
data/README.md
CHANGED
@@ -378,6 +378,56 @@ CLIPS::Environment::Defrule.pp_form(defrule)
|
|
378
378
|
defrule.pp_form
|
379
379
|
```
|
380
380
|
|
381
|
+
### `CLIPS::Environment::Defrule.has_breakpoint`
|
382
|
+
### `CLIPS::Environment::Defrule#has_breakpoint`
|
383
|
+
|
384
|
+
Returns whether or not the rule has a breakpoint set
|
385
|
+
|
386
|
+
```ruby
|
387
|
+
CLIPS::Environment::Defrule.has_breakpoint(defrule)
|
388
|
+
defrule.has_breakpoint
|
389
|
+
```
|
390
|
+
|
391
|
+
### `CLIPS::Environment::Defrule.set_break`
|
392
|
+
### `CLIPS::Environment::Defrule#set_break`
|
393
|
+
|
394
|
+
Sets a breakpoint on a rule
|
395
|
+
|
396
|
+
```ruby
|
397
|
+
CLIPS::Environment::Defrule.set_break(defrule)
|
398
|
+
defrule.set_break
|
399
|
+
```
|
400
|
+
|
401
|
+
### `CLIPS::Environment::Defrule.remove_break`
|
402
|
+
### `CLIPS::Environment::Defrule#remove_break`
|
403
|
+
|
404
|
+
Returns whether or not it was able to remove a breakpoint from a rule
|
405
|
+
|
406
|
+
```ruby
|
407
|
+
CLIPS::Environment::Defrule.remove_break(defrule)
|
408
|
+
defrule.remove_break
|
409
|
+
```
|
410
|
+
|
411
|
+
### `CLIPS::Environment::Defmodule.name`
|
412
|
+
### `CLIPS::Environment::Defmodule#name`
|
413
|
+
|
414
|
+
Returns the name of a defmodule as a symbol
|
415
|
+
|
416
|
+
```ruby
|
417
|
+
CLIPS::Environment::Defmodule.name(defmodule)
|
418
|
+
defmodule.name
|
419
|
+
```
|
420
|
+
|
421
|
+
### `CLIPS::Environment::Defmodule.pp_form`
|
422
|
+
### `CLIPS::Environment::Defmodule#pp_form`
|
423
|
+
|
424
|
+
Returns a pretty printed string representation of the Defmodule
|
425
|
+
|
426
|
+
```ruby
|
427
|
+
CLIPS::Environment::Defmodule.pp_form(defmodule)
|
428
|
+
defmodule.pp_form
|
429
|
+
```
|
430
|
+
|
381
431
|
## Running the tests
|
382
432
|
|
383
433
|
Simply do `rake compile` and then `rake test` in order to run the tests.
|
data/ext/clipsruby/clipsruby.c
CHANGED
@@ -1,6 +1,19 @@
|
|
1
1
|
#include "clips.h"
|
2
2
|
#include "ruby.h"
|
3
3
|
|
4
|
+
size_t defmodule_size(const void *data)
|
5
|
+
{
|
6
|
+
return sizeof(Defmodule);
|
7
|
+
}
|
8
|
+
|
9
|
+
static const rb_data_type_t Defmodule_type = {
|
10
|
+
.function = {
|
11
|
+
.dsize = defmodule_size
|
12
|
+
},
|
13
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY
|
14
|
+
};
|
15
|
+
|
16
|
+
|
4
17
|
size_t defrule_size(const void *data)
|
5
18
|
{
|
6
19
|
return sizeof(Defrule);
|
@@ -73,6 +86,21 @@ static VALUE clips_environment_static_facts(VALUE self, VALUE rbEnvironment)
|
|
73
86
|
return clips_environment_facts(rbEnvironment);
|
74
87
|
}
|
75
88
|
|
89
|
+
VALUE defmodule_alloc(VALUE self)
|
90
|
+
{
|
91
|
+
return TypedData_Wrap_Struct(self, &Defmodule_type, NULL);
|
92
|
+
}
|
93
|
+
|
94
|
+
VALUE defrule_alloc(VALUE self)
|
95
|
+
{
|
96
|
+
return TypedData_Wrap_Struct(self, &Defrule_type, NULL);
|
97
|
+
}
|
98
|
+
|
99
|
+
VALUE fact_alloc(VALUE self)
|
100
|
+
{
|
101
|
+
return TypedData_Wrap_Struct(self, &Fact_type, NULL);
|
102
|
+
}
|
103
|
+
|
76
104
|
VALUE environment_alloc(VALUE self)
|
77
105
|
{
|
78
106
|
return TypedData_Wrap_Struct(self, &Environment_type, CreateEnvironment());
|
@@ -1210,6 +1238,65 @@ static VALUE clips_environment_static_find_defrule(VALUE self, VALUE rbEnvironme
|
|
1210
1238
|
return clips_environment_find_defrule(rbEnvironment, defrule_name);
|
1211
1239
|
}
|
1212
1240
|
|
1241
|
+
static VALUE clips_environment_find_defmodule(VALUE self, VALUE defmodule_name)
|
1242
|
+
{
|
1243
|
+
Environment *env;
|
1244
|
+
Defmodule *module;
|
1245
|
+
|
1246
|
+
TypedData_Get_Struct(self, Environment, &Environment_type, env);
|
1247
|
+
|
1248
|
+
switch (TYPE(defmodule_name)) {
|
1249
|
+
case T_STRING:
|
1250
|
+
module = FindDefmodule(env, StringValueCStr(defmodule_name));
|
1251
|
+
break;
|
1252
|
+
case T_SYMBOL:
|
1253
|
+
module = FindDefmodule(env, rb_id2name(SYM2ID(defmodule_name)));
|
1254
|
+
break;
|
1255
|
+
default:
|
1256
|
+
rb_warn("defmodule name must be a symbol or string");
|
1257
|
+
return Qnil;
|
1258
|
+
}
|
1259
|
+
|
1260
|
+
if (module == NULL) {
|
1261
|
+
return Qnil;
|
1262
|
+
} else {
|
1263
|
+
return TypedData_Wrap_Struct(rb_const_get(CLASS_OF(self), rb_intern("Defmodule")), &Defmodule_type, module);
|
1264
|
+
}
|
1265
|
+
}
|
1266
|
+
|
1267
|
+
static VALUE clips_environment_static_find_defmodule(VALUE self, VALUE rbEnvironment, VALUE defmodule_name)
|
1268
|
+
{
|
1269
|
+
return clips_environment_find_defmodule(rbEnvironment, defmodule_name);
|
1270
|
+
}
|
1271
|
+
|
1272
|
+
static VALUE clips_environment_defmodule_name(VALUE self)
|
1273
|
+
{
|
1274
|
+
Defmodule *defmodule;
|
1275
|
+
|
1276
|
+
TypedData_Get_Struct(self, Defmodule, &Defmodule_type, defmodule);
|
1277
|
+
|
1278
|
+
return ID2SYM(rb_intern(DefmoduleName(defmodule)));
|
1279
|
+
}
|
1280
|
+
|
1281
|
+
static VALUE clips_environment_defmodule_static_name(VALUE self, VALUE rbDefmodule)
|
1282
|
+
{
|
1283
|
+
return clips_environment_defmodule_name(rbDefmodule);
|
1284
|
+
}
|
1285
|
+
|
1286
|
+
static VALUE clips_environment_defmodule_pp_form(VALUE self)
|
1287
|
+
{
|
1288
|
+
Defmodule *defmodule;
|
1289
|
+
|
1290
|
+
TypedData_Get_Struct(self, Defmodule, &Defmodule_type, defmodule);
|
1291
|
+
|
1292
|
+
return rb_str_new2(DefmodulePPForm(defmodule));
|
1293
|
+
}
|
1294
|
+
|
1295
|
+
static VALUE clips_environment_defmodule_static_pp_form(VALUE self, VALUE rbDefmodule)
|
1296
|
+
{
|
1297
|
+
return clips_environment_defmodule_pp_form(rbDefmodule);
|
1298
|
+
}
|
1299
|
+
|
1213
1300
|
static VALUE clips_environment_defrule_name(VALUE self)
|
1214
1301
|
{
|
1215
1302
|
Defrule *defrule;
|
@@ -1256,6 +1343,58 @@ static VALUE clips_environment_defrule_static_is_deletable(VALUE self, VALUE rbD
|
|
1256
1343
|
return clips_environment_defrule_is_deletable(rbDefrule);
|
1257
1344
|
}
|
1258
1345
|
|
1346
|
+
static VALUE clips_environment_defrule_has_breakpoint(VALUE self)
|
1347
|
+
{
|
1348
|
+
Defrule *defrule;
|
1349
|
+
|
1350
|
+
TypedData_Get_Struct(self, Defrule, &Defrule_type, defrule);
|
1351
|
+
|
1352
|
+
if (DefruleHasBreakpoint(defrule)) {
|
1353
|
+
return Qtrue;
|
1354
|
+
} else {
|
1355
|
+
return Qfalse;
|
1356
|
+
}
|
1357
|
+
}
|
1358
|
+
|
1359
|
+
static VALUE clips_environment_defrule_static_has_breakpoint(VALUE self, VALUE rbDefrule)
|
1360
|
+
{
|
1361
|
+
return clips_environment_defrule_has_breakpoint(rbDefrule);
|
1362
|
+
}
|
1363
|
+
|
1364
|
+
static VALUE clips_environment_defrule_set_break(VALUE self)
|
1365
|
+
{
|
1366
|
+
Defrule *defrule;
|
1367
|
+
|
1368
|
+
TypedData_Get_Struct(self, Defrule, &Defrule_type, defrule);
|
1369
|
+
|
1370
|
+
SetBreak(defrule);
|
1371
|
+
|
1372
|
+
return Qnil;
|
1373
|
+
}
|
1374
|
+
|
1375
|
+
static VALUE clips_environment_defrule_static_set_break(VALUE self, VALUE rbDefrule)
|
1376
|
+
{
|
1377
|
+
return clips_environment_defrule_set_break(rbDefrule);
|
1378
|
+
}
|
1379
|
+
|
1380
|
+
static VALUE clips_environment_defrule_remove_break(VALUE self)
|
1381
|
+
{
|
1382
|
+
Defrule *defrule;
|
1383
|
+
|
1384
|
+
TypedData_Get_Struct(self, Defrule, &Defrule_type, defrule);
|
1385
|
+
|
1386
|
+
if (RemoveBreak(defrule)) {
|
1387
|
+
return Qtrue;
|
1388
|
+
} else {
|
1389
|
+
return Qfalse;
|
1390
|
+
}
|
1391
|
+
}
|
1392
|
+
|
1393
|
+
static VALUE clips_environment_defrule_static_remove_break(VALUE self, VALUE rbDefrule)
|
1394
|
+
{
|
1395
|
+
return clips_environment_defrule_remove_break(rbDefrule);
|
1396
|
+
}
|
1397
|
+
|
1259
1398
|
void Init_clipsruby(void)
|
1260
1399
|
{
|
1261
1400
|
VALUE rbCLIPS = rb_define_module("CLIPS");
|
@@ -1305,8 +1444,18 @@ void Init_clipsruby(void)
|
|
1305
1444
|
rb_define_method(rbEnvironment, "bload_facts", clips_environment_bload_facts, 1);
|
1306
1445
|
rb_define_singleton_method(rbEnvironment, "find_defrule", clips_environment_static_find_defrule, 2);
|
1307
1446
|
rb_define_method(rbEnvironment, "find_defrule", clips_environment_find_defrule, 1);
|
1447
|
+
rb_define_singleton_method(rbEnvironment, "find_defmodule", clips_environment_static_find_defmodule, 2);
|
1448
|
+
rb_define_method(rbEnvironment, "find_defmodule", clips_environment_find_defmodule, 1);
|
1449
|
+
|
1450
|
+
VALUE rbDefmodule = rb_define_class_under(rbEnvironment, "Defmodule", rb_cObject);
|
1451
|
+
rb_define_alloc_func(rbDefmodule, defmodule_alloc);
|
1452
|
+
rb_define_singleton_method(rbDefmodule, "name", clips_environment_defmodule_static_name, 1);
|
1453
|
+
rb_define_method(rbDefmodule, "name", clips_environment_defmodule_name, 0);
|
1454
|
+
rb_define_singleton_method(rbDefmodule, "pp_form", clips_environment_defmodule_static_pp_form, 1);
|
1455
|
+
rb_define_method(rbDefmodule, "pp_form", clips_environment_defmodule_pp_form, 0);
|
1308
1456
|
|
1309
1457
|
VALUE rbFact = rb_define_class_under(rbEnvironment, "Fact", rb_cObject);
|
1458
|
+
rb_define_alloc_func(rbFact, fact_alloc);
|
1310
1459
|
rb_define_singleton_method(rbFact, "deftemplate_name", clips_environment_fact_static_deftemplate_name, 1);
|
1311
1460
|
rb_define_method(rbFact, "deftemplate_name", clips_environment_fact_deftemplate_name, 0);
|
1312
1461
|
rb_define_singleton_method(rbFact, "to_h", clips_environment_fact_static_to_h, 1);
|
@@ -1323,12 +1472,19 @@ void Init_clipsruby(void)
|
|
1323
1472
|
rb_define_method(rbFact, "index", clips_environment_fact_index, 0);
|
1324
1473
|
|
1325
1474
|
VALUE rbDefrule = rb_define_class_under(rbEnvironment, "Defrule", rb_cObject);
|
1475
|
+
rb_define_alloc_func(rbDefrule, defrule_alloc);
|
1326
1476
|
rb_define_singleton_method(rbDefrule, "name", clips_environment_defrule_static_name, 1);
|
1327
1477
|
rb_define_method(rbDefrule, "name", clips_environment_defrule_name, 0);
|
1328
1478
|
rb_define_singleton_method(rbDefrule, "pp_form", clips_environment_defrule_static_pp_form, 1);
|
1329
1479
|
rb_define_method(rbDefrule, "pp_form", clips_environment_defrule_pp_form, 0);
|
1330
1480
|
rb_define_singleton_method(rbDefrule, "is_deletable", clips_environment_defrule_static_is_deletable, 1);
|
1331
1481
|
rb_define_method(rbDefrule, "is_deletable", clips_environment_defrule_is_deletable, 0);
|
1482
|
+
rb_define_singleton_method(rbDefrule, "has_breakpoint", clips_environment_defrule_static_has_breakpoint, 1);
|
1483
|
+
rb_define_method(rbDefrule, "has_breakpoint", clips_environment_defrule_has_breakpoint, 0);
|
1484
|
+
rb_define_singleton_method(rbDefrule, "set_break", clips_environment_defrule_static_set_break, 1);
|
1485
|
+
rb_define_method(rbDefrule, "set_break", clips_environment_defrule_set_break, 0);
|
1486
|
+
rb_define_singleton_method(rbDefrule, "remove_break", clips_environment_defrule_static_remove_break, 1);
|
1487
|
+
rb_define_method(rbDefrule, "remove_break", clips_environment_defrule_remove_break, 0);
|
1332
1488
|
|
1333
1489
|
VALUE rbInstance = rb_define_class_under(rbEnvironment, "Instance", rb_cObject);
|
1334
1490
|
}
|