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

all: unify const names to snake_case

This commit is contained in:
yuyi
2020-05-22 23:36:09 +08:00
committed by GitHub
parent aef751861d
commit dda875a9c8
58 changed files with 543 additions and 540 deletions

View File

@ -32,7 +32,7 @@ mut:
n_file_size_low u32
dw_reserved0 u32
dw_reserved1 u32
c_file_name [260]u16 // MAX_PATH = 260
c_file_name [260]u16 // max_path_len = 260
c_alternate_file_name [14]u16 // 14
dw_file_type u32
dw_creator_type u32
@ -89,7 +89,7 @@ pub fn ls(path string) ?[]string {
mut dir_files := []string{}
// We can also check if the handle is valid. but using is_dir instead
// h_find_dir := C.FindFirstFile(path.str, &find_file_data)
// if (INVALID_HANDLE_VALUE == h_find_dir) {
// if (invalid_handle_value == h_find_dir) {
// return dir_files
// }
// C.FindClose(h_find_dir)
@ -146,7 +146,7 @@ pub fn mkdir(path string) ?bool {
pub fn get_file_handle(path string) HANDLE {
cfile := vfopen(path, 'rb')
if cfile == 0 {
return HANDLE(INVALID_HANDLE_VALUE)
return HANDLE(invalid_handle_value)
}
handle := HANDLE(C._get_osfhandle(fileno(cfile))) // CreateFile? - hah, no -_-
return handle
@ -177,24 +177,24 @@ pub fn get_module_filename(handle HANDLE) ?string {
// Ref - https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-formatmessagea#parameters
const (
FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100
FORMAT_MESSAGE_ARGUMENT_ARRAY = 0x00002000
FORMAT_MESSAGE_FROM_HMODULE = 0x00000800
FORMAT_MESSAGE_FROM_STRING = 0x00000400
FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000
FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200
format_message_allocate_buffer = 0x00000100
format_message_argument_array = 0x00002000
format_message_from_hmodule = 0x00000800
format_message_from_string = 0x00000400
format_message_from_system = 0x00001000
format_message_ignore_inserts = 0x00000200
)
// Ref - winnt.h
const (
SUBLANG_NEUTRAL = 0x00
SUBLANG_DEFAULT = 0x01
LANG_NEUTRAL = (SUBLANG_NEUTRAL)
sublang_neutral = 0x00
sublang_default = 0x01
lang_neutral = (sublang_neutral)
)
// Ref - https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--12000-15999-
const (
MAX_ERROR_CODE = 15841 // ERROR_API_UNAVAILABLE
max_error_code = 15841 // ERROR_API_UNAVAILABLE
)
// ptr_win_get_error_msg return string (voidptr)
@ -202,14 +202,14 @@ const (
fn ptr_win_get_error_msg(code u32) voidptr {
mut buf := voidptr(0)
// Check for code overflow
if code > u32(MAX_ERROR_CODE) {
if code > u32(max_error_code) {
return buf
}
C.FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_IGNORE_INSERTS,
0, code, C.MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), voidptr(&buf), 0, 0)
format_message_allocate_buffer
| format_message_from_system
| format_message_ignore_inserts,
0, code, C.MAKELANGID(lang_neutral, sublang_default), voidptr(&buf), 0, 0)
return buf
}