References

Library for creating and referencing pointers.


Source: pkg/lua/lib/ref.go | Import: ref

This is used when both go and lua need to reference the same mutable data.

Functions


new

new(value, type?) -> int<ref.REFType.*>

References are used when go and lua need to share a reference to the same value. The primitive type versions must be used when that value must be a Go value. Also note that when refs are used for indexes in Go that they must start at 0 not 1.

Arguments

  • value any
  • type int<ref.REFType> - Must be compatible with the above value.
Return Values

  • int<ref.REFType.*>
new_slice

new_slice(ln, type?) -> int<ref.REFType.*>

References are used when go and lua need to share a reference to the same value. The primitive type versions must be used when that value must be a Go value. Also note that when refs are used for indexes in Go that they must start at 0 not 1. This also includes the slice created here, it's index starts at 0.

Arguments

  • ln int - A fixed length for the slice.
  • type int<ref.REFType> - Must be compatible with the values set into the slice.
Return Values

  • int<ref.REFType.*>
get

get(id) -> any

Note: this is a copy of the value being referenced, to mutate the ref use 'ref.set()'.

Arguments

  • id int<ref.REFType.*>
Return Values

  • any - Will be a set type deteremined by the REFType.
get_slice

get_slice(id, index) -> any

Note: this is a copy of the value being referenced, to mutate the ref use 'ref.set_slice()'.

Arguments

  • id int<ref.REFType.*>
  • index int - Must be within the range of 0 to 1 less than the set length.
Return Values

  • any - Will be a set type determined by the REFType.
len_slice

len_slice(id) -> int

Arguments

  • id int<ref.REFType.*>
Return Values

  • int - The length of the slice in the ref.
set

set(id, value)

Arguments

  • id int<ref.REFType.*>
  • value any - Must be compatible with the set REFType.
set_slice

set_slice(id, index, value)

Arguments

  • id int<ref.REFType.*>
  • index int - Must be in range 0 to 1 less than the set length.
  • value any - Must be compatible with the set REFType.
del

del(id)

Arguments

  • id int<ref.REFType.*>
del_many

del_many(ids...)

Arguments

  • ids int<ref.REFType.*>...

Constants


REFType
  • LUA
  • BOOL
  • INT
  • INT32
  • FLOAT
  • FLOAT32
  • STRING
  • RGBA - Use in lua as struct<image.Color>.
  • TIME - Use in lua as a number representing the time in ms.
  • FONT - Internal 'giu.FontInfo', cannot be created or set, getting will return the result of 'font.String()'.