1 /* C++ modules. Experimental! -*- c++ -*-
2 Copyright (C) 2017-2020 Free Software Foundation, Inc.
3 Written by Nathan Sidwell <nathan@acm.org> while at FaceBook
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GCC is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef GXX_RESOLVER_H
22 #define GXX_RESOLVER_H 1
24 // Mapper interface for client and server bits
30 // This is a GCC class, so GCC coding conventions on new bits.
31 class module_resolver : public Cody::Resolver
34 using parent = Cody::Resolver;
35 using module_map = std::map<std::string, std::string>;
42 bool default_map = true;
43 bool default_translate = true;
46 module_resolver (bool map = true, bool xlate = false);
47 virtual ~module_resolver () override;
50 void set_default_map (bool d)
54 void set_default_translate (bool d)
56 default_translate = d;
58 void set_ident (char const *i)
62 bool set_repo (std::string &&repo, bool force = false);
63 bool add_mapping (std::string &&module, std::string &&file,
66 // Return +ve line number of error, or -ve errno
67 int read_tuple_file (int fd, char const *prefix, bool force = false);
68 int read_tuple_file (int fd, std::string const &prefix,
71 return read_tuple_file (fd, prefix.empty () ? nullptr : prefix.c_str (),
76 // Virtual overriders, names are controlled by Cody::Resolver
77 using parent::ConnectRequest;
78 virtual module_resolver *ConnectRequest (Cody::Server *, unsigned version,
82 using parent::ModuleRepoRequest;
83 virtual int ModuleRepoRequest (Cody::Server *) override;
84 using parent::ModuleExportRequest;
85 virtual int ModuleExportRequest (Cody::Server *s, Cody::Flags,
88 using parent::ModuleImportRequest;
89 virtual int ModuleImportRequest (Cody::Server *s, Cody::Flags,
92 using parent::IncludeTranslateRequest;
93 virtual int IncludeTranslateRequest (Cody::Server *s, Cody::Flags,
98 using parent::GetCMISuffix;
99 virtual char const *GetCMISuffix () override;
102 int cmi_response (Cody::Server *s, std::string &module);