}
engine := *enginePtr;
if engine.numInstr == 0 && st.NumField() > 0 && len(wireId.gobType().(*structType).field) > 0 {
- path, name := rt.Name();
+ name := rt.Name();
return os.ErrorString("gob: type mismatch: no fields matched compiling decoder for " + name)
}
return decodeStruct(engine, rt.(*reflect.StructType), b, uintptr(v.Addr()), 0);
if _, ok := t.Elem().(*reflect.Uint8Type); ok {
return tBytes.gobType()
}
- _, elemName := t.Elem().Name();
- return newSliceType(name, newType(elemName, t.Elem()));
+ return newSliceType(name, newType(t.Elem().Name(), t.Elem()));
case *reflect.StructType:
// Install the struct type itself before the fields so recursive
for i := 0; i < t.NumField(); i++ {
f := t.Field(i);
typ, _indir := indirect(f.Type);
- _pkg, tname := typ.Name();
+ tname := typ.Name();
if tname == "" {
tname = f.Type.String();
}
info, ok := typeInfoMap[rt];
if !ok {
info = new(typeInfo);
- path, name := rt.Name();
+ name := rt.Name();
info.typeId = getType(name, rt).id();
// assume it's a struct type
info.wire = &wireType{info.typeId.gobType().(*structType)};
// Each type in a program has a unique Type, so == on Types
// corresponds to Go's type equality.
type Type interface {
- // Name returns the type's package and name.
- // The package is a full package import path like "container/vector".
- Name() (pkgPath string, name string);
+ // PkgPath returns the type's package path.
+ // The package path is a full package import path like "container/vector".
+ PkgPath() string;
+
+ // Name returns the type's name within its package.
+ Name() string;
// String returns a string representation of the type.
// The string representation may use shortened package names
return t;
}
-func (t *uncommonType) Name() (pkgPath string, name string) {
- if t == nil {
- return;
+func (t *uncommonType) PkgPath() string {
+ if t == nil || t.pkgPath == nil {
+ return ""
}
- if t.pkgPath != nil {
- pkgPath = *t.pkgPath;
- }
- if t.name != nil {
- name = *t.name;
+ return *t.pkgPath;
+}
+
+func (t *uncommonType) Name() string {
+ if t == nil || t.name == nil {
+ return "";
}
- return;
+ return *t.name;
}
func (t *commonType) String() string {
return t.uncommonType.Method(i);
}
-func (t *commonType) Name() (pkgPath string, name string) {
+func (t *commonType) PkgPath() string {
+ return t.uncommonType.PkgPath();
+}
+
+func (t *commonType) Name() string {
return t.uncommonType.Name();
}
if p.name != nil {
f.Name = *p.name;
} else {
- nam, pkg := f.Type.Name();
- f.Name = nam;
+ f.Name = f.Type.Name();
f.Anonymous = true;
}
if p.pkgPath != nil {
s := new(service);
s.typ = reflect.Typeof(rcvr);
s.rcvr = reflect.NewValue(rcvr);
- path_, sname := reflect.Indirect(s.rcvr).Type().Name();
+ sname := reflect.Indirect(s.rcvr).Type().Name();
if sname == "" {
log.Exit("rpc: no service name for type", s.typ.String())
}