summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCsaba Hruska <csaba.hruska@gmail.com>2015-09-21 13:27:30 +0200
committerCsaba Hruska <csaba.hruska@gmail.com>2015-09-21 13:27:30 +0200
commit307895ce6e4fb875afba0999c257b573eff6aa4c (patch)
treea91a440b67b8525fa8dd5f8a1ade60e65f01eb31
parent080df3009bd166cfe61602d44fdfdcf865c4e8ae (diff)
ddl: improve typedef look in C++
-rw-r--r--Language.hs2
-rw-r--r--templates/data.hpp.ede5
2 files changed, 6 insertions, 1 deletions
diff --git a/Language.hs b/Language.hs
index b2e250c..ab96349 100644
--- a/Language.hs
+++ b/Language.hs
@@ -231,7 +231,7 @@ cppType aliasMap = \case
231 Map k v -> "std::map<" ++ cppType aliasMap k ++ ", " ++ cppType aliasMap v ++ ">" 231 Map k v -> "std::map<" ++ cppType aliasMap k ++ ", " ++ cppType aliasMap v ++ ">"
232 -- user defined 232 -- user defined
233 Data t -> case normalize aliasMap (Data t) of 233 Data t -> case normalize aliasMap (Data t) of
234 Data n | t == n -> "std::shared_ptr<::" ++ t ++ ">" 234 Data _ -> "std::shared_ptr<::" ++ t ++ ">"
235 _ -> "::" ++ t 235 _ -> "::" ++ t
236 x -> error $ "unknown type: " ++ show x 236 x -> error $ "unknown type: " ++ show x
237 237
diff --git a/templates/data.hpp.ede b/templates/data.hpp.ede
index 383ed5f..dab478c 100644
--- a/templates/data.hpp.ede
+++ b/templates/data.hpp.ede
@@ -28,7 +28,12 @@ namespace data { {% for c in t.value.constructors %}{% if !(c.value.fields | emp
28 };{% endif %}{% endfor %} 28 };{% endif %}{% endfor %}
29} 29}
30{% when "TypeAlias" %} 30{% when "TypeAlias" %}
31{% case t.value.aliasType.tag %}
32{% when "Data" %}
33typedef {{ t.value.aliasType.contents }} {{ t.value.aliasName }};
34{% else %}
31typedef {{ t.value.aliasType | cppType }} {{ t.value.aliasName }}; 35typedef {{ t.value.aliasType | cppType }} {{ t.value.aliasName }};
36{% endcase %}
32 37
33{% endcase %} 38{% endcase %}
34{% endfor %} 39{% endfor %}