diff --git a/docs/index-module/2-fi.html b/docs/index-module/2-fi.html index 6586777dd..3ffb4f2f3 100644 --- a/docs/index-module/2-fi.html +++ b/docs/index-module/2-fi.html @@ -405,52 +405,46 @@ and only if needed.
void FauxInstances::decode_hints(faux_instance_set *faux_set, inter_tree *I, int pass) { inter_package *pack = Inter::Packages::by_url(I, I"/main/completion/mapping_hints"); - inter_symbol *wanted = PackageTypes::get(I, I"_mapping_hint"); - inter_tree_node *D = Inter::Packages::definition(pack); - LOOP_THROUGH_INTER_CHILDREN(C, D) { - if (C->W.data[ID_IFLD] == PACKAGE_IST) { - inter_package *entry = Inter::Package::defined_by_frame(C); - if (Inter::Packages::type(entry) == wanted) { - faux_instance *from = FauxInstances::xref(faux_set, entry, I"^from"); - faux_instance *to = FauxInstances::xref(faux_set, entry, I"^to"); - faux_instance *dir = FauxInstances::xref(faux_set, entry, I"^dir"); - faux_instance *as_dir = FauxInstances::xref(faux_set, entry, I"^as_dir"); - if ((dir) && (as_dir)) { - if (pass == 1) Decode a hint mapping one direction as if another10.1; - continue; - } - if ((from) && (dir)) { - if (pass == 1) Decode a hint mapping one room in a specific direction from another10.2; - continue; - } - text_stream *name = Metadata::read_optional_textual(entry, I"^name"); - if (Str::len(name) > 0) { - int scope_level = (int) Metadata::read_optional_numeric(entry, I"^scope_level"); - faux_instance *scope_I = FauxInstances::xref(faux_set, entry, I"^scope_instance"); - text_stream *text_val = Metadata::read_optional_textual(entry, I"^text"); - int int_val = (int) Metadata::read_optional_numeric(entry, I"^number"); - if (scope_level != 1000000) { - if (pass == 2) Decode a hint setting EPS map parameters relating to levels10.4; - } else { - if (pass == 1) Decode a hint setting EPS map parameters10.3; - } - continue; - } - text_stream *annotation = Metadata::read_optional_textual(entry, I"^annotation"); - if (Str::len(annotation) > 0) { - if (pass == 1) { - rubric_holder *rh = CREATE(rubric_holder); - rh->annotation = annotation; - rh->point_size = (int) Metadata::read_optional_numeric(entry, I"^point_size"); - rh->font = Metadata::read_optional_textual(entry, I"^font"); - rh->colour = Metadata::read_optional_textual(entry, I"^colour"); - rh->at_offset = (int) Metadata::read_optional_numeric(entry, I"^offset"); - rh->offset_from = FauxInstances::xref(faux_set, entry, I"^offset_from"); - ADD_TO_LINKED_LIST(rh, rubric_holder, faux_set->rubrics); - } - continue; - } + inter_package *hint_pack; + LOOP_THROUGH_SUBPACKAGES(hint_pack, pack, I"_mapping_hint") { + faux_instance *from = FauxInstances::xref(faux_set, hint_pack, I"^from"); + faux_instance *to = FauxInstances::xref(faux_set, hint_pack, I"^to"); + faux_instance *dir = FauxInstances::xref(faux_set, hint_pack, I"^dir"); + faux_instance *as_dir = FauxInstances::xref(faux_set, hint_pack, I"^as_dir"); + if ((dir) && (as_dir)) { + if (pass == 1) Decode a hint mapping one direction as if another10.1; + continue; + } + if ((from) && (dir)) { + if (pass == 1) Decode a hint mapping one room in a specific direction from another10.2; + continue; + } + text_stream *name = Metadata::read_optional_textual(hint_pack, I"^name"); + if (Str::len(name) > 0) { + int scope_level = (int) Metadata::read_optional_numeric(hint_pack, I"^scope_level"); + faux_instance *scope_I = FauxInstances::xref(faux_set, hint_pack, I"^scope_instance"); + text_stream *text_val = Metadata::read_optional_textual(hint_pack, I"^text"); + int int_val = (int) Metadata::read_optional_numeric(hint_pack, I"^number"); + if (scope_level != 1000000) { + if (pass == 2) Decode a hint setting EPS map parameters relating to levels10.4; + } else { + if (pass == 1) Decode a hint setting EPS map parameters10.3; } + continue; + } + text_stream *annotation = Metadata::read_optional_textual(hint_pack, I"^annotation"); + if (Str::len(annotation) > 0) { + if (pass == 1) { + rubric_holder *rh = CREATE(rubric_holder); + rh->annotation = annotation; + rh->point_size = (int) Metadata::read_optional_numeric(hint_pack, I"^point_size"); + rh->font = Metadata::read_optional_textual(hint_pack, I"^font"); + rh->colour = Metadata::read_optional_textual(hint_pack, I"^colour"); + rh->at_offset = (int) Metadata::read_optional_numeric(hint_pack, I"^offset"); + rh->offset_from = FauxInstances::xref(faux_set, hint_pack, I"^offset_from"); + ADD_TO_LINKED_LIST(rh, rubric_holder, faux_set->rubrics); + } + continue; } } } diff --git a/docs/index-module/2-ir.html b/docs/index-module/2-ir.html index 90ad3d217..8e12ddf45 100644 --- a/docs/index-module/2-ir.html +++ b/docs/index-module/2-ir.html @@ -159,17 +159,11 @@ with ^action an if (rule_pack == NULL) return FALSE; if (rc.action_context) { int passes = FALSE; - inter_symbol *wanted = PackageTypes::get(I, I"_relevant_action"); - inter_tree_node *D = Inter::Packages::definition(rule_pack); - LOOP_THROUGH_INTER_CHILDREN(C, D) { - if (C->W.data[ID_IFLD] == PACKAGE_IST) { - inter_package *rel_pack = Inter::Package::defined_by_frame(C); - if (Inter::Packages::type(rel_pack) == wanted) { - inter_symbol *act_ds = Metadata::read_symbol(rel_pack, I"^action"); - if (Inter::Packages::container(act_ds->definition) == rc.action_context) - passes = TRUE; - } - } + inter_package *rel_pack; + LOOP_THROUGH_SUBPACKAGES(rel_pack, rule_pack, I"_relevant_action") { + inter_symbol *act_ds = Metadata::read_symbol(rel_pack, I"^action"); + if (Inter::Packages::container(act_ds->definition) == rc.action_context) + passes = TRUE; } if (passes == FALSE) return FALSE; } @@ -189,16 +183,10 @@ no rules which fit rc<-int IndexRules::is_contextually_empty(inter_tree *I, inter_package *rb_pack, rule_context rc) { if (rb_pack) { - inter_symbol *wanted = PackageTypes::get(I, I"_rulebook_entry"); - inter_tree_node *D = Inter::Packages::definition(rb_pack); - LOOP_THROUGH_INTER_CHILDREN(C, D) { - if (C->W.data[ID_IFLD] == PACKAGE_IST) { - inter_package *entry = Inter::Package::defined_by_frame(C); - if (Inter::Packages::type(entry) == wanted) - if (IndexRules::phrase_fits_rule_context(I, entry, rc)) - return FALSE; - } - } + inter_package *entry; + LOOP_THROUGH_SUBPACKAGES(entry, rb_pack, I"_rulebook_entry") + if (IndexRules::phrase_fits_rule_context(I, entry, rc)) + return FALSE; } return TRUE; } @@ -208,24 +196,12 @@ no rules which fit rc<@@ -547,8 +501,7 @@ of adjacent rules in a listing:int IndexRules::is_empty(inter_tree *I, inter_package *rb_pack) { - if ((rb_pack) && (IndexRules::no_rules(I, rb_pack) > 0)) return FALSE; + if ((rb_pack) && (IndexRules::no_rules(rb_pack) > 0)) return FALSE; return TRUE; } -int IndexRules::no_rules(inter_tree *I, inter_package *rb_pack) { - int N = 0; - if (rb_pack) { - inter_symbol *wanted = PackageTypes::get(I, I"_rulebook_entry"); - inter_tree_node *D = Inter::Packages::definition(rb_pack); - LOOP_THROUGH_INTER_CHILDREN(C, D) { - if (C->W.data[ID_IFLD] == PACKAGE_IST) { - inter_package *entry = Inter::Package::defined_by_frame(C); - if (Inter::Packages::type(entry) == wanted) - N++; - } - } - } - return N; +int IndexRules::no_rules(inter_package *rb_pack) { + return InterTree::no_subpackages(rb_pack, I"_rulebook_entry"); }§8. Links between rules in rulebook listings. A notation is used to show how rulebook sorting affected the placement of @@ -252,7 +228,7 @@ switched off:
int RS_unique_xtra_no = 77777; -int IndexRules::extra_ID(void) { +int IndexRules::extra_ID(void) { return RS_unique_xtra_no++; }@@ -272,21 +248,21 @@ switched off: string_position start = Str::start(textual_name); Str::put(start, Characters::tolower(Str::get(start))); - int n = IndexRules::no_rules(inv->of_tree, rb_pack); + int n = IndexRules::no_rules(rb_pack); if (place_in_expandable_box) { int expand_id = IndexRules::extra_ID(); HTML::open_indented_p(OUT, indent+1, "tight"); - IndexUtilities::extra_link(OUT, expand_id); + IndexUtilities::extra_link(OUT, expand_id); if (n == 0) HTML::begin_colour(OUT, I"808080"); WRITE("%S", textual_name); Add links and such to the titling10.2; WRITE(" (%d rule%s)", n, (n==1)?"":"s"); if (n == 0) HTML::end_colour(OUT); HTML_CLOSE("p"); - IndexUtilities::extra_div_open(OUT, expand_id, indent+1, RULEBOOK_BOX_COLOUR); + IndexUtilities::extra_div_open(OUT, expand_id, indent+1, RULEBOOK_BOX_COLOUR); Index the contents of the rulebook box10.1; - IndexUtilities::extra_div_close(OUT, RULEBOOK_BOX_COLOUR); + IndexUtilities::extra_div_close(OUT, RULEBOOK_BOX_COLOUR); } else { HTML::open_indented_p(OUT, indent, ""); HTML::open_coloured_box(OUT, RULEBOOK_BOX_COLOUR, ROUND_BOX_TOP+ROUND_BOX_BOTTOM); @@ -332,8 +308,7 @@ switched off:if (Str::len(doc_link) > 0) IndexUtilities::DocReferences::link(OUT, doc_link); WRITE(" ... %S", Metadata::read_optional_textual(rb_pack, I"^focus")); - int at = (int) Metadata::read_optional_numeric(rb_pack, I"^at"); - if (at > 0) IndexUtilities::link(OUT, at); + IndexUtilities::link_package(OUT, rb_pack);§11. Two ways to list a rulebook. Firstly, the whole contents: @@ -380,24 +355,18 @@ switched off: if (IndexRules::is_contextually_empty(I, rb_pack, rc)) suppress_outcome = TRUE; } inter_package *prev = NULL; - inter_symbol *wanted = PackageTypes::get(I, I"_rulebook_entry"); - inter_tree_node *D = Inter::Packages::definition(rb_pack); - LOOP_THROUGH_INTER_CHILDREN(C, D) { - if (C->W.data[ID_IFLD] == PACKAGE_IST) { - inter_package *entry = Inter::Package::defined_by_frame(C); - if (Inter::Packages::type(entry) == wanted) { - if (IndexRules::phrase_fits_rule_context(I, entry, rc)) { - if (count++ == 0) HTML::open_indented_p(OUT, 2, "indent"); - else WRITE("<br>"); - if ((Str::len(billing) > 0) && (IndexRules::showing_links())) - Show a linkage icon13.1; - WRITE("%S", billing); - WRITE(" "); - *resp_count += IndexRules::index_rule(OUT, I, entry, rb_pack, rc, LD); - } - prev = entry; - } + inter_package *entry; + LOOP_THROUGH_SUBPACKAGES(entry, rb_pack, I"_rulebook_entry") { + if (IndexRules::phrase_fits_rule_context(I, entry, rc)) { + if (count++ == 0) HTML::open_indented_p(OUT, 2, "indent"); + else WRITE("<br>"); + if ((Str::len(billing) > 0) && (IndexRules::showing_links())) + Show a linkage icon13.1; + WRITE("%S", billing); + WRITE(" "); + *resp_count += IndexRules::index_rule(OUT, I, entry, rb_pack, rc, LD); } + prev = entry; } if (count > 0) HTML_CLOSE("p"); if (suppress_outcome == FALSE) IndexRules::index_outcomes(OUT, I, rb_pack, LD); @@ -493,19 +462,10 @@ of adjacent rules in a listing: inter_symbol *R_symbol = Metadata::read_optional_symbol(R, I"^rule"); if (R_symbol) { - int c = 0; - inter_symbol *wanted = PackageTypes::get(I, I"_response"); - inter_tree_node *D = Inter::Packages::definition(R); - LOOP_THROUGH_INTER_CHILDREN(C, D) { - if (C->W.data[ID_IFLD] == PACKAGE_IST) { - inter_package *entry = Inter::Package::defined_by_frame(C); - if (Inter::Packages::type(entry) == wanted) - c++; - } - } + int c = InterTree::no_subpackages(R, I"_response"); if (c > 0) { WRITE(" "); - IndexUtilities::extra_link_with(OUT, response_box_id, "responses"); + IndexUtilities::extra_link_with(OUT, response_box_id, "responses"); WRITE("%d", c); } } @@ -518,20 +478,14 @@ of adjacent rules in a listing: inter_symbol *R_symbol = Metadata::read_optional_symbol(R, I"^rule"); if (R_symbol) { int c = 0; - inter_symbol *wanted = PackageTypes::get(I, I"_response"); - inter_tree_node *D = Inter::Packages::definition(R); - LOOP_THROUGH_INTER_CHILDREN(C, D) { - if (C->W.data[ID_IFLD] == PACKAGE_IST) { - inter_package *entry = Inter::Package::defined_by_frame(C); - if (Inter::Packages::type(entry) == wanted) { - if (c == 0) IndexUtilities::extra_div_open_nested(OUT, response_box_id, 2); - else HTML_TAG("br"); - IndexRules::index_response(OUT, R, entry, LD); - c++; - } - } + inter_package *resp_pack; + LOOP_THROUGH_SUBPACKAGES(resp_pack, R, I"_response") { + if (c == 0) IndexUtilities::extra_div_open_nested(OUT, response_box_id, 2); + else HTML_TAG("br"); + IndexRules::index_response(OUT, R, resp_pack, LD); + c++; } - if (c > 0) IndexUtilities::extra_div_close_nested(OUT); + if (c > 0) IndexUtilities::extra_div_close_nested(OUT); no_responses_indexed = c; }
- int at = (int) Metadata::read_optional_numeric(R, I"^at"); - if (at > 0) IndexUtilities::link(OUT, at); + IndexUtilities::link_package(OUT, R);
- This code is used in §14.
§14.6. Index the small type rule numbering14.6 = @@ -570,18 +523,11 @@ of adjacent rules in a listing:
inter_symbol *R_symbol = Metadata::read_optional_symbol(R, I"^rule"); if (R_symbol) { - inter_symbol *wanted = PackageTypes::get(I, I"_applicability_condition"); - inter_tree_node *D = Inter::Packages::definition(R); - LOOP_THROUGH_INTER_CHILDREN(C, D) { - if (C->W.data[ID_IFLD] == PACKAGE_IST) { - inter_package *entry = Inter::Package::defined_by_frame(C); - if (Inter::Packages::type(entry) == wanted) { - HTML_TAG("br"); - int at = (int) Metadata::read_optional_numeric(entry, I"^at"); - if (at > 0) IndexUtilities::link(OUT, at); - WRITE(" %S", Metadata::read_textual(entry, I"^index_text")); - } - } + inter_package *ac_pack; + LOOP_THROUGH_SUBPACKAGES(ac_pack, R, I"_applicability_condition") { + HTML_TAG("br"); + IndexUtilities::link_package(OUT, ac_pack); + WRITE(" %S", Metadata::read_textual(ac_pack, I"^index_text")); } }@@ -627,31 +573,25 @@ text to assert a change:void IndexRules::index_outcomes(OUTPUT_STREAM, inter_tree *I, inter_package *rb_pack, localisation_dictionary *LD) { - inter_symbol *wanted = PackageTypes::get(I, I"_rulebook_outcome"); - inter_tree_node *D = Inter::Packages::definition(rb_pack); - LOOP_THROUGH_INTER_CHILDREN(C, D) { - if (C->W.data[ID_IFLD] == PACKAGE_IST) { - inter_package *entry = Inter::Package::defined_by_frame(C); - if (Inter::Packages::type(entry) == wanted) { - HTML::open_indented_p(OUT, 2, "hanging"); - WRITE("<i>"); - Localisation::write_0(OUT, LD, I"Index.Elements.RS.Outcome"); - WRITE("</i> "); - int is_def = (int) Metadata::read_optional_numeric(entry, I"^is_default"); - if (is_def) WRITE("<b>"); - WRITE("%S", Metadata::read_optional_textual(entry, I"^text")); - if (is_def) WRITE("</b> (default)"); - WRITE(" - <i>"); - if (Metadata::read_optional_numeric(entry, I"^succeeds")) - Localisation::write_0(OUT, LD, I"Index.Elements.RS.Success"); - else if (Metadata::read_optional_numeric(entry, I"^fails")) - Localisation::write_0(OUT, LD, I"Index.Elements.RS.Failure"); - else - Localisation::write_0(OUT, LD, I"Index.Elements.RS.NoOutcome"); - WRITE("</i>"); - HTML_CLOSE("p"); - } - } + inter_package *ro_pack; + LOOP_THROUGH_SUBPACKAGES(ro_pack, rb_pack, I"_rulebook_outcome") { + HTML::open_indented_p(OUT, 2, "hanging"); + WRITE("<i>"); + Localisation::write_0(OUT, LD, I"Index.Elements.RS.Outcome"); + WRITE("</i> "); + int is_def = (int) Metadata::read_optional_numeric(ro_pack, I"^is_default"); + if (is_def) WRITE("<b>"); + WRITE("%S", Metadata::read_optional_textual(ro_pack, I"^text")); + if (is_def) WRITE("</b> (default)"); + WRITE(" - <i>"); + if (Metadata::read_optional_numeric(ro_pack, I"^succeeds")) + Localisation::write_0(OUT, LD, I"Index.Elements.RS.Success"); + else if (Metadata::read_optional_numeric(ro_pack, I"^fails")) + Localisation::write_0(OUT, LD, I"Index.Elements.RS.Failure"); + else + Localisation::write_0(OUT, LD, I"Index.Elements.RS.NoOutcome"); + WRITE("</i>"); + HTML_CLOSE("p"); } if (Metadata::read_optional_numeric(rb_pack, I"^default_succeeds")) { @@ -672,21 +612,14 @@ text to assert a change: void IndexRules::rb_index_placements(OUTPUT_STREAM, inter_tree *I, inter_package *rb_pack, localisation_dictionary *LD) { - inter_symbol *wanted = PackageTypes::get(I, I"_rulebook_placement"); - inter_tree_node *D = Inter::Packages::definition(rb_pack); - LOOP_THROUGH_INTER_CHILDREN(C, D) { - if (C->W.data[ID_IFLD] == PACKAGE_IST) { - inter_package *entry = Inter::Package::defined_by_frame(C); - if (Inter::Packages::type(entry) == wanted) { - WRITE(" "); - HTML_OPEN_WITH("span", "class=\"smaller\""); - WRITE("<i>NB:</i> %S", Metadata::read_optional_textual(entry, I"^text")); - int at = (int) Metadata::read_optional_numeric(entry, I"^at"); - if (at > 0) IndexUtilities::link(OUT, at); - HTML_CLOSE("span"); - HTML_TAG("br"); - } - } + inter_package *rp_pack; + LOOP_THROUGH_SUBPACKAGES(rp_pack, rb_pack, I"_rulebook_placement") { + WRITE(" "); + HTML_OPEN_WITH("span", "class=\"smaller\""); + WRITE("<i>NB:</i> %S", Metadata::read_optional_textual(rp_pack, I"^text")); + IndexUtilities::link_package(OUT, rp_pack); + HTML_CLOSE("span"); + HTML_TAG("br"); } }@@ -699,7 +632,6 @@ of an activity are part of a single construct:void IndexRules::activity_box(OUTPUT_STREAM, inter_tree *I, inter_package *av_pack, int indent, localisation_dictionary *LD) { - text_stream *doc_link = Metadata::read_optional_textual(av_pack, I"^documentation"); int expand_id = IndexRules::extra_ID(); inter_symbol *before_s = Metadata::read_symbol(av_pack, I"^before_rulebook"); @@ -709,9 +641,9 @@ of an activity are part of a single construct: inter_package *for_pack = Inter::Packages::container(for_s->definition); inter_package *after_pack = Inter::Packages::container(after_s->definition); - int n = IndexRules::no_rules(I, before_pack) + - IndexRules::no_rules(I, for_pack) + - IndexRules::no_rules(I, after_pack); + int n = IndexRules::no_rules(before_pack) + + IndexRules::no_rules(for_pack) + + IndexRules::no_rules(after_pack); TEMPORARY_TEXT(textual_name) text_stream *name = Metadata::read_optional_textual(av_pack, I"^name"); @@ -721,7 +653,7 @@ of an activity are part of a single construct: Str::put(start, Characters::tolower(Str::get(start))); HTML::open_indented_p(OUT, indent+1, "tight"); - IndexUtilities::extra_link(OUT, expand_id); + IndexUtilities::extra_link(OUT, expand_id); if (n == 0) HTML::begin_colour(OUT, I"808080"); WRITE("%S", textual_name); Write the titling line of an activity rules box17.1; @@ -729,7 +661,7 @@ of an activity are part of a single construct: if (n == 0) HTML::end_colour(OUT); HTML_CLOSE("p"); - IndexUtilities::extra_div_open(OUT, expand_id, indent+1, ACTIVITY_BOX_COLOUR); + IndexUtilities::extra_div_open(OUT, expand_id, indent+1, ACTIVITY_BOX_COLOUR); HTML::begin_html_table(OUT, NULL, TRUE, 0, 4, 0, 0, 0); HTML::first_html_column(OUT, 0); @@ -767,33 +699,25 @@ of an activity are part of a single construct: IndexRules::rulebook_list(OUT, I, for_pack, I"for", IndexRules::no_rule_context(), LD); IndexRules::rulebook_list(OUT, I, after_pack, I"after", IndexRules::no_rule_context(), LD); - inter_symbol *wanted = PackageTypes::get(I, I"_activity_xref"); - inter_tree_node *D = Inter::Packages::definition(av_pack); - LOOP_THROUGH_INTER_CHILDREN(C, D) { - if (C->W.data[ID_IFLD] == PACKAGE_IST) { - inter_package *entry = Inter::Package::defined_by_frame(C); - if (Inter::Packages::type(entry) == wanted) { - HTML::open_indented_p(OUT, 2, "tight"); - WRITE("NB: %S", Metadata::read_optional_textual(entry, I"^text")); - int at = (int) Metadata::read_optional_numeric(entry, I"^at"); - if (at > 0) IndexUtilities::link(OUT, at); - HTML_CLOSE("p"); - } - } + inter_package *xref_pack; + LOOP_THROUGH_SUBPACKAGES(xref_pack, av_pack, I"_activity_xref") { + HTML::open_indented_p(OUT, 2, "tight"); + WRITE("NB: %S", Metadata::read_optional_textual(xref_pack, I"^text")); + IndexUtilities::link_package(OUT, xref_pack); + HTML_CLOSE("p"); } - IndexUtilities::extra_div_close(OUT, ACTIVITY_BOX_COLOUR); + IndexUtilities::extra_div_close(OUT, ACTIVITY_BOX_COLOUR); }§17.1. Write the titling line of an activity rules box17.1 =
- if (Str::len(doc_link) > 0) IndexUtilities::DocReferences::link(OUT, doc_link); + IndexUtilities::link_to_documentation(OUT, av_pack); WRITE(" ... "); Localisation::write_0(OUT, LD, I"Index.Elements.RS.Activity"); - int at = (int) Metadata::read_optional_numeric(av_pack, I"^at"); - if (at > 0) IndexUtilities::link(OUT, at); + IndexUtilities::link_package(OUT, av_pack);
- This code is used in §17 (twice).
§9. The "definition area" for content is usually a heading inside an extension; +
§10. The "definition area" for content is usually a heading inside an extension; see the Phrasebook element for examples of how this comes out.
-void IndexUtilities::show_definition_area(OUTPUT_STREAM, inter_package *heading_pack, +void IndexUtilities::show_definition_area(OUTPUT_STREAM, inter_package *heading_pack, int show_if_unhyphenated) { inter_ti parts = Metadata::read_optional_numeric(heading_pack, I"^parts"); if ((parts == 1) && (show_if_unhyphenated == FALSE)) return; @@ -319,6 +335,18 @@ see the Phrasebook element for examples of how this comes out. HTML_TAG("br"); }+
§11. Here pack is the Inter package for a kind constructor. +
+ ++void IndexUtilities::kind_name(OUTPUT_STREAM, inter_package *pack, int plural, + int with_links) { + if (pack == NULL) return; + text_stream *key = (plural)?I"^index_plural":I"^index_singular"; + WRITE("%S", Metadata::read_optional_textual(pack, key)); + if (with_links) IndexUtilities::link_package(OUT, pack); +} +diff --git a/docs/index-module/2-lcl.html b/docs/index-module/2-lcl.html index 44a5c9ad9..ad71ecf8b 100644 --- a/docs/index-module/2-lcl.html +++ b/docs/index-module/2-lcl.html @@ -288,8 +288,11 @@ with everything under the first line being italicised. For example: How this project might be filed in a library catalogue.|About the Library Card<LCARDS>; About IFIDs<IFIDS> +
Note that a valid documentation reference must begin with an upper-case letter. +
+-void Localisation::write_0(OUTPUT_STREAM, localisation_dictionary *D, text_stream *key) { +void Localisation::write_0(OUTPUT_STREAM, localisation_dictionary *D, text_stream *key) { text_stream *vals[10]; Vacate the vals5.1; Localisation::write_general(OUT, D, key, vals); @@ -346,7 +349,9 @@ with everything under the first line being italicised. For example: i++; while ((i<Str::len(prototype)) && (Str::get_at(prototype, i) != '>')) PUT_TO(link, Str::get_at(prototype, i++)); - IndexUtilities::DocReferences::link(OUT, link); + if (Characters::isupper(Str::get_at(link, 0))) + IndexUtilities::DocReferences::link(OUT, link); + else WRITE("<%S>", link); DISCARD_TEXT(link) break; } diff --git a/docs/index-module/2-lxc.html b/docs/index-module/2-lxc.html index 831bc9532..b016e460d 100644 --- a/docs/index-module/2-lxc.html +++ b/docs/index-module/2-lxc.html @@ -406,15 +406,12 @@ source text: so any single link would be potentially misleading.switch(lex->part_of_speech) { - case COMMON_NOUN_TLEXE: { - text_stream *ref = - Metadata::read_optional_textual(lex->lex_package, I"^documentation"); - if (Str::len(ref) > 0) IndexUtilities::DocReferences::link(OUT, ref); + case COMMON_NOUN_TLEXE: + IndexUtilities::link_to_documentation(OUT, lex->lex_package); break; - } case VERB_TLEXE: case PREP_TLEXE: - IndexUtilities::below_link_numbered(OUT, 10000+verb_count++); + IndexUtilities::below_link_numbered(OUT, 10000+verb_count++); break; } if ((lex->part_of_speech != ADJECTIVAL_PHRASE_TLEXE) && (lex->link_to > 0)) diff --git a/docs/index-module/3-ae.html b/docs/index-module/3-ae.html index b53f594e0..8df092921 100644 --- a/docs/index-module/3-ae.html +++ b/docs/index-module/3-ae.html @@ -118,7 +118,7 @@ function togglePopup(material_id) { if (oow) HTML::begin_colour(OUT, I"800000"); WRITE("%S", Metadata::read_optional_textual(an_pack, I"^name")); if (oow) HTML::end_colour(OUT); - IndexUtilities::detail_link(OUT, "A", i, TRUE); + IndexUtilities::detail_link(OUT, "A", i, TRUE); if (requires_light) AlphabeticElement::note(OUT, I"Light", LD);
To write the Chart element (Ch) in the index.
-§1. This is a table of kinds of value, followed by a set of descriptions of each, +and it is quite dense with information. +
-void ChartElement::render(OUTPUT_STREAM, localisation_dictionary *LD) { +void ChartElement::render(OUTPUT_STREAM, localisation_dictionary *D) { inter_tree *I = InterpretIndex::get_tree(); tree_inventory *inv = Synoptic::inv(I); TreeLists::sort(inv->kind_nodes, Synoptic::module_order); TreeLists::sort(inv->instance_nodes, Synoptic::module_order); - ChartElement::index_kinds(OUT, inv, 1); - ChartElement::index_kinds(OUT, inv, 2); + HTML::begin_wide_html_table(OUT); + int pass = 1; + Add a dotty row to the chart of kinds1.3; + Add a titling row to the chart of kinds1.2; + Add a dotty row to the chart of kinds1.3; + Add the rubric below the chart of kinds1.4; + Run through the kinds in priority order1.1; + Add a dotty row to the chart of kinds1.3; + HTML::end_html_table(OUT); + pass = 2; + Run through the kinds in priority order1.1; + Explain about covariance and contravariance1.5; }-
§2. Indexing the kinds. The Kinds page of the index opens with a table summarising the hierarchy of -kinds, and then follows with details. This routine is called twice, once -with pass equal to 1, when it has to fill in the hierarchy of kinds listed -under "value" in the key chart at the top of the Kinds index; and then -again lower down, with pass equal to 2, when it gives more detail. -
- -Not all of the built-in kinds are indexed on the Kinds page. The ones +
§1.1. Not all of the built-in kinds are indexed on the Kinds page. The ones omitted are of no help to end users, and would only clutter up the table with misleading entries. Remaining kinds are grouped together in "priority" order, a device to enable the quasinumerical kinds to stick @@ -103,105 +108,73 @@ higher up, but kinds with priority 0 do not appear in the index at all.
define LOWEST_INDEX_PRIORITY 100-
-void ChartElement::index_kinds(OUTPUT_STREAM, tree_inventory *inv, int pass) { - int priority; - if (pass == 1) { - HTML_OPEN("p"); HTML_CLOSE("p"); - HTML::begin_wide_html_table(OUT); - Add a dotty row to the chart of kinds2.4; - Add a titling row to the chart of kinds2.2; - Add a dotty row to the chart of kinds2.4; - Add the rubric below the chart of kinds2.6; - } +Run through the kinds in priority order1.1 = +
- for (priority = 1; priority <= LOWEST_INDEX_PRIORITY; priority++) { ++ for (int priority = 1; priority <= LOWEST_INDEX_PRIORITY; priority++) { for (int i=0; i<TreeLists::len(inv->kind_nodes); i++) { inter_package *pack = Inter::Package::defined_by_frame(inv->kind_nodes->list[i].node); if ((Metadata::read_optional_numeric(pack, I"^is_base")) && (Metadata::read_optional_numeric(pack, I"^is_subkind_of_object") == 0) && (priority == (int) Metadata::read_optional_numeric(pack, I"^index_priority"))) { if ((priority == 8) || (Metadata::read_optional_numeric(pack, I"^is_definite"))) { - switch (pass) { - case 1: Write table row for this kind2.5; break; - case 2: { - Write heading for the detailed index entry for this kind2.7; - HTML::open_indented_p(OUT, 1, "tight"); - Index kinds of kinds matched by this kind2.9; - Index explanatory text supplied for a kind2.11; - Index literal patterns which can specify this kind2.8; - Index possible values of an enumerated kind2.10; - HTML_CLOSE("p"); - break; - } - } - if (Str::eq(Metadata::read_textual(pack, I"^printed_name"), I"object")) - Recurse to index subkinds of object2.1; + Index this kind package1.1.2; } } } if ((priority == 1) || (priority == 6) || (priority == 7)) { if (pass == 1) { - Add a dotty row to the chart of kinds2.4; + Add a dotty row to the chart of kinds1.3; if (priority == 7) { - Add a second titling row to the chart of kinds2.3; - Add a dotty row to the chart of kinds2.4; + Add a second titling row to the chart of kinds1.1.1; + Add a dotty row to the chart of kinds1.3; } } else HTML_TAG("hr"); } } - - if (pass == 1) { - Add a dotty row to the chart of kinds2.4; - HTML::end_html_table(OUT); - } else { - Explain about covariance and contravariance2.12; - } -}-
- ChartElement::index_subkinds(OUT, inv, pack, 2, pass); --
Add a titling row to the chart of kinds2.2 = +
Add a titling row to the chart of kinds1.2 =
HTML::first_html_column_nowrap(OUT, 0, "#e0e0e0"); - WRITE("<b>basic kinds</b>"); - ChartElement::index_kind_col_head(OUT, "default value", "default"); - ChartElement::index_kind_col_head(OUT, "repeat", "repeat"); - ChartElement::index_kind_col_head(OUT, "props", "props"); - ChartElement::index_kind_col_head(OUT, "under", "under"); + WRITE("<b>"); + Localisation::write_0(OUT, D, I"Index.Elements.Ch.BasicKinds"); + WRITE("</b>"); + ChartElement::index_kind_col_head(OUT, I"Index.Elements.Ch.DefaultColumn", "default", D); + ChartElement::index_kind_col_head(OUT, I"Index.Elements.Ch.RepeatColumn", "repeat", D); + ChartElement::index_kind_col_head(OUT, I"Index.Elements.Ch.PropsColumn", "props", D); + ChartElement::index_kind_col_head(OUT, I"Index.Elements.Ch.UnderColumn", "under", D); HTML::end_html_row(OUT);-
Add a second titling row to the chart of kinds2.3 = +
Add a second titling row to the chart of kinds1.1.1 =
HTML::first_html_column_nowrap(OUT, 0, "#e0e0e0"); - WRITE("<b>making new kinds from old</b>"); - ChartElement::index_kind_col_head(OUT, "default value", "default"); - ChartElement::index_kind_col_head(OUT, "", NULL); - ChartElement::index_kind_col_head(OUT, "", NULL); - ChartElement::index_kind_col_head(OUT, "", NULL); + WRITE("<b>"); + Localisation::write_0(OUT, D, I"Index.Elements.Ch.NewKinds"); + WRITE("</b>"); + ChartElement::index_kind_col_head(OUT, I"Index.Elements.Ch.DefaultColumn", "default", D); + ChartElement::index_kind_col_head(OUT, NULL, NULL, D); + ChartElement::index_kind_col_head(OUT, NULL, NULL, D); + ChartElement::index_kind_col_head(OUT, NULL, NULL, D); HTML::end_html_row(OUT);-
Add a dotty row to the chart of kinds2.4 = +
Add a dotty row to the chart of kinds1.3 =
@@ -210,96 +183,90 @@ higher up, but kinds with priority 0 do not appear in the index at all. HTML_CLOSE("td"); HTML_CLOSE("tr");-
§2.5. And then a typical row: -
- -Write table row for this kind2.5 = -
- -- char *repeat = "cross", *props = "cross", *under = "cross"; - int shaded = FALSE; - if (Metadata::read_optional_numeric(pack, I"^shaded_in_index")) shaded = TRUE; - if (Metadata::read_optional_numeric(pack, I"^finite_domain")) repeat = "tick"; - if (Metadata::read_optional_numeric(pack, I"^has_properties")) props = "tick"; - if (Metadata::read_optional_numeric(pack, I"^understandable")) under = "tick"; - if (priority == 8) { repeat = NULL; props = NULL; under = NULL; } - ChartElement::begin_chart_row(OUT); - ChartElement::index_kind_name_cell(OUT, shaded, pack); - ChartElement::end_chart_row(OUT, shaded, pack, repeat, props, under); --
§2.6. Note the named anchors here, which must match those linked from the titling +
+§1.4. Note the named IDs here, which must match those linked from the titling row.
-Add the rubric below the chart of kinds2.6 = +
Add the rubric below the chart of kinds1.4 =
HTML_OPEN_WITH("tr", "style=\"display:none\" id=\"default\""); HTML_OPEN_WITH("td", "colspan=\"5\""); - WRITE("The <b>default value</b> is used when we make something like " - "a variable but don't tell Inform what its value is. For instance, if " - "we write 'Zero hour is a time that varies', but don't tell Inform " - "anything specific like 'Zero hour is 11:21 PM.', then Inform uses " - "the value in the table above to decide what it will be. " - "The same applies if we create a property (for instance, 'A person " - "has a number called lucky number.'). Kinds of value not included " - "in the table cannot be used in variables and properties."); + Localisation::write_0(OUT, D, I"Index.Elements.Ch.DefaultGloss"); HTML_TAG("hr"); HTML_CLOSE("td"); HTML_CLOSE("tr"); HTML_OPEN_WITH("tr", "style=\"display:none\" id=\"repeat\""); HTML_OPEN_WITH("td", "colspan=\"5\""); - WRITE("A tick for <b>repeat</b> means that it's possible to " - "repeat through values of this kind. For instance, 'repeat with T " - "running through times:' is allowed, but 'repeat with N running " - "through numbers:' is not - there are too many numbers for this to " - "make sense. A tick here also means it's possible to form lists such " - "as 'list of rulebooks', or to count the 'number of scenes'."); + Localisation::write_0(OUT, D, I"Index.Elements.Ch.RepeatGloss"); HTML_TAG("hr"); HTML_CLOSE("td"); HTML_CLOSE("tr"); HTML_OPEN_WITH("tr", "style=\"display:none\" id=\"props\""); HTML_OPEN_WITH("td", "colspan=\"5\""); - WRITE("A tick for <b>props</b> means that values of this " - "kind can have properties. For instance, 'A scene can be thrilling or " - "dull.' makes an either/or property of a scene, but 'A number can be " - "nice or nasty.' is not allowed because it would cost too much storage " - "space. (Of course 'Definition:' can always be used to make adjectives " - "applying to numbers; it's only properties which have storage " - "worries.)"); + Localisation::write_0(OUT, D, I"Index.Elements.Ch.PropsGloss"); HTML_TAG("hr"); HTML_CLOSE("td"); HTML_CLOSE("tr"); HTML_OPEN_WITH("tr", "style=\"display:none\" id=\"under\""); HTML_OPEN_WITH("td", "colspan=\"5\""); - WRITE("A tick for <b>under</b> means that it's possible " - "to understand values of this kind. For instance, 'Understand \"award " - "[number]\" as awarding.' might be allowed, if awarding were an action " - "applying to a number, but 'Understand \"run [rule]\" as rule-running.' " - "is not allowed - there are so many rules with such long names that " - "Inform doesn't add them to its vocabulary during play."); + Localisation::write_0(OUT, D, I"Index.Elements.Ch.UnderGloss"); HTML_TAG("hr"); HTML_CLOSE("td"); HTML_CLOSE("tr");-
§2.7. The detailed entry lower down the page begins with: +
§1.1.2. So, the actual content, which is presented as a row of the table in pass 1, +or as paragraph of text in pass 2:
-Write heading for the detailed index entry for this kind2.7 = +
Index this kind package1.1.2 = +
+ ++ switch (pass) { + case 1: { + char *repeat = "cross", *props = "cross", *under = "cross"; + int shaded = FALSE; + if (Metadata::read_optional_numeric(pack, I"^shaded_in_index")) shaded = TRUE; + if (Metadata::read_optional_numeric(pack, I"^finite_domain")) repeat = "tick"; + if (Metadata::read_optional_numeric(pack, I"^has_properties")) props = "tick"; + if (Metadata::read_optional_numeric(pack, I"^understandable")) under = "tick"; + if (priority == 8) { repeat = NULL; props = NULL; under = NULL; } + ChartElement::begin_chart_row(OUT); + ChartElement::index_kind_name_cell(OUT, shaded, pack); + ChartElement::end_chart_row(OUT, shaded, pack, repeat, props, under); + break; + } + case 2: { + Write heading for the detailed index entry for this kind1.1.2.1; + HTML::open_indented_p(OUT, 1, "tight"); + Index kinds of kinds matched by this kind1.1.2.3; + Index explanatory text supplied for a kind1.1.2.5; + Index literal patterns which can specify this kind1.1.2.2; + Index possible values of an enumerated kind1.1.2.4; + HTML_CLOSE("p"); + break; + } + } + if (Str::eq(Metadata::read_textual(pack, I"^printed_name"), I"object")) + ChartElement::index_subkinds(OUT, inv, pack, 2, pass, D); ++
§1.1.2.1. Write heading for the detailed index entry for this kind1.1.2.1 =
HTML::open_indented_p(OUT, 1, "halftight"); - IndexUtilities::anchor_numbered(OUT, i); ...the anchor to which the grey icon in the table led - WRITE("<b>"); ChartElement::index_kind(OUT, pack, FALSE, TRUE); WRITE("</b>"); - WRITE(" (<i>plural</i> "); ChartElement::index_kind(OUT, pack, TRUE, FALSE); WRITE(")"); - text_stream *doc_ref = Metadata::read_optional_textual(pack, I"^documentation"); - if (Str::len(doc_ref) > 0) IndexUtilities::DocReferences::link(OUT, doc_ref); blue help icon, if any + IndexUtilities::anchor_numbered(OUT, i); ...the anchor to which the grey icon in the table led + WRITE("<b>"); IndexUtilities::kind_name(OUT, pack, FALSE, TRUE); WRITE("</b>"); + WRITE(" (<i>"); + Localisation::write_0(OUT, D, I"Index.Elements.Ch.Plural"); + WRITE("</i> "); + IndexUtilities::kind_name(OUT, pack, TRUE, FALSE); WRITE(")"); + IndexUtilities::link_to_documentation(OUT, pack); HTML_CLOSE("p"); text_stream *variance = Metadata::read_optional_textual(pack, I"^variance"); if (Str::len(variance) > 0) { @@ -312,8 +279,8 @@ row. HTML_CLOSE("p"); }-
§2.8. Index literal patterns which can specify this kind2.8 = +
§1.1.2.2. Index literal patterns which can specify this kind1.1.2.2 =
@@ -323,71 +290,63 @@ row. HTML_TAG("br"); }-
§2.9. Index kinds of kinds matched by this kind2.9 = +
§1.1.2.3. Index kinds of kinds matched by this kind1.1.2.3 =
int f = FALSE; WRITE("<i>Matches:</i> "); - inter_symbol *wanted = PackageTypes::get(inv->of_tree, I"_conformance"); - inter_tree_node *D = Inter::Packages::definition(pack); - LOOP_THROUGH_INTER_CHILDREN(C, D) { - if (C->W.data[ID_IFLD] == PACKAGE_IST) { - inter_package *entry = Inter::Package::defined_by_frame(C); - if (Inter::Packages::type(entry) == wanted) { - inter_symbol *xref = Metadata::read_optional_symbol(entry, I"^conformed_to"); - inter_package *other = Inter::Packages::container(xref->definition); - if (f) WRITE(", "); - ChartElement::index_kind(OUT, other, FALSE, TRUE); - f = TRUE; - } - } + inter_package *conf_pack; + LOOP_THROUGH_SUBPACKAGES(conf_pack, pack, I"_conformance") { + inter_symbol *xref = Metadata::read_optional_symbol(conf_pack, I"^conformed_to"); + inter_package *other = Inter::Packages::container(xref->definition); + if (f) WRITE(", "); + IndexUtilities::kind_name(OUT, other, FALSE, TRUE); + f = TRUE; } HTML_TAG("br");-
§2.10. Index possible values of an enumerated kind2.10 = +
§1.1.2.4. Index possible values of an enumerated kind1.1.2.4 =
if (Str::ne(Metadata::read_textual(pack, I"^printed_name"), I"object")) if (Metadata::read_optional_numeric(pack, I"^instance_count") > 0) - ChartElement::index_instances(OUT, inv, pack, 1); + ChartElement::index_instances(OUT, inv, pack, 1);-
§2.11. Index explanatory text supplied for a kind2.11 = +
§1.1.2.5. Index explanatory text supplied for a kind1.1.2.5 =
- ChartElement::index_inferences(OUT, pack, FALSE); + ChartElement::index_inferences(OUT, pack, FALSE);-
§2.12. Explain about covariance and contravariance2.12 = +
§1.5. Explain about covariance and contravariance1.5 =
HTML_OPEN("p"); HTML_TAG_WITH("a", "name=contra"); HTML_OPEN_WITH("span", "class=\"smaller\""); - WRITE("<b>Covariance</b> means that if K is a kind of L, then something " - "you make from K can be used as the same thing made from L. For example, " - "a list of doors can be used as a list of things, because 'list of K' is " - "covariant. <b>Contravariance</b> means it works the other way round. " - "For example, an activity on things can be used as an activity on doors, " - "but not vice versa, because 'activity of K' is contravariant."); + Localisation::write_0(OUT, D, I"Index.Elements.Ch.CovarianceGloss"); HTML_CLOSE("span"); HTML_CLOSE("p");-
§3. Kind table construction. First, here's the table cell for the heading at the top of a column: the +
§2. Kind table construction. First, here's the table cell for the heading at the top of a column: the link is to the part of the rubric explaining what goes into the column.
-void ChartElement::index_kind_col_head(OUTPUT_STREAM, char *name, char *anchor) { +void ChartElement::index_kind_col_head(OUTPUT_STREAM, text_stream *key, char *anchor, + localisation_dictionary *D) { HTML::next_html_column_nowrap(OUT, 0); - WRITE("<i>%s</i> ", name); + WRITE("<i>"); + if (Str::len(key) > 0) Localisation::write_0(OUT, D, key); + WRITE("</i> "); if (anchor) { HTML_OPEN_WITH("a", "href=\"#\" onClick=\"showBasic('%s');\"", anchor); HTML_TAG_WITH("img", "border=0 src=inform:/doc_images/shelp.png"); @@ -395,55 +354,48 @@ link is to the part of the rubric explaining what goes into the column. } }-
§4. Once we're past the heading row, each row is made in two parts: first this +
§3. Once we're past the heading row, each row is made in two parts: first this is called —
int striper = FALSE; -void ChartElement::begin_chart_row(OUTPUT_STREAM) { +void ChartElement::begin_chart_row(OUTPUT_STREAM) { char *col = NULL; if (striper) col = "#f0f0ff"; striper = striper?FALSE:TRUE; HTML::first_html_column_nowrap(OUT, 0, col); }-
§5. That leads us into the cell for the name of the kind. The following -routine is used for the kind rows, but not for the kinds-of-object -rows; the cell for those is filled in a different way in "Index -Physical World". -
- -It's convenient to return the shadedness: a row is shaded if it's for -a kind which can have enumerated values but doesn't at the moment — -for instance, the sound effects row is shaded if there are none. +
§4. It's convenient to return the shadedness: a row is shaded if it's for a kind +which can have enumerated values but doesn't at the moment — for instance, the +sound effects row is shaded if there are none.
-int ChartElement::index_kind_name_cell(OUTPUT_STREAM, int shaded, inter_package *pack) { +int ChartElement::index_kind_name_cell(OUTPUT_STREAM, int shaded, inter_package *pack) { if (shaded) HTML::begin_colour(OUT, I"808080"); - ChartElement::index_kind(OUT, pack, FALSE, TRUE); + IndexUtilities::kind_name(OUT, pack, FALSE, TRUE); if (Metadata::read_optional_numeric(pack, I"^is_quasinumerical")) { WRITE(" "); HTML_OPEN_WITH("a", "href=\"Kinds.html?segment2\""); HTML_TAG_WITH("img", "border=0 src=inform:/doc_images/calc1.png"); HTML_CLOSE("a"); } - text_stream *doc_ref = Metadata::read_optional_textual(pack, I"^documentation"); - if (Str::len(doc_ref) > 0) IndexUtilities::DocReferences::link(OUT, doc_ref); + IndexUtilities::link_to_documentation(OUT, pack); int i = (int) Metadata::read_optional_numeric(pack, I"^instance_count"); if (i >= 1) WRITE(" [%d]", i); - IndexUtilities::below_link_numbered(OUT, pack->allocation_id); + IndexUtilities::below_link_numbered(OUT, pack->allocation_id); if (shaded) HTML::end_colour(OUT); return shaded; }-
§6. Finally we close the name cell, add the remaining cells, and close out the +
§5. Finally we close the name cell, add the remaining cells, and close out the whole row.
-void ChartElement::end_chart_row(OUTPUT_STREAM, int shaded, inter_package *pack, +void ChartElement::end_chart_row(OUTPUT_STREAM, int shaded, inter_package *pack, char *tick1, char *tick2, char *tick3) { if (tick1) HTML::next_html_column(OUT, 0); else HTML::next_html_column_spanning(OUT, 0, 4); @@ -470,71 +422,61 @@ whole row. HTML::end_html_row(OUT); }- - -
-void ChartElement::index_kind(OUTPUT_STREAM, inter_package *pack, int plural, int with_links) { - if (pack == NULL) return; - text_stream *key = (plural)?I"^index_plural":I"^index_singular"; - WRITE("%S", Metadata::read_optional_textual(pack, key)); - if (with_links) { - int at = (int) Metadata::read_optional_numeric(pack, I"^at"); - if (at > 0) IndexUtilities::link(OUT, at); - } -} -- +
§6. Recursing through subkinds. The following limitation exists just to catch errors. +
define MAX_OBJECT_INDEX_DEPTH 10000
-void ChartElement::index_subkinds(OUTPUT_STREAM, tree_inventory *inv, inter_package *pack, int depth, int pass) { +void ChartElement::index_subkinds(OUTPUT_STREAM, tree_inventory *inv, inter_package *pack, + int depth, int pass, localisation_dictionary *D) { for (int j=0; j<TreeLists::len(inv->kind_nodes); j++) { inter_package *inner_pack = Inter::Package::defined_by_frame(inv->kind_nodes->list[j].node); if ((Metadata::read_optional_numeric(inner_pack, I"^is_base")) && (Metadata::read_optional_numeric(inner_pack, I"^is_subkind_of_object"))) { inter_symbol *super_weak = Metadata::read_optional_symbol(inner_pack, I"^superkind"); if ((super_weak) && (Inter::Packages::container(super_weak->definition) == pack)) - ChartElement::index_object_kind(OUT, inv, inner_pack, depth, pass); + ChartElement::index_object_kind(OUT, inv, inner_pack, depth, pass, D); } } } -void ChartElement::index_object_kind(OUTPUT_STREAM, tree_inventory *inv, inter_package *pack, int depth, int pass) { +void ChartElement::index_object_kind(OUTPUT_STREAM, tree_inventory *inv, + inter_package *pack, int depth, int pass, localisation_dictionary *D) { if (depth == MAX_OBJECT_INDEX_DEPTH) internal_error("MAX_OBJECT_INDEX_DEPTH exceeded"); inter_symbol *class_s = Metadata::read_optional_symbol(pack, I"^object_class"); if (class_s == NULL) internal_error("no class for object kind"); text_stream *anchor = class_s->symbol_name; int shaded = FALSE; - Begin the object citation line8.1; - Index the name part of the object citation8.3; - Index the link icons part of the object citation8.4; - End the object citation line8.2; - if (pass == 2) Add a subsidiary paragraph of details about this object8.5; - ChartElement::index_subkinds(OUT, inv, pack, depth+1, pass); + Begin the object citation line6.1; + Index the name part of the object citation6.3; + Index the link icons part of the object citation6.4; + End the object citation line6.2; + if (pass == 2) Add a subsidiary paragraph of details about this object6.5; + ChartElement::index_subkinds(OUT, inv, pack, depth+1, pass, D); }-
§8.1. Begin the object citation line8.1 = +
§6.1. Begin the object citation line6.1 =
- if (pass == 1) ChartElement::begin_chart_row(OUT); + if (pass == 1) ChartElement::begin_chart_row(OUT); if (pass == 2) { HTML::open_indented_p(OUT, depth, "halftight"); - IndexUtilities::anchor(OUT, anchor); + IndexUtilities::anchor(OUT, anchor); }-
§8.2. End the object citation line8.2 = +
§6.2. End the object citation line6.2 =
- if (pass == 1) ChartElement::end_chart_row(OUT, shaded, pack, "tick", "tick", "tick"); + if (pass == 1) ChartElement::end_chart_row(OUT, shaded, pack, "tick", "tick", "tick"); if (pass == 2) HTML_CLOSE("p");-
§8.3. Index the name part of the object citation8.3 = +
§6.3. Index the name part of the object citation6.3 =
@@ -542,78 +484,78 @@ whole row. int c = (int) Metadata::read_optional_numeric(pack, I"^instance_count"); if ((c == 0) && (pass == 1)) shaded = TRUE; if (shaded) HTML::begin_colour(OUT, I"808080"); - Quote the name of the object being indexed8.3.1; + Quote the name of the object being indexed6.3.1; if (shaded) HTML::end_colour(OUT); if ((pass == 1) && (c > 0)) WRITE(" [%d]", c); } else { - Quote the name of the object being indexed8.3.1; + Quote the name of the object being indexed6.3.1; }-
§8.3.1. Quote the name of the object being indexed8.3.1 = +
§6.3.1. Quote the name of the object being indexed6.3.1 =
if (pass == 2) WRITE("<b>"); - ChartElement::index_kind(OUT, pack, FALSE, FALSE); + IndexUtilities::kind_name(OUT, pack, FALSE, FALSE); if (pass == 2) WRITE("</b>"); if (pass == 2) { - WRITE(" (<i>plural</i> "); ChartElement::index_kind(OUT, pack, TRUE, FALSE); + WRITE(" (<i>"); + Localisation::write_0(OUT, D, I"Index.Elements.Ch.Plural"); + WRITE("</i> "); + IndexUtilities::kind_name(OUT, pack, TRUE, FALSE); WRITE(")"); }-
§8.4. Index the link icons part of the object citation8.4 = +
§6.4. Index the link icons part of the object citation6.4 =
- int at = (int) Metadata::read_optional_numeric(pack, I"^at"); - if (at > 0) IndexUtilities::link(OUT, at); - text_stream *doc_ref = Metadata::read_optional_textual(pack, I"^documentation"); - if (Str::len(doc_ref) > 0) IndexUtilities::DocReferences::link(OUT, doc_ref); - if (pass == 1) IndexUtilities::below_link(OUT, anchor); + IndexUtilities::link_package(OUT, pack); + IndexUtilities::link_to_documentation(OUT, pack); + if (pass == 1) IndexUtilities::below_link(OUT, anchor);-
§8.5. Add a subsidiary paragraph of details about this object8.5 = +
§6.5. Add a subsidiary paragraph of details about this object6.5 =
HTML::open_indented_p(OUT, depth, "tight"); - ChartElement::index_inferences(OUT, pack, TRUE); + ChartElement::index_inferences(OUT, pack, TRUE); HTML_CLOSE("p"); - ChartElement::index_instances(OUT, inv, pack, depth); + ChartElement::index_instances(OUT, inv, pack, depth);-
-int ii_xtras = 900000; - -void ChartElement::index_instances(OUTPUT_STREAM, tree_inventory *inv, inter_package *pack, int depth) { +void ChartElement::index_instances(OUTPUT_STREAM, tree_inventory *inv, inter_package *pack, + int depth) { HTML::open_indented_p(OUT, depth, "tight"); int c = (int) Metadata::read_optional_numeric(pack, I"^instance_count"); if (c >= 10) { - int xtra = ii_xtras++; - IndexUtilities::extra_link(OUT, xtra); + int xtra = IndexRules::extra_ID(); + IndexUtilities::extra_link(OUT, xtra); HTML::begin_colour(OUT, I"808080"); WRITE("%d ", c); - ChartElement::index_kind(OUT, pack, TRUE, FALSE); + IndexUtilities::kind_name(OUT, pack, TRUE, FALSE); HTML::end_colour(OUT); HTML_CLOSE("p"); - IndexUtilities::extra_div_open(OUT, xtra, depth+1, "e0e0e0"); - Itemise the instances9.1; - IndexUtilities::extra_div_close(OUT, "e0e0e0"); + IndexUtilities::extra_div_open(OUT, xtra, depth+1, "e0e0e0"); + Itemise the instances7.1; + IndexUtilities::extra_div_close(OUT, "e0e0e0"); } else { - Itemise the instances9.1; + Itemise the instances7.1; HTML_CLOSE("p"); } }-
§9.1. Itemise the instances9.1 = +
§7.1. Itemise the instances7.1 =
- c = 0; + int c = 0; for (int i=0; i<TreeLists::len(inv->instance_nodes); i++) { inter_package *I_pack = Inter::Package::defined_by_frame(inv->instance_nodes->list[i].node); inter_symbol *strong_kind_ID = Metadata::read_optional_symbol(I_pack, I"^kind_xref"); @@ -622,16 +564,16 @@ whole row. HTML::begin_colour(OUT, I"808080"); WRITE("%S", Metadata::read_optional_textual(I_pack, I"^name")); HTML::end_colour(OUT); - int at = (int) Metadata::read_optional_numeric(I_pack, I"^at"); - if (at > 0) IndexUtilities::link(OUT, at); + IndexUtilities::link_package(OUT, I_pack); } }-
§8. Here pack can be either an instance or a kind package. +
-void ChartElement::index_inferences(OUTPUT_STREAM, inter_package *pack, int brief) { +void ChartElement::index_inferences(OUTPUT_STREAM, inter_package *pack, int brief) { text_stream *explanation = Metadata::read_optional_textual(pack, I"^specification"); if (Str::len(explanation) > 0) { WRITE("%S", explanation); diff --git a/docs/index-module/3-ce3.html b/docs/index-module/3-ce3.html index 0a281ec39..75a651a47 100644 --- a/docs/index-module/3-ce3.html +++ b/docs/index-module/3-ce3.html @@ -72,7 +72,7 @@ function togglePopup(material_id) {
To write the Commands element (Cm) in the index.
-§2. The following modest structure is used for the indexing of command verbs, -and is too deeply boring to comment upon. These are the headwords of commands -which can be typed at run-time, like QUIT or INVENTORY. For indexing purposes, -we divide these headwords into five "natures": +
§1.1. Create the entries for the command list1.1 = +
+ ++ inter_package *pack = Inter::Packages::by_url(I, I"/main/completion/grammar"); + inter_package *entry; + LOOP_THROUGH_SUBPACKAGES(entry, pack, I"_command_grammar") + if ((Metadata::read_optional_numeric(entry, I"^is_command")) && + (InterTree::no_subpackages(entry, I"_cg_line") > 0)) + Create entry for this command1.1.1; + CommandsElement::make_direction_entry(entries); ++
§1.1.1. Create entry for this command1.1.1 = +
+ ++ text_stream *main_command = Metadata::read_optional_textual(entry, I"^command"); + if (Str::len(main_command) == 0) main_command = I"0"; + CommandsElement::make_entry(main_command, entry, NORMAL_COMMAND, entries); + inter_package *alias; + LOOP_THROUGH_SUBPACKAGES(alias, entry, I"_cg_alias") { + text_stream *alias_command = Metadata::read_textual(alias, I"^alias"); + CommandsElement::make_entry(alias_command, entry, ALIAS_COMMAND, entries); + } ++
§1.2. Entries in the list correspond to the headwords of commands which can be typed +at runtime, like QUIT or INVENTORY. For indexing purposes, we divide these headwords +as follows:
define NORMAL_COMMAND 1 @@ -200,86 +145,147 @@ we divide these headwords into five "natures": command_index_entry *sorted_command_index = NULL; in alphabetical order of text
-void CommandsElement::test_verb(text_stream *t) { - command_index_entry *vie; - vie = CREATE(command_index_entry); - vie->command_headword = Str::duplicate(t); - vie->nature = TESTING_COMMAND; - vie->cg_indexed = NULL; - vie->next_alphabetically = NULL; +void CommandsElement::make_test_entry(text_stream *t, linked_list *entries) { + command_index_entry *cie; + cie = CREATE(command_index_entry); + cie->command_headword = Str::duplicate(t); + cie->nature = TESTING_COMMAND; + cie->cg_indexed = NULL; + cie->next_alphabetically = NULL; + ADD_TO_LINKED_LIST(cie, command_index_entry, entries); } -command_index_entry *CommandsElement::vie_new_from(text_stream *headword, inter_package *cg, int nature) { - command_index_entry *vie = CREATE(command_index_entry); - vie->command_headword = Str::duplicate(headword); - vie->nature = nature; - vie->cg_indexed = cg; - vie->next_alphabetically = NULL; - return vie; +void CommandsElement::make_entry(text_stream *headword, inter_package *cg_pack, + int nature, linked_list *entries) { + command_index_entry *cie = CREATE(command_index_entry); + cie->command_headword = Str::duplicate(headword); + cie->nature = nature; + cie->cg_indexed = cg_pack; + cie->next_alphabetically = NULL; + ADD_TO_LINKED_LIST(cie, command_index_entry, entries); } -void CommandsElement::direction_verb(void) { - command_index_entry *vie = CREATE(command_index_entry); - vie->command_headword = I"0"; - vie->nature = BARE_DIRECTION_COMMAND; - vie->cg_indexed = NULL; - vie->next_alphabetically = NULL; +void CommandsElement::make_direction_entry(linked_list *entries) { + command_index_entry *cie = CREATE(command_index_entry); + cie->command_headword = I"0"; + cie->nature = BARE_DIRECTION_COMMAND; + cie->cg_indexed = NULL; + cie->next_alphabetically = NULL; + ADD_TO_LINKED_LIST(cie, command_index_entry, entries); }-
§4. Indexing by grammar. This is the more obvious form of indexing: we show the grammar lines which -make up an individual CGL. (For instance, this is used in the Actions index -to show the grammar for an individual command word, by calling the routine -below for that command word's CG.) Such an index list is done in sorted -order, so that the order of appearance in the index corresponds to the -order of parsing — this is what the reader of the index is interested in. +
+ ++linked_list *CommandsElement::sort(linked_list *entries) { + command_index_entry *cie, *list_start = NULL; + LOOP_OVER_LINKED_LIST(cie, command_index_entry, entries) { + if (list_start == NULL) { list_start = cie; continue; } + command_index_entry *cie2 = list_start, *last_cie2 = NULL; + while (cie2 && (Str::cmp(cie->command_headword, cie2->command_headword) > 0)) { + last_cie2 = cie2; + cie2 = cie2->next_alphabetically; + } + if (last_cie2 == NULL) { + cie->next_alphabetically = list_start; list_start = cie; + } else { + last_cie2->next_alphabetically = cie; cie->next_alphabetically = cie2; + } + } + linked_list *sorted = NEW_LINKED_LIST(command_index_entry); + for (command_index_entry *cie = list_start; cie; cie = cie->next_alphabetically) + ADD_TO_LINKED_LIST(cie, command_index_entry, sorted); + return sorted; +} ++
§1.5. With those lengthy digressions done, back to the actual indexing: +
+ +Render an index entry from the sorted list1.5 =
-void CommandsElement::index_normal(OUTPUT_STREAM, inter_tree *I, inter_package *cg, text_stream *headword) { - inter_symbol *wanted = PackageTypes::get(I, I"_cg_line"); - inter_tree_node *D = Inter::Packages::definition(cg); - LOOP_THROUGH_INTER_CHILDREN(C, D) { - if (C->W.data[ID_IFLD] == PACKAGE_IST) { - inter_package *entry = Inter::Package::defined_by_frame(C); - if (Inter::Packages::type(entry) == wanted) - CommandsElement::cgl_index_normal(OUT, entry, headword); - } + inter_package *cg_pack = cie->cg_indexed; + switch (cie->nature) { + case NORMAL_COMMAND: + CommandsElement::index_normal(OUT, I, cg_pack, cie->command_headword, LD); + break; + case ALIAS_COMMAND: + CommandsElement::index_alias(OUT, I, cg_pack, cie->command_headword, LD); + break; + case OUT_OF_WORLD_COMMAND: + HTML::begin_colour(OUT, I"800000"); + WRITE(""%S", <i>", cie->command_headword); + Localisation::write_0(OUT, LD, I"Index.Elements.Cm.Command"); + WRITE("</i>"); + HTML::end_colour(OUT); + HTML_TAG("br"); + break; + case TESTING_COMMAND: + HTML::begin_colour(OUT, I"800000"); + WRITE(""%S", <i>", cie->command_headword); + Localisation::write_0(OUT, LD, I"Index.Elements.Cm.TestingCommand"); + WRITE("</i>"); + HTML::end_colour(OUT); + HTML_TAG("br"); + break; + case BARE_DIRECTION_COMMAND: + WRITE(""[direction]" - <i>"); + Localisation::write_0(OUT, LD, I"Index.Elements.Cm.DirectionCommand"); + WRITE("</i>"); + HTML_TAG("br"); + break; } ++
+void CommandsElement::index_normal(OUTPUT_STREAM, inter_tree *I, inter_package *cg_pack, + text_stream *headword, localisation_dictionary *LD) { + inter_package *entry; + LOOP_THROUGH_SUBPACKAGES(entry, cg_pack, I"_cg_line") + CommandsElement::index_grammar_line(OUT, entry, headword, LD); } -void CommandsElement::cgl_index_normal(OUTPUT_STREAM, inter_package *cgl, text_stream *headword) { +void CommandsElement::index_alias(OUTPUT_STREAM, inter_tree *I, inter_package *cg_pack, + text_stream *headword, localisation_dictionary *LD) { + WRITE(""%S", <i>", headword); + Localisation::write_0(OUT, LD, I"Index.Elements.Cm.Alias"); + WRITE("</i> "%S"", Metadata::read_textual(cg_pack, I"^command")); + IndexUtilities::link_package(OUT, cg_pack); + HTML_TAG("br"); +} + +void CommandsElement::index_grammar_line(OUTPUT_STREAM, inter_package *cgl, + text_stream *headword, localisation_dictionary *LD) { inter_symbol *an_s = Metadata::read_optional_symbol(cgl, I"^action"); if (an_s == NULL) return; inter_package *an = Inter::Packages::container(an_s->definition); int oow = (int) Metadata::read_optional_numeric(an, I"^out_of_world"); - if (Str::len(headword) > 0) IndexUtilities::anchor(OUT, headword); + if (Str::len(headword) > 0) IndexUtilities::anchor(OUT, headword); if (oow) HTML::begin_colour(OUT, I"800000"); WRITE("""); TokensElement::verb_definition(OUT, Metadata::read_optional_textual(cgl, I"^text"), headword, EMPTY_WORDING); WRITE("""); - int at = (int) Metadata::read_optional_numeric(cgl, I"^at"); - if (at > 0) IndexUtilities::link(OUT, at); + IndexUtilities::link_package(OUT, cgl); WRITE(" - <i>%S", Metadata::read_textual(an, I"^name")); - IndexUtilities::detail_link(OUT, "A", (int) Metadata::read_numeric(an, I"action_id"), TRUE); - if (Metadata::read_optional_numeric(cgl, I"^reversed")) - WRITE(" <i>reversed</i>"); + IndexUtilities::detail_link(OUT, "A", + (int) Metadata::read_numeric(an, I"action_id"), TRUE); + if (Metadata::read_optional_numeric(cgl, I"^reversed")) { + WRITE(" <i>"); + Localisation::write_0(OUT, LD, I"Index.Elements.Cm.Reversed"); + WRITE("</i>"); + } WRITE("</i>"); if (oow) HTML::end_colour(OUT); HTML_TAG("br"); } - -void CommandsElement::index_alias(OUTPUT_STREAM, inter_tree *I, inter_package *cg, text_stream *headword) { - WRITE(""%S", <i>same as</i> "%S"", - headword, Metadata::read_textual(cg, I"^command")); - int at = (int) Metadata::read_optional_numeric(cg, I"^at"); - if (at > 0) IndexUtilities::link(OUT, at); - HTML_TAG("br"); -}