Skip to content

Commit c3d19db

Browse files
committed
all: use runtime/cgo and require go1.17
1 parent 4cdf6cd commit c3d19db

File tree

6 files changed

+10
-308
lines changed

6 files changed

+10
-308
lines changed

.github/workflows/clipboard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- uses: actions/setup-go@v2
3434
with:
3535
stable: 'false'
36-
go-version: '1.16.0'
36+
go-version: '1.17.0'
3737

3838
- name: TestLinux
3939
run: |

clipboard_linux.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66

77
#include <stdlib.h>
88
#include <stdio.h>
9+
#include <stdint.h>
910
#include <string.h>
1011
#include <X11/Xlib.h>
1112
#include <X11/Xatom.h>
1213

1314
// syncStatus is a function from the Go side.
14-
extern void syncStatus(unsigned long long handle, int status);
15+
extern void syncStatus(uintptr_t handle, int status);
1516

1617
int clipboard_test() {
1718
Display *d = XOpenDisplay(0);
@@ -25,7 +26,7 @@ int clipboard_test() {
2526
// clipboard_write writes the given buf of size n as type typ.
2627
// if start is provided, the value of start will be changed to 1 to indicate
2728
// if the write is availiable for reading.
28-
int clipboard_write(char *typ, unsigned char *buf, size_t n, unsigned long long handle) {
29+
int clipboard_write(char *typ, unsigned char *buf, size_t n, uintptr_t handle) {
2930
Display* d = XOpenDisplay(0);
3031
if (d == NULL) {
3132
if (handle != 0) syncStatus(handle, -1);

clipboard_linux.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ package clipboard
1313
#cgo LDFLAGS: -lX11
1414
#include <stdlib.h>
1515
#include <stdio.h>
16+
#include <stdint.h>
1617
#include <string.h>
1718
#include <X11/Xlib.h>
1819
#include <X11/Xatom.h>
@@ -23,7 +24,7 @@ int clipboard_write(
2324
char* typ,
2425
unsigned char* buf,
2526
size_t n,
26-
unsigned long long handle
27+
uintptr_t handle
2728
);
2829
unsigned long clipboard_read(char* typ, char **out);
2930
*/
@@ -34,10 +35,9 @@ import (
3435
"fmt"
3536
"os"
3637
"runtime"
38+
"runtime/cgo"
3739
"time"
3840
"unsafe"
39-
40-
"golang.design/x/clipboard/internal/cgo"
4141
)
4242

4343
func init() {
@@ -105,9 +105,9 @@ func write(t Format, buf []byte) (<-chan struct{}, error) {
105105
h := cgo.NewHandle(start)
106106
var ok C.int
107107
if len(buf) == 0 {
108-
ok = C.clipboard_write(cs, nil, 0, C.ulonglong(h))
108+
ok = C.clipboard_write(cs, nil, 0, C.uintptr_t(h))
109109
} else {
110-
ok = C.clipboard_write(cs, (*C.uchar)(unsafe.Pointer(&(buf[0]))), C.size_t(len(buf)), C.ulonglong(h))
110+
ok = C.clipboard_write(cs, (*C.uchar)(unsafe.Pointer(&(buf[0]))), C.size_t(len(buf)), C.uintptr_t(h))
111111
}
112112
if ok != C.int(0) {
113113
fmt.Fprintf(os.Stderr, "write failed with status: %d\n", int(ok))

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module golang.design/x/clipboard
22

3-
go 1.16
3+
go 1.17

internal/cgo/handle.go

Lines changed: 0 additions & 156 deletions
This file was deleted.

internal/cgo/handle_test.go

Lines changed: 0 additions & 143 deletions
This file was deleted.

0 commit comments

Comments
 (0)