summaryrefslogtreecommitdiff
path: root/cpp/src/slice2js/JsUtil.h
blob: 6486ba111c672b38bddee7d39304cd6e48684e62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//

#ifndef JS_UTIL_H
#define JS_UTIL_H

#include <Slice/Parser.h>
#include <IceUtil/OutputUtil.h>

namespace Slice
{

std::string relativePath(const std::string&, const std::string&);

class JsGenerator : private ::IceUtil::noncopyable
{
public:

    virtual ~JsGenerator() {};

    static bool isClassType(const TypePtr&);
    static std::string getModuleMetadata(const TypePtr&);
    static std::string getModuleMetadata(const ContainedPtr&);
    static std::string fixId(const std::string&);
    static std::string fixId(const ContainedPtr&);
    static bool findMetaData(const std::string&, const StringList&, std::string&);
    static std::string importPrefix(const TypePtr&,
                                    const ContainedPtr&,
                                    const std::vector<std::pair<std::string, std::string> >&);

    static std::string importPrefix(const ContainedPtr&,
                                    const ContainedPtr&,
                                    const std::vector<std::pair<std::string, std::string> >&);
    static std::string importPrefix(const std::string&, const ContainedPtr&);

    static std::string getUnqualified(const std::string&, const std::string&, const std::string&);

    static std::string typeToString(const TypePtr&,
                                    const ContainedPtr& = 0,
                                    const std::vector<std::pair<std::string, std::string> >& =
                                        std::vector<std::pair<std::string, std::string> >(),
                                    bool typeScript = false,
                                    bool definition = false);

    static std::string typeToString(const TypePtr&,
                                    const ContainedPtr&,
                                    const std::vector<std::pair<std::string, std::string> >&,
                                    bool typeScript,
                                    bool definition,
                                    bool usealias);

    static std::string getLocalScope(const std::string&, const std::string& separator = ".");

    static std::string getHelper(const TypePtr&);
    //
    // Generate code to marshal or unmarshal a type
    //
    void writeMarshalUnmarshalCode(::IceUtilInternal::Output&, const TypePtr&, const std::string&, bool);
    void writeOptionalMarshalUnmarshalCode(::IceUtilInternal::Output&, const TypePtr&, const std::string&, int, bool);

private:

    std::vector< std::string> _seenProxy;
};

}

#endif