package objc

import "golang.org/x/mobile/internal/importers/objc"

The objc package takes the result of an AST traversal by the importers package and uses the clang command to dump the type information for the referenced ObjC classes and protocols.

It is the of go/types for ObjC types and is used by the bind package to generate Go wrappers for ObjC API on iOS.

Index

Types

type Func

type Func struct {
	Sig    string
	GoName string
	Params []*Param
	Ret    *Type
	Static bool
	// Method whose name start with "init"
	Constructor bool
}

Func is a ObjC method, static functions as well as instance methods.

type Named

type Named struct {
	Name       string
	GoName     string
	Module     string
	Funcs      []*Func
	Methods    []*Func
	AllMethods []*Func
	Supers     []Super

	Protocol bool
	// Generated is true if the type is wrapper of a
	// generated Go struct.
	Generated bool
	// contains filtered or unexported fields
}

Named represents ObjC classes and protocols.

func Import

func Import(refs *importers.References) ([]*Named, error)

Import returns descriptors for a list of references to ObjC protocols and classes.

The type information is parsed from the output of clang -cc1 -ast-dump.

func (*Named) ObjcType

func (t *Named) ObjcType() string

type Param

type Param struct {
	Name string
	Type *Type
}

type Super

type Super struct {
	Name     string
	Protocol bool
}

Super denotes a super class or protocol.

type Type

type Type struct {
	Kind TypeKind
	// For Interface and Protocol types.
	Name string

	// The declared type raw from the AST.
	Decl string
	// Set if the type is a pointer to its kind. For classes
	// Indirect is true if the type is a double pointer, e.g.
	// NSObject **.
	Indirect bool
	// contains filtered or unexported fields
}

type TypeKind

type TypeKind int
const (
	Unknown TypeKind = iota
	Protocol
	Class
	String
	Data
	Int
	Uint
	Short
	Ushort
	Bool
	Char
	Uchar
	Float
	Double
)

Source Files

objc.go

Version
v0.0.0-20250408133729-978277e7eaf7 (latest)
Published
Apr 8, 2025
Platform
js/wasm
Imports
8 packages
Last checked
4 days ago

Tools for package owners.