|
NAMEcritcl::literals - CriTcl Utilities: Constant string poolsSYNOPSISpackage require Tcl 8.4package require critcl ?3.1.11? package require critcl::literals ?1.3? ::critcl::literals::def name definition ?mode? 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::literals package. This package provides convenience commands for advanced functionality built on top of both critcl core and package critcl::iassoc. Many packages will have a fixed set of string constants occuring in one or places. Most of them will be coded to create a new string Tcl_Obj* from a C char* every time the constant is needed, as this is easy to to, despite the inherent waste of memory. This package was written to make declaration and management of string pools which do not waste memory as easy as the wasteful solution, hiding all attendant complexity from the user. 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 | | ... | +----------------+ API
Tcl_Obj* name (Tcl_Interp* interp, name_names literal);
Tcl_Obj* name_list (Tcl_Interp* interp, int c, name_names* literal);
const char* name_cstr (name_names literal);
EXAMPLEThe example shown below is the specification of the string pool pulled from the draft work on a Tcl binding to Linux's inotify APIs.package require Tcl 8.5 package require critcl 3.1.11 critcl::buildrequirement { package require critcl::literals } critcl::literals::def tcl_inotify_strings { w_create "create" w_directory "directory" w_events "events" w_file "file" w_handler "handler" w_remove "remove" } {c tcl} # Declarations: tcl_inotify_strings.h # Type: tcl_inotify_strings_names # Accessor: Tcl_Obj* tcl_inotify_strings (Tcl_Interp* interp, # tcl_inotify_strings_names literal); # Accessor: const char* tcl_inotify_strings_cstr (tcl_inotify_strings_names literal); # ResultType: tcl_inotify_strings 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, Tcl Interp Association, code generator, compile & run, compiler, dynamic code generation, dynamic compilation, generate package, linker, literal pool, on demand compilation, on-the-fly compilation, singleton, string poolCATEGORYGlueing/Embedded C codeCOPYRIGHTCopyright (c) 2011-2018 Andreas Kupries
Visit the GSP FreeBSD Man Page Interface. |