s3d.util

This module provides the following classes:

    • Memory: A dynamically allocated block of memory.
    • UUID: A class for generating and processing Universal Unique Identifiers.

Module Data

Module Functions

AsText (...)

Console (fmt, ...)

EnableWarnings (doEnable)

GetField (t, f)

Globals (pattern, depth)

Help ()

IsValidUUID (id)

id -> string

Returns true if the id string represents a valid UUID.

MakeInvalidUUID ()

Returns an invalid UUID in string form.

MakeUUID ()

Using an internal UUID object this function creates a randomly generated UUID string. Returns the UUID string.

Note: This function should not be called from runtime code because it will generate a different result each time. If using this UUID for a class declaration it's important that the string remain the same over the life of the class.

MakeReadOnlyTable (t)

t -> table

Returns a table meant to replace the supplied table which disallows further modifications, resulting in read-only access.

PersistentForget (key, global)

key -> string

global -> boolean

Removes the value with the given key from persistent storage.

"global" should match what was used in storing the value.

PersistentRetrieve (key, global)

key -> string

global -> boolean

Gets the value string from persistent storage using the given key.

"global" should match what was used in storing the value.

PersistentStore (key, value, global)

key -> string

value -> string

global -> boolean

Puts the given value string into persistent storage under the given key.

If "global" is true then the value is stored for all users on this machine,

otherwise the value is stored locally for this user only.

Printf (...)

PrintMeta (...)

PrintObj (...)

SetField (t, f, v)

SetMode (t, mode)

_CHECK (assertion [, message])

_INFORM (format, ...)

_DEBUG_ONLY (func, ...)

_NONDEBUG_ONLY (func, ...)

_MAC_ONLY (func, ...)

_NONMAC_ONLY (func, ...)

_WIN_ONLY (func, ...)

_NONWIN_ONLY (func, ...)

_WARNING (message, level)

Module Classes

The Memory Class

This class provides a dynamically allocated block of memory.

This class has the following construction methods:

Memory (numBytes)

numBytes -> integer

Constructs a new block of memory holding uninitialized data of the given size.

Returns the new object.

Memory (block)

block -> Memory

Constructs a new block of memory sharing the same storage with the given block.

Returns the new object.

Every instance of this class has the following member methods:

Please note that the in-memory layout of anything larger than a byte is processor dependent.

Memory:Clone ()

Returns a newly allocated copy of this block of memory.

Memory:GetSize ()

Returns the size in bytes of this block of memory.

Memory:IsValid ()

Returns true if this object holds a valid block of memory.

Memory:Peek (offset)

offset -> integer

Returns the byte at the given offset within this block of memory.

Memory:Peek16 (offset)

Returns the word at the given offset within this block of memory.

offset -> integer

Memory:Peek32 (offset)

offset -> integer

Returns the long word at the given offset within this block of memory.

Memory:Peek64 (offset)

offset -> integer

Returns the long long word at the given offset within this block of memory.

Memory:PeekFloat32 (offset)

offset -> integer

Returns the float at the given offset within this block of memory.

Memory:PeekFloat64 (offset)

Returns the double at the given offset within this block of memory.

offset -> integer

Memory:Poke (offset, value)

offset -> integer

value -> integer

Stores the given byte value at the given offset within this block of memory.

Memory:Poke16 (offset, value)

offset -> integer

value -> integer

Stores the given word value at the given offset within this block of memory.

Memory:Poke32 (offset, value)

offset -> integer

value -> integer

Stores the given long word value at the given offset within this block of memory.

Memory:Poke64 (offset, value)

offset -> integer

value -> integer

Stores the given long long word value at the given offset within this block of memory.

Memory:PokeFloat32 (offset, value)

offset -> integer

value -> double

Stores the given float value at the given offset within this block of memory.

Memory:PokeFloat64 (offset, value)

offset -> integer

value -> double

Stores the given double value at the given offset within this block of memory.

The UUID Class

This class provides for generating and comparing Universal Unique Identifiers.

This class has the following construction methods:

UUID ()

Constructs a new UUID object for the invalid ID.

Returns the new object.

UUID (uuid)

uuid -> UUID

Constructs a new UUID object by copying the existing object.

Returns the new object.

UUID (id)

id -> string

Constructs a new UUID object using a UUID string with the format:

"tttttttt-tttt-cccc-cccc-nnnnnnnnnnnn"

Returns the new object.

Every instance of this class has the following member methods:

UUID:Compare (uuid)

uuid -> UUID

Compare two UUIDs "lexically" and return:

-1) this UUID is lexically before the given UUID

0) this UUID is equal to the given UUID

+1) this UUID is lexically after the given UUID

UUID:Get ()

Returns the UUID in string form.

UUID:Hash ()

Returns a 16-bit unsigned integer hash code for this object.

Memory:Invalidate ()

Reverts this UUID to its invalid form.

Memory:IsValid ()

Returns true if this object is a valid UUID.

UUID:Set (id)

id -> string

Sets the UUID in string form.