From 21d5db43af72ad17cf7f08a28a9a9dd9242d85e2 Mon Sep 17 00:00:00 2001 From: Swastik Baranwal Date: Mon, 4 Jan 2021 13:27:31 +0530 Subject: [PATCH] cgen: do not generate `!=` and `==` for C types (#7856) --- vlib/clipboard/clipboard_windows.c.v | 10 +++++----- vlib/v/gen/cgen.v | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/vlib/clipboard/clipboard_windows.c.v b/vlib/clipboard/clipboard_windows.c.v index f1415b84f7..1aba3b1175 100644 --- a/vlib/clipboard/clipboard_windows.c.v +++ b/vlib/clipboard/clipboard_windows.c.v @@ -104,11 +104,11 @@ fn new_clipboard() &Clipboard { } fn (cb &Clipboard) check_availability() bool { - return voidptr(cb.hwnd) != voidptr(0) + return cb.hwnd != C.HWND(C.NULL) } fn (cb &Clipboard) has_ownership() bool { - return voidptr(C.GetClipboardOwner()) == voidptr(cb.hwnd) + return C.GetClipboardOwner() == cb.hwnd } fn (mut cb Clipboard) clear() { @@ -130,7 +130,7 @@ fn to_wide(text string) C.HGLOBAL { len_required := C.MultiByteToWideChar(C.CP_UTF8, C.MB_ERR_INVALID_CHARS, text.str, text.len + 1, C.NULL, 0) buf := C.GlobalAlloc(C.GMEM_MOVEABLE, i64(sizeof(u16)) * len_required) - if voidptr(buf) != voidptr(0) { + if buf != C.HGLOBAL(C.NULL) { mut locked := &u16(C.GlobalLock(buf)) C.MultiByteToWideChar(C.CP_UTF8, C.MB_ERR_INVALID_CHARS, text.str, text.len + 1, locked, len_required) @@ -151,7 +151,7 @@ fn (mut cb Clipboard) set_text(text string) bool { } else { // EmptyClipboard must be called to properly update clipboard ownership C.EmptyClipboard() - if voidptr(C.SetClipboardData(C.CF_UNICODETEXT, buf)) == voidptr(0) { + if C.SetClipboardData(C.CF_UNICODETEXT, buf) == C.HANDLE(C.NULL) { println('SetClipboardData: Failed.') C.CloseClipboard() C.GlobalFree(buf) @@ -169,7 +169,7 @@ fn (mut cb Clipboard) get_text() string { return '' } h_data := C.GetClipboardData(C.CF_UNICODETEXT) - if voidptr(h_data) == voidptr(0) { + if h_data == C.HANDLE(C.NULL) { C.CloseClipboard() return '' } diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index c00b272ff4..e9d546162d 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -3157,7 +3157,7 @@ fn (mut g Gen) infix_expr(node ast.InfixExpr) { g.write(')') } else { a := (left_sym.name[0].is_capital() || left_sym.name.contains('.')) && - left_sym.kind !in [.enum_, .function, .interface_, .sum_type] + left_sym.kind !in [.enum_, .function, .interface_, .sum_type] && left_sym.language != .c b := left_sym.kind != .alias c := left_sym.kind == .alias && (left_sym.info as table.Alias).language == .c // Check if aliased type is a struct