Help us shape the future of Go! Take the 2026 Go Developer Survey

meta

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package meta defines the data model consumed by the purego code generator.

FrameworkMeta is the serialisable representation of a single macOS framework's public API surface. The scanner writes one <framework>-<arch>-<sdk>.gometa.json file per framework; the purego generator reads them back to emit CGo-free Go packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Availability

type Availability struct {
	MacOSIntroduced string   `json:"macos_introduced,omitempty"`
	MacOSDeprecated string   `json:"macos_deprecated,omitempty"`
	MacOSObsoleted  string   `json:"macos_obsoleted,omitempty"`
	DeprecationMsg  string   `json:"deprecation_message,omitempty"`
	ReplacedBy      string   `json:"replaced_by,omitempty"`
	IsUnavailable   bool     `json:"unavailable,omitempty"`
	Entitlements    []string `json:"entitlements,omitempty"`
}

Availability carries macOS API availability information.

type BlockType

type BlockType struct {
	Params []Param    `json:"args,omitempty"`
	Return ReturnType `json:"return"`
}

BlockType is a unique ObjC block signature.

type Class

type Class struct {
	Super         string       `json:"super,omitempty"`
	Protocols     []string     `json:"protocols,omitempty"`
	GenericParams []string     `json:"generic_params,omitempty"`
	Methods       []Method     `json:"methods,omitempty"`
	Properties    []Property   `json:"properties,omitempty"`
	Availability  Availability `json:"availability,omitempty"`
	SDKFile       string       `json:"sdk_file,omitempty"`
	SDKLine       int          `json:"sdk_line,omitempty"`
	SwiftName     string       `json:"swift_name,omitempty"`
	Doc           string       `json:"doc,omitempty"`

	// IsMainThreadRequired is set at load time (not scanned) when the class is
	// isolated to Swift's @MainActor — directly or by inheriting it from an
	// ancestor — meaning its instances must be used on the main thread. The
	// idiomatic emitter wraps such calls in purego.Main. Populated by the
	// mainactor sidecar merge + hierarchy propagation; never serialised to
	// .gometa.json.
	IsMainThreadRequired bool `json:"-"`
}

Class represents an Objective-C class (@interface).

type Enum

type Enum struct {
	GoType       string       `json:"go_type"`
	Members      []EnumMember `json:"members,omitempty"`
	IsAnon       bool         `json:"is_anon,omitempty"`
	Availability Availability `json:"availability,omitempty"`
	SDKFile      string       `json:"sdk_file,omitempty"`
	SDKLine      int          `json:"sdk_line,omitempty"`
	IsBitmask    bool         `json:"is_bitmask,omitempty"`
	IsExtensible bool         `json:"is_extensible,omitempty"`
	Doc          string       `json:"doc,omitempty"`
}

Enum is an Objective-C enum (NS_ENUM, NS_OPTIONS, or plain enum).

type EnumMember

type EnumMember struct {
	Name         string       `json:"name"`
	Value        string       `json:"value"`
	Availability Availability `json:"availability,omitempty"`
	Doc          string       `json:"doc,omitempty"`
}

EnumMember is a single constant within an enum.

type Extern

type Extern struct {
	Name         string       `json:"name"`
	ObjCType     string       `json:"objc_type"`
	GoType       string       `json:"go_type,omitempty"`
	Availability Availability `json:"availability,omitempty"`
	SDKFile      string       `json:"sdk_file,omitempty"`
	SDKLine      int          `json:"sdk_line,omitempty"`
	Doc          string       `json:"doc,omitempty"`
}

Extern is an extern symbol (global constant or variable).

type FrameworkMeta

type FrameworkMeta struct {
	Framework  string               `json:"framework"`
	SDKVersion string               `json:"sdk_version"`
	Arch       string               `json:"arch"`
	Classes    map[string]Class     `json:"classes"`
	Protocols  map[string]Protocol  `json:"protocols"`
	Enums      map[string]Enum      `json:"enums"`
	Structs    map[string]Struct    `json:"structs"`
	Functions  []Function           `json:"functions"`
	Externs    []Extern             `json:"externs"`
	BlockTypes map[string]BlockType `json:"block_types"`
	Typedefs   map[string]string    `json:"typedefs"`

	IsSwiftOnly     bool     `json:"swift_only,omitempty"`
	ParentFramework string   `json:"parent_framework,omitempty"`
	UmbrellaFor     []string `json:"umbrella_for,omitempty"`

	ForeignExtensions map[string][]Method `json:"foreign_extensions,omitempty"`
	DeclaredImports   map[string]bool     `json:"declared_imports,omitempty"`

	// LinkLib, when non-empty, means this is a plain C library (not an ObjC framework).
	// The generated package uses purego.Dlopen with the library path instead of a
	// framework path.
	LinkLib string `json:"link_lib,omitempty"`

	// SchemaVersion records which generation of the .gometa.json schema wrote
	// the file (stamped by internal/meta.Write at scan time); Read checks it
	// against internal/meta's supported window.
	SchemaVersion int `json:"schema_version,omitempty"`

	// ClangVersion and XcodeVersion are toolchain provenance recorded at scan
	// time. Carried here so tools reading via this package can surface them.
	ClangVersion string `json:"clang_version,omitempty"`
	XcodeVersion string `json:"xcode_version,omitempty"`
}

FrameworkMeta is the Go-optimised metadata for a single macOS framework, produced by the scanner and consumed by the purego code generator. Serialised as <framework>-<arch>-<sdk>.gometa.json.

func Read

func Read(path string) (*FrameworkMeta, error)

Read deserialises a .gometa.json file. The schema-version window is defined by internal/meta (the package that writes these files); referencing its constants here keeps the two readers from drifting.

type Function

type Function struct {
	Name         string       `json:"name"`
	Params       []Param      `json:"args,omitempty"`
	Return       ReturnType   `json:"return"`
	IsInline     bool         `json:"inline,omitempty"`
	IsVariadic   bool         `json:"variadic,omitempty"`
	Availability Availability `json:"availability,omitempty"`
	SDKFile      string       `json:"sdk_file,omitempty"`
	SDKLine      int          `json:"sdk_line,omitempty"`
	IsWarnUnused bool         `json:"warn_unused,omitempty"`
	Doc          string       `json:"doc,omitempty"`
}

Function is a plain C function declared in the framework headers.

type Method

type Method struct {
	Selector             string       `json:"selector"`
	IsClassMethod        bool         `json:"class_method,omitempty"`
	Params               []Param      `json:"args,omitempty"`
	Return               ReturnType   `json:"return"`
	IsInit               bool         `json:"is_init,omitempty"`
	IsNSError            bool         `json:"has_nserror,omitempty"`
	IsVariadic           bool         `json:"variadic,omitempty"`
	Availability         Availability `json:"availability,omitempty"`
	SDKFile              string       `json:"sdk_file,omitempty"`
	SDKLine              int          `json:"sdk_line,omitempty"`
	IsDesignatedInit     bool         `json:"designated_init,omitempty"`
	IsWarnUnused         bool         `json:"warn_unused,omitempty"`
	SwiftName            string       `json:"swift_name,omitempty"`
	Doc                  string       `json:"doc,omitempty"`
	IsOptional           bool         `json:"is_optional,omitempty"`
	IsMainThreadRequired bool         `json:"main_thread_required,omitempty"`

	// IsMainThreadExempt is set at load time (not scanned) when the method is
	// `nonisolated` — it explicitly opts out of its class's @MainActor isolation
	// and must NOT be wrapped in purego.Main even though the class is otherwise
	// main-thread-bound. Populated by the mainactor sidecar merge.
	IsMainThreadExempt bool `json:"-"`
}

Method represents a single Objective-C method selector.

type Param

type Param struct {
	Name       string `json:"name"`
	ObjCType   string `json:"objc_type"`
	IsBlock    bool   `json:"is_block,omitempty"`
	BlockRef   string `json:"block_ref,omitempty"`
	IsNullable bool   `json:"nullable,omitempty"`
	IsNoescape bool   `json:"no_escape,omitempty"`
	Direction  string `json:"modifier,omitempty"`
}

Param is a method argument.

type Property

type Property struct {
	Name         string       `json:"name"`
	ObjCType     string       `json:"objc_type"`
	IsReadOnly   bool         `json:"readonly,omitempty"`
	IsWeak       bool         `json:"weak,omitempty"`
	IsCopy       bool         `json:"copy,omitempty"`
	Getter       string       `json:"getter,omitempty"`
	Setter       string       `json:"setter,omitempty"`
	Availability Availability `json:"availability,omitempty"`
	SDKFile      string       `json:"sdk_file,omitempty"`
	SDKLine      int          `json:"sdk_line,omitempty"`
	Doc          string       `json:"doc,omitempty"`
}

Property is an Objective-C @property declaration.

type Protocol

type Protocol struct {
	InheritedProtocols []string     `json:"protocols,omitempty"`
	Methods            []Method     `json:"methods,omitempty"`
	Availability       Availability `json:"availability,omitempty"`
}

Protocol represents an Objective-C @protocol.

type ReturnType

type ReturnType struct {
	ObjCType          string `json:"objc_type"`
	IsGeneric         bool   `json:"is_generic,omitempty"`
	GenericParamName  string `json:"generic_param_name,omitempty"`
	IsInstancetype    bool   `json:"instancetype,omitempty"`
	IsAlreadyRetained bool   `json:"already_retained,omitempty"`
	IsNullable        bool   `json:"nullable,omitempty"`
}

ReturnType describes a method's return value.

type Struct

type Struct struct {
	Fields       []StructField `json:"fields,omitempty"`
	Availability Availability  `json:"availability,omitempty"`
	SDKFile      string        `json:"sdk_file,omitempty"`
	SDKLine      int           `json:"sdk_line,omitempty"`
	Doc          string        `json:"doc,omitempty"`
}

Struct is a C struct exposed by the framework.

type StructField

type StructField struct {
	Name     string `json:"name"`
	ObjCType string `json:"objc_type"`
	GoType   string `json:"go_type,omitempty"`
}

StructField is one field within a struct.

Jump to

Keyboard shortcuts

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