1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker: allow EnumName(number) casts only inside unsafe{} blocks (#15932)

This commit is contained in:
Swastik Baranwal
2022-10-03 01:09:11 +05:30
committed by GitHub
parent 7993f0bf39
commit b584e1df98
32 changed files with 129 additions and 97 deletions

View File

@ -289,7 +289,7 @@ fn single_char(buf string) &Event {
mut event := &Event{
typ: .key_down
ascii: ch
code: KeyCode(ch)
code: unsafe { KeyCode(ch) }
utf8: ch.ascii_str()
}
@ -305,7 +305,7 @@ fn single_char(buf string) &Event {
typ: event.typ
ascii: event.ascii
utf8: event.utf8
code: KeyCode(96 | ch)
code: unsafe { KeyCode(96 | ch) }
modifiers: .ctrl
}
}
@ -314,7 +314,7 @@ fn single_char(buf string) &Event {
typ: event.typ
ascii: event.ascii
utf8: event.utf8
code: KeyCode(32 | ch)
code: unsafe { KeyCode(32 | ch) }
modifiers: .shift
}
}
@ -330,7 +330,7 @@ fn multi_char(buf string) (&Event, int) {
mut event := &Event{
typ: .key_down
ascii: ch
code: KeyCode(ch)
code: unsafe { KeyCode(ch) }
utf8: buf
}
@ -346,7 +346,7 @@ fn multi_char(buf string) (&Event, int) {
typ: event.typ
ascii: event.ascii
utf8: event.utf8
code: KeyCode(96 | ch)
code: unsafe { KeyCode(96 | ch) }
modifiers: .ctrl
}
}
@ -355,7 +355,7 @@ fn multi_char(buf string) (&Event, int) {
typ: event.typ
ascii: event.ascii
utf8: event.utf8
code: KeyCode(32 | ch)
code: unsafe { KeyCode(32 | ch) }
modifiers: .shift
}
}
@ -447,7 +447,7 @@ fn escape_sequence(buf_ string) (&Event, int) {
match typ {
0...31 {
last := buf[buf.len - 1]
button := if lo < 3 { MouseButton(lo + 1) } else { MouseButton.unknown }
button := if lo < 3 { unsafe { MouseButton(lo + 1) } } else { MouseButton.unknown }
event := if last == `m` || lo == 3 {
EventType.mouse_up
} else {
@ -465,7 +465,7 @@ fn escape_sequence(buf_ string) (&Event, int) {
}
32...63 {
button, event := if lo < 3 {
MouseButton(lo + 1), EventType.mouse_drag
unsafe { MouseButton(lo + 1), EventType.mouse_drag }
} else {
MouseButton.unknown, EventType.mouse_move
}