|
1 | 1 | ## Custom Macros and top level methods go here! |
2 | 2 | ## WinMD will not overwrite this file. |
3 | 3 |
|
| 4 | +# Converts a string to a pointer to a null-terminated wide string pointer. |
4 | 5 | macro pwstr(str) |
5 | 6 | {{str}}.to_utf16.to_unsafe |
6 | 7 | end |
7 | 8 |
|
8 | | -def loword(i : UInt64) : UInt16 |
| 9 | +# Returns the low-order `WORD` from a `UInt64`. |
| 10 | +def loword(i : UInt32) : UInt16 |
9 | 11 | val = (i & 0xffff).to_u16 |
10 | 12 | val |
11 | 13 | end |
12 | 14 |
|
13 | | -def loword(i : Int64) : UInt16 |
14 | | - val = (i.to_u64 & 0xffff).to_u16 |
| 15 | +# Returns the low-order `WORD` from a `Int64`. |
| 16 | +def loword(i : Int32) : UInt16 |
| 17 | + val = (i.to_u32 & 0xffff).to_u16 |
15 | 18 | val |
16 | 19 | end |
17 | 20 |
|
| 21 | +# Returns the low-order `WORD` from a `UInt64` pointer. |
| 22 | +def loword(i : UInt32*) : UInt16 |
| 23 | + val = (i.value & 0xffff).to_u16 |
| 24 | + val |
| 25 | +end |
| 26 | + |
| 27 | +# Returns the low-order `WORD` from a `Int64` pointer. |
| 28 | +def loword(i : Int32*) : UInt16 |
| 29 | + val = (i.value.to_u32 & 0xffff).to_u16 |
| 30 | + val |
| 31 | +end |
| 32 | + |
| 33 | +# Returns the high-order `WORD` from a `UInt32`. |
| 34 | +def hiword(i : UInt32) : UInt16 |
| 35 | + val = ((i >> 16) & 0xFFFF).to_u16 |
| 36 | + val |
| 37 | +end |
| 38 | + |
| 39 | +# Returns the high-order `WORD` from a `Int32`. |
| 40 | +def hiword(i : Int32) : UInt16 |
| 41 | + val = ((i.to_u32 >> 16) & 0xFFFF).to_u16 |
| 42 | + val |
| 43 | +end |
| 44 | + |
| 45 | +# Returns the high-order `WORD` from a `UInt32` pointer. |
18 | 46 | def hiword(i : UInt32*) : UInt16 |
19 | 47 | val = ((i.value >> 16) & 0xFFFF).to_u16 |
20 | 48 | val |
21 | 49 | end |
22 | 50 |
|
23 | | -def hiword(i : Int64*) : UInt16 |
24 | | - val = ((i.value.to_u64 >> 16) & 0xFFFF).to_u16 |
| 51 | +# Returns the high-order `WORD` from a `Int32` pointer. |
| 52 | +def hiword(i : Int32*) : UInt16 |
| 53 | + val = ((i.value.to_u32 >> 16) & 0xFFFF).to_u16 |
25 | 54 | val |
26 | 55 | end |
0 commit comments