chiark / gitweb /
initial import and build-faff, wip
[chiark-tcl.git] / hbytes / hbglue.c
diff --git a/hbytes/hbglue.c b/hbytes/hbglue.c
new file mode 100644 (file)
index 0000000..1ac833d
--- /dev/null
@@ -0,0 +1,23 @@
+int cht_pat_hbv(Tcl_Interp *ip, Tcl_Obj *var, HBytes_Var *agg) {
+  int rc;
+  rc= pat_somethingv(ip,var,&agg->sth,&hbytes_type);  if (rc) return rc;
+  agg->hb= OBJ_HBYTES(agg->sth.obj);
+  return TCL_OK;
+}
+
+int cht_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= *OBJ_HBYTES(obj);
+  return TCL_OK;
+}
+
+Tcl_Obj *cht_ret_hb(Tcl_Interp *ip, HBytes_Value val) {
+  Tcl_Obj *obj;
+  obj= Tcl_NewObj();
+  Tcl_InvalidateStringRep(obj);
+  *OBJ_HBYTES(obj)= val;
+  obj->typePtr= &hbytes_type;
+  return obj;
+}
+