|
NAMEcritcl::enum - CriTcl Utilities: String/Integer mappingSYNOPSISpackage require Tcl 8.4package require critcl ?3.1.11? package require critcl::enum ?1.1? ::critcl::enum::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::enum package. This package provides convenience commands for advanced functionality built on top of both critcl core and package critcl::literals. It is an extended form of string pool which not only converts integer values into Tcl-level strings, but also handles the reverse direction, converting from strings to the associated integer values. It essentially provides a bi-directional mapping between a C enumeration type and a set of strings, one per enumeration value. Note that the C enumeration in question is created by the definition. It is not possible to use the symbols of an existing enumeration type. This package was written to make the declaration and management of such mappings easy. It uses a string pool for one of the directions, using its ability to return shared literals and conserve memory. 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_ToObj (Tcl_Interp* interp, name_names literal);
Tcl_Obj* name_ToObjList (Tcl_Interp* interp, int c, name_names* literal);
int name_GetFromObj (Tcl_Interp* interp, Tcl_Obj* obj, int flags, int* literal);
EXAMPLEThe example shown below is the specification for a set of actions, methods, and the like, a function may take as argument.package require Tcl 8.5 package require critcl 3.1.11 critcl::buildrequirement { package require critcl::enum } critcl::enum::def action { w_create "create" w_directory "directory" w_events "events" w_file "file" w_handler "handler" w_remove "remove" } # Declarations: action.h # Type: action_names # Accessor: Tcl_Obj* action_ToObj (Tcl_Interp* interp, int literal); # Accessor: int action_GetFromObj (Tcl_Interp* interp, Tcl_Obj* o, int flags, int* literal); # ResultType: action # ArgType: action 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, conversion, dynamic code generation, dynamic compilation, generate package, int to string mapping, linker, literal pool, on demand compilation, on-the-fly compilation, singleton, string pool, string to int mappingCATEGORYGlueing/Embedded C codeCOPYRIGHTCopyright (c) 2011-2018 Andreas Kupries
Visit the GSP FreeBSD Man Page Interface. |