|
NAMEcritcl::cutil - CriTcl C-level UtilitiesSYNOPSISpackage require Tcl 8.4package require critcl ?2.1? package require critcl::cutil ?0.2? ::critcl::cutil::alloc ::critcl::cutil::assertions ?enable? ::critcl::cutil::tracer ?enable? type* ALLOC (type) type* ALLOC_PLUS (type, int n) type* NALLOC (type, int n) type* REALLOC (type* var, type, int n) void FREE (type* var) void STREP (Tcl_Obj* o, char* s, int len) void STREP_DS (Tcl_Obj* o, Tcl_DString* ds) void STRDUP (varname, char* str) void ASSERT (expression, char* message void ASSERT_BOUNDS (int index, int size) void STOPAFTER(n) TRACE_ON TRACE_OFF TRACE_TAG_ON (identifier) TRACE_TAG_OFF (identifier) void TRACE_FUNC void TRACE_TAG_FUNC (tag) void TRACE_FUNC_VOID void TRACE_TAG_FUNC_VOID (tag) void TRACE_RETURN_VOID void TRACE_TAG_RETURN_VOID (tag) any TRACE_RETURN ( char* format, any x) any TRACE_TAG_RETURN (tag, char* format, any x) void TRACE ( char* format, ...) void TRACE_TAG (tag, char* format, ...) void TRACE_HEADER (int indent) void TRACE_TAG_HEADER (tag, int indent) void TRACE_CLOSER void TRACE_TAG_CLOSER (tag) void TRACE_ADD (const char* format, ...) void TRACE_TAG_ADD (tag, const char* format, ...) void TRACE_PUSH_SCOPE (const char* name) void TRACE_PUSH_FUNC void TRACE_PUSH_POP TRACE_TAG_VAR (tag) TRACE_RUN (code); TRACE_DO (code); TRACE_TAG_DO (tag, code); DESCRIPTIONC Runtime In Tcl, or CriTcl , is a system for compiling C code embedded in Tcl on the fly and either loading the resulting objects into Tcl for immediate use or packaging them for distribution. Use CriTcl to improve performance by rewriting in C those routines that are performance bottlenecks.This document is the reference manpage for the critcl::cutil package. This package encapsulates a number of C-level utilites for easier writing of memory allocations, assertions, and narrative tracing and provides convenience commands to make these utilities accessible to critcl projects. Its intended audience are mainly developers wishing to write Tcl packages with embedded C code. This package resides in the Core Package Layer of CriTcl. +----------------+ |Applications | | critcl | | critcl::app | +----------------+ *================* |Core Packages | | critcl | | critcl::util | *================* +----------------+ |Support Packages| | stubs::* | | md5, platform | | ... | +----------------+ The reason for this is that the main critcl package makes use of the facilities for narrative tracing when critcl::config trace is set, to instrument commands and procedures. API
type* ALLOC (type) type* ALLOC_PLUS (type, int n) type* NALLOC (type, int n) type* REALLOC (type* var, type, int n) void FREE (type* var) void STREP (Tcl_Obj* o, char* s, int len); void STREP_DS (Tcl_Obj* o, Tcl_DString* ds); void STRDUP (varname, char* str); The details of the semantics are explained in section Allocation. The result of the command is an empty string.
void ASSERT (expression, char* message); void ASSERT_BOUNDS (int index, int size); void STOPAFTER (int n); Note that these definitions are conditional on the existence of the macro CRITCL_ASSERT. Without a critcl::cflags -DCRITCL_ASSERT all assertions in the C code are quiescent and not compiled into the object file. In other words, assertions can be (de)activated at will during build time, as needed by the user. For convenience this is controlled by enable. By default (false) the facility available, but not active. Using true not only makes it available, but activates it as well. The details of the semantics are explained in section Assertions. The result of the command is an empty string.
/* (de)activation of named logical streams. * These are declarators, not statements. */ TRACE_ON; TRACE_OFF; TRACE_TAG_ON (tag_identifier); TRACE_TAG_OFF (tag_identifier); /* * Higher level trace statements (convenience commands) */ void TRACE_FUNC (const char* format, ...); void TRACE_FUNC_VOID; any TRACE_RETURN (const char* format, any x); void TRACE_RETURN_VOID; void TRACE (const char* format, ...); /* * Low-level trace statements the higher level ones above * are composed from. Scope management and output management. */ void TRACE_PUSH_SCOPE (const char* scope); void TRACE_PUSH_FUNC; void TRACE_POP; void TRACE_HEADER (int indent); void TRACE_ADD (const char* format, ...); void TRACE_CLOSER; /* * Convert tag to the underlying status variable. */ TRACE_TAG_VAR (tag) /* * Conditional use of arbitrary code. */ TRACE_RUN (code); TRACE_DO (code); TRACE_TAG_DO (code); Note that these definitions are conditional on the existence of the macro CRITCL_TRACER. Without a critcl::cflags -DCRITCL_TRACER all trace functionality in the C code is quiescent and not compiled into the object file. In other words, tracing can be (de)activated at will during build time, as needed by the user. For convenience this is controlled by enable. By default (false) the facility available, but not active. Using true not only makes it available, but activates it as well. Further note that the command critcl::config now accepts a boolean option trace. Setting it activates enter/exit tracing in all commands based on critcl::cproc, with proper printing of arguments and results. This implicitly activates the tracing facility in general. The details of the semantics are explained in section Tracing The result of the command is an empty string. ALLOCATION
ASSERTIONS
TRACINGAll output is printed to stdout.
TRACE_TAG_ON (lexer_in); All high- and low-level trace commands producing output have the controlling tag as an implicit argument. The scope management commands do not take tags.
return
return x
AUTHORSAndreas KupriesBUGS, IDEAS, FEEDBACKThis document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such at https://github.com/andreas-kupries/critcl. Please also report any ideas for enhancements you may have for either package and/or documentation.KEYWORDSC code, Embedded C Code, code generator, compile & run, compiler, dynamic code generation, dynamic compilation, generate package, linker, on demand compilation, on-the-fly compilationCATEGORYGlueing/Embedded C codeCOPYRIGHTCopyright (c) 2011-2018 Andreas Kupries
Visit the GSP FreeBSD Man Page Interface. |