clipsruby 0.0.43 → 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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/ext/clipsruby/clipsruby.c +377 -0
  3. metadata +3 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6fc073e3a6ed11b566b2aff954ff17fcb2874fa1cf83f8b4fbeba5b893d204bc
4
- data.tar.gz: f9c000d65fae9a2140f43bf234e8b3360937f461df35e5b2e659dac942048063
3
+ metadata.gz: 83db571b1b54cd6848878cfd5422841e150e51f11b5616640460bce6bac024ef
4
+ data.tar.gz: 5a25ab26198c8d7b1e92fa8d6c903f01455ac36c7eeaa307255002c45733e55c
5
5
  SHA512:
6
- metadata.gz: 522fe0e9ca9ad792684bac67b24708897f68840586c180e5e8712fa9920561b1f9316e968d22bb7cf5371f1467705b2b6e739a649cff0d7fa22f76433164e60e
7
- data.tar.gz: 630373e7297ac2945d7a560d4db06262b482b526591e7a7d685a6305ffbd6e5f2864ad58b49eea0e8481f7806515dba5d4cd29388685b7d2429cf79a18307097
6
+ metadata.gz: 3ce8105ae4ebab196499a520513f56f1b433c712d14e0d3f87f0febe3f20b2dd156bc21c0c69ece6fd9990e5775aa92bd274a231b58bbdf66892ca0975cb46d4
7
+ data.tar.gz: b375fdfb92af2c1aa02add709b983c1b81cc1376393017026526ca8ac17a8bb6f1aba0776a264bd9eebbceab1d4cc885649a3c8c333eb8b93ec91253c100e8f4
@@ -3027,6 +3027,53 @@ static VALUE clips_environment_defmodule_static_find_instance(int argc, VALUE *a
3027
3027
  }
3028
3028
  }
3029
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
+ }
3030
3077
 
3031
3078
  static VALUE clips_environment_find_deftemplate(VALUE self, VALUE deftemplate_name)
3032
3079
  {
@@ -4776,6 +4823,238 @@ static VALUE clips_environment_static_get_watch_state(VALUE self, VALUE rbEnviro
4776
4823
  return clips_environment_get_watch_state(rbEnvironment, item);
4777
4824
  }
4778
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
+
4779
5058
  static VALUE clips_environment_activation_defrule_name(VALUE self)
4780
5059
  {
4781
5060
  Activation *activation;
@@ -4790,6 +5069,74 @@ static VALUE clips_environment_activation_static_defrule_name(VALUE self, VALUE
4790
5069
  return clips_environment_activation_defrule_name(rbActivation);
4791
5070
  }
4792
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
+ }
4793
5140
 
4794
5141
  void Init_clipsruby(void)
4795
5142
  {
@@ -4944,6 +5291,22 @@ void Init_clipsruby(void)
4944
5291
  rb_define_method(rbEnvironment, "get_watch_state", clips_environment_get_watch_state, 1);
4945
5292
  rb_define_singleton_method(rbEnvironment, "make_instance", clips_environment_static_make_instance, -1);
4946
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);
4947
5310
 
4948
5311
  VALUE rbDeffacts = rb_define_class_under(rbEnvironment, "Deffacts", rb_cObject);
4949
5312
  rb_define_alloc_func(rbDeffacts, deffacts_alloc);
@@ -5007,6 +5370,12 @@ void Init_clipsruby(void)
5007
5370
  rb_define_method(rbDefmodule, "get_defrule_list", clips_environment_defmodule_get_defrule_list, 0);
5008
5371
  rb_define_singleton_method(rbDefmodule, "find_instance", clips_environment_defmodule_static_find_instance, -1);
5009
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);
5010
5379
 
5011
5380
  VALUE rbFact = rb_define_class_under(rbEnvironment, "Fact", rb_cObject);
5012
5381
  rb_define_alloc_func(rbFact, fact_alloc);
@@ -5092,4 +5461,12 @@ void Init_clipsruby(void)
5092
5461
  rb_define_alloc_func(rbActivation, activation_alloc);
5093
5462
  rb_define_singleton_method(rbActivation, "defrule_name", clips_environment_activation_static_defrule_name, 1);
5094
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);
5095
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.43
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: 2024-10-13 00:00:00.000000000 Z
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.5.16
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: []