9 static void enum_nt_dup(Tcl_Obj *src, Tcl_Obj *dup) {
10 dup->internalRep= src->internalRep;
13 static void enum_nt_ustr(Tcl_Obj *o) {
17 static int enum_nt_sfa(Tcl_Interp *ip, Tcl_Obj *o) {
21 Tcl_ObjType enum_nearlytype = {
23 0, enum_nt_dup, enum_nt_ustr, enum_nt_sfa
26 Tcl_ObjType enum1_nearlytype = {
28 0, enum_nt_dup, enum_nt_ustr, enum_nt_sfa
31 const void *enum_lookup_cached_func(Tcl_Interp *ip, Tcl_Obj *o,
32 const void *firstentry, size_t entrysize,
34 const char *supplied, *found;
37 if (o->typePtr == &enum_nearlytype &&
38 o->internalRep.twoPtrValue.ptr1 == firstentry)
39 return o->internalRep.twoPtrValue.ptr2;
41 supplied= Tcl_GetStringFromObj(o,0); assert(supplied);
43 (found= *(const char*const*)ep) && strcmp(supplied,found);
48 o->typePtr= &enum_nearlytype;
49 o->internalRep.twoPtrValue.ptr1= (void*)firstentry;
50 o->internalRep.twoPtrValue.ptr2= (void*)ep;
55 Tcl_AppendResult(ip, "invalid ",what," - must be one of:",(char*)0);
57 (found= *(const char*const*)ep);
59 Tcl_AppendResult(ip, " ",found,(char*)0);
63 int enum1_lookup_cached_func(Tcl_Interp *ip, Tcl_Obj *o,
64 const char *opts, const char *what) {
65 const char *supplied, *fp;
67 if (o->typePtr != &enum1_nearlytype ||
68 o->internalRep.twoPtrValue.ptr1 != opts) {
70 supplied= Tcl_GetStringFromObj(o,0); assert(supplied);
72 if (!(strlen(supplied) == 1 &&
73 (fp= strchr(opts, supplied[0])))) {
75 Tcl_AppendResult(ip, "invalid ",what,
76 " - must be one character from: ", opts);
81 o->typePtr= &enum1_nearlytype;
82 o->internalRep.twoPtrValue.ptr1= (void*)opts;
83 o->internalRep.twoPtrValue.ptr2= (void*)fp;
85 return (const char*)o->internalRep.twoPtrValue.ptr2 - opts;