clipsruby 0.0.42 → 0.0.44
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 +33 -0
- data/ext/clipsruby/clipsruby.c +505 -0
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 83db571b1b54cd6848878cfd5422841e150e51f11b5616640460bce6bac024ef
|
|
4
|
+
data.tar.gz: 5a25ab26198c8d7b1e92fa8d6c903f01455ac36c7eeaa307255002c45733e55c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3ce8105ae4ebab196499a520513f56f1b433c712d14e0d3f87f0febe3f20b2dd156bc21c0c69ece6fd9990e5775aa92bd274a231b58bbdf66892ca0975cb46d4
|
|
7
|
+
data.tar.gz: b375fdfb92af2c1aa02add709b983c1b81cc1376393017026526ca8ac17a8bb6f1aba0776a264bd9eebbceab1d4cc885649a3c8c333eb8b93ec91253c100e8f4
|
data/README.md
CHANGED
|
@@ -401,6 +401,15 @@ CLIPS::Environment.find_defmodule(:a)
|
|
|
401
401
|
env.find_defmodule("foo")
|
|
402
402
|
```
|
|
403
403
|
|
|
404
|
+
#### `CLIPS::Environment.get_activation_list` / `CLIPS::Environment#get_activation_list`
|
|
405
|
+
|
|
406
|
+
Return an array of Activation objects in the current demodule.
|
|
407
|
+
|
|
408
|
+
```ruby
|
|
409
|
+
CLIPS::Environment.get_activation_list
|
|
410
|
+
env.get_activation_list
|
|
411
|
+
```
|
|
412
|
+
|
|
404
413
|
#### `CLIPS::Environment.get_defclass_list` / `CLIPS::Environment#get_defclass_list`
|
|
405
414
|
|
|
406
415
|
Return an array of Defclass names as symbols in the environment. Pass an argument of a
|
|
@@ -850,6 +859,19 @@ CLIPS::Environment::Defrule.salience(defrule)
|
|
|
850
859
|
defrule.salience
|
|
851
860
|
```
|
|
852
861
|
|
|
862
|
+
#### `CLIPS::Environment::Defrule.matches` / `CLIPS::Environment::Defrule#matches`
|
|
863
|
+
|
|
864
|
+
Returns an array holding the number of pattern matches, partial matches,
|
|
865
|
+
and activations for a given rule. Pass a first argument of
|
|
866
|
+
`:verbose`, `:succinct`, or `:terse` to determine the amount of information
|
|
867
|
+
to print to `STDOUT` (`:verbose` by default).
|
|
868
|
+
|
|
869
|
+
```ruby
|
|
870
|
+
CLIPS::Environment::Defrule.matches(defrule, :succinct)
|
|
871
|
+
defrule.matches(:terse)
|
|
872
|
+
[pattern, partial, activations] = defrule.matches
|
|
873
|
+
```
|
|
874
|
+
|
|
853
875
|
### Defmodule Methods
|
|
854
876
|
|
|
855
877
|
#### `CLIPS::Environment::Defmodule.name` / `CLIPS::Environment::Defmodule#name`
|
|
@@ -1141,6 +1163,17 @@ CLIPS::Environment::Deffacts.pp_form(deffacts)
|
|
|
1141
1163
|
deffacts.pp_form
|
|
1142
1164
|
```
|
|
1143
1165
|
|
|
1166
|
+
### Activation Methods
|
|
1167
|
+
|
|
1168
|
+
#### `CLIPS::Environment::Activation.defule_name` / `CLIPS::Environment::Activation#defule_name`
|
|
1169
|
+
|
|
1170
|
+
Returns the name of a defrule that triggered this activation.
|
|
1171
|
+
|
|
1172
|
+
```ruby
|
|
1173
|
+
CLIPS::Environment::Activation.defrule_name
|
|
1174
|
+
activation.defrule_name
|
|
1175
|
+
```
|
|
1176
|
+
|
|
1144
1177
|
## Running the tests
|
|
1145
1178
|
|
|
1146
1179
|
Simply do `rake compile` and then `rake test` in order to run the tests.
|
data/ext/clipsruby/clipsruby.c
CHANGED
|
@@ -103,6 +103,18 @@ static const rb_data_type_t Instance_type = {
|
|
|
103
103
|
.flags = RUBY_TYPED_FREE_IMMEDIATELY
|
|
104
104
|
};
|
|
105
105
|
|
|
106
|
+
size_t activation_size(const void *data)
|
|
107
|
+
{
|
|
108
|
+
return sizeof(Activation);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
static const rb_data_type_t Activation_type = {
|
|
112
|
+
.function = {
|
|
113
|
+
.dsize = activation_size
|
|
114
|
+
},
|
|
115
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY
|
|
116
|
+
};
|
|
117
|
+
|
|
106
118
|
static VALUE clips_environment_fact_deftemplate(VALUE self)
|
|
107
119
|
{
|
|
108
120
|
VALUE rbDeftemplate, rbEnvironment;
|
|
@@ -276,6 +288,11 @@ VALUE instance_alloc(VALUE self)
|
|
|
276
288
|
return TypedData_Wrap_Struct(self, &Instance_type, NULL);
|
|
277
289
|
}
|
|
278
290
|
|
|
291
|
+
VALUE activation_alloc(VALUE self)
|
|
292
|
+
{
|
|
293
|
+
return TypedData_Wrap_Struct(self, &Activation_type, NULL);
|
|
294
|
+
}
|
|
295
|
+
|
|
279
296
|
VALUE environment_alloc(VALUE self)
|
|
280
297
|
{
|
|
281
298
|
return TypedData_Wrap_Struct(self, &Environment_type, CreateEnvironment());
|
|
@@ -1633,6 +1650,63 @@ static VALUE clips_environment_defclass_static_slots(int argc, VALUE *argv, VALU
|
|
|
1633
1650
|
return out;
|
|
1634
1651
|
}
|
|
1635
1652
|
|
|
1653
|
+
static VALUE clips_environment_defrule_matches(int argc, VALUE *argv, VALUE rbDefrule)
|
|
1654
|
+
{
|
|
1655
|
+
VALUE verbosity, rbEnvironment, out;
|
|
1656
|
+
Defrule *defrule;
|
|
1657
|
+
CLIPSValue value;
|
|
1658
|
+
|
|
1659
|
+
rb_scan_args(argc, argv, "01", &verbosity);
|
|
1660
|
+
|
|
1661
|
+
TypedData_Get_Struct(rbDefrule, Defrule, &Defrule_type, defrule);
|
|
1662
|
+
|
|
1663
|
+
rbEnvironment = rb_iv_get(rbDefrule, "@environment");
|
|
1664
|
+
|
|
1665
|
+
if (NIL_P(verbosity) || verbosity == ID2SYM(rb_intern("verbose"))) {
|
|
1666
|
+
Matches(defrule, VERBOSE, &value);
|
|
1667
|
+
} else if (verbosity == ID2SYM(rb_intern("succinct"))) {
|
|
1668
|
+
Matches(defrule, SUCCINCT, &value);
|
|
1669
|
+
} else if (verbosity == ID2SYM(rb_intern("terse"))) {
|
|
1670
|
+
Matches(defrule, TERSE, &value);
|
|
1671
|
+
} else {
|
|
1672
|
+
rb_warn("could not find matches for defrule: unsupported verbosity.");
|
|
1673
|
+
return Qnil;
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
CLIPSValue_to_VALUE(&value, &out, &rbEnvironment);
|
|
1677
|
+
|
|
1678
|
+
return out;
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1681
|
+
|
|
1682
|
+
static VALUE clips_environment_defrule_static_matches(int argc, VALUE *argv, VALUE klass)
|
|
1683
|
+
{
|
|
1684
|
+
VALUE rbDefrule, verbosity, rbEnvironment, out;
|
|
1685
|
+
Defrule *defrule;
|
|
1686
|
+
CLIPSValue value;
|
|
1687
|
+
|
|
1688
|
+
rb_scan_args(argc, argv, "11", &rbDefrule, &verbosity);
|
|
1689
|
+
|
|
1690
|
+
TypedData_Get_Struct(rbDefrule, Defrule, &Defrule_type, defrule);
|
|
1691
|
+
|
|
1692
|
+
rbEnvironment = rb_iv_get(rbDefrule, "@environment");
|
|
1693
|
+
|
|
1694
|
+
if (verbosity == ID2SYM(rb_intern("verbose"))) {
|
|
1695
|
+
Matches(defrule, VERBOSE, &value);
|
|
1696
|
+
} else if (verbosity == ID2SYM(rb_intern("succinct"))) {
|
|
1697
|
+
Matches(defrule, SUCCINCT, &value);
|
|
1698
|
+
} else if (verbosity == ID2SYM(rb_intern("terse"))) {
|
|
1699
|
+
Matches(defrule, TERSE, &value);
|
|
1700
|
+
} else {
|
|
1701
|
+
rb_warn("could not find matches for defrule: unsupported verbosity.");
|
|
1702
|
+
return Qnil;
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
CLIPSValue_to_VALUE(&value, &out, &rbEnvironment);
|
|
1706
|
+
|
|
1707
|
+
return out;
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1636
1710
|
static VALUE clips_environment_run(int argc, VALUE *argv, VALUE environment) {
|
|
1637
1711
|
VALUE integer;
|
|
1638
1712
|
Environment *env;
|
|
@@ -2953,6 +3027,53 @@ static VALUE clips_environment_defmodule_static_find_instance(int argc, VALUE *a
|
|
|
2953
3027
|
}
|
|
2954
3028
|
}
|
|
2955
3029
|
|
|
3030
|
+
static VALUE clips_environment_defmodule_refresh_agenda(VALUE self)
|
|
3031
|
+
{
|
|
3032
|
+
Defmodule *module;
|
|
3033
|
+
|
|
3034
|
+
TypedData_Get_Struct(self, Defmodule, &Defmodule_type, module);
|
|
3035
|
+
|
|
3036
|
+
RefreshAgenda(module);
|
|
3037
|
+
|
|
3038
|
+
return Qnil;
|
|
3039
|
+
}
|
|
3040
|
+
|
|
3041
|
+
static VALUE clips_environment_defmodule_static_refresh_agenda(VALUE self, VALUE rbDefmodule)
|
|
3042
|
+
{
|
|
3043
|
+
return clips_environment_defmodule_refresh_agenda(rbDefmodule);
|
|
3044
|
+
}
|
|
3045
|
+
|
|
3046
|
+
static VALUE clips_environment_defmodule_reorder_agenda(VALUE self)
|
|
3047
|
+
{
|
|
3048
|
+
Defmodule *module;
|
|
3049
|
+
|
|
3050
|
+
TypedData_Get_Struct(self, Defmodule, &Defmodule_type, module);
|
|
3051
|
+
|
|
3052
|
+
ReorderAgenda(module);
|
|
3053
|
+
|
|
3054
|
+
return Qnil;
|
|
3055
|
+
}
|
|
3056
|
+
|
|
3057
|
+
static VALUE clips_environment_defmodule_static_reorder_agenda(VALUE self, VALUE rbDefmodule)
|
|
3058
|
+
{
|
|
3059
|
+
return clips_environment_defmodule_reorder_agenda(rbDefmodule);
|
|
3060
|
+
}
|
|
3061
|
+
|
|
3062
|
+
static VALUE clips_environment_defmodule_delete_all_activations(VALUE self)
|
|
3063
|
+
{
|
|
3064
|
+
Defmodule *module;
|
|
3065
|
+
|
|
3066
|
+
TypedData_Get_Struct(self, Defmodule, &Defmodule_type, module);
|
|
3067
|
+
|
|
3068
|
+
DeleteAllActivations(module);
|
|
3069
|
+
|
|
3070
|
+
return Qnil;
|
|
3071
|
+
}
|
|
3072
|
+
|
|
3073
|
+
static VALUE clips_environment_defmodule_static_delete_all_activations(VALUE self, VALUE rbDefmodule)
|
|
3074
|
+
{
|
|
3075
|
+
return clips_environment_defmodule_delete_all_activations(rbDefmodule);
|
|
3076
|
+
}
|
|
2956
3077
|
|
|
2957
3078
|
static VALUE clips_environment_find_deftemplate(VALUE self, VALUE deftemplate_name)
|
|
2958
3079
|
{
|
|
@@ -3748,6 +3869,36 @@ static VALUE clips_environment_static_get_defmodule_list(VALUE self, VALUE rbEnv
|
|
|
3748
3869
|
return clips_environment_get_defmodule_list(rbEnvironment);
|
|
3749
3870
|
}
|
|
3750
3871
|
|
|
3872
|
+
static VALUE clips_environment_get_activation_list(VALUE self)
|
|
3873
|
+
{
|
|
3874
|
+
Activation *theActivation;
|
|
3875
|
+
Environment *env;
|
|
3876
|
+
VALUE rbActivation, returnArray;
|
|
3877
|
+
|
|
3878
|
+
returnArray = rb_ary_new2(0);
|
|
3879
|
+
|
|
3880
|
+
TypedData_Get_Struct(self, Environment, &Environment_type, env);
|
|
3881
|
+
|
|
3882
|
+
for (
|
|
3883
|
+
theActivation = GetNextActivation(env,NULL);
|
|
3884
|
+
theActivation != NULL;
|
|
3885
|
+
theActivation = GetNextActivation(env,theActivation)
|
|
3886
|
+
) {
|
|
3887
|
+
rbActivation =
|
|
3888
|
+
TypedData_Wrap_Struct(rb_const_get(CLASS_OF(self), rb_intern("Activation")), &Activation_type, theActivation);
|
|
3889
|
+
|
|
3890
|
+
rb_iv_set(rbActivation, "@environment", self);
|
|
3891
|
+
rb_ary_push(returnArray, rbActivation);
|
|
3892
|
+
}
|
|
3893
|
+
|
|
3894
|
+
return returnArray;
|
|
3895
|
+
}
|
|
3896
|
+
|
|
3897
|
+
static VALUE clips_environment_static_get_activation_list(VALUE self, VALUE rbEnvironment)
|
|
3898
|
+
{
|
|
3899
|
+
return clips_environment_get_activation_list(rbEnvironment);
|
|
3900
|
+
}
|
|
3901
|
+
|
|
3751
3902
|
static VALUE clips_environment_defrule_name(VALUE self)
|
|
3752
3903
|
{
|
|
3753
3904
|
Defrule *defrule;
|
|
@@ -4672,6 +4823,321 @@ static VALUE clips_environment_static_get_watch_state(VALUE self, VALUE rbEnviro
|
|
|
4672
4823
|
return clips_environment_get_watch_state(rbEnvironment, item);
|
|
4673
4824
|
}
|
|
4674
4825
|
|
|
4826
|
+
static VALUE clips_environment_refresh_all_agendas(VALUE self)
|
|
4827
|
+
{
|
|
4828
|
+
Environment *env;
|
|
4829
|
+
|
|
4830
|
+
TypedData_Get_Struct(self, Environment, &Environment_type, env);
|
|
4831
|
+
|
|
4832
|
+
RefreshAllAgendas(env);
|
|
4833
|
+
|
|
4834
|
+
return Qnil;
|
|
4835
|
+
}
|
|
4836
|
+
|
|
4837
|
+
static VALUE clips_environment_static_refresh_all_agendas(VALUE self, VALUE rbEnvironment)
|
|
4838
|
+
{
|
|
4839
|
+
return clips_environment_refresh_all_agendas(rbEnvironment);
|
|
4840
|
+
}
|
|
4841
|
+
|
|
4842
|
+
static VALUE clips_environment_reorder_all_agendas(VALUE self)
|
|
4843
|
+
{
|
|
4844
|
+
Environment *env;
|
|
4845
|
+
|
|
4846
|
+
TypedData_Get_Struct(self, Environment, &Environment_type, env);
|
|
4847
|
+
|
|
4848
|
+
ReorderAllAgendas(env);
|
|
4849
|
+
|
|
4850
|
+
return Qnil;
|
|
4851
|
+
}
|
|
4852
|
+
|
|
4853
|
+
static VALUE clips_environment_static_reorder_all_agendas(VALUE self, VALUE rbEnvironment)
|
|
4854
|
+
{
|
|
4855
|
+
return clips_environment_reorder_all_agendas(rbEnvironment);
|
|
4856
|
+
}
|
|
4857
|
+
|
|
4858
|
+
static VALUE clips_environment_get_agenda_changed(VALUE self)
|
|
4859
|
+
{
|
|
4860
|
+
Environment *environment;
|
|
4861
|
+
|
|
4862
|
+
TypedData_Get_Struct(self, Environment, &Environment_type, environment);
|
|
4863
|
+
|
|
4864
|
+
return GetAgendaChanged(environment) ? Qtrue : Qfalse;
|
|
4865
|
+
}
|
|
4866
|
+
|
|
4867
|
+
static VALUE clips_environment_static_get_agenda_changed(VALUE self, VALUE rbEnvironment)
|
|
4868
|
+
{
|
|
4869
|
+
return clips_environment_get_agenda_changed(rbEnvironment);
|
|
4870
|
+
}
|
|
4871
|
+
|
|
4872
|
+
static VALUE clips_environment_set_agenda_changed(VALUE self, VALUE changed)
|
|
4873
|
+
{
|
|
4874
|
+
Environment *environment;
|
|
4875
|
+
|
|
4876
|
+
TypedData_Get_Struct(self, Environment, &Environment_type, environment);
|
|
4877
|
+
|
|
4878
|
+
SetAgendaChanged(environment, changed == Qtrue);
|
|
4879
|
+
|
|
4880
|
+
return Qnil;
|
|
4881
|
+
}
|
|
4882
|
+
|
|
4883
|
+
static VALUE clips_environment_static_set_agenda_changed(VALUE self, VALUE rbEnvironment, VALUE changed)
|
|
4884
|
+
{
|
|
4885
|
+
return clips_environment_set_agenda_changed(rbEnvironment, changed);
|
|
4886
|
+
}
|
|
4887
|
+
|
|
4888
|
+
// copied from agenda.c, not exposed in agenda.h
|
|
4889
|
+
/*****************************************************************/
|
|
4890
|
+
/* SalienceEvaluationName: Given the integer value corresponding */
|
|
4891
|
+
/* to a specified salience evaluation behavior, returns a */
|
|
4892
|
+
/* character string of the behavior's name. */
|
|
4893
|
+
/*****************************************************************/
|
|
4894
|
+
static const char *SalienceEvaluationName(
|
|
4895
|
+
SalienceEvaluationType strategy)
|
|
4896
|
+
{
|
|
4897
|
+
const char *sname;
|
|
4898
|
+
|
|
4899
|
+
switch (strategy)
|
|
4900
|
+
{
|
|
4901
|
+
case WHEN_DEFINED:
|
|
4902
|
+
sname = "when-defined";
|
|
4903
|
+
break;
|
|
4904
|
+
case WHEN_ACTIVATED:
|
|
4905
|
+
sname = "when-activated";
|
|
4906
|
+
break;
|
|
4907
|
+
case EVERY_CYCLE:
|
|
4908
|
+
sname = "every-cycle";
|
|
4909
|
+
break;
|
|
4910
|
+
default:
|
|
4911
|
+
sname = "unknown";
|
|
4912
|
+
break;
|
|
4913
|
+
}
|
|
4914
|
+
|
|
4915
|
+
return sname;
|
|
4916
|
+
}
|
|
4917
|
+
|
|
4918
|
+
static VALUE clips_environment_get_salience_evaluation(VALUE self)
|
|
4919
|
+
{
|
|
4920
|
+
Environment *environment;
|
|
4921
|
+
|
|
4922
|
+
TypedData_Get_Struct(self, Environment, &Environment_type, environment);
|
|
4923
|
+
|
|
4924
|
+
return ID2SYM(rb_intern(SalienceEvaluationName(GetSalienceEvaluation(environment))));
|
|
4925
|
+
}
|
|
4926
|
+
|
|
4927
|
+
static VALUE clips_environment_static_get_salience_evaluation(VALUE self, VALUE rbEnvironment)
|
|
4928
|
+
{
|
|
4929
|
+
return clips_environment_get_salience_evaluation(rbEnvironment);
|
|
4930
|
+
}
|
|
4931
|
+
|
|
4932
|
+
static VALUE clips_environment_set_salience_evaluation(VALUE self, VALUE changed)
|
|
4933
|
+
{
|
|
4934
|
+
Environment *environment;
|
|
4935
|
+
const char *argument, *oldValue;
|
|
4936
|
+
|
|
4937
|
+
TypedData_Get_Struct(self, Environment, &Environment_type, environment);
|
|
4938
|
+
|
|
4939
|
+
argument = rb_id2name(SYM2ID(changed));
|
|
4940
|
+
oldValue = SalienceEvaluationName(GetSalienceEvaluation(environment));
|
|
4941
|
+
|
|
4942
|
+
if (strcmp(argument,"when-defined") == 0)
|
|
4943
|
+
{ SetSalienceEvaluation(environment,WHEN_DEFINED); }
|
|
4944
|
+
else if (strcmp(argument,"when-activated") == 0)
|
|
4945
|
+
{ SetSalienceEvaluation(environment,WHEN_ACTIVATED); }
|
|
4946
|
+
else if (strcmp(argument,"every-cycle") == 0)
|
|
4947
|
+
{ SetSalienceEvaluation(environment,EVERY_CYCLE); }
|
|
4948
|
+
else
|
|
4949
|
+
{
|
|
4950
|
+
rb_warn("set_salience_evaluation: symbol must be when-defined, when-activated, or every-cycle");
|
|
4951
|
+
return Qfalse;
|
|
4952
|
+
}
|
|
4953
|
+
|
|
4954
|
+
return ID2SYM(rb_intern(oldValue));
|
|
4955
|
+
}
|
|
4956
|
+
|
|
4957
|
+
static VALUE clips_environment_static_set_salience_evaluation(VALUE self, VALUE rbEnvironment, VALUE changed)
|
|
4958
|
+
{
|
|
4959
|
+
return clips_environment_set_salience_evaluation(rbEnvironment, changed);
|
|
4960
|
+
}
|
|
4961
|
+
|
|
4962
|
+
// copied from crstrtgy.c
|
|
4963
|
+
// not exposed in crstrtgy.h
|
|
4964
|
+
/**********************************************************/
|
|
4965
|
+
/* GetStrategyName: Given the integer value corresponding */
|
|
4966
|
+
/* to a specified strategy, return a character string */
|
|
4967
|
+
/* of the strategy's name. */
|
|
4968
|
+
/**********************************************************/
|
|
4969
|
+
static const char *GetStrategyName(
|
|
4970
|
+
StrategyType strategy)
|
|
4971
|
+
{
|
|
4972
|
+
const char *sname;
|
|
4973
|
+
|
|
4974
|
+
switch (strategy)
|
|
4975
|
+
{
|
|
4976
|
+
case DEPTH_STRATEGY:
|
|
4977
|
+
sname = "depth";
|
|
4978
|
+
break;
|
|
4979
|
+
case BREADTH_STRATEGY:
|
|
4980
|
+
sname = "breadth";
|
|
4981
|
+
break;
|
|
4982
|
+
case LEX_STRATEGY:
|
|
4983
|
+
sname = "lex";
|
|
4984
|
+
break;
|
|
4985
|
+
case MEA_STRATEGY:
|
|
4986
|
+
sname = "mea";
|
|
4987
|
+
break;
|
|
4988
|
+
case COMPLEXITY_STRATEGY:
|
|
4989
|
+
sname = "complexity";
|
|
4990
|
+
break;
|
|
4991
|
+
case SIMPLICITY_STRATEGY:
|
|
4992
|
+
sname = "simplicity";
|
|
4993
|
+
break;
|
|
4994
|
+
case RANDOM_STRATEGY:
|
|
4995
|
+
sname = "random";
|
|
4996
|
+
break;
|
|
4997
|
+
default:
|
|
4998
|
+
sname = "unknown";
|
|
4999
|
+
break;
|
|
5000
|
+
}
|
|
5001
|
+
|
|
5002
|
+
return(sname);
|
|
5003
|
+
}
|
|
5004
|
+
|
|
5005
|
+
static VALUE clips_environment_get_strategy(VALUE self)
|
|
5006
|
+
{
|
|
5007
|
+
Environment *environment;
|
|
5008
|
+
|
|
5009
|
+
TypedData_Get_Struct(self, Environment, &Environment_type, environment);
|
|
5010
|
+
|
|
5011
|
+
return ID2SYM(rb_intern(GetStrategyName(GetStrategy(environment))));
|
|
5012
|
+
}
|
|
5013
|
+
|
|
5014
|
+
static VALUE clips_environment_static_get_strategy(VALUE self, VALUE rbEnvironment)
|
|
5015
|
+
{
|
|
5016
|
+
return clips_environment_get_strategy(rbEnvironment);
|
|
5017
|
+
}
|
|
5018
|
+
|
|
5019
|
+
static VALUE clips_environment_set_strategy(VALUE self, VALUE changed)
|
|
5020
|
+
{
|
|
5021
|
+
Environment *environment;
|
|
5022
|
+
const char *argument, *oldValue;
|
|
5023
|
+
|
|
5024
|
+
TypedData_Get_Struct(self, Environment, &Environment_type, environment);
|
|
5025
|
+
|
|
5026
|
+
argument = rb_id2name(SYM2ID(changed));
|
|
5027
|
+
oldValue = GetStrategyName(GetStrategy(environment));
|
|
5028
|
+
|
|
5029
|
+
if (strcmp(argument,"depth") == 0)
|
|
5030
|
+
{ SetStrategy(environment,DEPTH_STRATEGY); }
|
|
5031
|
+
else if (strcmp(argument,"breadth") == 0)
|
|
5032
|
+
{ SetStrategy(environment,BREADTH_STRATEGY); }
|
|
5033
|
+
else if (strcmp(argument,"lex") == 0)
|
|
5034
|
+
{ SetStrategy(environment,LEX_STRATEGY); }
|
|
5035
|
+
else if (strcmp(argument,"mea") == 0)
|
|
5036
|
+
{ SetStrategy(environment,MEA_STRATEGY); }
|
|
5037
|
+
else if (strcmp(argument,"complexity") == 0)
|
|
5038
|
+
{ SetStrategy(environment,COMPLEXITY_STRATEGY); }
|
|
5039
|
+
else if (strcmp(argument,"simplicity") == 0)
|
|
5040
|
+
{ SetStrategy(environment,SIMPLICITY_STRATEGY); }
|
|
5041
|
+
else if (strcmp(argument,"random") == 0)
|
|
5042
|
+
{ SetStrategy(environment,RANDOM_STRATEGY); }
|
|
5043
|
+
else
|
|
5044
|
+
{
|
|
5045
|
+
rb_warn("set_strategy: symbol must be depth, breadth, lex, mea, complexity, simplicity, or random");
|
|
5046
|
+
return Qfalse;
|
|
5047
|
+
}
|
|
5048
|
+
|
|
5049
|
+
return ID2SYM(rb_intern(oldValue));
|
|
5050
|
+
}
|
|
5051
|
+
|
|
5052
|
+
static VALUE clips_environment_static_set_strategy(VALUE self, VALUE rbEnvironment, VALUE changed)
|
|
5053
|
+
{
|
|
5054
|
+
return clips_environment_set_strategy(rbEnvironment, changed);
|
|
5055
|
+
}
|
|
5056
|
+
|
|
5057
|
+
|
|
5058
|
+
static VALUE clips_environment_activation_defrule_name(VALUE self)
|
|
5059
|
+
{
|
|
5060
|
+
Activation *activation;
|
|
5061
|
+
|
|
5062
|
+
TypedData_Get_Struct(self, Activation, &Activation_type, activation);
|
|
5063
|
+
|
|
5064
|
+
return ID2SYM(rb_intern(ActivationRuleName(activation)));
|
|
5065
|
+
}
|
|
5066
|
+
|
|
5067
|
+
static VALUE clips_environment_activation_static_defrule_name(VALUE self, VALUE rbActivation)
|
|
5068
|
+
{
|
|
5069
|
+
return clips_environment_activation_defrule_name(rbActivation);
|
|
5070
|
+
}
|
|
5071
|
+
|
|
5072
|
+
static VALUE clips_environment_activation_get_salience(VALUE self)
|
|
5073
|
+
{
|
|
5074
|
+
Activation *activation;
|
|
5075
|
+
|
|
5076
|
+
TypedData_Get_Struct(self, Activation, &Activation_type, activation);
|
|
5077
|
+
|
|
5078
|
+
return LONG2NUM(ActivationGetSalience(activation));
|
|
5079
|
+
}
|
|
5080
|
+
|
|
5081
|
+
static VALUE clips_environment_activation_static_get_salience(VALUE self, VALUE rbActivation)
|
|
5082
|
+
{
|
|
5083
|
+
return clips_environment_activation_get_salience(rbActivation);
|
|
5084
|
+
}
|
|
5085
|
+
|
|
5086
|
+
static VALUE clips_environment_activation_set_salience(VALUE self, VALUE salience)
|
|
5087
|
+
{
|
|
5088
|
+
Activation *activation;
|
|
5089
|
+
|
|
5090
|
+
TypedData_Get_Struct(self, Activation, &Activation_type, activation);
|
|
5091
|
+
|
|
5092
|
+
return LONG2NUM(ActivationSetSalience(activation, NUM2LONG(salience)));
|
|
5093
|
+
}
|
|
5094
|
+
|
|
5095
|
+
static VALUE clips_environment_activation_static_set_salience(VALUE self, VALUE rbActivation, VALUE salience)
|
|
5096
|
+
{
|
|
5097
|
+
return clips_environment_activation_set_salience(rbActivation, salience);
|
|
5098
|
+
}
|
|
5099
|
+
|
|
5100
|
+
static VALUE clips_environment_activation_pp_form(VALUE self)
|
|
5101
|
+
{
|
|
5102
|
+
Environment *env;
|
|
5103
|
+
Activation *activation;
|
|
5104
|
+
StringBuilder *sb;
|
|
5105
|
+
VALUE toReturn;
|
|
5106
|
+
|
|
5107
|
+
VALUE rbEnvironment = rb_iv_get(self, "@environment");
|
|
5108
|
+
TypedData_Get_Struct(rbEnvironment, Environment, &Environment_type, env);
|
|
5109
|
+
sb = CreateStringBuilder(env, 0);
|
|
5110
|
+
|
|
5111
|
+
TypedData_Get_Struct(self, Activation, &Activation_type, activation);
|
|
5112
|
+
|
|
5113
|
+
ActivationPPForm(activation, sb);
|
|
5114
|
+
toReturn = rb_str_new2(sb->contents);
|
|
5115
|
+
SBDispose(sb);
|
|
5116
|
+
|
|
5117
|
+
return toReturn;
|
|
5118
|
+
}
|
|
5119
|
+
|
|
5120
|
+
static VALUE clips_environment_activation_static_pp_form(VALUE self, VALUE rbActivation)
|
|
5121
|
+
{
|
|
5122
|
+
return clips_environment_activation_pp_form(rbActivation);
|
|
5123
|
+
}
|
|
5124
|
+
|
|
5125
|
+
static VALUE clips_environment_activation_delete_activation(VALUE self)
|
|
5126
|
+
{
|
|
5127
|
+
Activation *activation;
|
|
5128
|
+
|
|
5129
|
+
TypedData_Get_Struct(self, Activation, &Activation_type, activation);
|
|
5130
|
+
|
|
5131
|
+
DeleteActivation(activation);
|
|
5132
|
+
|
|
5133
|
+
return Qnil;
|
|
5134
|
+
}
|
|
5135
|
+
|
|
5136
|
+
static VALUE clips_environment_activation_static_delete_activation(VALUE self, VALUE rbActivation)
|
|
5137
|
+
{
|
|
5138
|
+
return clips_environment_activation_delete_activation(rbActivation);
|
|
5139
|
+
}
|
|
5140
|
+
|
|
4675
5141
|
void Init_clipsruby(void)
|
|
4676
5142
|
{
|
|
4677
5143
|
VALUE rbCLIPS = rb_define_module("CLIPS");
|
|
@@ -4753,6 +5219,8 @@ void Init_clipsruby(void)
|
|
|
4753
5219
|
rb_define_method(rbEnvironment, "get_defrule_list", clips_environment_get_defrule_list, -1);
|
|
4754
5220
|
rb_define_singleton_method(rbEnvironment, "get_defmodule_list", clips_environment_static_get_defmodule_list, 1);
|
|
4755
5221
|
rb_define_method(rbEnvironment, "get_defmodule_list", clips_environment_get_defmodule_list, 0);
|
|
5222
|
+
rb_define_singleton_method(rbEnvironment, "get_activation_list", clips_environment_static_get_activation_list, 1);
|
|
5223
|
+
rb_define_method(rbEnvironment, "get_activation_list", clips_environment_get_activation_list, 0);
|
|
4756
5224
|
rb_define_singleton_method(rbEnvironment, "find_deffacts", clips_environment_static_find_deffacts, 2);
|
|
4757
5225
|
rb_define_method(rbEnvironment, "find_deffacts", clips_environment_find_deffacts, 1);
|
|
4758
5226
|
rb_define_singleton_method(rbEnvironment, "watch", clips_environment_static_watch, 2);
|
|
@@ -4823,6 +5291,22 @@ void Init_clipsruby(void)
|
|
|
4823
5291
|
rb_define_method(rbEnvironment, "get_watch_state", clips_environment_get_watch_state, 1);
|
|
4824
5292
|
rb_define_singleton_method(rbEnvironment, "make_instance", clips_environment_static_make_instance, -1);
|
|
4825
5293
|
rb_define_method(rbEnvironment, "make_instance", clips_environment_make_instance, -1);
|
|
5294
|
+
rb_define_singleton_method(rbEnvironment, "refresh_all_agendas", clips_environment_static_refresh_all_agendas, 1);
|
|
5295
|
+
rb_define_method(rbEnvironment, "refresh_all_agendas", clips_environment_refresh_all_agendas, 0);
|
|
5296
|
+
rb_define_singleton_method(rbEnvironment, "reorder_all_agendas", clips_environment_static_reorder_all_agendas, 1);
|
|
5297
|
+
rb_define_method(rbEnvironment, "reorder_all_agendas", clips_environment_reorder_all_agendas, 0);
|
|
5298
|
+
rb_define_singleton_method(rbEnvironment, "get_agenda_changed", clips_environment_static_get_agenda_changed, 1);
|
|
5299
|
+
rb_define_method(rbEnvironment, "get_agenda_changed", clips_environment_get_agenda_changed, 0);
|
|
5300
|
+
rb_define_singleton_method(rbEnvironment, "set_agenda_changed", clips_environment_static_set_agenda_changed, 2);
|
|
5301
|
+
rb_define_method(rbEnvironment, "set_agenda_changed", clips_environment_set_agenda_changed, 1);
|
|
5302
|
+
rb_define_singleton_method(rbEnvironment, "get_salience_evaluation", clips_environment_static_get_salience_evaluation, 1);
|
|
5303
|
+
rb_define_method(rbEnvironment, "get_salience_evaluation", clips_environment_get_salience_evaluation, 0);
|
|
5304
|
+
rb_define_singleton_method(rbEnvironment, "set_salience_evaluation", clips_environment_static_set_salience_evaluation, 2);
|
|
5305
|
+
rb_define_method(rbEnvironment, "set_salience_evaluation", clips_environment_set_salience_evaluation, 1);
|
|
5306
|
+
rb_define_singleton_method(rbEnvironment, "get_strategy", clips_environment_static_get_strategy, 1);
|
|
5307
|
+
rb_define_method(rbEnvironment, "get_strategy", clips_environment_get_strategy, 0);
|
|
5308
|
+
rb_define_singleton_method(rbEnvironment, "set_strategy", clips_environment_static_set_strategy, 2);
|
|
5309
|
+
rb_define_method(rbEnvironment, "set_strategy", clips_environment_set_strategy, 1);
|
|
4826
5310
|
|
|
4827
5311
|
VALUE rbDeffacts = rb_define_class_under(rbEnvironment, "Deffacts", rb_cObject);
|
|
4828
5312
|
rb_define_alloc_func(rbDeffacts, deffacts_alloc);
|
|
@@ -4886,6 +5370,12 @@ void Init_clipsruby(void)
|
|
|
4886
5370
|
rb_define_method(rbDefmodule, "get_defrule_list", clips_environment_defmodule_get_defrule_list, 0);
|
|
4887
5371
|
rb_define_singleton_method(rbDefmodule, "find_instance", clips_environment_defmodule_static_find_instance, -1);
|
|
4888
5372
|
rb_define_method(rbDefmodule, "find_instance", clips_environment_defmodule_find_instance, -1);
|
|
5373
|
+
rb_define_singleton_method(rbDefmodule, "refresh_agenda", clips_environment_defmodule_static_refresh_agenda, 1);
|
|
5374
|
+
rb_define_method(rbDefmodule, "refresh_agenda", clips_environment_defmodule_refresh_agenda, 0);
|
|
5375
|
+
rb_define_singleton_method(rbDefmodule, "reorder_agenda", clips_environment_defmodule_static_reorder_agenda, 1);
|
|
5376
|
+
rb_define_method(rbDefmodule, "reorder_agenda", clips_environment_defmodule_reorder_agenda, 0);
|
|
5377
|
+
rb_define_singleton_method(rbDefmodule, "delete_all_activations", clips_environment_defmodule_static_delete_all_activations, 1);
|
|
5378
|
+
rb_define_method(rbDefmodule, "delete_all_activations", clips_environment_defmodule_delete_all_activations, 0);
|
|
4889
5379
|
|
|
4890
5380
|
VALUE rbFact = rb_define_class_under(rbEnvironment, "Fact", rb_cObject);
|
|
4891
5381
|
rb_define_alloc_func(rbFact, fact_alloc);
|
|
@@ -4930,6 +5420,8 @@ void Init_clipsruby(void)
|
|
|
4930
5420
|
rb_define_method(rbDefrule, "defmodule_name", clips_environment_defrule_defmodule_name, 0);
|
|
4931
5421
|
rb_define_singleton_method(rbDefrule, "defmodule", clips_environment_defrule_static_defmodule, 1);
|
|
4932
5422
|
rb_define_method(rbDefrule, "defmodule", clips_environment_defrule_defmodule, 0);
|
|
5423
|
+
rb_define_singleton_method(rbDefrule, "matches", clips_environment_defrule_static_matches, -1);
|
|
5424
|
+
rb_define_method(rbDefrule, "matches", clips_environment_defrule_matches, -1);
|
|
4933
5425
|
|
|
4934
5426
|
VALUE rbDefclass = rb_define_class_under(rbEnvironment, "Defclass", rb_cObject);
|
|
4935
5427
|
rb_define_alloc_func(rbDefclass, defclass_alloc);
|
|
@@ -4964,4 +5456,17 @@ void Init_clipsruby(void)
|
|
|
4964
5456
|
rb_define_method(rbInstance, "pp_form", clips_environment_instance_pp_form, 0);
|
|
4965
5457
|
rb_define_singleton_method(rbInstance, "to_h", clips_environment_instance_static_to_h, -1);
|
|
4966
5458
|
rb_define_method(rbInstance, "to_h", clips_environment_instance_to_h, -1);
|
|
5459
|
+
|
|
5460
|
+
VALUE rbActivation = rb_define_class_under(rbEnvironment, "Activation", rb_cObject);
|
|
5461
|
+
rb_define_alloc_func(rbActivation, activation_alloc);
|
|
5462
|
+
rb_define_singleton_method(rbActivation, "defrule_name", clips_environment_activation_static_defrule_name, 1);
|
|
5463
|
+
rb_define_method(rbActivation, "defrule_name", clips_environment_activation_defrule_name, 0);
|
|
5464
|
+
rb_define_singleton_method(rbActivation, "get_salience", clips_environment_activation_static_get_salience, 1);
|
|
5465
|
+
rb_define_method(rbActivation, "get_salience", clips_environment_activation_get_salience, 0);
|
|
5466
|
+
rb_define_singleton_method(rbActivation, "set_salience", clips_environment_activation_static_set_salience, 2);
|
|
5467
|
+
rb_define_method(rbActivation, "set_salience", clips_environment_activation_set_salience, 1);
|
|
5468
|
+
rb_define_singleton_method(rbActivation, "pp_form", clips_environment_activation_static_pp_form, 1);
|
|
5469
|
+
rb_define_method(rbActivation, "pp_form", clips_environment_activation_pp_form, 0);
|
|
5470
|
+
rb_define_singleton_method(rbActivation, "delete_activation", clips_environment_activation_static_delete_activation, 1);
|
|
5471
|
+
rb_define_method(rbActivation, "delete_activation", clips_environment_activation_delete_activation, 0);
|
|
4967
5472
|
}
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
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.44
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ryan Johnston
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies: []
|
|
13
12
|
description: Calling the CLIPS programming language from within Ruby
|
|
14
13
|
email: mrryanjohnston@gmail.com
|
|
@@ -369,7 +368,6 @@ licenses:
|
|
|
369
368
|
metadata:
|
|
370
369
|
documentation_uri: https://github.com/mrryanjohnston/clipsruby/blob/main/README.md
|
|
371
370
|
source_code_uri: https://github.com/mrryanjohnston/clipsruby
|
|
372
|
-
post_install_message:
|
|
373
371
|
rdoc_options: []
|
|
374
372
|
require_paths:
|
|
375
373
|
- lib
|
|
@@ -385,8 +383,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
385
383
|
- !ruby/object:Gem::Version
|
|
386
384
|
version: '0'
|
|
387
385
|
requirements: []
|
|
388
|
-
rubygems_version: 3.
|
|
389
|
-
signing_key:
|
|
386
|
+
rubygems_version: 3.6.9
|
|
390
387
|
specification_version: 4
|
|
391
388
|
summary: Calling CLIPS from within Ruby
|
|
392
389
|
test_files: []
|