diff options
author | Jose <jose@zeroc.com> | 2019-02-26 00:13:38 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2019-02-26 00:14:51 +0100 |
commit | 668a3838e26b4e21a8635bd4ea39c3f7da96e2c8 (patch) | |
tree | 3a598d5e05995ef82787dfd262ace44511ca8db3 /cpp/src/slice2swift/SwiftUtil.h | |
parent | Float/double fixes and some linting (diff) | |
download | ice-668a3838e26b4e21a8635bd4ea39c3f7da96e2c8.tar.bz2 ice-668a3838e26b4e21a8635bd4ea39c3f7da96e2c8.tar.xz ice-668a3838e26b4e21a8635bd4ea39c3f7da96e2c8.zip |
Generate imports for types defined in separate Swift modules
Diffstat (limited to 'cpp/src/slice2swift/SwiftUtil.h')
-rw-r--r-- | cpp/src/slice2swift/SwiftUtil.h | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/cpp/src/slice2swift/SwiftUtil.h b/cpp/src/slice2swift/SwiftUtil.h index 4cdfbd01e80..98863020ffb 100644 --- a/cpp/src/slice2swift/SwiftUtil.h +++ b/cpp/src/slice2swift/SwiftUtil.h @@ -16,6 +16,11 @@ namespace Slice { +std::string getSwiftModule(const ModulePtr&, std::string&); +std::string getSwiftModule(const ModulePtr&); +ModulePtr getTopLevelModule(const ContainedPtr&); +ModulePtr getTopLevelModule(const TypePtr&); + class SwiftGenerator : private IceUtil::noncopyable { public: @@ -26,19 +31,6 @@ public: protected: - struct ModulePrefix - { - ModulePtr m; - std::string module; - std::string name; - }; - - static bool addModule(const ModulePtr&, const std::string&, const std::string&); - static ModulePrefix modulePrefix(const ModulePtr&); - static std::string moduleName(const ModulePtr&); - static ModulePtr findModule(const ContainedPtr&); - static void modulePrefixError(const ModulePtr&, const std::string&); - std::string getLocalScope(const std::string&, const std::string& = "."); std::string typeToString(const TypePtr&, const ContainedPtr& = 0); std::string typeToProxyImpl(const TypePtr&); @@ -67,6 +59,7 @@ protected: private: + class MetaDataVisitor : public ParserVisitor { public: @@ -81,17 +74,24 @@ private: virtual void visitConst(const ConstPtr&); private: + void validate(const ContainedPtr&); - static void modulePrefixError(const ModulePtr&, const std::string&); + + typedef std::map<std::string, std::string> ModuleMap; + typedef std::map<std::string, ModuleMap> ModulePrefix; + + // + // Each Slice unit has to map all top-level modules to a single Swift module + // + ModuleMap _modules; + + // + // With a given Swift module a Slice module has to map to a single prefix + // + ModulePrefix _prefixes; static const std::string _msg; }; - - // - // Map of module scoped name to ModulePtr. Used to verify that objc:prefix metadata directives are consistent. - // - typedef std::map<std::string, ModulePrefix> ModuleMap; - static ModuleMap _modules; }; } |