P prints the arguments to the generated output. It handles strings and int32s, plus handling indirections because they may be *string, etc. Any inputs of type AnnotatedAtoms may emit annotations in a .meta file in addition to outputting the atoms themselves (if g.annotateCode is true).
(str ...interface{})
| 1006 | // annotations in a .meta file in addition to outputting the atoms themselves (if g.annotateCode |
| 1007 | // is true). |
| 1008 | func (g *Generator) P(str ...interface{}) { |
| 1009 | if !g.writeOutput { |
| 1010 | return |
| 1011 | } |
| 1012 | g.WriteString(g.indent) |
| 1013 | for _, v := range str { |
| 1014 | switch v := v.(type) { |
| 1015 | case *AnnotatedAtoms: |
| 1016 | begin := int32(g.Len()) |
| 1017 | for _, v := range v.atoms { |
| 1018 | g.printAtom(v) |
| 1019 | } |
| 1020 | if g.annotateCode { |
| 1021 | end := int32(g.Len()) |
| 1022 | var path []int32 |
| 1023 | for _, token := range strings.Split(v.path, ",") { |
| 1024 | val, err := strconv.ParseInt(token, 10, 32) |
| 1025 | if err != nil { |
| 1026 | g.Fail("could not parse proto AST path: ", err.Error()) |
| 1027 | } |
| 1028 | path = append(path, int32(val)) |
| 1029 | } |
| 1030 | g.annotations = append(g.annotations, &descriptor.GeneratedCodeInfo_Annotation{ |
| 1031 | Path: path, |
| 1032 | SourceFile: &v.source, |
| 1033 | Begin: &begin, |
| 1034 | End: &end, |
| 1035 | }) |
| 1036 | } |
| 1037 | default: |
| 1038 | g.printAtom(v) |
| 1039 | } |
| 1040 | } |
| 1041 | g.WriteByte('\n') |
| 1042 | } |
| 1043 | |
| 1044 | // addInitf stores the given statement to be printed inside the file's init function. |
| 1045 | // The statement is given as a format specifier and arguments. |
no test coverage detected