This repository was archived by the owner on Jul 24, 2023. It is now read-only.
File tree 3 files changed +43
-10
lines changed
3 files changed +43
-10
lines changed Original file line number Diff line number Diff line change @@ -91,16 +91,6 @@ func int2err(i C.int) error {
91
91
return & gopy_err {fmt .Sprintf ("error in C-Python (rc=%i)" , int (i ))}
92
92
}
93
93
94
- // file2py opens a stdC file from a Go os.File. Note the returned file has
95
- // been newly opened: the caller must close it with C.fclose(retval).
96
- func file2py (f * os.File , mode string ) * C.FILE {
97
- cmode := C .CString (mode )
98
- defer C .free (unsafe .Pointer (cmode ))
99
- fd := f .Fd ()
100
- file := C .fdopen (C .int (fd ), cmode )
101
- return file
102
- }
103
-
104
94
func file2go (f * C.FILE ) * os.File {
105
95
return nil
106
96
}
Original file line number Diff line number Diff line change
1
+ package python
2
+
3
+ //#include <stdlib.h>
4
+ //#include <string.h>
5
+ //#include <stdio.h>
6
+ import "C"
7
+
8
+ import (
9
+ "os"
10
+ "unsafe"
11
+ )
12
+
13
+ // file2py opens a stdC file from a Go os.File. Note the returned file has
14
+ // been newly opened: the caller must close it with C.fclose(retval).
15
+ func file2py (f * os.File , mode string ) * C.FILE {
16
+ cmode := C .CString (mode )
17
+ defer C .free (unsafe .Pointer (cmode ))
18
+ fd := f .Fd ()
19
+ file := C .fdopen (C .int (fd ), cmode )
20
+ return file
21
+ }
Original file line number Diff line number Diff line change
1
+ package python
2
+
3
+ //#include <stdlib.h>
4
+ //#include <string.h>
5
+ //#include <stdio.h>
6
+ import "C"
7
+
8
+ import (
9
+ "os"
10
+ "unsafe"
11
+ )
12
+
13
+ // file2py opens a stdC file from a Go os.File. Note the returned file has
14
+ // been newly opened: the caller must close it with C.fclose(retval).
15
+ func file2py (f * os.File , mode string ) * C.FILE {
16
+ cmode := C .CString (mode )
17
+ defer C .free (unsafe .Pointer (cmode ))
18
+ name := C .CString (file .Name ())
19
+ defer C .free (unsafe .Pointer (name ))
20
+ file := C .fopen (name , cmode )
21
+ return file
22
+ }
You can’t perform that action at this time.
0 commit comments