diff options
author | Mark Spruiell <mes@zeroc.com> | 2014-03-19 12:45:55 -0700 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2014-03-19 12:45:55 -0700 |
commit | cdcffbcc3c3c052afdeb772ff0167e7a90b525bb (patch) | |
tree | 4f16ee41ef7d33394c44e9db81e4d6cd89908250 /cpp/src/slice2js/Gen.h | |
parent | fixing testicedist.py for 5487 (diff) | |
download | ice-cdcffbcc3c3c052afdeb772ff0167e7a90b525bb.tar.bz2 ice-cdcffbcc3c3c052afdeb772ff0167e7a90b525bb.tar.xz ice-cdcffbcc3c3c052afdeb772ff0167e7a90b525bb.zip |
merging javascript branch
Diffstat (limited to 'cpp/src/slice2js/Gen.h')
-rw-r--r-- | cpp/src/slice2js/Gen.h | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/cpp/src/slice2js/Gen.h b/cpp/src/slice2js/Gen.h new file mode 100644 index 00000000000..d337e3eee5c --- /dev/null +++ b/cpp/src/slice2js/Gen.h @@ -0,0 +1,136 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#ifndef GEN_H +#define GEN_H + +#include <JsUtil.h> + +namespace Slice +{ + +class JsVisitor : public JsGenerator, public ParserVisitor +{ +public: + + JsVisitor(::IceUtilInternal::Output&); + virtual ~JsVisitor(); + +protected: + + void writeMarshalUnmarshalParams(const ParamDeclList&, const OperationPtr&, bool); + void writePostUnmarshalParams(const ParamDeclList&, const OperationPtr&); + void writeMarshalDataMember(const DataMemberPtr&); + void writeUnmarshalDataMember(const DataMemberPtr&); + + virtual void writeDispatchAndMarshalling(const ClassDefPtr&); + virtual std::vector<std::string> getParams(const OperationPtr&); + virtual std::vector<std::string> getParamsAsync(const OperationPtr&, bool, bool = false); + virtual std::vector<std::string> getParamsAsyncCB(const OperationPtr&, bool = false, bool = true); + virtual std::vector<std::string> getArgs(const OperationPtr&); + virtual std::vector<std::string> getArgsAsync(const OperationPtr&, bool = false); + virtual std::vector<std::string> getArgsAsyncCB(const OperationPtr&, bool = false, bool = false); + + std::string getValue(const std::string&, const TypePtr&); + + void writeConstantValue(const std::string&, const TypePtr&, const SyntaxTreeBasePtr&, const std::string&); + + static StringList splitComment(const ContainedPtr&); + void writeDocComment(const ContainedPtr&, const std::string&, const std::string& = ""); + + ::IceUtilInternal::Output& _out; +}; + +class Gen : public JsGenerator +{ +public: + + Gen(const std::string&, + const std::vector<std::string>&, + const std::string&); + ~Gen(); + + void generate(const UnitPtr&); + void closeOutput(); + +private: + + IceUtilInternal::Output _out; + + std::vector<std::string> _includePaths; + std::string _fileBase; + + void printHeader(); + + class RequireVisitor : public JsVisitor + { + public: + + RequireVisitor(::IceUtilInternal::Output&, std::vector<std::string>); + + virtual bool visitClassDefStart(const ClassDefPtr&); + virtual bool visitStructStart(const StructPtr&); + virtual void visitOperation(const OperationPtr&); + virtual bool visitExceptionStart(const ExceptionPtr&); + virtual void visitSequence(const SequencePtr&); + virtual void visitDictionary(const DictionaryPtr&); + virtual void visitEnum(const EnumPtr&); + + std::vector< std::string> writeRequires(const UnitPtr&); + + private: + + bool _seenClass; + bool _seenCompactId; + bool _seenOperation; + bool _seenStruct; + bool _seenUserException; + bool _seenLocalException; + bool _seenEnum; + bool _seenObjectSeq; + bool _seenObjectDict; + std::vector<std::string> _includePaths; + }; + + class TypesVisitor : public JsVisitor + { + public: + + TypesVisitor(::IceUtilInternal::Output&, std::vector< std::string>); + + virtual bool visitModuleStart(const ModulePtr&); + virtual void visitModuleEnd(const ModulePtr&); + virtual bool visitClassDefStart(const ClassDefPtr&); + virtual bool visitExceptionStart(const ExceptionPtr&); + virtual bool visitStructStart(const StructPtr&); + virtual void visitSequence(const SequencePtr&); + virtual void visitDictionary(const DictionaryPtr&); + virtual void visitEnum(const EnumPtr&); + virtual void visitConst(const ConstPtr&); + + private: + + std::string encodeTypeForOperation(const TypePtr&); + + std::vector<std::string> _seenModules; + }; + + class ExportVisitor : public JsVisitor + { + public: + + ExportVisitor(::IceUtilInternal::Output&); + + virtual bool visitModuleStart(const ModulePtr&); + }; +}; + +} + +#endif |