§1. Public API. This is a large and complex module of code, but it really only does one thing,
+and so it is simple to control. Other modules or tools should do this only by
+calling the functions below.
+
+
+
To produce one or more index products (see below), first open a session; then
+set its localisation — essentially, choose what language it should be written
+in; then call functions to make the actual products; and finally close the session.
+Note that:
+
+
+
(1) If you want to index the same tree of code to two different languages, you
+will need to do this as two sessions. However, an Index website and an EPS map
+which are in the same language can both be made in the same session, and this
+is more efficient than using two.
+
(2) Only one session can be open at a time. In some abstract sense it would be tidy
+to make this whole module threadsafe, but in concrete terms, it's hard to see
+what problem that would solve for anyone. If a user needs to make multiple
+indexes simultaneously, the simplest way would be to start multiple inter
+processes, each working on one project at a time. However, the API is designed
+so that this decision could be reversed if we wanted to.
+
The structure index_session is accessed in 2/fi and here.
+
§3. Now localising. You can either set an existing dictionary which you happen
+to have to hand, or else ask to read definitions from a file. See Localisation (in html)
+for how all of this works.
+
+
+
+voidIndexing::set_localisation_dictionary(index_session *session, localisation_dictionary *LD) {
+Check this is an open session3.5;
+session->dict = LD;
+}
+
+voidIndexing::localise(index_session *session, filename *F) {
+Check this is an open session3.5;
+Localisation::stock_from_file(F, session->dict);
+}
+
+
§3.1. Now for the productive part. You can make an entire index mini-website with
+the following function, which may generate several hundred HTML files. This is
+what is used in the Inform GUI apps on every compilation.
+
§3.2. This is a one-off function for generating the content of an index element
+(without its heading, or any HTML surround): it's used for unit-testing those
+elements, but is never used by the Inform GUI app.
+
§3.3. This is used by the Inform GUI apps to "release along with an EPS file".
+Essentially it makes a print-suitable version of the Map element of the index,
+though there are also many bells and whistles for customising the appearance
+of this.
+
§3.4. And lastly closing. The only thing this now does is to enable a new session
+to be opened afterwards, in fact, but that might change in future.
+
+
+
+voidIndexing::close_session(index_session *session) {
+Check this is an open session3.5;
+session->session_closed = TRUE;
+index_sessions_open--;
+}
+
This code is used in §3 (twice), §3.1, §3.2, §3.3, §3.4, §4 (three times), §5 (three times).
+
§4. Private API. The remaining functions in this section are for use only within the index
+module.
+
+
+
+inter_tree *Indexing::get_tree(index_session *session) {
+Check this is an open session3.5;
+returnsession->tree;
+}
+
+localisation_dictionary *Indexing::get_localisation(index_session *session) {
+Check this is an open session3.5;
+returnsession->dict;
+}
+
+tree_inventory *Indexing::get_inventory(index_session *session) {
+Check this is an open session3.5;
+returnsession->inv;
+}
+
+
§5. These more substantial resources are calculated only on demand:
+
+
+
+inter_lexicon *Indexing::get_lexicon(index_session *session) {
+Check this is an open session3.5;
+if (session->indexing_lexicon == NULL)
+session->indexing_lexicon = IndexLexicon::stock(session->tree, session->inv);
+returnsession->indexing_lexicon;
+}
+
+faux_instance_set *Indexing::get_set_of_instances(index_session *session) {
+Check this is an open session3.5;
+if (session->indexing_fis == NULL) FauxInstances::make_faux(session);
+returnsession->indexing_fis;
+}
+
+linked_list *Indexing::get_list_of_scenes(index_session *session) {
+Check this is an open session3.5;
+if (session->indexing_fs == NULL)
+session->indexing_fs = FauxScenes::list_of_faux_scenes(session);
+returnsession->indexing_fs;
+}
+
+
+
+
+
+
+
diff --git a/docs/index-module/1-im.html b/docs/index-module/1-im.html
index a22b86093..178e43886 100644
--- a/docs/index-module/1-im.html
+++ b/docs/index-module/1-im.html
@@ -93,7 +93,8 @@ which use this module:
§3.
-
enumindex_page_CLASS
+
enumindex_session_CLASS
+enumindex_page_CLASSenumindex_element_CLASSenuminter_lexicon_CLASSenumindex_lexicon_entry_CLASS
@@ -108,6 +109,7 @@ which use this module:
enumrubric_holder_CLASS
+DECLARE_CLASS(index_session)DECLARE_CLASS(index_element)DECLARE_CLASS(index_page)DECLARE_CLASS(inter_lexicon)
@@ -123,7 +125,7 @@ which use this module:
DECLARE_CLASS(rubric_holder)
diff --git a/docs/index-module/2-fi.html b/docs/index-module/2-fi.html
index 2e37ab197..2a6222c07 100644
--- a/docs/index-module/2-fi.html
+++ b/docs/index-module/2-fi.html
@@ -256,10 +256,11 @@ we may need to keep multiple sets of faux instances, one for each tree. So:
-faux_instance_set *FauxInstances::make_faux(inter_tree *IT) {
+voidFauxInstances::make_faux(index_session *session) {faux_instance_set *faux_set = FauxInstances::new_empty_set();
+session->indexing_fis = faux_set;
-tree_inventory *inv = Synoptic::inv(IT);
+tree_inventory *inv = Indexing::get_inventory(session);TreeLists::sort(inv->instance_nodes, Synoptic::module_order);inter_package *pack;LOOP_OVER_INVENTORY_PACKAGES(pack, i, inv->instance_nodes)
@@ -275,8 +276,7 @@ we may need to keep multiple sets of faux instances, one for each tree. So:
if (FauxInstances::is_a_door(I)) Cross-reference door adjacencies8.6; }
-FauxInstances::decode_hints(faux_set, IT, 1);
-returnfaux_set;
+FauxInstances::decode_hints(session, 1);}
§8.1. Add a faux instance to the set for this object-instance package8.1 =
@@ -402,7 +402,9 @@ and only if needed.
-voidFauxInstances::decode_hints(faux_instance_set *faux_set, inter_tree *I, intpass) {
+voidFauxInstances::decode_hints(index_session *session, intpass) {
+faux_instance_set *faux_set = Indexing::get_set_of_instances(session);
+inter_tree *I = Indexing::get_tree(session);inter_package *pack = Inter::Packages::by_url(I, I"/main/completion/mapping_hints");inter_package *hint_pack;LOOP_THROUGH_SUBPACKAGES(hint_pack, pack, I"_mapping_hint") {
@@ -492,7 +494,7 @@ can only be known once the spatial grid has been found, i.e., on EPS_map_level *eml;LOOP_OVER(eml, EPS_map_level)if ((eml->contains_rooms)
- && (eml->map_level - SpatialMap::benchmark_level() == scope_level))
+ && (eml->map_level - SpatialMap::benchmark_level(session) == scope_level))scope = &(eml->map_parameters);if (scope) ConfigureIndexMap::put_mp(name, scope, scope_I, text_val, int_val);
@@ -500,38 +502,38 @@ can only be known once the spatial grid has been found, i.e., on §11. Instance set properties.
§1. The index is generated by a bare-bones structure file. These are identified
by name: in particular Basic is the barer version, for Basic Inform projects,
@@ -104,20 +104,19 @@ by the function ArithmeticElement::ren
The method here is basically to read all the declarations, generating a set
-of index_page and index_element objects to represent them, and only to
+of index_page and index_element objects to represent them, and only to
begin writing some HTML when this scanning is done, i.e., when the whole structure
file has been read.
§3. This is a one-off function for generating the content of an index element
-(without its heading, or any HTML surround): it's used for unit-testing those
-elements.
-
diff --git a/docs/index-module/2-lxc.html b/docs/index-module/2-lxc.html
index abe49a633..d65cfa642 100644
--- a/docs/index-module/2-lxc.html
+++ b/docs/index-module/2-lxc.html
@@ -125,11 +125,10 @@ order, then sorted.
-inter_lexicon *IndexLexicon::stock(inter_tree *I) {
+inter_lexicon *IndexLexicon::stock(inter_tree *I, tree_inventory *inv) {inter_lexicon *lexicon = CREATE(inter_lexicon);lexicon->first = NULL;lexicon->unsorted = NEW_LINKED_LIST(index_lexicon_entry);
-tree_inventory *inv = Synoptic::inv(I);Add verb entries3.1;Add preposition entries3.2;Add adjective entries3.3;
diff --git a/docs/index-module/2-sas.html b/docs/index-module/2-sas.html
index 87c638594..8a88f8730 100644
--- a/docs/index-module/2-sas.html
+++ b/docs/index-module/2-sas.html
@@ -72,17 +72,21 @@ failing to link to said files correctly.
But it means every HTML page in the index has to embed its own CSS and
Javascript, and this is done with a callback function which allows us to insert
-material into the head of an HTML page when it is opened for output:
+material into the head of an HTML page when it is opened for output. Note that
+the function acts only when the page was created with state, which will only
+happen when it was created by index.
§1.1. The CSS is mostly the same every time and is therefore mostly loaded from an
diff --git a/docs/index-module/3-ae.html b/docs/index-module/3-ae.html
index 00e252894..79595119a 100644
--- a/docs/index-module/3-ae.html
+++ b/docs/index-module/3-ae.html
@@ -76,9 +76,9 @@ function togglePopup(material_id) {
-voidAlphabeticElement::render(OUTPUT_STREAM, localisation_dictionary *LD) {
-inter_tree *I = InterpretIndex::get_tree();
-tree_inventory *inv = Synoptic::inv(I);
+voidAlphabeticElement::render(OUTPUT_STREAM, index_session *session) {
+localisation_dictionary *LD = Indexing::get_localisation(session);
+tree_inventory *inv = Indexing::get_inventory(session);TreeLists::sort(inv->action_nodes, AlphabeticElement::alphabetical_order);HTML::begin_html_table(OUT, NULL, FALSE, 0, 0, 0, 0, 0);
diff --git a/docs/index-module/3-ae2.html b/docs/index-module/3-ae2.html
index f46a942b8..0b2b7ddba 100644
--- a/docs/index-module/3-ae2.html
+++ b/docs/index-module/3-ae2.html
@@ -77,9 +77,9 @@ so we do little more than tabulate that data here.
diff --git a/docs/index-module/3-ie.html b/docs/index-module/3-ie.html
index 71255acec..332b53454 100644
--- a/docs/index-module/3-ie.html
+++ b/docs/index-module/3-ie.html
@@ -77,9 +77,10 @@ technical implementation rather than the content of a work.
diff --git a/docs/index-module/3-me.html b/docs/index-module/3-me.html
index 914fb2116..418fc55d4 100644
--- a/docs/index-module/3-me.html
+++ b/docs/index-module/3-me.html
@@ -81,16 +81,17 @@ cues all of that up; but even that code is fairly long.
@@ -182,7 +183,7 @@ will be things which are offstage (and their contents and any parts thereof):
Localisation::bold(OUT, LD, I"Index.Elements.Mp.NowhereHeading");HTML_TAG("br"); }
-MapElement::index(OUT, I, 2, FALSE, LD);
+MapElement::index(OUT, I, 2, FALSE, session); }suppress_panel_changes = FALSE;
@@ -212,7 +213,8 @@ will be things which are offstage (and their contents and any parts thereof):
}voidMapElement::index(OUTPUT_STREAM, faux_instance *I, intdepth, intdetails,
-localisation_dictionary *LD) {
+index_session *session) {
+localisation_dictionary *LD = Indexing::get_localisation(session);if (depth == MAX_OBJECT_INDEX_DEPTH) internal_error("MAX_OBJECT_INDEX_DEPTH exceeded");if (I) {if (depth > NUMBER_CREATED(faux_instance) + 1) return; to recover from errors
@@ -233,7 +235,7 @@ will be things which are offstage (and their contents and any parts thereof):
Add the chain of kinds2.8;Add the catalogue of specific properties2.9;Add details depending on the kind2.10;
-MapElement::index_usages(OUT, I, LD);
+MapElement::index_usages(OUT, I, session);IndexUtilities::extra_div_close(OUT, "e0e0e0"); }Recurse the index citation for the object as necessary2.6;
@@ -248,7 +250,7 @@ will be things which are offstage (and their contents and any parts thereof):
if (I != indexing_room) IndexUtilities::anchor(OUT, I->anchor_text); } else { #ifdefIF_MODULE
-if (I) MapElement::index_spatial_relationship(OUT, I, LD);
+if (I) MapElement::index_spatial_relationship(OUT, I, session); #endif }
@@ -303,8 +305,8 @@ will be things which are offstage (and their contents and any parts thereof):
-voidMapElement::index_usages(OUTPUT_STREAM, faux_instance *I, localisation_dictionary *LD) {
+voidMapElement::index_usages(OUTPUT_STREAM, faux_instance *I, index_session *session) {
+localisation_dictionary *LD = Indexing::get_localisation(session);intk = 0;inter_package *pack = I->package;inter_tree_node *P = Metadata::read_optional_list(pack, I"^backdrop_presences");
@@ -401,9 +404,10 @@ will be things which are offstage (and their contents and any parts thereof):
if (k > 0) HTML_CLOSE("p");}
-intMapElement::add_room_to_World_index(OUTPUT_STREAM, faux_instance *O) {
+intMapElement::add_room_to_World_index(OUTPUT_STREAM, faux_instance *O,
+index_session *session) {if ((O) && (FauxInstances::is_a_room(O))) {
-SpatialMap::index_room_connections(OUT, O);
+SpatialMap::index_room_connections(OUT, O, session); }returnFALSE;}
@@ -417,8 +421,9 @@ will be things which are offstage (and their contents and any parts thereof):
}intMapElement::annotate_player(OUTPUT_STREAM, faux_instance *I,
-localisation_dictionary *LD) {
-if (I == FauxInstances::start_room()) {
+index_session *session) {
+localisation_dictionary *LD = Indexing::get_localisation(session);
+if (I == FauxInstances::start_room(session)) {WRITE(" - ");Localisation::italic(OUT, LD, I"Index.Elements.Mp.RoomWherePlayBegins");DocReferences::link(OUT, I"ROOMPLAYBEGINS");
@@ -428,7 +433,8 @@ will be things which are offstage (and their contents and any parts thereof):
}intMapElement::annotate_door(OUTPUT_STREAM, faux_instance *O,
-localisation_dictionary *LD) {
+index_session *session) {
+localisation_dictionary *LD = Indexing::get_localisation(session);if ((O) && (FauxInstances::is_a_door(O))) {faux_instance *A = NULL, *B = NULL;FauxInstances::get_door_data(O, &A, &B);
@@ -451,7 +457,8 @@ will be things which are offstage (and their contents and any parts thereof):
voidMapElement::index_spatial_relationship(OUTPUT_STREAM, faux_instance *I,
-localisation_dictionary *LD) {
+index_session *session) {
+localisation_dictionary *LD = Indexing::get_localisation(session);text_stream *rel = NULL;faux_instance *P = FauxInstances::progenitor(I);if (P) {
@@ -482,18 +489,18 @@ it already turns up under its owner.
§1.2. Show the legend for the scene table icons1.2 =
@@ -154,7 +151,7 @@ about and created but never made use of.)
IndexUtilities::anchor(OUT, I"SDETAILS");simplified_scene *ssc;
-LOOP_OVER(ssc, simplified_scene) {
+LOOP_OVER_LINKED_LIST(ssc, simplified_scene, L) {HTML_TAG("hr");Give details of a specific scene1.3.1; }
@@ -334,7 +331,8 @@ on the initial call when dept
§4.1. The following cuts the text down to the abbreviation length by knocking out,
+
§3.1. The following cuts the text down to the abbreviation length by knocking out,
in sequence: (a) lower-case vowels; (b) spaces; (c) lower-case consonants; (d)
punctuation marks. If that doesn't do it, the text is simply truncated. For
example, "Peisey-Nancroix" abbreviated to 10 is "Pesy-Nncrx" and to 5
is "PsyNn".
-
Abbreviate the text to be printed by stripping dispensable letters4.1 =
+
Abbreviate the text to be printed by stripping dispensable letters3.1 =
@@ -595,12 +594,12 @@ is "PsyNn".
RemoveOne:Str::delete_nth_character(txt, j); }
§6. Circles and rectangles. In EPS files, there's an imaginary pen which traces out "paths". These begin
+
§5. Circles and rectangles. In EPS files, there's an imaginary pen which traces out "paths". These begin
whenever the pen moves to a new location, and then continue until they are
closed (joined up back to the start position) with a closepath command.
-voidRenderEPSMap::EPS_compile_circular_path(OUTPUT_STREAM, intx0, inty0, intradius) {
+voidRenderEPSMap::EPS_compile_circular_path(OUTPUT_STREAM, intx0, inty0, intradius) {WRITE("%d %d moveto %% rightmost point\n", x0+radius, y0);WRITE("%d %d %d %d %d arc %% full circle traced anticlockwise\n",x0, y0, radius, 0, 360);WRITE("closepath\n");}
-voidRenderEPSMap::EPS_compile_rectangular_path(OUTPUT_STREAM, intx0, inty0,
+voidRenderEPSMap::EPS_compile_rectangular_path(OUTPUT_STREAM, intx0, inty0,intx1, inty1) {WRITE("%d %d moveto %% bottom left corner\n", x0, y0);WRITE("%d %d lineto %% bottom side\n", x1, y0);
@@ -630,38 +629,38 @@ closed (joined up back to the start position) with a WRITE("closepath\n");}
-
§7. The boundary of a room is always one of these:
+
§6. The boundary of a room is always one of these:
-voidRenderEPSMap::EPS_compile_dashed_arrow(OUTPUT_STREAM, intlength, vectorDir,
+voidRenderEPSMap::EPS_compile_dashed_arrow(OUTPUT_STREAM, intlength, vectorDir,intx0, inty0) {WRITE("[2 1] 0 setdash %% dashed line for arrow\n");WRITE("%d %d moveto %% room centre\n", x0, y0);
@@ -670,13 +669,13 @@ closed (joined up back to the start position) with a WRITE("[] 0 setdash %% back to normal solid lines\n");}
§13. RGB colours. Inform internally stores colours as six hexadecimal digits, in traditional
+
§12. RGB colours. Inform internally stores colours as six hexadecimal digits, in traditional
HTML way: RRGGBB, with each colour from 0 to 255. In EPS files, colours
are written as triples of floating point numbers \(0 \leq b \leq 1\).
@@ -727,16 +726,16 @@ are written as triples of floating point numbers \(0 \leq b \leq 1\).
-voidRenderEPSMap::EPS_compile_set_colour(OUTPUT_STREAM, text_stream *htmlcolour) {
+voidRenderEPSMap::EPS_compile_set_colour(OUTPUT_STREAM, text_stream *htmlcolour) {if (Str::len(htmlcolour) != 6) internal_error("Improper HTML colour");
-RenderEPSMap::choose_colour_beam(OUT, Str::get_at(htmlcolour, 0), Str::get_at(htmlcolour, 1));
-RenderEPSMap::choose_colour_beam(OUT, Str::get_at(htmlcolour, 2), Str::get_at(htmlcolour, 3));
-RenderEPSMap::choose_colour_beam(OUT, Str::get_at(htmlcolour, 4), Str::get_at(htmlcolour, 5));
+RenderEPSMap::choose_colour_beam(OUT, Str::get_at(htmlcolour, 0), Str::get_at(htmlcolour, 1));
+RenderEPSMap::choose_colour_beam(OUT, Str::get_at(htmlcolour, 2), Str::get_at(htmlcolour, 3));
+RenderEPSMap::choose_colour_beam(OUT, Str::get_at(htmlcolour, 4), Str::get_at(htmlcolour, 5));WRITE("setrgbcolor %% From HTML colour %S\n", htmlcolour);}voidRenderEPSMap::choose_colour_beam(OUTPUT_STREAM, inthex1, inthex2) {
-intk = RenderEPSMap::hex_to_int(hex1)*16 + RenderEPSMap::hex_to_int(hex2);
+intk = RenderEPSMap::hex_to_int(hex1)*16 + RenderEPSMap::hex_to_int(hex2);WRITE("%.6g ", (double) (((float) k)/255.0));}
@@ -763,11 +762,11 @@ are written as triples of floating point numbers \(0 \leq b \leq 1\).
return0;}
-
§14. EPS also supports greyscale, where there's only one beam:
+
§13. EPS also supports greyscale, where there's only one beam:
diff --git a/docs/index-module/4-rhm.html b/docs/index-module/4-rhm.html
index baa195f2d..0943b773a 100644
--- a/docs/index-module/4-rhm.html
+++ b/docs/index-module/4-rhm.html
@@ -115,8 +115,8 @@ this icon position, and has the same indexing as the icon grid.
faux_instance **room_grid = NULL;int *icon_grid = NULL, *exit_grid = NULL;
-voidHTMLMap::calculate_map_grid(void) {
-faux_instance_set *faux_set = InterpretIndex::get_faux_instances();
+voidHTMLMap::calculate_map_grid(index_session *session) {
+faux_instance_set *faux_set = Indexing::get_set_of_instances(session);Allocate the three mapping grids1.1;Populate the room grid1.2;Populate the icon and exit grids1.3;
@@ -551,14 +551,15 @@ the details part of the World Index page) will be all right.
-intSpatialMap::opposite(intstory_direction) {
+intSpatialMap::opposite(intstory_direction) {if ((story_direction < 0) || (story_direction >= MAX_DIRECTIONS)) return0;intpage_direction = story_dir_to_page_dir[story_direction];switch(page_direction) {
@@ -445,7 +446,7 @@ we use these hard-wired macros instead.
defineLOOP_OVER_DIRECTION_NUMBERS(i)for (i=0; i<12; i++)defineLOOP_OVER_STORY_DIRECTIONS(i)
-for (i=0; ((i<FauxInstances::no_directions()) && (i<MAX_DIRECTIONS)); i++)
+for (i=0; ((i<FauxInstances::no_directions(session)) && (i<MAX_DIRECTIONS)); i++)defineLOOP_OVER_LATTICE_DIRECTIONS(i)for (i=0; i<10; i++)defineLOOP_OVER_NONLATTICE_DIRECTIONS(i)
@@ -529,7 +530,7 @@ door, which we take a note of if asked to do so.
-faux_instance *SpatialMap::room_exit(faux_instance *origin, intdir_num,
+faux_instance *SpatialMap::room_exit(faux_instance *origin, intdir_num,faux_instance **via) {if (via) *via = NULL;if ((origin == NULL) || (FauxInstances::is_a_room(origin) == FALSE) ||
@@ -770,7 +771,7 @@ boundaries, and will be needed when we place submaps on the global grid.
-connected_submap *SpatialMap::new_submap(void) {
+connected_submap *SpatialMap::new_submap(index_session *session) {connected_submap *sub = CREATE(connected_submap);sub->bounds = Geometry::empty_cuboid();sub->first_room_in_submap = NULL;
@@ -778,6 +779,7 @@ boundaries, and will be needed when we place submaps on the global grid.
sub->incidence_cache = NULL;sub->incidence_cache_bounds = Geometry::empty_cuboid();sub->superpositions = 0;
+sub->for_session = session;returnsub;}
@@ -968,7 +970,7 @@ since its rooms have all moved out.
§7.24. The following grows a component outwards from at, so that it also includes
@@ -1033,21 +1035,21 @@ each room, so phase (2) has running time \(O(R)\).
§7.31.1.2. The drill square is a way to place large numbers of single-room components,
@@ -2752,7 +2754,7 @@ one big component.
sub->allocation_id, sub->bounds.population);if (drill_square_side == 0) {Drill_square_O =
-Geometry::vec(box.corner1.x + 1, box.corner0.y, SpatialMap::benchmark_level());
+Geometry::vec(box.corner1.x + 1, box.corner0.y, SpatialMap::benchmark_level(session));Drill_square_At = Drill_square_O;connected_submap *sing;intN = 0;
@@ -2788,7 +2790,7 @@ with.
SpatialMap::find_link_to_placed_components(sub, &outer, &inner);vectorBest_offset =Geometry::vec(x_max, box.corner0.y - sub->bounds.corner0.y,
-SpatialMap::benchmark_level() - sub->bounds.corner0.z);
+SpatialMap::benchmark_level(session) - sub->bounds.corner0.z);if ((outer) && (inner)) {intdx = 0, dy = 0, dz = 0, min_s = FUSION_POINT;for (dx = -MAX_OFFSET; dx <= MAX_OFFSET; dx++)
@@ -2931,7 +2933,7 @@ rooms connected that way are by definition in the same component.
intSpatialMap::cross_component_links(connected_submap *sub, faux_instance **outer,faux_instance **inner, int *heat, intposnd) {
-faux_instance_set *faux_set = InterpretIndex::get_faux_instances();
+faux_instance_set *faux_set = Indexing::get_set_of_instances(sub->for_session);intno_links = 0;if (heat) *heat = 0;faux_instance *R;
@@ -3084,9 +3086,10 @@ locking means that blank planes are inevitable.
§42.
-voidSpatialMap::index_room_connections(OUTPUT_STREAM, faux_instance *R) {
+voidSpatialMap::index_room_connections(OUTPUT_STREAM, faux_instance *R,
+index_session *session) {text_stream *RW = FauxInstances::get_name(R); name of the origin room
-faux_instance_set *faux_set = InterpretIndex::get_faux_instances();
+faux_instance_set *faux_set = Indexing::get_set_of_instances(session);faux_instance *dir;LOOP_OVER_FAUX_DIRECTIONS(faux_set, dir) {inti = dir->direction_index;
@@ -3165,7 +3168,7 @@ locking means that blank planes are inevitable.
§43. Unit testing.
-voidSpatialMap::perform_map_internal_test(OUTPUT_STREAM) {
+voidSpatialMap::perform_map_internal_test(OUTPUT_STREAM, index_session *session) {connected_submap *sub;LOOP_OVER(sub, connected_submap) {WRITE("Map component %d: extent (%d...%d, %d...%d, %d...%d): population %d\n",
@@ -3181,7 +3184,7 @@ locking means that blank planes are inevitable.
Room_position(R).y,Room_position(R).z);FauxInstances::write_name(OUT, R);
-if (R == FauxInstances::benchmark()) WRITE(" (benchmark)");
+if (R == FauxInstances::benchmark(session)) WRITE(" (benchmark)");WRITE("\n"); }WRITE("\n");
diff --git a/docs/index-module/index.html b/docs/index-module/index.html
index e7c07262d..b271ab5d7 100644
--- a/docs/index-module/index.html
+++ b/docs/index-module/index.html
@@ -71,6 +71,11 @@
Index Module -
Setting up the use of this module.
+
+
+ Indexing API -
+ How the parent tool can ask for an Inter tree to be indexed.
+
diff --git a/docs/supervisor-module/7-ip.html b/docs/supervisor-module/7-ip.html
index 053a6ad86..2ebad86e4 100644
--- a/docs/supervisor-module/7-ip.html
+++ b/docs/supervisor-module/7-ip.html
@@ -89,7 +89,7 @@ function togglePopup(material_id) {
HTML::header(OUT, I"Extensions",InstalledFiles::filename(CSS_FOR_STANDARD_PAGES_IRES),
-InstalledFiles::filename(JAVASCRIPT_FOR_EXTENSIONS_IRES));
+InstalledFiles::filename(JAVASCRIPT_FOR_EXTENSIONS_IRES), NULL);Write the body of the HTML1.1;STREAM_CLOSE(OUT);HTML::footer(OUT);
diff --git a/docs/supervisor-module/7-ip2.html b/docs/supervisor-module/7-ip2.html
index 35d1a2941..e9ce7db12 100644
--- a/docs/supervisor-module/7-ip2.html
+++ b/docs/supervisor-module/7-ip2.html
@@ -165,7 +165,7 @@ our E, and return 0 in response to the ECD call to prevent further ECD calls.
HTML::header(OUT, I"Extension",InstalledFiles::filename(CSS_FOR_STANDARD_PAGES_IRES),
-InstalledFiles::filename(JAVASCRIPT_FOR_ONE_EXTENSION_IRES));
+InstalledFiles::filename(JAVASCRIPT_FOR_ONE_EXTENSION_IRES), NULL);HTML::incorporate_HTML(OUT,InstalledFiles::filename(EXTENSION_DOCUMENTATION_MODEL_IRES));Write documentation for a specific extension into the page2.2.1;
diff --git a/inbuild/supervisor-module/Chapter 7/Index Pages.w b/inbuild/supervisor-module/Chapter 7/Index Pages.w
index bbb682059..6ad8bda47 100644
--- a/inbuild/supervisor-module/Chapter 7/Index Pages.w
+++ b/inbuild/supervisor-module/Chapter 7/Index Pages.w
@@ -17,7 +17,7 @@ void ExtensionIndex::write(filename *F, int content, extension_census *C) {
HTML::header(OUT, I"Extensions",
InstalledFiles::filename(CSS_FOR_STANDARD_PAGES_IRES),
- InstalledFiles::filename(JAVASCRIPT_FOR_EXTENSIONS_IRES));
+ InstalledFiles::filename(JAVASCRIPT_FOR_EXTENSIONS_IRES), NULL);
@;
STREAM_CLOSE(OUT);
HTML::footer(OUT);
diff --git a/inbuild/supervisor-module/Chapter 7/Individual Pages.w b/inbuild/supervisor-module/Chapter 7/Individual Pages.w
index 604eefa40..95031b88b 100644
--- a/inbuild/supervisor-module/Chapter 7/Individual Pages.w
+++ b/inbuild/supervisor-module/Chapter 7/Individual Pages.w
@@ -84,7 +84,7 @@ our E, and return 0 in response to the ECD call to prevent further ECD calls.
@ =
HTML::header(OUT, I"Extension",
InstalledFiles::filename(CSS_FOR_STANDARD_PAGES_IRES),
- InstalledFiles::filename(JAVASCRIPT_FOR_ONE_EXTENSION_IRES));
+ InstalledFiles::filename(JAVASCRIPT_FOR_ONE_EXTENSION_IRES), NULL);
HTML::incorporate_HTML(OUT,
InstalledFiles::filename(EXTENSION_DOCUMENTATION_MODEL_IRES));
@;
diff --git a/inform7/Figures/memory-diagnostics.txt b/inform7/Figures/memory-diagnostics.txt
index a58ff5812..b46b8c281 100644
--- a/inform7/Figures/memory-diagnostics.txt
+++ b/inform7/Figures/memory-diagnostics.txt
@@ -175,11 +175,11 @@ Total memory consumption was 391746K = 383 MB
---- target_vm 6 objects, 816 bytes
---- generated_segment 25 objects, 800 bytes
---- inter_data_type 14 objects, 784 bytes
- ---- internal_test 14 objects, 672 bytes
---- inform_language 6 objects, 672 bytes
+ ---- internal_test 14 objects, 672 bytes
+ ---- inter_warehouse_room 10 objects, 640 bytes
---- I6T_intervention 8 objects, 640 bytes
---- relation_guard 5 objects, 640 bytes
- ---- inter_warehouse_room 10 objects, 640 bytes
---- inbuild_search_result 15 objects, 600 bytes
---- rulebook_outcome 17 objects, 544 bytes
---- small_word_set 11 objects, 528 bytes
@@ -193,43 +193,43 @@ Total memory consumption was 391746K = 383 MB
---- bp_family 12 objects, 384 bytes
---- source_file 5 objects, 360 bytes
---- inbuild_genre 7 objects, 336 bytes
- ---- door_dir_notice 5 objects, 320 bytes
---- grammatical_category 8 objects, 320 bytes
+ ---- door_dir_notice 5 objects, 320 bytes
---- pronoun 8 objects, 320 bytes
---- tree_inventory 1 object, 312 bytes
- ---- build_step 4 objects, 288 bytes
---- up_family 9 objects, 288 bytes
- ---- compilation_unit 5 objects, 280 bytes
+ ---- build_step 4 objects, 288 bytes
---- door_to_notice 5 objects, 280 bytes
- ---- contents_entry 7 objects, 280 bytes
+ ---- compilation_unit 5 objects, 280 bytes
---- explicit_bp_data 5 objects, 280 bytes
+ ---- contents_entry 7 objects, 280 bytes
---- inform_pipeline 4 objects, 256 bytes
---- verb_usage_tier 5 objects, 240 bytes
---- adjective_meaning_family 7 objects, 224 bytes
---- test_scenario 1 object, 216 bytes
---- release_instructions 1 object, 208 bytes
---- build_skill 5 objects, 200 bytes
- ---- kit_dependency 4 objects, 192 bytes
---- plural_dictionary_entry 4 objects, 192 bytes
+ ---- kit_dependency 4 objects, 192 bytes
---- inform_project 1 object, 176 bytes
---- inference_subject_family 5 objects, 160 bytes
---- inter_architecture 4 objects, 160 bytes
- ---- code_generation_target 4 objects, 160 bytes
---- link_instruction 4 objects, 160 bytes
+ ---- code_generation_target 4 objects, 160 bytes
---- imperative_defn_family 4 objects, 160 bytes
- ---- element_activation 4 objects, 128 bytes
---- codegen_pipeline 1 object, 128 bytes
+ ---- element_activation 4 objects, 128 bytes
---- inbuild_nest 3 objects, 120 bytes
---- local_block_value 2 objects, 112 bytes
---- inform_kit_ittt 2 objects, 96 bytes
---- group_together_function 2 objects, 80 bytes
---- compile_task_data 1 object, 80 bytes
---- article 2 objects, 80 bytes
- ---- figures_data 1 object, 56 bytes
---- build_methodology 1 object, 56 bytes
---- inter_warehouse 1 object, 56 bytes
- ---- HTML_file_state 1 object, 48 bytes
+ ---- figures_data 1 object, 56 bytes
---- star_invention 1 object, 48 bytes
+ ---- HTML_file_state 1 object, 48 bytes
---- kind_template_definition 1 object, 40 bytes
---- loop_over_scope 1 object, 40 bytes
---- by_function_bp_data 1 object, 40 bytes
diff --git a/inform7/Figures/timings-diagnostics.txt b/inform7/Figures/timings-diagnostics.txt
index 9784981c8..2bcd6ce37 100644
--- a/inform7/Figures/timings-diagnostics.txt
+++ b/inform7/Figures/timings-diagnostics.txt
@@ -11,26 +11,26 @@
0.4% in //Sequence::undertake_queued_tasks//
0.4% in //Sequence::undertake_queued_tasks//
0.4% in //World::stage_V//
- 0.1% in //CompletionModule::compile//
+ 0.2% in //CompletionModule::compile//
0.1% in //InferenceSubjects::emit_all//
0.1% in //RTKindConstructors::compile_permissions//
0.1% in //Task::make_built_in_kind_constructors//
0.1% in //World::stages_II_and_III//
- 2.0% not specifically accounted for
- 42.2% in running Inter pipeline
- 11.3% in step preparation
- 9.9% in inter step 7/14: consolidate-text
- 8.1% in inter step 2/14: link
- 6.9% in inter step 14/14: generate inform6 -> auto.inf
+ 1.9% not specifically accounted for
+ 42.0% in running Inter pipeline
+ 11.2% in step preparation
+ 9.8% in inter step 7/14: consolidate-text
+ 8.2% in inter step 2/14: link
+ 7.0% in inter step 14/14: generate inform6 -> auto.inf
1.6% in inter step 10/14: make-identifiers-unique
0.4% in inter step 11/14: reconcile-verbs
0.2% in inter step 13/14: eliminate-redundant-operations
0.2% in inter step 6/14: assimilate
0.2% in inter step 8/14: resolve-external-symbols
- 0.2% in inter step 9/14: inspect-plugs
0.1% in inter step 12/14: eliminate-redundant-labels
0.1% in inter step 4/14: parse-linked-matter
0.1% in inter step 5/14: resolve-conditional-compilation
- 2.1% not specifically accounted for
+ 0.1% in inter step 9/14: inspect-plugs
+ 2.0% not specifically accounted for
1.7% in supervisor
- 0.2% not specifically accounted for
+ 0.3% not specifically accounted for
diff --git a/inform7/core-module/Chapter 1/Internal Test Cases.w b/inform7/core-module/Chapter 1/Internal Test Cases.w
index 43fb02743..2326a6a22 100644
--- a/inform7/core-module/Chapter 1/Internal Test Cases.w
+++ b/inform7/core-module/Chapter 1/Internal Test Cases.w
@@ -216,11 +216,11 @@ void InternalTests::perform_ing_internal_test(OUTPUT_STREAM,
void InternalTests::perform_index_internal_test(OUTPUT_STREAM,
struct internal_test_case *itc) {
- localisation_dictionary *D = Localisation::new();
+ index_session *session = Indexing::open_session(Emit::tree());
inform_language *L = Projects::get_language_of_index(Task::project());
- Localisation::stock_from_file(
- Filenames::in(Languages::path_to_bundle(L), I"Index.txt"), D);
- InterpretIndex::generate_one_element(OUT, Emit::tree(), itc->text_supplying_the_case, D);
+ Indexing::localise(session, Filenames::in(Languages::path_to_bundle(L), I"Index.txt"));
+ Indexing::generate_one_element(session, OUT, itc->text_supplying_the_case);
+ Indexing::close_session(session);
}
@ And here's a set of six tests of the kinds system. This is quite old code,
diff --git a/inform7/core-module/Chapter 1/What To Compile.w b/inform7/core-module/Chapter 1/What To Compile.w
index ac362c483..e8bd9ea57 100644
--- a/inform7/core-module/Chapter 1/What To Compile.w
+++ b/inform7/core-module/Chapter 1/What To Compile.w
@@ -444,20 +444,17 @@ void Task::disable_or_enable_census(int which) {
void Task::produce_index(void) {
inform_project *project = Task::project();
if ((do_not_generate_index == FALSE) || (write_EPS_format_map)) {
+ index_session *session = Indexing::open_session(Emit::tree());
inform_language *L = Projects::get_language_of_index(project);
- localisation_dictionary *D = Localisation::new();
- Localisation::stock_from_file(
- Filenames::in(Languages::path_to_bundle(L), I"Index.txt"), D);
+ Indexing::localise(session,
+ Filenames::in(Languages::path_to_bundle(L), I"Index.txt"));
if (do_not_generate_index == FALSE) {
- InterpretIndex::generate(
- Emit::tree(),
- Projects::index_structure(project),
- D);
+ Indexing::generate_index_website(session, Projects::index_structure(project));
if (do_not_update_census == FALSE)
ExtensionWebsite::index_after_compilation(Task::project());
}
- if (write_EPS_format_map) {
- RenderEPSMap::render_map_as_EPS(Task::epsmap_file(), D);
- }
+ if (write_EPS_format_map)
+ Indexing::generate_EPS_map(session, Task::epsmap_file());
+ Indexing::close_session(session);
}
}
diff --git a/inform7/core-module/Chapter 2/Using Problems.w b/inform7/core-module/Chapter 2/Using Problems.w
index d3b21a9eb..ba210f3f1 100644
--- a/inform7/core-module/Chapter 2/Using Problems.w
+++ b/inform7/core-module/Chapter 2/Using Problems.w
@@ -18,7 +18,7 @@ void Problems::Using::start_problems_report(filename *F, text_stream *P) {
Problems::fatal_on_file("Can't open problem log", F);
HTML::header(P, I"Translating the Source",
InstalledFiles::filename(CSS_FOR_STANDARD_PAGES_IRES),
- InstalledFiles::filename(JAVASCRIPT_FOR_STANDARD_PAGES_IRES));
+ InstalledFiles::filename(JAVASCRIPT_FOR_STANDARD_PAGES_IRES), NULL);
}
void Problems::Using::final_report(int disaster_struck, int problems_count) {
diff --git a/inter/index-module/Chapter 1/Index Module.w b/inter/index-module/Chapter 1/Index Module.w
index d1f7971fa..9ccf56bc0 100644
--- a/inter/index-module/Chapter 1/Index Module.w
+++ b/inter/index-module/Chapter 1/Index Module.w
@@ -30,6 +30,7 @@ void IndexModule::end(void) {
@
+@e index_session_CLASS
@e index_page_CLASS
@e index_element_CLASS
@e inter_lexicon_CLASS
@@ -45,6 +46,7 @@ void IndexModule::end(void) {
@e rubric_holder_CLASS
=
+DECLARE_CLASS(index_session)
DECLARE_CLASS(index_element)
DECLARE_CLASS(index_page)
DECLARE_CLASS(inter_lexicon)
diff --git a/inter/index-module/Chapter 1/Indexing API.w b/inter/index-module/Chapter 1/Indexing API.w
new file mode 100644
index 000000000..e1de6faa3
--- /dev/null
+++ b/inter/index-module/Chapter 1/Indexing API.w
@@ -0,0 +1,158 @@
+[Indexing::] Indexing API.
+
+How the parent tool can ask for an Inter tree to be indexed.
+
+@h Public API.
+This is a large and complex module of code, but it really only does one thing,
+and so it is simple to control. Other modules or tools should do this only by
+calling the functions below.
+
+To produce one or more index products (see below), first open a session; then
+set its localisation -- essentially, choose what language it should be written
+in; then call functions to make the actual products; and finally close the session.
+Note that:
+
+(1) If you want to index the same tree of code to two different languages, you
+will need to do this as two sessions. However, an Index website and an EPS map
+which are in the same language can both be made in the same session, and this
+is more efficient than using two.
+
+(2) Only one session can be open at a time. In some abstract sense it would be tidy
+to make this whole module threadsafe, but in concrete terms, it's hard to see
+what problem that would solve for anyone. If a user needs to make multiple
+indexes simultaneously, the simplest way would be to start multiple |inter|
+processes, each working on one project at a time. However, the API is designed
+so that this decision could be reversed if we wanted to.
+
+@ So, then, opening:
+
+=
+typedef struct index_session {
+ struct inter_tree *tree;
+ struct tree_inventory *inv;
+ struct inter_lexicon *indexing_lexicon;
+ struct faux_instance_set *indexing_fis;
+ struct linked_list *indexing_fs;
+ struct localisation_dictionary *dict;
+ int session_closed;
+ CLASS_DEFINITION
+} index_session;
+
+int index_sessions_open = 0;
+
+index_session *Indexing::open_session(inter_tree *I) {
+ if (I == NULL) internal_error("no tree to index");
+ if (index_sessions_open++ > 0) internal_error("one indexing session at a time");
+ index_session *session = CREATE(index_session);
+ session->tree = I;
+ session->inv = Synoptic::inv(I);
+ session->indexing_lexicon = NULL;
+ session->indexing_fis = NULL;
+ session->indexing_fs = NULL;
+ session->dict = Localisation::new();
+ session->session_closed = FALSE;
+ return session;
+}
+
+@ Now localising. You can either set an existing dictionary which you happen
+to have to hand, or else ask to read definitions from a file. See //html: Localisation//
+for how all of this works.
+
+=
+void Indexing::set_localisation_dictionary(index_session *session, localisation_dictionary *LD) {
+ @;
+ session->dict = LD;
+}
+
+void Indexing::localise(index_session *session, filename *F) {
+ @;
+ Localisation::stock_from_file(F, session->dict);
+}
+
+@ Now for the productive part. You can make an entire index mini-website with
+the following function, which may generate several hundred HTML files. This is
+what is used in the Inform GUI apps on every compilation.
+
+=
+void Indexing::generate_index_website(index_session *session, text_stream *structure) {
+ @;
+ InterpretIndex::generate(structure, session);
+}
+
+@ This is a one-off function for generating the content of an index element
+(without its heading, or any HTML surround): it's used for unit-testing those
+elements, but is never used by the Inform GUI app.
+
+=
+void Indexing::generate_one_element(index_session *session, text_stream *OUT, wording elt) {
+ @;
+ Elements::test_card(OUT, elt, session);
+}
+
+@ This is used by the Inform GUI apps to "release along with an EPS file".
+Essentially it makes a print-suitable version of the Map element of the index,
+though there are also many bells and whistles for customising the appearance
+of this.
+
+=
+void Indexing::generate_EPS_map(index_session *session, filename *F) {
+ @;
+ RenderEPSMap::render_map_as_EPS(F, session);
+}
+
+@ And lastly closing. The only thing this now does is to enable a new session
+to be opened afterwards, in fact, but that might change in future.
+
+=
+void Indexing::close_session(index_session *session) {
+ @;
+ session->session_closed = TRUE;
+ index_sessions_open--;
+}
+
+@ =
+ if (session == NULL) internal_error("no indexing session");
+ if (session->session_closed) internal_error("closed indexing session");
+
+@h Private API.
+The remaining functions in this section are for use only within the //index//
+module.
+
+=
+inter_tree *Indexing::get_tree(index_session *session) {
+ @;
+ return session->tree;
+}
+
+localisation_dictionary *Indexing::get_localisation(index_session *session) {
+ @;
+ return session->dict;
+}
+
+tree_inventory *Indexing::get_inventory(index_session *session) {
+ @;
+ return session->inv;
+}
+
+@ These more substantial resources are calculated only on demand:
+
+=
+inter_lexicon *Indexing::get_lexicon(index_session *session) {
+ @;
+ if (session->indexing_lexicon == NULL)
+ session->indexing_lexicon = IndexLexicon::stock(session->tree, session->inv);
+ return session->indexing_lexicon;
+}
+
+faux_instance_set *Indexing::get_set_of_instances(index_session *session) {
+ @;
+ if (session->indexing_fis == NULL) FauxInstances::make_faux(session);
+ return session->indexing_fis;
+}
+
+linked_list *Indexing::get_list_of_scenes(index_session *session) {
+ @;
+ if (session->indexing_fs == NULL)
+ session->indexing_fs = FauxScenes::list_of_faux_scenes(session);
+ return session->indexing_fs;
+}
diff --git a/inter/index-module/Chapter 2/Faux Instances.w b/inter/index-module/Chapter 2/Faux Instances.w
index 39766b88a..34608726c 100644
--- a/inter/index-module/Chapter 2/Faux Instances.w
+++ b/inter/index-module/Chapter 2/Faux Instances.w
@@ -176,10 +176,11 @@ faux_instance_set *FauxInstances::new_empty_set(void) {
@ And here is the code to make a fully cross-referenced set from a given tree:
=
-faux_instance_set *FauxInstances::make_faux(inter_tree *IT) {
+void FauxInstances::make_faux(index_session *session) {
faux_instance_set *faux_set = FauxInstances::new_empty_set();
+ session->indexing_fis = faux_set;
- tree_inventory *inv = Synoptic::inv(IT);
+ tree_inventory *inv = Indexing::get_inventory(session);
TreeLists::sort(inv->instance_nodes, Synoptic::module_order);
inter_package *pack;
LOOP_OVER_INVENTORY_PACKAGES(pack, i, inv->instance_nodes)
@@ -195,8 +196,7 @@ faux_instance_set *FauxInstances::make_faux(inter_tree *IT) {
if (FauxInstances::is_a_door(I)) @;
}
- FauxInstances::decode_hints(faux_set, IT, 1);
- return faux_set;
+ FauxInstances::decode_hints(session, 1);
}
@ =
@@ -296,7 +296,9 @@ being made; |pass| 2 only after the spatial grid layout has been calculated,
and only if needed.
=
-void FauxInstances::decode_hints(faux_instance_set *faux_set, inter_tree *I, int pass) {
+void FauxInstances::decode_hints(index_session *session, int pass) {
+ faux_instance_set *faux_set = Indexing::get_set_of_instances(session);
+ inter_tree *I = Indexing::get_tree(session);
inter_package *pack = Inter::Packages::by_url(I, I"/main/completion/mapping_hints");
inter_package *hint_pack;
LOOP_THROUGH_SUBPACKAGES(hint_pack, pack, I"_mapping_hint") {
@@ -367,36 +369,36 @@ can only be known once the spatial grid has been found, i.e., on |pass| 2.
EPS_map_level *eml;
LOOP_OVER(eml, EPS_map_level)
if ((eml->contains_rooms)
- && (eml->map_level - SpatialMap::benchmark_level() == scope_level))
+ && (eml->map_level - SpatialMap::benchmark_level(session) == scope_level))
scope = &(eml->map_parameters);
if (scope) ConfigureIndexMap::put_mp(name, scope, scope_I, text_val, int_val);
@h Instance set properties.
=
-faux_instance *FauxInstances::start_room(void) {
- faux_instance_set *faux_set = InterpretIndex::get_faux_instances();
+faux_instance *FauxInstances::start_room(index_session *session) {
+ faux_instance_set *faux_set = Indexing::get_set_of_instances(session);
return faux_set->start_faux_instance;
}
-faux_instance *FauxInstances::yourself(void) {
- faux_instance_set *faux_set = InterpretIndex::get_faux_instances();
+faux_instance *FauxInstances::yourself(index_session *session) {
+ faux_instance_set *faux_set = Indexing::get_set_of_instances(session);
return faux_set->faux_yourself;
}
-faux_instance *FauxInstances::benchmark(void) {
- faux_instance_set *faux_set = InterpretIndex::get_faux_instances();
+faux_instance *FauxInstances::benchmark(index_session *session) {
+ faux_instance_set *faux_set = Indexing::get_set_of_instances(session);
return faux_set->faux_benchmark;
}
@ =
-int FauxInstances::no_directions(void) {
- faux_instance_set *faux_set = InterpretIndex::get_faux_instances();
+int FauxInstances::no_directions(index_session *session) {
+ faux_instance_set *faux_set = Indexing::get_set_of_instances(session);
return faux_set->no_direction_fi;
}
-int FauxInstances::no_rooms(void) {
- faux_instance_set *faux_set = InterpretIndex::get_faux_instances();
+int FauxInstances::no_rooms(index_session *session) {
+ faux_instance_set *faux_set = Indexing::get_set_of_instances(session);
return faux_set->no_room_fi;
}
diff --git a/inter/index-module/Chapter 2/Faux Scenes.w b/inter/index-module/Chapter 2/Faux Scenes.w
index 54448a034..8ee8a156d 100644
--- a/inter/index-module/Chapter 2/Faux Scenes.w
+++ b/inter/index-module/Chapter 2/Faux Scenes.w
@@ -30,6 +30,19 @@ typedef struct simplified_connector {
CLASS_DEFINITION
} simplified_connector;
+linked_list *FauxScenes::list_of_faux_scenes(index_session *session) {
+ linked_list *L = NEW_LINKED_LIST(simplified_scene);
+ inter_tree *I = Indexing::get_tree(session);
+ tree_inventory *inv = Indexing::get_inventory(session);
+ TreeLists::sort(inv->scene_nodes, PlotElement::scene_order);
+ TreeLists::sort(inv->rulebook_nodes, Synoptic::module_order);
+
+ inter_package *scene_pack;
+ LOOP_OVER_INVENTORY_PACKAGES(scene_pack, i, inv->scene_nodes)
+ ADD_TO_LINKED_LIST(FauxScenes::simplified(I, scene_pack), simplified_scene, L);
+ return L;
+}
+
simplified_scene *FauxScenes::simplified(inter_tree *I, inter_package *sc_pack) {
simplified_scene *ssc = CREATE(simplified_scene);
ssc->pack = sc_pack;
diff --git a/inter/index-module/Chapter 2/Index Interpreter.w b/inter/index-module/Chapter 2/Index Interpreter.w
index 58f80f768..9a41a3cc7 100644
--- a/inter/index-module/Chapter 2/Index Interpreter.w
+++ b/inter/index-module/Chapter 2/Index Interpreter.w
@@ -32,14 +32,13 @@ begin writing some HTML when this scanning is done, i.e., when the whole structu
file has been read.
=
-void InterpretIndex::generate(inter_tree *I, text_stream *structure, localisation_dictionary *D) {
- InterpretIndex::set_tree(I);
+void InterpretIndex::generate(text_stream *structure, index_session *session) {
+ localisation_dictionary *D = Indexing::get_localisation(session);
filename *index_structure = InstalledFiles::index_structure_file(structure);
index_generation_state igs;
@;
@;
@;
- InterpretIndex::set_tree(NULL);
}
@ This little structure is just some state being carried by the reader-function
@@ -47,13 +46,13 @@ which goes through the |.indext| file line by line.
=
typedef struct index_generation_state {
- struct localisation_dictionary *dict;
+ struct index_session *session;
struct linked_list *pages; /* of |index_page| */
} index_generation_state;
@ =
igs.pages = NEW_LINKED_LIST(index_page);
- igs.dict = D;
+ igs.session = session;
@ =
TextFiles::read(index_structure, FALSE, "unable to read index structure file", TRUE,
@@ -71,7 +70,7 @@ pages.
=
void InterpretIndex::read_structure(text_stream *text, text_file_position *tfp, void *state) {
index_generation_state *igs = (index_generation_state *) state;
- localisation_dictionary *D = igs->dict;
+ localisation_dictionary *D = Indexing::get_localisation(igs->session);
match_results mr = Regexp::create_mr();
if (Regexp::match(&mr, text, L"page (%C+) (%C+)")) {
@;
@@ -122,27 +121,14 @@ will be |Kinds.html| either way.
WRITE_TO(leafname, "%S.html", page->page_leafname);
TEMPORARY_TEXT(key)
WRITE_TO(key, "Index.Pages.%S.Title", page->page_leafname);
- text_stream *OUT =
- InterpretIndex::open_file(page, leafname,
- Localisation::read(D, key), -1, D);
- Elements::periodic_table(OUT, page, leafname, D);
+ text_stream index_file_struct; text_stream *OUT = &index_file_struct;
+ InterpretIndex::open_file(OUT, page, leafname, Localisation::read(D, key), -1, D);
+ Elements::periodic_table(OUT, page, leafname, session);
InterpretIndex::close_index_file(OUT);
DISCARD_TEXT(key)
DISCARD_TEXT(leafname)
}
- GroupedElement::detail_pages(D);
-
-@ This is a one-off function for generating the content of an index element
-(without its heading, or any HTML surround): it's used for unit-testing those
-elements.
-
-=
-void InterpretIndex::generate_one_element(OUTPUT_STREAM, inter_tree *I, wording elt,
- localisation_dictionary *D) {
- InterpretIndex::set_tree(I);
- Elements::test_card(OUT, elt, D);
- InterpretIndex::set_tree(NULL);
-}
+ GroupedElement::detail_pages(session);
@h Registering.
So, then, here are the objects representing the index pages and their elements
@@ -194,56 +180,14 @@ index_element *InterpretIndex::register_element(text_stream *abb, index_page *ow
return ie;
}
-@h Current.
-A clumsy convenience: keeping track of the page currently being written, and
-of the Inter tree currently being indexed.
-
-=
-index_page *current_index_page = NULL;
-void InterpretIndex::set_page(index_page *page) {
- current_index_page = page;
-}
-index_page *InterpretIndex::get_page(void) {
- return current_index_page;
-}
-
-inter_tree *indexing_tree = NULL;
-void InterpretIndex::set_tree(inter_tree *I) {
- indexing_tree = I;
-}
-inter_tree *InterpretIndex::get_tree(void) {
- if (indexing_tree == NULL) internal_error("no indexing tree");
- return indexing_tree;
-}
-
-@ =
-inter_lexicon *indexing_lexicon = NULL;
-inter_lexicon *InterpretIndex::get_lexicon(void) {
- if (indexing_lexicon == NULL) {
- if (indexing_tree == NULL) internal_error("no indexing lexicon");
- indexing_lexicon = IndexLexicon::stock(indexing_tree);
- }
- return indexing_lexicon;
-}
-
-@ =
-faux_instance_set *indexing_fis = NULL;
-faux_instance_set *InterpretIndex::get_faux_instances(void) {
- if (indexing_fis == NULL) {
- if (indexing_tree == NULL) internal_error("no indexing lexicon");
- indexing_fis = FauxInstances::make_faux(indexing_tree);
- }
- return indexing_fis;
-}
-
@h Opening and closing HTML files.
=
-text_stream index_file_struct; /* The current index file being written */
-text_stream *InterpretIndex::open_file(index_page *page, text_stream *index_leaf,
+text_stream *InterpretIndex::open_file(text_stream *IF,
+ index_page *page, text_stream *index_leaf,
text_stream *title, int sub, localisation_dictionary *D) {
filename *F = IndexLocations::filename(index_leaf, sub);
- if (STREAM_OPEN_TO_FILE(&index_file_struct, F, UTF8_ENC) == FALSE) {
+ if (STREAM_OPEN_TO_FILE(IF, F, UTF8_ENC) == FALSE) {
#ifdef CORE_MODULE
Problems::fatal_on_file("Can't open index file", F);
#endif
@@ -251,17 +195,15 @@ text_stream *InterpretIndex::open_file(index_page *page, text_stream *index_leaf
Errors::fatal_with_file("can't open index file", F);
#endif
}
- text_stream *OUT = &index_file_struct;
- InterpretIndex::set_page(page);
- HTML::header(OUT, title,
+ HTML::header(IF, title,
InstalledFiles::filename(CSS_FOR_STANDARD_PAGES_IRES),
- InstalledFiles::filename(JAVASCRIPT_FOR_STANDARD_PAGES_IRES));
- return OUT;
+ InstalledFiles::filename(JAVASCRIPT_FOR_STANDARD_PAGES_IRES),
+ (void *) page);
+ return IF;
}
@ =
void InterpretIndex::close_index_file(text_stream *ifl) {
HTML::footer(ifl);
STREAM_CLOSE(ifl);
- InterpretIndex::set_page(NULL);
}
diff --git a/inter/index-module/Chapter 2/Lexicon.w b/inter/index-module/Chapter 2/Lexicon.w
index 0b30a58ab..90b9dbdf7 100644
--- a/inter/index-module/Chapter 2/Lexicon.w
+++ b/inter/index-module/Chapter 2/Lexicon.w
@@ -44,11 +44,10 @@ typedef struct inter_lexicon {
And this is where that happens:
=
-inter_lexicon *IndexLexicon::stock(inter_tree *I) {
+inter_lexicon *IndexLexicon::stock(inter_tree *I, tree_inventory *inv) {
inter_lexicon *lexicon = CREATE(inter_lexicon);
lexicon->first = NULL;
lexicon->unsorted = NEW_LINKED_LIST(index_lexicon_entry);
- tree_inventory *inv = Synoptic::inv(I);
@;
@;
@;
diff --git a/inter/index-module/Chapter 2/Styles and Scripts.w b/inter/index-module/Chapter 2/Styles and Scripts.w
index 102eb3ece..9e9bb394b 100644
--- a/inter/index-module/Chapter 2/Styles and Scripts.w
+++ b/inter/index-module/Chapter 2/Styles and Scripts.w
@@ -9,16 +9,20 @@ failing to link to said files correctly.
But it means every HTML page in the index has to embed its own CSS and
Javascript, and this is done with a callback function which allows us to insert
-material into the head of an HTML page when it is opened for output:
+material into the head of an HTML page when it is opened for output. Note that
+the function acts only when the page was created with |state|, which will only
+happen when it was created by //index//.
@d ADDITIONAL_SCRIPTING_HTML_CALLBACK IndexStyles::incorporate
=
-void IndexStyles::incorporate(OUTPUT_STREAM) {
- index_page *current_page = InterpretIndex::get_page();
- if (current_page == NULL) return;
- @;
- @;
+void IndexStyles::incorporate(OUTPUT_STREAM, void *state) {
+ if (state) {
+ index_page *current_page = (index_page *) state;
+ if (current_page == NULL) return;
+ @;
+ @;
+ }
}
@ The CSS is mostly the same every time and is therefore mostly loaded from an
diff --git a/inter/index-module/Chapter 3/Alphabetic Element.w b/inter/index-module/Chapter 3/Alphabetic Element.w
index 0f313f094..16ae08d30 100644
--- a/inter/index-module/Chapter 3/Alphabetic Element.w
+++ b/inter/index-module/Chapter 3/Alphabetic Element.w
@@ -5,9 +5,9 @@ To write the Alphabetic actions element (A2) in the index.
@ This element is a simple three-column table.
=
-void AlphabeticElement::render(OUTPUT_STREAM, localisation_dictionary *LD) {
- inter_tree *I = InterpretIndex::get_tree();
- tree_inventory *inv = Synoptic::inv(I);
+void AlphabeticElement::render(OUTPUT_STREAM, index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
+ tree_inventory *inv = Indexing::get_inventory(session);
TreeLists::sort(inv->action_nodes, AlphabeticElement::alphabetical_order);
HTML::begin_html_table(OUT, NULL, FALSE, 0, 0, 0, 0, 0);
diff --git a/inter/index-module/Chapter 3/Arithmetic Element.w b/inter/index-module/Chapter 3/Arithmetic Element.w
index 04fde0d74..38ae880c6 100644
--- a/inter/index-module/Chapter 3/Arithmetic Element.w
+++ b/inter/index-module/Chapter 3/Arithmetic Element.w
@@ -6,9 +6,9 @@ To write the Arithmetic element (Ar) in the index.
so we do little more than tabulate that data here.
=
-void ArithmeticElement::render(OUTPUT_STREAM, localisation_dictionary *LD) {
- inter_tree *I = InterpretIndex::get_tree();
- tree_inventory *inv = Synoptic::inv(I);
+void ArithmeticElement::render(OUTPUT_STREAM, index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
+ tree_inventory *inv = Indexing::get_inventory(session);
TreeLists::sort(inv->kind_nodes, Synoptic::module_order);
TreeLists::sort(inv->multiplication_rule_nodes, Synoptic::module_order);
HTML_TAG("hr");
diff --git a/inter/index-module/Chapter 3/Behaviour Element.w b/inter/index-module/Chapter 3/Behaviour Element.w
index 90223f6f6..0368f4431 100644
--- a/inter/index-module/Chapter 3/Behaviour Element.w
+++ b/inter/index-module/Chapter 3/Behaviour Element.w
@@ -5,9 +5,10 @@ To write the Behaviour element (Bh) in the index.
@ This simply itemises kinds of action, and what defines them.
=
-void BehaviourElement::render(OUTPUT_STREAM, localisation_dictionary *LD) {
- inter_tree *I = InterpretIndex::get_tree();
- tree_inventory *inv = Synoptic::inv(I);
+void BehaviourElement::render(OUTPUT_STREAM, index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
+ inter_tree *I = Indexing::get_tree(session);
+ tree_inventory *inv = Indexing::get_inventory(session);
int num_naps = TreeLists::len(inv->named_action_pattern_nodes);
diff --git a/inter/index-module/Chapter 3/Card Element.w b/inter/index-module/Chapter 3/Card Element.w
index e5a7b34d4..7a5cdb252 100644
--- a/inter/index-module/Chapter 3/Card Element.w
+++ b/inter/index-module/Chapter 3/Card Element.w
@@ -7,8 +7,8 @@ natural way to present bibliographic data to the user. In effect, it's a
simplified form of the iFiction record, without the XML overhead.
=
-void CardElement::render(OUTPUT_STREAM, localisation_dictionary *LD) {
- inter_tree *I = InterpretIndex::get_tree();
+void CardElement::render(OUTPUT_STREAM, index_session *session) {
+ inter_tree *I = Indexing::get_tree(session);
inter_package *pack = Inter::Packages::by_url(I, I"/main/completion/bibliographic");
HTML_OPEN("p");
diff --git a/inter/index-module/Chapter 3/Chart Element.w b/inter/index-module/Chapter 3/Chart Element.w
index 4cfaf64e6..3efaa04fd 100644
--- a/inter/index-module/Chapter 3/Chart Element.w
+++ b/inter/index-module/Chapter 3/Chart Element.w
@@ -6,9 +6,9 @@ To write the Chart element (Ch) in the index.
and it is quite dense with information.
=
-void ChartElement::render(OUTPUT_STREAM, localisation_dictionary *D) {
- inter_tree *I = InterpretIndex::get_tree();
- tree_inventory *inv = Synoptic::inv(I);
+void ChartElement::render(OUTPUT_STREAM, index_session *session) {
+ localisation_dictionary *D = Indexing::get_localisation(session);
+ tree_inventory *inv = Indexing::get_inventory(session);
TreeLists::sort(inv->kind_nodes, Synoptic::module_order);
TreeLists::sort(inv->instance_nodes, Synoptic::module_order);
HTML::begin_wide_html_table(OUT);
diff --git a/inter/index-module/Chapter 3/Commands Element.w b/inter/index-module/Chapter 3/Commands Element.w
index b5b628a07..d555437cd 100644
--- a/inter/index-module/Chapter 3/Commands Element.w
+++ b/inter/index-module/Chapter 3/Commands Element.w
@@ -3,8 +3,9 @@
To write the Commands element (Cm) in the index.
@ =
-void CommandsElement::render(OUTPUT_STREAM, localisation_dictionary *LD) {
- inter_tree *I = InterpretIndex::get_tree();
+void CommandsElement::render(OUTPUT_STREAM, index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
+ inter_tree *I = Indexing::get_tree(session);
linked_list *entries = NEW_LINKED_LIST(command_index_entry);
@;
diff --git a/inter/index-module/Chapter 3/Contents Element.w b/inter/index-module/Chapter 3/Contents Element.w
index aa65bfb1c..cb9f8e51a 100644
--- a/inter/index-module/Chapter 3/Contents Element.w
+++ b/inter/index-module/Chapter 3/Contents Element.w
@@ -5,9 +5,10 @@ To write the Contents element (C) in the index.
@ This is a hierarchical contents page.
=
-void ContentsElement::render(OUTPUT_STREAM, localisation_dictionary *LD) {
- inter_tree *I = InterpretIndex::get_tree();
- tree_inventory *inv = Synoptic::inv(I);
+void ContentsElement::render(OUTPUT_STREAM, index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
+ inter_tree *I = Indexing::get_tree(session);
+ tree_inventory *inv = Indexing::get_inventory(session);
TreeLists::sort(inv->extension_nodes, Synoptic::category_order);
TreeLists::sort(inv->heading_nodes, Synoptic::module_order);
diff --git a/inter/index-module/Chapter 3/Events Element.w b/inter/index-module/Chapter 3/Events Element.w
index 53899907d..bc65f873a 100644
--- a/inter/index-module/Chapter 3/Events Element.w
+++ b/inter/index-module/Chapter 3/Events Element.w
@@ -5,9 +5,9 @@ To write the Events element (Ev) in the index.
@ There are two tables, one for timed events, the other for those of no fixed time.
=
-void EventsElement::render(OUTPUT_STREAM, localisation_dictionary *LD) {
- inter_tree *I = InterpretIndex::get_tree();
- tree_inventory *inv = Synoptic::inv(I);
+void EventsElement::render(OUTPUT_STREAM, index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
+ tree_inventory *inv = Indexing::get_inventory(session);
TreeLists::sort(inv->rule_nodes, Synoptic::module_order);
int when_count = 0, tt_count = 0;
diff --git a/inter/index-module/Chapter 3/Extras Element.w b/inter/index-module/Chapter 3/Extras Element.w
index e6efde8ea..3950ed6fe 100644
--- a/inter/index-module/Chapter 3/Extras Element.w
+++ b/inter/index-module/Chapter 3/Extras Element.w
@@ -6,9 +6,10 @@ To write the Extras element (Xt) in the index.
really, and most of the code here is just to arrange them in some logical order.
=
-void ExtrasElement::render(OUTPUT_STREAM, localisation_dictionary *LD) {
- inter_tree *I = InterpretIndex::get_tree();
- tree_inventory *inv = Synoptic::inv(I);
+void ExtrasElement::render(OUTPUT_STREAM, index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
+ inter_tree *I = Indexing::get_tree(session);
+ tree_inventory *inv = Indexing::get_inventory(session);
TreeLists::sort(inv->rulebook_nodes, Synoptic::module_order);
TreeLists::sort(inv->activity_nodes, Synoptic::module_order);
diff --git a/inter/index-module/Chapter 3/Figures Element.w b/inter/index-module/Chapter 3/Figures Element.w
index 5b16affed..ecb0357d4 100644
--- a/inter/index-module/Chapter 3/Figures Element.w
+++ b/inter/index-module/Chapter 3/Figures Element.w
@@ -5,9 +5,10 @@ To write the Figures element (Fi) in the index.
@ Not only figures but also sounds and external files, a little questionably.
=
-void FiguresElement::render(OUTPUT_STREAM, localisation_dictionary *LD) {
- inter_tree *I = InterpretIndex::get_tree();
- tree_inventory *inv = Synoptic::inv(I);
+void FiguresElement::render(OUTPUT_STREAM, index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
+ inter_tree *I = Indexing::get_tree(session);
+ tree_inventory *inv = Indexing::get_inventory(session);
TreeLists::sort(inv->figure_nodes, Synoptic::module_order);
TreeLists::sort(inv->sound_nodes, Synoptic::module_order);
TreeLists::sort(inv->file_nodes, Synoptic::module_order);
diff --git a/inter/index-module/Chapter 3/Gazetteer Element.w b/inter/index-module/Chapter 3/Gazetteer Element.w
index 559420344..6d4c4d6b2 100644
--- a/inter/index-module/Chapter 3/Gazetteer Element.w
+++ b/inter/index-module/Chapter 3/Gazetteer Element.w
@@ -3,6 +3,7 @@
To write the Gazetteer element (Gz) in the index.
@ =
-void GazetteerElement::render(OUTPUT_STREAM, localisation_dictionary *LD) {
- IndexLexicon::listing(OUT, InterpretIndex::get_lexicon(), TRUE, LD);
+void GazetteerElement::render(OUTPUT_STREAM, index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
+ IndexLexicon::listing(OUT, Indexing::get_lexicon(session), TRUE, LD);
}
diff --git a/inter/index-module/Chapter 3/Grouped Element.w b/inter/index-module/Chapter 3/Grouped Element.w
index c9a1a809d..62a09fec0 100644
--- a/inter/index-module/Chapter 3/Grouped Element.w
+++ b/inter/index-module/Chapter 3/Grouped Element.w
@@ -6,9 +6,8 @@ per-action pages linked from it.
@ The element itself is easily made:
=
-void GroupedElement::render(OUTPUT_STREAM, localisation_dictionary *LD) {
- inter_tree *I = InterpretIndex::get_tree();
- tree_inventory *inv = Synoptic::inv(I);
+void GroupedElement::render(OUTPUT_STREAM, index_session *session) {
+ tree_inventory *inv = Indexing::get_inventory(session);
TreeLists::sort(inv->action_nodes, Synoptic::module_order);
int f = FALSE;
@@ -54,14 +53,16 @@ void GroupedElement::render(OUTPUT_STREAM, localisation_dictionary *LD) {
page for each action.
=
-void GroupedElement::detail_pages(localisation_dictionary *LD) {
- inter_tree *I = InterpretIndex::get_tree();
- tree_inventory *inv = Synoptic::inv(I);
+void GroupedElement::detail_pages(index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
+ inter_tree *I = Indexing::get_tree(session);
+ tree_inventory *inv = Indexing::get_inventory(session);
TreeLists::sort(inv->action_nodes, Synoptic::module_order);
inter_package *an_pack;
LOOP_OVER_INVENTORY_PACKAGES(an_pack, i, inv->action_nodes) {
- text_stream *OUT = InterpretIndex::open_file(NULL, I"A.html", I";
InterpretIndex::close_index_file(OUT);
}
diff --git a/inter/index-module/Chapter 3/Innards Element.w b/inter/index-module/Chapter 3/Innards Element.w
index 13766598a..6fc45189d 100644
--- a/inter/index-module/Chapter 3/Innards Element.w
+++ b/inter/index-module/Chapter 3/Innards Element.w
@@ -6,9 +6,10 @@ To write the Innards element (In) in the index.
technical implementation rather than the content of a work.
=
-void InnardsElement::render(OUTPUT_STREAM, localisation_dictionary *LD) {
- inter_tree *I = InterpretIndex::get_tree();
- tree_inventory *inv = Synoptic::inv(I);
+void InnardsElement::render(OUTPUT_STREAM, index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
+ inter_tree *I = Indexing::get_tree(session);
+ tree_inventory *inv = Indexing::get_inventory(session);
TreeLists::sort(inv->use_option_nodes, Synoptic::module_order);
@;
diff --git a/inter/index-module/Chapter 3/Lexicon Element.w b/inter/index-module/Chapter 3/Lexicon Element.w
index 7360fa0e7..08c773251 100644
--- a/inter/index-module/Chapter 3/Lexicon Element.w
+++ b/inter/index-module/Chapter 3/Lexicon Element.w
@@ -3,12 +3,13 @@
To write the Lexicon element (Lx) in the index.
@ =
-void LexiconElement::render(OUTPUT_STREAM, localisation_dictionary *LD) {
+void LexiconElement::render(OUTPUT_STREAM, index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
IndexUtilities::anchor(OUT, I"LEXICON");
HTML_OPEN("p");
HTML_OPEN_WITH("span", "class=\"smaller\"");
Localisation::roman(OUT, LD, I"Index.Elements.Lx.Explanation");
HTML_CLOSE("span");
HTML_CLOSE("p");
- IndexLexicon::listing(OUT, InterpretIndex::get_lexicon(), FALSE, LD);
+ IndexLexicon::listing(OUT, Indexing::get_lexicon(session), FALSE, LD);
}
diff --git a/inter/index-module/Chapter 3/Map Element.w b/inter/index-module/Chapter 3/Map Element.w
index 290127789..4367704f2 100644
--- a/inter/index-module/Chapter 3/Map Element.w
+++ b/inter/index-module/Chapter 3/Map Element.w
@@ -8,16 +8,17 @@ cues all of that up; but even that code is fairly long.
=
int suppress_panel_changes = FALSE;
-void MapElement::render(OUTPUT_STREAM, localisation_dictionary *LD, int test_only) {
+void MapElement::render(OUTPUT_STREAM, index_session *session, int test_only) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
SpatialMap::initialise_page_directions();
- faux_instance_set *faux_set = InterpretIndex::get_faux_instances();
- SpatialMap::establish_spatial_coordinates();
+ faux_instance_set *faux_set = Indexing::get_set_of_instances(session);
+ SpatialMap::establish_spatial_coordinates(session);
if (test_only) {
- SpatialMap::perform_map_internal_test(OUT);
+ SpatialMap::perform_map_internal_test(OUT, session);
} else {
- HTMLMap::render_map_as_HTML(OUT, LD);
- HTMLMap::add_region_key(OUT);
- MapElement::index_backdrop_further(OUT, NULL, 0, FALSE, 1, LD);
+ HTMLMap::render_map_as_HTML(OUT, session);
+ HTMLMap::add_region_key(OUT, session);
+ MapElement::index_backdrop_further(OUT, NULL, 0, FALSE, 1, session);
IndexUtilities::anchor(OUT, I"MDETAILS");
int unruly = FALSE;
@@ -46,11 +47,11 @@ void MapElement::render(OUTPUT_STREAM, localisation_dictionary *LD, int test_onl
if (subheaded == FALSE) {
@;
@;
- MapElement::index_backdrop_further(OUT, reg, 0, FALSE, 2, LD);
+ MapElement::index_backdrop_further(OUT, reg, 0, FALSE, 2, session);
HTML_OPEN("p");
subheaded = TRUE;
}
- HTMLMap::render_single_room_as_HTML(OUT, rm, LD);
+ HTMLMap::render_single_room_as_HTML(OUT, rm, session);
FauxInstances::increment_indexing_count(rm);
}
}
@@ -69,7 +70,7 @@ void MapElement::render(OUTPUT_STREAM, localisation_dictionary *LD, int test_onl
LOOP_OVER_FAUX_ROOMS(faux_set, I)
if (FauxInstances::indexed_yet(I) == FALSE) {
@;
- HTMLMap::render_single_room_as_HTML(OUT, I, LD);
+ HTMLMap::render_single_room_as_HTML(OUT, I, session);
}
@ By this point we've accounted for rooms (and their contents and any parts
@@ -89,7 +90,7 @@ will be things which are offstage (and their contents and any parts thereof):
Localisation::bold(OUT, LD, I"Index.Elements.Mp.NowhereHeading");
HTML_TAG("br");
}
- MapElement::index(OUT, I, 2, FALSE, LD);
+ MapElement::index(OUT, I, 2, FALSE, session);
}
suppress_panel_changes = FALSE;
@@ -114,7 +115,8 @@ void MapElement::set_room_being_indexed(faux_instance *I) {
}
void MapElement::index(OUTPUT_STREAM, faux_instance *I, int depth, int details,
- localisation_dictionary *LD) {
+ index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
if (depth == MAX_OBJECT_INDEX_DEPTH) internal_error("MAX_OBJECT_INDEX_DEPTH exceeded");
if (I) {
if (depth > NUMBER_CREATED(faux_instance) + 1) return; /* to recover from errors */
@@ -135,7 +137,7 @@ void MapElement::index(OUTPUT_STREAM, faux_instance *I, int depth, int details,
@;
@;
@;
- MapElement::index_usages(OUT, I, LD);
+ MapElement::index_usages(OUT, I, session);
IndexUtilities::extra_div_close(OUT, "e0e0e0");
}
@;
@@ -147,7 +149,7 @@ void MapElement::index(OUTPUT_STREAM, faux_instance *I, int depth, int details,
if (I != indexing_room) IndexUtilities::anchor(OUT, I->anchor_text);
} else {
#ifdef IF_MODULE
- if (I) MapElement::index_spatial_relationship(OUT, I, LD);
+ if (I) MapElement::index_spatial_relationship(OUT, I, session);
#endif
}
@@ -182,8 +184,8 @@ void MapElement::index(OUTPUT_STREAM, faux_instance *I, int depth, int details,
}
@ =
- if ((MapElement::annotate_door(OUT, I, LD) == FALSE) &&
- (MapElement::annotate_player(OUT, I, LD) == FALSE)) {
+ if ((MapElement::annotate_door(OUT, I, session) == FALSE) &&
+ (MapElement::annotate_player(OUT, I, session) == FALSE)) {
if (FauxInstances::specify_kind(I)) {
WRITE(" - ");
FauxInstances::write_kind(OUT, I);
@@ -199,7 +201,7 @@ void MapElement::index(OUTPUT_STREAM, faux_instance *I, int depth, int details,
@ =
#ifdef IF_MODULE
- MapElement::index_object_further(OUT, I, depth, details, LD);
+ MapElement::index_object_further(OUT, I, depth, details, session);
#endif
@ =
@@ -224,14 +226,15 @@ void MapElement::index(OUTPUT_STREAM, faux_instance *I, int depth, int details,
WRITE("%S", material);
@ =
- MapElement::add_room_to_World_index(OUT, I);
+ MapElement::add_room_to_World_index(OUT, I, session);
MapElement::add_region_to_World_index(OUT, I);
- MapElement::add_to_World_index(OUT, I, LD);
+ MapElement::add_to_World_index(OUT, I, session);
@
=
-void MapElement::index_usages(OUTPUT_STREAM, faux_instance *I, localisation_dictionary *LD) {
+void MapElement::index_usages(OUTPUT_STREAM, faux_instance *I, index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
int k = 0;
inter_package *pack = I->package;
inter_tree_node *P = Metadata::read_optional_list(pack, I"^backdrop_presences");
@@ -254,9 +257,10 @@ void MapElement::index_usages(OUTPUT_STREAM, faux_instance *I, localisation_dict
if (k > 0) HTML_CLOSE("p");
}
-int MapElement::add_room_to_World_index(OUTPUT_STREAM, faux_instance *O) {
+int MapElement::add_room_to_World_index(OUTPUT_STREAM, faux_instance *O,
+ index_session *session) {
if ((O) && (FauxInstances::is_a_room(O))) {
- SpatialMap::index_room_connections(OUT, O);
+ SpatialMap::index_room_connections(OUT, O, session);
}
return FALSE;
}
@@ -270,8 +274,9 @@ int MapElement::add_region_to_World_index(OUTPUT_STREAM, faux_instance *O) {
}
int MapElement::annotate_player(OUTPUT_STREAM, faux_instance *I,
- localisation_dictionary *LD) {
- if (I == FauxInstances::start_room()) {
+ index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
+ if (I == FauxInstances::start_room(session)) {
WRITE(" - ");
Localisation::italic(OUT, LD, I"Index.Elements.Mp.RoomWherePlayBegins");
DocReferences::link(OUT, I"ROOMPLAYBEGINS");
@@ -281,7 +286,8 @@ int MapElement::annotate_player(OUTPUT_STREAM, faux_instance *I,
}
int MapElement::annotate_door(OUTPUT_STREAM, faux_instance *O,
- localisation_dictionary *LD) {
+ index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
if ((O) && (FauxInstances::is_a_door(O))) {
faux_instance *A = NULL, *B = NULL;
FauxInstances::get_door_data(O, &A, &B);
@@ -302,7 +308,8 @@ int MapElement::annotate_door(OUTPUT_STREAM, faux_instance *O,
@ =
void MapElement::index_spatial_relationship(OUTPUT_STREAM, faux_instance *I,
- localisation_dictionary *LD) {
+ index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
text_stream *rel = NULL;
faux_instance *P = FauxInstances::progenitor(I);
if (P) {
@@ -331,18 +338,18 @@ int MapElement::no_detail_index(faux_instance *I) {
=
void MapElement::index_object_further(OUTPUT_STREAM, faux_instance *I, int depth,
- int details, localisation_dictionary *LD) {
- faux_instance_set *faux_set = InterpretIndex::get_faux_instances();
+ int details, index_session *session) {
+ faux_instance_set *faux_set = Indexing::get_set_of_instances(session);
if (depth > NUMBER_CREATED(faux_instance) + 1) return; /* to recover from errors */
if (FauxInstances::incorp_child(I)) {
faux_instance *I2 = FauxInstances::incorp_child(I);
while (I2) {
- MapElement::index(OUT, I2, depth+1, details, LD);
+ MapElement::index(OUT, I2, depth+1, details, session);
I2 = FauxInstances::incorp_sibling(I2);
}
}
if (FauxInstances::child(I))
- MapElement::index(OUT, FauxInstances::child(I), depth+1, details, LD);
+ MapElement::index(OUT, FauxInstances::child(I), depth+1, details, session);
if ((FauxInstances::is_a_room(I)) &&
(FauxInstances::is_a_door(I) == FALSE)) {
faux_instance *I2;
@@ -350,23 +357,24 @@ void MapElement::index_object_further(OUTPUT_STREAM, faux_instance *I, int depth
if ((FauxInstances::is_a_door(I2)) && (FauxInstances::progenitor(I2) != I)) {
faux_instance *A = NULL, *B = NULL;
FauxInstances::get_door_data(I2, &A, &B);
- if (A == I) MapElement::index(OUT, I2, depth+1, details, LD);
- if (B == I) MapElement::index(OUT, I2, depth+1, details, LD);
+ if (A == I) MapElement::index(OUT, I2, depth+1, details, session);
+ if (B == I) MapElement::index(OUT, I2, depth+1, details, session);
}
}
}
- MapElement::index_player_further(OUT, I, depth, details, LD);
- MapElement::index_backdrop_further(OUT, I, depth, details, 0, LD);
+ MapElement::index_player_further(OUT, I, depth, details, session);
+ MapElement::index_backdrop_further(OUT, I, depth, details, 0, session);
if (FauxInstances::sibling(I))
- MapElement::index(OUT, FauxInstances::sibling(I), depth, details, LD);
+ MapElement::index(OUT, FauxInstances::sibling(I), depth, details, session);
}
@ And also:
=
int MapElement::add_to_World_index(OUTPUT_STREAM, faux_instance *O,
- localisation_dictionary *LD) {
+ index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
if ((O) && (FauxInstances::is_a_thing(O))) {
HTML::open_indented_p(OUT, 1, "tight");
faux_instance *P = FauxInstances::progenitor(O);
@@ -392,28 +400,29 @@ int MapElement::add_to_World_index(OUTPUT_STREAM, faux_instance *O,
}
void MapElement::index_player_further(OUTPUT_STREAM, faux_instance *I, int depth,
- int details, localisation_dictionary *LD) {
- faux_instance *yourself = FauxInstances::yourself();
- if ((I == FauxInstances::start_room()) && (yourself) &&
+ int details, index_session *session) {
+ faux_instance *yourself = FauxInstances::yourself(session);
+ if ((I == FauxInstances::start_room(session)) && (yourself) &&
(FauxInstances::indexed_yet(yourself) == FALSE))
- MapElement::index(OUT, yourself, depth+1, details, LD);
+ MapElement::index(OUT, yourself, depth+1, details, session);
}
void MapElement::index_backdrop_further(OUTPUT_STREAM, faux_instance *loc, int depth,
- int details, int how, localisation_dictionary *LD) {
- faux_instance_set *faux_set = InterpretIndex::get_faux_instances();
+ int details, int how, index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
+ faux_instance_set *faux_set = Indexing::get_set_of_instances(session);
int discoveries = 0;
faux_instance *bd;
if (loc) {
LOOP_OVER_LINKED_LIST(bd, faux_instance, loc->backdrop_presences) {
if (++discoveries == 1) @;
- MapElement::index(OUT, bd, depth+1, details, LD);
+ MapElement::index(OUT, bd, depth+1, details, session);
}
} else {
LOOP_OVER_FAUX_BACKDROPS(faux_set, bd)
if (FauxInstances::is_everywhere(bd)) {
if (++discoveries == 1) @;
- MapElement::index(OUT, bd, depth+1, details, LD);
+ MapElement::index(OUT, bd, depth+1, details, session);
}
}
if (discoveries > 0) @;
diff --git a/inter/index-module/Chapter 3/Phrasebook Element.w b/inter/index-module/Chapter 3/Phrasebook Element.w
index 739d340fc..cbb2447e5 100644
--- a/inter/index-module/Chapter 3/Phrasebook Element.w
+++ b/inter/index-module/Chapter 3/Phrasebook Element.w
@@ -3,8 +3,8 @@
To write the Phrasebook element (Pb) in the index.
@ =
-void PhrasebookElement::render(OUTPUT_STREAM, localisation_dictionary *LD) {
- inter_tree *I = InterpretIndex::get_tree();
+void PhrasebookElement::render(OUTPUT_STREAM, index_session *session) {
+ inter_tree *I = Indexing::get_tree(session);
inter_package *pack = Inter::Packages::by_url(I, I"/main/completion/phrases");
for (int pass = 1; pass <= 2; pass++) {
int grand_c = 0;
diff --git a/inter/index-module/Chapter 3/Plot Element.w b/inter/index-module/Chapter 3/Plot Element.w
index 0411de053..3c13cff6c 100644
--- a/inter/index-module/Chapter 3/Plot Element.w
+++ b/inter/index-module/Chapter 3/Plot Element.w
@@ -10,16 +10,11 @@ with a notation which takes a little bit of on-screen explanation, but
seems natural enough to learn in practice.
=
-void PlotElement::render(OUTPUT_STREAM, localisation_dictionary *LD) {
- inter_tree *I = InterpretIndex::get_tree();
- tree_inventory *inv = Synoptic::inv(I);
- TreeLists::sort(inv->scene_nodes, PlotElement::scene_order);
- TreeLists::sort(inv->rulebook_nodes, Synoptic::module_order);
-
- inter_package *scene_pack;
- LOOP_OVER_INVENTORY_PACKAGES(scene_pack, i, inv->scene_nodes)
- FauxScenes::simplified(I, scene_pack);
-
+void PlotElement::render(OUTPUT_STREAM, index_session *session) {
+ tree_inventory *inv = Indexing::get_inventory(session);
+ inter_tree *I = Indexing::get_tree(session);
+ localisation_dictionary *LD = Indexing::get_localisation(session);
+ linked_list *L = Indexing::get_list_of_scenes(session);
@;
@;
@;
@@ -35,15 +30,17 @@ about and created but never made use of.)
@ =
simplified_scene *ssc;
- LOOP_OVER(ssc, simplified_scene)
+ LOOP_OVER_LINKED_LIST(ssc, simplified_scene, L)
+ ssc->indexed_already = FALSE;
+ LOOP_OVER_LINKED_LIST(ssc, simplified_scene, L)
if ((FauxScenes::starts_at_start_of_play(ssc)) || (FauxScenes::is_entire_game(ssc)))
- PlotElement::index_from_scene(OUT, ssc, 0, START_OF_PLAY_END, NULL);
- LOOP_OVER(ssc, simplified_scene)
+ PlotElement::index_from_scene(OUT, ssc, 0, START_OF_PLAY_END, NULL, session);
+ LOOP_OVER_LINKED_LIST(ssc, simplified_scene, L)
if ((FauxScenes::starts_on_condition(ssc)) && (FauxScenes::is_entire_game(ssc) == FALSE))
- PlotElement::index_from_scene(OUT, ssc, 0, START_OF_PLAY_END, NULL);
- LOOP_OVER(ssc, simplified_scene)
+ PlotElement::index_from_scene(OUT, ssc, 0, START_OF_PLAY_END, NULL, session);
+ LOOP_OVER_LINKED_LIST(ssc, simplified_scene, L)
if (ssc->indexed_already == FALSE)
- PlotElement::index_from_scene(OUT, ssc, 0, NEVER_HAPPENS_END, NULL);
+ PlotElement::index_from_scene(OUT, ssc, 0, NEVER_HAPPENS_END, NULL, session);
@ =
HTML_OPEN("p");
@@ -69,7 +66,7 @@ about and created but never made use of.)
@ =
IndexUtilities::anchor(OUT, I"SDETAILS");
simplified_scene *ssc;
- LOOP_OVER(ssc, simplified_scene) {
+ LOOP_OVER_LINKED_LIST(ssc, simplified_scene, L) {
HTML_TAG("hr");
@;
}
@@ -210,7 +207,8 @@ on the initial call when |depth| is 0.
=
void PlotElement::index_from_scene(OUTPUT_STREAM, simplified_scene *ssc, int depth,
- int end, simplified_scene *sc_from) {
+ int end, simplified_scene *sc_from, index_session *session) {
+ linked_list *L = Indexing::get_list_of_scenes(session);
HTML::open_indented_p(OUT, depth+1, "tight");
@;
@;
@@ -261,14 +259,14 @@ this one does; then to scenes which begin when this one ends.
@ =
simplified_scene *ssc2;
- LOOP_OVER(ssc2, simplified_scene)
+ LOOP_OVER_LINKED_LIST(ssc2, simplified_scene, L)
for (simplified_connector *scon = ssc2->ends[0]->anchor_connectors; scon; scon=scon->next)
if ((FauxScenes::connects_to(scon) == ssc) && (FauxScenes::scon_end(scon) >= 1))
- PlotElement::index_from_scene(OUT, ssc2, depth + 1, FauxScenes::scon_end(scon), ssc);
- LOOP_OVER(ssc2, simplified_scene)
+ PlotElement::index_from_scene(OUT, ssc2, depth + 1, FauxScenes::scon_end(scon), ssc, session);
+ LOOP_OVER_LINKED_LIST(ssc2, simplified_scene, L)
for (simplified_connector *scon = ssc2->ends[0]->anchor_connectors; scon; scon=scon->next)
if ((FauxScenes::connects_to(scon) == ssc) && (FauxScenes::scon_end(scon) == 0))
- PlotElement::index_from_scene(OUT, ssc2, depth, FauxScenes::scon_end(scon), ssc);
+ PlotElement::index_from_scene(OUT, ssc2, depth, FauxScenes::scon_end(scon), ssc, session);
@ We have been using:
diff --git a/inter/index-module/Chapter 3/Relations Element.w b/inter/index-module/Chapter 3/Relations Element.w
index 123de5123..8de99e842 100644
--- a/inter/index-module/Chapter 3/Relations Element.w
+++ b/inter/index-module/Chapter 3/Relations Element.w
@@ -5,9 +5,9 @@ To write the Relations element (Rl) in the index.
@ A four-column table of relations.
=
-void RelationsElement::render(OUTPUT_STREAM, localisation_dictionary *LD) {
- inter_tree *I = InterpretIndex::get_tree();
- tree_inventory *inv = Synoptic::inv(I);
+void RelationsElement::render(OUTPUT_STREAM, index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
+ tree_inventory *inv = Indexing::get_inventory(session);
TreeLists::sort(inv->relation_nodes, Synoptic::module_order);
HTML_OPEN("p");
diff --git a/inter/index-module/Chapter 3/Rules for Scenes Element.w b/inter/index-module/Chapter 3/Rules for Scenes Element.w
index f9d7ec7ea..a8ded8d25 100644
--- a/inter/index-module/Chapter 3/Rules for Scenes Element.w
+++ b/inter/index-module/Chapter 3/Rules for Scenes Element.w
@@ -5,9 +5,9 @@ To write the Rules for Scenes element (RS) in the index.
@
=
-void RulesForScenesElement::render(OUTPUT_STREAM, localisation_dictionary *LD) {
- inter_tree *I = InterpretIndex::get_tree();
- tree_inventory *inv = Synoptic::inv(I);
+void RulesForScenesElement::render(OUTPUT_STREAM, index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
+ tree_inventory *inv = Indexing::get_inventory(session);
TreeLists::sort(inv->rulebook_nodes, Synoptic::module_order);
HTML_OPEN("p");
diff --git a/inter/index-module/Chapter 3/Standards Element.w b/inter/index-module/Chapter 3/Standards Element.w
index a468b28ba..5a45db357 100644
--- a/inter/index-module/Chapter 3/Standards Element.w
+++ b/inter/index-module/Chapter 3/Standards Element.w
@@ -6,9 +6,9 @@ To write the Standards element (St) in the index.
their contents in logical order.
=
-void StandardsElement::render(OUTPUT_STREAM, localisation_dictionary *LD) {
- inter_tree *I = InterpretIndex::get_tree();
- tree_inventory *inv = Synoptic::inv(I);
+void StandardsElement::render(OUTPUT_STREAM, index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
+ tree_inventory *inv = Indexing::get_inventory(session);
TreeLists::sort(inv->rulebook_nodes, Synoptic::module_order);
TreeLists::sort(inv->activity_nodes, Synoptic::module_order);
diff --git a/inter/index-module/Chapter 3/Tables Element.w b/inter/index-module/Chapter 3/Tables Element.w
index 0599813df..e17266125 100644
--- a/inter/index-module/Chapter 3/Tables Element.w
+++ b/inter/index-module/Chapter 3/Tables Element.w
@@ -7,9 +7,9 @@ corresponds to one of the compilation modules: thus, all the tables in the
main source text, all the tables in the Standard Rules, and so on.
=
-void TablesElement::render(OUTPUT_STREAM, localisation_dictionary *LD) {
- inter_tree *I = InterpretIndex::get_tree();
- tree_inventory *inv = Synoptic::inv(I);
+void TablesElement::render(OUTPUT_STREAM, index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
+ tree_inventory *inv = Indexing::get_inventory(session);
TreeLists::sort(inv->table_nodes, Synoptic::category_order);
inter_package *current_mod = NULL; int mc = 0, first_ext = TRUE;
diff --git a/inter/index-module/Chapter 3/The Periodic Table.w b/inter/index-module/Chapter 3/The Periodic Table.w
index 93c60f772..5564eece6 100644
--- a/inter/index-module/Chapter 3/The Periodic Table.w
+++ b/inter/index-module/Chapter 3/The Periodic Table.w
@@ -39,7 +39,8 @@ and text underneath in another of class "headingrubric".
=
void Elements::periodic_table(OUTPUT_STREAM, index_page *current_page,
- text_stream *index_leaf, localisation_dictionary *D) {
+ text_stream *index_leaf, index_session *session) {
+ localisation_dictionary *D = Indexing::get_localisation(session);
int max_elements = 0;
index_page *ip;
LOOP_OVER(ip, index_page)
@@ -162,7 +163,7 @@ content at last; and then a rule.
HTML_TAG("hr");
IndexUtilities::banner_line(OUT, current_page, ie->atomic_number, ie->chemical_symbol,
ie->element_name, ie->explanation_key, NULL, D);
- Elements::render(OUT, ie->chemical_symbol, D);
+ Elements::render(OUT, ie->chemical_symbol, session);
HTML_CLOSE("div");
}
HTML_TAG("hr");
@@ -171,42 +172,42 @@ content at last; and then a rule.
text file from the content of a single element.
=
-void Elements::test_card(OUTPUT_STREAM, wording W, localisation_dictionary *LD) {
+void Elements::test_card(OUTPUT_STREAM, wording W, index_session *session) {
TEMPORARY_TEXT(elt)
WRITE_TO(elt, "%+W", W);
- Elements::render(OUT, elt, LD);
+ Elements::render(OUT, elt, session);
DISCARD_TEXT(elt)
}
@ In general, then, these are the elements:
=
-void Elements::render(OUTPUT_STREAM, text_stream *elt, localisation_dictionary *LD) {
- if (Str::eq_wide_string(elt, L"A1")) { GroupedElement::render(OUT, LD); return; }
- if (Str::eq_wide_string(elt, L"A2")) { AlphabeticElement::render(OUT, LD); return; }
- if (Str::eq_wide_string(elt, L"Ar")) { ArithmeticElement::render(OUT, LD); return; }
- if (Str::eq_wide_string(elt, L"Bh")) { BehaviourElement::render(OUT, LD); return; }
- if (Str::eq_wide_string(elt, L"C")) { ContentsElement::render(OUT, LD); return; }
- if (Str::eq_wide_string(elt, L"Cd")) { CardElement::render(OUT, LD); return; }
- if (Str::eq_wide_string(elt, L"Ch")) { ChartElement::render(OUT, LD); return; }
- if (Str::eq_wide_string(elt, L"Cm")) { CommandsElement::render(OUT, LD); return; }
- if (Str::eq_wide_string(elt, L"Ev")) { EventsElement::render(OUT, LD); return; }
- if (Str::eq_wide_string(elt, L"Fi")) { FiguresElement::render(OUT, LD); return; }
- if (Str::eq_wide_string(elt, L"Gz")) { GazetteerElement::render(OUT, LD); return; }
- if (Str::eq_wide_string(elt, L"In")) { InnardsElement::render(OUT, LD); return; }
- if (Str::eq_wide_string(elt, L"Lx")) { LexiconElement::render(OUT, LD); return; }
- if (Str::eq_wide_string(elt, L"Mp")) { MapElement::render(OUT, LD, FALSE); return; }
- if (Str::eq_wide_string(elt, L"MT")) { MapElement::render(OUT, LD, TRUE); return; }
- if (Str::eq_wide_string(elt, L"Ph")) { PhrasebookElement::render(OUT, LD); return; }
- if (Str::eq_wide_string(elt, L"Pl")) { PlotElement::render(OUT, LD); return; }
- if (Str::eq_wide_string(elt, L"Rl")) { RelationsElement::render(OUT, LD); return; }
- if (Str::eq_wide_string(elt, L"RS")) { RulesForScenesElement::render(OUT, LD); return; }
- if (Str::eq_wide_string(elt, L"St")) { StandardsElement::render(OUT, LD); return; }
- if (Str::eq_wide_string(elt, L"Tb")) { TablesElement::render(OUT, LD); return; }
- if (Str::eq_wide_string(elt, L"To")) { TokensElement::render(OUT, LD); return; }
- if (Str::eq_wide_string(elt, L"Vb")) { VerbsElement::render(OUT, LD); return; }
- if (Str::eq_wide_string(elt, L"Vl")) { ValuesElement::render(OUT, LD); return; }
- if (Str::eq_wide_string(elt, L"Xt")) { ExtrasElement::render(OUT, LD); return; }
+void Elements::render(OUTPUT_STREAM, text_stream *elt, index_session *session) {
+ if (Str::eq_wide_string(elt, L"A1")) { GroupedElement::render(OUT, session); return; }
+ if (Str::eq_wide_string(elt, L"A2")) { AlphabeticElement::render(OUT, session); return; }
+ if (Str::eq_wide_string(elt, L"Ar")) { ArithmeticElement::render(OUT, session); return; }
+ if (Str::eq_wide_string(elt, L"Bh")) { BehaviourElement::render(OUT, session); return; }
+ if (Str::eq_wide_string(elt, L"C")) { ContentsElement::render(OUT, session); return; }
+ if (Str::eq_wide_string(elt, L"Cd")) { CardElement::render(OUT, session); return; }
+ if (Str::eq_wide_string(elt, L"Ch")) { ChartElement::render(OUT, session); return; }
+ if (Str::eq_wide_string(elt, L"Cm")) { CommandsElement::render(OUT, session); return; }
+ if (Str::eq_wide_string(elt, L"Ev")) { EventsElement::render(OUT, session); return; }
+ if (Str::eq_wide_string(elt, L"Fi")) { FiguresElement::render(OUT, session); return; }
+ if (Str::eq_wide_string(elt, L"Gz")) { GazetteerElement::render(OUT, session); return; }
+ if (Str::eq_wide_string(elt, L"In")) { InnardsElement::render(OUT, session); return; }
+ if (Str::eq_wide_string(elt, L"Lx")) { LexiconElement::render(OUT, session); return; }
+ if (Str::eq_wide_string(elt, L"Mp")) { MapElement::render(OUT, session, FALSE); return; }
+ if (Str::eq_wide_string(elt, L"MT")) { MapElement::render(OUT, session, TRUE); return; }
+ if (Str::eq_wide_string(elt, L"Ph")) { PhrasebookElement::render(OUT, session); return; }
+ if (Str::eq_wide_string(elt, L"Pl")) { PlotElement::render(OUT, session); return; }
+ if (Str::eq_wide_string(elt, L"Rl")) { RelationsElement::render(OUT, session); return; }
+ if (Str::eq_wide_string(elt, L"RS")) { RulesForScenesElement::render(OUT, session); return; }
+ if (Str::eq_wide_string(elt, L"St")) { StandardsElement::render(OUT, session); return; }
+ if (Str::eq_wide_string(elt, L"Tb")) { TablesElement::render(OUT, session); return; }
+ if (Str::eq_wide_string(elt, L"To")) { TokensElement::render(OUT, session); return; }
+ if (Str::eq_wide_string(elt, L"Vb")) { VerbsElement::render(OUT, session); return; }
+ if (Str::eq_wide_string(elt, L"Vl")) { ValuesElement::render(OUT, session); return; }
+ if (Str::eq_wide_string(elt, L"Xt")) { ExtrasElement::render(OUT, session); return; }
HTML_OPEN("p"); WRITE("NO CONTENT"); HTML_CLOSE("p");
}
diff --git a/inter/index-module/Chapter 3/Tokens Element.w b/inter/index-module/Chapter 3/Tokens Element.w
index 10f019f7b..737f9f819 100644
--- a/inter/index-module/Chapter 3/Tokens Element.w
+++ b/inter/index-module/Chapter 3/Tokens Element.w
@@ -3,14 +3,15 @@
To write the Tokens element (To) in the index.
@ =
-void TokensElement::render(OUTPUT_STREAM, localisation_dictionary *LD) {
+void TokensElement::render(OUTPUT_STREAM, index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
HTML_OPEN("p");
Localisation::roman(OUT, LD, I"Index.Elements.To.Explanation1");
HTML_CLOSE("p");
HTML_OPEN("p");
Localisation::roman(OUT, LD, I"Index.Elements.To.Explanation2");
HTML_CLOSE("p");
- inter_tree *I = InterpretIndex::get_tree();
+ inter_tree *I = Indexing::get_tree(session);
TokensElement::token(OUT, I, "anybody", NULL, I"someone_token", I"[someone]", LD);
TokensElement::token(OUT, I, "anyone", NULL, I"someone_token", I"[someone]", LD);
diff --git a/inter/index-module/Chapter 3/Values Element.w b/inter/index-module/Chapter 3/Values Element.w
index 422e8db37..4fc818304 100644
--- a/inter/index-module/Chapter 3/Values Element.w
+++ b/inter/index-module/Chapter 3/Values Element.w
@@ -6,9 +6,9 @@ To write the Values element (Vl) in the index.
quite different.
=
-void ValuesElement::render(OUTPUT_STREAM, localisation_dictionary *LD) {
- inter_tree *I = InterpretIndex::get_tree();
- tree_inventory *inv = Synoptic::inv(I);
+void ValuesElement::render(OUTPUT_STREAM, index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
+ tree_inventory *inv = Indexing::get_inventory(session);
TreeLists::sort(inv->variable_nodes, Synoptic::module_order);
@;
TreeLists::sort(inv->equation_nodes, Synoptic::module_order);
diff --git a/inter/index-module/Chapter 3/Verbs Element.w b/inter/index-module/Chapter 3/Verbs Element.w
index cbde075e3..8b0418009 100644
--- a/inter/index-module/Chapter 3/Verbs Element.w
+++ b/inter/index-module/Chapter 3/Verbs Element.w
@@ -6,13 +6,14 @@ To write the Verbs element (Vb) in the index.
be more usefully informative.
=
-void VerbsElement::render(OUTPUT_STREAM, localisation_dictionary *LD) {
+void VerbsElement::render(OUTPUT_STREAM, index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
HTML_OPEN("p");
Localisation::italic(OUT, LD, I"Index.Elements.Vb.About");
HTML_CLOSE("p");
int verb_count = 0;
- inter_lexicon *lexicon = InterpretIndex::get_lexicon();
+ inter_lexicon *lexicon = Indexing::get_lexicon(session);
for (index_lexicon_entry *lex = lexicon->first; lex; lex = lex->sorted_next)
if ((lex->part_of_speech == VERB_TLEXE) ||
(lex->part_of_speech == MVERB_TLEXE) ||
diff --git a/inter/index-module/Chapter 4/Render EPS Map.w b/inter/index-module/Chapter 4/Render EPS Map.w
index 2aac92287..70c2594e6 100644
--- a/inter/index-module/Chapter 4/Render EPS Map.w
+++ b/inter/index-module/Chapter 4/Render EPS Map.w
@@ -3,19 +3,19 @@
To render the spatial map of rooms as an EPS (Encapsulated PostScript) file.
@ =
-void RenderEPSMap::render_map_as_EPS(filename *F, localisation_dictionary *LD) {
- inter_tree *I = InterpretIndex::get_tree();
+void RenderEPSMap::render_map_as_EPS(filename *F, index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
@;
@;
}
@ =
- faux_instance_set *faux_set = InterpretIndex::get_faux_instances();
+ faux_instance_set *faux_set = Indexing::get_set_of_instances(session);
@;
for (int z=Universe.corner1.z; z>=Universe.corner0.z; z--)
@;
- FauxInstances::decode_hints(faux_set, I, 2);
+ FauxInstances::decode_hints(session, 2);
if (changed_global_room_colour == FALSE)
@;
@@ -45,7 +45,7 @@ void RenderEPSMap::render_map_as_EPS(filename *F, localisation_dictionary *LD) {
}
Str::clear(eml->titling);
- HTMLMap::devise_level_rubric(z, eml->titling, LD);
+ HTMLMap::devise_level_rubric(z, eml->titling, session);
if (Str::len(eml->titling) == 0) eml->contains_titling = FALSE;
else eml->contains_titling = TRUE;
@@ -65,8 +65,8 @@ void RenderEPSMap::render_map_as_EPS(filename *F, localisation_dictionary *LD) {
R->fimd.colour);
@ =
- text_stream EPS_struct; text_stream *EPS = &EPS_struct;
- if (STREAM_OPEN_TO_FILE(EPS, F, ISO_ENC) == FALSE) {
+ text_stream EPS_struct; text_stream *OUT = &EPS_struct;
+ if (STREAM_OPEN_TO_FILE(OUT, F, ISO_ENC) == FALSE) {
#ifdef CORE_MODULE
Problems::fatal_on_file("Can't open index file", F);
#endif
@@ -74,16 +74,16 @@ void RenderEPSMap::render_map_as_EPS(filename *F, localisation_dictionary *LD) {
Errors::fatal_with_file("can't open index file", F);
#endif
}
- RenderEPSMap::EPS_compile_map(EPS);
- STREAM_CLOSE(EPS);
+ faux_instance_set *faux_set = Indexing::get_set_of_instances(session);
+ @;
+ @;
+ STREAM_CLOSE(OUT);
-@ =
-void RenderEPSMap::EPS_compile_map(OUTPUT_STREAM) {
+@ =
int blh, /* total height of the EPS map area (not counting border) */
blw, /* total width of the EPS map area (not counting border) */
border = ConfigureIndexMap::get_int_mp(I"border-size", NULL),
vskip = ConfigureIndexMap::get_int_mp(I"vertical-spacing", NULL);
- faux_instance_set *faux_set = InterpretIndex::get_faux_instances();
@;
int bounding_box_width = blw+2*border, bounding_box_height = blh+2*border;
@@ -117,9 +117,6 @@ void RenderEPSMap::EPS_compile_map(OUTPUT_STREAM) {
}
}
- @;
-}
-
@ =
int total_chunk_height = 0, max_chunk_width = 0;
EPS_map_level *eml;
diff --git a/inter/index-module/Chapter 4/Render HTML Map.w b/inter/index-module/Chapter 4/Render HTML Map.w
index 98bdc6d91..50eb3d079 100644
--- a/inter/index-module/Chapter 4/Render HTML Map.w
+++ b/inter/index-module/Chapter 4/Render HTML Map.w
@@ -27,8 +27,8 @@ this icon position, and has the same indexing as the icon grid.
faux_instance **room_grid = NULL;
int *icon_grid = NULL, *exit_grid = NULL;
-void HTMLMap::calculate_map_grid(void) {
- faux_instance_set *faux_set = InterpretIndex::get_faux_instances();
+void HTMLMap::calculate_map_grid(index_session *session) {
+ faux_instance_set *faux_set = Indexing::get_set_of_instances(session);
@;
@;
@;
@@ -386,14 +386,15 @@ as the icon grid in order to be sure that the little 1 by 1 map for it (in
the details part of the World Index page) will be all right.
=
-void HTMLMap::render_map_as_HTML(OUTPUT_STREAM, localisation_dictionary *LD) {
- faux_instance_set *faux_set = InterpretIndex::get_faux_instances();
- HTMLMap::calculate_map_grid();
+void HTMLMap::render_map_as_HTML(OUTPUT_STREAM, index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
+ faux_instance_set *faux_set = Indexing::get_set_of_instances(session);
+ HTMLMap::calculate_map_grid(session);
@;
@;
- if (FauxInstances::no_rooms() >= 2) {
+ if (FauxInstances::no_rooms(session) >= 2) {
WRITE("\n\n");
HTML::comment(OUT, I"WORLD WRITE MAP BEGINS");
HTML_OPEN("p");
@@ -458,7 +459,7 @@ from each other.)
@ =
TEMPORARY_TEXT(level_rubric)
- HTMLMap::devise_level_rubric(z, level_rubric, LD);
+ HTMLMap::devise_level_rubric(z, level_rubric, session);
HTML_OPEN("tr"); HTML_OPEN("td");
int rounding = 0;
if (z == Universe.corner1.z) rounding = ROUND_BOX_TOP;
@@ -481,7 +482,7 @@ from each other.)
LOGIF(SPATIAL_MAP, "Level %d has rooms with %d <= y <= %d\n", z, y_min, y_max);
HTML_OPEN("tr"); HTML_OPEN("td");
- HTMLMap::plot_map_level(OUT, Universe.corner0.x, Universe.corner1.x, y_min, y_max, z, 1, LD);
+ HTMLMap::plot_map_level(OUT, Universe.corner0.x, Universe.corner1.x, y_min, y_max, z, 1, session);
HTML_CLOSE("td"); HTML_CLOSE("tr"); WRITE("\n");
@ =
@@ -493,7 +494,7 @@ from each other.)
@ =
faux_instance *D; int k = 0;
LOOP_OVER_FAUX_DIRECTIONS(faux_set, D) {
- faux_instance *A = SpatialMap::mapped_as_if(D);
+ faux_instance *A = SpatialMap::mapped_as_if(D, session);
if (A) {
k++;
if (k == 1) { HTML_OPEN("p"); } else WRITE("; ");
@@ -507,7 +508,8 @@ from each other.)
=
void HTMLMap::devise_level_rubric(int z, text_stream *level_rubric,
- localisation_dictionary *LD) {
+ index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
text_stream *key = I"Index.Elements.Mp.DefaultLevel";
int par = 0;
switch(Universe.corner1.z - Universe.corner0.z) {
@@ -517,7 +519,7 @@ void HTMLMap::devise_level_rubric(int z, text_stream *level_rubric,
if (z == Universe.corner1.z) key = I"Index.Elements.Mp.UpperLevel";
break;
default: {
- int z_offset = z - SpatialMap::benchmark_level();
+ int z_offset = z - SpatialMap::benchmark_level(session);
switch(z_offset) {
case 0: key = I"Index.Elements.Mp.StartingLevel"; break;
case 1: key = I"Index.Elements.Mp.FirstLevelUp"; break;
@@ -551,7 +553,7 @@ that the grids are calculated, the region colours decided, and so on.
=
void HTMLMap::render_single_room_as_HTML(OUTPUT_STREAM, faux_instance *R,
- localisation_dictionary *LD) {
+ index_session *session) {
WRITE("\n\n");
HTML_OPEN("p");
IndexUtilities::anchor(OUT, R->anchor_text);
@@ -559,11 +561,11 @@ void HTMLMap::render_single_room_as_HTML(OUTPUT_STREAM, faux_instance *R,
HTML::begin_plain_html_table(OUT);
HTML::first_html_column(OUT, 0);
vector P = Room_position(R);
- HTMLMap::plot_map_level(OUT, P.x, P.x, P.y, P.y, P.z, 2, LD);
+ HTMLMap::plot_map_level(OUT, P.x, P.x, P.y, P.y, P.z, 2, session);
HTML::next_html_column(OUT, 0);
WRITE(" ");
HTML::next_html_column(OUT, 0);
- MapElement::index(OUT, R, 1, FALSE, LD);
+ MapElement::index(OUT, R, 1, FALSE, session);
HTML::end_html_row(OUT);
HTML::end_html_table(OUT);
HTML_CLOSE("p");
@@ -577,7 +579,7 @@ index page.
=
void HTMLMap::plot_map_level(OUTPUT_STREAM, int x0, int x1, int y0, int y1, int z,
- int pass, localisation_dictionary *LD) {
+ int pass, index_session *session) {
if (pass == 1)
LOGIF(SPATIAL_MAP, "Plot: [%d, %d] x [%d, %d] x {%d}\n", x0, x1, y0, y1, z);
@@ -694,15 +696,15 @@ height, and they're drawn with a single stripe.
HTMLMap::begin_map_table(OUT, MAP_CELL_SIZE, MAP_CELL_OUTER_SIZE);
HTML_OPEN("tr");
HTML_OPEN("td");
- HTMLMap::plot_map_cell(OUT, pass, P, 0, 0, 2, LD);
+ HTMLMap::plot_map_cell(OUT, pass, P, 0, 0, 2, session);
if (icon_grid[ICON_GRID_POS(P, 0, 0)] & CONNECTIVE_BITMAP)
HTMLMap::plot_map_icon(OUT, I"s_dot"); else HTMLMap::plot_map_icon(OUT, I"ns_spacer");
- HTMLMap::plot_map_cell(OUT, pass, P, 1, 0, 8, LD);
- HTMLMap::plot_map_cell(OUT, pass, P, 2, 0, 0, LD);
- HTMLMap::plot_map_cell(OUT, pass, P, 3, 0, -1, LD);
+ HTMLMap::plot_map_cell(OUT, pass, P, 1, 0, 8, session);
+ HTMLMap::plot_map_cell(OUT, pass, P, 2, 0, 0, session);
+ HTMLMap::plot_map_cell(OUT, pass, P, 3, 0, -1, session);
if (icon_grid[ICON_GRID_POS(P, 4, 0)] & CONNECTIVE_BITMAP)
HTMLMap::plot_map_icon(OUT, I"s_dot"); else HTMLMap::plot_map_icon(OUT, I"ns_spacer");
- HTMLMap::plot_map_cell(OUT, pass, P, 4, 0, 1, LD);
+ HTMLMap::plot_map_cell(OUT, pass, P, 4, 0, 1, session);
HTML_CLOSE("td");
HTML_CLOSE("tr");
HTMLMap::end_map_table(OUT);
@@ -720,11 +722,11 @@ height, and they're drawn with a single stripe.
if (icon_grid[ICON_GRID_POS(P, 0, 0)] & CONNECTIVE_BITMAP)
HTMLMap::plot_map_icon(OUT, I"e_dot"); else HTMLMap::plot_map_icon(OUT, I"ew_spacer");
HTML_TAG("br");
- HTMLMap::plot_map_cell(OUT, pass, P, 0, 1, 11, LD);
+ HTMLMap::plot_map_cell(OUT, pass, P, 0, 1, 11, session);
HTML_TAG("br");
- HTMLMap::plot_map_cell(OUT, pass, P, 0, 2, 7, LD);
+ HTMLMap::plot_map_cell(OUT, pass, P, 0, 2, 7, session);
HTML_TAG("br");
- HTMLMap::plot_map_cell(OUT, pass, P, 0, 3, -1, LD);
+ HTMLMap::plot_map_cell(OUT, pass, P, 0, 3, -1, session);
HTML_TAG("br");
if (icon_grid[ICON_GRID_POS(P, 0, 4)] & CONNECTIVE_BITMAP)
HTMLMap::plot_map_icon(OUT, I"e_dot"); else HTMLMap::plot_map_icon(OUT, I"ew_spacer");
@@ -742,11 +744,11 @@ height, and they're drawn with a single stripe.
if (icon_grid[ICON_GRID_POS(P, 4, 0)] & CONNECTIVE_BITMAP)
HTMLMap::plot_map_icon(OUT, I"w_dot"); else HTMLMap::plot_map_icon(OUT, I"ew_spacer");
HTML_TAG("br");
- HTMLMap::plot_map_cell(OUT, pass, P, 4, 1, -1, LD);
+ HTMLMap::plot_map_cell(OUT, pass, P, 4, 1, -1, session);
HTML_TAG("br");
- HTMLMap::plot_map_cell(OUT, pass, P, 4, 2, 6, LD);
+ HTMLMap::plot_map_cell(OUT, pass, P, 4, 2, 6, session);
HTML_TAG("br");
- HTMLMap::plot_map_cell(OUT, pass, P, 4, 3, 10, LD);
+ HTMLMap::plot_map_cell(OUT, pass, P, 4, 3, 10, session);
HTML_TAG("br");
if (icon_grid[ICON_GRID_POS(P, 4, 4)] & CONNECTIVE_BITMAP)
HTMLMap::plot_map_icon(OUT, I"w_dot"); else HTMLMap::plot_map_icon(OUT, I"ew_spacer");
@@ -766,7 +768,7 @@ There are 15 possibilities, and their icons are named as the following shows:
HTML_OPEN("td");
int bits = (icon_grid[ICON_GRID_POS(P, 2, 2)]) & LONGS_BITMAP;
if (bits == 0)
- HTMLMap::index_room_square(OUT, room_grid[ROOM_GRID_POS(P)], pass);
+ HTMLMap::index_room_square(OUT, room_grid[ROOM_GRID_POS(P)], pass, session);
else {
TEMPORARY_TEXT(icon_name)
WRITE_TO(icon_name, "long");
@@ -785,15 +787,15 @@ There are 15 possibilities, and their icons are named as the following shows:
HTMLMap::begin_map_table(OUT, MAP_CELL_SIZE, MAP_CELL_OUTER_SIZE);
HTML_OPEN("tr");
HTML_OPEN("td");
- HTMLMap::plot_map_cell(OUT, pass, P, 0, 4, 5, LD);
+ HTMLMap::plot_map_cell(OUT, pass, P, 0, 4, 5, session);
if (icon_grid[ICON_GRID_POS(P, 0, 4)] & CONNECTIVE_BITMAP)
HTMLMap::plot_map_icon(OUT, I"n_dot"); else HTMLMap::plot_map_icon(OUT, I"ns_spacer");
- HTMLMap::plot_map_cell(OUT, pass, P, 1, 4, -1, LD);
- HTMLMap::plot_map_cell(OUT, pass, P, 2, 4, 3, LD);
- HTMLMap::plot_map_cell(OUT, pass, P, 3, 4, 9, LD);
+ HTMLMap::plot_map_cell(OUT, pass, P, 1, 4, -1, session);
+ HTMLMap::plot_map_cell(OUT, pass, P, 2, 4, 3, session);
+ HTMLMap::plot_map_cell(OUT, pass, P, 3, 4, 9, session);
if (icon_grid[ICON_GRID_POS(P, 4, 4)] & CONNECTIVE_BITMAP)
HTMLMap::plot_map_icon(OUT, I"n_dot"); else HTMLMap::plot_map_icon(OUT, I"ns_spacer");
- HTMLMap::plot_map_cell(OUT, pass, P, 4, 4, 4, LD);
+ HTMLMap::plot_map_cell(OUT, pass, P, 4, 4, 4, session);
HTML_CLOSE("td");
HTML_CLOSE("tr");
HTMLMap::end_map_table(OUT);
@@ -848,8 +850,9 @@ of the cell. First, the eight cells around the outside:
=
void HTMLMap::plot_map_cell(OUTPUT_STREAM, int pass, vector P, int i1, int i2,
- int faux_exit, localisation_dictionary *LD) {
- faux_instance_set *faux_set = InterpretIndex::get_faux_instances();
+ int faux_exit, index_session *session) {
+ localisation_dictionary *LD = Indexing::get_localisation(session);
+ faux_instance_set *faux_set = Indexing::get_set_of_instances(session);
int bitmap = icon_grid[ICON_GRID_POS(P, i1, i2)];
if (pass == 2) bitmap &= CONNECTIVE_BITMAP;
if (bitmap == 0) @
@@ -937,10 +940,10 @@ which are bordered and coloured single-cell tables.
@d ROOM_TEXT_COLOUR "000000"
=
-void HTMLMap::index_room_square(OUTPUT_STREAM, faux_instance *I, int pass) {
+void HTMLMap::index_room_square(OUTPUT_STREAM, faux_instance *I, int pass, index_session *session) {
if (I) {
int b = ROOM_BORDER_SIZE;
- if ((I == FauxInstances::benchmark()) && (pass == 1)) b = B_ROOM_BORDER_SIZE;
+ if ((I == FauxInstances::benchmark(session)) && (pass == 1)) b = B_ROOM_BORDER_SIZE;
HTML_OPEN_WITH("table",
"border=\"%d\" cellpadding=\"0\" cellspacing=\"0\" "
"bordercolor=\"#%s\" width=\"%d\" height=\"%d\" title=\"%S\"",
@@ -971,7 +974,7 @@ void HTMLMap::index_room_square(OUTPUT_STREAM, faux_instance *I, int pass) {
I->allocation_id);
HTML::begin_colour(OUT, col);
}
- if ((pass == 1) && (I == FauxInstances::benchmark())) HTML_OPEN("b");
+ if ((pass == 1) && (I == FauxInstances::benchmark(session))) HTML_OPEN("b");
TEMPORARY_TEXT(abbrev)
WRITE_TO(abbrev, "%S", I->abbrev);
#ifdef HTML_MAP_FONT_SIZE
@@ -982,7 +985,7 @@ void HTMLMap::index_room_square(OUTPUT_STREAM, faux_instance *I, int pass) {
#ifdef HTML_MAP_FONT_SIZE
HTML_CLOSE("span");
#endif
- if ((pass == 1) && (I == FauxInstances::benchmark())) HTML_CLOSE("b");
+ if ((pass == 1) && (I == FauxInstances::benchmark(session))) HTML_CLOSE("b");
if (pass == 1) { HTML::end_colour(OUT); HTML_CLOSE("a"); }
DISCARD_TEXT(abbrev)
@@ -1014,17 +1017,17 @@ The part of the World Index showing which rooms belong to which regions. Note
that nothing is shown if all of the rooms are outside of regions.
=
-void HTMLMap::add_region_key(OUTPUT_STREAM) {
- faux_instance_set *faux_set = InterpretIndex::get_faux_instances();
+void HTMLMap::add_region_key(OUTPUT_STREAM, index_session *session) {
+ faux_instance_set *faux_set = Indexing::get_set_of_instances(session);
faux_instance *reg; int count = 0;
LOOP_OVER_FAUX_REGIONS(faux_set, reg)
- count += HTMLMap::add_key_for(OUT, reg);
- if (count > 0) count += HTMLMap::add_key_for(OUT, NULL);
+ count += HTMLMap::add_key_for(OUT, reg, session);
+ if (count > 0) count += HTMLMap::add_key_for(OUT, NULL, session);
if (count > 0) HTML_TAG("hr");
}
-int HTMLMap::add_key_for(OUTPUT_STREAM, faux_instance *reg) {
- faux_instance_set *faux_set = InterpretIndex::get_faux_instances();
+int HTMLMap::add_key_for(OUTPUT_STREAM, faux_instance *reg, index_session *session) {
+ faux_instance_set *faux_set = Indexing::get_set_of_instances(session);
int count = 0;
faux_instance *R;
LOOP_OVER_FAUX_ROOMS(faux_set, R) {
@@ -1046,7 +1049,7 @@ int HTMLMap::add_key_for(OUTPUT_STREAM, faux_instance *reg) {
HTML::begin_plain_html_table(OUT);
HTML_OPEN("tr"); WRITE("\n");
HTML_OPEN_WITH("td", "width=\"40\" valign=\"middle\" align=\"left\"");
- HTMLMap::index_room_square(OUT, R, 1);
+ HTMLMap::index_room_square(OUT, R, 1, session);
HTML_CLOSE("td"); WRITE("\n");
HTML_OPEN_WITH("td", "valign=\"middle\" align=\"left\"");
WRITE("");
diff --git a/inter/index-module/Chapter 4/Spatial Map.w b/inter/index-module/Chapter 4/Spatial Map.w
index f0bfe347e..d42ce301c 100644
--- a/inter/index-module/Chapter 4/Spatial Map.w
+++ b/inter/index-module/Chapter 4/Spatial Map.w
@@ -73,6 +73,7 @@ typedef struct connected_submap {
int incidence_cache_size; /* how large that cache is */
struct cuboid incidence_cache_bounds; /* bounds of the incidence cache array */
int superpositions; /* number of pairs of rooms which share the same grid location */
+ struct index_session *for_session;
CLASS_DEFINITION
} connected_submap;
@@ -85,9 +86,9 @@ cuboid Universe;
This is usually the room in which the player begins.
=
-int SpatialMap::benchmark_level(void) {
- if (FauxInstances::benchmark() == NULL) return 0;
- return Room_position(FauxInstances::benchmark()).z;
+int SpatialMap::benchmark_level(index_session *session) {
+ if (FauxInstances::benchmark(session) == NULL) return 0;
+ return Room_position(FauxInstances::benchmark(session)).z;
}
@ We are going to be iterating through the set of rooms often. Looping over
@@ -133,9 +134,9 @@ to get the results in time to write them in the story file.
int spatial_coordinates_established = FALSE;
int partitioned_into_components = FALSE;
-void SpatialMap::establish_spatial_coordinates(void) {
+void SpatialMap::establish_spatial_coordinates(index_session *session) {
if (spatial_coordinates_established) return;
- faux_instance_set *faux_set = InterpretIndex::get_faux_instances();
+ faux_instance_set *faux_set = Indexing::get_set_of_instances(session);
Universe = Geometry::empty_cuboid();
@<(1) Create the spatial relationship arrays@>;
@<(2) Partition the set of rooms into component submaps@>;
@@ -211,8 +212,8 @@ When we read this, we associate direction object 13, say (the starboard
direction) with page direction 6:
=
-faux_instance *SpatialMap::mapped_as_if(faux_instance *I) {
- faux_instance_set *faux_set = InterpretIndex::get_faux_instances();
+faux_instance *SpatialMap::mapped_as_if(faux_instance *I, index_session *session) {
+ faux_instance_set *faux_set = Indexing::get_set_of_instances(session);
int i = I->direction_index;
if (story_dir_to_page_dir[i] == i) return NULL;
faux_instance *D;
@@ -332,7 +333,7 @@ we use these hard-wired macros instead.
for (i=0; i<12; i++)
@d LOOP_OVER_STORY_DIRECTIONS(i)
- for (i=0; ((ibounds = Geometry::empty_cuboid();
sub->first_room_in_submap = NULL;
@@ -626,6 +627,7 @@ connected_submap *SpatialMap::new_submap(void) {
sub->incidence_cache = NULL;
sub->incidence_cache_bounds = Geometry::empty_cuboid();
sub->superpositions = 0;
+ sub->for_session = session;
return sub;
}
@@ -797,7 +799,7 @@ since its rooms have all moved out.
=
void SpatialMap::create_submaps_from_zones(connected_submap *sub,
int Z1_number, connected_submap *Zone1, int Z2_number, connected_submap *Zone2) {
- faux_instance_set *faux_set = InterpretIndex::get_faux_instances();
+ faux_instance_set *faux_set = Indexing::get_set_of_instances(sub->for_session);
faux_instance *R;
LOOP_OVER_FAUX_ROOMS(faux_set, R) {
if (R->fimd.zone == Z1_number)
@@ -815,7 +817,7 @@ reverse process exactly.
=
void SpatialMap::create_zones_from_submaps(connected_submap *sub,
int Z1_number, connected_submap *Zone1, int Z2_number, connected_submap *Zone2) {
- faux_instance_set *faux_set = InterpretIndex::get_faux_instances();
+ faux_instance_set *faux_set = Indexing::get_set_of_instances(sub->for_session);
faux_instance *R;
LOOP_OVER_FAUX_ROOMS(faux_set, R) {
if (R->fimd.submap == Zone1) {
@@ -839,11 +841,11 @@ We ensure that the first-created component is the one containing the
benchmark room.
@<(2) Partition the set of rooms into component submaps@> =
- SpatialMap::create_map_component_around(FauxInstances::benchmark());
+ SpatialMap::create_map_component_around(FauxInstances::benchmark(session), session);
faux_instance *R;
LOOP_OVER_FAUX_ROOMS(faux_set, R)
if (R->fimd.submap == NULL)
- SpatialMap::create_map_component_around(R);
+ SpatialMap::create_map_component_around(R, session);
@ The following grows a component outwards from |at|, so that it also includes
all rooms locked to |at| or with a SR to it. If |at| is currently not in a
@@ -854,21 +856,21 @@ doesn't depend on $R$, the number of rooms. It is called exactly once for
each room, so phase (2) has running time $O(R)$.
=
-void SpatialMap::create_map_component_around(faux_instance *at) {
+void SpatialMap::create_map_component_around(faux_instance *at, index_session *session) {
if (at->fimd.submap == NULL)
- SpatialMap::add_room_to_submap(at, SpatialMap::new_submap());
+ SpatialMap::add_room_to_submap(at, SpatialMap::new_submap(session));
int i;
LOOP_OVER_LATTICE_DIRECTIONS(i) {
faux_instance *locked_to = SpatialMap::read_slock(at, i);
if ((locked_to) && (locked_to->fimd.submap != at->fimd.submap)) {
SpatialMap::add_room_to_submap(locked_to, at->fimd.submap);
- SpatialMap::create_map_component_around(locked_to);
+ SpatialMap::create_map_component_around(locked_to, session);
}
faux_instance *dest = SpatialMap::read_smap(at, i);
if ((dest) && (dest->fimd.submap != at->fimd.submap)) {
SpatialMap::add_room_to_submap(dest, at->fimd.submap);
- SpatialMap::create_map_component_around(dest);
+ SpatialMap::create_map_component_around(dest, session);
}
}
}
@@ -1245,8 +1247,8 @@ dividing at one relationship F1-to-T1 or at two, F1-to-T1 and F2-to-T2.
Z1_count, Z2_count);
@ =
- connected_submap *Zone1 = SpatialMap::new_submap();
- connected_submap *Zone2 = SpatialMap::new_submap();
+ connected_submap *Zone1 = SpatialMap::new_submap(sub->for_session);
+ connected_submap *Zone2 = SpatialMap::new_submap(sub->for_session);
SpatialMap::create_submaps_from_zones(sub, Z1_number, Zone1, Z2_number, Zone2);
LOGIF(SPATIAL_MAP, "Zone 1 becomes submap %d; zone 2 becomes submap %d\n",
Zone1->allocation_id, Zone2->allocation_id);
@@ -2368,7 +2370,7 @@ predecessor, with the same baseline, and on the level of the benchmark room.
sub->allocation_id, sub->bounds.population);
SpatialMap::move_component(sub,
Geometry::vec(x_max, box.corner0.y - sub->bounds.corner0.y,
- SpatialMap::benchmark_level() - sub->bounds.corner0.z));
+ SpatialMap::benchmark_level(session) - sub->bounds.corner0.z));
@ The drill square is a way to place large numbers of single-room components,
such as exist in IF works where rooms are being plaited together live during
@@ -2383,7 +2385,7 @@ one big component.
sub->allocation_id, sub->bounds.population);
if (drill_square_side == 0) {
Drill_square_O =
- Geometry::vec(box.corner1.x + 1, box.corner0.y, SpatialMap::benchmark_level());
+ Geometry::vec(box.corner1.x + 1, box.corner0.y, SpatialMap::benchmark_level(session));
Drill_square_At = Drill_square_O;
connected_submap *sing;
int N = 0;
@@ -2414,7 +2416,7 @@ with.
SpatialMap::find_link_to_placed_components(sub, &outer, &inner);
vector Best_offset =
Geometry::vec(x_max, box.corner0.y - sub->bounds.corner0.y,
- SpatialMap::benchmark_level() - sub->bounds.corner0.z);
+ SpatialMap::benchmark_level(session) - sub->bounds.corner0.z);
if ((outer) && (inner)) {
int dx = 0, dy = 0, dz = 0, min_s = FUSION_POINT;
for (dx = -MAX_OFFSET; dx <= MAX_OFFSET; dx++)
@@ -2542,7 +2544,7 @@ rooms connected that way are by definition in the same component.
=
int SpatialMap::cross_component_links(connected_submap *sub, faux_instance **outer,
faux_instance **inner, int *heat, int posnd) {
- faux_instance_set *faux_set = InterpretIndex::get_faux_instances();
+ faux_instance_set *faux_set = Indexing::get_set_of_instances(sub->for_session);
int no_links = 0;
if (heat) *heat = 0;
faux_instance *R;
@@ -2681,9 +2683,10 @@ locking means that blank planes are inevitable.
@
=
-void SpatialMap::index_room_connections(OUTPUT_STREAM, faux_instance *R) {
+void SpatialMap::index_room_connections(OUTPUT_STREAM, faux_instance *R,
+ index_session *session) {
text_stream *RW = FauxInstances::get_name(R); /* name of the origin room */
- faux_instance_set *faux_set = InterpretIndex::get_faux_instances();
+ faux_instance_set *faux_set = Indexing::get_set_of_instances(session);
faux_instance *dir;
LOOP_OVER_FAUX_DIRECTIONS(faux_set, dir) {
int i = dir->direction_index;
@@ -2762,7 +2765,7 @@ void SpatialMap::index_room_connections(OUTPUT_STREAM, faux_instance *R) {
@h Unit testing.
=
-void SpatialMap::perform_map_internal_test(OUTPUT_STREAM) {
+void SpatialMap::perform_map_internal_test(OUTPUT_STREAM, index_session *session) {
connected_submap *sub;
LOOP_OVER(sub, connected_submap) {
WRITE("Map component %d: extent (%d...%d, %d...%d, %d...%d): population %d\n",
@@ -2778,7 +2781,7 @@ void SpatialMap::perform_map_internal_test(OUTPUT_STREAM) {
Room_position(R).y,
Room_position(R).z);
FauxInstances::write_name(OUT, R);
- if (R == FauxInstances::benchmark()) WRITE(" (benchmark)");
+ if (R == FauxInstances::benchmark(session)) WRITE(" (benchmark)");
WRITE("\n");
}
WRITE("\n");
diff --git a/inter/index-module/Contents.w b/inter/index-module/Contents.w
index e2aa73c13..98876695d 100644
--- a/inter/index-module/Contents.w
+++ b/inter/index-module/Contents.w
@@ -6,6 +6,7 @@ Licence: Artistic License 2.0
Chapter 1: Starting Up
Index Module
+ Indexing API
Chapter 2: Utilities
Index Locations