From a2e0cc98bb6fb56c45fb5a7480309ad39183d926 Mon Sep 17 00:00:00 2001 From: Graham Nelson Date: Thu, 22 Jun 2023 09:22:19 +0100 Subject: [PATCH] Further work on enumerations --- README.md | 2 +- build.txt | 4 ++-- .../Internal/Extensions/Graham Nelson/Basic Inform.i7x | 1 + .../Internal/Inter/Architecture16Kit/kit_metadata.json | 2 +- .../Internal/Inter/Architecture32Kit/kit_metadata.json | 2 +- .../Internal/Inter/BasicInformKit/kit_metadata.json | 2 +- .../Internal/Inter/CommandParserKit/kit_metadata.json | 2 +- .../Inter/EnglishLanguageKit/kit_metadata.json | 2 +- inform7/Internal/Inter/WorldModelKit/kit_metadata.json | 2 +- .../basic_inform/Sections/Phrase Definitions.w | 1 + inform7/knowledge-module/Chapter 2/Instances.w | 6 +++++- services/kinds-module/Chapter 4/Kind Commands.w | 10 +++++++++- services/kinds-module/Chapter 4/Kind Constructors.w | 1 + 13 files changed, 26 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 4a9e50416..362d78b0a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Inform 7 -[Version](notes/versioning.md): 10.2.0-beta+6W64 'Krypton' (21 June 2023) +[Version](notes/versioning.md): 10.2.0-beta+6W65 'Krypton' (22 June 2023) ## About Inform diff --git a/build.txt b/build.txt index eacaa1347..df59ff4a0 100644 --- a/build.txt +++ b/build.txt @@ -1,3 +1,3 @@ Prerelease: beta -Build Date: 21 June 2023 -Build Number: 6W64 +Build Date: 22 June 2023 +Build Number: 6W65 diff --git a/inform7/Internal/Extensions/Graham Nelson/Basic Inform.i7x b/inform7/Internal/Extensions/Graham Nelson/Basic Inform.i7x index abe581e99..6919d0f6b 100644 --- a/inform7/Internal/Extensions/Graham Nelson/Basic Inform.i7x +++ b/inform7/Internal/Extensions/Graham Nelson/Basic Inform.i7x @@ -734,6 +734,7 @@ Section 1 - Enumerations To decide which number is number of (S - description of values) (documented at ph_numberof): (- {-primitive-definition:number-of} -). +To decide what number is the numerical value of (V - enumerated value): (- {V} -). To decide which K is (name of kind of enumerated value K) after (X - K) (documented at ph_enumafter): (- {-next-routine:K}({X}) -). diff --git a/inform7/Internal/Inter/Architecture16Kit/kit_metadata.json b/inform7/Internal/Inter/Architecture16Kit/kit_metadata.json index c88d31911..209ddb5d7 100644 --- a/inform7/Internal/Inter/Architecture16Kit/kit_metadata.json +++ b/inform7/Internal/Inter/Architecture16Kit/kit_metadata.json @@ -2,7 +2,7 @@ "is": { "type": "kit", "title": "Architecture16Kit", - "version": "10.2.0-beta+6W64" + "version": "10.2.0-beta+6W65" }, "compatibility": "16-bit", "kit-details": { diff --git a/inform7/Internal/Inter/Architecture32Kit/kit_metadata.json b/inform7/Internal/Inter/Architecture32Kit/kit_metadata.json index 8eb0408f4..30eb0df06 100644 --- a/inform7/Internal/Inter/Architecture32Kit/kit_metadata.json +++ b/inform7/Internal/Inter/Architecture32Kit/kit_metadata.json @@ -2,7 +2,7 @@ "is": { "type": "kit", "title": "Architecture32Kit", - "version": "10.2.0-beta+6W64" + "version": "10.2.0-beta+6W65" }, "compatibility": "32-bit", "kit-details": { diff --git a/inform7/Internal/Inter/BasicInformKit/kit_metadata.json b/inform7/Internal/Inter/BasicInformKit/kit_metadata.json index f9f8918fe..2b91989a3 100644 --- a/inform7/Internal/Inter/BasicInformKit/kit_metadata.json +++ b/inform7/Internal/Inter/BasicInformKit/kit_metadata.json @@ -2,7 +2,7 @@ "is": { "type": "kit", "title": "BasicInformKit", - "version": "10.2.0-beta+6W64" + "version": "10.2.0-beta+6W65" }, "needs": [ { "need": { diff --git a/inform7/Internal/Inter/CommandParserKit/kit_metadata.json b/inform7/Internal/Inter/CommandParserKit/kit_metadata.json index 97c55f8c9..5de228116 100644 --- a/inform7/Internal/Inter/CommandParserKit/kit_metadata.json +++ b/inform7/Internal/Inter/CommandParserKit/kit_metadata.json @@ -2,7 +2,7 @@ "is": { "type": "kit", "title": "CommandParserKit", - "version": "10.2.0-beta+6W64" + "version": "10.2.0-beta+6W65" }, "needs": [ { "need": { diff --git a/inform7/Internal/Inter/EnglishLanguageKit/kit_metadata.json b/inform7/Internal/Inter/EnglishLanguageKit/kit_metadata.json index e97bb2c7e..c1147007a 100644 --- a/inform7/Internal/Inter/EnglishLanguageKit/kit_metadata.json +++ b/inform7/Internal/Inter/EnglishLanguageKit/kit_metadata.json @@ -2,7 +2,7 @@ "is": { "type": "kit", "title": "EnglishLanguageKit", - "version": "10.2.0-beta+6W64" + "version": "10.2.0-beta+6W65" }, "needs": [ { "need": { diff --git a/inform7/Internal/Inter/WorldModelKit/kit_metadata.json b/inform7/Internal/Inter/WorldModelKit/kit_metadata.json index 3731ec4d8..3d8277150 100644 --- a/inform7/Internal/Inter/WorldModelKit/kit_metadata.json +++ b/inform7/Internal/Inter/WorldModelKit/kit_metadata.json @@ -2,7 +2,7 @@ "is": { "type": "kit", "title": "WorldModelKit", - "version": "10.2.0-beta+6W64" + "version": "10.2.0-beta+6W65" }, "needs": [ { "need": { diff --git a/inform7/extensions/basic_inform/Sections/Phrase Definitions.w b/inform7/extensions/basic_inform/Sections/Phrase Definitions.w index d663d790e..03885c4f8 100644 --- a/inform7/extensions/basic_inform/Sections/Phrase Definitions.w +++ b/inform7/extensions/basic_inform/Sections/Phrase Definitions.w @@ -915,6 +915,7 @@ Section 1 - Enumerations To decide which number is number of (S - description of values) (documented at ph_numberof): (- {-primitive-definition:number-of} -). +To decide what number is the numerical value of (V - enumerated value): (- {V} -). To decide which K is (name of kind of enumerated value K) after (X - K) (documented at ph_enumafter): (- {-next-routine:K}({X}) -). diff --git a/inform7/knowledge-module/Chapter 2/Instances.w b/inform7/knowledge-module/Chapter 2/Instances.w index 159cb3a7d..522e84c70 100644 --- a/inform7/knowledge-module/Chapter 2/Instances.w +++ b/inform7/knowledge-module/Chapter 2/Instances.w @@ -350,14 +350,18 @@ void Instances::make_instances_from_Neptune(void) { LOOP_OVER(kc, kind_constructor) { linked_list *L = KindConstructors::instances(kc); kind_constructor_instance *kci; + inter_ti current_val = 1; LOOP_OVER_LINKED_LIST(kci, kind_constructor_instance, L) { wording W = Feeds::feed_text(kci->natural_language_name); kind *K = Kinds::base_construction(kc); pcalc_prop *prop = Propositions::Abstract::to_create_something(K, W); Assert::true(prop, CERTAIN_CE); instance *I = Instances::latest(); - RTKindConstructors::set_explicit_runtime_instance_value(K, I, (inter_ti) kci->value); + if (kci->value_specified) current_val = (inter_ti) kci->value; + RTKindConstructors::set_explicit_runtime_instance_value(K, I, current_val); RTInstances::set_translation(I, kci->identifier); + // LOG("From kit: %W = %S = %d -> $O\n", W, kci->identifier, current_val, I); + current_val++; } } } diff --git a/services/kinds-module/Chapter 4/Kind Commands.w b/services/kinds-module/Chapter 4/Kind Commands.w index ccf9af600..70938d900 100644 --- a/services/kinds-module/Chapter 4/Kind Commands.w +++ b/services/kinds-module/Chapter 4/Kind Commands.w @@ -101,11 +101,19 @@ void KindCommands::apply(single_kind_command stc, kind_constructor *con) { } if (tcc == instance_KCC) { match_results mr = Regexp::create_mr(); - if (Regexp::match(&mr, stc.textual_argument, L" *(%c+?) *= *(%c+?) *= *(%d+) *")) { + if (Regexp::match(&mr, stc.textual_argument, L" *(%c+?) *= *(%C+) *= *(%d+) *")) { kind_constructor_instance *kci = CREATE(kind_constructor_instance); kci->natural_language_name = Str::duplicate(mr.exp[0]); kci->identifier = Str::duplicate(mr.exp[1]); kci->value = Str::atoi(mr.exp[2], 0); + kci->value_specified = TRUE; + ADD_TO_LINKED_LIST(kci, kind_constructor_instance, con->instances); + } else if (Regexp::match(&mr, stc.textual_argument, L" *(%c+?) *= *(%C+) *")) { + kind_constructor_instance *kci = CREATE(kind_constructor_instance); + kci->natural_language_name = Str::duplicate(mr.exp[0]); + kci->identifier = Str::duplicate(mr.exp[1]); + kci->value = 0; + kci->value_specified = FALSE; ADD_TO_LINKED_LIST(kci, kind_constructor_instance, con->instances); } else { NeptuneFiles::error(stc.textual_argument, diff --git a/services/kinds-module/Chapter 4/Kind Constructors.w b/services/kinds-module/Chapter 4/Kind Constructors.w index 41e9df955..14e5cc5e8 100644 --- a/services/kinds-module/Chapter 4/Kind Constructors.w +++ b/services/kinds-module/Chapter 4/Kind Constructors.w @@ -135,6 +135,7 @@ typedef struct kind_constructor_instance { struct text_stream *natural_language_name; struct text_stream *identifier; int value; + int value_specified; } kind_constructor_instance; @ The "tupling" of an argument is the extent to which an argument can be