public override void VisitCustomDeclaration(CustomDeclaration customDeclaration) { if (HandleDeclaration(customDeclaration)) { return; } string variableName = customDeclaration.Name.ToLowerCamelCase(); if (customDeclaration.IsPointer) { if (customDeclaration.CppType.EndsWith("Component")) { int hash = customDeclaration.CppType.GetStableHashCode(); m_Builder.Tab().Append("JSON ").Append(variableName).Append("Json;\n") .Tab().Append("nlohmann::json& ").Append(variableName).Append("J = ").Append(variableName).Append("Json.GetJ();\n") .Tab().Append("const int ").Append(variableName).Append("EntityId = m_").Append(customDeclaration.Name).Append(" != nullptr ? ") .Append("m_").Append(customDeclaration.Name).Append("->GetOwner()->GetId() : -1;\n") .Tab().Append(variableName).Append("J[\"entityId\"] = ").Append(variableName).Append("EntityId;\n") .Tab().Append(variableName).Append("J[\"class\"] = ").Append(hash).Append(";\n") .Tab().Append("j[\"").Append(variableName).Append("\"] = ").Append(variableName).Append("J;\n"); } else { m_Builder.Append("Error\n"); } } else { m_Builder.Tab().Append("JSON ").Append(variableName).Append("Json;\n") .Tab().Append("m_").Append(customDeclaration.Name).Append(".ToJSON(&").Append(variableName).Append("Json);\n") .Tab().Append("j[\"").Append(variableName).Append("\"] = ").Append(variableName).Append("Json.GetJ();\n"); } }
public override void VisitCustomDeclaration(CustomDeclaration customDeclaration) { if (customDeclaration.IsPointer && !customDeclaration.HasAttribute("ForwardDeclareIgnore") && !IsAlreadyAdded(customDeclaration.CppType)) { m_Builder.Append("class ").Append(customDeclaration.CppType).Append(";\n"); m_AddedDeclares.Add(customDeclaration.CppType); } }
public override void VisitCustomDeclaration(CustomDeclaration customDeclaration) { if (customDeclaration.IsPointer || customDeclaration.HasAttribute("Enum")) { VisitValueDeclaration(customDeclaration); } else { VisitReferenceDeclaration(customDeclaration); } }
public override void VisitCustomDeclaration(CustomDeclaration customDeclaration) { if (!CanVisit(customDeclaration)) { return; } Prefix(); VisitDeclaration(customDeclaration); }
public override void VisitCustomDeclaration(CustomDeclaration customDeclaration) { if ((customDeclaration.IsPointer || customDeclaration.HasAttribute("Enum")) && !customDeclaration.IsArray) { bool isBaseType = customDeclaration.HasAttribute("Enum"); VisitValueDeclaration(customDeclaration, isBaseType); } else { VisitReferenceDeclaration(customDeclaration); } }
public override void VisitCustomDeclaration(CustomDeclaration customDeclaration) { if (HandleDeclaration(customDeclaration)) { return; } if (!customDeclaration.IsPointer) { string variableName = customDeclaration.Name.ToLowerCamelCase(); m_Builder.Tab().Append("JSON ").Append(variableName).Append("JSON(j[\"").Append(variableName).Append("\"]);\n") .Tab().Append("m_").Append(customDeclaration.Name).Append(".FromJSON(&").Append(variableName).Append("JSON);\n"); } }
public override void VisitCustomDeclaration(CustomDeclaration customDeclaration) { if (HandleDeclaration(customDeclaration)) { return; } if (customDeclaration.IsPointer) { string variableName = customDeclaration.Name.ToLowerCamelCase(); m_Builder.Tab().Append("if (Entity* ").Append(variableName).Append("Entity = GetOwner()->GetWorld()->GetEntityById(j[\"") .Append(variableName).Append("\"][\"entityId\"]))\n") .Tab().Append("{\n") .Tab().Tab().Append("m_").Append(customDeclaration.Name).Append(" = static_cast<").Append(customDeclaration.CppType) .Append("*>(ComponentBuilder::GetComponent(").Append(variableName).Append("Entity, j[\"").Append(variableName) .Append("\"][\"class\"]));\n") .Tab().Append("}\n"); } }
public override void VisitCustomDeclaration(CustomDeclaration customDeclaration) { VisitDeclaration(customDeclaration, null); }
public abstract void VisitCustomDeclaration(CustomDeclaration customDeclaration);
private Declaration Declaration() { List <FieldAttribute> attrs = new List <FieldAttribute>(); while (m_Look.Tag == '[') { List <FieldAttribute> fieldAttributes = FieldAttributes(); attrs.AddRange(fieldAttributes); } TypeInfo typeInfo = new TypeInfo(); if (m_Look.Tag == (int)TagType.Const) { typeInfo.IsConst = true; Match(TagType.Const); } CType t = Type(); if (m_Look.Tag == '*') { typeInfo.IsPointer = true; Match('*'); } if (m_Look.Tag == '[') { typeInfo.IsArray = true; Match('['); Match(']'); } Word word = (Word)m_Look; Match(TagType.Id); Declaration decl = null; if (m_Look.Tag == '=') { decl = InitializedDeclaration(t, word.Lexeme, typeInfo); } else { if (t.Tag == (int)TagType.Custom) { decl = new CustomDeclaration(word.Lexeme, t.Lexeme, typeInfo); } else { decl = UninitializedDeclaration(t, word.Lexeme, typeInfo); } } if (decl == null) { Error("invalid declaration"); } decl.Attributes = attrs; return(decl); }