From d7966a333d107ff9372fb33a5a9dbc21425ab63d Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 15 May 2019 17:03:30 -0400 Subject: doc_abstraction reduce use of return ref, check --- org/meta_abstraction.org | 160 +++++++++++++++++++++++++---------------------- 1 file changed, 84 insertions(+), 76 deletions(-) (limited to 'org') diff --git a/org/meta_abstraction.org b/org/meta_abstraction.org index d6d687e..8f2b76a 100644 --- a/org/meta_abstraction.org +++ b/org/meta_abstraction.org @@ -832,7 +832,7 @@ if there is a glossary section you need to: tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html; tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub; } else { - line.flow_para_match_(an_object, an_object_key, indent, bullet, obj_type_status, line_occur); + an_object = line.flow_para_match_(an_object, an_object_key, indent, bullet, obj_type_status, line_occur); comp_obj_para = comp_obj_para.init; comp_obj_para.metainfo.is_of_part = "backmatter"; comp_obj_para.metainfo.is_of_section = "glossary"; @@ -993,7 +993,7 @@ if there is a blurb section you need to: tag_assoc[comp_obj_heading_.tags.anchor_tag_html]["seg_lv4"] = comp_obj_heading_.tags.in_segment_html; tag_assoc[comp_obj_heading_.tags.segment_anchor_tag_epub]["seg_lv1_to_4"] = comp_obj_heading_.tags.segment_anchor_tag_epub; } else { - line.flow_para_match_(an_object, an_object_key, indent, bullet, obj_type_status, line_occur); + an_object = line.flow_para_match_(an_object, an_object_key, indent, bullet, obj_type_status, line_occur); comp_obj_para = comp_obj_para.init; comp_obj_para.metainfo.is_of_part = "backmatter"; comp_obj_para.metainfo.is_of_section = "blurb"; @@ -1024,7 +1024,7 @@ if there is a blurb section you need to: line = line ._doc_header_and_make_substitutions_(conf_make_meta) ._doc_header_and_make_substitutions_fontface_(conf_make_meta); - line.flow_txt_block_quote(an_object, obj_type_status); + an_object = line.flow_txt_block_quote(an_object, obj_type_status); continue; #+END_SRC @@ -1038,7 +1038,7 @@ if there is a blurb section you need to: ._doc_header_and_make_substitutions_(conf_make_meta) ._doc_header_and_make_substitutions_fontface_(conf_make_meta) .replaceAll(rgx.para_delimiter, mkup.br_paragraph ~ "$1"); - line.flow_txt_block_group(an_object, obj_type_status); + an_object = line.flow_txt_block_group(an_object, obj_type_status); continue; #+END_SRC @@ -1054,7 +1054,7 @@ if there is a blurb section you need to: line = line .replaceAll(rgx.spaces_keep, (m.captures[1]).translate([ ' ' : mkup.nbsp ])); } - line.flow_txt_block_block(an_object, obj_type_status); + an_object = line.flow_txt_block_block(an_object, obj_type_status); continue; #+END_SRC @@ -1063,7 +1063,7 @@ if there is a blurb section you need to: #+name: abs_in_loop_body_non_code_obj #+BEGIN_SRC d } else if (obj_type_status["poem"] == TriState.on) { /+ within block object: poem +/ - line.flow_txt_block_poem(an_object, obj_type_status, cntr, object_number_poem, conf_make_meta, tag_in_seg); + an_object = line.flow_txt_block_poem(an_object, obj_type_status, cntr, object_number_poem, conf_make_meta, tag_in_seg); continue; #+END_SRC @@ -1072,7 +1072,7 @@ if there is a blurb section you need to: #+name: abs_in_loop_body_non_code_obj #+BEGIN_SRC d } else if (obj_type_status["table"] == TriState.on) { /+ within block object: table +/ - line.flow_txt_block_table(an_object, obj_type_status, conf_make_meta); + an_object = line.flow_txt_block_table(an_object, obj_type_status, conf_make_meta); continue; #+END_SRC @@ -1138,7 +1138,7 @@ if (obj_type_status["blocks"] == TriState.closing) { if (line.matchFirst(rgx.book_index) || line.matchFirst(rgx.book_index_open) || obj_type_status["book_index"] == State.on ) { /+ book_index +/ - line.flow_book_index_(book_idx_tmp, an_object, obj_type_status, opt_action); + an_object = line.flow_book_index_(an_object, book_idx_tmp, obj_type_status, opt_action); #+END_SRC ******* not book index [+1] @@ -1180,7 +1180,7 @@ if (line.matchFirst(rgx.book_index) && (obj_type_status["heading"] == State.off))) { /+ heading or para but neither flag nor line exists +/ if ((conf_make_meta.make.headings.length > 2) && (obj_type_status["make_headings"] == State.off)) { /+ heading found +/ - line.flow_heading_found_(conf_make_meta.make.headings, heading_match_str, heading_match_rgx, obj_type_status); + heading_match_str = line.flow_heading_found_(heading_match_str, conf_make_meta.make.headings, heading_match_rgx, obj_type_status); } if ((obj_type_status["make_headings"] == State.on) && ((line_occur["para"] == State.off) @@ -1197,13 +1197,13 @@ if (line.matchFirst(rgx.book_index) +/ if (line.matchFirst(rgx.heading)) { /+ heading match +/ line = line._doc_header_and_make_substitutions_(conf_make_meta); - line.flow_heading_matched_(line_occur, an_object, an_object_key, lv, collapsed_lev, obj_type_status, conf_make_meta); + an_object = line.flow_heading_matched_(an_object, line_occur, an_object_key, lv, collapsed_lev, obj_type_status, conf_make_meta); } else if (line_occur["para"] == State.off) { /+ para match +/ an_object_key="body_nugget"; line = line ._doc_header_and_make_substitutions_(conf_make_meta) ._doc_header_and_make_substitutions_fontface_(conf_make_meta); - line.flow_para_match_(an_object, an_object_key, indent, bullet, obj_type_status, line_occur); + an_object = line.flow_para_match_(an_object, an_object_key, indent, bullet, obj_type_status, line_occur); } #+END_SRC @@ -1240,10 +1240,9 @@ if (line.matchFirst(rgx.book_index) #+name: abs_in_loop_body_not_block_obj_line_empty_blocks_flags #+BEGIN_SRC d -flow_block_flag_line_empty_( - bookindex_extract_hash, - line, +an_object = line.flow_block_flag_line_empty_( an_object, + bookindex_extract_hash, the_document_body_section, bookindex_unordered_hashes, obj_cite_digits, @@ -3802,9 +3801,9 @@ void flow_txt_block_biblio( #+name: abs_functions_block_quote #+BEGIN_SRC d -void flow_txt_block_quote(L,O,T)( +auto flow_txt_block_quote(L,O,T)( L line, - return ref O an_object, + O an_object, return ref T obj_type_status ) { debug(asserts) { @@ -3844,6 +3843,7 @@ void flow_txt_block_quote(L,O,T)( an_object[an_object_key] ~= line ~= "\n"; // build quote array (or string) } } + return an_object; } #+END_SRC @@ -3854,9 +3854,9 @@ void flow_txt_block_quote(L,O,T)( #+name: abs_functions_block_group #+BEGIN_SRC d -void flow_txt_block_group(L,O,T)( +auto flow_txt_block_group(L,O,T)( L line, - return ref O an_object, + O an_object, return ref T obj_type_status ) { debug(asserts) { @@ -3896,6 +3896,7 @@ void flow_txt_block_group(L,O,T)( an_object[an_object_key] ~= line ~= "\n"; // build group array (or string) } } + return an_object; } #+END_SRC @@ -3907,9 +3908,9 @@ void flow_txt_block_group(L,O,T)( #+name: abs_functions_block_block #+BEGIN_SRC d -void flow_txt_block_block(L,O,T)( +auto flow_txt_block_block(L,O,T)( L line, - return ref O an_object, + O an_object, return ref T obj_type_status ) { debug(asserts) { @@ -3949,6 +3950,7 @@ void flow_txt_block_block(L,O,T)( an_object[an_object_key] ~= line ~= "\n"; // build block array (or string) } } + return an_object; } #+END_SRC @@ -3958,9 +3960,9 @@ why extra object stuff only in poem/verse? #+name: abs_functions_block_poem #+BEGIN_SRC d -void flow_txt_block_poem(L,O,T,C,N,CMM,Ts)( +auto flow_txt_block_poem(L,O,T,C,N,CMM,Ts)( L line, - return ref O an_object, + O an_object, return ref T obj_type_status, return ref C cntr, N object_number_poem, @@ -4205,6 +4207,7 @@ void flow_txt_block_poem(L,O,T,C,N,CMM,Ts)( } } } + return an_object; } #+END_SRC @@ -4228,9 +4231,9 @@ you need: #+name: abs_functions_block_table #+BEGIN_SRC d -void flow_txt_block_table(L,O,T,CMM)( +auto flow_txt_block_table(L,O,T,CMM)( L line, - return ref O an_object, + O an_object, return ref T obj_type_status, return ref CMM conf_make_meta, ) { @@ -4259,8 +4262,7 @@ void flow_txt_block_table(L,O,T,CMM)( obj_type_status["blocks"] = TriState.off; obj_type_status["table"] = TriState.off; obj_type_status["curly_table_special_markup"] = TriState.off; - flow_table_closed_make_special_notation_table_( - line, + line.flow_table_closed_make_special_notation_table_( an_object, the_document_body_section, obj_cite_digits, @@ -4290,6 +4292,7 @@ void flow_txt_block_table(L,O,T,CMM)( an_object[an_object_key] ~= line ~= "\n"; // build table array (or string) } } + return an_object; } #+END_SRC @@ -4304,7 +4307,7 @@ process and use an_object["table_head"] (then empty it) #+name: abs_functions_block_line_status_empty #+BEGIN_SRC d void flow_table_closed_make_special_notation_table_(N,CMM)( - char[] line, + char[] line, return ref string[string] an_object, return ref ObjGenericComposite[] the_document_body_section, return ref N obj_cite_digits, @@ -4313,36 +4316,36 @@ void flow_table_closed_make_special_notation_table_(N,CMM)( return ref int[string] obj_type_status, CMM conf_make_meta ) { - comp_obj_block = comp_obj_block.init; - obj_cite_digits = ocn_emit(obj_type_status["ocn_status"]); - auto comp_obj_location - = node_construct.node_location_emitter( - content_non_header, - tag_in_seg, - lev_anchor_tag, - tag_assoc, - obj_cite_digits, - cntr, - heading_ptr-1, - "table" - ); - 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, No._new_doc); - an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; - comp_obj_block.metainfo.ocn = obj_cite_digits.object_number; - comp_obj_block.metainfo.identifier = obj_cite_digits.identifier; - comp_obj_block.metainfo.object_number_off = obj_cite_digits.off; - comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; - comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; - comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; - comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; - comp_obj_block = comp_obj_block.flow_table_instructions(an_object["table_head"]); - comp_obj_block = comp_obj_block.flow_table_substantive_munge_special(an_object["substantive"]); - the_document_body_section ~= comp_obj_block; - object_reset(an_object); - processing.remove("verse"); - ++cntr; + comp_obj_block = comp_obj_block.init; + obj_cite_digits = ocn_emit(obj_type_status["ocn_status"]); + auto comp_obj_location + = node_construct.node_location_emitter( + content_non_header, + tag_in_seg, + lev_anchor_tag, + tag_assoc, + obj_cite_digits, + cntr, + heading_ptr-1, + "table" + ); + 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, No._new_doc); + an_object["substantive"] = substantive_obj_misc_tuple[sObj.content]; + comp_obj_block.metainfo.ocn = obj_cite_digits.object_number; + comp_obj_block.metainfo.identifier = obj_cite_digits.identifier; + comp_obj_block.metainfo.object_number_off = obj_cite_digits.off; + comp_obj_block.tags.html_segment_anchor_tag_is = tag_in_seg["seg_lv4"]; + comp_obj_block.tags.epub_segment_anchor_tag_is = tag_in_seg["seg_lv1_to_4"]; + comp_obj_block.metainfo.o_n_book_index = obj_cite_digits.bkidx; + comp_obj_block.metainfo.object_number_type = obj_cite_digits.type; + comp_obj_block = comp_obj_block.flow_table_instructions(an_object["table_head"]); + comp_obj_block = comp_obj_block.flow_table_substantive_munge_special(an_object["substantive"]); + the_document_body_section ~= comp_obj_block; + object_reset(an_object); + processing.remove("verse"); + ++cntr; } #+END_SRC @@ -4352,10 +4355,10 @@ void flow_table_closed_make_special_notation_table_(N,CMM)( #+name: abs_functions_block_line_status_empty #+BEGIN_SRC d -void flow_block_flag_line_empty_(B,N,CMM,Ts)( - B bookindex_extract_hash, - char[] line, - return ref string[string] an_object, +auto flow_block_flag_line_empty_(B,N,CMM,Ts)( + char[] line, + string[string] an_object, + B bookindex_extract_hash, return ref ObjGenericComposite[] the_document_body_section, return ref string[][string][string] bookindex_unordered_hashes, return ref N obj_cite_digits, @@ -4700,6 +4703,7 @@ void flow_block_flag_line_empty_(B,N,CMM,Ts)( #+name: abs_functions_block_line_status_empty #+BEGIN_SRC d + return an_object; } #+END_SRC @@ -4708,11 +4712,11 @@ void flow_block_flag_line_empty_(B,N,CMM,Ts)( #+name: abs_functions_book_index #+BEGIN_SRC d auto flow_book_index_(L,I,O,T,B)( - L line, - return ref I book_idx_tmp, - return ref O an_object, + L line, + O an_object, + I book_idx_tmp, return ref T obj_type_status, - B opt_action, + B opt_action, ) { debug(asserts) { static assert(is(typeof(line) == char[])); @@ -4761,6 +4765,7 @@ auto flow_book_index_(L,I,O,T,B)( } } } + return an_object; } #+END_SRC @@ -4769,10 +4774,10 @@ auto flow_book_index_(L,I,O,T,B)( #+name: abs_functions_heading #+BEGIN_SRC d -auto flow_heading_found_(L,X,H,R,T)( - L line, - X _make_unmarked_headings, - return ref H heading_match_str, +auto flow_heading_found_(L,H,X,R,T)( + L line, + H heading_match_str, + X _make_unmarked_headings, return ref R heading_match_rgx, return ref T obj_type_status ) { @@ -4855,6 +4860,7 @@ auto flow_heading_found_(L,X,H,R,T)( } obj_type_status["make_headings"] = State.on; } + return heading_match_str; } #+END_SRC @@ -4932,8 +4938,8 @@ auto flow_heading_make_set_(L,C,R,T)( #+BEGIN_SRC d auto flow_heading_matched_(L,C,O,K,Lv,Lc,T,CMM)( L line, + O an_object, return ref C line_occur, - return ref O an_object, return ref K an_object_key, return ref Lv lv, return ref Lc collapsed_lev, @@ -5083,6 +5089,7 @@ auto flow_heading_matched_(L,C,O,K,Lv,Lc,T,CMM)( writeln(line.strip); } } + return an_object; } #+END_SRC @@ -5090,9 +5097,9 @@ auto flow_heading_matched_(L,C,O,K,Lv,Lc,T,CMM)( #+name: abs_functions_para #+BEGIN_SRC d -void flow_para_match_(L,O,K,I,B,T,C)( +auto flow_para_match_(L,O,K,I,B,T,C)( L line, - return ref O an_object, + O an_object, return ref K an_object_key, return ref I indent, return ref B bullet, @@ -5134,7 +5141,7 @@ void flow_para_match_(L,O,K,I,B,T,C)( debug(paraindenthang) { writeln(line); } - indent=[ + indent = [ "hang_position" : (m["hang"]).to!int, "base_position" : (m["indent"]).to!int, ]; @@ -5142,7 +5149,7 @@ void flow_para_match_(L,O,K,I,B,T,C)( debug(parabulletindent) { writeln(line); } - indent=[ + indent = [ "hang_position" : (m["indent"]).to!int, "base_position" : (m["indent"]).to!int, ]; @@ -5150,6 +5157,7 @@ void flow_para_match_(L,O,K,I,B,T,C)( } ++line_occur["para"]; } + return an_object; } #+END_SRC @@ -6755,7 +6763,7 @@ struct BookIndexNuggetHash { #+BEGIN_SRC d struct BookIndexReportIndent { int mkn, skn; - auto bookindex_report_indented(BI)( + void bookindex_report_indented(BI)( BI bookindex_unordered_hashes ) { debug(asserts) { @@ -6799,7 +6807,7 @@ struct BookIndexReportSection { #+name: meta_emitters_book_index_report_section #+BEGIN_SRC d - auto bookindex_write_section(BI)( + void bookindex_write_section(BI)( BI bookindex_unordered_hashes ) { auto mainkeys = -- cgit v1.2.3