critcl_emap man page on DragonFly

Man page or keyword search:  
man Server   44335 pages
apropos Keyword Search (all sections)
Output format
DragonFly logo
[printable version]

critcl::emap(n)		   C Runtime In Tcl (CriTcl)	       critcl::emap(n)

______________________________________________________________________________

NAME
       critcl::emap - CriTcl Utilities: Enum en- and decoding

SYNOPSIS
       package require Tcl  8.4

       package require critcl  ?3.1.11?

       package require critcl::emap  ?1?

       ::critcl::emap::def name definition ?-nocase?

______________________________________________________________________________

DESCRIPTION
       Welcome	to the C Runtime In Tcl, CriTcl for short, a system to build C
       extension packages for Tcl on the fly, from C code embedded within  Tcl
       scripts, for all who wish to make their code go faster.

       This  document  is  the reference manpage for the critcl::emap package.
       This package provides convenience commands for  advanced	 functionality
       built on top of both critcl core and package critcl::iassoc.

       C  level	 libraries  often use enumerations or integer values to encode
       information, like the state of a system. Tcl bindings to such libraries
       now  have  the  task  of converting a Tcl representation, i.e. a string
       into such state, and back.  Note here that the C-level information  has
       to be something which already exists. The package does not create these
       values. This is in contrast to the package critcl::enum	which  creates
       an enumeration based on the specified symbolic names.

       This package was written to make the declaration and management of such
       enumerations and their associated conversions  functions	 easy,	hiding
       all attendant complexity from the user.

       Its  intended audience are mainly developers wishing to write Tcl pack‐
       ages 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
       ::critcl::emap::def name definition ?-nocase?
	      This command defines two C functions for the conversion  of  the
	      named  state code into a Tcl string, and vice versa.  The under‐
	      lying mapping tables  are	 automatically	initialized  on	 first
	      access, and finalized on interpreter destruction.

	      The  definition  dictionary  provides  the mapping from the Tcl-
	      level symbolic names of the state to their C expressions	(often
	      the  name	 of the macro specifying the actual value).  Note here
	      that the C-level information has to be something	which  already
	      exists.  The  package  does  not create these values. This is in
	      contrast to the package critcl::enum which creates  an  enumera‐
	      tion based on the specified symbolic names.

	      Further  note  that multiple strings can be mapped to the same C
	      expression. When converting to Tcl the first string for the map‐
	      ping  is	returned. An important thing to know: If all C expres‐
	      sions are recognizable as	 integer  numbers  and	their  covered
	      range  is	 not  too large (at most 50) the package will generate
	      code using direct and fast mapping tables	 instead  of  using  a
	      linear search.

	      If  the  option -nocase is specified then the encoder will match
	      strings case-insensitively, and the decoder will always return a
	      lower-case  string, regardless of the string's case in the defi‐
	      nition.

	      The package generates multiple things (declarations and  defini‐
	      tions)  with names derived from name, which has to be a proper C
	      identifier.

	      name_encode
		     The function for encoding a Tcl string into  the  equiva‐
		     lent state code.  Its signature is

		     int name_encode (Tcl_Interp* interp, Tcl_Obj* state, int* result);

	      The  return  value  of  the  function  is a Tcl error code, i.e.
	      TCL_OK, TCL_ERROR, etc.

	      name_decode
		     The function for decoding a state code into  the  equiva‐
		     lent Tcl strings.	Its signature is

		     Tcl_Obj* name_decode (Tcl_Interp* interp, int state);

	      name.h A	header	file  containing  the declarations for the two
		     conversion functions, for use by other parts of the  sys‐
		     tem, if necessary.

		     The generated file is stored in a place where it will not
		     interfere with the overall system outside of the package,
		     yet also be available for easy inclusion by package files
		     (csources).

	      name   The name of a  critcl  argument  type  encapsulating  the
		     encoder function for use by critcl::cproc.

	      name   The  name	of  a  critcl  result  type  encapsulating the
		     decoder function for use by critcl::cproc.

EXAMPLE
       The example shown below is the specification for the possible modes  of
       entry  (normal,	no  feedback,  stars)  used  by the Tcl binding to the
       linenoise library.

	      package require Tcl 8.5
	      package require critcl 3.1.11

	      critcl::buildrequirement {
		  package require critcl::emap
	      }

	      critcl::emap::def hiddenmode {
			  no  0 n 0 off 0 false 0 0 0
		  all	1 yes 1 y 1 on	1 true	1 1 1
		  stars 2
	      } -nocase

	      # Declarations: hiddenmode.h
	      # Encoder:      int      hiddenmode_encode (Tcl_Interp* interp, Tcl_Obj* state, int* result);
	      # Decoder:      Tcl_Obj* hiddenmode_decode (Tcl_Interp* interp, int state);
	      # ResultType:   hiddenmode
	      # ArgumentType: hiddenmode

AUTHORS
       Andreas Kupries

BUGS, IDEAS, FEEDBACK
       This 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 documen‐
       tation.

KEYWORDS
       C code, Embedded C Code, Tcl Interp Association, bitmask, bitset,  code
       generator,  compile  &  run, compiler, dynamic code generation, dynamic
       compilation, flags, generate package, linker,  on  demand  compilation,
       on-the-fly compilation, singleton

CATEGORY
       Glueing/Embedded C code

COPYRIGHT
       Copyright (c) 2011-2015 Andreas Kupries

doc				       1		       critcl::emap(n)
[top]

List of man pages available for DragonFly

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net