| OLD | NEW | 
|---|
|  | (Empty) | 
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |  | 
| 2 // Use of this source code is governed by a BSD-style license that can be |  | 
| 3 // found in the LICENSE file. |  | 
| 4 |  | 
| 5 // HEAVILY adapted from github.com/golang/appengine/datastore |  | 
| 6 |  | 
| 7 package helper |  | 
| 8 |  | 
| 9 import ( |  | 
| 10         "reflect" |  | 
| 11 |  | 
| 12         "github.com/luci/gae" |  | 
| 13 ) |  | 
| 14 |  | 
| 15 // GetPLS resolves o into a gae.DSStructPLS. o must be a pointer to a |  | 
| 16 // struct of some sort. |  | 
| 17 func GetPLS(o interface{}) gae.DSPropertyLoadSaver { |  | 
| 18         v := reflect.ValueOf(o) |  | 
| 19         if v.Kind() != reflect.Ptr || v.Elem().Kind() != reflect.Struct { |  | 
| 20                 return &structPLS{c: &structCodec{problem: gae.ErrDSInvalidEntit
    yType}} |  | 
| 21         } |  | 
| 22         v = v.Elem() |  | 
| 23         t := v.Type() |  | 
| 24 |  | 
| 25         structCodecsMutex.RLock() |  | 
| 26         if c, ok := structCodecs[t]; ok { |  | 
| 27                 structCodecsMutex.RUnlock() |  | 
| 28                 return &structPLS{v, c} |  | 
| 29         } |  | 
| 30         structCodecsMutex.RUnlock() |  | 
| 31 |  | 
| 32         structCodecsMutex.Lock() |  | 
| 33         defer structCodecsMutex.Unlock() |  | 
| 34         return &structPLS{v, getStructCodecLocked(t)} |  | 
| 35 } |  | 
| OLD | NEW | 
|---|