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_string(Tcl_Interp *ip, Tcl_Obj *obj, const char **val) {
34 *val= Tcl_GetString(obj);
38 int pat_hbv(Tcl_Interp *ip, Tcl_Obj *var, HBytes_Var *agg) {
44 val= Tcl_ObjGetVar2(ip,var,0,TCL_LEAVE_ERR_MSG);
45 if (!val) return TCL_ERROR;
47 rc= Tcl_ConvertToType(ip,val,&hbytes_type);
50 if (Tcl_IsShared(val)) {
51 val= Tcl_DuplicateObj(val);
54 Tcl_InvalidateStringRep(val);
57 agg->hb= OBJ_HBYTES(val);
61 void fini_hbv(Tcl_Interp *ip, int rc, HBytes_Var *agg) {
66 ro= Tcl_ObjSetVar2(ip,agg->var,0,agg->obj,TCL_LEAVE_ERR_MSG);
67 if (!ro) rc= TCL_ERROR;
69 if (rc && agg->copied)
70 Tcl_DecrRefCount(agg->obj);
73 int pat_hb(Tcl_Interp *ip, Tcl_Obj *obj, HBytes_Value *val) {
75 rc= Tcl_ConvertToType(ip,obj,&hbytes_type); if (rc) return rc;
76 *val= *OBJ_HBYTES(obj);
80 Tcl_Obj *ret_hb(Tcl_Interp *ip, HBytes_Value val) {
83 Tcl_InvalidateStringRep(obj);
84 *OBJ_HBYTES(obj)= val;
85 obj->typePtr= &hbytes_type;
89 Tcl_Obj *ret_int(Tcl_Interp *ip, int val) {
90 return Tcl_NewIntObj(val);
93 Tcl_Obj *ret_long(Tcl_Interp *ip, long val) {
94 return Tcl_NewLongObj(val);
97 Tcl_Obj *ret_string(Tcl_Interp *ip, const char *val) {
98 return Tcl_NewStringObj(val,-1);
101 Tcl_Obj *ret_obj(Tcl_Interp *ip, Tcl_Obj *val) {
105 void setstringresult(Tcl_Interp *ip, const char *m) {
107 Tcl_AppendResult(ip, m, (char*)0);