diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2017-01-23 12:12:02 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2017-01-24 14:53:00 +0300 |
commit | 7d292e2ab53dfc2cf6595f30bcdb6efa4bf260a3 (patch) | |
tree | b1ef941923f1ab1634fda8baa2d1df9cfc45b8e5 /build2/test/script/script | |
parent | 28106f96de8ae5cdb3a0ee0e3a8a8185551e3b00 (diff) |
Add support for shared here-documents
Diffstat (limited to 'build2/test/script/script')
-rw-r--r-- | build2/test/script/script | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/build2/test/script/script b/build2/test/script/script index fbf3dd5..90b71bf 100644 --- a/build2/test/script/script +++ b/build2/test/script/script @@ -71,10 +71,11 @@ namespace build2 null, merge, here_str_literal, - here_doc_literal, here_str_regex, + here_doc_literal, here_doc_regex, - file + here_doc_ref, // Reference to here_doc literal or regex. + file, }; // Pre-parsed (but not instantiated) regex lines. The idea here is that @@ -154,9 +155,10 @@ namespace build2 union { int fd; // Merge-to descriptor. - string str; // Note: includes trailing newline, if requested. - regex_lines regex; // Note: includes trailing blank, if requested. + string str; // Note: with trailing newline, if requested. + regex_lines regex; // Note: with trailing blank, if requested. file_type file; + reference_wrapper<const redirect> ref; // Note: no chains. }; string modifiers; // Redirect modifiers. @@ -164,15 +166,34 @@ namespace build2 uint64_t end_line; // Here-document end marker location. uint64_t end_column; + // Create redirect of a type other than reference. + // explicit redirect (redirect_type = redirect_type::none); + // Create redirect of the reference type. + // + redirect (redirect_type t, const redirect& r) + : type (redirect_type::here_doc_ref), ref (r) + { + // There is no support (and need) for reference chains. + // + assert (t == redirect_type::here_doc_ref && + r.type != redirect_type::here_doc_ref); + } + // Move constuctible/assignable-only type. // redirect (redirect&&); redirect& operator= (redirect&&); ~redirect (); + + const redirect& + effective () const noexcept + { + return type == redirect_type::here_doc_ref ? ref.get () : *this; + } }; // cleanup |