func (ir *Interpreter) NewFloatVar(name string) *FloatVar { fv := new(FloatVar) fv.ir = ir fv.name = name fv.data = 0.0 cname := C.CString(name) status := C.Tcl_LinkVar(ir.C, cname, (*C.char)(unsafe.Pointer(&fv.data)), C.TCL_LINK_DOUBLE) C.free_string(cname) if status != C.TCL_OK { panic(C.GoString(C.Tcl_GetStringResult(ir.C))) } return fv }
func (ir *Interpreter) NewIntVar(name string) *IntVar { iv := new(IntVar) iv.ir = ir iv.name = name iv.data = 0 cname := C.CString(name) status := C.Tcl_LinkVar(ir.C, cname, (*C.char)(unsafe.Pointer(&iv.data)), C.TCL_LINK_WIDE_INT) C.free_string(cname) if status != C.TCL_OK { panic(C.GoString(C.Tcl_GetStringResult(ir.C))) } return iv }
func (ir *Interpreter) NewStringVar(name string) *StringVar { sv := new(StringVar) sv.ir = ir sv.name = name sv.data = C.Tcl_Alloc(1) (*((*[alot]byte)(unsafe.Pointer(sv.data))))[0] = 0 cname := C.CString(name) status := C.Tcl_LinkVar(ir.C, cname, (*C.char)(unsafe.Pointer(&sv.data)), C.TCL_LINK_STRING) C.free_string(cname) if status != C.TCL_OK { panic(C.GoString(C.Tcl_GetStringResult(ir.C))) } return sv }