Lines Matching refs:field
39 static std::string GenMethod(const FieldDef &field);
45 static std::string TypeName(const FieldDef &field);
50 std::string OffsetPrefix(const FieldDef &field) { in OffsetPrefix() argument
52 NumToString(field.value.offset) + in OffsetPrefix()
166 const FieldDef &field, in GetVectorLen() argument
171 code += " " + MakeCamel(field.name) + "Length("; in GetVectorLen()
172 code += ") int " + OffsetPrefix(field); in GetVectorLen()
179 const FieldDef &field, in GetUByteSlice() argument
184 code += " " + MakeCamel(field.name) + "Bytes("; in GetUByteSlice()
185 code += ") []byte " + OffsetPrefix(field); in GetUByteSlice()
192 const FieldDef &field, in GetScalarFieldOfStruct() argument
195 std::string getter = GenGetter(field.value.type); in GetScalarFieldOfStruct()
197 code += " " + MakeCamel(field.name); in GetScalarFieldOfStruct()
198 code += "() " + TypeName(field) + " {\n"; in GetScalarFieldOfStruct()
201 code += NumToString(field.value.offset) + "))\n}\n"; in GetScalarFieldOfStruct()
206 const FieldDef &field, in GetScalarFieldOfTable() argument
209 std::string getter = GenGetter(field.value.type); in GetScalarFieldOfTable()
211 code += " " + MakeCamel(field.name); in GetScalarFieldOfTable()
212 code += "() " + TypeName(field) + " "; in GetScalarFieldOfTable()
213 code += OffsetPrefix(field) + "\t\treturn " + getter; in GetScalarFieldOfTable()
215 code += "\treturn " + field.value.constant + "\n"; in GetScalarFieldOfTable()
222 const FieldDef &field, in GetStructFieldOfStruct() argument
226 code += " " + MakeCamel(field.name); in GetStructFieldOfStruct()
227 code += "(obj *" + TypeName(field); in GetStructFieldOfStruct()
228 code += ") *" + TypeName(field); in GetStructFieldOfStruct()
231 code += "\t\tobj = new(" + TypeName(field) + ")\n"; in GetStructFieldOfStruct()
234 code += NumToString(field.value.offset) + ")"; in GetStructFieldOfStruct()
242 const FieldDef &field, in GetStructFieldOfTable() argument
246 code += " " + MakeCamel(field.name); in GetStructFieldOfTable()
248 code += TypeName(field); in GetStructFieldOfTable()
249 code += ") *" + TypeName(field) + " " + OffsetPrefix(field); in GetStructFieldOfTable()
250 if (field.value.type.struct_def->fixed) { in GetStructFieldOfTable()
256 code += "\t\t\tobj = new(" + TypeName(field) + ")\n"; in GetStructFieldOfTable()
265 const FieldDef &field, in GetStringField() argument
269 code += " " + MakeCamel(field.name); in GetStringField()
270 code += "() " + TypeName(field) + " "; in GetStringField()
271 code += OffsetPrefix(field) + "\t\treturn " + GenGetter(field.value.type); in GetStringField()
278 const FieldDef &field, in GetUnionField() argument
282 code += " " + MakeCamel(field.name) + "("; in GetUnionField()
283 code += "obj " + TypeName(field) + ") bool "; in GetUnionField()
284 code += OffsetPrefix(field); in GetUnionField()
285 code += "\t\t" + GenGetter(field.value.type); in GetUnionField()
293 const FieldDef &field, in GetMemberOfVectorOfStruct() argument
296 auto vectortype = field.value.type.VectorType(); in GetMemberOfVectorOfStruct()
299 code += " " + MakeCamel(field.name); in GetMemberOfVectorOfStruct()
300 code += "(obj *" + TypeName(field); in GetMemberOfVectorOfStruct()
301 code += ", j int) bool " + OffsetPrefix(field); in GetMemberOfVectorOfStruct()
317 const FieldDef &field, in GetMemberOfVectorOfNonStruct() argument
320 auto vectortype = field.value.type.VectorType(); in GetMemberOfVectorOfNonStruct()
323 code += " " + MakeCamel(field.name); in GetMemberOfVectorOfNonStruct()
324 code += "(j int) " + TypeName(field) + " "; in GetMemberOfVectorOfNonStruct()
325 code += OffsetPrefix(field); in GetMemberOfVectorOfNonStruct()
327 code += "\t\treturn " + GenGetter(field.value.type) + "("; in GetMemberOfVectorOfNonStruct()
360 auto &field = **it; in StructBuilderArgs() local
361 if (IsStruct(field.value.type)) { in StructBuilderArgs()
365 StructBuilderArgs(*field.value.type.struct_def, in StructBuilderArgs()
366 (nameprefix + (field.name + "_")).c_str(), in StructBuilderArgs()
371 code += MakeCamel(field.name, false); in StructBuilderArgs()
372 code += " " + GenTypeBasic(field.value.type); in StructBuilderArgs()
394 auto &field = **it; in StructBuilderBody() local
395 if (field.padding) in StructBuilderBody()
396 code += "\tbuilder.Pad(" + NumToString(field.padding) + ")\n"; in StructBuilderBody()
397 if (IsStruct(field.value.type)) { in StructBuilderBody()
398 StructBuilderBody(*field.value.type.struct_def, in StructBuilderBody()
399 (nameprefix + (field.name + "_")).c_str(), in StructBuilderBody()
402 code += "\tbuilder.Prepend" + GenMethod(field) + "("; in StructBuilderBody()
403 code += nameprefix + MakeCamel(field.name, false) + ")\n"; in StructBuilderBody()
427 const FieldDef &field, in BuildFieldOfTable() argument
431 code += "func " + struct_def.name + "Add" + MakeCamel(field.name); in BuildFieldOfTable()
433 code += MakeCamel(field.name, false) + " "; in BuildFieldOfTable()
434 if (!IsScalar(field.value.type.base_type) && (!struct_def.fixed)) { in BuildFieldOfTable()
437 code += GenTypeBasic(field.value.type); in BuildFieldOfTable()
441 code += GenMethod(field) + "Slot("; in BuildFieldOfTable()
443 if (!IsScalar(field.value.type.base_type) && (!struct_def.fixed)) { in BuildFieldOfTable()
446 code += MakeCamel(field.name, false) + ")"; in BuildFieldOfTable()
448 code += MakeCamel(field.name, false); in BuildFieldOfTable()
450 code += ", " + field.value.constant; in BuildFieldOfTable()
456 const FieldDef &field, in BuildVectorOfTable() argument
460 code += MakeCamel(field.name); in BuildVectorOfTable()
463 auto vector_type = field.value.type.VectorType(); in BuildVectorOfTable()
488 const FieldDef &field, in GenStructAccessor() argument
490 GenComment(field.doc_comment, code_ptr, nullptr, ""); in GenStructAccessor()
491 if (IsScalar(field.value.type.base_type)) { in GenStructAccessor()
493 GetScalarFieldOfStruct(struct_def, field, code_ptr); in GenStructAccessor()
495 GetScalarFieldOfTable(struct_def, field, code_ptr); in GenStructAccessor()
498 switch (field.value.type.base_type) { in GenStructAccessor()
501 GetStructFieldOfStruct(struct_def, field, code_ptr); in GenStructAccessor()
503 GetStructFieldOfTable(struct_def, field, code_ptr); in GenStructAccessor()
507 GetStringField(struct_def, field, code_ptr); in GenStructAccessor()
510 auto vectortype = field.value.type.VectorType(); in GenStructAccessor()
512 GetMemberOfVectorOfStruct(struct_def, field, code_ptr); in GenStructAccessor()
514 GetMemberOfVectorOfNonStruct(struct_def, field, code_ptr); in GenStructAccessor()
519 GetUnionField(struct_def, field, code_ptr); in GenStructAccessor()
525 if (field.value.type.base_type == BASE_TYPE_VECTOR) { in GenStructAccessor()
526 GetVectorLen(struct_def, field, code_ptr); in GenStructAccessor()
527 if (field.value.type.element == BASE_TYPE_UCHAR) { in GenStructAccessor()
528 GetUByteSlice(struct_def, field, code_ptr); in GenStructAccessor()
535 const FieldDef &field, in MutateScalarFieldOfStruct() argument
538 std::string type = MakeCamel(GenTypeBasic(field.value.type)); in MutateScalarFieldOfStruct()
541 code += " Mutate" + MakeCamel(field.name); in MutateScalarFieldOfStruct()
542 code += "(n " + TypeName(field) + ") bool {\n\treturn " + setter; in MutateScalarFieldOfStruct()
544 code += NumToString(field.value.offset) + "), n)\n}\n\n"; in MutateScalarFieldOfStruct()
549 const FieldDef &field, in MutateScalarFieldOfTable() argument
552 std::string type = MakeCamel(GenTypeBasic(field.value.type)); in MutateScalarFieldOfTable()
555 code += " Mutate" + MakeCamel(field.name); in MutateScalarFieldOfTable()
556 code += "(n " + TypeName(field) + ") bool {\n\treturn "; in MutateScalarFieldOfTable()
557 code += setter + "(" + NumToString(field.value.offset) + ", n)\n"; in MutateScalarFieldOfTable()
563 const FieldDef &field, in GenStructMutator() argument
565 GenComment(field.doc_comment, code_ptr, nullptr, ""); in GenStructMutator()
566 if (IsScalar(field.value.type.base_type)) { in GenStructMutator()
568 MutateScalarFieldOfStruct(struct_def, field, code_ptr); in GenStructMutator()
570 MutateScalarFieldOfTable(struct_def, field, code_ptr); in GenStructMutator()
583 auto &field = **it; in GenTableBuilders() local
584 if (field.deprecated) continue; in GenTableBuilders()
587 BuildFieldOfTable(struct_def, field, offset, code_ptr); in GenTableBuilders()
588 if (field.value.type.base_type == BASE_TYPE_VECTOR) { in GenTableBuilders()
589 BuildVectorOfTable(struct_def, field, code_ptr); in GenTableBuilders()
618 auto &field = **it; in GenStruct() local
619 if (field.deprecated) continue; in GenStruct()
621 GenStructAccessor(struct_def, field, code_ptr); in GenStruct()
622 GenStructMutator(struct_def, field, code_ptr); in GenStruct()
672 static std::string GenMethod(const FieldDef &field) { in GenMethod() argument
673 return IsScalar(field.value.type.base_type) in GenMethod()
674 ? MakeCamel(GenTypeBasic(field.value.type)) in GenMethod()
675 : (IsStruct(field.value.type) ? "Struct" : "UOffsetT"); in GenMethod()
709 static std::string TypeName(const FieldDef &field) { in TypeName() argument
710 return GenTypeGet(field.value.type); in TypeName()