public void FillTranslatorEnumTo(Dictionary <String, TypeDef> VersionedNameToType, EnumDef e, List <String> l, String NamespaceName) { var Name = e.FullName(); EnumDef eHead = null; if (VersionedNameToType.ContainsKey(Name)) { var tHead = VersionedNameToType[Name]; if (tHead.OnEnum) { eHead = tHead.Enum; } } var VersionedSimpleName = e.GetTypeSpec().SimpleName(NamespaceName); var TypeString = GetTypeString(Nonversioned(e.GetTypeSpec()), NamespaceName); var VersionedTypeString = GetTypeString(e.GetTypeSpec(), NamespaceName); if (eHead == null) { FillTranslatorEnumTo(VersionedSimpleName, TypeString, VersionedTypeString, e.Literals, new List <LiteralDef> { }, l, NamespaceName); } else { FillTranslatorEnumTo(VersionedSimpleName, TypeString, VersionedTypeString, e.Literals, eHead.Literals, l, NamespaceName); } }
public IEnumerable <String> BinaryTranslator_Enum(EnumDef e, String NamespaceName) { foreach (var _Line in Combine(Begin(), BinaryTranslator_Enum(e.GetTypeSpec().SimpleName(NamespaceName), GetTypeString(e.GetTypeSpec(), NamespaceName), e.UnderlyingType.SimpleName(NamespaceName), GetTypeString(e.UnderlyingType, NamespaceName), NamespaceName))) { yield return(_Line); } }
public IEnumerable <String> JsonTranslator_Enum(EnumDef e, String NamespaceName) { var Name = e.GetTypeSpec().SimpleName(NamespaceName); foreach (var _Line in Combine(Combine(Combine(Combine(Begin(), "public static function "), GetEscapedIdentifier(Combine(Combine(Begin(), LowercaseCamelize(Name)), "FromJson"))), "(j : Dynamic) : "), GetTypeString(e.UnderlyingType, NamespaceName))) { yield return(_Line); } yield return("{"); foreach (var _Line in Combine(Combine(Combine(Begin(), " return cast(j, "), GetTypeString(e.UnderlyingType, NamespaceName)), ");")) { yield return(_Line); } yield return("}"); foreach (var _Line in Combine(Combine(Combine(Combine(Combine(Begin(), "public static function "), GetEscapedIdentifier(Combine(Combine(Begin(), LowercaseCamelize(Name)), "ToJson"))), "(o : "), GetTypeString(e.UnderlyingType, NamespaceName)), ") : Dynamic")) { yield return(_Line); } yield return("{"); yield return(" return o;"); yield return("}"); }
public IEnumerable <String> EnumFunctor(EnumDef e) { var TypeString = GetTypeString(e.GetTypeSpec(), "std"); yield return("template <>"); foreach (var _Line in Combine(Combine(Combine(Begin(), "struct hash<"), TypeString), ">")) { yield return(_Line); } yield return("{"); foreach (var _Line in Combine(Combine(Combine(Begin(), " size_t operator()(const "), TypeString), " &x) const")) { yield return(_Line); } yield return(" {"); foreach (var _Line in Combine(Combine(Combine(Combine(Combine(Begin(), " return hash<"), GetTypeString(e.UnderlyingType, e.NamespaceName())), ">()(static_cast<"), GetTypeString(e.UnderlyingType, e.NamespaceName())), ">(x));")) { yield return(_Line); } yield return(" }"); yield return("};"); yield return("template <>"); foreach (var _Line in Combine(Combine(Combine(Begin(), "struct less<"), TypeString), ">")) { yield return(_Line); } yield return("{"); foreach (var _Line in Combine(Combine(Combine(Combine(Combine(Begin(), " bool operator()(const "), TypeString), " &x, const "), TypeString), " &y) const")) { yield return(_Line); } yield return(" {"); foreach (var _Line in Combine(Combine(Combine(Combine(Combine(Combine(Combine(Begin(), " return less<"), GetTypeString(e.UnderlyingType, "std")), ">()(static_cast<"), GetTypeString(e.UnderlyingType, "std")), ">(x), static_cast<"), GetTypeString(e.UnderlyingType, "std")), ">(y));")) { yield return(_Line); } yield return(" }"); yield return("};"); }