Exemplo n.º 1
0
Arquivo: code.go Projeto: MogeiWang/py
func CompileFile(name string, start StartToken) (*Code, error) {
	fn := C.CString(name)
	defer C.free(unsafe.Pointer(fn))

	file, err := C.openFile(fn)
	if file == nil {
		return nil, err
	}
	defer C.fclose(file)

	ret := C.compileFile(file, fn, C.int(start))
	if ret == nil {
		return nil, exception()
	}
	return newCode(ret), nil
}
Exemplo n.º 2
0
func (w *window) openFile(f func(filename string)) {
	C.openFile(w.id, unsafe.Pointer(&f))
}