예제 #1
0
func (ir *interpreter) eval(args ...interface{}) error {
	ir.cmdbuf.Reset()
	fmt.Fprint(&ir.cmdbuf, args...)
	ir.cmdbuf.WriteByte(0)

	status := C.Tcl_Eval(ir.C, (*C.char)(unsafe.Pointer(&ir.cmdbuf.Bytes()[0])))
	if status != C.TCL_OK {
		return errors.New(C.GoString(C.Tcl_GetStringResult(ir.C)))
	}
	return nil
}
예제 #2
0
func (ir *Interpreter) Eval(args ...string) {
	for _, arg := range args {
		ir.cmdbuf.WriteString(arg)
		ir.cmdbuf.WriteString(" ")
	}

	s := ir.cmdbuf.String()
	ir.cmdbuf.Reset()

	if debug {
		println(s)
	}

	cs := C.CString(s)
	status := C.Tcl_Eval(ir.C, cs)
	C.free_string(cs)
	if status != C.TCL_OK {
		fmt.Fprintln(os.Stderr, C.GoString(C.Tcl_GetStringResult(ir.C)))
	}
}