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_long(Tcl_Interp *ip, Tcl_Obj *obj, long *val) {
30 return Tcl_GetLongFromObj(ip, obj, val);
33 int pat_hbv(Tcl_Interp *ip, Tcl_Obj *var, HBytes_Var *agg) {
39 val= Tcl_ObjGetVar2(ip,var,0,TCL_LEAVE_ERR_MSG);
40 if (!val) return TCL_ERROR;
42 rc= Tcl_ConvertToType(ip,val,&hbytes_type);
45 if (Tcl_IsShared(val)) {
46 val= Tcl_DuplicateObj(val);
49 Tcl_InvalidateStringRep(val);
52 agg->hb= OBJ_HBYTES(val);
56 void fini_hbv(Tcl_Interp *ip, int rc, HBytes_Var *agg) {
61 ro= Tcl_ObjSetVar2(ip,agg->var,0,agg->obj,TCL_LEAVE_ERR_MSG);
62 if (!ro) rc= TCL_ERROR;
64 if (rc && agg->copied)
65 Tcl_DecrRefCount(agg->obj);
68 int pat_hb(Tcl_Interp *ip, Tcl_Obj *obj, HBytes_Value *val) {
70 rc= Tcl_ConvertToType(ip,obj,&hbytes_type); if (rc) return rc;
71 *val= *OBJ_HBYTES(obj);
75 Tcl_Obj *ret_hb(Tcl_Interp *ip, HBytes_Value val) {
78 Tcl_InvalidateStringRep(obj);
79 *OBJ_HBYTES(obj)= val;
80 obj->typePtr= &hbytes_type;
84 Tcl_Obj *ret_int(Tcl_Interp *ip, int val) {
85 return Tcl_NewIntObj(val);
88 Tcl_Obj *ret_long(Tcl_Interp *ip, long val) {
89 return Tcl_NewLongObj(val);
92 Tcl_Obj *ret_obj(Tcl_Interp *ip, Tcl_Obj *val) {
96 void setstringresult(Tcl_Interp *ip, const char *m) {
98 Tcl_AppendResult(ip, m, (char*)0);