Documentation ¶
Index ¶
- func PtrToByteSlice(p unsafe.Pointer) []byte
- func PtrToUint16Slice(p unsafe.Pointer) []uint16
- func ReinterpretCast[RET, SRC any](src SRC) RET
- func Wrap[CTYPE any, self any](in WrappableType[CTYPE, self]) (cPtr *CTYPE, finisher func())
- func WrapNumberPtr[CTYPE Number, GOTYPE Number](goValue *GOTYPE) (wrapped *CTYPE, finisher func())
- func WrapString[RET ~int8](value string) (wrapped *RET, finisher func())
- func WrapStringList[RET ~int8](value []string) (wrapped **RET, finisher func())
- type Number
- type Pool
- type StringBuffer
- type WrappableType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PtrToByteSlice ¶
func PtrToUint16Slice ¶
func ReinterpretCast ¶
func ReinterpretCast[RET, SRC any](src SRC) RET
ReinterpretCast acts exactly like C++'s reinterpret_cast. Intendedd use is to convert packageA.C.MyType to packageB.C.MyType. make sure your types are identical C types before using it. THIS IS HIGHLY UNSAFE (even more than Go's unsafe package) AND NOT RECOMMENDED TO USE OUTSIDE CIMGUI. It just forces pointer/type reinterpretation with unsafe.Pointer.
func Wrap ¶
func Wrap[CTYPE any, self any](in WrappableType[CTYPE, self]) (cPtr *CTYPE, finisher func())
Wrap takes a variable of one of the types defined in this file and returns a pointer to its C equivalend as well as a "finisher" func. This finisher func should be called after doing any operations on C pointer in order to apply the changes back to the original GO variable.
func WrapNumberPtr ¶
WrapNumberPtr is a generic method to convert GOTYPE (int32/float32 e.t.c.) into CTYPE (c_int/c_float e.t.c.)
func WrapString ¶
WrapString converts Go string to C char* Default value of RET is C.char
func WrapStringList ¶
WrapStringList converts Go string slice to C char** Default value of RET is C.char
Types ¶
type Number ¶
type Number interface { ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~float32 | ~float64 | ~bool // in C bool is technically a number }
Number is a generic type for Go/C types that can be used as a number. It could be anything that you can convert to that type (e.g. C.int is a Number, because it can be directly converted to int)
type Pool ¶ added in v1.2.0
type Pool[GoCallback any, CCallback comparable] struct { // contains filtered or unexported fields }
func NewPool ¶ added in v1.2.0
func NewPool[GoCallback any, CCallback comparable](poolElements ...CCallback) *Pool[GoCallback, CCallback]
func (*Pool[GoCallback, CCallback]) Allocate ¶ added in v1.2.0
func (p *Pool[GoCallback, CCallback]) Allocate(callback GoCallback) CCallback
func (*Pool[GoCallback, CCallback]) Clear ¶ added in v1.2.0
func (p *Pool[GoCallback, CCallback]) Clear()
type StringBuffer ¶
type StringBuffer struct {
// contains filtered or unexported fields
}
func NewStringBuffer ¶
func NewStringBuffer(initialValue string) *StringBuffer
func (*StringBuffer) Free ¶
func (buf *StringBuffer) Free()
func (*StringBuffer) Ptr ¶
func (buf *StringBuffer) Ptr() unsafe.Pointer
func (*StringBuffer) ResizeTo ¶
func (buf *StringBuffer) ResizeTo(requestedSize int)
func (*StringBuffer) Size ¶
func (buf *StringBuffer) Size() int
func (*StringBuffer) ToGo ¶
func (buf *StringBuffer) ToGo() string
type WrappableType ¶
type WrappableType[CTYPE any, self any] interface { // ToC converts self into CTYPE ToC() CTYPE // FromC force-converts taken any to CTYPE, converts it into self, // applies to receiver and returns it. FromC(unsafe.Pointer) self }
WrappableType represents a GO type that can be converted into a C value and back - into a GO value. CTYPE represents the equivalent C type of self. self is the type WrappableType applies to - TODO - figure out if it can be ommited :-) intentional values: - CTYPE is e.g. C.ImVec2, C.ImColor e.t.c. - self is a pointer type (e.g. *Vec2, Color)