nativebind

package
v0.4.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package nativebind selects native bindings once, when a schema is built.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateFields

func GenerateFields(w io.Writer, name, typ string, fields []FieldSpec)

GenerateFields emits native operations using direct, typed Go expressions. Callers supply imports for nativebind, values, reflect, unsafe and field types. Both evmbind and record generators use this emitter.

func Layout

func Layout(t reflect.Type, fields *Struct, direct bool) *values.NativeLayout

Layout describes native memory for a reflected or generated field binding. The operations are also used for native addresses retained by EVM.

func Load

Load and Store are the shared reflection fallback for native storage. The supplied pointer addresses a Go value of exactly t, never VM cell storage.

func Store

func Store(t reflect.Type, p unsafe.Pointer, x values.Value)

Types

type Field

type Field struct {
	Name   string
	Type   reflect.Type
	Offset uintptr
	Get    func(unsafe.Pointer) values.Value
	Set    func(unsafe.Pointer, values.Value)
}

Field accesses a field of a live Go struct. The owner pointer must refer to the registered Go type and remain alive for the operation. Structs, arrays, maps and slices are borrowed by address; pointers retain their native target. Scalar and string values use the ordinary values.Value representation.

func (*Field) Address

func (f *Field) Address(owner unsafe.Pointer) unsafe.Pointer

func (*Field) AtOffset

func (f *Field) AtOffset(offset uintptr) *Field

AtOffset reuses this field's getter/setter inside a value-struct embedding. The offset is resolved at registration; generated leaf access stays generated.

type FieldSpec

type FieldSpec struct {
	Name, Type string
	Kind       reflect.Kind
}

FieldSpec describes one exported native Go field to the shared generator. Type is its Go source spelling in the generated file's import environment.

type GeneratedField

type GeneratedField struct {
	Name string
	Get  func(unsafe.Pointer) values.Value
	Set  func(unsafe.Pointer, values.Value)
}

type GeneratedFields

type GeneratedFields struct {
	Type   reflect.Type
	New    func() unsafe.Pointer
	Fields []GeneratedField
}

GeneratedFields is emitted alongside evmbind wrappers or KVO codecs. Type and the complete exposed field list are checked once during registration.

type Mode

type Mode uint8
const (
	Automatic Mode = iota
	StaticOnly
)

func (Mode) Select

func (m Mode) Select(name, want, provided string, compatible bool) bool

Select uses generated operations only if the declaration and its native operations both match. StaticOnly treats a stale binding as a setup error.

type Struct

type Struct struct {
	Type      reflect.Type
	Fields    []Field
	New       func() unsafe.Pointer
	Generated bool
	// contains filtered or unexported fields
}

Struct is an immutable native field binding. It is independent of KVO property numbers, VM memory layouts and the lifetime of any one object.

func BindFields

func BindFields(t reflect.Type, generated *GeneratedFields, mode Mode) *Struct

func (*Struct) Field

func (b *Struct) Field(name string) *Field

Directories

Path Synopsis
internal
fixture
Code generated by nativebind.
Code generated by nativebind.
generate command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL