variadic

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2023 License: MIT, BSD-2-Clause Imports: 2 Imported by: 1

README

Package variadic
================

This packge implements variadic calling conventions for calling foreign C code from within Go.

The primary motivation for this package was to be able to interface with Apple's Objective-C
runtime on Mac OS X, which uses a variadic function (objc_msgSend) for sending messages to objects.

Status
======

amd64:  Works pretty well - http://github.com/mkrautz/objc uses it (only tested on darwin, though!)

386:    Works on linux/386 and darwin/386

        Note: darwin/386 requires 16 byte stack alignment, and no
        effort has been made to support this at the moment. However,
        the tests pass on darwin/386 - not sure if I've been lucky.

Documentation

Overview

Package variadic implements interfaces for various variadic C calling conventions

Index

Constants

View Source
const (
	RDI = iota
	RDX
	RCX
	R8
	R9
	XMM0
	XMM1
	XMM2
	XMM3
	XMM4
	XMM5
	XMM6
	XMM7
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Function added in v0.2.0

type Function int
const (
	F_msgSend Function = iota
	F_msgSendSuper
	F_msgSend_stret
	F_msgSendSuper_stret
)

func (Function) Addr added in v0.2.0

func (f Function) Addr() unsafe.Pointer

func (Function) IsStRet added in v0.2.0

func (f Function) IsStRet() bool

func (Function) IsSuper added in v0.2.0

func (f Function) IsSuper() bool

func (Function) NewCall added in v0.2.0

func (f Function) NewCall() *FunctionCall

func (Function) StRet added in v0.2.0

func (f Function) StRet() Function

func (Function) String added in v0.2.0

func (f Function) String() string

type FunctionCall

type FunctionCall struct {
	Words     [14]uintptr
	NumFloat  int64
	NumMemory int64
	Memory    uintptr
	// contains filtered or unexported fields
}

func NewFunctionCall

func NewFunctionCall(name string) *FunctionCall

NewFunctionCall creates a new FunctionCall than can be used to call the C function named by the name parameter.

func NewFunctionCallAddr

func NewFunctionCallAddr(addr unsafe.Pointer) *FunctionCall

NewFunctionCallAddr creates a new FunctionCall that can be used to cll the C function at the address given by the addr parameter.

func (*FunctionCall) Call

func (f *FunctionCall) Call() uintptr

Call calls the FunctionCall's underlying function, returning its return value as an uintptr.

func (*FunctionCall) CallFloat32

func (f *FunctionCall) CallFloat32() float32

CallFloat32 calls the FunctionCall's underlying function, returning its return value as a float32.

func (*FunctionCall) CallFloat64

func (f *FunctionCall) CallFloat64() float64

CallFloat64 calls the FunctionCall's underlying function, returning its return value as float64.

Jump to

Keyboard shortcuts

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