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_int(Tcl_Interp *ip, Tcl_Obj *obj, int *val) {
14 return Tcl_GetIntFromObj(ip, obj, val);
17 int pat_long(Tcl_Interp *ip, Tcl_Obj *obj, long *val) {
18 return Tcl_GetLongFromObj(ip, obj, val);
21 int pat_string(Tcl_Interp *ip, Tcl_Obj *obj, const char **val) {
22 *val= Tcl_GetString(obj);
26 int pat_hbv(Tcl_Interp *ip, Tcl_Obj *var, HBytes_Var *agg) {
32 val= Tcl_ObjGetVar2(ip,var,0,TCL_LEAVE_ERR_MSG);
33 if (!val) return TCL_ERROR;
35 rc= Tcl_ConvertToType(ip,val,&hbytes_type);
38 if (Tcl_IsShared(val)) {
39 val= Tcl_DuplicateObj(val);
42 Tcl_InvalidateStringRep(val);
45 agg->hb= OBJ_HBYTES(val);
49 void fini_hbv(Tcl_Interp *ip, int rc, HBytes_Var *agg) {
54 ro= Tcl_ObjSetVar2(ip,agg->var,0,agg->obj,TCL_LEAVE_ERR_MSG);
55 if (!ro) rc= TCL_ERROR;
57 if (rc && agg->copied)
58 Tcl_DecrRefCount(agg->obj);
61 int pat_hb(Tcl_Interp *ip, Tcl_Obj *obj, HBytes_Value *val) {
63 rc= Tcl_ConvertToType(ip,obj,&hbytes_type); if (rc) return rc;
64 *val= *OBJ_HBYTES(obj);
68 Tcl_Obj *ret_hb(Tcl_Interp *ip, HBytes_Value val) {
71 Tcl_InvalidateStringRep(obj);
72 *OBJ_HBYTES(obj)= val;
73 obj->typePtr= &hbytes_type;
77 Tcl_Obj *ret_long(Tcl_Interp *ip, long val) {
78 return Tcl_NewLongObj(val);
81 Tcl_Obj *ret_string(Tcl_Interp *ip, const char *val) {
82 return Tcl_NewStringObj(val,-1);