@@ -637,57 +637,37 @@ template <> const std::string ast_control<enum_type_extension_content>::error_me
637637template <> const std::string ast_control<input_object_type_extension_content>::error_message = " Expected https://facebook.github.io/graphql/June2018/#InputObjectTypeExtension" ;
638638template <> const std::string ast_control<document_content>::error_message = " Expected https://facebook.github.io/graphql/June2018/#Document" ;
639639
640- template <>
641- ast<std::vector<char >>::~ast ()
640+ ast parseString (std::string_view input)
642641{
643- // The default destructor gets inlined and may use a different allocator to free ast<>'s member
644- // variables than the graphqlservice module used to allocate them. So even though this could be
645- // omitted, declare it explicitly and define it in graphqlservice.
646- }
647-
648- template <>
649- ast<std::unique_ptr<file_input<>>>::~ast ()
650- {
651- // The default destructor gets inlined and may use a different allocator to free ast<>'s member
652- // variables than the graphqlservice module used to allocate them. So even though this could be
653- // omitted, declare it explicitly and define it in graphqlservice.
654- }
655-
656- template <>
657- ast<const char *>::~ast ()
658- {
659- // The default destructor gets inlined and may use a different allocator to free ast<>'s member
660- // variables than the graphqlservice module used to allocate them. So even though this could be
661- // omitted, declare it explicitly and define it in graphqlservice.
662- }
663-
664- ast<std::vector<char >> parseString (std::string_view input)
665- {
666- ast<std::vector<char >> result{ { input.cbegin (), input.cend () }, nullptr };
667- memory_input<> in (result.input .data (), result.input .size (), " GraphQL" );
642+ ast result{ std::make_shared<ast_input>(ast_input{ std::vector<char >{ input.cbegin (), input.cend () } }), {}};
643+ const auto & data = std::get<std::vector<char >>(result.input ->data );
644+ memory_input<> in (data.data (), data.size (), " GraphQL" );
668645
669646 result.root = parse_tree::parse<document, ast_node, ast_selector, nothing, ast_control>(std::move (in));
670647
671648 return result;
672649}
673650
674- ast<std::unique_ptr<file_input<>>> parseFile (std::string_view filename)
651+ ast parseFile (std::string_view filename)
675652{
676- auto in = std::make_unique<file_input<>>(std::string ( filename)) ;
677- ast <std::unique_ptr<file_input<>>> result { std::move (in), nullptr } ;
653+ ast result{ std::make_shared<ast_input>(ast_input{ std::make_unique<file_input<>>(filename) }), {} } ;
654+ auto & in = *std::get <std::unique_ptr<file_input<>>>(result. input -> data ) ;
678655
679- result.root = parse_tree::parse<document, ast_node, ast_selector, nothing, ast_control>(std::move (*result. input ));
656+ result.root = parse_tree::parse<document, ast_node, ast_selector, nothing, ast_control>(std::move (in ));
680657
681658 return result;
682659}
683660
684661} /* namespace peg */
685662
686- peg::ast< const char *> operator " " _graphql(const char * text, size_t size)
663+ peg::ast operator " " _graphql(const char * text, size_t size)
687664{
688665 peg::memory_input<> in (text, size, " GraphQL" );
689666
690- return { text, peg::parse_tree::parse<peg::document, peg::ast_node, peg::ast_selector, peg::nothing, peg::ast_control>(std::move (in)) };
667+ return {
668+ std::make_shared<peg::ast_input>(peg::ast_input{ { std::string_view{ text, size } } }),
669+ peg::parse_tree::parse<peg::document, peg::ast_node, peg::ast_selector, peg::nothing, peg::ast_control>(std::move (in))
670+ };
691671}
692672
693673} /* namespace facebook::graphql */
0 commit comments