RegisterType is called from generated code and maps from the fully qualified proto name to the type (pointer to struct) of the protocol buffer.
(x Message, name string)
| 543 | // RegisterType is called from generated code and maps from the fully qualified |
| 544 | // proto name to the type (pointer to struct) of the protocol buffer. |
| 545 | func RegisterType(x Message, name string) { |
| 546 | if _, ok := protoTypedNils[name]; ok { |
| 547 | // TODO: Some day, make this a panic. |
| 548 | log.Printf("proto: duplicate proto type registered: %s", name) |
| 549 | return |
| 550 | } |
| 551 | t := reflect.TypeOf(x) |
| 552 | if v := reflect.ValueOf(x); v.Kind() == reflect.Ptr && v.Pointer() == 0 { |
| 553 | // Generated code always calls RegisterType with nil x. |
| 554 | // This check is just for extra safety. |
| 555 | protoTypedNils[name] = x |
| 556 | } else { |
| 557 | protoTypedNils[name] = reflect.Zero(t).Interface().(Message) |
| 558 | } |
| 559 | revProtoTypes[t] = name |
| 560 | } |
| 561 | |
| 562 | // RegisterMapType is called from generated code and maps from the fully qualified |
| 563 | // proto name to the native map type of the proto map definition. |
no outgoing calls
searching dependent graphs…