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_hbv(Tcl_Interp *ip, Tcl_Obj *var, HBytes_Var *agg) {
29 Tcl_IncrRefCount(var);
32 val= Tcl_ObjGetVar2(ip,var,0,TCL_LEAVE_ERR_MSG);
33 if (!val) return TCL_ERROR;
34 if (Tcl_IsShared(val)) val= Tcl_DuplicateObj(val);
35 Tcl_IncrRefCount(val);
38 rc= Tcl_ConvertToType(ip,val,&hbytes_type);
41 agg->hb= &HBYTES(val);
45 void fini_hbv(Tcl_Interp *ip, int rc, HBytes_Var *agg) {
50 ro= Tcl_ObjSetVar2(ip,agg->var,0,agg->obj,TCL_LEAVE_ERR_MSG);
51 if (!ro) rc= TCL_ERROR;
53 if (agg->obj) Tcl_DecrRefCount(agg->obj);
54 if (agg->var) Tcl_DecrRefCount(agg->var);
57 int pat_hb(Tcl_Interp *ip, Tcl_Obj *obj, HBytes_Value *val) {
59 rc= Tcl_ConvertToType(ip,obj,&hbytes_type); if (rc) return rc;
64 Tcl_Obj *ret_hb(Tcl_Interp *ip, HBytes_Value val) {
65 return hbytes_set_obj(0, val.start, HBYTES_LEN(val));