store ids rather than Types in the structs so they can be encoded.

change Type to gobType.
fix some bugs around recursive structures.
lots of cleanup.
add the first cut at a type encoder.

R=rsc
DELTA=400  (287 added, 11 deleted, 102 changed)
OCL=31401
CL=31406
This commit is contained in:
Rob Pike 2009-07-09 14:33:43 -07:00
parent 7472f4c951
commit ec23467e65
8 changed files with 384 additions and 106 deletions

View file

@ -0,0 +1,37 @@
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package gob
import (
"bytes";
"gob";
"os";
"reflect";
"strings";
"testing";
"unsafe";
)
type ET2 struct {
x string;
}
type ET1 struct {
a int;
et2 *ET2;
next *ET1;
}
func TestBasicEncoder(t *testing.T) {
b := new(bytes.Buffer);
enc := NewEncoder(b);
et1 := new(ET1);
et1.a = 7;
et1.et2 = new(ET2);
enc.Encode(et1);
if enc.state.err != nil {
t.Error("encoder fail:", enc.state.err)
}
}