ruby

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package ruby is a wrapper for creating Ruby native extension in Go

ref.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool2Int

func Bool2Int(b bool) int

Bool2Int convert from bool to int (0 or 1)

func Char2String

func Char2String(char *Char) string

Char2String convert from *Char to Go string without copy

func GetGoStruct

func GetGoStruct(obj VALUE) unsafe.Pointer

GetGoStruct returns Go object from Ruby object

See also [NewGoStruct]

func Int2Bool

func Int2Bool(i Int) bool

Int2Bool convert from int (0 or 1) to bool

func NUM2INT

func NUM2INT(x VALUE) int

NUM2INT is alias to [RbNum2intInline]

func RbRaise

func RbRaise(exc VALUE, format string, a ...interface{})

RbRaise calls `rb_raise` in C

Original definition is following

void rb_raise(VALUE exc, const char *fmt, ...)

`format` is supported in Go's format, not Ruby

func Value2String

func Value2String(str VALUE) string

Value2String convert from [VALUE] to Go string

Types

type Bool

type Bool C.bool

Bool is a type for passing `C.bool` in and out of package

func (Bool) IsFalse

func (b Bool) IsFalse() bool

IsFalse checks whether false

func (Bool) IsTrue

func (b Bool) IsTrue() bool

IsTrue checks whether true

type Char

type Char C.char

Char is a type for passing `C.char` in and out of package

func String2Char

func String2Char(str string) (*Char, func())

String2Char convert from Go string to *Char

2nd return value is a function to free pointer. To prevent memory leaks, this function MUST always be called with `defer` when calling this function.

Example

char, clean := ruby.String2Char("ABCD")
defer clean()

func Strings2Chars

func Strings2Chars(strs []string) (**Char, func())

Strings2Chars convert from Go strings to **Char

2nd return value is a function to free pointer. To prevent memory leaks, this function MUST always be called with `defer` when calling this function.

Example

chars, clean := ruby.Strings2Chars([]string{"ABCD"})
defer clean()

type Double

type Double C.double

Double is a type for passing `C.double` in and out of package

type FdSet

type FdSet C.fd_set

FdSet is a type for passing `C.fd_set` in and out of package

type Int

type Int C.int

Int is a type for passing `C.int` in and out of package

type IntptrT

type IntptrT C.intptr_t

IntptrT is a type for passing `C.intptr_t` in and out of package

type Long

type Long C.long

Long is a type for passing `C.long` in and out of package

func NUM2LONG

func NUM2LONG(num VALUE) Long

NUM2LONG is alias to [RbNum2long]

func RARRAY_LEN added in v0.4.0

func RARRAY_LEN(a VALUE) Long

RARRAY_LEN is alias to [RbArrayLen]

func StringLen

func StringLen(str string) Long

StringLen returns string length as Long

type Longlong

type Longlong C.longlong

Longlong is a type for passing `C.longlong` in and out of package

type ModeT

type ModeT C.mode_t

ModeT is a type for passing `C.mode_t` in and out of package

type Short

type Short C.short

Short is a type for passing `C.short` in and out of package

type SizeT

type SizeT C.size_t

SizeT is a type for passing `C.size_t` in and out of package

type SsizeT

type SsizeT C.ssize_t

SsizeT is a type for passing `C.ssize_t` in and out of package

type StHashType

type StHashType StructStHashType

StHashType is alias to StructStHashType

type StructStHashType

type StructStHashType C.struct_st_hash_type

StructStHashType is a type for passing `C.struct_st_hash_type` in and out of package

type StructTimespec

type StructTimespec C.struct_timespec

StructTimespec is a type for passing `C.struct_timespec` in and out of package

type StructTimeval

type StructTimeval C.struct_timeval

StructTimeval is a type for passing `C.struct_timeval` in and out of package

type TimeT

type TimeT C.time_t

TimeT is a type for passing `C.time_t` in and out of package

type Timespec

type Timespec StructTimespec

Timespec is alias to StructTimespec

type Timeval

type Timeval StructTimeval

Timeval is alias to StructTimeval

type Uchar

type Uchar C.uchar

Uchar is a type for passing `C.uchar` in and out of package

type Uint32T

type Uint32T C.uint32_t

Uint32T is a type for passing `C.uint32_t` in and out of package

type UintptrT

type UintptrT C.uintptr_t

UintptrT is a type for passing `C.uintptr_t` in and out of package

type Ulonglong

type Ulonglong C.ulonglong

Ulonglong is a type for passing `C.ulonglong` in and out of package

type Ushort

type Ushort C.ushort

Ushort is a type for passing `C.ushort` in and out of package

type VaList

type VaList C.va_list

VaList is a type for passing `C.va_list` in and out of package

type Void

type Void C.void

Void is a type for passing `C.void` in and out of package

Jump to

Keyboard shortcuts

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