From 3be1d59280d0614e23f968b928c4d73c4113a466 Mon Sep 17 00:00:00 2001
From: Ralph Amissah <ralph@amissah.com>
Date: Tue, 31 Jul 2018 10:37:33 -0400
Subject: 0.26.6 prepare for parallelism, remove __gshared

---
 org/meta_abstraction.org | 74 ++++++++++++++++++++++++++++++++++--------------
 org/sdp.org              |  3 +-
 2 files changed, 55 insertions(+), 22 deletions(-)

(limited to 'org')

diff --git a/org/meta_abstraction.org b/org/meta_abstraction.org
index 18bf8d6..05f204d 100644
--- a/org/meta_abstraction.org
+++ b/org/meta_abstraction.org
@@ -41,6 +41,7 @@ template SiSUdocAbstraction() {
     CMM                  conf_make_meta,
     Opt                  opt_action,
     Mfst                 manifest_matter,
+    bool                 _new_doc
   ) {
     static auto rgx = Rgx();
     debug(asserts) {
@@ -1156,10 +1157,16 @@ if ((obj_type_status["heading"] == State.on)
   an_object["is"] = "heading";
   an_object_key="body_nugget";
   auto substantive_object_and_anchor_tags_tuple
-    = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta);
+    = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, _new_doc);
   an_object["substantive"] = substantive_object_and_anchor_tags_tuple[sObj.content];
   anchor_tags = substantive_object_and_anchor_tags_tuple[sObj.anchor_tags];
-  if (an_object["lev_markup_number"].to!int == 4) {
+  if (_new_doc) {
+    cnt1 = 1;
+    cnt2 = 1;
+    cnt3 = 1;
+    _new_doc = false;
+  }
+  if (an_object["lev_markup_number"].to!int == 4 ) {
     segment_anchor_tag_that_object_belongs_to = anchor_tags[0];
     segment_anchor_tag_that_object_belongs_to_uri = anchor_tags[0] ~ ".fnSuffix";
     anchor_tag_ = anchor_tags[0];
@@ -1264,7 +1271,7 @@ if ((obj_type_status["heading"] == State.on)
       an_object["is"],
     );
   auto substantive_obj_misc_tuple
-    = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta);
+    = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false);
   an_object["substantive"] = substantive_obj_misc_tuple[sObj.content];
   anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags];
   comp_obj_para                                             = comp_obj_para.init;
@@ -2673,6 +2680,12 @@ if (the_document_body_section.length > 1) {
     the_bookindex_section["scroll"] ~
     the_blurb_section
   );
+  debug(decendants_tuple) {
+    pairs = pairs.sort();
+    foreach (pair; pairs) {  // (pair; pairs.sort())
+      writeln(pair[0], "..", pair[1]);
+    }
+  }
   foreach (ref obj; the_document_head_section) {
     if (obj.metainfo.is_a == "heading") {
       foreach (pair; pairs) {
@@ -3749,7 +3762,7 @@ void _poem_block_(L,O,T,C,N,CMM)(
           }
           an_object["is"]                           = "verse";
           auto substantive_obj_misc_tuple
-            = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta);
+            = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false);
           an_object["substantive"] = substantive_obj_misc_tuple[sObj.content];
           anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags];
           comp_obj_block                               = comp_obj_block.init;
@@ -3806,7 +3819,7 @@ void _poem_block_(L,O,T,C,N,CMM)(
           an_object["is"]
         );
         auto substantive_obj_misc_tuple
-          = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta);
+          = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false);
         an_object["substantive"] = substantive_obj_misc_tuple[sObj.content];
         anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags];
         comp_obj_block                               = comp_obj_block.init;
@@ -3848,7 +3861,7 @@ void _poem_block_(L,O,T,C,N,CMM)(
         processing.remove("verse");
         an_object["is"]                           = "verse";
         auto substantive_obj_misc_tuple
-          = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta);
+          = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false);
         an_object["substantive"] = substantive_obj_misc_tuple[sObj.content];
         anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags];
         comp_obj_block                               = comp_obj_block.init;
@@ -3905,7 +3918,7 @@ void _poem_block_(L,O,T,C,N,CMM)(
             an_object["is"]
           );
         auto substantive_obj_misc_tuple
-          = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta);
+          = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false);
         an_object["substantive"] = substantive_obj_misc_tuple[sObj.content];
         anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags];
         comp_obj_block                               = comp_obj_block.init;
@@ -4049,7 +4062,7 @@ void _table_closed_make_special_notation_table_(N,CMM)(
       );
     an_object["is"] = "table";
     auto substantive_obj_misc_tuple
-      = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, "body_nugget", conf_make_meta);
+      = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, "body_nugget", conf_make_meta, false);
     an_object["substantive"]                     = substantive_obj_misc_tuple[sObj.content];
     comp_obj_block.metainfo.ocn                  = obj_cite_digits.on;
     comp_obj_block.metainfo.object_number_off    = (obj_cite_digits.off==0)   ? "" : obj_cite_digits.off.to!string;
@@ -4120,7 +4133,7 @@ void _block_flag_line_empty_(B,N,CMM)(
         an_object["is"]
       );
     auto substantive_obj_misc_tuple
-      = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta);
+      = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false);
     an_object["substantive"] = substantive_obj_misc_tuple[sObj.content];
     anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags];
     comp_obj_block                               = comp_obj_block.init;
@@ -4169,7 +4182,7 @@ void _block_flag_line_empty_(B,N,CMM)(
         an_object["is"]
       );
     auto substantive_obj_misc_tuple
-      = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta);
+      = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false);
     an_object["substantive"] = substantive_obj_misc_tuple[sObj.content];
     anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags];
     comp_obj_block                               = comp_obj_block.init;
@@ -4218,7 +4231,7 @@ void _block_flag_line_empty_(B,N,CMM)(
         an_object["is"]
       );
     auto substantive_obj_misc_tuple
-      = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta);
+      = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false);
     an_object["substantive"]                     = substantive_obj_misc_tuple[sObj.content];
     comp_obj_block                               = comp_obj_block.init;
     comp_obj_block.metainfo.is_of_part           = "body";
@@ -4306,7 +4319,7 @@ void _block_flag_line_empty_(B,N,CMM)(
         an_object["is"]
       );
     auto substantive_obj_misc_tuple
-      = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta);
+      = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false);
     an_object["substantive"] = substantive_obj_misc_tuple[sObj.content];
     anchor_tags = substantive_obj_misc_tuple[sObj.anchor_tags];
     comp_obj_code                                = comp_obj_code.init;
@@ -4356,7 +4369,7 @@ void _block_flag_line_empty_(B,N,CMM)(
         an_object["is"]
       );
     auto substantive_obj_misc_tuple
-      = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta);
+      = obj_im.obj_inline_markup_and_anchor_tags_and_misc(an_object, an_object_key, conf_make_meta, false);
     an_object["substantive"]                     = substantive_obj_misc_tuple[sObj.content];
     comp_obj_block                               = comp_obj_block.init;
     comp_obj_block.metainfo.ocn                  = obj_cite_digits.on;
@@ -5639,6 +5652,8 @@ static struct ObjInlineMarkup {
   static auto rgx = Rgx();
   static auto munge = ObjInlineMarkupMunge();
   string[string] obj_txt;
+  static string[] anchor_tags_ = [];
+  static string anchor_tag = "";
 #+END_SRC
 
 ******* object inline markup and anchor tags              :markup:inline:
@@ -5649,6 +5664,7 @@ static struct ObjInlineMarkup {
     O   obj_,
     K   obj_key_,
     CMM conf_make_meta,
+    bool _new_doc
   )
   in {
     debug(asserts) {
@@ -5661,7 +5677,9 @@ static struct ObjInlineMarkup {
     obj_txt["munge"] = (obj_["is"].match(ctRegex!(`verse|code`)))
     ? obj_txt["munge"]
     : obj_txt["munge"].strip;
-    static __gshared string[] anchor_tags_ = [];
+    if (_new_doc) {
+      anchor_tags_ = [];
+    }
     auto x = munge.init;
     bool[string] obj_notes_and_links;
     obj_notes_and_links["notes_reg"]           = false;
@@ -5670,9 +5688,11 @@ static struct ObjInlineMarkup {
     obj_notes_and_links["image_no_dimensions"] = false;
     switch (obj_["is"]) {
     case "heading":
-      static __gshared string anchor_tag = "";
-      obj_txt["munge"]=_configured_auto_heading_numbering_and_segment_anchor_tags(obj_txt["munge"], obj_, conf_make_meta);
-      obj_txt["munge"]=_make_segment_anchor_tags_if_none_provided(obj_txt["munge"], obj_["lev"]);
+      if (_new_doc) {
+        anchor_tag = "";
+      }
+      obj_txt["munge"]=_configured_auto_heading_numbering_and_segment_anchor_tags(obj_txt["munge"], obj_, conf_make_meta, _new_doc);
+      obj_txt["munge"]=_make_segment_anchor_tags_if_none_provided(obj_txt["munge"], obj_["lev"], _new_doc);
       if (auto m = obj_txt["munge"].match(rgx.heading_anchor_tag)) {
         anchor_tag = m.captures[1];
         anchor_tags_ ~= anchor_tag;
@@ -5930,17 +5950,22 @@ private:
 
 #+name: meta_emitters_obj_inline_markup_heading_numbering_segment_anchor_tags
 #+BEGIN_SRC d
+  static int[] heading_num = [ 0, 0, 0, 0 ];
+  static string heading_number_auto_composite = "";
   static string _configured_auto_heading_numbering_and_segment_anchor_tags(M,O,CMM)(
     M   munge_,
     O   obj_,
     CMM conf_make_meta,
+    bool _new_doc
   ) {
     debug(asserts) {
       static assert(is(typeof(munge_)          == string));
       static assert(is(typeof(obj_)            == string[string]));
     }
-    static __gshared int[] heading_num = [ 0, 0, 0, 0 ];
-    static __gshared string heading_number_auto_composite = "";
+    if (_new_doc) {
+      heading_num = [ 0, 0, 0, 0 ];
+      heading_number_auto_composite = "";
+    }
     if (conf_make_meta.make.auto_num_top_lv) {
       if (obj_["lev_markup_number"].to!int == 0) {
         heading_num[0] = 0;
@@ -6040,7 +6065,12 @@ private:
 
 #+name: meta_emitters_obj_inline_markup_heading_numbering_segment_anchor_tags
 #+BEGIN_SRC d
-  static string _make_segment_anchor_tags_if_none_provided(M,Lv)(M munge_, Lv lev_) {
+  static int heading_num_lev1 = 0;
+  static string _make_segment_anchor_tags_if_none_provided(M,Lv)(
+    M munge_,
+    Lv lev_,
+    bool _new_doc
+  ) {
     debug(asserts) {
       static assert(is(typeof(munge_) == string));
       static assert(is(typeof(lev_)   == string));
@@ -6057,7 +6087,9 @@ private:
             "$1~" ~ "s" ~ m.captures[1] ~ " ");
         }
       } else if (lev_ == "1") { // (if not successful) manufacture a unique anchor tag for lev=="1"
-        static __gshared int heading_num_lev1 = 0;
+        if (_new_doc) {
+          heading_num_lev1 = 0;
+        }
         heading_num_lev1 ++;
         munge_=(munge_).replaceFirst(
           rgx.heading_marker_missing_tag,
diff --git a/org/sdp.org b/org/sdp.org
index 8796a6b..83e0b4e 100644
--- a/org/sdp.org
+++ b/org/sdp.org
@@ -26,7 +26,7 @@ struct Version {
   int minor;
   int patch;
 }
-enum ver = Version(0, 26, 5);
+enum ver = Version(0, 26, 6);
 #+END_SRC
 
 ** compilation restrictions (supported compilers)
@@ -856,6 +856,7 @@ auto da = SiSUdocAbstraction!()(
   _make_and_meta_struct,
   _opt_action,
   _manifest,
+  true,
 );
 static assert(!isTypeTuple!(da));
 static assert(da.length==5);
-- 
cgit v1.2.3