push

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package push provides basic routines to push data of individual values of different types and some not-so-basic to push data of blocks from save files of Grim Dawn

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Block

func Block(ctx gdcx.Context, kind uint32) iter.Seq[gdcx.Context]

Block takes an instance of gdcx.Context and a `uint32` value with kind of a block, and returns an iterator of the context. The iterator properly pushes the block's prefix and suffix, yielding between and calculating the resulting block size. If the context is nil, has been halted or is halted during yield, the iterator returns.

func Bool

func Bool(ctx gdcx.Context, v bool)

Bool takes an instance of gdcx.Context and a `bool` value, and pushed zero byte, if the value is false, or byte of 1 otherwise. Its behavior is based on Byte completely.

func Byte

func Byte(ctx gdcx.Context, v byte)

Byte takes an instance of gdcx.Context and a byte, encrypts the byte with help of the context's state and pushes the encrypted byte to the context's data stack, transforming the context's state in the process. It does nothing if the context is nil or has been halted.

func CheckInt

func CheckInt(ctx gdcx.Context, v int)

CheckInt takes an instance of gdcx.Context and an `int` value, and checks, if the value is in range of [0, math.MaxUint32]. If the context is nil or the value is in range, it does nothig. Otherwise it halts the context with the corresponding error.

func Float32

func Float32(ctx gdcx.Context, v float32)

Float32 takes a instance of gdcx.Context and a `float32` value, and pushes the value onto data stack of the context. Its behavior is based on Uint32 completely.

func Int

func Int(ctx gdcx.Context, v int)

Int takes an instance of gdcx.Context and an `int` value, checks, if the value is in proper range with CheckInt, and tries to push it with Uint32. Its behavior is defined by the functions completely.

func Safe

func Safe[T comparable](ctx gdcx.Context, v T, err error) func(func() bool)

Safe is a wrapper around the checks in the provided instance of gdcx.Context and the provided instance of comparable `T`. It yields to the provided function, if the context is not nil and hasn't been halted, and the instance of `T` doesn't default value. If the instance has default value, it halts the context with the provided error value. It is supposed to be used in `for range` clause:

for range Safe(ctx, v, errVNil) {
	// This block of code is assured to have non-nil not-halted ctx
	// and v with non-default (like nil) value
}

func Slice

func Slice[T any](ctx gdcx.Context, v []T, p func(gdcx.Context, T))

Slice accepts an instance of gdcx.Context, a slice of values of type `T` and a function p, which accepts a context too with a value of type `T`. Slice pushes to the data stack of the context length of the slice and then all the elements with help of p. It returns, if the context is nil, has been halted or is halted in the process. It halts the context with a corresponding error, if p is nil. It treats nil slices as zero-lengthed ones.

func State

func State(ctx gdcx.Context)

States takes an instance of gdcx.Context and pushes its state to its data stack as is without any transforming. It does nothing, if the context is nil or has been halted.

func String

func String(ctx gdcx.Context, v string)

String takes an instance of gdcx.Context and a string value, and pushes length of the string and its content to the data stack of the context with help of Uint32 and Byte. If the context is nil or has been halted, it does nothing.

func StringUtf16

func StringUtf16(ctx gdcx.Context, v string)

StringUtf16 takes an instance of gdcx.Context and a string value, and pushes length of the string and its content to the data stack of the context with help of Uint32 and Byte in format of UTF-16 little endian encoding. If the context is nil or has been halted, it does nothing.

func Uint32

func Uint32(ctx gdcx.Context, v uint32)

Uint32 takes an instance of gdcx.Context and a `uint32` value, encrypts the value with help of the context's state and pushes the encrypted value to the context's data stack in little-endian order, transforming the context's state in the process. It does nothing if the context is nil or has been halted.

func Uuid

func Uuid(ctx gdcx.Context, v [16]byte)

Uuid takes an instance of gdcx.Context and an array of 16 bytes, and pushes the bytes into data stack of the context. Its behavior is based on Byte completely.

Types

This section is empty.

Jump to

Keyboard shortcuts

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