chiark / gitweb /
Socket address stuff. Sockid is broken still.
[chiark-tcl.git] / hbytes / parse.c
index 14d8f9906b59334ab8343e59c54d98e3d1e153cf..b81511cc827e0c45d1cb53bfe318c74cb1a34cfe 100644 (file)
@@ -22,6 +22,10 @@ int pat_obj(Tcl_Interp *ip, Tcl_Obj *obj, Tcl_Obj **val) {
   return TCL_OK;
 }
 
   return TCL_OK;
 }
 
+int pat_int(Tcl_Interp *ip, Tcl_Obj *obj, int *val) {
+  return Tcl_GetIntFromObj(ip, obj, val);
+}
+  
 int pat_hbv(Tcl_Interp *ip, Tcl_Obj *var, HBytes_Var *agg) {
   int rc;
   Tcl_Obj *val;
 int pat_hbv(Tcl_Interp *ip, Tcl_Obj *var, HBytes_Var *agg) {
   int rc;
   Tcl_Obj *val;
@@ -38,13 +42,12 @@ int pat_hbv(Tcl_Interp *ip, Tcl_Obj *var, HBytes_Var *agg) {
   rc= Tcl_ConvertToType(ip,val,&hbytes_type);
   if (rc) return rc;
 
   rc= Tcl_ConvertToType(ip,val,&hbytes_type);
   if (rc) return rc;
 
-  agg->hb= &HBYTES(val);
-  return TCL_OK;
-}
+  agg->hb= OBJ_HBYTES(val); return TCL_OK; }
 
 void fini_hbv(Tcl_Interp *ip, int rc, HBytes_Var *agg) {
   Tcl_Obj *ro;
   
 
 void fini_hbv(Tcl_Interp *ip, int rc, HBytes_Var *agg) {
   Tcl_Obj *ro;
   
+  if (agg->obj) Tcl_InvalidateStringRep(agg->obj);
   if (!rc) {
     assert(agg->obj);
     ro= Tcl_ObjSetVar2(ip,agg->var,0,agg->obj,TCL_LEAVE_ERR_MSG);
   if (!rc) {
     assert(agg->obj);
     ro= Tcl_ObjSetVar2(ip,agg->var,0,agg->obj,TCL_LEAVE_ERR_MSG);
@@ -57,10 +60,28 @@ void fini_hbv(Tcl_Interp *ip, int rc, HBytes_Var *agg) {
 int pat_hb(Tcl_Interp *ip, Tcl_Obj *obj, HBytes_Value *val) {
   int rc;
   rc= Tcl_ConvertToType(ip,obj,&hbytes_type);  if (rc) return rc;
 int pat_hb(Tcl_Interp *ip, Tcl_Obj *obj, HBytes_Value *val) {
   int rc;
   rc= Tcl_ConvertToType(ip,obj,&hbytes_type);  if (rc) return rc;
-  *val= HBYTES(obj);
+  *val= *OBJ_HBYTES(obj);
   return TCL_OK;
 }
 
 Tcl_Obj *ret_hb(Tcl_Interp *ip, HBytes_Value val) {
   return TCL_OK;
 }
 
 Tcl_Obj *ret_hb(Tcl_Interp *ip, HBytes_Value val) {
-  return hbytes_set_obj(0, val.start, HBYTES_LEN(val));
+  Tcl_Obj *obj;
+  obj= Tcl_NewObj();
+  Tcl_InvalidateStringRep(obj);
+  *OBJ_HBYTES(obj)= val;
+  obj->typePtr= &hbytes_type;
+  return obj;
+}
+
+Tcl_Obj *ret_int(Tcl_Interp *ip, int val) {
+  return Tcl_NewIntObj(val);
+}
+
+Tcl_Obj *ret_obj(Tcl_Interp *ip, Tcl_Obj *val) {
+  return val;
+}
+
+void setstringresult(Tcl_Interp *ip, const char *m) {
+  Tcl_ResetResult(ip);
+  Tcl_AppendResult(ip, m, (char*)0);
 }
 }