6 int pat_charfrom(Tcl_Interp *ip, Tcl_Obj *obj, int *val,
7 const char *opts, const char *what) {
8 *val= enum1_lookup_cached_func(ip,obj,opts,what);
9 if (*val==-1) return TCL_ERROR;
13 int pat_enum(Tcl_Interp *ip, Tcl_Obj *obj, const void **val,
14 const void *opts, size_t sz, const char *what) {
15 *val= enum_lookup_cached_func(ip,obj,opts,sz,what);
16 if (!*val) return TCL_ERROR;
20 int pat_obj(Tcl_Interp *ip, Tcl_Obj *obj, Tcl_Obj **val) {
25 int pat_int(Tcl_Interp *ip, Tcl_Obj *obj, int *val) {
26 return Tcl_GetIntFromObj(ip, obj, val);
29 int pat_hbv(Tcl_Interp *ip, Tcl_Obj *var, HBytes_Var *agg) {
33 Tcl_IncrRefCount(var);
36 val= Tcl_ObjGetVar2(ip,var,0,TCL_LEAVE_ERR_MSG);
37 if (!val) return TCL_ERROR;
38 if (Tcl_IsShared(val)) val= Tcl_DuplicateObj(val);
39 Tcl_IncrRefCount(val);
42 rc= Tcl_ConvertToType(ip,val,&hbytes_type);
45 agg->hb= OBJ_HBYTES(val); return TCL_OK; }
47 void fini_hbv(Tcl_Interp *ip, int rc, HBytes_Var *agg) {
50 if (agg->obj) Tcl_InvalidateStringRep(agg->obj);
53 ro= Tcl_ObjSetVar2(ip,agg->var,0,agg->obj,TCL_LEAVE_ERR_MSG);
54 if (!ro) rc= TCL_ERROR;
56 if (agg->obj) Tcl_DecrRefCount(agg->obj);
57 if (agg->var) Tcl_DecrRefCount(agg->var);
60 int pat_hb(Tcl_Interp *ip, Tcl_Obj *obj, HBytes_Value *val) {
62 rc= Tcl_ConvertToType(ip,obj,&hbytes_type); if (rc) return rc;
63 *val= *OBJ_HBYTES(obj);
67 Tcl_Obj *ret_hb(Tcl_Interp *ip, HBytes_Value val) {
70 Tcl_InvalidateStringRep(obj);
71 *OBJ_HBYTES(obj)= val;
72 obj->typePtr= &hbytes_type;
76 Tcl_Obj *ret_int(Tcl_Interp *ip, int val) {
77 return Tcl_NewIntObj(val);
80 Tcl_Obj *ret_obj(Tcl_Interp *ip, Tcl_Obj *val) {
84 void setstringresult(Tcl_Interp *ip, const char *m) {
86 Tcl_AppendResult(ip, m, (char*)0);