gmlTcl_General.h

00001 /*
00002  * gmlTcl_General.h --
00003  *
00004  *  Declarations of general utility functions for gml-tcl binding.
00005  *
00006  *  Copyright (c) 2004 CLIPS-IMAG
00007  *
00008  *  See the file "gml_LicenseTerms.txt" for information on usage and redistribution
00009  *  of this file, and for a DISCLAIMER OF ALL WARRANTIES.
00010  *
00011  *  Created on January 22, 2004 (FB).
00012  */
00013 
00014 #ifndef __GMLTCL_GENERAL__
00015 #define __GMLTCL_GENERAL__
00016   #if defined(__cplusplus)
00017     extern "C" {
00018   #endif
00019 
00020 #include "tcl.h"
00021 #include "gml/base/gml_Types.h"
00022 
00023 /**
00024  * GMLTCL_CHECK_ERR --
00025  *
00026  *   Check the <err> variable; if an error is detected, report it to
00027  *   <interp> and exit the calling procedure.
00028  */
00029 #define GMLTCL_CHECK_ERR                                
00030   do {                                                  
00031     if (err != gml_cNoError) {                          
00032       Tcl_AppendResult (interp,                         
00033         gml_ErrorGetMessage (err), (char*)NULL);        
00034       return TCL_ERROR;                                 
00035     }                                                   
00036   } while (0)
00037 
00038 #define GMLTCL_CHECK_ERR_MSG(msg)                       
00039   do {                                                  
00040     if (err != gml_cNoError) {                          
00041       Tcl_AppendResult (interp,                         
00042         msg, ": ",                                      
00043         gml_ErrorGetMessage (err), (char*)NULL);        
00044       return TCL_ERROR;                                 
00045     }                                                   
00046   } while (0)
00047 
00048 /**
00049  * gmlTcl_ObjectIsEmpty --
00050  *
00051  *  Copied from the generic Tk code (generic/tkConfig.c).
00052  *
00053  *        This procedure tests whether the string value of an object is
00054  *        empty.
00055  *
00056  * Results:
00057  *        The return value is 1 if the string value of objPtr has length
00058  *        zero, and 0 otherwise.
00059  *
00060  * Side effects:
00061  *  May cause object shimmering, since this function can force a
00062  *  conversion to a string object.
00063  */
00064 int gmlTcl_ObjectIsEmpty (Tcl_Interp* interp, Tcl_Obj* objPtr);
00065 
00066 
00067 /**
00068  * gmlTcl_TInterpState --
00069  *
00070  * Hold data representing the state of a Tcl interpreter.
00071  */
00072 typedef struct {
00073   Tcl_SavedResult     savedResult;
00074   Tcl_Obj*            errorInfoVarName;
00075   Tcl_Obj*            errorInfoObj;
00076   Tcl_Obj*            errorCodeVarName;
00077   Tcl_Obj*            errorCodeObj;
00078 
00079 } gmlTcl_TInterpState;
00080 
00081 
00082 /**
00083  * gmlTcl_SaveInterpState --
00084  *
00085  * Save in <state> the current state of <interp>.
00086  */
00087 void gmlTcl_SaveInterpState    (Tcl_Interp* interp, gmlTcl_TInterpState* state);
00088 
00089 
00090 /**
00091  * gmlTcl_RestoreInterpState --
00092  *
00093  * Restore to <interp> the state saved in <state>.
00094  */
00095 void gmlTcl_RestoreInterpState (Tcl_Interp* interp, gmlTcl_TInterpState* state);
00096 
00097 
00098 
00099 /*
00100  * gmlTcl_Uid --
00101  * gmlTcl_GetUid --
00102  *
00103  *  Unique identifiers for strings. See Tk's "Tk_GetUid" man page.
00104  *  This has been renamed "gmlTcl_" only to remove dependency to Tk 
00105  *  (ie. to be able to use strings unique identifiers without linking with Tk).
00106  */
00107 typedef char*   gmlTcl_Uid;
00108 gmlTcl_Uid      gmlTcl_GetUid (char* str);
00109 
00110 
00111 
00112 /**
00113  * gmlTclWrapFindIndexFromString --
00114  *
00115  *  Find the index of an entry in an array that has a givrn (string) key in its first field.
00116  *  The end of the array must be represented with an empty string ('\0' character) in the 
00117  *    first field.
00118  *
00119  *  Returns the index of the matching entry or -1 if the string was not found.
00120  */
00121 int gmlTclWrapFindIndexFromString (char* array, gml_TBlockSize entrySize, char* key);
00122 
00123 
00124 
00125 /**
00126  * gmlTclWrapFindEntryFromString --
00127  *
00128  *  Find the entry in an array that has a given (string) key in its first field.
00129  *  The end of the array must be represented with an empty string ('\0' character) in the 
00130  *    first field.
00131  *
00132  *  Returns the address of the entry, or NULL if there is no such entry.
00133  */
00134 char* gmlTclWrapFindEntryFromString (char* array, gml_TBlockSize entrySize, char* key);
00135 
00136 
00137 
00138 
00139   #if defined(__cplusplus)
00140     }
00141   #endif
00142 #endif
Generated on Tue Jun 12 14:03:27 2007 for gml by Doxygen 1.5.2.