Example #1
0
File: code.go Project: 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
}
Example #2
0
func (w *window) openFile(f func(filename string)) {
	C.openFile(w.id, unsafe.Pointer(&f))
}