changed 'sed' to use -e for an expression
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
22
go/cb.go
22
go/cb.go
@ -9,7 +9,11 @@ import "C"
|
||||
import (
|
||||
// "bufio"
|
||||
// "io"
|
||||
"bufio"
|
||||
"io"
|
||||
"os"
|
||||
"sync"
|
||||
"unsafe"
|
||||
// "sync"
|
||||
// "unsafe"
|
||||
)
|
||||
@ -19,7 +23,6 @@ type IOHandle struct {
|
||||
ioif interface{}
|
||||
}
|
||||
|
||||
/*
|
||||
type IOHandleTable struct {
|
||||
mtx sync.Mutex
|
||||
handles []IOHandle
|
||||
@ -348,10 +351,10 @@ func (p *ScanFileHandler) Open(g *HCL) error {
|
||||
)
|
||||
|
||||
f = os.Stdin
|
||||
//f, err = os.Open("/dev/stdin")
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
//f, err = os.Open("/dev/stdin")
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
|
||||
p.r = bufio.NewReader(f)
|
||||
p.f = f
|
||||
@ -407,10 +410,10 @@ func (p *PrintFileHandler) Open(g *HCL) error {
|
||||
// err error
|
||||
)
|
||||
|
||||
// f, err = os.OpenFile("/dev/stdout", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// f, err = os.OpenFile("/dev/stdout", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
f = os.Stdout
|
||||
|
||||
@ -455,4 +458,3 @@ func (p *PrintFileHandler) Flush() error {
|
||||
//fmt.Fprintf(os.Stderr, "XXXXXXXXXX flush porint\n")
|
||||
return p.w.Flush()
|
||||
}
|
||||
*/
|
||||
|
23
go/hcl.go
23
go/hcl.go
@ -12,13 +12,23 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
type IOImpl interface {
|
||||
Open(g *HCL, name string, includer_name string) (int, error)
|
||||
Close(fd int)
|
||||
Read(fd int, buf []rune) (int, error)
|
||||
Write(data []rune) error
|
||||
WriteBytes(data []byte) error
|
||||
Flush() error
|
||||
}
|
||||
|
||||
type HCL struct {
|
||||
c *C.hcl_t
|
||||
inst_no int
|
||||
|
||||
io struct {
|
||||
r IOHandle
|
||||
w IOHandle
|
||||
r IOImpl
|
||||
s IOImpl
|
||||
p IOImpl
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,7 +92,14 @@ func (hcl *HCL) AddBuiltinPrims() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (hcl *HCL) AttachIO() error {
|
||||
func (hcl *HCL) AttachIO(r IOImpl, w IOImpl, p IOImpl) error {
|
||||
hcl.io.r = r
|
||||
hcl.io.s = s
|
||||
hcl.io.p = p
|
||||
if C.hcl_attachio(hcl.c, go_read_handler, go_scan_handler, go_print_handler) <= -1 {
|
||||
// TODO: restore to the old value..
|
||||
return fmt.Errorf("unable to attach I/O handlers: %s", string(ucstr_to_rune_slice(C.hcl_geterrstr(hcl.c))))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user