Package initialization C reference
These are installed interfaces. The two stubs helpers are linked into consumers, not invoked through a table slot. See Package loading and stubs for loading order.
-
int Rbc_Init(Tcl_Interp *interp)
Initialize the Tcl-only vector package in an interpreter.
Initializes Tcl stubs, creates interpreter-associated readiness state and the rbc namespace, and registers vector commands plus the private _initTk command. Provides rbc::vector with the shared RBC stubs table. Does not load Tk or source the Tcl support scripts; the package index performs those later steps. Completed initialization phases survive errors. Readiness flags prevent repeating completed phases, but do not repair commands deleted by callers.
- Parameters:
interp – Interpreter receiving the commands and package registration. See Interpreter arguments.
- Returns:
TCL_OK on success; TCL_ERROR with an interpreter diagnostic on failure.
-
const char *Rbc_InitStubs(Tcl_Interp *interp, const char *version, int exact)
Require the full RBC package and initialize the client’s stubs pointer.
Linked statically into the consumer from the RBC stub library. On success, replaces that consumer’s rbcStubsPtr with package client data. On failure, leaves its previous value unchanged. Requires Tk through the full package loader. Does not retain an interpreter or vector, validate table entries, or provide synchronization for changing the pointer.
- Parameters:
interp – Interpreter in which to require rbc; loading may execute Tcl. See Interpreter arguments.
version – Required version, interpreted by Tcl_PkgRequireEx.
exact – Nonzero requests an exact version match.
- Returns:
Borrowed actual package version on success; NULL if requiring the package fails or its client data is NULL. The latter adds no diagnostic.
-
const char *Rbc_VectorInitStubs(Tcl_Interp *interp, const char *version, int exact)
Require the Tcl-only vector package and initialize the client’s stubs pointer.
Has the same pointer ownership and failure behavior as Rbc_InitStubs, but does not require Tk. Both packages publish the same RBC stubs table. The caller must request a version supporting every table slot it will use.
- Parameters:
interp – Interpreter in which to require rbc::vector; loading may execute Tcl. See Interpreter arguments.
version – Required version, interpreted by Tcl_PkgRequireEx.
exact – Nonzero requests an exact version match.
- Returns:
Borrowed actual package version on success; NULL if requiring the package fails or its client data is NULL. The latter adds no diagnostic.
Private registration helpers
These records and callbacks belong to the loader implementation, not the installed C API. The consumer-side stubs object is documented alongside them because it receives the table published by package initialization.
- group Package initialization helpers
Private loader callbacks and readiness bookkeeping, not installed interfaces.
Functions
-
static void FreeInitData(ClientData clientData, Tcl_Interp *interp)
Release the interpreter initialization bookkeeping.
clientData is the allocated RbcInitData owned by Tcl associated data. Free only that record. Subsystem registries, commands, widgets and vectors have separate deletion paths. interp is unused; no Tcl evaluation occurs.
- Parameters:
clientData – [in] Owned RbcInitData record being released.
interp – [in] Unused here; see Interpreter arguments.
-
static int InitTkObjCmd(ClientData clientData, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
Complete the Tk-dependent phases after Tcl-only initialization.
Require the rbc::init associated record and namespace established by Rbc_Init. Accept no arguments beyond the command name; initialize Tk stubs, then run graph, winop, spline and EPS registration in order. Completed phase flags survive later errors, so retries skip completed work. Re-export constructor names on every successful traversal and provide the full package with the shared stubs table. Do not source support scripts or create widgets here. Return the first Tcl error or package-provision status. The EPS initializer has no status return. This is a private loader command, not a reinitialization or command-repair API.
- Parameters:
clientData – [in] Unused registration data.
interp – [in] See Interpreter arguments.
objc – [in] See Tcl command arguments; must equal one.
objv – [in] See Tcl command arguments.
- Returns:
Tcl status from registration, export or package provision.
-
static const char *InitPackageStubs(Tcl_Interp *interp, const char *package, const char *version, int exact)
Require a package and select its published C dispatch table.
Borrow interp, package and version; pass exact unchanged to Tcl_PkgRequireEx. Package loading may execute Tcl. If require fails or returns NULL client data, return NULL without changing rbcStubsPtr; missing client data adds no diagnostic. Otherwise assign the borrowed table and return the borrowed actual version. No table-magic/slot checks, copying, interpreter retention or locking occur. Both public stubs initializers share this path; the package name chooses whether Tk and full support scripts are required.
- Parameters:
interp – [in] See Interpreter arguments; package loading may execute Tcl.
package – [in] Borrowed package name: rbc or rbc::vector.
version – [in] Borrowed version requirement passed to Tcl.
exact – [in] Nonzero requests an exact version match.
- Returns:
Borrowed actual version on success, or NULL on failure.
Variables
-
const RbcStubs *rbcStubsPtr
Borrowed dispatch table selected by the consumer-linked stub object.
Initially NULL. Successful initialization replaces it; failed initialization leaves it unchanged. This is not interpreter-associated storage or an owned allocation, and no lifetime reference or synchronization is supplied here.
-
struct RbcInitData
Interpreter-owned record of completed registration phases.
Stored as rbc::init associated data and freed by FreeInitData. Flags are set only after a phase succeeds and are retained if a later phase fails. They neither own subsystem objects nor detect commands deleted by callers.
Public Members
-
int vectorReady
Vector commands and private Tk initializer registered.
-
int graphReady
Graph constructors registered; no widget is created.
-
int winopReady
Window/photo command registration completed.
-
int splineReady
Spline command registration completed.
-
int epsReady
EPS canvas item registration invoked.
-
int vectorReady
-
static void FreeInitData(ClientData clientData, Tcl_Interp *interp)
Windows loader wrappers
These entry points do not initialize Tcl packages. Their platform-selected contracts come from the separate Windows Doxygen input.
- group Windows DLL entry wrappers
Loader entry wrappers; Tcl package initialization is a separate phase.
Functions
-
BOOL DllMain(HINSTANCE hInst, DWORD reason, LPVOID reserved)
Accept Windows DLL loader notifications without package initialization.
Return TRUE for every reason. The instance handle, reason and reserved pointer are unused. No allocation, Tcl/Tk initialization or cleanup runs under this loader callback; Rbc_Init performs package initialization later.
- Parameters:
hInst – [in] Borrowed module instance handle supplied by the loader; unused.
reason – [in] Loader notification reason; all reasons are accepted.
reserved – [in] Loader-supplied reserved pointer; may be NULL and is never dereferenced or retained.
- Returns:
TRUE; package initialization is deferred to Rbc_Init.
-
BOOL DllEntryPoint(HINSTANCE hInst, DWORD reason, LPVOID reserved)
Forward the alternate Windows entry point to DllMain.
Pass all loader arguments through and return DllMain’s BOOL result. This wrapper introduces no additional registration or ownership.
- Parameters:
hInst – [in] Borrowed module instance handle supplied by the loader; unused.
reason – [in] Loader notification reason; all reasons are accepted.
reserved – [in] Loader-supplied reserved pointer; may be NULL and is never dereferenced or retained.
- Returns:
TRUE; package initialization is deferred to Rbc_Init.
-
BOOL DllMain(HINSTANCE hInst, DWORD reason, LPVOID reserved)