printAtom prints the (atomic, non-annotation) argument to the generated output.
(v interface{})
| 973 | |
| 974 | // printAtom prints the (atomic, non-annotation) argument to the generated output. |
| 975 | func (g *Generator) printAtom(v interface{}) { |
| 976 | switch v := v.(type) { |
| 977 | case string: |
| 978 | g.WriteString(v) |
| 979 | case *string: |
| 980 | g.WriteString(*v) |
| 981 | case bool: |
| 982 | fmt.Fprint(g, v) |
| 983 | case *bool: |
| 984 | fmt.Fprint(g, *v) |
| 985 | case int: |
| 986 | fmt.Fprint(g, v) |
| 987 | case *int32: |
| 988 | fmt.Fprint(g, *v) |
| 989 | case *int64: |
| 990 | fmt.Fprint(g, *v) |
| 991 | case float64: |
| 992 | fmt.Fprint(g, v) |
| 993 | case *float64: |
| 994 | fmt.Fprint(g, *v) |
| 995 | case GoPackageName: |
| 996 | g.WriteString(string(v)) |
| 997 | case GoImportPath: |
| 998 | g.WriteString(strconv.Quote(string(v))) |
| 999 | default: |
| 1000 | g.Fail(fmt.Sprintf("unknown type in printer: %T", v)) |
| 1001 | } |
| 1002 | } |
| 1003 | |
| 1004 | // P prints the arguments to the generated output. It handles strings and int32s, plus |
| 1005 | // handling indirections because they may be *string, etc. Any inputs of type AnnotatedAtoms may emit |