summaryrefslogtreecommitdiff
path: root/ddl/out/LambdaCube.TypeInfo.cpp
blob: 51c897d092368fd3ecb9cd0bb3f5562df7ddf0e5 (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// generated file, do not modify!
// 2016-09-15T19:44:48.120020034Z

#include "LambdaCube.TypeInfo.hpp"
template<> json toJSON<std::shared_ptr<Range>>(std::shared_ptr<Range> &v) {
  json obj({});
  switch (v->tag) { 
    case ::Range::tag::Range:
      obj["tag"] = "Range";
      {
        std::shared_ptr<data::Range> tv = std::static_pointer_cast<data::Range>(v);
        obj["startLine"] = toJSON(tv->startLine);
        obj["startColumn"] = toJSON(tv->startColumn);
        obj["endLine"] = toJSON(tv->endLine);
        obj["endColumn"] = toJSON(tv->endColumn);
      }
      break;
  }
  return obj;
}

template<> std::shared_ptr<Range> fromJSON<std::shared_ptr<Range>>(W<std::shared_ptr<Range>> v, json &obj) {
  enum ::Range::tag tagType;
  std::string tag = obj["tag"];
  if (tag == "Range") {
    tagType = ::Range::tag::Range;
    std::shared_ptr<data::Range> tv(new data::Range());
    tv->startLine = fromJSON(W<Int>(), obj["startLine"]);
    tv->startColumn = fromJSON(W<Int>(), obj["startColumn"]);
    tv->endLine = fromJSON(W<Int>(), obj["endLine"]);
    tv->endColumn = fromJSON(W<Int>(), obj["endColumn"]);
    return tv;
  }
  else throw "unknown constructor: " + tag;
  std::shared_ptr<::Range> o(new ::Range());
  o->tag = tagType;
  return o;
}

template<> json toJSON<std::shared_ptr<TypeInfo>>(std::shared_ptr<TypeInfo> &v) {
  json obj({});
  switch (v->tag) { 
    case ::TypeInfo::tag::TypeInfo:
      obj["tag"] = "TypeInfo";
      {
        std::shared_ptr<data::TypeInfo> tv = std::static_pointer_cast<data::TypeInfo>(v);
        obj["range"] = toJSON(tv->range);
        obj["text"] = toJSON(tv->text);
      }
      break;
  }
  return obj;
}

template<> std::shared_ptr<TypeInfo> fromJSON<std::shared_ptr<TypeInfo>>(W<std::shared_ptr<TypeInfo>> v, json &obj) {
  enum ::TypeInfo::tag tagType;
  std::string tag = obj["tag"];
  if (tag == "TypeInfo") {
    tagType = ::TypeInfo::tag::TypeInfo;
    std::shared_ptr<data::TypeInfo> tv(new data::TypeInfo());
    tv->range = fromJSON(W<std::shared_ptr<::Range>>(), obj["range"]);
    tv->text = fromJSON(W<String>(), obj["text"]);
    return tv;
  }
  else throw "unknown constructor: " + tag;
  std::shared_ptr<::TypeInfo> o(new ::TypeInfo());
  o->tag = tagType;
  return o;
}

template<> json toJSON<std::shared_ptr<CompileResult>>(std::shared_ptr<CompileResult> &v) {
  json obj({});
  switch (v->tag) { 
    case ::CompileResult::tag::CompileError:
      obj["tag"] = "CompileError";
      {
        std::shared_ptr<data::CompileError> tv = std::static_pointer_cast<data::CompileError>(v);
        obj["arg0"] = toJSON(tv->_0);
        obj["arg1"] = toJSON(tv->_1);
        obj["arg2"] = toJSON(tv->_2);
      }
      break;
    case ::CompileResult::tag::Compiled:
      obj["tag"] = "Compiled";
      {
        std::shared_ptr<data::Compiled> tv = std::static_pointer_cast<data::Compiled>(v);
        obj["arg0"] = toJSON(tv->_0);
        obj["arg1"] = toJSON(tv->_1);
        obj["arg2"] = toJSON(tv->_2);
        obj["arg3"] = toJSON(tv->_3);
      }
      break;
  }
  return obj;
}

template<> std::shared_ptr<CompileResult> fromJSON<std::shared_ptr<CompileResult>>(W<std::shared_ptr<CompileResult>> v, json &obj) {
  enum ::CompileResult::tag tagType;
  std::string tag = obj["tag"];
  if (tag == "CompileError") {
    tagType = ::CompileResult::tag::CompileError;
    std::shared_ptr<data::CompileError> tv(new data::CompileError());
    tv->_0 = fromJSON(W<std::vector<std::shared_ptr<::Range>>>(), obj["arg0"]);
    tv->_1 = fromJSON(W<String>(), obj["arg1"]);
    tv->_2 = fromJSON(W<std::vector<std::shared_ptr<::TypeInfo>>>(), obj["arg2"]);
    return tv;
  }
  else if (tag == "Compiled") {
    tagType = ::CompileResult::tag::Compiled;
    std::shared_ptr<data::Compiled> tv(new data::Compiled());
    tv->_0 = fromJSON(W<String>(), obj["arg0"]);
    tv->_1 = fromJSON(W<String>(), obj["arg1"]);
    tv->_2 = fromJSON(W<std::shared_ptr<::Pipeline>>(), obj["arg2"]);
    tv->_3 = fromJSON(W<std::vector<std::shared_ptr<::TypeInfo>>>(), obj["arg3"]);
    return tv;
  }
  else throw "unknown constructor: " + tag;
  std::shared_ptr<::CompileResult> o(new ::CompileResult());
  o->tag = tagType;
  return o;
}