// See: http://duktape.org/api.html#duk_is_pointer
555905
func (d *Context) IsPointer(index int) bool {
	return int(C.duk_is_pointer(d.duk_context, C.duk_idx_t(index))) == 1
}
1165859
func (d *Context) PushHeapptr(ptr unsafe.Pointer) {
	C.duk_push_heapptr(d.duk_context, ptr)
}
950265
func structPointer_RefBool(p structPointer, f field) *bool {
	return (*bool)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
664928
func IsNotAPointerError(err error) bool {
	if e, ok := err.(interface {
		NotAPointerError() bool
	}); ok {
		return e.NotAPointerError()
	}
	if parent := parentOf(err); parent != nil {
		return IsNotAPointerError(parent)
	}
	return false
}
386333
func (d *Context) GetHeapptr(index int) unsafe.Pointer {
	return unsafe.Pointer(C.duk_get_heapptr(d.duk_context, C.duk_idx_t(index)))
}
212471
func toAddrPointer(i *interface{}, isptr, deref bool) pointer {
	v := reflect.ValueOf(*i)
	u := reflect.New(v.Type())
	u.Elem().Set(v)
	if deref {
		u = u.Elem()
	}
	return pointer{v: u}
}
88056
func (f *FieldInfo) IsPtr() bool {
	_, ok := f.Type.(*ast.StarExpr)
	return ok
}
530959
func isNullish(src interface{}) bool {
	if src == nil {
		return true
	}
	value := reflect.ValueOf(src)
	if value.Kind() == reflect.Ptr {
		if value.IsNil() {
			return true
		}
		value = value.Elem()
	}
	switch value.Kind() {
	case reflect.String:
		// if src is ptr type and len(string)=0, it returns false
		if !value.IsValid() {
			return true
		}
	case reflect.Int:
		return math.IsNaN(float64(value.Int()))
	case reflect.Float32, reflect.Float64:
		return math.IsNaN(float64(value.Float()))
	}
	return false
}
485190
func (pm *pointerMap) consider(v reflect.Value) {
	if v.Kind() == reflect.Invalid {
		return
	}
	// fmt.Printf("Considering [%s] %#v\n\r", v.Type().String(), v.Interface())
	if isPointerValue(v) && v.Pointer() != 0 { // pointer is 0 for unexported fields
		// fmt.Printf("Ptr is %d\n\r", v.Pointer())
		reused := pm.addPointerReturnTrueIfWasReused(v.Pointer())
		if reused {
			// No use descending inside this value, since it have been seen before and all its descendants
			// have been considered
			return
		}
	}

	// Now descend into any children of this value
	switch v.Kind() {
	case reflect.Slice, reflect.Array:
		numEntries := v.Len()
		for i := 0; i < numEntries; i++ {
			pm.consider(v.Index(i))
		}

	case reflect.Interface:
		pm.consider(v.Elem())

	case reflect.Ptr:
		pm.consider(v.Elem())

	case reflect.Map:
		keys := v.MapKeys()
		sort.Sort(mapKeySorter{
			keys:    keys,
			options: &Config,
		})
		for _, key := range keys {
			pm.consider(v.MapIndex(key))
		}

	case reflect.Struct:
		numFields := v.NumField()
		for i := 0; i < numFields; i++ {
			pm.consider(v.Field(i))
		}
	}
}
830553
func (d *Context) RequireBuffer(index int) (rawPtr unsafe.Pointer, outSize uint) {
	rawPtr = C.duk_require_buffer(d.duk_context, C.duk_idx_t(index), (*C.duk_size_t)(unsafe.Pointer(&outSize)))
	return rawPtr, outSize
}
1298723
func isMarshaler(t reflect.Type) bool {
	// We're checking for (likely) pointer-receiver methods
	// so if t is not a pointer, something is very wrong.
	// The calls above only invoke isMarshaler on pointer types.
	if t.Kind() != reflect.Ptr {
		panic("proto: misuse of isMarshaler")
	}
	return t.Implements(marshalerType)
}
269864
func goFunctionCall(cCtx *C.duk_context) C.duk_ret_t {
	d := contextFromPointer(cCtx)

	funPtr, ctx := d.getFunctionPtrs()
	d.transmute(unsafe.Pointer(ctx))

	result := d.fnIndex.get(funPtr)(d)

	return C.duk_ret_t(result)
}
218503
func (d *Context) Dup(fromIndex int) {
	C.duk_dup(d.duk_context, C.duk_idx_t(fromIndex))
}
574417
func PointerCancel(listener func(*vecty.Event)) *vecty.EventListener {
	return &vecty.EventListener{Name: "pointercancel", Listener: listener}
}
302636
func toAddrPointer(i *interface{}, isptr, deref bool) (p pointer) {
	// Super-tricky - read or get the address of data word of interface value.
	if isptr {
		// The interface is of pointer type, thus it is a direct interface.
		// The data word is the pointer data itself. We take its address.
		p = pointer{p: unsafe.Pointer(uintptr(unsafe.Pointer(i)) + ptrSize)}
	} else {
		// The interface is not of pointer type. The data word is the pointer
		// to the data.
		p = pointer{p: (*[2]unsafe.Pointer)(unsafe.Pointer(i))[1]}
	}
	if deref {
		p.p = *(*unsafe.Pointer)(p.p)
	}
	return p
}
1208668
func (a *Allocation) Ptr() unsafe.Pointer {
	sh := (*reflect.SliceHeader)(unsafe.Pointer(&a.data))
	return unsafe.Pointer(sh.Data)
}
1055963
func (d *dumpState) dumpPtr(v reflect.Value) {
	// Remove pointers at or below the current depth from map used to detect
	// circular refs.
	for k, depth := range d.pointers {
		if depth >= d.depth {
			delete(d.pointers, k)
		}
	}

	// Keep list of all dereferenced pointers to show later.
	pointerChain := make([]uintptr, 0)

	// Figure out how many levels of indirection there are by dereferencing
	// pointers and unpacking interfaces down the chain while detecting circular
	// references.
	nilFound := false
	cycleFound := false
	indirects := 0
	ve := v
	for ve.Kind() == reflect.Ptr {
		if ve.IsNil() {
			nilFound = true
			break
		}
		indirects++
		addr := ve.Pointer()
		pointerChain = append(pointerChain, addr)
		if pd, ok := d.pointers[addr]; ok && pd < d.depth {
			cycleFound = true
			indirects--
			break
		}
		d.pointers[addr] = d.depth

		ve = ve.Elem()
		if ve.Kind() == reflect.Interface {
			if ve.IsNil() {
				nilFound = true
				break
			}
			ve = ve.Elem()
		}
	}

	// Display type information.
	d.w.Write(openParenBytes)
	d.w.Write(bytes.Repeat(asteriskBytes, indirects))
	d.w.Write([]byte(ve.Type().String()))
	d.w.Write(closeParenBytes)

	// Display pointer information.
	if !d.cs.DisablePointerAddresses && len(pointerChain) > 0 {
		d.w.Write(openParenBytes)
		for i, addr := range pointerChain {
			if i > 0 {
				d.w.Write(pointerChainBytes)
			}
			printHexPtr(d.w, addr)
		}
		d.w.Write(closeParenBytes)
	}

	// Display dereferenced value.
	d.w.Write(openParenBytes)
	switch {
	case nilFound:
		d.w.Write(nilAngleBytes)

	case cycleFound:
		d.w.Write(circularBytes)

	default:
		d.ignoreNextType = true
		d.dump(ve)
	}
	d.w.Write(closeParenBytes)
}