diff --git a/docs/codegen-module/3-su.html b/docs/codegen-module/3-su.html index bf52e7306..6c6ba6957 100644 --- a/docs/codegen-module/3-su.html +++ b/docs/codegen-module/3-su.html @@ -207,7 +207,7 @@ function togglePopup(material_id) { tree_inventory *cached_inventory = NULL; inter_tree *cache_is_for = NULL; -tree_inventory *Synoptic::inv(inter_tree *I) { +tree_inventory *Synoptic::inv(inter_tree *I) { if (cache_is_for == I) return cached_inventory; cache_is_for = I; cached_inventory = Synoptic::new_inventory(I); @@ -238,7 +238,7 @@ function togglePopup(material_id) { return TRUE; } - +

§2.

@@ -257,7 +257,7 @@ function togglePopup(material_id) {
     return E1->sort_key - E2->sort_key;  smaller values sort earlier
 }
 
-int Synoptic::category_order(const void *ent1, const void *ent2) {
+int Synoptic::category_order(const void *ent1, const void *ent2) {
     itl_entry *E1 = (itl_entry *) ent1;
     itl_entry *E2 = (itl_entry *) ent2;
     if (E1 == E2) return 0;
@@ -373,7 +373,7 @@ function togglePopup(material_id) {
     synoptic_array_node->W.data[synoptic_array_node->W.extent-1] = val2;
 }
 
-inter_tree_node *Synoptic::get_definition(inter_package *pack, text_stream *name) {
+inter_tree_node *Synoptic::get_definition(inter_package *pack, text_stream *name) {
     inter_symbol *def_s = InterSymbolsTables::symbol_from_name(Inter::Packages::scope(pack), name);
     if (def_s == NULL) {
         LOG("Unable to find symbol %S in $6\n", name, pack);
@@ -395,7 +395,7 @@ function togglePopup(material_id) {
     return D;
 }
 
-inter_package *Synoptic::module_containing(inter_tree_node *P) {
+inter_package *Synoptic::module_containing(inter_tree_node *P) {
     inter_package *pack = Inter::Packages::container(P);
     inter_tree *I = Inter::Packages::tree(pack);
     while (pack) {
diff --git a/docs/codegen-module/6-be.html b/docs/codegen-module/6-be.html
index e3c4970f9..c9f8f059e 100644
--- a/docs/codegen-module/6-be.html
+++ b/docs/codegen-module/6-be.html
@@ -115,7 +115,7 @@ function togglePopup(material_id) {
 }
 
diff --git a/docs/codegen-module/6-ce.html b/docs/codegen-module/6-ce.html index 8a419ef31..0f25c4a05 100644 --- a/docs/codegen-module/6-ce.html +++ b/docs/codegen-module/6-ce.html @@ -150,7 +150,7 @@ simplified form of the iFiction record, without the XML overhead. } diff --git a/docs/codegen-module/6-ee.html b/docs/codegen-module/6-ee.html index 2be343b71..e842d819d 100644 --- a/docs/codegen-module/6-ee.html +++ b/docs/codegen-module/6-ee.html @@ -150,7 +150,7 @@ function togglePopup(material_id) { diff --git a/docs/codegen-module/6-fe.html b/docs/codegen-module/6-fe.html index 18c4a8e18..6605c5333 100644 --- a/docs/codegen-module/6-fe.html +++ b/docs/codegen-module/6-fe.html @@ -353,7 +353,7 @@ to match this width, preserving the aspect ratio. diff --git a/docs/codegen-module/6-ifs.html b/docs/codegen-module/6-ifs.html index 1831d742f..990a594e7 100644 --- a/docs/codegen-module/6-ifs.html +++ b/docs/codegen-module/6-ifs.html @@ -83,7 +83,7 @@ function togglePopup(material_id) { indexing_tree = I; } -inter_tree *Index::get_tree(void) { +inter_tree *Index::get_tree(void) { return indexing_tree; } @@ -225,7 +225,6 @@ leafname A.html } ifl = &index_file_struct; text_stream *OUT = ifl; -LOG("Index: %f\n", F); Set the current index page8.1; HTML::header(OUT, title, @@ -838,12 +837,12 @@ to show, hide and colour things: FiguresElement::render(OUT); return; } - - #ifdef CORE_MODULE if (Str::eq_wide_string(elt, L"Tb")) { - IXTables::render(OUT); + TablesElement::render(OUT); return; } + + #ifdef CORE_MODULE if (Str::eq_wide_string(elt, L"In")) { IXInnards::render(OUT, Supervisor::current_vm()); return; @@ -1023,7 +1022,7 @@ the source text in the application.

-void Index::link(OUTPUT_STREAM, int wn) {
+void Index::link(OUTPUT_STREAM, int wn) {
     Index::link_to_location(OUT, Lexer::word_location(wn), TRUE);
 }
 
@@ -1096,7 +1095,7 @@ code.
 

§17. "Show extra" links, and also a spacer of equivalent width.

-void Index::extra_link(OUTPUT_STREAM, int id) {
+void Index::extra_link(OUTPUT_STREAM, int id) {
     HTML_OPEN_WITH("a", "href=\"#\" onclick=\"showExtra('extra%d', 'plus%d'); return false;\"", id, id);
     HTML_TAG_WITH("img", "border=0 id=\"plus%d\" src=inform:/doc_images/extra.png", id);
     HTML_CLOSE("a");
@@ -1126,13 +1125,13 @@ code.
 

-void Index::extra_div_open(OUTPUT_STREAM, int id, int indent, char *colour) {
+void Index::extra_div_open(OUTPUT_STREAM, int id, int indent, char *colour) {
     HTML_OPEN_WITH("div", "id=\"extra%d\" style=\"display: none;\"", id);
     HTML::open_indented_p(OUT, indent, "");
     HTML::open_coloured_box(OUT, colour, ROUND_BOX_TOP+ROUND_BOX_BOTTOM);
 }
 
-void Index::extra_div_close(OUTPUT_STREAM, char *colour) {
+void Index::extra_div_close(OUTPUT_STREAM, char *colour) {
     HTML::close_coloured_box(OUT, colour, ROUND_BOX_TOP+ROUND_BOX_BOTTOM);
     HTML_CLOSE("p");
     HTML_CLOSE("div");
@@ -1176,7 +1175,7 @@ quotes.
 }
 
diff --git a/docs/codegen-module/6-ii.html b/docs/codegen-module/6-ii.html index 152595346..05ad59ad2 100644 --- a/docs/codegen-module/6-ii.html +++ b/docs/codegen-module/6-ii.html @@ -288,7 +288,7 @@ time.) {-index:name}
  • This code is used in §3.
diff --git a/docs/codegen-module/6-re.html b/docs/codegen-module/6-re.html index 2532d11ed..c1edce1bf 100644 --- a/docs/codegen-module/6-re.html +++ b/docs/codegen-module/6-re.html @@ -112,7 +112,7 @@ function togglePopup(material_id) { }
diff --git a/docs/codegen-module/6-te.html b/docs/codegen-module/6-te.html new file mode 100644 index 000000000..69272032c --- /dev/null +++ b/docs/codegen-module/6-te.html @@ -0,0 +1,261 @@ + + + + Tables Element + + + + + + + + + + + + + + + + + + +
+ + +

To write the Tables element (Tb) in the index.

+ +
+ +

§1. Indexing. Tables inside extensions are often used just for the storage needed to manage +back-of-house algorithms, so to speak, and they aren't intended for the end +user to poke around with; that's certainly true of the tables in the Standard +Rules, which of course are always present. So these are hidden by default. +

+ +
+void TablesElement::render(OUTPUT_STREAM) {
+    inter_tree *I = Index::get_tree();
+    tree_inventory *inv = Synoptic::inv(I);
+    TreeLists::sort(inv->table_nodes, Synoptic::category_order);
+
+    inter_package *current_mod = NULL; int mc = 0, first_ext = TRUE;
+    inter_ti cat = 1, open_cat = 0;
+    for (inter_ti with_cat = 1; with_cat <= 3; with_cat++) {
+        for (int i=0; i<TreeLists::len(inv->table_nodes); i++) {
+            inter_package *mod = Synoptic::module_containing(inv->table_nodes->list[i].node);
+            if (mod == NULL) continue;
+            cat = Metadata::read_optional_numeric(mod, I"^category");
+            if (cat == with_cat) {
+                if ((mc == 0) || (mod != current_mod)) {
+                    Close block of tables1.2;
+                    mc++; current_mod = mod;
+                    Open block of tables1.1;
+                }
+                inter_package *pack = Inter::Package::defined_by_frame(inv->table_nodes->list[i].node);
+                Index this table1.3;
+            }
+        }
+    }
+    Close block of tables1.2;
+}
+
+

§1.1. Open block of tables1.1 = +

+ +
+    if (cat > 1) {
+        if (first_ext) {
+            HTML_OPEN("p");
+            Index::extra_link(OUT, 2);
+            if (mc > 1) WRITE("Show tables inside extensions too");
+            else WRITE("Show tables inside extensions (there are none in the main text)");
+            HTML_CLOSE("p");
+            first_ext = FALSE;
+        }
+        Index::extra_div_open(OUT, 2, 1, "e0e0e0");
+        HTML_OPEN("p");
+        WRITE("<i>%S</i>", Metadata::read_textual(mod, I"^title"));
+        HTML_CLOSE("p");
+    }
+    open_cat = cat;
+    HTML::begin_plain_html_table(OUT);
+
+ +

§1.2. Close block of tables1.2 = +

+ +
+    if (mc > 0) {
+        HTML::end_html_table(OUT);
+        if (open_cat > 1) Index::extra_div_close(OUT, "e0e0e0");
+    }
+
+ +

§1.3. The following probably ought to use a multiplication sign rather than a +Helvetica-style lower case "x", but life is full of compromises. +

+ +

Index this table1.3 = +

+ +
+    HTML::first_html_column_spaced(OUT, 0);
+    WRITE("<b>%S</b>", Metadata::read_textual(pack, I"^printed_name"));
+    int ntc = 0;
+    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) == PackageTypes::get(I, I"_table_contribution")) {
+                if (ntc++ > 0) WRITE(" +");
+                int at = (int) Metadata::read_optional_numeric(entry, I"^at");
+                Index::link(OUT, at);
+            }
+        }
+    }
+    HTML::next_html_column_spaced(OUT, 0);
+
+    int nc = 0;
+    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) == PackageTypes::get(I, I"_table_column_usage"))
+                nc++;
+        }
+    }
+    int nr = (int) Metadata::read_numeric(pack, I"^rows");
+    int nb = (int) Metadata::read_numeric(pack, I"^blank_rows");
+    int defines = (int) Metadata::read_optional_numeric(pack, I"^defines");
+    text_stream *for_each = Metadata::read_optional_textual(pack, I"^blank_rows_for_each");
+
+    WRITE("<i>");
+    HTML_OPEN_WITH("span", "class=\"smaller\"");
+    if (defines) {
+        WRITE("%d definition%s", nr, (nr == 1)?"":"s");
+    } else {
+        WRITE("%d column%s x %d row%s", nc, (nc == 1)?"":"s", nr, (nr == 1)?"":"s");
+    }
+    if (nb > 0) {
+        WRITE(" (%d blank", nb);
+        if (Str::len(for_each) > 0) WRITE(", one for each %S", for_each);
+        WRITE(")");
+    }
+    HTML_CLOSE("span");
+    WRITE("</i>");
+
+    HTML::end_html_row(OUT);
+
+    int col = 0;
+    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) == PackageTypes::get(I, I"_table_column_usage")) {
+                inter_tree_node *ID = Synoptic::get_definition(entry, I"column_identity");
+                inter_symbol *id_s = NULL;
+                if (ID->W.data[DATA_CONST_IFLD] == ALIAS_IVAL)
+                    id_s = InterSymbolsTables::symbol_from_id(Inter::Packages::scope(entry), ID->W.data[DATA_CONST_IFLD+1]);
+                if (id_s == NULL) internal_error("column_identity not an ALIAS_IVAL");
+                inter_package *col_pack = Inter::Packages::container(id_s->definition);
+                LOG("Whellll... $6\n", col_pack);
+
+                HTML::first_html_column(OUT, 0);
+                WRITE("&nbsp;&nbsp;col %d:&nbsp;&nbsp;", col+1);
+                Give column details1.3.1;
+                HTML::next_html_column(OUT, 0);
+                Give column 2 details1.3.2;
+                HTML::end_html_row(OUT);
+                col++;
+            }
+        }
+    }
+
+ +

§1.3.1. Give column details1.3.1 = +

+ +
+    text_stream *CW = Metadata::read_optional_textual(col_pack, I"^name");
+    if ((defines) && (col == 0)) {
+        WRITE("%S", Metadata::read_optional_textual(pack, I"^defines_text"));
+        int at = (int) Metadata::read_optional_numeric(pack, I"^defines_at");
+        Index::link(OUT, at);
+    } else {
+        if (defines) WRITE("<i>sets</i> ");
+        WRITE("%S&nbsp;", CW);
+        TEMPORARY_TEXT(TEMP)
+        WRITE_TO(TEMP, "%S", CW);
+        if (defines == FALSE) WRITE_TO(TEMP, " entry");
+        PasteButtons::paste_text(OUT, TEMP);
+        DISCARD_TEXT(TEMP)
+    }
+
+ +

§1.3.2. Give column 2 details1.3.2 = +

+ +
+    if ((defines) && (col == 0)) {
+        WRITE("<i>names</i>");
+    } else if (defines) {
+        WRITE("%S property", Metadata::read_optional_textual(col_pack, I"^contents"));
+    } else {
+        WRITE("of %S", Metadata::read_optional_textual(col_pack, I"^contents"));
+    }
+
+ + + +
+ + + diff --git a/docs/codegen-module/index.html b/docs/codegen-module/index.html index bad07846c..cec479df6 100644 --- a/docs/codegen-module/index.html +++ b/docs/codegen-module/index.html @@ -361,6 +361,11 @@ Figures Element - To write the Figures element (Fi) in the index.

+
  • +

    + Tables Element - + To write the Tables element (Tb) in the index.

    +
  • diff --git a/docs/index-module/2-act.html b/docs/index-module/2-act.html index c0374343e..113084c9a 100644 --- a/docs/index-module/2-act.html +++ b/docs/index-module/2-act.html @@ -86,7 +86,7 @@ function togglePopup(material_id) { struct activity_crossref *next; } activity_crossref;
    - +

    §2.

    @@ -164,7 +164,7 @@ function togglePopup(material_id) {
     }
     
    diff --git a/docs/index-module/2-adj.html b/docs/index-module/2-adj.html index ba251424b..5919052de 100644 --- a/docs/index-module/2-adj.html +++ b/docs/index-module/2-adj.html @@ -104,7 +104,7 @@ prefaced "(of a rulebook)", "(of an activity)", and so on. diff --git a/docs/index-module/2-ae.html b/docs/index-module/2-ae.html index 8034545c6..aab8aa63d 100644 --- a/docs/index-module/2-ae.html +++ b/docs/index-module/2-ae.html @@ -217,7 +217,7 @@ text, sorted into kind order of left and then right operand. diff --git a/docs/index-module/2-ce.html b/docs/index-module/2-ce.html index c53386c5b..4a46da452 100644 --- a/docs/index-module/2-ce.html +++ b/docs/index-module/2-ce.html @@ -129,7 +129,7 @@ function togglePopup(material_id) { } } - +

    §1.1. Index this entry in the contents1.1 =

    @@ -312,7 +312,7 @@ giving only minimal entries about them. } diff --git a/docs/index-module/2-ie.html b/docs/index-module/2-ie.html index 5053158e7..5d2451236 100644 --- a/docs/index-module/2-ie.html +++ b/docs/index-module/2-ie.html @@ -299,7 +299,7 @@ dictionary. } diff --git a/docs/index-module/2-ie2.html b/docs/index-module/2-ie2.html index 168e68726..1f84b4fef 100644 --- a/docs/index-module/2-ie2.html +++ b/docs/index-module/2-ie2.html @@ -255,7 +255,7 @@ function togglePopup(material_id) { diff --git a/docs/index-module/2-inf.html b/docs/index-module/2-inf.html index 0b98805b4..c10ed81d4 100644 --- a/docs/index-module/2-inf.html +++ b/docs/index-module/2-inf.html @@ -194,7 +194,7 @@ state of being boolean, and the given certainty levels: } diff --git a/docs/index-module/2-ins.html b/docs/index-module/2-ins.html index ef83bcba3..6516eab1d 100644 --- a/docs/index-module/2-ins.html +++ b/docs/index-module/2-ins.html @@ -89,7 +89,7 @@ function togglePopup(material_id) { struct instance_usage *next; } instance_usage; - +

    §2.

    @@ -203,7 +203,7 @@ constant value.
     }
     
    diff --git a/docs/index-module/2-ki.html b/docs/index-module/2-ki.html index e71e51bef..5c889dd1d 100644 --- a/docs/index-module/2-ki.html +++ b/docs/index-module/2-ki.html @@ -571,7 +571,7 @@ as "0 kg", "0 hectares", or whatever is appropriate. diff --git a/docs/index-module/2-li.html b/docs/index-module/2-li.html index 22e118e48..5044f208d 100644 --- a/docs/index-module/2-li.html +++ b/docs/index-module/2-li.html @@ -712,7 +712,7 @@ be able to print out a table of just those verbs created in that extension. } diff --git a/docs/index-module/2-me.html b/docs/index-module/2-me.html index 3678b88d6..d03c2d4d8 100644 --- a/docs/index-module/2-me.html +++ b/docs/index-module/2-me.html @@ -475,7 +475,7 @@ table of Kinds. } diff --git a/docs/index-module/2-pi.html b/docs/index-module/2-pi.html index b5ad87a76..3212aa728 100644 --- a/docs/index-module/2-pi.html +++ b/docs/index-module/2-pi.html @@ -501,7 +501,7 @@ so we won't list them here. } diff --git a/docs/index-module/2-prp.html b/docs/index-module/2-prp.html index 91d045136..b8227b552 100644 --- a/docs/index-module/2-prp.html +++ b/docs/index-module/2-prp.html @@ -143,7 +143,7 @@ function togglePopup(material_id) { } diff --git a/docs/index-module/2-rfse.html b/docs/index-module/2-rfse.html index 0dabf3cac..b71fbb118 100644 --- a/docs/index-module/2-rfse.html +++ b/docs/index-module/2-rfse.html @@ -82,7 +82,7 @@ } diff --git a/docs/index-module/2-rls.html b/docs/index-module/2-rls.html index 07b678679..b4ee3a942 100644 --- a/docs/index-module/2-rls.html +++ b/docs/index-module/2-rls.html @@ -796,7 +796,7 @@ have affected it in this way: } } - +

    §10. Rule contexts. These are mainly (only?) used in indexing, as a way to represent the idea of being the relevant scene or action for a rule.

    @@ -864,7 +864,7 @@ text to assert a change: } diff --git a/docs/index-module/2-te.html b/docs/index-module/2-te.html deleted file mode 100644 index a1c5a0d79..000000000 --- a/docs/index-module/2-te.html +++ /dev/null @@ -1,221 +0,0 @@ - - - - Tables Element - - - - - - - - - - - - - - - - - - -
    - - -

    To index tables.

    - -
    - -

    §1. Indexing. Tables inside extensions are often used just for the storage needed to manage -back-of-house algorithms, so to speak, and they aren't intended for the end -user to poke around with; that's certainly true of the tables in the Standard -Rules, which of course are always present. So these are hidden by default. -

    - -
    -void IXTables::render(OUTPUT_STREAM) {
    -    HTML_OPEN("p");
    -    int m = IXTables::index_tables_in(OUT, NULL, 0);
    -    HTML_CLOSE("p");
    -    HTML_OPEN("p");
    -    Index::extra_link(OUT, 2);
    -    if (m > 0) WRITE("Show tables inside extensions too");
    -    else WRITE("Show tables inside extensions (there are none in the main text)");
    -    HTML_CLOSE("p");
    -    Index::extra_div_open(OUT, 2, 1, "e0e0e0");
    -    inform_extension *E; int efc = 0;
    -    LOOP_OVER(E, inform_extension) IXTables::index_tables_in(OUT, E, efc++);
    -    Index::extra_div_close(OUT, "e0e0e0");
    -}
    -
    -

    §2. This tabulates tables within a given extension, returning the number listed, -and does nothing at all if that number is 0. -

    - -
    -int IXTables::index_tables_in(OUTPUT_STREAM, inform_extension *E, int efc) {
    -    int tc = 0; table *t;
    -    LOOP_OVER(t, table) if (IXTables::table_within(t, E)) tc++;
    -    if (tc > 0) {
    -        if (E) {
    -            HTML_OPEN("p");
    -            WRITE("<i>%S</i>", E->as_copy->edition->work->title);
    -            HTML_CLOSE("p");
    -        }
    -        HTML::begin_plain_html_table(OUT);
    -        LOOP_OVER(t, table)
    -            if (IXTables::table_within(t, E))
    -                Index this table2.1;
    -        HTML::end_html_table(OUT);
    -    }
    -    return tc;
    -}
    -
    -

    §2.1. The following probably ought to use a multiplication sign rather than a -Helvetica-style lower case "x", but life is full of compromises. -

    - -

    Index this table2.1 = -

    - -
    -    HTML::first_html_column_spaced(OUT, 0);
    -    WRITE("<b>%+W</b>", Node::get_text(t->headline_fragment));
    -    table_contribution *tc; int ntc = 0;
    -    for (tc = t->table_created_at; tc; tc = tc->next) {
    -        if (ntc++ > 0) WRITE(" +");
    -        Index::link(OUT, Wordings::first_wn(Node::get_text(tc->source_table)));
    -    }
    -    HTML::next_html_column_spaced(OUT, 0);
    -    int rc = Tables::get_no_rows(t);
    -    WRITE("<i>");
    -    HTML_OPEN_WITH("span", "class=\"smaller\"");
    -    if (t->first_column_by_definition) {
    -        WRITE("%d definition%s", rc,
    -            (rc == 1)?"":"s");
    -    } else {
    -        WRITE("%d column%s x %d row%s",
    -            t->no_columns, (t->no_columns == 1)?"":"s",
    -            rc, (rc == 1)?"":"s");
    -    }
    -    if (t->blank_rows > 0) {
    -        WRITE(" (%d blank", t->blank_rows);
    -        if (Wordings::nonempty(t->blank_rows_for_each_text))
    -            WRITE(", one for each %+W", t->blank_rows_for_each_text);
    -        WRITE(")");
    -    }
    -    HTML_CLOSE("span");
    -    WRITE("</i>");
    -    HTML::end_html_row(OUT);
    -    int col;
    -    for (col = 0; col < t->no_columns; col++) {
    -        HTML::first_html_column(OUT, 0);
    -        WRITE("&nbsp;&nbsp;col %d:&nbsp;&nbsp;", col+1);
    -        wording CW = Nouns::nominative_singular(t->columns[col].column_identity->name);
    -        if ((t->first_column_by_definition) && (col == 0)) {
    -            parse_node *PN = t->where_used_to_define;
    -            WRITE("%+W", Node::get_text(PN));
    -            Index::link(OUT, Wordings::first_wn(Node::get_text(PN)));
    -        } else {
    -            if (t->first_column_by_definition) WRITE("<i>sets</i> ");
    -            WRITE("%+W&nbsp;", CW);
    -            TEMPORARY_TEXT(TEMP)
    -            WRITE_TO(TEMP, "%+W", CW);
    -            if (t->first_column_by_definition == FALSE) WRITE_TO(TEMP, " entry");
    -            PasteButtons::paste_text(OUT, TEMP);
    -            DISCARD_TEXT(TEMP)
    -        }
    -        HTML::next_html_column(OUT, 0);
    -        if ((t->first_column_by_definition) && (col == 0)) {
    -            parse_node *cell;
    -            int row;
    -            for (row = 1, cell = t->columns[0].entries->down; cell; cell = cell->next, row++) {
    -                if (row > 1) WRITE(", ");
    -                WRITE("%+W", Node::get_text(cell));
    -                Index::link(OUT, Wordings::first_wn(Node::get_text(cell)));
    -            }
    -        } else if (t->first_column_by_definition) {
    -            Kinds::Textual::write(OUT,
    -                Tables::Columns::get_kind(
    -                    t->columns[col].column_identity));
    -            WRITE(" property");
    -        } else {
    -            WRITE("of ");
    -            Kinds::Textual::write_plural(OUT,
    -                Tables::Columns::get_kind(
    -                    t->columns[col].column_identity));
    -        }
    -        HTML::end_html_row(OUT);
    -    }
    -
    - -

    §3. The following laboriously tests whether a table is defined within a -given extension: -

    - -
    -int IXTables::table_within(table *t, inform_extension *E) {
    -    if (t->amendment_of) return FALSE;
    -    heading *at_heading =
    -        Headings::of_wording(Node::get_text(t->table_created_at->source_table));
    -    inform_extension *at_E = Headings::get_extension_containing(at_heading);
    -    if (E == at_E) return TRUE;
    -    return FALSE;
    -}
    -
    - - -
    - - - diff --git a/docs/index-module/2-ve.html b/docs/index-module/2-ve.html index f2581602e..bdfa50933 100644 --- a/docs/index-module/2-ve.html +++ b/docs/index-module/2-ve.html @@ -188,7 +188,7 @@ the following: } diff --git a/docs/index-module/4-em.html b/docs/index-module/4-em.html index ae6d35547..d831a1f64 100644 --- a/docs/index-module/4-em.html +++ b/docs/index-module/4-em.html @@ -127,7 +127,7 @@ values inherited by sub-objects. int numeric_value; or numeric value, if appropriate to this type } plotting_parameter; - +

    §3. A set of variables associated with any map object is called a "scope". As implied above, the global scope is special: it contains the default settings passed down to all lower scopes. diff --git a/docs/index-module/index.html b/docs/index-module/index.html index 3dc446568..0221aada5 100644 --- a/docs/index-module/index.html +++ b/docs/index-module/index.html @@ -143,11 +143,6 @@ Phrasebook Index - To compile most of the HTML page for the Phrasebook index.

    -
  • -

    - Tables Element - - To index tables.

    -
  • Innards Element - diff --git a/docs/runtime-module/2-hrr.html b/docs/runtime-module/2-hrr.html index c46f994e8..24df73736 100644 --- a/docs/runtime-module/2-hrr.html +++ b/docs/runtime-module/2-hrr.html @@ -1378,6 +1378,12 @@ that the compiler can refer to it. enum TABLE_PNAME_MD_HL enum TABLE_VALUE_MD_HL enum RANKING_TABLE_MD_HL +enum TABLE_ROWS_MD_HL +enum TABLE_BLANK_ROWS_MD_HL +enum TABLE_BLANK_ROWS_FOR_MD_HL +enum TABLE_DEFINES_MD_HL +enum TABLE_DEFINES_TEXT_MD_HL +enum TABLE_DEFINES_AT_MD_HL enum TABLE_ID_HL enum TABLE_DATA_HL enum TABLE_COLUMN_USAGES_HAP @@ -1386,8 +1392,12 @@ that the compiler can refer to it. enum COLUMN_BITS_HL enum COLUMN_BLANKS_HL enum COLUMN_BLANK_DATA_HL +enum TABLE_CONTRIBUTION_HAP +enum TABLE_CONTRIBUTION_AT_MD_HL enum TABLE_COLUMNS_HAP enum TABLE_COLUMN_ID_HL +enum TABLE_COLUMN_NAME_MD_HL +enum TABLE_COLUMN_CONTENTS_MD_HL enum TABLE_COLUMN_KIND_MD_HL

    §8.1.42. Establish tables8.1.42 = @@ -1402,6 +1412,12 @@ that the compiler can refer to it. H_C_U(TABLE_PNAME_MD_HL, I"^printed_name") H_C_U(TABLE_VALUE_MD_HL, I"^value") H_C_U(RANKING_TABLE_MD_HL, I"^ranking_table") + H_C_U(TABLE_ROWS_MD_HL, I"^rows") + H_C_U(TABLE_BLANK_ROWS_MD_HL, I"^blank_rows") + H_C_U(TABLE_BLANK_ROWS_FOR_MD_HL, I"^blank_rows_for_each") + H_C_U(TABLE_DEFINES_MD_HL, I"^defines") + H_C_U(TABLE_DEFINES_TEXT_MD_HL, I"^defines_text") + H_C_U(TABLE_DEFINES_AT_MD_HL, I"^defines_at") H_C_U(TABLE_ID_HL, I"table_id") H_C_U(TABLE_DATA_HL, I"table_data") H_BEGIN_AP(TABLE_COLUMN_USAGES_HAP, I"column", I"_table_column_usage") @@ -1411,6 +1427,9 @@ that the compiler can refer to it. H_C_U(COLUMN_BLANKS_HL, I"column_blanks") H_C_U(COLUMN_BLANK_DATA_HL, I"^column_blank_data") H_END + H_BEGIN_AP(TABLE_CONTRIBUTION_HAP, I"contribution", I"_table_contribution") + H_C_U(TABLE_CONTRIBUTION_AT_MD_HL, I"^at") + H_END H_END H_END @@ -1418,7 +1437,9 @@ that the compiler can refer to it. H_BEGIN(HierarchyLocations::local_submodule(table_columns)) H_BEGIN_AP(TABLE_COLUMNS_HAP, I"table_column", I"_table_column") H_C_U(TABLE_COLUMN_ID_HL, I"table_column_id") - H_C_U(TABLE_COLUMN_KIND_MD_HL, I"^column_kind") + H_C_U(TABLE_COLUMN_NAME_MD_HL, I"^name") + H_C_U(TABLE_COLUMN_CONTENTS_MD_HL, I"^contents") + H_C_U(TABLE_COLUMN_KIND_MD_HL, I"^column_kind") H_END H_END @@ -1852,7 +1873,7 @@ will automatically trip, in order to enforce the layout rules.

    -package_request *Hierarchy::package_within(int hap_id, package_request *super) {
    +package_request *Hierarchy::package_within(int hap_id, package_request *super) {
         return HierarchyLocations::attach_new_package(Emit::tree(), NULL, super, hap_id);
     }
     
    @@ -1869,12 +1890,12 @@ point system, and for those:

    -void Hierarchy::apply_metadata(package_request *P, int id, text_stream *value) {
    +void Hierarchy::apply_metadata(package_request *P, int id, text_stream *value) {
         inter_name *iname = Hierarchy::make_iname_in(id, P);
         Emit::text_constant(iname, value);
     }
     
    -void Hierarchy::apply_metadata_from_number(package_request *P, int id, inter_ti N) {
    +void Hierarchy::apply_metadata_from_number(package_request *P, int id, inter_ti N) {
         inter_name *iname = Hierarchy::make_iname_in(id, P);
         Emit::numeric_constant(iname, N);
     }
    @@ -1891,7 +1912,7 @@ point system, and for those:
         DISCARD_TEXT(ANT)
     }
     
    -void Hierarchy::apply_metadata_from_raw_wording(package_request *P, int id, wording W) {
    +void Hierarchy::apply_metadata_from_raw_wording(package_request *P, int id, wording W) {
         TEMPORARY_TEXT(ANT)
         WRITE_TO(ANT, "%+W", W);
         Hierarchy::apply_metadata(P, id, ANT);
    diff --git a/docs/runtime-module/5-tbl.html b/docs/runtime-module/5-tbl.html
    index 504d62227..b2956798c 100644
    --- a/docs/runtime-module/5-tbl.html
    +++ b/docs/runtime-module/5-tbl.html
    @@ -421,6 +421,29 @@ case.)
         WRITE_TO(S, "%+W", Node::get_text(t->headline_fragment));
         Hierarchy::apply_metadata(RTTables::package(t), TABLE_PNAME_MD_HL, S);
         DISCARD_TEXT(S)
    +    for (table_contribution *tc = t->table_created_at; tc; tc = tc->next) {
    +        package_request *R =
    +            Hierarchy::package_within(TABLE_CONTRIBUTION_HAP,
    +                RTTables::package(t));
    +        Hierarchy::apply_metadata_from_number(R, TABLE_CONTRIBUTION_AT_MD_HL,
    +            (inter_ti) Wordings::first_wn(Node::get_text(tc->source_table)));
    +    }
    +    Hierarchy::apply_metadata_from_number(RTTables::package(t),
    +        TABLE_ROWS_MD_HL, (inter_ti) Tables::get_no_rows(t));
    +    Hierarchy::apply_metadata_from_number(RTTables::package(t),
    +        TABLE_BLANK_ROWS_MD_HL, (inter_ti) t->blank_rows);
    +    if (Wordings::nonempty(t->blank_rows_for_each_text))
    +        Hierarchy::apply_metadata_from_raw_wording(RTTables::package(t),
    +            TABLE_BLANK_ROWS_FOR_MD_HL, t->blank_rows_for_each_text);
    +    if (t->first_column_by_definition) {
    +        Hierarchy::apply_metadata_from_number(RTTables::package(t),
    +            TABLE_DEFINES_MD_HL, 1);
    +        Hierarchy::apply_metadata_from_raw_wording(RTTables::package(t),
    +            TABLE_DEFINES_TEXT_MD_HL, Node::get_text(t->where_used_to_define));
    +        Hierarchy::apply_metadata_from_number(RTTables::package(t),
    +            TABLE_DEFINES_AT_MD_HL,
    +            (inter_ti) Wordings::first_wn(Node::get_text(t->where_used_to_define)));
    +    }
     

    §3. The issue here is whether the value IMPROBABLE_VALUE can, despite its diff --git a/docs/runtime-module/5-tc.html b/docs/runtime-module/5-tc.html index 070f82633..77843322f 100644 --- a/docs/runtime-module/5-tc.html +++ b/docs/runtime-module/5-tc.html @@ -116,10 +116,16 @@ to the column-ID constant, and let the linker choose a value for that. void RTTableColumns::compile(void) { table_column *tc; LOOP_OVER(tc, table_column) { + package_request *pack = RTTableColumns::package(tc); Emit::numeric_constant(RTTableColumns::id_iname(tc), 0); placeholder value - inter_name *kind_iname = Hierarchy::make_iname_in(TABLE_COLUMN_KIND_MD_HL, - RTTableColumns::package(tc)); + inter_name *kind_iname = Hierarchy::make_iname_in(TABLE_COLUMN_KIND_MD_HL, pack); RTKindIDs::define_constant_as_strong_id(kind_iname, Tables::Columns::get_kind(tc)); + Hierarchy::apply_metadata_from_raw_wording(pack, + TABLE_COLUMN_NAME_MD_HL, Nouns::nominative_singular(tc->name)); + TEMPORARY_TEXT(conts) + Kinds::Textual::write_plural(conts, Tables::Columns::get_kind(tc)); + Hierarchy::apply_metadata(pack, TABLE_COLUMN_CONTENTS_MD_HL, conts); + DISCARD_TEXT(conts) } } diff --git a/inform7/Figures/memory-diagnostics.txt b/inform7/Figures/memory-diagnostics.txt index 2a5cbd2ef..4197f0378 100644 --- a/inform7/Figures/memory-diagnostics.txt +++ b/inform7/Figures/memory-diagnostics.txt @@ -1,9 +1,9 @@ -Total memory consumption was 307974K = 301 MB +Total memory consumption was 306408K = 299 MB -63.6% was used for 1531974 objects, in 321733 frames in 245 x 800K = 196000K = 191 MB: +63.4% was used for 1532416 objects, in 321779 frames in 243 x 800K = 194400K = 189 MB: 9.6% inter_tree_node_array 42 x 8192 = 344064 objects, 30278976 bytes - 6.2% text_stream_array 3498 x 100 = 349800 objects, 19700736 bytes + 6.2% text_stream_array 3502 x 100 = 350200 objects, 19723264 bytes 5.2% linked_list 29337 objects, 16428720 bytes 3.2% parse_node 129384 objects, 10350720 bytes 2.8% inter_symbol_array 92 x 1024 = 94208 objects, 9046912 bytes @@ -17,16 +17,16 @@ Total memory consumption was 307974K = 301 MB 0.5% inter_name_array 34 x 1000 = 34000 objects, 1633088 bytes 0.4% i6_schema_array 23 x 100 = 2300 objects, 1380736 bytes 0.4% match_trie_array 10 x 1000 = 10000 objects, 1360320 bytes + 0.3% inter_package 15571 objects, 1121112 bytes 0.3% inter_name_generator_array 28 x 1000 = 28000 objects, 1120896 bytes - 0.3% inter_package 15564 objects, 1120608 bytes 0.3% id_body 940 objects, 1075360 bytes 0.3% adjective_meaning 202 objects, 1000304 bytes - 0.3% dictionary 20756 objects, 996288 bytes - 0.3% inter_symbols_table 15564 objects, 996096 bytes + 0.3% dictionary 20763 objects, 996624 bytes + 0.3% inter_symbols_table 15571 objects, 996544 bytes 0.3% excerpt_meaning 3098 objects, 966576 bytes 0.2% dict_entry_array 282 x 100 = 28200 objects, 911424 bytes 0.2% production 3871 objects, 898072 bytes - 0.2% package_request 10140 objects, 892320 bytes + 0.2% package_request 10147 objects, 892936 bytes 0.2% ptoken 8379 objects, 871416 bytes 0.2% grammatical_usage 3610 objects, 866400 bytes 0.2% individual_form 2560 objects, 860160 bytes @@ -46,7 +46,7 @@ Total memory consumption was 307974K = 301 MB ---- rule_family_data 400 objects, 147200 bytes ---- index_lexicon_entry 395 objects, 142200 bytes ---- nonterminal 759 objects, 139656 bytes - ---- hierarchy_location 882 objects, 134064 bytes + ---- hierarchy_location 891 objects, 135432 bytes ---- nascent_array 1948 objects, 124672 bytes ---- documentation_ref 1274 objects, 112112 bytes ---- inference 1703 objects, 108992 bytes @@ -54,7 +54,7 @@ Total memory consumption was 307974K = 301 MB ---- anl_entry_array 2 x 1000 = 2000 objects, 96064 bytes ---- noun_usage 2401 objects, 96040 bytes ---- preposition 273 objects, 87360 bytes - ---- inter_tree 6 objects, 86160 bytes + ---- inter_tree 6 objects, 86640 bytes ---- lexical_cluster 2516 objects, 80512 bytes ---- pcalc_term_array 2 x 1000 = 2000 objects, 80064 bytes ---- kind_variable_declaration 1652 objects, 79296 bytes @@ -112,14 +112,14 @@ Total memory consumption was 307974K = 301 MB ---- pathname 292 objects, 11680 bytes ---- stopwatch_timer 108 objects, 8640 bytes ---- filename 208 objects, 8320 bytes - ---- uniqueness_count 334 objects, 8016 bytes + ---- uniqueness_count 338 objects, 8112 bytes ---- equation_node 68 objects, 7616 bytes ---- understanding_item_array 3 x 100 = 300 objects, 7296 bytes ---- shared_variable_array 1 x 100 objects, 7232 bytes ---- determiner 22 objects, 7216 bytes ---- verb 108 objects, 6048 bytes ---- text_literal_holder 144 objects, 5760 bytes - ---- hierarchy_attachment_point 55 objects, 5280 bytes + ---- hierarchy_attachment_point 56 objects, 5376 bytes ---- inbuild_work 78 objects, 4992 bytes ---- explicit_action_array 1 x 100 objects, 4832 bytes ---- value_property_data 84 objects, 4704 bytes @@ -236,16 +236,16 @@ Total memory consumption was 307974K = 301 MB ---- by_function_bp_data 1 object, 40 bytes ---- kind_template_definition 1 object, 40 bytes -36.3% was used for memory not allocated for objects: +36.5% was used for memory not allocated for objects: - 17.2% text stream storage 54533376 bytes in 362426 claims - 3.6% dictionary storage 11514368 bytes in 20756 claims + 17.3% text stream storage 54563284 bytes in 362764 claims + 3.6% dictionary storage 11517952 bytes in 20763 claims ---- sorting 712 bytes in 3 claims 2.2% source text 7200000 bytes in 3 claims 3.4% source text details 10800000 bytes in 2 claims ---- linguistic stock array 81920 bytes in 2 claims ---- small word set array 105600 bytes in 22 claims - 0.8% inter symbols storage 2692544 bytes in 16544 claims + 0.8% inter symbols storage 2693440 bytes in 16551 claims 5.3% inter bytecode storage 16802796 bytes in 14 claims 2.8% inter links storage 8866944 bytes in 265 claims ---- inter tree location list storage 166656 bytes in 26 claims @@ -255,5 +255,5 @@ Total memory consumption was 307974K = 301 MB ---- code generation workspace for objects 9648 bytes in 9 claims ---- emitter array storage 154432 bytes in 2037 claims -20.1% was overhead - 63571328 bytes = 62081K = 60 MB +19.7% was overhead - 61906456 bytes = 60455K = 59 MB diff --git a/inform7/Figures/timings-diagnostics.txt b/inform7/Figures/timings-diagnostics.txt index 3eae3c3e9..1150290ef 100644 --- a/inform7/Figures/timings-diagnostics.txt +++ b/inform7/Figures/timings-diagnostics.txt @@ -1,25 +1,24 @@ 100.0% in inform7 run - 54.1% in compilation to Inter - 40.0% in //Sequence::undertake_queued_tasks// - 4.1% in //MajorNodes::pre_pass// + 53.4% in compilation to Inter + 39.4% in //Sequence::undertake_queued_tasks// + 4.2% in //MajorNodes::pre_pass// 3.1% in //MajorNodes::pass_1// 1.7% in //ImperativeDefinitions::assess_all// 0.5% in //ImperativeDefinitions::compile_first_block// 0.5% in //MajorNodes::pass_2// 0.5% in //RTKindConstructors::compile// - 0.5% in //Sequence::undertake_queued_tasks// 0.5% in //World::stage_V// + 0.3% in //Sequence::undertake_queued_tasks// 0.1% in //InferenceSubjects::emit_all// 0.1% in //RTKindConstructors::compile_permissions// - 0.1% in //Sequence::undertake_queued_tasks// 0.1% in //Task::make_built_in_kind_constructors// 0.1% in //World::stages_II_and_III// - 1.7% not specifically accounted for - 43.6% in running Inter pipeline + 1.8% not specifically accounted for + 44.3% in running Inter pipeline 11.2% in inter step 7/14: consolidate-text 11.0% in step preparation - 9.1% in inter step 2/14: link - 7.4% in inter step 14/14: generate inform6 -> auto.inf + 9.4% in inter step 2/14: link + 7.5% in inter step 14/14: generate inform6 -> auto.inf 0.8% in inter step 10/14: make-identifiers-unique 0.3% in inter step 11/14: reconcile-verbs 0.3% in inter step 13/14: eliminate-redundant-operations @@ -29,6 +28,6 @@ 0.1% in inter step 5/14: resolve-conditional-compilation 0.1% in inter step 8/14: resolve-external-symbols 0.1% in inter step 9/14: inspect-plugs - 2.1% not specifically accounted for - 1.8% in supervisor + 2.3% not specifically accounted for + 1.9% in supervisor 0.4% not specifically accounted for diff --git a/inform7/Tests/Test Internals/Index-Tables.txt b/inform7/Tests/Test Internals/Index-Tables.txt new file mode 100644 index 000000000..ed3b4c647 --- /dev/null +++ b/inform7/Tests/Test Internals/Index-Tables.txt @@ -0,0 +1,38 @@ +Home is a room. + +A dynasty is a kind of value. The dynasties are Stuart, Hanover, Saxe-Coburg-Gotha +and Windsor. + +Table 4 - Recent Monarchs +Name Accession Family +"Anne" 1702 Stuart +"George I" 1714 Hanover +"George II" 1720 Hanover +"George III" 1760 Hanover +"George IV" 1820 Hanover +"William IV" 1830 Hanover +"Victoria" 1837 Hanover +"Edward VII" 1901 Saxe-Coburg-Gotha +"George V" 1910 Windsor +"Edward VIII" 1936 Windsor +"George VI" 1936 Windsor +"Elizabeth II" 1952 Windsor + +Table 2.1 - Selected Elements +Element Symbol Atomic number Atomic weight Mystery +"Hydrogen" "H" 1 1 { 2, 3, 6, 7 } +"Iron" "Fe" 26 56 -- +"Zinc" "Zn" 30 65 { 34, 151 } +"Uranium" "U" 92 238 { -4 } +with 3 blank rows + +A jersey is a kind of thing. A jersey is wearable. Some jerseys in the Home are defined by the Table of Honorary Jerseys. + +Table of Honorary Jerseys +jersey year established citation +a yellow jersey 1919 "race leader" +a polkadot jersey 1933 "King of the Mountains" +a green jersey 1953 "highest point scorer on sprints" +a white jersey 1975 "best cyclist aged 25 or less" + +Test index (internal) with Tb. diff --git a/inform7/Tests/Test Internals/_Results_Ideal/Index-Tables.txt b/inform7/Tests/Test Internals/_Results_Ideal/Index-Tables.txt new file mode 100644 index 000000000..7aa530112 --- /dev/null +++ b/inform7/Tests/Test Internals/_Results_Ideal/Index-Tables.txt @@ -0,0 +1,230 @@ +1. Tb + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + Table of Honorary Jerseys      + + 4 definitions +
    +   col 1:  Some jerseys in the Home      + + names +
    +   col 2:  sets citation      + + texts property +
    +   col 3:  sets jersey      + + objects property +
    + Table 4 - Recent Monarchs      + + 3 columns x 12 rows +
    +   col 1:  Name      + + of texts +
    +   col 2:  Accession      + + of numbers +
    +   col 3:  Family      + + of dynasties +
    + Table 2.1 - Selected Elements      + + 5 columns x 7 rows (3 blank) +
    +   col 1:  Element      + + of texts +
    +   col 2:  Symbol      + + of texts +
    +   col 3:  Atomic number      + + of numbers +
    +   col 4:  Atomic weight      + + of numbers +
    +   col 5:  Mystery      + + of lists of numbers +
    +

     Show tables inside extensions too

    + + diff --git a/inform7/index-module/Chapter 2/Tables Element.w b/inform7/index-module/Chapter 2/Tables Element.w deleted file mode 100644 index 9908d8983..000000000 --- a/inform7/index-module/Chapter 2/Tables Element.w +++ /dev/null @@ -1,133 +0,0 @@ -[IXTables::] Tables Element. - -To index tables. - -@h Indexing. -Tables inside extensions are often used just for the storage needed to manage -back-of-house algorithms, so to speak, and they aren't intended for the end -user to poke around with; that's certainly true of the tables in the Standard -Rules, which of course are always present. So these are hidden by default. - -= -void IXTables::render(OUTPUT_STREAM) { - HTML_OPEN("p"); - int m = IXTables::index_tables_in(OUT, NULL, 0); - HTML_CLOSE("p"); - HTML_OPEN("p"); - Index::extra_link(OUT, 2); - if (m > 0) WRITE("Show tables inside extensions too"); - else WRITE("Show tables inside extensions (there are none in the main text)"); - HTML_CLOSE("p"); - Index::extra_div_open(OUT, 2, 1, "e0e0e0"); - inform_extension *E; int efc = 0; - LOOP_OVER(E, inform_extension) IXTables::index_tables_in(OUT, E, efc++); - Index::extra_div_close(OUT, "e0e0e0"); -} - -@ This tabulates tables within a given extension, returning the number listed, -and does nothing at all if that number is 0. - -= -int IXTables::index_tables_in(OUTPUT_STREAM, inform_extension *E, int efc) { - int tc = 0; table *t; - LOOP_OVER(t, table) if (IXTables::table_within(t, E)) tc++; - if (tc > 0) { - if (E) { - HTML_OPEN("p"); - WRITE("%S", E->as_copy->edition->work->title); - HTML_CLOSE("p"); - } - HTML::begin_plain_html_table(OUT); - LOOP_OVER(t, table) - if (IXTables::table_within(t, E)) - @; - HTML::end_html_table(OUT); - } - return tc; -} - -@ The following probably ought to use a multiplication sign rather than a -Helvetica-style lower case "x", but life is full of compromises. - -@ = - HTML::first_html_column_spaced(OUT, 0); - WRITE("%+W", Node::get_text(t->headline_fragment)); - table_contribution *tc; int ntc = 0; - for (tc = t->table_created_at; tc; tc = tc->next) { - if (ntc++ > 0) WRITE(" +"); - Index::link(OUT, Wordings::first_wn(Node::get_text(tc->source_table))); - } - HTML::next_html_column_spaced(OUT, 0); - int rc = Tables::get_no_rows(t); - WRITE(""); - HTML_OPEN_WITH("span", "class=\"smaller\""); - if (t->first_column_by_definition) { - WRITE("%d definition%s", rc, - (rc == 1)?"":"s"); - } else { - WRITE("%d column%s x %d row%s", - t->no_columns, (t->no_columns == 1)?"":"s", - rc, (rc == 1)?"":"s"); - } - if (t->blank_rows > 0) { - WRITE(" (%d blank", t->blank_rows); - if (Wordings::nonempty(t->blank_rows_for_each_text)) - WRITE(", one for each %+W", t->blank_rows_for_each_text); - WRITE(")"); - } - HTML_CLOSE("span"); - WRITE(""); - HTML::end_html_row(OUT); - int col; - for (col = 0; col < t->no_columns; col++) { - HTML::first_html_column(OUT, 0); - WRITE("  col %d:  ", col+1); - wording CW = Nouns::nominative_singular(t->columns[col].column_identity->name); - if ((t->first_column_by_definition) && (col == 0)) { - parse_node *PN = t->where_used_to_define; - WRITE("%+W", Node::get_text(PN)); - Index::link(OUT, Wordings::first_wn(Node::get_text(PN))); - } else { - if (t->first_column_by_definition) WRITE("sets "); - WRITE("%+W ", CW); - TEMPORARY_TEXT(TEMP) - WRITE_TO(TEMP, "%+W", CW); - if (t->first_column_by_definition == FALSE) WRITE_TO(TEMP, " entry"); - PasteButtons::paste_text(OUT, TEMP); - DISCARD_TEXT(TEMP) - } - HTML::next_html_column(OUT, 0); - if ((t->first_column_by_definition) && (col == 0)) { - parse_node *cell; - int row; - for (row = 1, cell = t->columns[0].entries->down; cell; cell = cell->next, row++) { - if (row > 1) WRITE(", "); - WRITE("%+W", Node::get_text(cell)); - Index::link(OUT, Wordings::first_wn(Node::get_text(cell))); - } - } else if (t->first_column_by_definition) { - Kinds::Textual::write(OUT, - Tables::Columns::get_kind( - t->columns[col].column_identity)); - WRITE(" property"); - } else { - WRITE("of "); - Kinds::Textual::write_plural(OUT, - Tables::Columns::get_kind( - t->columns[col].column_identity)); - } - HTML::end_html_row(OUT); - } - -@ The following laboriously tests whether a table is defined within a -given extension: - -= -int IXTables::table_within(table *t, inform_extension *E) { - if (t->amendment_of) return FALSE; - heading *at_heading = - Headings::of_wording(Node::get_text(t->table_created_at->source_table)); - inform_extension *at_E = Headings::get_extension_containing(at_heading); - if (E == at_E) return TRUE; - return FALSE; -} diff --git a/inform7/index-module/Contents.w b/inform7/index-module/Contents.w index f3b180bf8..f60eced49 100644 --- a/inform7/index-module/Contents.w +++ b/inform7/index-module/Contents.w @@ -22,7 +22,6 @@ Chapter 2: Indexing Rules Activities Phrasebook Index - Tables Element Innards Element Rules for Scenes Element Arithmetic Element diff --git a/inform7/runtime-module/Chapter 2/Hierarchy.w b/inform7/runtime-module/Chapter 2/Hierarchy.w index f0fd3f81f..7061e8398 100644 --- a/inform7/runtime-module/Chapter 2/Hierarchy.w +++ b/inform7/runtime-module/Chapter 2/Hierarchy.w @@ -1214,6 +1214,12 @@ void Hierarchy::establish(void) { @e TABLE_PNAME_MD_HL @e TABLE_VALUE_MD_HL @e RANKING_TABLE_MD_HL +@e TABLE_ROWS_MD_HL +@e TABLE_BLANK_ROWS_MD_HL +@e TABLE_BLANK_ROWS_FOR_MD_HL +@e TABLE_DEFINES_MD_HL +@e TABLE_DEFINES_TEXT_MD_HL +@e TABLE_DEFINES_AT_MD_HL @e TABLE_ID_HL @e TABLE_DATA_HL @e TABLE_COLUMN_USAGES_HAP @@ -1222,9 +1228,13 @@ void Hierarchy::establish(void) { @e COLUMN_BITS_HL @e COLUMN_BLANKS_HL @e COLUMN_BLANK_DATA_HL +@e TABLE_CONTRIBUTION_HAP +@e TABLE_CONTRIBUTION_AT_MD_HL @e TABLE_COLUMNS_HAP @e TABLE_COLUMN_ID_HL +@e TABLE_COLUMN_NAME_MD_HL +@e TABLE_COLUMN_CONTENTS_MD_HL @e TABLE_COLUMN_KIND_MD_HL @ = @@ -1236,6 +1246,12 @@ void Hierarchy::establish(void) { H_C_U(TABLE_PNAME_MD_HL, I"^printed_name") H_C_U(TABLE_VALUE_MD_HL, I"^value") H_C_U(RANKING_TABLE_MD_HL, I"^ranking_table") + H_C_U(TABLE_ROWS_MD_HL, I"^rows") + H_C_U(TABLE_BLANK_ROWS_MD_HL, I"^blank_rows") + H_C_U(TABLE_BLANK_ROWS_FOR_MD_HL, I"^blank_rows_for_each") + H_C_U(TABLE_DEFINES_MD_HL, I"^defines") + H_C_U(TABLE_DEFINES_TEXT_MD_HL, I"^defines_text") + H_C_U(TABLE_DEFINES_AT_MD_HL, I"^defines_at") H_C_U(TABLE_ID_HL, I"table_id") H_C_U(TABLE_DATA_HL, I"table_data") H_BEGIN_AP(TABLE_COLUMN_USAGES_HAP, I"column", I"_table_column_usage") @@ -1245,6 +1261,9 @@ void Hierarchy::establish(void) { H_C_U(COLUMN_BLANKS_HL, I"column_blanks") H_C_U(COLUMN_BLANK_DATA_HL, I"^column_blank_data") H_END + H_BEGIN_AP(TABLE_CONTRIBUTION_HAP, I"contribution", I"_table_contribution") + H_C_U(TABLE_CONTRIBUTION_AT_MD_HL, I"^at") + H_END H_END H_END @@ -1252,7 +1271,9 @@ void Hierarchy::establish(void) { H_BEGIN(HierarchyLocations::local_submodule(table_columns)) H_BEGIN_AP(TABLE_COLUMNS_HAP, I"table_column", I"_table_column") H_C_U(TABLE_COLUMN_ID_HL, I"table_column_id") - H_C_U(TABLE_COLUMN_KIND_MD_HL, I"^column_kind") + H_C_U(TABLE_COLUMN_NAME_MD_HL, I"^name") + H_C_U(TABLE_COLUMN_CONTENTS_MD_HL, I"^contents") + H_C_U(TABLE_COLUMN_KIND_MD_HL, I"^column_kind") H_END H_END diff --git a/inform7/runtime-module/Chapter 5/Table Columns.w b/inform7/runtime-module/Chapter 5/Table Columns.w index 9facce553..a841778a8 100644 --- a/inform7/runtime-module/Chapter 5/Table Columns.w +++ b/inform7/runtime-module/Chapter 5/Table Columns.w @@ -44,9 +44,15 @@ to the column-ID constant, and let the linker choose a value for that. void RTTableColumns::compile(void) { table_column *tc; LOOP_OVER(tc, table_column) { + package_request *pack = RTTableColumns::package(tc); Emit::numeric_constant(RTTableColumns::id_iname(tc), 0); /* placeholder value */ - inter_name *kind_iname = Hierarchy::make_iname_in(TABLE_COLUMN_KIND_MD_HL, - RTTableColumns::package(tc)); + inter_name *kind_iname = Hierarchy::make_iname_in(TABLE_COLUMN_KIND_MD_HL, pack); RTKindIDs::define_constant_as_strong_id(kind_iname, Tables::Columns::get_kind(tc)); + Hierarchy::apply_metadata_from_raw_wording(pack, + TABLE_COLUMN_NAME_MD_HL, Nouns::nominative_singular(tc->name)); + TEMPORARY_TEXT(conts) + Kinds::Textual::write_plural(conts, Tables::Columns::get_kind(tc)); + Hierarchy::apply_metadata(pack, TABLE_COLUMN_CONTENTS_MD_HL, conts); + DISCARD_TEXT(conts) } } diff --git a/inform7/runtime-module/Chapter 5/Tables.w b/inform7/runtime-module/Chapter 5/Tables.w index c28563c93..8bf0b8814 100644 --- a/inform7/runtime-module/Chapter 5/Tables.w +++ b/inform7/runtime-module/Chapter 5/Tables.w @@ -288,6 +288,29 @@ case.) WRITE_TO(S, "%+W", Node::get_text(t->headline_fragment)); Hierarchy::apply_metadata(RTTables::package(t), TABLE_PNAME_MD_HL, S); DISCARD_TEXT(S) + for (table_contribution *tc = t->table_created_at; tc; tc = tc->next) { + package_request *R = + Hierarchy::package_within(TABLE_CONTRIBUTION_HAP, + RTTables::package(t)); + Hierarchy::apply_metadata_from_number(R, TABLE_CONTRIBUTION_AT_MD_HL, + (inter_ti) Wordings::first_wn(Node::get_text(tc->source_table))); + } + Hierarchy::apply_metadata_from_number(RTTables::package(t), + TABLE_ROWS_MD_HL, (inter_ti) Tables::get_no_rows(t)); + Hierarchy::apply_metadata_from_number(RTTables::package(t), + TABLE_BLANK_ROWS_MD_HL, (inter_ti) t->blank_rows); + if (Wordings::nonempty(t->blank_rows_for_each_text)) + Hierarchy::apply_metadata_from_raw_wording(RTTables::package(t), + TABLE_BLANK_ROWS_FOR_MD_HL, t->blank_rows_for_each_text); + if (t->first_column_by_definition) { + Hierarchy::apply_metadata_from_number(RTTables::package(t), + TABLE_DEFINES_MD_HL, 1); + Hierarchy::apply_metadata_from_raw_wording(RTTables::package(t), + TABLE_DEFINES_TEXT_MD_HL, Node::get_text(t->where_used_to_define)); + Hierarchy::apply_metadata_from_number(RTTables::package(t), + TABLE_DEFINES_AT_MD_HL, + (inter_ti) Wordings::first_wn(Node::get_text(t->where_used_to_define))); + } @ The issue here is whether the value |IMPROBABLE_VALUE| can, despite its improbability, be valid for this kind. If we can prove that it is not, we diff --git a/inter/codegen-module/Chapter 6/Index File Services.w b/inter/codegen-module/Chapter 6/Index File Services.w index 1f4bcadfa..e853cd7e5 100644 --- a/inter/codegen-module/Chapter 6/Index File Services.w +++ b/inter/codegen-module/Chapter 6/Index File Services.w @@ -142,7 +142,6 @@ text_stream *Index::open_file(text_stream *index_leaf, text_stream *title, int s } ifl = &index_file_struct; text_stream *OUT = ifl; -LOG("Index: %f\n", F); @; HTML::header(OUT, title, @@ -665,12 +664,12 @@ void Index::index_actual_element(OUTPUT_STREAM, text_stream *elt) { FiguresElement::render(OUT); return; } - - #ifdef CORE_MODULE if (Str::eq_wide_string(elt, L"Tb")) { - IXTables::render(OUT); + TablesElement::render(OUT); return; } + + #ifdef CORE_MODULE if (Str::eq_wide_string(elt, L"In")) { IXInnards::render(OUT, Supervisor::current_vm()); return; diff --git a/inter/codegen-module/Chapter 6/Tables Element.w b/inter/codegen-module/Chapter 6/Tables Element.w new file mode 100644 index 000000000..30c5010ad --- /dev/null +++ b/inter/codegen-module/Chapter 6/Tables Element.w @@ -0,0 +1,159 @@ +[TablesElement::] Tables Element. + +To write the Tables element (Tb) in the index. + +@h Indexing. +Tables inside extensions are often used just for the storage needed to manage +back-of-house algorithms, so to speak, and they aren't intended for the end +user to poke around with; that's certainly true of the tables in the Standard +Rules, which of course are always present. So these are hidden by default. + += +void TablesElement::render(OUTPUT_STREAM) { + inter_tree *I = Index::get_tree(); + tree_inventory *inv = Synoptic::inv(I); + TreeLists::sort(inv->table_nodes, Synoptic::category_order); + + inter_package *current_mod = NULL; int mc = 0, first_ext = TRUE; + inter_ti cat = 1, open_cat = 0; + for (inter_ti with_cat = 1; with_cat <= 3; with_cat++) { + for (int i=0; itable_nodes); i++) { + inter_package *mod = Synoptic::module_containing(inv->table_nodes->list[i].node); + if (mod == NULL) continue; + cat = Metadata::read_optional_numeric(mod, I"^category"); + if (cat == with_cat) { + if ((mc == 0) || (mod != current_mod)) { + @; + mc++; current_mod = mod; + @; + } + inter_package *pack = Inter::Package::defined_by_frame(inv->table_nodes->list[i].node); + @; + } + } + } + @; +} + +@ = + if (cat > 1) { + if (first_ext) { + HTML_OPEN("p"); + Index::extra_link(OUT, 2); + if (mc > 1) WRITE("Show tables inside extensions too"); + else WRITE("Show tables inside extensions (there are none in the main text)"); + HTML_CLOSE("p"); + first_ext = FALSE; + } + Index::extra_div_open(OUT, 2, 1, "e0e0e0"); + HTML_OPEN("p"); + WRITE("%S", Metadata::read_textual(mod, I"^title")); + HTML_CLOSE("p"); + } + open_cat = cat; + HTML::begin_plain_html_table(OUT); + +@ = + if (mc > 0) { + HTML::end_html_table(OUT); + if (open_cat > 1) Index::extra_div_close(OUT, "e0e0e0"); + } + +@ The following probably ought to use a multiplication sign rather than a +Helvetica-style lower case "x", but life is full of compromises. + +@ = + HTML::first_html_column_spaced(OUT, 0); + WRITE("%S", Metadata::read_textual(pack, I"^printed_name")); + int ntc = 0; + 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) == PackageTypes::get(I, I"_table_contribution")) { + if (ntc++ > 0) WRITE(" +"); + int at = (int) Metadata::read_optional_numeric(entry, I"^at"); + Index::link(OUT, at); + } + } + } + HTML::next_html_column_spaced(OUT, 0); + + int nc = 0; + 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) == PackageTypes::get(I, I"_table_column_usage")) + nc++; + } + } + int nr = (int) Metadata::read_numeric(pack, I"^rows"); + int nb = (int) Metadata::read_numeric(pack, I"^blank_rows"); + int defines = (int) Metadata::read_optional_numeric(pack, I"^defines"); + text_stream *for_each = Metadata::read_optional_textual(pack, I"^blank_rows_for_each"); + + WRITE(""); + HTML_OPEN_WITH("span", "class=\"smaller\""); + if (defines) { + WRITE("%d definition%s", nr, (nr == 1)?"":"s"); + } else { + WRITE("%d column%s x %d row%s", nc, (nc == 1)?"":"s", nr, (nr == 1)?"":"s"); + } + if (nb > 0) { + WRITE(" (%d blank", nb); + if (Str::len(for_each) > 0) WRITE(", one for each %S", for_each); + WRITE(")"); + } + HTML_CLOSE("span"); + WRITE(""); + + HTML::end_html_row(OUT); + + int col = 0; + 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) == PackageTypes::get(I, I"_table_column_usage")) { + inter_tree_node *ID = Synoptic::get_definition(entry, I"column_identity"); + inter_symbol *id_s = NULL; + if (ID->W.data[DATA_CONST_IFLD] == ALIAS_IVAL) + id_s = InterSymbolsTables::symbol_from_id(Inter::Packages::scope(entry), ID->W.data[DATA_CONST_IFLD+1]); + if (id_s == NULL) internal_error("column_identity not an ALIAS_IVAL"); + inter_package *col_pack = Inter::Packages::container(id_s->definition); + LOG("Whellll... $6\n", col_pack); + + HTML::first_html_column(OUT, 0); + WRITE("  col %d:  ", col+1); + @; + HTML::next_html_column(OUT, 0); + @; + HTML::end_html_row(OUT); + col++; + } + } + } + +@ = + text_stream *CW = Metadata::read_optional_textual(col_pack, I"^name"); + if ((defines) && (col == 0)) { + WRITE("%S", Metadata::read_optional_textual(pack, I"^defines_text")); + int at = (int) Metadata::read_optional_numeric(pack, I"^defines_at"); + Index::link(OUT, at); + } else { + if (defines) WRITE("sets "); + WRITE("%S ", CW); + TEMPORARY_TEXT(TEMP) + WRITE_TO(TEMP, "%S", CW); + if (defines == FALSE) WRITE_TO(TEMP, " entry"); + PasteButtons::paste_text(OUT, TEMP); + DISCARD_TEXT(TEMP) + } + +@ = + if ((defines) && (col == 0)) { + WRITE("names"); + } else if (defines) { + WRITE("%S property", Metadata::read_optional_textual(col_pack, I"^contents")); + } else { + WRITE("of %S", Metadata::read_optional_textual(col_pack, I"^contents")); + } diff --git a/inter/codegen-module/Contents.w b/inter/codegen-module/Contents.w index 59e8c2703..92de5e6b0 100644 --- a/inter/codegen-module/Contents.w +++ b/inter/codegen-module/Contents.w @@ -68,3 +68,4 @@ Chapter 6: Index Relations Element Events Element Figures Element + Tables Element