From de02319cfa7b4bbff8c111bda02be1a7c6591555 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 5 Jan 2020 20:17:17 -0500 Subject: dlang safe default imminent, look ahead - @safe @trusted & @system, reconsider @trusted --- org/spine.org | 232 +++++++++++++++++++++------------------------------------- 1 file changed, 83 insertions(+), 149 deletions(-) (limited to 'org/spine.org') diff --git a/org/spine.org b/org/spine.org index 27dfdc1..5c66ce6 100644 --- a/org/spine.org +++ b/org/spine.org @@ -85,7 +85,7 @@ name "spine" description "A SiSU inspired document parser writen in D." homepage "http://sisudoc.org" +/ -void main(string[] args) { +@system void main(string[] args) { <> <> <> @@ -458,16 +458,16 @@ if (helpInfo.helpWanted) { #+BEGIN_SRC d enum outTask { source_or_pod, sqlite, sqlite_multi, latex, odt, epub, html_scroll, html_seg, html_stuff } struct OptActions { - bool assertions() @trusted { + @trusted bool assertions() { return opts["assertions"]; } - bool concordance() @trusted { + @trusted bool concordance() { return opts["concordance"]; } auto config_path_set() { return settings["config"]; } - bool css_theme_default() @trusted { + @trusted bool css_theme_default() { bool _is_light; if (opts["light"] || opts["theme-light"]) { _is_light = true; @@ -478,94 +478,94 @@ struct OptActions { } return _is_light; } - bool debug_do() @trusted { + @trusted bool debug_do() { return opts["debug"]; } - bool digest() @trusted { + @trusted bool digest() { return opts["digest"]; } - bool epub() @trusted { + @trusted bool epub() { return opts["epub"]; } - bool harvest_link() @trusted { + @trusted bool harvest_link() { return (opts["harvest-link"]) ? true : false; } - bool harvest() @trusted { + @trusted bool harvest() { return (opts["harvest"] || opts["harvest-authors"] || opts["harvest-topics"]) ? true : false; } - bool harvest_authors() @trusted { + @trusted bool harvest_authors() { return (opts["harvest"] || opts["harvest-authors"]) ? true : false; } - bool harvest_topics() @trusted { + @trusted bool harvest_topics() { return (opts["harvest"] || opts["harvest-topics"]) ? true : false; } - bool html() @trusted { + @trusted bool html() { return (opts["html"] || opts["html-seg"] || opts["html-scroll"]) ? true : false; } - bool html_seg() @trusted { + @trusted bool html_seg() { return (opts["html"] || opts["html-seg"]) ? true : false; } - bool html_scroll() @trusted { + @trusted bool html_scroll() { return (opts["html"] || opts["html-scroll"]) ? true : false; } - bool html_stuff() @trusted { + @trusted bool html_stuff() { return (opts["html"] || opts["html-scroll"] || opts["html-seg"]) ? true : false; } - bool latex() @trusted { + @trusted bool latex() { return (opts["latex"] || opts["pdf"]) ? true : false; } - bool odt() @trusted { + @trusted bool odt() { return (opts["odf"] || opts["odt"]) ? true : false; } - bool manifest() @trusted { + @trusted bool manifest() { return opts["manifest"]; } - bool ocn_hidden() @trusted { + @trusted bool ocn_hidden() { return opts["hide-ocn"]; } - bool ocn_off() @trusted { + @trusted bool ocn_off() { return opts["ocn-off"]; } - bool quiet() @trusted { + @trusted bool quiet() { return opts["quiet"]; } - bool pod() @trusted { + @trusted bool pod() { return opts["pod"]; } - bool show_summary() @trusted { + @trusted bool show_summary() { return opts["show-summary"]; } - bool show_make() @trusted { + @trusted bool show_make() { return opts["show-make"]; } - bool show_metadata() @trusted { + @trusted bool show_metadata() { return opts["show-metadata"]; } - bool show_config() @trusted { + @trusted bool show_config() { return opts["show-config"]; } - bool source() @trusted { + @trusted bool source() { return opts["source"]; } - bool source_or_pod() @trusted { + @trusted bool source_or_pod() { return (opts["pod"] || opts["source"]) ? true : false; } - bool sqlite_discrete() @trusted { + @trusted bool sqlite_discrete() { return opts["sqlite-discrete"]; } - bool sqlite_db_drop() @trusted { + @trusted bool sqlite_db_drop() { return (opts["sqlite-db-recreate"] || opts["sqlite-db-drop"]) ? true : false; } - bool sqlite_db_create() @trusted { + @trusted bool sqlite_db_create() { return (opts["sqlite-db-recreate"] || opts["sqlite-db-create"]) ? true : false; } - bool sqlite_delete() @trusted { + @trusted bool sqlite_delete() { return opts["sqlite-delete"]; } - bool sqlite_update() @trusted { + @trusted bool sqlite_update() { return (opts["sqlite-update"] || opts["sqlite-insert"]) ? true : false; } - bool sqlite_shared_db_action() @trusted { + @trusted bool sqlite_shared_db_action() { return ( opts["sqlite-db-recreate"] || opts["sqlite-db-create"] @@ -574,46 +574,46 @@ struct OptActions { || opts["sqlite-update"] ) ? true : false; } - bool text() @trusted { + @trusted bool text() { return opts["text"]; } - bool verbose() @trusted { + @trusted bool verbose() { return (opts["verbose"] || opts["very-verbose"]) ? true : false; } - bool very_verbose() @trusted { + @trusted bool very_verbose() { return opts["very-verbose"]; } - bool xhtml() @trusted { + @trusted bool xhtml() { return opts["xhtml"]; } - bool section_toc() @trusted { + @trusted bool section_toc() { return opts["section_toc"]; } - bool section_body() @trusted { + @trusted bool section_body() { return opts["section_body"]; } - bool section_endnotes() @trusted { + @trusted bool section_endnotes() { return opts["section_endnotes"]; } - bool section_glossary() @trusted { + @trusted bool section_glossary() { return opts["section_glossary"]; } - bool section_biblio() @trusted { + @trusted bool section_biblio() { return opts["section_biblio"]; } - bool section_bookindex() @trusted { + @trusted bool section_bookindex() { return opts["section_bookindex"]; } - bool section_blurb() @trusted { + @trusted bool section_blurb() { return opts["section_blurb"]; } - bool backmatter() @trusted { + @trusted bool backmatter() { return opts["backmatter"]; } - bool skip_output() @trusted { + @trusted bool skip_output() { return opts["skip-output"]; } - bool workon() @trusted { + @trusted bool workon() { return opts["workon"]; } auto languages_set() { @@ -625,7 +625,7 @@ struct OptActions { auto sqlite_filename() { return settings["sqlite-filename"]; } - bool parallelise() @trusted { + @trusted bool parallelise() { bool _is; if (opts["parallel"] == true) { _is = true; @@ -649,7 +649,7 @@ struct OptActions { } else { _is = false; } return _is; } - bool parallelise_subprocesses() @trusted { + @trusted bool parallelise_subprocesses() { return opts["parallel-subprocesses"]; } auto output_task_scheduler() { @@ -680,7 +680,7 @@ struct OptActions { } return schedule.sort().uniq; } - bool abstraction() @trusted { + @trusted bool abstraction() { return ( opts["abstraction"] || concordance @@ -696,7 +696,7 @@ struct OptActions { || sqlite_update ) ? true : false; } - bool meta_processing_general() @trusted { + @trusted bool meta_processing_general() { return ( opts["abstraction"] || html @@ -707,7 +707,7 @@ struct OptActions { || sqlite_update ) ? true :false; } - bool meta_processing_xml_dom() @trusted { + @trusted bool meta_processing_xml_dom() { return ( opts["abstraction"] || html @@ -726,20 +726,20 @@ auto _opt_action = OptActions(); #+NAME: spine_args #+BEGIN_SRC d -auto program_info() { +@safe auto program_info() { struct ProgramInfo { - string project() { + @safe string project() { return project_name; } - string name() { + @safe string name() { return program_name; } - string ver() { + @safe string ver() { return format("%s.%s.%s", _ver.major, _ver.minor, _ver.patch, ); } - string compiler() { + @safe string compiler() { return format ("%s D:%s, %s %s", __VENDOR__, __VERSION__, bits, os, @@ -1168,7 +1168,7 @@ template spineAbstraction() { enum makeMeta { make, meta } enum docAbst { doc_abstract_obj, doc_has } static auto rgx = Rgx(); - auto spineAbstraction(E,P,O,M,S)( + @system auto spineAbstraction(E,P,O,M,S)( E _env, P program_info, O _opt_action, @@ -1339,39 +1339,39 @@ struct DocumentMatters { #+NAME: spine_each_file_do_document_matters #+BEGIN_SRC d - auto generator_program() { + @safe auto generator_program() { struct Prog_ { - string project_name() { + @safe string project_name() { return "spine"; } - string name() { + @safe string name() { return program_info.name; } - string ver() { + @safe string ver() { return program_info.ver; } - string name_and_version() @trusted { + @trusted string name_and_version() { return format("%s-%s", name, ver, ); } - string url_home() { + @safe string url_home() { return "http://sisudoc.org"; } - string url_git() { + @safe string url_git() { return "https://git.sisudoc.org/software/sisu"; } - auto compiler() { + @safe auto compiler() { return program_info.compiler; } - auto stime() { + @safe auto stime() { return Clock.currTime(UTC()).toSimpleString(); } } return Prog_(); } - auto generated_time() { + @safe auto generated_time() { auto _st = Clock.currTime(UTC()); auto _time = _st.year.to!string ~ "-" ~ _st.month.to!int.to!string // prefer as month number @@ -1388,10 +1388,10 @@ struct DocumentMatters { #+NAME: spine_each_file_do_document_matters #+BEGIN_SRC d - auto conf_make_meta() { + @safe auto conf_make_meta() { return _make_and_meta_struct; } - auto has() { + @safe auto has() { return _doc_has_struct; } #+END_SRC @@ -1400,12 +1400,12 @@ struct DocumentMatters { #+NAME: spine_each_file_do_document_matters #+BEGIN_SRC d - auto env() { + @safe auto env() { struct Env_ { - auto pwd() { + @safe auto pwd() { return _manifest.env.pwd; } - auto home() { + @safe auto home() { return _manifest.env.home; } } @@ -1417,9 +1417,9 @@ struct DocumentMatters { #+NAME: spine_each_file_do_document_matters #+BEGIN_SRC d - auto opt() { + @safe auto opt() { struct Opt_ { - auto action() { + @safe auto action() { /+ getopt options, commandline instructions, raw - processing instructions --epub --html etc. - command line config instructions --output-path @@ -1435,27 +1435,27 @@ struct DocumentMatters { #+NAME: spine_each_file_do_document_matters #+BEGIN_SRC d - auto src() { + @safe auto src() { return _manifest.src; } - auto src_path_info() { + @safe auto src_path_info() { return spinePathsSRC!()(_manifest.env.pwd, _manifest.src.file_with_absolute_path); // would like (to have and use) relative path } - auto pod() { + @safe auto pod() { return _manifest.pod; } - auto sqlite() { + @safe auto sqlite() { struct SQLite_ { - string filename() { + @safe string filename() { return _opt_action.sqlite_filename; } } return SQLite_(); } - auto output_path() { + @safe auto output_path() { return _make_and_meta_struct.conf.output_path; } - auto srcs() { + @safe auto srcs() { struct SRC_ { auto file_insert_list() { return _header_body_insertfilelist_imagelist[headBody.insert_file_list]; @@ -1487,72 +1487,6 @@ if ((_opt_action.debug_do) } #+END_SRC -**** H. abridged doc matters, for harvest (from doc head only, doc abstraction not performed) -- harvest abridged doc matters gathered -***** doc matters shared - -#+NAME: spine_each_file_do_document_matters_abridged -#+BEGIN_SRC d -if ((_opt_action.debug_do) -|| (_opt_action.verbose) -) { - writeln("step4 commence → (doc_matters)"); -} -struct DocumentMattersShared { - auto env() { - struct Env_ { - auto pwd() { - return _manifest.env.pwd; - } - auto home() { - return _manifest.env.home; - } - } - return Env_(); - } - auto opt() { - struct Opt_ { - auto action() { - return _opt_action; - } - } - return Opt_(); - } -} -DocumentMattersShared doc_matters_shared = DocumentMattersShared(); -#+END_SRC - -***** abridged doc matters, for harvest (from doc head only, doc abstraction not performed) TODO - -#+NAME: spine_each_file_do_document_matters_abridged -#+BEGIN_SRC d -struct DocumentMattersAbridged { - auto conf_make_meta() { - return _make_and_meta_struct; - } - auto src() { - return _manifest.src; - } - auto src_path_info() { - return spinePathsSRC!()(_manifest.env.pwd, _manifest.src.file_with_absolute_path); - } - auto pod() { - return _manifest.pod; - } - auto sqlite() { - struct SQLite_ { - string filename() { - return _opt_action.sqlite_filename; - } - } - return SQLite_(); - } - auto output_path() { - return _make_and_meta_struct.conf.output_path; - } -} -#+END_SRC - * __END__ dev notes -- cgit v1.2.3