From 7545ed41214e0b25f68ac96208c5864be098346c Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sat, 9 Jan 2021 11:37:40 +0200 Subject: [PATCH] ci: fix union field warnings in `clipboard` module --- vlib/clipboard/clipboard_darwin.c.v | 9 ++++----- vlib/clipboard/x11/clipboard.c.v | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/vlib/clipboard/clipboard_darwin.c.v b/vlib/clipboard/clipboard_darwin.c.v index bc9e265a4c..803d8e7d17 100644 --- a/vlib/clipboard/clipboard_darwin.c.v +++ b/vlib/clipboard/clipboard_darwin.c.v @@ -3,9 +3,7 @@ module clipboard #include #include #flag -framework Cocoa - #include "@VROOT/vlib/clipboard/clipboard_darwin.m" - pub struct Clipboard { pb voidptr last_cb_serial i64 @@ -14,12 +12,14 @@ mut: } fn C.darwin_new_pasteboard() voidptr + fn C.darwin_get_pasteboard_text(voidptr) byteptr + fn C.darwin_set_pasteboard_text(string) bool fn new_clipboard() &Clipboard { cb := &Clipboard{ - pb: C.darwin_new_pasteboard()// pb + pb: C.darwin_new_pasteboard() // pb } return cb } @@ -58,9 +58,8 @@ fn (mut cb Clipboard) get_text() string { if isnil(cb.pb) { return '' } - utf8_clip := C.darwin_get_pasteboard_text(cb.pb) - return unsafe {utf8_clip.vstring()} + return unsafe { utf8_clip.vstring() } } pub fn new_primary() &Clipboard { diff --git a/vlib/clipboard/x11/clipboard.c.v b/vlib/clipboard/x11/clipboard.c.v index 95cf171ebf..944510f993 100644 --- a/vlib/clipboard/x11/clipboard.c.v +++ b/vlib/clipboard/x11/clipboard.c.v @@ -255,19 +255,19 @@ fn (mut cb Clipboard) start_listener(){ mut to_be_requested := C.Atom(0) for { C.XNextEvent(cb.display, &event) - if event.@type == 0 { + if unsafe { event.@type == 0 } { println("error") continue } - match event.@type { + match unsafe {event.@type} { C.DestroyNotify { - if event.xdestroywindow.window == cb.window { + if unsafe { event.xdestroywindow.window == cb.window } { // we are done return } } C.SelectionClear { - if event.xselectionclear.window == cb.window && event.xselectionclear.selection == cb.selection { + if unsafe { event.xselectionclear.window == cb.window } && unsafe { event.xselectionclear.selection == cb.selection } { cb.mutex.m_lock() cb.is_owner = false cb.text = "" @@ -275,9 +275,9 @@ fn (mut cb Clipboard) start_listener(){ } } C.SelectionRequest { - if event.xselectionrequest.selection == cb.selection { + if unsafe { event.xselectionrequest.selection == cb.selection } { mut xsre := &C.XSelectionRequestEvent{ display: 0 } - xsre = &event.xselectionrequest + xsre = unsafe { &event.xselectionrequest } mut xse := C.XSelectionEvent{ @type: C.SelectionNotify // 31 @@ -296,20 +296,20 @@ fn (mut cb Clipboard) start_listener(){ } } C.SelectionNotify { - if event.xselection.selection == cb.selection && event.xselection.property != C.Atom(C.None) { - if event.xselection.target == cb.get_atom(.targets) && !sent_request { + if unsafe { event.xselection.selection == cb.selection && event.xselection.property != C.Atom(C.None) } { + if unsafe { event.xselection.target == cb.get_atom(.targets) && !sent_request } { sent_request = true prop := read_property(cb.display, cb.window, cb.selection) to_be_requested = cb.pick_target(prop) if to_be_requested != C.Atom(0) { C.XConvertSelection(cb.display, cb.selection, to_be_requested, cb.selection, cb.window, C.CurrentTime) } - } else if event.xselection.target == to_be_requested { + } else if unsafe { event.xselection.target == to_be_requested } { sent_request = false to_be_requested = C.Atom(0) cb.mutex.m_lock() - prop := read_property(event.xselection.display, event.xselection.requestor, event.xselection.property) - C.XDeleteProperty(event.xselection.display, event.xselection.requestor, event.xselection.property) + prop := unsafe{ read_property(event.xselection.display, event.xselection.requestor, event.xselection.property) } + unsafe{ C.XDeleteProperty(event.xselection.display, event.xselection.requestor, event.xselection.property) } if cb.is_supported_target(prop.actual_type) { cb.got_text = true unsafe {