Skip to content

Latest commit

 

History

History
522 lines (297 loc) · 6.97 KB

api.md

File metadata and controls

522 lines (297 loc) · 6.97 KB

indirection

Function pointers and code redirection.

Copyright (c) 2022 Alex "Y_Less" Cole. Licensed under MPL 1.1

Indirection is a system for calling function pointers in a generic and type-safe way. Instead of CallLocalFunction, Call, defer, Callback_Call, or any other method, this gives one common interface which can be extended by library authors; utilising tags for compile-time parameters.

Functions

Indirect_Call:

Syntax

Indirect_Call(func, tag, ...)

Parameters

Name Info
func
tag
... {_,Bit,Text,Group,File,Float,Text3D}

Estimated stack usage

1 cells

Indirect_Claim_:

Syntax

Indirect_Claim_(func)

Parameters

Name Info
func The function pointer you want to use later.

Remarks

If a function pointer is used within one function, that is not a problem. However, if you want to store the function pointer for use later, you must first "claim" it, so that any associated data is not cleared when the parent function ends (i.e. the function that called your function). After use it must be released, and the number of claims must match the number of releases.

Depends on

Estimated stack usage

1 cells

Indirect_DePtr_:

Syntax

Indirect_DePtr_(ptr)

Parameters

Name Info
ptr
`` The array to convert to an offset pointer.

Remarks

Strings and arrays are passed relative to COD not DAT so they can be distinguished from normal function pointers. This function does the offset.

Depends on

Estimated stack usage

1 cells

Indirect_FromCallback:

Syntax

Indirect_FromCallback(cb, release)

Parameters

Name Info
cb F@_@
release bool

Remarks

A generic public wrapper for calling inline functions.

Depends on

Attributes

  • public

Estimated stack usage

5 cells

Indirect_GetMetaBool:

Syntax

Indirect_GetMetaBool(index, &ret)

Parameters

Name Info
index
ret bool &

Tag

bool:

Remarks

Get boolean metadata.

Depends on

Estimated stack usage

1 cells

Indirect_GetMetaFloat:

Syntax

Indirect_GetMetaFloat(index, &ret)

Parameters

Name Info
index
ret Float &

Tag

bool:

Remarks

Get float metadata.

Depends on

Estimated stack usage

1 cells

Indirect_GetMetaInt:

Syntax

Indirect_GetMetaInt(index, &ret)

Parameters

Name Info
index
ret &

Tag

bool:

Remarks

Get integer metadata.

Depends on

Estimated stack usage

1 cells

Indirect_GetMetaRef:

Syntax

Indirect_GetMetaRef(index, &ret)

Parameters

Name Info
index
ret &

Tag

bool:

Remarks

Get ref metadata.

Depends on

Estimated stack usage

1 cells

Indirect_GetMetaString:

Syntax

Indirect_GetMetaString(index, dest[], size)

Parameters

Name Info
index
dest []
size

Tag

bool:

Remarks

Get ref metadata.

Depends on

Estimated stack usage

5 cells

Indirect_Init:

Syntax

Indirect_Init()

Remarks

Get the size of the COD AMX segment.

Depends on

Estimated stack usage

21 cells

Indirect_Memcpy:

Syntax

Indirect_Memcpy(dest[], source, index, numbytes, maxlength)

Parameters

Name Info
dest []
source
index
numbytes
maxlength

Attributes

  • native

Indirect_SetMetaRef:

Syntax

Indirect_SetMetaRef(index, val)

Parameters

Name Info
index
val

Tag

bool:

Remarks

Set ref metadata.

Depends on

Estimated stack usage

1 cells

Indirect_Strcat:

Syntax

Indirect_Strcat(dest[], source, maxlength)

Parameters

Name Info
dest []
source
maxlength

Attributes

  • native

Indirect_Tag:

Syntax

Indirect_Tag(id, dest[])

Parameters

Name Info
id The ID of the tag to get the specifiers from the name of.
dest [32] Where to store the name.

Remarks

Functions are tagged with a special tag containing their specifiers. Get the string value of that tag from the AMX header.

Depends on

Estimated stack usage

6 cells

OnScriptInit@C:

Syntax

OnScriptInit@C()

Depends on

Attributes

  • public

Estimated stack usage

3 cells

OnScriptInit@E:

Syntax

OnScriptInit@E()

Depends on

Attributes

  • public

Estimated stack usage

3 cells

ScriptInit_OnJITCompile:

Syntax

ScriptInit_OnJITCompile()

Depends on

Attributes

  • public

Automaton

_ALS

Estimated stack usage

3 cells