cgen: do not generate `!=` and `==` for C types (#7856)
parent
43adbf4b66
commit
21d5db43af
|
@ -104,11 +104,11 @@ fn new_clipboard() &Clipboard {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (cb &Clipboard) check_availability() bool {
|
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 {
|
fn (cb &Clipboard) has_ownership() bool {
|
||||||
return voidptr(C.GetClipboardOwner()) == voidptr(cb.hwnd)
|
return C.GetClipboardOwner() == cb.hwnd
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (mut cb Clipboard) clear() {
|
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,
|
len_required := C.MultiByteToWideChar(C.CP_UTF8, C.MB_ERR_INVALID_CHARS, text.str,
|
||||||
text.len + 1, C.NULL, 0)
|
text.len + 1, C.NULL, 0)
|
||||||
buf := C.GlobalAlloc(C.GMEM_MOVEABLE, i64(sizeof(u16)) * len_required)
|
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))
|
mut locked := &u16(C.GlobalLock(buf))
|
||||||
C.MultiByteToWideChar(C.CP_UTF8, C.MB_ERR_INVALID_CHARS, text.str, text.len + 1,
|
C.MultiByteToWideChar(C.CP_UTF8, C.MB_ERR_INVALID_CHARS, text.str, text.len + 1,
|
||||||
locked, len_required)
|
locked, len_required)
|
||||||
|
@ -151,7 +151,7 @@ fn (mut cb Clipboard) set_text(text string) bool {
|
||||||
} else {
|
} else {
|
||||||
// EmptyClipboard must be called to properly update clipboard ownership
|
// EmptyClipboard must be called to properly update clipboard ownership
|
||||||
C.EmptyClipboard()
|
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.')
|
println('SetClipboardData: Failed.')
|
||||||
C.CloseClipboard()
|
C.CloseClipboard()
|
||||||
C.GlobalFree(buf)
|
C.GlobalFree(buf)
|
||||||
|
@ -169,7 +169,7 @@ fn (mut cb Clipboard) get_text() string {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
h_data := C.GetClipboardData(C.CF_UNICODETEXT)
|
h_data := C.GetClipboardData(C.CF_UNICODETEXT)
|
||||||
if voidptr(h_data) == voidptr(0) {
|
if h_data == C.HANDLE(C.NULL) {
|
||||||
C.CloseClipboard()
|
C.CloseClipboard()
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
|
@ -3157,7 +3157,7 @@ fn (mut g Gen) infix_expr(node ast.InfixExpr) {
|
||||||
g.write(')')
|
g.write(')')
|
||||||
} else {
|
} else {
|
||||||
a := (left_sym.name[0].is_capital() || left_sym.name.contains('.')) &&
|
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
|
b := left_sym.kind != .alias
|
||||||
c := left_sym.kind == .alias && (left_sym.info as table.Alias).language == .c
|
c := left_sym.kind == .alias && (left_sym.info as table.Alias).language == .c
|
||||||
// Check if aliased type is a struct
|
// Check if aliased type is a struct
|
||||||
|
|
Loading…
Reference in New Issue