raw

package
v0.0.0-...-e25c500 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2021 License: GPL-3.0, JSON Imports: 3 Imported by: 0

README

== Disclaimer ==
The RAW package circumvents and subverts Go's type system. As such it should be used with extreme caution and only
when absolutely necessary. Incautious use can and will lead to memory corruption. As such no warranty can be provided
as to its suitability or fitness for purpose.

Just to reiterate: MISUSE WILL RESULT IN MEMORY CORRUPTION.


== License ==

RAW is dual-licensed.

The library can be included in your project as "Random Access Woe" under the BSD-derived license in LICENSE.

"Read it And Weep" is the closed-source variant of the library. It is in all particulars identical to the open-source
version but requires a commercial usage license and in the process hides your shame for abusing Go in this manner.
Further details of commercial license costs are available from the author on request.


== About ==

RAW is a high-level interface to Go's unsafe and reflection packages, designed to ease both generic programming and
low-level memory access.

RAW allows any type with identifiable contiguous memory allocation to be converted to a byte slice which can then
be manipulated using many of the standard IO interfaces provided by the core library. This is very unsafe but for
certain system programming tasks can be very useful. In particular it facilitates the sharing of memory buffers with
language runtimes and any number of related tricks such as polymorphic variables, mixed-content arrays and binary
data marshalling.

Documentation is currently sparse but will improve over time. I have tried to keep nomenclature clear to assist with
figuring our how the library should be used and there are also extensive tests which demonstrate all of the library
types and their methods in use.


== History ==

The RAW package began life as a research spike of the GoLightly virtual machine project and was originally to be called
either "Dangerous" or "Deadly" to reflect the unpleasant consequences of misuse. A friend suggested "Random Access Woe"
and the name stuck.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BOOLEAN = RegisterType("bool", true, []bool{})
View Source
var BYTE = RegisterType("byte", byte(0), []byte{})
View Source
var COMPLEX128 = RegisterType("complex128", complex128(0), []complex128{})
View Source
var COMPLEX64 = RegisterType("complex64", complex64(0), []complex64{})
View Source
var FLOAT32 = RegisterType("float32", float32(0.0), []float32{})
View Source
var FLOAT64 = RegisterType("float64", float64(0.0), []float64{})
View Source
var INT = RegisterType("int", int(0), []int{})
View Source
var INT16 = RegisterType("int16", int16(0), []int16{})
View Source
var INT32 = RegisterType("int32", int32(0), []int32{})
View Source
var INT64 = RegisterType("int64", int64(0), []int64{})
View Source
var INT8 = RegisterType("int8", int8(0), []int8{})
View Source
var INTERFACE = RegisterType("interface{}", _a, []interface{}{})
View Source
var POINTER = RegisterType("unsafe.Pointer", unsafe.Pointer(&_a), []unsafe.Pointer{})
View Source
var UINT = RegisterType("uint", uint(0), []uint{})
View Source
var UINT16 = RegisterType("uint16", uint16(0), []uint16{})
View Source
var UINT32 = RegisterType("uint32", uint32(0), []uint32{})
View Source
var UINT64 = RegisterType("uint64", uint64(0), []uint64{})
View Source
var UINT8 = RegisterType("uint8", uint8(0), []uint8{})
View Source
var UINTPTR = RegisterType("uintptr", uintptr(0), []uintptr{})

Functions

func Assign

func Assign(location, value reflect.Value)

func BoolSlice

func BoolSlice(i interface{}) []bool

func ByteCopy

func ByteCopy(d interface{}, s interface{})

func ByteSlice

func ByteSlice(i interface{}) []byte

func Catch

func Catch(f func())

func CatchAll

func CatchAll(f func())

func Compatible

func Compatible(l, r interface{}) (b bool)

func Complex128Slice

func Complex128Slice(i interface{}) []complex128

func Complex64Slice

func Complex64Slice(i interface{}) []complex64

func ConcreteValue

func ConcreteValue(value interface{}) (r reflect.Value)

func DataAddress

func DataAddress(b []byte) (p unsafe.Pointer)

func Float32Slice

func Float32Slice(i interface{}) []float32

func Float64Slice

func Float64Slice(i interface{}) []float64

func Int16Slice

func Int16Slice(i interface{}) []int16

func Int32Slice

func Int32Slice(i interface{}) []int32

func Int64Slice

func Int64Slice(i interface{}) []int64

func Int8Slice

func Int8Slice(i interface{}) []int8

func IntSlice

func IntSlice(i interface{}) []int

func InterfaceSlice

func InterfaceSlice(i interface{}) []interface{}

func MakeAddressable

func MakeAddressable(value reflect.Value) reflect.Value

func PointerSlice

func PointerSlice(i interface{}) []unsafe.Pointer

func Reslice

func Reslice(slice interface{}, sliceType reflect.Type, elementSize int) interface{}

func Scale

func Scale(oldHeader *reflect.SliceHeader, oldElementSize, newElementSize int) (h *reflect.SliceHeader)

func SliceHeader

func SliceHeader(i interface{}) (Header *reflect.SliceHeader, ElementSize, ElementAlignment int)

func Throw

func Throw()

func Type

func Type(v interface{}) (r reflect.Type)

func Uint16Slice

func Uint16Slice(i interface{}) []uint16

func Uint32Slice

func Uint32Slice(i interface{}) []uint32

func Uint64Slice

func Uint64Slice(i interface{}) []uint64

func Uint8Slice

func Uint8Slice(i interface{}) []uint8

func UintSlice

func UintSlice(i interface{}) []uint

func UintptrSlice

func UintptrSlice(i interface{}) []uintptr

Types

type BasicType

type BasicType struct {
	// contains filtered or unexported fields
}

func RegisterType

func RegisterType(name string, v, s interface{}) (r BasicType)

func (BasicType) String

func (b BasicType) String() string

func (BasicType) Type

func (b BasicType) Type() reflect.Type

type MemoryBlock

type MemoryBlock interface {
	ByteSlice() []byte
}

A Buffered object can present itself as a byteslice. This byteslice can then be manipulated directly to modify the contents of memory. Use with extreme caution.

type Typed

type Typed interface {
	Type() reflect.Type
}

Jump to

Keyboard shortcuts

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