You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

24 lines
671 B

  1. // Copyright 2018, The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE.md file.
  4. // +build purego
  5. package value
  6. import "reflect"
  7. // Pointer is an opaque typed pointer and is guaranteed to be comparable.
  8. type Pointer struct {
  9. p uintptr
  10. t reflect.Type
  11. }
  12. // PointerOf returns a Pointer from v, which must be a
  13. // reflect.Ptr, reflect.Slice, or reflect.Map.
  14. func PointerOf(v reflect.Value) Pointer {
  15. // NOTE: Storing a pointer as an uintptr is technically incorrect as it
  16. // assumes that the GC implementation does not use a moving collector.
  17. return Pointer{v.Pointer(), v.Type()}
  18. }