Typed dispatch C reference

See Typed command dispatch for table lifetime, argument counts and callback boundaries. These are private implementation interfaces.

struct Rbc_OpSpecHeader

Common first member of persistent typed operation-table entries.

Terminate a table with a NULL name. Bounds count the complete command word vector; maxArgs <= 0 is unbounded. The enclosing entry supplies its own correctly typed callback, and its sizeof is the lookup stride.

Public Members

const char *name

Borrowed persistent operation name.

Tcl_Size minArgs

Minimum total argument count.

Tcl_Size maxArgs

Maximum total count, or nonpositive for no maximum.

const char *usage

Borrowed suffix for Tcl_WrongNumArgs.

int Rbc_GetOpIndexFromObj(Tcl_Interp *interp, const void *specArr, Tcl_Size specSize, Tcl_Size operPos, Tcl_Size objc, Tcl_Obj *const objv[], int *indexPtr)

Select a typed operation-table entry and validate total argument count.

Require a persistent NULL-name-terminated table whose entries start with Rbc_OpSpecHeader and have byte stride specSize. Tcl lookup accepts unique abbreviations and caches the table in the operation object. On success assign indexPtr, not a function pointer; the caller dispatches through its typed table. minArgs/maxArgs count all objc words; maxArgs <= 0 means unbounded. Leave the output unchanged on error and set an interpreter diagnostic.

Parameters:
  • interp – [inout] Borrowed result interpreter; see Interpreter arguments.

  • specArr – [in] Persistent NULL-name-terminated table with Rbc_OpSpecHeader as the first field of each entry; Tcl may cache this address.

  • specSize – [in] Byte stride of one complete typed entry, at least sizeof(Rbc_OpSpecHeader).

  • operPos – [in] Nonnegative index of the operation word in the full command array.

  • objc – [in] Number of objects in objv; counts every word when validating operation arity.

  • objv – [in] Borrowed full command array; see Tcl command arguments.

  • indexPtr – [out] Required output receiving the selected table index only on success.

Implementation selectors

enum Rbc_OpIndex

Zero-based position of the operation word in the argument vector supplied to lookup.

Values:

enumerator RBC_OP_ARG0
enumerator RBC_OP_ARG1
enumerator RBC_OP_ARG2
enumerator RBC_OP_ARG3
enumerator RBC_OP_ARG4
enum Rbc_ScrollKind

Distinguishes fractional positioning from signed movement by units or pages.

Values:

enumerator RBC_SCROLL_MOVETO
enumerator RBC_SCROLL_UNITS
enumerator RBC_SCROLL_PAGES