@@ -37,7 +37,7 @@ type Nature struct {
3737 Type reflect.Type // Type of the value. If nil, then value is unknown.
3838 Kind reflect.Kind // Kind of the value.
3939
40- * Optional
40+ * TypeData
4141
4242 // Ref is a reference used for multiple, disjoint purposes. When the Nature
4343 // is for a:
@@ -50,7 +50,7 @@ type Nature struct {
5050 Method bool // If value retrieved from method. Usually used to determine amount of in arguments.
5151}
5252
53- type Optional struct {
53+ type TypeData struct {
5454 pkgPath string
5555 methodset * methodset // optional to avoid the map in *Cache
5656
@@ -100,15 +100,15 @@ func (c *Cache) FromType(t reflect.Type) Nature {
100100 if t == nil {
101101 return Nature {}
102102 }
103- var opt * Optional
103+ var opt * TypeData
104104 k := t .Kind ()
105105 switch k {
106106 case reflect .Struct :
107107 return c .getStruct (t )
108108 case reflect .Func :
109- opt = new (Optional )
109+ opt = new (TypeData )
110110 }
111- return Nature {Type : t , Kind : k , Optional : opt }
111+ return Nature {Type : t , Kind : k , TypeData : opt }
112112}
113113
114114func (c * Cache ) getStruct (t reflect.Type ) Nature {
@@ -122,7 +122,7 @@ func (c *Cache) getStruct(t reflect.Type) Nature {
122122 nt := Nature {
123123 Type : t ,
124124 Kind : reflect .Struct ,
125- Optional : & Optional {
125+ TypeData : & TypeData {
126126 structData : & structData {
127127 rType : t ,
128128 numField : t .NumField (),
@@ -215,7 +215,7 @@ func (n *Nature) Elem(c *Cache) Nature {
215215 case reflect .Ptr :
216216 return c .FromType (n .Type .Elem ())
217217 case reflect .Map :
218- if n .Optional != nil && n .DefaultMapValue != nil {
218+ if n .TypeData != nil && n .DefaultMapValue != nil {
219219 return * n .DefaultMapValue
220220 }
221221 return c .FromType (n .Type .Elem ())
@@ -243,12 +243,12 @@ func (n *Nature) AssignableTo(nt Nature) bool {
243243}
244244
245245func (n * Nature ) getMethodset (c * Cache ) * methodset {
246- if n .Optional != nil && n .Optional .methodset != nil {
247- return n .Optional .methodset
246+ if n .TypeData != nil && n .TypeData .methodset != nil {
247+ return n .TypeData .methodset
248248 }
249249 s := c .getMethodset (n .Type , n .Kind )
250- if n .Optional != nil {
251- n .Optional .methodset = s // cache locally if possible
250+ if n .TypeData != nil {
251+ n .TypeData .methodset = s // cache locally if possible
252252 }
253253 return s
254254}
@@ -341,7 +341,7 @@ func (n *Nature) FieldByName(c *Cache, name string) (Nature, bool) {
341341 return Nature {}, false
342342 }
343343 var sd * structData
344- if n .Optional != nil && n .structData != nil {
344+ if n .TypeData != nil && n .structData != nil {
345345 sd = n .structData
346346 } else {
347347 sd = c .getStruct (n .Type ).structData
@@ -356,13 +356,13 @@ func (n *Nature) PkgPath() string {
356356 if n .Type == nil {
357357 return ""
358358 }
359- if n .Optional != nil && n .Optional .pkgPathSet {
360- return n .Optional .pkgPath
359+ if n .TypeData != nil && n .TypeData .pkgPathSet {
360+ return n .TypeData .pkgPath
361361 }
362362 p := n .Type .PkgPath ()
363- if n .Optional != nil {
364- n .Optional .pkgPathSet = true
365- n .Optional .pkgPath = p
363+ if n .TypeData != nil {
364+ n .TypeData .pkgPathSet = true
365+ n .TypeData .pkgPath = p
366366 }
367367 return p
368368}
@@ -375,7 +375,7 @@ func (n *Nature) IsFastMap() bool {
375375}
376376
377377func (n * Nature ) Get (c * Cache , name string ) (Nature , bool ) {
378- if n .Kind == reflect .Map && n .Optional != nil {
378+ if n .Kind == reflect .Map && n .TypeData != nil {
379379 f , ok := n .Fields [name ]
380380 return f , ok
381381 }
@@ -414,8 +414,8 @@ func (n *Nature) All(c *Cache) map[string]Nature {
414414 for i := 0 ; i < n .NumMethods (c ); i ++ {
415415 method := n .Type .Method (i )
416416 nt := c .FromType (method .Type )
417- if nt .Optional == nil {
418- nt .Optional = new (Optional )
417+ if nt .TypeData == nil {
418+ nt .TypeData = new (TypeData )
419419 }
420420 nt .Method = true
421421 nt .MethodIndex = method .Index
@@ -434,7 +434,7 @@ func (n *Nature) All(c *Cache) map[string]Nature {
434434 }
435435
436436 case reflect .Map :
437- if n .Optional != nil {
437+ if n .TypeData != nil {
438438 for key , nt := range n .Fields {
439439 if _ , ok := table [key ]; ok {
440440 continue
0 commit comments