An error occurred fetching the project authors.
  1. 18 Oct, 2011 1 commit
  2. 17 Oct, 2011 1 commit
  3. 24 Aug, 2011 1 commit
  4. 22 Aug, 2011 1 commit
  5. 27 Jul, 2011 2 commits
  6. 14 Jul, 2011 1 commit
  7. 29 Jun, 2011 2 commits
    • Russ Cox's avatar
      reflect: support for struct tag use by multiple packages · 25733a94
      Russ Cox authored
      Each package using struct field tags assumes that
      it is the only package storing data in the tag.
      This CL adds support in package reflect for sharing
      tags between multiple packages.  In this scheme, the
      tags must be of the form
      
              key:"value" key2:"value2"
      
      (raw strings help when writing that tag in Go source).
      
      reflect.StructField's Tag field now has type StructTag
      (a string type), which has method Get(key string) string
      that returns the associated value.
      
      Clients of json and xml will need to be updated.
      Code that says
      
              type T struct {
                      X int "name"
              }
      
      should become
      
              type T struct {
                      X int `json:"name"`  // or `xml:"name"`
              }
      
      Use govet to identify struct tags that need to be changed
      to use the new syntax.
      
      R=r, r, dsymonds, bradfitz, kevlar, fvbommel, n13m3y3r
      CC=golang-dev
      https://golang.org/cl/4645069
      25733a94
    • Rob Pike's avatar
      reflect: MethodByName · 22484e22
      Rob Pike authored
      It's more common to ask for methods by name than by index, so might
      as well make it easy to do so.
      
      R=rsc
      CC=golang-dev
      https://golang.org/cl/4639083
      22484e22
  8. 17 May, 2011 1 commit
  9. 03 May, 2011 1 commit
  10. 28 Apr, 2011 1 commit
  11. 27 Apr, 2011 1 commit
  12. 25 Apr, 2011 1 commit
  13. 21 Apr, 2011 1 commit
  14. 20 Apr, 2011 1 commit
    • Russ Cox's avatar
      reflect: add Type.Implements, Type.AssignableTo, Value.CallSlice; make Set match Go · e1ee3b5d
      Russ Cox authored
      This CL makes reflect require that values be assignable to the target type
      in exactly the same places where that is the rule in Go.  It also adds
      the Implements and AssignableTo methods so that callers can check
      the types themselves so as to avoid a panic.
      
      Before this CL, reflect required strict type identity.
      
      This CL expands Call to accept and correctly marshal arbitrary
      argument lists for variadic functions; it introduces CallSlice for use
      in the case where the slice for the variadic argument is already known.
      
      Fixes #327.
      Fixes #1212.
      
      R=r, dsymonds
      CC=golang-dev
      https://golang.org/cl/4439058
      e1ee3b5d
  15. 19 Apr, 2011 1 commit
  16. 18 Apr, 2011 1 commit
    • Russ Cox's avatar
      reflect: more efficient; cannot Set result of NewValue anymore · 40fccbce
      Russ Cox authored
       * Reduces malloc counts during gob encoder/decoder test from 6/6 to 3/5.
      
      The current reflect uses Set to mean two subtly different things.
      
      (1) If you have a reflect.Value v, it might just represent
      itself (as in v = reflect.NewValue(42)), in which case calling
      v.Set only changed v, not any other data in the program.
      
      (2) If you have a reflect Value v derived from a pointer
      or a slice (as in x := []int{42}; v = reflect.NewValue(x).Index(0)),
      v represents the value held there.  Changing x[0] affects the
      value returned by v.Int(), and calling v.Set affects x[0].
      
      This was not really by design; it just happened that way.
      
      The motivation for the new reflect implementation was
      to remove mallocs.  The use case (1) has an implicit malloc
      inside it.  If you can do:
      
             v := reflect.NewValue(0)
             v.Set(42)
             i := v.Int()  // i = 42
      
      then that implies that v is referring to some underlying
      chunk of memory in order to remember the 42; that is,
      NewValue must have allocated some memory.
      
      Almost all the time you are using reflect the goal is to
      inspect or to change other data, not to manipulate data
      stored solely inside a reflect.Value.
      
      This CL removes use case (1), so that an assignable
      reflect.Value must always refer to some other piece of data
      in the program.  Put another way, removing this case would
      make
      
             v := reflect.NewValue(0)
             v.Set(42)
      
      as illegal as
      
             0 = 42.
      
      It would also make this illegal:
      
             x := 0
             v := reflect.NewValue(x)
             v.Set(42)
      
      for the same reason.  (Note that right now, v.Set(42) "succeeds"
      but does not change the value of x.)
      
      If you really wanted to make v refer to x, you'd start with &x
      and dereference it:
      
             x := 0
             v := reflect.NewValue(&x).Elem()  // v = *&x
             v.Set(42)
      
      It's pretty rare, except in tests, to want to use NewValue and then
      call Set to change the Value itself instead of some other piece of
      data in the program.  I haven't seen it happen once yet while
      making the tree build with this change.
      
      For the same reasons, reflect.Zero (formerly reflect.MakeZero)
      would also return an unassignable, unaddressable value.
      This invalidates the (awkward) idiom:
      
             pv := ... some Ptr Value we have ...
             v := reflect.Zero(pv.Type().Elem())
             pv.PointTo(v)
      
      which, when the API changed, turned into:
      
             pv := ... some Ptr Value we have ...
             v := reflect.Zero(pv.Type().Elem())
             pv.Set(v.Addr())
      
      In both, it is far from clear what the code is trying to do.  Now that
      it is possible, this CL adds reflect.New(Type) Value that does the
      obvious thing (same as Go's new), so this code would be replaced by:
      
             pv := ... some Ptr Value we have ...
             pv.Set(reflect.New(pv.Type().Elem()))
      
      The changes just described can be confusing to think about,
      but I believe it is because the old API was confusing - it was
      conflating two different kinds of Values - and that the new API
      by itself is pretty simple: you can only Set (or call Addr on)
      a Value if it actually addresses some real piece of data; that is,
      only if it is the result of dereferencing a Ptr or indexing a Slice.
      
      If you really want the old behavior, you'd get it by translating:
      
             v := reflect.NewValue(x)
      
      into
      
             v := reflect.New(reflect.Typeof(x)).Elem()
             v.Set(reflect.NewValue(x))
      
      Gofix will not be able to help with this, because whether
      and how to change the code depends on whether the original
      code meant use (1) or use (2), so the developer has to read
      and think about the code.
      
      You can see the effect on packages in the tree in
      https://golang.org/cl/4423043/.
      
      R=r
      CC=golang-dev
      https://golang.org/cl/4435042
      40fccbce
  17. 08 Apr, 2011 1 commit
    • Russ Cox's avatar
      reflect: new Type and Value definitions · fb175cf7
      Russ Cox authored
      Type is now an interface that implements all the possible type methods.
      Instead of a type switch on a reflect.Type t, switch on t.Kind().
      If a method is invoked on the wrong kind of type (for example,
      calling t.Field(0) when t.Kind() != Struct), the call panics.
      
      There is one method renaming: t.(*ChanType).Dir() is now t.ChanDir().
      
      Value is now a struct value that implements all the possible value methods.
      Instead of a type switch on a reflect.Value v, switch on v.Kind().
      If a method is invoked on the wrong kind of value (for example,
      calling t.Recv() when t.Kind() != Chan), the call panics.
      
      Since Value is now a struct, not an interface, its zero value
      cannot be compared to nil.  Instead of v != nil, use v.IsValid().
      Instead of other uses of nil as a Value, use Value{}, the zero value.
      
      Many methods have been renamed, most due to signature conflicts:
      
                 OLD                          NEW
      
          v.(*ArrayValue).Elem             v.Index
          v.(*BoolValue).Get               v.Bool
          v.(*BoolValue).Set               v.SetBool
          v.(*ChanType).Dir                v.ChanDir
          v.(*ChanValue).Get               v.Pointer
          v.(*ComplexValue).Get            v.Complex
          v.(*ComplexValue).Overflow       v.OverflowComplex
          v.(*ComplexValue).Set            v.SetComplex
          v.(*FloatValue).Get              v.Float
          v.(*FloatValue).Overflow         v.OverflowFloat
          v.(*FloatValue).Set              v.SetFloat
          v.(*FuncValue).Get               v.Pointer
          v.(*InterfaceValue).Get          v.InterfaceData
          v.(*IntValue).Get                v.Int
          v.(*IntValue).Overflow           v.OverflowInt
          v.(*IntValue).Set                v.SetInt
          v.(*MapValue).Elem               v.MapIndex
          v.(*MapValue).Get                v.Pointer
          v.(*MapValue).Keys               v.MapKeys
          v.(*MapValue).SetElem            v.SetMapIndex
          v.(*PtrValue).Get                v.Pointer
          v.(*SliceValue).Elem             v.Index
          v.(*SliceValue).Get              v.Pointer
          v.(*StringValue).Get             v.String
          v.(*StringValue).Set             v.SetString
          v.(*UintValue).Get               v.Uint
          v.(*UintValue).Overflow          v.OverflowUint
          v.(*UintValue).Set               v.SetUint
          v.(*UnsafePointerValue).Get      v.Pointer
          v.(*UnsafePointerValue).Set      v.SetPointer
      
      Part of the motivation for this change is to enable a more
      efficient implementation of Value, one that does not allocate
      memory during most operations.  To reduce the size of the CL,
      this CL's implementation is a wrapper around the old API.
      Later CLs will make the implementation more efficient without
      changing the API.
      
      Other CLs to be submitted at the same time as this one
      add support for this change to gofix (4343047) and update
      the Go source tree (4353043).
      
      R=gri, iant, niemeyer, r, rog, gustavo, r2
      CC=golang-dev
      https://golang.org/cl/4281055
      fb175cf7
  18. 11 Mar, 2011 1 commit
  19. 03 Mar, 2011 1 commit
  20. 20 Jan, 2011 1 commit
  21. 15 Dec, 2010 1 commit
  22. 14 Dec, 2010 1 commit
  23. 12 Dec, 2010 1 commit
  24. 07 Dec, 2010 1 commit
    • Rob Pike's avatar
      throughout: fix broken calls to Printf etc. · 1ce6245d
      Rob Pike authored
      I have written a tool to verify Printf calls, and although it's not
      ready to be reviewed yet it's already uncovered a spate of problems
      in the repository.  I'm sending this CL to break the changes into
      pieces; as the tool improves it will find more, I'm sure.
      
      R=rsc
      CC=golang-dev
      https://golang.org/cl/3427043
      1ce6245d
  25. 22 Oct, 2010 1 commit
  26. 28 Sep, 2010 1 commit
  27. 27 Sep, 2010 1 commit
  28. 17 Aug, 2010 1 commit
  29. 03 Aug, 2010 1 commit
  30. 20 Jun, 2010 1 commit
  31. 14 Jun, 2010 1 commit
  32. 21 Apr, 2010 1 commit
  33. 24 Feb, 2010 1 commit
  34. 26 Jan, 2010 1 commit
  35. 25 Jan, 2010 1 commit
  36. 15 Dec, 2009 1 commit
    • Robert Griesemer's avatar
      1) Change default gofmt default settings for · d65a5cce
      Robert Griesemer authored
         parsing and printing to new syntax.
      
         Use -oldparser to parse the old syntax,
         use -oldprinter to print the old syntax.
      
      2) Change default gofmt formatting settings
         to use tabs for indentation only and to use
         spaces for alignment. This will make the code
         alignment insensitive to an editor's tabwidth.
      
         Use -spaces=false to use tabs for alignment.
      
      3) Manually changed src/exp/parser/parser_test.go
         so that it doesn't try to parse the parser's
         source files using the old syntax (they have
         new syntax now).
      
      4) gofmt -w src misc test/bench
      
      4th set of files.
      
      R=rsc
      CC=golang-dev
      https://golang.org/cl/180049
      d65a5cce
  37. 10 Nov, 2009 1 commit
  38. 09 Nov, 2009 1 commit