*
*/
+#include <string.h>
+
#include "hbytes.h"
static void enum_nt_dup(Tcl_Obj *src, Tcl_Obj *dup) {
0, enum_nt_dup, enum_nt_ustr, enum_nt_sfa
};
+Tcl_ObjType enum1_nearlytype = {
+ "enum1-nearly",
+ 0, enum_nt_dup, enum_nt_ustr, enum_nt_sfa
+};
+
const void *enum_lookup_cached_func(Tcl_Interp *ip, Tcl_Obj *o,
- size_t entrysize, const void *firstentry,
+ const void *firstentry, size_t entrysize,
const char *what) {
const char *supplied, *found;
const char *ep;
Tcl_AppendResult(ip, " ",found,(char*)0);
return 0;
}
+
+int enum1_lookup_cached_func(Tcl_Interp *ip, Tcl_Obj *o,
+ const char *opts, const char *what) {
+ const char *supplied, *fp;
+
+ if (o->typePtr != &enum1_nearlytype ||
+ o->internalRep.twoPtrValue.ptr1 != opts) {
+
+ supplied= Tcl_GetStringFromObj(o,0); assert(supplied);
+
+ if (!(strlen(supplied) == 1 &&
+ (fp= strchr(opts, supplied[0])))) {
+ Tcl_ResetResult(ip);
+ Tcl_AppendResult(ip, "invalid ",what,
+ " - must be one character from: ", opts);
+ return -1;
+ }
+
+ objfreeir(o);
+ o->typePtr= &enum1_nearlytype;
+ o->internalRep.twoPtrValue.ptr1= (void*)opts;
+ o->internalRep.twoPtrValue.ptr2= (void*)fp;
+ }
+ return (const char*)o->internalRep.twoPtrValue.ptr2 - opts;
+}