mirror of
https://github.com/vlang/v.git
synced 2025-09-13 06:22:26 +03:00
This commit is contained in:
parent
36e31d6908
commit
209063ffd0
65 changed files with 260 additions and 129 deletions
|
@ -153,18 +153,18 @@ jobs:
|
|||
echo "Build v-analyzer release"
|
||||
v build.vsh release
|
||||
|
||||
- name: Format vlang/v-analyzer
|
||||
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
|
||||
run: |
|
||||
cd /tmp/v-analyzer
|
||||
set +e
|
||||
v fmt -c .
|
||||
exit_code=$?
|
||||
if [[ $exit_code -ne 0 && $exit_code -ne 5 ]]; then
|
||||
# Don't fail if there are only internal errors (exit code 5).
|
||||
v fmt -diff .
|
||||
exit 1
|
||||
fi
|
||||
# - name: Format vlang/v-analyzer
|
||||
# if: ${{ !cancelled() && steps.build.outcome == 'success' }}
|
||||
# run: |
|
||||
# cd /tmp/v-analyzer
|
||||
# set +e
|
||||
# v fmt -c .
|
||||
# exit_code=$?
|
||||
# if [[ $exit_code -ne 0 && $exit_code -ne 5 ]]; then
|
||||
# # Don't fail if there are only internal errors (exit code 5).
|
||||
# v fmt -diff .
|
||||
# exit 1
|
||||
# fi
|
||||
|
||||
- name: Build vlang/go2v
|
||||
if: ${{ !cancelled() && steps.build.outcome == 'success' && matrix.os != 'macos-14' }}
|
||||
|
|
|
@ -98,7 +98,8 @@ fn gen_api_for_module_in_os(mod_name string, os_ pref.OS) string {
|
|||
if s is ast.FnDecl && s.is_pub {
|
||||
fn_mod := s.modname()
|
||||
if fn_mod == mod_name {
|
||||
fn_signature := b.table.stringify_fn_decl(&s, mod_name, map[string]string{})
|
||||
fn_signature := b.table.stringify_fn_decl(&s, mod_name, map[string]string{},
|
||||
false)
|
||||
fline := '${fn_mod}: ${fn_signature}'
|
||||
res << fline
|
||||
}
|
||||
|
|
|
@ -26,7 +26,8 @@ fn (vd VDoc) gen_markdown(d doc.Doc, with_toc bool) string {
|
|||
return hw.str() + '\n' + cw.str()
|
||||
}
|
||||
|
||||
fn (vd VDoc) write_markdown_content(contents []doc.DocNode, mut cw strings.Builder, mut hw strings.Builder, indent int, with_toc bool) {
|
||||
fn (vd VDoc) write_markdown_content(contents []doc.DocNode, mut cw strings.Builder, mut hw strings.Builder,
|
||||
indent int, with_toc bool) {
|
||||
cfg := vd.cfg
|
||||
for cn in contents {
|
||||
if with_toc && cn.name != '' {
|
||||
|
|
|
@ -41,7 +41,8 @@ fn C.wkhtmltopdf_create_converter(global_settings &C.wkhtmltopdf_global_settings
|
|||
|
||||
fn C.wkhtmltopdf_destroy_converter(converter &C.wkhtmltopdf_converter)
|
||||
|
||||
fn C.wkhtmltopdf_add_object(converter &C.wkhtmltopdf_converter, object_settings &C.wkhtmltopdf_object_settings, data &char)
|
||||
fn C.wkhtmltopdf_add_object(converter &C.wkhtmltopdf_converter, object_settings &C.wkhtmltopdf_object_settings,
|
||||
data &char)
|
||||
|
||||
fn C.wkhtmltopdf_convert(converter &C.wkhtmltopdf_converter) bool
|
||||
|
||||
|
|
|
@ -48,7 +48,8 @@ pub mut:
|
|||
pattern [][]string
|
||||
}
|
||||
|
||||
fn (mut s Solution) find_pattern(adj map[string][]string, mut visited map[string]bool, node string, target string, mut path []string) {
|
||||
fn (mut s Solution) find_pattern(adj map[string][]string, mut visited map[string]bool, node string, target string,
|
||||
mut path []string) {
|
||||
path << node
|
||||
visited[node] = true
|
||||
if node == target {
|
||||
|
|
|
@ -158,7 +158,8 @@ pub:
|
|||
}
|
||||
|
||||
// step_message_with_label_and_duration returns a string describing the current step.
|
||||
pub fn (b &Benchmark) step_message_with_label_and_duration(label string, msg string, sduration time.Duration, opts MessageOptions) string {
|
||||
pub fn (b &Benchmark) step_message_with_label_and_duration(label string, msg string, sduration time.Duration,
|
||||
opts MessageOptions) string {
|
||||
timed_line := b.tdiff_in_ms(msg, sduration.microseconds())
|
||||
if b.nexpected_steps > 1 {
|
||||
mut sprogress := ''
|
||||
|
|
|
@ -172,7 +172,8 @@ pub fn gc_check_leaks() {
|
|||
}
|
||||
}
|
||||
|
||||
fn C.GC_get_heap_usage_safe(pheap_size &usize, pfree_bytes &usize, punmapped_bytes &usize, pbytes_since_gc &usize, ptotal_bytes &usize)
|
||||
fn C.GC_get_heap_usage_safe(pheap_size &usize, pfree_bytes &usize, punmapped_bytes &usize, pbytes_since_gc &usize,
|
||||
ptotal_bytes &usize)
|
||||
fn C.GC_get_memory_use() usize
|
||||
|
||||
pub struct C.GC_stack_base {
|
||||
|
|
|
@ -15,7 +15,8 @@ type BacktraceErrorCallback = fn (data voidptr, msg &char, errnum int) voidptr
|
|||
type BacktraceFullCallback = fn (data voidptr, pc voidptr, filename &char, lineno int, func &char) &int
|
||||
|
||||
fn C.backtrace_create_state(filename &char, threaded int, error_callback BacktraceErrorCallback, data voidptr) &C.backtrace_state
|
||||
fn C.backtrace_full(state &C.backtrace_state, skip int, cb BacktraceFullCallback, err_cb BacktraceErrorCallback, data voidptr) int
|
||||
fn C.backtrace_full(state &C.backtrace_state, skip int, cb BacktraceFullCallback, err_cb BacktraceErrorCallback,
|
||||
data voidptr) int
|
||||
|
||||
__global bt_state = init_bt_state()
|
||||
|
||||
|
|
|
@ -14,7 +14,8 @@ fn C.GC_REALLOC(ptr voidptr, n usize) voidptr
|
|||
|
||||
fn C.GC_FREE(ptr voidptr)
|
||||
|
||||
fn C.GC_get_heap_usage_safe(pheap_size &usize, pfree_bytes &usize, punmapped_bytes &usize, pbytes_since_gc &usize, ptotal_bytes &usize)
|
||||
fn C.GC_get_heap_usage_safe(pheap_size &usize, pfree_bytes &usize, punmapped_bytes &usize, pbytes_since_gc &usize,
|
||||
ptotal_bytes &usize)
|
||||
|
||||
fn C.GC_get_memory_use() usize
|
||||
|
||||
|
|
|
@ -237,9 +237,11 @@ fn C.GetModuleFileName(hModule voidptr, lpFilename &u16, nSize u32) u32
|
|||
|
||||
fn C.GetModuleFileNameW(hModule voidptr, lpFilename &u16, nSize u32) u32
|
||||
|
||||
fn C.CreateFile(lpFilename &u16, dwDesiredAccess u32, dwShareMode u32, lpSecurityAttributes &u16, dwCreationDisposition u32, dwFlagsAndAttributes u32, hTemplateFile voidptr) voidptr
|
||||
fn C.CreateFile(lpFilename &u16, dwDesiredAccess u32, dwShareMode u32, lpSecurityAttributes &u16, dwCreationDisposition u32,
|
||||
dwFlagsAndAttributes u32, hTemplateFile voidptr) voidptr
|
||||
|
||||
fn C.CreateFileW(lpFilename &u16, dwDesiredAccess u32, dwShareMode u32, lpSecurityAttributes &u16, dwCreationDisposition u32, dwFlagsAndAttributes u32, hTemplateFile voidptr) voidptr
|
||||
fn C.CreateFileW(lpFilename &u16, dwDesiredAccess u32, dwShareMode u32, lpSecurityAttributes &u16, dwCreationDisposition u32,
|
||||
dwFlagsAndAttributes u32, hTemplateFile voidptr) voidptr
|
||||
|
||||
fn C.GetFinalPathNameByHandleW(hFile voidptr, lpFilePath &u16, nSize u32, dwFlags u32) u32
|
||||
|
||||
|
@ -258,7 +260,9 @@ fn C.SendMessageTimeout() isize
|
|||
|
||||
fn C.SendMessageTimeoutW(hWnd voidptr, msg u32, wParam &u16, lParam &u32, fuFlags u32, uTimeout u32, lpdwResult &u64) isize
|
||||
|
||||
fn C.CreateProcessW(lpApplicationName &u16, lpCommandLine &u16, lpProcessAttributes voidptr, lpThreadAttributes voidptr, bInheritHandles bool, dwCreationFlags u32, lpEnvironment voidptr, lpCurrentDirectory &u16, lpStartupInfo voidptr, lpProcessInformation voidptr) bool
|
||||
fn C.CreateProcessW(lpApplicationName &u16, lpCommandLine &u16, lpProcessAttributes voidptr, lpThreadAttributes voidptr,
|
||||
bInheritHandles bool, dwCreationFlags u32, lpEnvironment voidptr, lpCurrentDirectory &u16, lpStartupInfo voidptr,
|
||||
lpProcessInformation voidptr) bool
|
||||
|
||||
fn C.ReadFile(hFile voidptr, lpBuffer voidptr, nNumberOfBytesToRead u32, lpNumberOfBytesRead &u32, lpOverlapped voidptr) bool
|
||||
|
||||
|
@ -298,11 +302,13 @@ fn C.setbuf(voidptr, &char)
|
|||
|
||||
fn C.SymCleanup(hProcess voidptr)
|
||||
|
||||
fn C.MultiByteToWideChar(codePage u32, dwFlags u32, lpMultiMyteStr &char, cbMultiByte int, lpWideCharStr &u16, cchWideChar int) int
|
||||
fn C.MultiByteToWideChar(codePage u32, dwFlags u32, lpMultiMyteStr &char, cbMultiByte int, lpWideCharStr &u16,
|
||||
cchWideChar int) int
|
||||
|
||||
fn C.wcslen(str voidptr) usize
|
||||
|
||||
fn C.WideCharToMultiByte(codePage u32, dwFlags u32, lpWideCharStr &u16, cchWideChar int, lpMultiByteStr &char, cbMultiByte int, lpDefaultChar &char, lpUsedDefaultChar &int) int
|
||||
fn C.WideCharToMultiByte(codePage u32, dwFlags u32, lpWideCharStr &u16, cchWideChar int, lpMultiByteStr &char,
|
||||
cbMultiByte int, lpDefaultChar &char, lpUsedDefaultChar &int) int
|
||||
|
||||
fn C._wstat(path &u16, buffer &C._stat) int
|
||||
|
||||
|
@ -324,7 +330,8 @@ fn C._waccess(path &u16, mode int) int
|
|||
|
||||
fn C._wremove(path &u16) int
|
||||
|
||||
fn C.ReadConsole(in_input_handle voidptr, out_buffer voidptr, in_chars_to_read u32, out_read_chars &u32, in_input_control voidptr) bool
|
||||
fn C.ReadConsole(in_input_handle voidptr, out_buffer voidptr, in_chars_to_read u32, out_read_chars &u32,
|
||||
in_input_control voidptr) bool
|
||||
|
||||
fn C.WriteConsole() voidptr
|
||||
|
||||
|
@ -354,7 +361,8 @@ fn C.FindClose(hFindFile voidptr)
|
|||
// macro
|
||||
fn C.MAKELANGID(lgid voidptr, srtid voidptr) int
|
||||
|
||||
fn C.FormatMessageW(dwFlags u32, lpSource voidptr, dwMessageId u32, dwLanguageId u32, lpBuffer voidptr, nSize u32, arguments ...voidptr) u32
|
||||
fn C.FormatMessageW(dwFlags u32, lpSource voidptr, dwMessageId u32, dwLanguageId u32, lpBuffer voidptr,
|
||||
nSize u32, arguments ...voidptr) u32
|
||||
|
||||
fn C.CloseHandle(voidptr) int
|
||||
|
||||
|
|
|
@ -269,7 +269,8 @@ fn new_map(key_bytes int, value_bytes int, hash_fn MapHashFn, key_eq_fn MapEqFn,
|
|||
}
|
||||
}
|
||||
|
||||
fn new_map_init(hash_fn MapHashFn, key_eq_fn MapEqFn, clone_fn MapCloneFn, free_fn MapFreeFn, n int, key_bytes int, value_bytes int, keys voidptr, values voidptr) map {
|
||||
fn new_map_init(hash_fn MapHashFn, key_eq_fn MapEqFn, clone_fn MapCloneFn, free_fn MapFreeFn, n int, key_bytes int,
|
||||
value_bytes int, keys voidptr, values voidptr) map {
|
||||
mut out := new_map(key_bytes, value_bytes, hash_fn, key_eq_fn, clone_fn, free_fn)
|
||||
// TODO: pre-allocate n slots
|
||||
mut pkey := &u8(keys)
|
||||
|
|
|
@ -29,7 +29,8 @@ fn new_dense_array_noscan(key_bytes int, key_noscan bool, value_bytes int, value
|
|||
}
|
||||
}
|
||||
|
||||
fn new_map_noscan_key(key_bytes int, value_bytes int, hash_fn MapHashFn, key_eq_fn MapEqFn, clone_fn MapCloneFn, free_fn MapFreeFn) map {
|
||||
fn new_map_noscan_key(key_bytes int, value_bytes int, hash_fn MapHashFn, key_eq_fn MapEqFn, clone_fn MapCloneFn,
|
||||
free_fn MapFreeFn) map {
|
||||
metasize := int(sizeof(u32) * (init_capicity + extra_metas_inc))
|
||||
// for now assume anything bigger than a pointer is a string
|
||||
has_string_keys := key_bytes > sizeof(voidptr)
|
||||
|
@ -51,7 +52,8 @@ fn new_map_noscan_key(key_bytes int, value_bytes int, hash_fn MapHashFn, key_eq_
|
|||
}
|
||||
}
|
||||
|
||||
fn new_map_noscan_value(key_bytes int, value_bytes int, hash_fn MapHashFn, key_eq_fn MapEqFn, clone_fn MapCloneFn, free_fn MapFreeFn) map {
|
||||
fn new_map_noscan_value(key_bytes int, value_bytes int, hash_fn MapHashFn, key_eq_fn MapEqFn, clone_fn MapCloneFn,
|
||||
free_fn MapFreeFn) map {
|
||||
metasize := int(sizeof(u32) * (init_capicity + extra_metas_inc))
|
||||
// for now assume anything bigger than a pointer is a string
|
||||
has_string_keys := key_bytes > sizeof(voidptr)
|
||||
|
@ -73,7 +75,8 @@ fn new_map_noscan_value(key_bytes int, value_bytes int, hash_fn MapHashFn, key_e
|
|||
}
|
||||
}
|
||||
|
||||
fn new_map_noscan_key_value(key_bytes int, value_bytes int, hash_fn MapHashFn, key_eq_fn MapEqFn, clone_fn MapCloneFn, free_fn MapFreeFn) map {
|
||||
fn new_map_noscan_key_value(key_bytes int, value_bytes int, hash_fn MapHashFn, key_eq_fn MapEqFn, clone_fn MapCloneFn,
|
||||
free_fn MapFreeFn) map {
|
||||
metasize := int(sizeof(u32) * (init_capicity + extra_metas_inc))
|
||||
// for now assume anything bigger than a pointer is a string
|
||||
has_string_keys := key_bytes > sizeof(voidptr)
|
||||
|
@ -95,7 +98,8 @@ fn new_map_noscan_key_value(key_bytes int, value_bytes int, hash_fn MapHashFn, k
|
|||
}
|
||||
}
|
||||
|
||||
fn new_map_init_noscan_key(hash_fn MapHashFn, key_eq_fn MapEqFn, clone_fn MapCloneFn, free_fn MapFreeFn, n int, key_bytes int, value_bytes int, keys voidptr, values voidptr) map {
|
||||
fn new_map_init_noscan_key(hash_fn MapHashFn, key_eq_fn MapEqFn, clone_fn MapCloneFn, free_fn MapFreeFn,
|
||||
n int, key_bytes int, value_bytes int, keys voidptr, values voidptr) map {
|
||||
mut out := new_map_noscan_key(key_bytes, value_bytes, hash_fn, key_eq_fn, clone_fn,
|
||||
free_fn)
|
||||
// TODO: pre-allocate n slots
|
||||
|
@ -111,7 +115,8 @@ fn new_map_init_noscan_key(hash_fn MapHashFn, key_eq_fn MapEqFn, clone_fn MapClo
|
|||
return out
|
||||
}
|
||||
|
||||
fn new_map_init_noscan_value(hash_fn MapHashFn, key_eq_fn MapEqFn, clone_fn MapCloneFn, free_fn MapFreeFn, n int, key_bytes int, value_bytes int, keys voidptr, values voidptr) map {
|
||||
fn new_map_init_noscan_value(hash_fn MapHashFn, key_eq_fn MapEqFn, clone_fn MapCloneFn, free_fn MapFreeFn,
|
||||
n int, key_bytes int, value_bytes int, keys voidptr, values voidptr) map {
|
||||
mut out := new_map_noscan_value(key_bytes, value_bytes, hash_fn, key_eq_fn, clone_fn,
|
||||
free_fn)
|
||||
// TODO: pre-allocate n slots
|
||||
|
@ -127,7 +132,8 @@ fn new_map_init_noscan_value(hash_fn MapHashFn, key_eq_fn MapEqFn, clone_fn MapC
|
|||
return out
|
||||
}
|
||||
|
||||
fn new_map_init_noscan_key_value(hash_fn MapHashFn, key_eq_fn MapEqFn, clone_fn MapCloneFn, free_fn MapFreeFn, n int, key_bytes int, value_bytes int, keys voidptr, values voidptr) map {
|
||||
fn new_map_init_noscan_key_value(hash_fn MapHashFn, key_eq_fn MapEqFn, clone_fn MapCloneFn, free_fn MapFreeFn,
|
||||
n int, key_bytes int, value_bytes int, keys voidptr, values voidptr) map {
|
||||
mut out := new_map_noscan_key_value(key_bytes, value_bytes, hash_fn, key_eq_fn, clone_fn,
|
||||
free_fn)
|
||||
// TODO: pre-allocate n slots
|
||||
|
|
|
@ -117,7 +117,8 @@ fn abs64(x i64) u64 {
|
|||
//---------------------------------------
|
||||
|
||||
// convert from data format to compact u64
|
||||
pub fn get_str_intp_u64_format(fmt_type StrIntpType, in_width int, in_precision int, in_tail_zeros bool, in_sign bool, in_pad_ch u8, in_base int, in_upper_case bool) u64 {
|
||||
pub fn get_str_intp_u64_format(fmt_type StrIntpType, in_width int, in_precision int, in_tail_zeros bool,
|
||||
in_sign bool, in_pad_ch u8, in_base int, in_upper_case bool) u64 {
|
||||
width := if in_width != 0 { abs64(in_width) } else { u64(0) }
|
||||
align := if in_width > 0 { u64(1 << 5) } else { u64(0) } // two bit 0 .left 1 .right, for now we use only one
|
||||
upper_case := if in_upper_case { u64(1 << 7) } else { u64(0) }
|
||||
|
@ -134,7 +135,8 @@ pub fn get_str_intp_u64_format(fmt_type StrIntpType, in_width int, in_precision
|
|||
}
|
||||
|
||||
// convert from data format to compact u32
|
||||
pub fn get_str_intp_u32_format(fmt_type StrIntpType, in_width int, in_precision int, in_tail_zeros bool, in_sign bool, in_pad_ch u8, in_base int, in_upper_case bool) u32 {
|
||||
pub fn get_str_intp_u32_format(fmt_type StrIntpType, in_width int, in_precision int, in_tail_zeros bool,
|
||||
in_sign bool, in_pad_ch u8, in_base int, in_upper_case bool) u32 {
|
||||
width := if in_width != 0 { abs64(in_width) } else { u32(0) }
|
||||
align := if in_width > 0 { u32(1 << 5) } else { u32(0) } // two bit 0 .left 1 .right, for now we use only one
|
||||
upper_case := if in_upper_case { u32(1 << 7) } else { u32(0) }
|
||||
|
|
|
@ -24,7 +24,8 @@ fn C.RegisterClassEx(class &WndClassEx) int
|
|||
|
||||
fn C.GetClipboardOwner() C.HWND
|
||||
|
||||
fn C.CreateWindowEx(dwExStyle i64, lpClassName &u16, lpWindowName &u16, dwStyle i64, x int, y int, nWidth int, nHeight int, hWndParent i64, hMenu voidptr, h_instance voidptr, lpParam voidptr) C.HWND
|
||||
fn C.CreateWindowEx(dwExStyle i64, lpClassName &u16, lpWindowName &u16, dwStyle i64, x int, y int, nWidth int,
|
||||
nHeight int, hWndParent i64, hMenu voidptr, h_instance voidptr, lpParam voidptr) C.HWND
|
||||
|
||||
// fn C.MultiByteToWideChar(CodePage u32, dw_flags u16, lpMultiByteStr byteptr, cbMultiByte int, lpWideCharStr u16, cchWideChar int) int
|
||||
fn C.EmptyClipboard()
|
||||
|
|
|
@ -41,13 +41,15 @@ fn C.XSetSelectionOwner(d &C.Display, a Atom, w Window, time int)
|
|||
|
||||
fn C.XGetSelectionOwner(d &C.Display, a Atom) Window
|
||||
|
||||
fn C.XChangeProperty(d &C.Display, requestor Window, property Atom, typ Atom, format int, mode int, data voidptr, nelements int) int
|
||||
fn C.XChangeProperty(d &C.Display, requestor Window, property Atom, typ Atom, format int, mode int, data voidptr,
|
||||
nelements int) int
|
||||
|
||||
fn C.XSendEvent(d &C.Display, requestor Window, propagate int, mask i64, event &C.XEvent)
|
||||
|
||||
fn C.XInternAtom(d &C.Display, typ &u8, only_if_exists int) Atom
|
||||
|
||||
fn C.XCreateSimpleWindow(d &C.Display, root Window, x int, y int, width u32, height u32, border_width u32, border u64, background u64) Window
|
||||
fn C.XCreateSimpleWindow(d &C.Display, root Window, x int, y int, width u32, height u32, border_width u32,
|
||||
border u64, background u64) Window
|
||||
|
||||
fn C.XOpenDisplay(name &u8) &C.Display
|
||||
|
||||
|
@ -55,7 +57,8 @@ fn C.XConvertSelection(d &C.Display, selection Atom, target Atom, property Atom,
|
|||
|
||||
fn C.XSync(d &C.Display, discard int) int
|
||||
|
||||
fn C.XGetWindowProperty(d &C.Display, w Window, property Atom, offset i64, length i64, delete int, req_type Atom, actual_type_return &Atom, actual_format_return &int, nitems &u64, bytes_after_return &u64, prop_return &&u8) int
|
||||
fn C.XGetWindowProperty(d &C.Display, w Window, property Atom, offset i64, length i64, delete int, req_type Atom,
|
||||
actual_type_return &Atom, actual_format_return &int, nitems &u64, bytes_after_return &u64, prop_return &&u8) int
|
||||
|
||||
fn C.XDeleteProperty(d &C.Display, w Window, property Atom) int
|
||||
|
||||
|
|
|
@ -4,17 +4,20 @@ fn C.SQLAllocHandle(handle_type C.SQLSMALLINT, input_handle C.SQLHANDLE, output_
|
|||
|
||||
fn C.SQLSetEnvAttr(environment_handle C.SQLHENV, attribute C.SQLINTEGER, value C.SQLPOINTER, string_length C.SQLINTEGER) C.SQLRETURN
|
||||
|
||||
fn C.SQLGetDiagRec(handle_type C.SQLSMALLINT, handle C.SQLHANDLE, rec_number C.SQLSMALLINT, sql_state &C.SQLCHAR, native_error &C.SQLINTEGER, message_text &C.SQLCHAR, buffer_length C.SQLSMALLINT, text_length &C.SQLSMALLINT) C.SQLRETURN
|
||||
fn C.SQLGetDiagRec(handle_type C.SQLSMALLINT, handle C.SQLHANDLE, rec_number C.SQLSMALLINT, sql_state &C.SQLCHAR,
|
||||
native_error &C.SQLINTEGER, message_text &C.SQLCHAR, buffer_length C.SQLSMALLINT, text_length &C.SQLSMALLINT) C.SQLRETURN
|
||||
|
||||
fn C.SQLSetConnectAttr(connection_handle C.SQLHDBC, attribute C.SQLINTEGER, value C.SQLPOINTER, string_length C.SQLINTEGER) C.SQLRETURN
|
||||
|
||||
fn C.SQLDriverConnect(hdbc C.SQLHDBC, hwnd C.SQLHWND, sz_conn_str_in &C.SQLCHAR, cb_conn_str_in C.SQLSMALLINT, sz_conn_str_out &C.SQLCHAR, cb_conn_str_out_max C.SQLSMALLINT, pcb_conn_str_out &C.SQLSMALLINT, f_driver_completion C.SQLUSMALLINT) C.SQLRETURN
|
||||
fn C.SQLDriverConnect(hdbc C.SQLHDBC, hwnd C.SQLHWND, sz_conn_str_in &C.SQLCHAR, cb_conn_str_in C.SQLSMALLINT,
|
||||
sz_conn_str_out &C.SQLCHAR, cb_conn_str_out_max C.SQLSMALLINT, pcb_conn_str_out &C.SQLSMALLINT, f_driver_completion C.SQLUSMALLINT) C.SQLRETURN
|
||||
|
||||
fn C.SQLDisconnect(connection_handle C.SQLHDBC) C.SQLRETURN
|
||||
|
||||
fn C.SQLExecDirect(statement_handle C.SQLHSTMT, statement_text &C.SQLCHAR, text_length C.SQLINTEGER) C.SQLRETURN
|
||||
|
||||
fn C.SQLBindCol(statement_handle C.SQLHSTMT, column_number C.SQLUSMALLINT, target_type C.SQLSMALLINT, target_value C.SQLPOINTER, buffer_length C.SQLLEN, str_len_or_ind &C.SQLLEN) C.SQLRETURN
|
||||
fn C.SQLBindCol(statement_handle C.SQLHSTMT, column_number C.SQLUSMALLINT, target_type C.SQLSMALLINT, target_value C.SQLPOINTER,
|
||||
buffer_length C.SQLLEN, str_len_or_ind &C.SQLLEN) C.SQLRETURN
|
||||
|
||||
fn C.SQLFetch(statement_handle C.SQLHSTMT) C.SQLRETURN
|
||||
|
||||
|
@ -22,6 +25,7 @@ fn C.SQLFreeHandle(handle_type C.SQLSMALLINT, handle C.SQLHANDLE) C.SQLRETURN
|
|||
|
||||
fn C.SQLNumResultCols(statement_handle C.SQLHSTMT, column_count &C.SQLSMALLINT) C.SQLRETURN
|
||||
|
||||
fn C.SQLColAttribute(statement_handle C.SQLHSTMT, column_number C.SQLUSMALLINT, field_identifier C.SQLUSMALLINT, character_attribute C.SQLPOINTER, buffer_length C.SQLSMALLINT, string_length C.SQLSMALLINT, numeric_attribute &C.SQLLEN) C.SQLRETURN
|
||||
fn C.SQLColAttribute(statement_handle C.SQLHSTMT, column_number C.SQLUSMALLINT, field_identifier C.SQLUSMALLINT,
|
||||
character_attribute C.SQLPOINTER, buffer_length C.SQLSMALLINT, string_length C.SQLSMALLINT, numeric_attribute &C.SQLLEN) C.SQLRETURN
|
||||
|
||||
fn C.SQLRowCount(statement_handle C.SQLHSTMT, row_count &C.SQLLEN) C.SQLRETURN
|
||||
|
|
|
@ -36,7 +36,8 @@ pub struct C.MYSQL_FIELD {
|
|||
fn C.mysql_init(mysql &C.MYSQL) &C.MYSQL
|
||||
|
||||
// C.mysql_real_connect attempts to establish a connection to a MySQL server running on `host`.
|
||||
fn C.mysql_real_connect(mysql &C.MYSQL, host &char, user &char, passwd &char, db &char, port u32, unix_socket &char, client_flag ConnectionFlag) &C.MYSQL
|
||||
fn C.mysql_real_connect(mysql &C.MYSQL, host &char, user &char, passwd &char, db &char, port u32, unix_socket &char,
|
||||
client_flag ConnectionFlag) &C.MYSQL
|
||||
|
||||
// C.mysql_query executes the SQL statement pointed to by the null-terminated string `stmt_str`.
|
||||
fn C.mysql_query(mysql &C.MYSQL, q &u8) int
|
||||
|
|
|
@ -137,7 +137,8 @@ fn C.PQnfields(const_res &C.PGresult) int
|
|||
// const char *const *paramValues
|
||||
// const int *paramLengths
|
||||
// const int *paramFormats
|
||||
fn C.PQexecParams(conn &C.PGconn, const_command &char, nParams int, const_paramTypes &int, const_paramValues &char, const_paramLengths &int, const_paramFormats &int, resultFormat int) &C.PGresult
|
||||
fn C.PQexecParams(conn &C.PGconn, const_command &char, nParams int, const_paramTypes &int, const_paramValues &char,
|
||||
const_paramLengths &int, const_paramFormats &int, resultFormat int) &C.PGresult
|
||||
|
||||
fn C.PQputCopyData(conn &C.PGconn, const_buffer &char, nbytes int) int
|
||||
|
||||
|
|
|
@ -135,7 +135,8 @@ fn example_vfs_access(vfs &sqlite.Sqlite3_vfs, zPath &char, flags int, pResOut &
|
|||
return sqlite.sqlite_ok
|
||||
}
|
||||
|
||||
fn example_vfs_open(vfs &sqlite.Sqlite3_vfs, file_name_or_null_for_tempfile &char, vfs_opened_file &sqlite.Sqlite3_file, in_flags int, out_flags &int) int {
|
||||
fn example_vfs_open(vfs &sqlite.Sqlite3_vfs, file_name_or_null_for_tempfile &char, vfs_opened_file &sqlite.Sqlite3_file,
|
||||
in_flags int, out_flags &int) int {
|
||||
println('open called')
|
||||
|
||||
mut is_temp := false
|
||||
|
|
|
@ -18,7 +18,8 @@ pub fn (ctx &Context) draw_cubic_bezier_recursive(points []f32, c Color) {
|
|||
|
||||
// draw_cubic_bezier_recursive_scalar is the same as `draw_cubic_bezier_recursive`, except that the `points` are given
|
||||
// as indiviual x,y f32 scalar parameters, and not in a single dynamic array parameter.
|
||||
pub fn (ctx &Context) draw_cubic_bezier_recursive_scalar(x1 f32, y1 f32, x2 f32, y2 f32, x3 f32, y3 f32, x4 f32, y4 f32, c Color) {
|
||||
pub fn (ctx &Context) draw_cubic_bezier_recursive_scalar(x1 f32, y1 f32, x2 f32, y2 f32, x3 f32, y3 f32,
|
||||
x4 f32, y4 f32, c Color) {
|
||||
if c.a == 0 {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -670,7 +670,8 @@ pub fn (ctx &Context) draw_circle_line(x f32, y f32, radius int, segments int, c
|
|||
}
|
||||
|
||||
// draw_slice_empty draws the outline of a circle slice/pie
|
||||
pub fn (ctx &Context) draw_slice_empty(x f32, y f32, radius f32, start_angle f32, end_angle f32, segments int, c gx.Color) {
|
||||
pub fn (ctx &Context) draw_slice_empty(x f32, y f32, radius f32, start_angle f32, end_angle f32, segments int,
|
||||
c gx.Color) {
|
||||
if segments <= 0 || radius <= 0 {
|
||||
return
|
||||
}
|
||||
|
@ -706,7 +707,8 @@ pub fn (ctx &Context) draw_slice_empty(x f32, y f32, radius f32, start_angle f32
|
|||
// `end_angle` is the angle in radians at which the slice ends.
|
||||
// `segments` affects how smooth/round the slice is.
|
||||
// `c` is the fill color.
|
||||
pub fn (ctx &Context) draw_slice_filled(x f32, y f32, radius f32, start_angle f32, end_angle f32, segments int, c gx.Color) {
|
||||
pub fn (ctx &Context) draw_slice_filled(x f32, y f32, radius f32, start_angle f32, end_angle f32, segments int,
|
||||
c gx.Color) {
|
||||
if segments <= 0 || radius < 0 {
|
||||
return
|
||||
}
|
||||
|
@ -747,7 +749,8 @@ pub fn (ctx &Context) draw_slice_filled(x f32, y f32, radius f32, start_angle f3
|
|||
// `end_angle` is the angle in radians at which the arc ends.
|
||||
// `segments` affects how smooth/round the arc is.
|
||||
// `c` is the color of the arc/outline.
|
||||
pub fn (ctx Context) draw_arc_line(x f32, y f32, radius f32, start_angle f32, end_angle f32, segments int, c gx.Color) {
|
||||
pub fn (ctx Context) draw_arc_line(x f32, y f32, radius f32, start_angle f32, end_angle f32, segments int,
|
||||
c gx.Color) {
|
||||
if segments <= 0 || radius < 0 {
|
||||
return
|
||||
}
|
||||
|
@ -794,7 +797,8 @@ pub fn (ctx Context) draw_arc_line(x f32, y f32, radius f32, start_angle f32, en
|
|||
// `end_angle` is the angle in radians at which the arc ends.
|
||||
// `segments` affects how smooth/round the arc is.
|
||||
// `c` is the color of the arc outline.
|
||||
pub fn (ctx &Context) draw_arc_empty(x f32, y f32, inner_radius f32, thickness f32, start_angle f32, end_angle f32, segments int, c gx.Color) {
|
||||
pub fn (ctx &Context) draw_arc_empty(x f32, y f32, inner_radius f32, thickness f32, start_angle f32, end_angle f32,
|
||||
segments int, c gx.Color) {
|
||||
outer_radius := inner_radius + thickness
|
||||
if segments <= 0 || outer_radius < 0 {
|
||||
return
|
||||
|
@ -857,7 +861,8 @@ pub fn (ctx &Context) draw_arc_empty(x f32, y f32, inner_radius f32, thickness f
|
|||
// `end_angle` is the angle in radians at which the arc ends.
|
||||
// `segments` affects how smooth/round the arc is.
|
||||
// `c` is the fill color of the arc.
|
||||
pub fn (ctx &Context) draw_arc_filled(x f32, y f32, inner_radius f32, thickness f32, start_angle f32, end_angle f32, segments int, c gx.Color) {
|
||||
pub fn (ctx &Context) draw_arc_filled(x f32, y f32, inner_radius f32, thickness f32, start_angle f32, end_angle f32,
|
||||
segments int, c gx.Color) {
|
||||
outer_radius := inner_radius + thickness
|
||||
if segments <= 0 || outer_radius < 0 {
|
||||
return
|
||||
|
|
|
@ -15,7 +15,9 @@ pub fn (ctx &Context) has_text_style() bool {
|
|||
return false
|
||||
}
|
||||
|
||||
pub fn (ctx &Context) set_text_style(font_name string, font_path string, size int, color gx.Color, align int, vertical_align int) {}
|
||||
pub fn (ctx &Context) set_text_style(font_name string, font_path string, size int, color gx.Color, align int,
|
||||
vertical_align int) {
|
||||
}
|
||||
|
||||
// default draw_text (draw_text_def but without set_text_cfg)
|
||||
pub fn (ctx &Context) draw_text_default(x int, y int, text string) {
|
||||
|
|
|
@ -88,7 +88,8 @@ fn C.getpeername(sockfd int, addr &Addr, addlen &u32) int
|
|||
|
||||
fn C.inet_ntop(af AddrFamily, src voidptr, dst &char, dst_size int) &char
|
||||
|
||||
fn C.WSAAddressToStringA(lpsaAddress &Addr, dwAddressLength u32, lpProtocolInfo voidptr, lpszAddressString &char, lpdwAddressStringLength &u32) int
|
||||
fn C.WSAAddressToStringA(lpsaAddress &Addr, dwAddressLength u32, lpProtocolInfo voidptr, lpszAddressString &char,
|
||||
lpdwAddressStringLength &u32) int
|
||||
|
||||
// fn C.getsockname(sockfd int, addr &C.sockaddr, addrlen &C.socklen_t) int
|
||||
fn C.getsockname(sockfd int, addr &C.sockaddr, addrlen &u32) int
|
||||
|
|
|
@ -19,7 +19,8 @@ pub fn (mut d TerminalStreamingDownloader) on_start(mut request Request, path st
|
|||
}
|
||||
|
||||
// on_chunk is called multiple times, once per chunk of received content.
|
||||
pub fn (mut d TerminalStreamingDownloader) on_chunk(request &Request, chunk []u8, already_received u64, expected u64) ! {
|
||||
pub fn (mut d TerminalStreamingDownloader) on_chunk(request &Request, chunk []u8, already_received u64,
|
||||
expected u64) ! {
|
||||
now := time.now()
|
||||
elapsed := now - d.start_time
|
||||
// delta_elapsed := now - d.past_time
|
||||
|
|
|
@ -170,7 +170,8 @@ fn C.mbedtls_ssl_setup(&C.mbedtls_ssl_context, &C.mbedtls_ssl_config) int
|
|||
fn C.mbedtls_ssl_session_reset(&C.mbedtls_ssl_context)
|
||||
fn C.mbedtls_ssl_conf_authmode(&C.mbedtls_ssl_config, int)
|
||||
fn C.mbedtls_ssl_conf_rng(&C.mbedtls_ssl_config, fn (voidptr, &u8, usize) int, &C.mbedtls_ctr_drbg_context)
|
||||
fn C.mbedtls_ssl_set_bio(&C.mbedtls_ssl_context, &C.mbedtls_net_context, &C.mbedtls_ssl_send_t, &C.mbedtls_ssl_recv_t, &C.mbedtls_ssl_recv_timeout_t)
|
||||
fn C.mbedtls_ssl_set_bio(&C.mbedtls_ssl_context, &C.mbedtls_net_context, &C.mbedtls_ssl_send_t, &C.mbedtls_ssl_recv_t,
|
||||
&C.mbedtls_ssl_recv_timeout_t)
|
||||
fn C.mbedtls_ssl_conf_own_cert(&C.mbedtls_ssl_config, &C.mbedtls_x509_crt, &C.mbedtls_pk_context) int
|
||||
fn C.mbedtls_ssl_conf_ca_chain(&C.mbedtls_ssl_config, &C.mbedtls_x509_crt, &C.mbedtls_x509_crl)
|
||||
fn C.mbedtls_ssl_set_hostname(&C.mbedtls_ssl_context, &char) int
|
||||
|
@ -184,7 +185,8 @@ fn C.mbedtls_ssl_config_free(&C.mbedtls_ssl_config)
|
|||
|
||||
fn C.mbedtls_pk_init(&C.mbedtls_pk_context)
|
||||
fn C.mbedtls_pk_free(&C.mbedtls_pk_context)
|
||||
fn C.mbedtls_pk_parse_key(&C.mbedtls_pk_context, &u8, usize, &u8, usize, fn (voidptr, &u8, usize) int, voidptr) int
|
||||
fn C.mbedtls_pk_parse_key(&C.mbedtls_pk_context, &u8, usize, &u8, usize, fn (voidptr, &u8, usize) int,
|
||||
voidptr) int
|
||||
fn C.mbedtls_pk_parse_keyfile(&C.mbedtls_pk_context, &char, &char, fn (voidptr, &u8, usize) int, voidptr) int
|
||||
|
||||
fn C.mbedtls_ctr_drbg_init(&C.mbedtls_ctr_drbg_context)
|
||||
|
|
|
@ -207,7 +207,8 @@ pub interface Connection {
|
|||
// num - Stmt uses nums at prepared statements (? or ?1)
|
||||
// qm - Character for prepared statement (qm for question mark, as in sqlite)
|
||||
// start_pos - When num is true, it's the start position of the counter
|
||||
pub fn orm_stmt_gen(sql_dialect SQLDialect, table string, q string, kind StmtKind, num bool, qm string, start_pos int, data QueryData, where QueryData) (string, QueryData) {
|
||||
pub fn orm_stmt_gen(sql_dialect SQLDialect, table string, q string, kind StmtKind, num bool, qm string,
|
||||
start_pos int, data QueryData, where QueryData) (string, QueryData) {
|
||||
mut str := ''
|
||||
mut c := start_pos
|
||||
mut data_fields := []string{}
|
||||
|
@ -432,7 +433,8 @@ fn gen_where_clause(where QueryData, q string, qm string, num bool, mut c &int)
|
|||
// fields - See TableField
|
||||
// sql_from_v - Function which maps type indices to sql type names
|
||||
// alternative - Needed for msdb
|
||||
pub fn orm_table_gen(table string, q string, defaults bool, def_unique_len int, fields []TableField, sql_from_v fn (int) !string, alternative bool) !string {
|
||||
pub fn orm_table_gen(table string, q string, defaults bool, def_unique_len int, fields []TableField, sql_from_v fn (int) !string,
|
||||
alternative bool) !string {
|
||||
mut str := 'CREATE TABLE IF NOT EXISTS ${q}${table}${q} ('
|
||||
|
||||
if alternative {
|
||||
|
|
|
@ -6,7 +6,8 @@ fn C.GenerateConsoleCtrlEvent(event u32, pgid u32) bool
|
|||
fn C.GetModuleHandleA(name &char) HMODULE
|
||||
fn C.GetProcAddress(handle voidptr, procname &u8) voidptr
|
||||
fn C.TerminateProcess(process HANDLE, exit_code u32) bool
|
||||
fn C.PeekNamedPipe(hNamedPipe voidptr, lpBuffer voidptr, nBufferSize int, lpBytesRead voidptr, lpTotalBytesAvail voidptr, lpBytesLeftThisMessage voidptr) bool
|
||||
fn C.PeekNamedPipe(hNamedPipe voidptr, lpBuffer voidptr, nBufferSize int, lpBytesRead voidptr, lpTotalBytesAvail voidptr,
|
||||
lpBytesLeftThisMessage voidptr) bool
|
||||
|
||||
type FN_NTSuspendResume = fn (voidptr) u64
|
||||
|
||||
|
|
|
@ -220,13 +220,15 @@ pub fn (mut desc C.sg_shader_desc) set_frag_uniform_block_size(block_index int,
|
|||
return desc
|
||||
}
|
||||
|
||||
pub fn (mut desc C.sg_shader_desc) set_vert_uniform(block_index int, uniform_index int, name string, @type UniformType, array_count int) &ShaderDesc {
|
||||
pub fn (mut desc C.sg_shader_desc) set_vert_uniform(block_index int, uniform_index int, name string, @type UniformType,
|
||||
array_count int) &ShaderDesc {
|
||||
desc.vs.uniform_blocks[block_index].uniforms[uniform_index].name = &char(name.str)
|
||||
desc.vs.uniform_blocks[block_index].uniforms[uniform_index].@type = @type
|
||||
return desc
|
||||
}
|
||||
|
||||
pub fn (mut desc C.sg_shader_desc) set_frag_uniform(block_index int, uniform_index int, name string, @type UniformType, array_count int) &ShaderDesc {
|
||||
pub fn (mut desc C.sg_shader_desc) set_frag_uniform(block_index int, uniform_index int, name string, @type UniformType,
|
||||
array_count int) &ShaderDesc {
|
||||
desc.fs.uniform_blocks[block_index].uniforms[uniform_index].name = &char(name.str)
|
||||
desc.fs.uniform_blocks[block_index].uniforms[uniform_index].@type = @type
|
||||
return desc
|
||||
|
|
|
@ -31,7 +31,8 @@ pub fn sfree(ptr voidptr, user_data voidptr) {
|
|||
|
||||
fn C.SOKOL_LOG(const_message &char)
|
||||
|
||||
pub fn slog(const_tag &char, log_level u32, log_item_id u32, const_message_or_null &char, line_nr u32, const_filename_or_null &char, user_data voidptr) {
|
||||
pub fn slog(const_tag &char, log_level u32, log_item_id u32, const_message_or_null &char, line_nr u32,
|
||||
const_filename_or_null &char, user_data voidptr) {
|
||||
C.fprintf(C.stderr, c'sokol.memory.slog | user_data: %p, const_tag: %s, level: %d, item_id: %d, fname: %s, line: %d, message: %s\n',
|
||||
user_data, const_tag, log_level, log_item_id, const_filename_or_null, line_nr,
|
||||
const_message_or_null)
|
||||
|
|
|
@ -224,7 +224,8 @@ pub fn perspective(fov_y f32, aspect f32, z_near f32, z_far f32) {
|
|||
}
|
||||
|
||||
@[inline]
|
||||
pub fn lookat(eye_x f32, eye_y f32, eye_z f32, center_x f32, center_y f32, center_z f32, up_x f32, up_y f32, up_z f32) {
|
||||
pub fn lookat(eye_x f32, eye_y f32, eye_z f32, center_x f32, center_y f32, center_z f32, up_x f32, up_y f32,
|
||||
up_z f32) {
|
||||
C.sgl_lookat(eye_x, eye_y, eye_z, center_x, center_y, center_z, up_x, up_y, up_z)
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,8 @@ fn C.sgl_translate(x f32, y f32, z f32)
|
|||
fn C.sgl_frustum(l f32, r f32, b f32, t f32, n f32, f f32)
|
||||
fn C.sgl_ortho(l f32, r f32, b f32, t f32, n f32, f f32)
|
||||
fn C.sgl_perspective(fov_y f32, aspect f32, z_near f32, z_far f32)
|
||||
fn C.sgl_lookat(eye_x f32, eye_y f32, eye_z f32, center_x f32, center_y f32, center_z f32, up_x f32, up_y f32, up_z f32)
|
||||
fn C.sgl_lookat(eye_x f32, eye_y f32, eye_z f32, center_x f32, center_y f32, center_z f32, up_x f32, up_y f32,
|
||||
up_z f32)
|
||||
fn C.sgl_push_matrix()
|
||||
fn C.sgl_pop_matrix()
|
||||
|
||||
|
|
|
@ -154,7 +154,8 @@ pub fn load_from_memory(buf &u8, bufsize int, params LoadParams) !Image {
|
|||
// Resize functions
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
fn C.stbir_resize_uint8_linear(input_pixels &u8, input_w int, input_h int, input_stride_in_bytes int, output_pixels &u8, output_w int, output_h int, output_stride_in_bytes int, num_channels int) int
|
||||
fn C.stbir_resize_uint8_linear(input_pixels &u8, input_w int, input_h int, input_stride_in_bytes int, output_pixels &u8,
|
||||
output_w int, output_h int, output_stride_in_bytes int, num_channels int) int
|
||||
|
||||
// resize_uint8 resizes `img` to dimensions of `output_w` and `output_h`
|
||||
pub fn resize_uint8(img &Image, output_w int, output_h int) !Image {
|
||||
|
|
|
@ -53,7 +53,8 @@ fn C.SetConsoleTitle(title &u16) bool
|
|||
fn C.SetConsoleCursorPosition(handle C.HANDLE, coord C.COORD) bool
|
||||
|
||||
// ref - https://docs.microsoft.com/en-us/windows/console/scrollconsolescreenbuffer
|
||||
fn C.ScrollConsoleScreenBuffer(output C.HANDLE, scroll_rect &C.SMALL_RECT, clip_rect &C.SMALL_RECT, des C.COORD, fill &C.CHAR_INFO) bool
|
||||
fn C.ScrollConsoleScreenBuffer(output C.HANDLE, scroll_rect &C.SMALL_RECT, clip_rect &C.SMALL_RECT, des C.COORD,
|
||||
fill &C.CHAR_INFO) bool
|
||||
|
||||
// get_terminal_size returns a number of columns and rows of terminal window.
|
||||
pub fn get_terminal_size() (int, int) {
|
||||
|
|
|
@ -37,7 +37,8 @@ fn C.GetSystemTimeAsFileTime(lpSystemTimeAsFileTime &C._FILETIME)
|
|||
|
||||
fn C.FileTimeToSystemTime(lpFileTime &C._FILETIME, lpSystemTime &SystemTime)
|
||||
|
||||
fn C.SystemTimeToTzSpecificLocalTime(lpTimeZoneInformation &C.TIME_ZONE_INFORMATION, lpUniversalTime &SystemTime, lpLocalTime &SystemTime)
|
||||
fn C.SystemTimeToTzSpecificLocalTime(lpTimeZoneInformation &C.TIME_ZONE_INFORMATION, lpUniversalTime &SystemTime,
|
||||
lpLocalTime &SystemTime)
|
||||
|
||||
fn C.localtime_s(t &C.time_t, tm &C.tm)
|
||||
|
||||
|
|
|
@ -84,11 +84,11 @@ pub fn (t &Table) stringify_anon_decl(node &AnonFn, cur_mod string, m2a map[stri
|
|||
}
|
||||
f.write_string('] ')
|
||||
}
|
||||
t.stringify_fn_after_name(node.decl, mut f, cur_mod, m2a)
|
||||
t.stringify_fn_after_name(node.decl, mut f, cur_mod, m2a, false)
|
||||
return f.str()
|
||||
}
|
||||
|
||||
pub fn (t &Table) stringify_fn_decl(node &FnDecl, cur_mod string, m2a map[string]string) string {
|
||||
pub fn (t &Table) stringify_fn_decl(node &FnDecl, cur_mod string, m2a map[string]string, needs_wrap bool) string {
|
||||
mut f := strings.new_builder(30)
|
||||
if node.is_pub {
|
||||
f.write_string('pub ')
|
||||
|
@ -132,11 +132,12 @@ pub fn (t &Table) stringify_fn_decl(node &FnDecl, cur_mod string, m2a map[string
|
|||
if name in ['+', '-', '*', '/', '%', '<', '>', '==', '!=', '>=', '<='] {
|
||||
f.write_string(' ')
|
||||
}
|
||||
t.stringify_fn_after_name(node, mut f, cur_mod, m2a)
|
||||
t.stringify_fn_after_name(node, mut f, cur_mod, m2a, needs_wrap)
|
||||
return f.str()
|
||||
}
|
||||
|
||||
fn (t &Table) stringify_fn_after_name(node &FnDecl, mut f strings.Builder, cur_mod string, m2a map[string]string) {
|
||||
fn (t &Table) stringify_fn_after_name(node &FnDecl, mut f strings.Builder, cur_mod string, m2a map[string]string,
|
||||
needs_wrap bool) {
|
||||
mut add_para_types := true
|
||||
mut is_wrap_needed := false
|
||||
if node.generic_names.len > 0 {
|
||||
|
@ -162,6 +163,7 @@ fn (t &Table) stringify_fn_after_name(node &FnDecl, mut f strings.Builder, cur_m
|
|||
}
|
||||
}
|
||||
f.write_string('(')
|
||||
mut last_len := 0
|
||||
for i, param in node.params {
|
||||
// skip receiver
|
||||
if node.is_method && i == 0 {
|
||||
|
@ -228,7 +230,12 @@ fn (t &Table) stringify_fn_after_name(node &FnDecl, mut f strings.Builder, cur_m
|
|||
}
|
||||
}
|
||||
if !is_last_param {
|
||||
f.write_string(', ')
|
||||
if needs_wrap && f.len - last_len > 100 {
|
||||
last_len = f.len
|
||||
f.write_string(',\n\t')
|
||||
} else {
|
||||
f.write_string(', ')
|
||||
}
|
||||
}
|
||||
}
|
||||
f.write_string(')')
|
||||
|
|
|
@ -593,7 +593,8 @@ pub fn (mut b Builder) print_warnings_and_errors() {
|
|||
for stmt in file.stmts {
|
||||
if stmt is ast.FnDecl {
|
||||
if stmt.name == fn_name {
|
||||
fheader := b.table.stringify_fn_decl(&stmt, 'main', map[string]string{})
|
||||
fheader := b.table.stringify_fn_decl(&stmt, 'main', map[string]string{},
|
||||
false)
|
||||
redefines << FunctionRedefinition{
|
||||
fpath: file.path
|
||||
fline: stmt.pos.line_nr
|
||||
|
|
|
@ -613,7 +613,8 @@ fn (mut c Checker) check_shift(mut node ast.InfixExpr, left_type_ ast.Type, righ
|
|||
return left_type
|
||||
}
|
||||
|
||||
fn (mut c Checker) promote_keeping_aliases(left_type ast.Type, right_type ast.Type, left_kind ast.Kind, right_kind ast.Kind) ast.Type {
|
||||
fn (mut c Checker) promote_keeping_aliases(left_type ast.Type, right_type ast.Type, left_kind ast.Kind,
|
||||
right_kind ast.Kind) ast.Type {
|
||||
if left_type == right_type && left_kind == .alias && right_kind == .alias {
|
||||
return left_type
|
||||
}
|
||||
|
|
|
@ -604,7 +604,8 @@ fn (mut c Checker) alias_type_decl(node ast.AliasTypeDecl) {
|
|||
}
|
||||
}
|
||||
|
||||
fn (mut c Checker) check_alias_vs_element_type_of_parent(node ast.AliasTypeDecl, element_type_of_parent ast.Type, label string) {
|
||||
fn (mut c Checker) check_alias_vs_element_type_of_parent(node ast.AliasTypeDecl, element_type_of_parent ast.Type,
|
||||
label string) {
|
||||
if node.typ.idx() != element_type_of_parent.idx() {
|
||||
return
|
||||
}
|
||||
|
@ -1970,7 +1971,8 @@ fn (mut c Checker) enum_decl(mut node ast.EnumDecl) {
|
|||
}
|
||||
}
|
||||
|
||||
fn (mut c Checker) check_enum_field_integer_literal(expr ast.IntegerLiteral, is_signed bool, is_multi_allowed bool, styp string, pos token.Pos, mut useen []u64, umin u64, umax u64, mut iseen []i64, imin i64, imax i64) {
|
||||
fn (mut c Checker) check_enum_field_integer_literal(expr ast.IntegerLiteral, is_signed bool, is_multi_allowed bool,
|
||||
styp string, pos token.Pos, mut useen []u64, umin u64, umax u64, mut iseen []i64, imin i64, imax i64) {
|
||||
mut overflows := false
|
||||
mut uval := u64(0)
|
||||
mut ival := i64(0)
|
||||
|
@ -3971,7 +3973,8 @@ fn (mut c Checker) concat_expr(mut node ast.ConcatExpr) ast.Type {
|
|||
}
|
||||
|
||||
// smartcast takes the expression with the current type which should be smartcasted to the target type in the given scope
|
||||
fn (mut c Checker) smartcast(mut expr ast.Expr, cur_type ast.Type, to_type_ ast.Type, mut scope ast.Scope, is_comptime bool) {
|
||||
fn (mut c Checker) smartcast(mut expr ast.Expr, cur_type ast.Type, to_type_ ast.Type, mut scope ast.Scope,
|
||||
is_comptime bool) {
|
||||
sym := c.table.sym(cur_type)
|
||||
to_type := if sym.kind == .interface_ && c.table.sym(to_type_).kind != .interface_ {
|
||||
to_type_.ref()
|
||||
|
@ -4474,12 +4477,14 @@ fn (mut c Checker) prefix_expr(mut node ast.PrefixExpr) ast.Type {
|
|||
return right_type
|
||||
}
|
||||
|
||||
fn (mut c Checker) type_error_for_operator(op_label string, types_label string, found_type_label string, pos token.Pos) {
|
||||
fn (mut c Checker) type_error_for_operator(op_label string, types_label string, found_type_label string,
|
||||
pos token.Pos) {
|
||||
c.error('operator `${op_label}` can only be used with ${types_label} types, but the value after `${op_label}` is of type `${found_type_label}` instead',
|
||||
pos)
|
||||
}
|
||||
|
||||
fn (mut c Checker) check_index(typ_sym &ast.TypeSymbol, index ast.Expr, index_type ast.Type, pos token.Pos, range_index bool, is_gated bool) {
|
||||
fn (mut c Checker) check_index(typ_sym &ast.TypeSymbol, index ast.Expr, index_type ast.Type, pos token.Pos,
|
||||
range_index bool, is_gated bool) {
|
||||
if typ_sym.kind in [.array, .array_fixed, .string] {
|
||||
index_type_sym := c.table.sym(index_type)
|
||||
if !(index_type.is_int() || index_type_sym.kind == .enum_
|
||||
|
@ -5173,7 +5178,8 @@ fn (mut c Checker) check_unused_labels() {
|
|||
}
|
||||
}
|
||||
|
||||
fn (mut c Checker) deprecate_old_isreftype_and_sizeof_of_a_guessed_type(is_guessed_type bool, typ ast.Type, pos token.Pos, label string) {
|
||||
fn (mut c Checker) deprecate_old_isreftype_and_sizeof_of_a_guessed_type(is_guessed_type bool, typ ast.Type,
|
||||
pos token.Pos, label string) {
|
||||
if is_guessed_type {
|
||||
styp := c.table.type_to_str(typ)
|
||||
c.note('`${label}(${styp})` is deprecated. Use `v fmt -w .` to convert it to `${label}[${styp}]()` instead.',
|
||||
|
|
|
@ -596,7 +596,8 @@ fn (mut c Checker) check_elements_ref_fields_initialized(typ ast.Type, pos &toke
|
|||
}
|
||||
|
||||
// Recursively check the element, and its children for ref uninitialized fields
|
||||
fn (mut c Checker) do_check_elements_ref_fields_initialized(sym &ast.TypeSymbol, mut checked_types []ast.Type, pos &token.Pos) {
|
||||
fn (mut c Checker) do_check_elements_ref_fields_initialized(sym &ast.TypeSymbol, mut checked_types []ast.Type,
|
||||
pos &token.Pos) {
|
||||
if sym.info is ast.Struct {
|
||||
linked_name := sym.name
|
||||
// For now, let's call this method and give a notice instead of an error.
|
||||
|
|
|
@ -451,7 +451,8 @@ fn (mut c Checker) fetch_and_check_orm_fields(info ast.Struct, pos token.Pos, ta
|
|||
|
||||
// check_sql_value_expr_is_comptime_with_natural_number_or_expr_with_int_type checks that an expression is compile-time
|
||||
// and contains an integer greater than or equal to zero or it is a runtime expression with an integer type.
|
||||
fn (mut c Checker) check_sql_value_expr_is_comptime_with_natural_number_or_expr_with_int_type(mut expr ast.Expr, sql_keyword string) {
|
||||
fn (mut c Checker) check_sql_value_expr_is_comptime_with_natural_number_or_expr_with_int_type(mut expr ast.Expr,
|
||||
sql_keyword string) {
|
||||
comptime_number := c.get_comptime_number_value(mut expr) or {
|
||||
c.check_sql_expr_type_is_int(expr, sql_keyword)
|
||||
return
|
||||
|
@ -543,7 +544,8 @@ fn (mut c Checker) check_expr_has_no_fn_calls_with_non_orm_return_type(expr &ast
|
|||
// check_where_expr_has_no_pointless_exprs checks that an expression has no pointless expressions
|
||||
// which don't affect the result. For example, `where 3` is pointless.
|
||||
// Also, it checks that the left side of the infix expression is always the structure field.
|
||||
fn (mut c Checker) check_where_expr_has_no_pointless_exprs(table_type_symbol &ast.TypeSymbol, field_names []string, expr &ast.Expr) {
|
||||
fn (mut c Checker) check_where_expr_has_no_pointless_exprs(table_type_symbol &ast.TypeSymbol, field_names []string,
|
||||
expr &ast.Expr) {
|
||||
// Skip type checking for generated subqueries
|
||||
// that are not linked to scope and vars but only created for cgen.
|
||||
if expr is ast.None {
|
||||
|
|
|
@ -942,7 +942,8 @@ or use an explicit `unsafe{ a[..] }`, if you do not want a copy of the slice.',
|
|||
}
|
||||
|
||||
// Recursively check whether the struct type field is initialized
|
||||
fn (mut c Checker) check_ref_fields_initialized(struct_sym &ast.TypeSymbol, mut checked_types []ast.Type, linked_name string, pos &token.Pos) {
|
||||
fn (mut c Checker) check_ref_fields_initialized(struct_sym &ast.TypeSymbol, mut checked_types []ast.Type,
|
||||
linked_name string, pos &token.Pos) {
|
||||
if (c.pref.translated || c.file.is_translated) || struct_sym.language == .c {
|
||||
return
|
||||
}
|
||||
|
@ -984,7 +985,8 @@ fn (mut c Checker) check_ref_fields_initialized(struct_sym &ast.TypeSymbol, mut
|
|||
// This method is temporary and will only be called by the do_check_elements_ref_fields_initialized() method.
|
||||
// The goal is to give only a notice, not an error, for now. After a while,
|
||||
// when we change the notice to error, we can remove this temporary method.
|
||||
fn (mut c Checker) check_ref_fields_initialized_note(struct_sym &ast.TypeSymbol, mut checked_types []ast.Type, linked_name string, pos &token.Pos) {
|
||||
fn (mut c Checker) check_ref_fields_initialized_note(struct_sym &ast.TypeSymbol, mut checked_types []ast.Type,
|
||||
linked_name string, pos &token.Pos) {
|
||||
if (c.pref.translated || c.file.is_translated) || struct_sym.language == .c {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -182,11 +182,13 @@ fn (mut tasks Tasks) add_checked_run(voptions string, result_extension string, t
|
|||
tasks.add('', checker_dir, voptions, result_extension, tests, false)
|
||||
}
|
||||
|
||||
fn (mut tasks Tasks) add(custom_vexe string, dir string, voptions string, result_extension string, tests []string, is_module bool) {
|
||||
fn (mut tasks Tasks) add(custom_vexe string, dir string, voptions string, result_extension string, tests []string,
|
||||
is_module bool) {
|
||||
tasks.add_evars('', custom_vexe, dir, voptions, result_extension, tests, is_module)
|
||||
}
|
||||
|
||||
fn (mut tasks Tasks) add_evars(evars string, custom_vexe string, dir string, voptions string, result_extension string, tests []string, is_module bool) {
|
||||
fn (mut tasks Tasks) add_evars(evars string, custom_vexe string, dir string, voptions string, result_extension string,
|
||||
tests []string, is_module bool) {
|
||||
max_ntries := get_max_ntries()
|
||||
paths := vtest.filter_vtest_only(tests, basepath: dir)
|
||||
for path in paths {
|
||||
|
|
|
@ -142,7 +142,7 @@ pub fn (mut d Doc) stmt_signature(stmt ast.Stmt) string {
|
|||
return 'module ${stmt.name}'
|
||||
}
|
||||
ast.FnDecl {
|
||||
return d.table.stringify_fn_decl(&stmt, d.fmt.cur_mod, d.fmt.mod2alias)
|
||||
return d.table.stringify_fn_decl(&stmt, d.fmt.cur_mod, d.fmt.mod2alias, false)
|
||||
}
|
||||
else {
|
||||
d.fmt.out = strings.new_builder(1000)
|
||||
|
|
|
@ -1083,7 +1083,7 @@ pub fn (mut f Fmt) enum_decl(node ast.EnumDecl) {
|
|||
|
||||
pub fn (mut f Fmt) fn_decl(node ast.FnDecl) {
|
||||
f.attrs(node.attrs)
|
||||
f.write(f.table.stringify_fn_decl(&node, f.cur_mod, f.mod2alias))
|
||||
f.write(f.table.stringify_fn_decl(&node, f.cur_mod, f.mod2alias, true))
|
||||
// Handle trailing comments after fn header declarations
|
||||
if node.no_body && node.end_comments.len > 0 {
|
||||
first_comment := node.end_comments[0]
|
||||
|
@ -1409,7 +1409,8 @@ pub fn (mut f Fmt) interface_decl(node ast.InterfaceDecl) {
|
|||
f.writeln('}\n')
|
||||
}
|
||||
|
||||
pub fn (mut f Fmt) calculate_alignment(fields []ast.StructField, mut field_aligns []AlignInfo, mut comment_aligns []AlignInfo, mut default_expr_aligns []AlignInfo, mut field_types []string) {
|
||||
pub fn (mut f Fmt) calculate_alignment(fields []ast.StructField, mut field_aligns []AlignInfo, mut comment_aligns []AlignInfo,
|
||||
mut default_expr_aligns []AlignInfo, mut field_types []string) {
|
||||
// Calculate the alignments first
|
||||
for i, field in fields {
|
||||
ft := f.no_cur_mod(f.table.type_to_str_using_aliases(field.typ, f.mod2alias))
|
||||
|
@ -1485,7 +1486,7 @@ pub fn (mut f Fmt) interface_method(method ast.FnDecl) {
|
|||
f.comments(before_comments, level: .indent)
|
||||
}
|
||||
f.write('\t')
|
||||
f.write(f.table.stringify_fn_decl(&method, f.cur_mod, f.mod2alias).all_after_first('fn '))
|
||||
f.write(f.table.stringify_fn_decl(&method, f.cur_mod, f.mod2alias, false).all_after_first('fn '))
|
||||
f.comments(end_comments, same_line: true, has_nl: false, level: .indent)
|
||||
f.writeln('')
|
||||
f.comments(method.next_comments, level: .indent)
|
||||
|
|
12
vlib/v/fmt/tests/fn_with_long_args_keep.vv
Normal file
12
vlib/v/fmt/tests/fn_with_long_args_keep.vv
Normal file
|
@ -0,0 +1,12 @@
|
|||
fn process_keyholder1(super_long_argument1 string, super_long_argument2 string, super_long_argument3 string,
|
||||
super_long_argument4 string, super_long_argument5 string) string {
|
||||
return ''
|
||||
}
|
||||
|
||||
fn process_keyholder2(super_long_argument1 string, super_long_argument2 string, super_long_argument3 string,
|
||||
super_long_argument4 string, super_long_argument5 string, super_long_argument6 string, super_long_argument7 string,
|
||||
super_long_argument8 string) string {
|
||||
return ''
|
||||
}
|
||||
|
||||
fn main() {}
|
|
@ -279,7 +279,8 @@ fn (mut g Gen) struct_has_array_or_map_field(elem_typ ast.Type) bool {
|
|||
}
|
||||
|
||||
// `[]int{len: 6, cap: 10, init: index * index}`
|
||||
fn (mut g Gen) array_init_with_fields(node ast.ArrayInit, elem_type Type, is_amp bool, shared_styp string, var_name string) {
|
||||
fn (mut g Gen) array_init_with_fields(node ast.ArrayInit, elem_type Type, is_amp bool, shared_styp string,
|
||||
var_name string) {
|
||||
prev_inside_lambda := g.inside_lambda
|
||||
g.inside_lambda = true
|
||||
defer {
|
||||
|
@ -1393,7 +1394,8 @@ fn (mut g Gen) write_prepared_tmp_value(tmp string, node &ast.CallExpr, tmp_styp
|
|||
return has_infix_left_var_name
|
||||
}
|
||||
|
||||
fn (mut g Gen) write_prepared_var(var_name string, inp_info ast.Array, inp_elem_type string, tmp string, i string) {
|
||||
fn (mut g Gen) write_prepared_var(var_name string, inp_info ast.Array, inp_elem_type string, tmp string,
|
||||
i string) {
|
||||
if g.table.sym(inp_info.elem_type).kind == .array_fixed {
|
||||
g.writeln('${inp_elem_type} ${var_name};')
|
||||
g.writeln('memcpy(&${var_name}, ((${inp_elem_type}*) ${tmp}_orig.data)[${i}], sizeof(${inp_elem_type}));')
|
||||
|
|
|
@ -7,7 +7,8 @@ import v.ast
|
|||
import v.util
|
||||
import v.token
|
||||
|
||||
fn (mut g Gen) expr_with_opt_or_block(expr ast.Expr, expr_typ ast.Type, var_expr ast.Expr, ret_typ ast.Type, in_heap bool) {
|
||||
fn (mut g Gen) expr_with_opt_or_block(expr ast.Expr, expr_typ ast.Type, var_expr ast.Expr, ret_typ ast.Type,
|
||||
in_heap bool) {
|
||||
gen_or := expr is ast.Ident && expr.or_expr.kind != .absent
|
||||
if gen_or {
|
||||
old_inside_opt_or_res := g.inside_opt_or_res
|
||||
|
|
|
@ -1111,7 +1111,8 @@ fn c_struct_ptr(sym &ast.TypeSymbol, typ ast.Type, expects_ptr bool) string {
|
|||
return ''
|
||||
}
|
||||
|
||||
fn struct_auto_str_func(sym &ast.TypeSymbol, lang ast.Language, _field_type ast.Type, fn_name string, field_name string, has_custom_str bool, expects_ptr bool) (string, bool) {
|
||||
fn struct_auto_str_func(sym &ast.TypeSymbol, lang ast.Language, _field_type ast.Type, fn_name string, field_name string,
|
||||
has_custom_str bool, expects_ptr bool) (string, bool) {
|
||||
$if trace_autostr ? {
|
||||
eprintln('> struct_auto_str_func: ${sym.name} | field_type.debug() | ${fn_name} | ${field_name} | ${has_custom_str} | ${expects_ptr}')
|
||||
}
|
||||
|
|
|
@ -2493,7 +2493,8 @@ fn (mut g Gen) write_sumtype_casting_fn(fun SumtypeCastingFn) {
|
|||
g.auto_fn_definitions << sb.str()
|
||||
}
|
||||
|
||||
fn (mut g Gen) call_cfn_for_casting_expr(fname string, expr ast.Expr, exp_is_ptr bool, exp_styp string, got_is_ptr bool, got_is_fn bool, got_styp string) {
|
||||
fn (mut g Gen) call_cfn_for_casting_expr(fname string, expr ast.Expr, exp_is_ptr bool, exp_styp string,
|
||||
got_is_ptr bool, got_is_fn bool, got_styp string) {
|
||||
mut rparen_n := 1
|
||||
if exp_is_ptr {
|
||||
g.write('HEAP(${exp_styp}, ')
|
||||
|
@ -3086,7 +3087,8 @@ fn (mut g Gen) print_autofree_var(var ast.Var, comment string) {
|
|||
println('autofree: ${g.file.path}:${var.pos.line_nr}: skipping `${var.name}` in fn `${g.last_fn_c_name}`. ${comment}')
|
||||
}
|
||||
|
||||
fn (mut g Gen) autofree_scope_vars2(scope &ast.Scope, start_pos int, end_pos int, line_nr int, free_parent_scopes bool, stop_pos int) {
|
||||
fn (mut g Gen) autofree_scope_vars2(scope &ast.Scope, start_pos int, end_pos int, line_nr int, free_parent_scopes bool,
|
||||
stop_pos int) {
|
||||
if scope == unsafe { nil } {
|
||||
return
|
||||
}
|
||||
|
@ -5942,7 +5944,8 @@ fn (mut g Gen) const_decl(node ast.ConstDecl) {
|
|||
}
|
||||
}
|
||||
|
||||
fn (mut g Gen) const_decl_precomputed(mod string, name string, field_name string, ct_value ast.ComptTimeConstValue, typ ast.Type) bool {
|
||||
fn (mut g Gen) const_decl_precomputed(mod string, name string, field_name string, ct_value ast.ComptTimeConstValue,
|
||||
typ ast.Type) bool {
|
||||
mut styp := g.typ(typ)
|
||||
cname := if g.pref.translated && !g.is_builtin_mod { name } else { '_const_${name}' }
|
||||
$if trace_const_precomputed ? {
|
||||
|
@ -6096,7 +6099,8 @@ fn (mut g Gen) c_const_name(name string) string {
|
|||
return if g.pref.translated && !g.is_builtin_mod { name } else { '_const_${name}' }
|
||||
}
|
||||
|
||||
fn (mut g Gen) const_decl_init_later(mod string, name string, expr ast.Expr, typ ast.Type, unwrap_option bool, surround_cbr bool) {
|
||||
fn (mut g Gen) const_decl_init_later(mod string, name string, expr ast.Expr, typ ast.Type, unwrap_option bool,
|
||||
surround_cbr bool) {
|
||||
// Initialize more complex consts in `void _vinit/2{}`
|
||||
// (C doesn't allow init expressions that can't be resolved at compile time).
|
||||
mut styp := g.typ(typ)
|
||||
|
@ -6157,7 +6161,8 @@ fn (mut g Gen) const_decl_init_later(mod string, name string, expr ast.Expr, typ
|
|||
}
|
||||
}
|
||||
|
||||
fn (mut g Gen) const_decl_init_later_msvc_string_fixed_array(mod string, name string, expr ast.ArrayInit, typ ast.Type) {
|
||||
fn (mut g Gen) const_decl_init_later_msvc_string_fixed_array(mod string, name string, expr ast.ArrayInit,
|
||||
typ ast.Type) {
|
||||
mut styp := g.typ(typ)
|
||||
cname := g.c_const_name(name)
|
||||
mut init := strings.new_builder(100)
|
||||
|
@ -6940,7 +6945,8 @@ fn (mut g Gen) sort_structs(typesa []&ast.TypeSymbol) []&ast.TypeSymbol {
|
|||
}
|
||||
}
|
||||
|
||||
fn (mut g Gen) gen_or_block_stmts(cvar_name string, cast_typ string, stmts []ast.Stmt, return_type ast.Type, is_option bool) {
|
||||
fn (mut g Gen) gen_or_block_stmts(cvar_name string, cast_typ string, stmts []ast.Stmt, return_type ast.Type,
|
||||
is_option bool) {
|
||||
g.indent++
|
||||
for i, stmt in stmts {
|
||||
if i == stmts.len - 1 {
|
||||
|
|
|
@ -1419,7 +1419,8 @@ fn (mut g Gen) resolve_comptime_args(func ast.Fn, mut node_ ast.CallExpr, concre
|
|||
return comptime_args
|
||||
}
|
||||
|
||||
fn (mut g Gen) resolve_receiver_name(node ast.CallExpr, unwrapped_rec_type ast.Type, final_left_sym ast.TypeSymbol, left_sym ast.TypeSymbol, typ_sym ast.TypeSymbol) string {
|
||||
fn (mut g Gen) resolve_receiver_name(node ast.CallExpr, unwrapped_rec_type ast.Type, final_left_sym ast.TypeSymbol,
|
||||
left_sym ast.TypeSymbol, typ_sym ast.TypeSymbol) string {
|
||||
mut receiver_type_name := util.no_dots(g.cc_type(unwrapped_rec_type, false))
|
||||
if final_left_sym.kind == .map && node.name in ['clone', 'move'] {
|
||||
receiver_type_name = 'map'
|
||||
|
|
|
@ -219,7 +219,8 @@ ${enc_fn_dec} {
|
|||
}
|
||||
|
||||
@[inline]
|
||||
fn (mut g Gen) gen_enum_to_str(utyp ast.Type, sym ast.TypeSymbol, enum_var string, result_var string, ident string, mut enc strings.Builder) {
|
||||
fn (mut g Gen) gen_enum_to_str(utyp ast.Type, sym ast.TypeSymbol, enum_var string, result_var string, ident string,
|
||||
mut enc strings.Builder) {
|
||||
enum_prefix := g.gen_enum_prefix(utyp.clear_flag(.option))
|
||||
enc.writeln('${ident}switch (${enum_var}) {')
|
||||
for val in (sym.info as ast.Enum).vals {
|
||||
|
@ -238,7 +239,8 @@ fn (mut g Gen) gen_enum_to_str(utyp ast.Type, sym ast.TypeSymbol, enum_var strin
|
|||
}
|
||||
|
||||
@[inline]
|
||||
fn (mut g Gen) gen_str_to_enum(utyp ast.Type, sym ast.TypeSymbol, val_var string, result_var string, ident string, mut dec strings.Builder) {
|
||||
fn (mut g Gen) gen_str_to_enum(utyp ast.Type, sym ast.TypeSymbol, val_var string, result_var string, ident string,
|
||||
mut dec strings.Builder) {
|
||||
enum_prefix := g.gen_enum_prefix(utyp.clear_flag(.option))
|
||||
is_option := utyp.has_flag(.option)
|
||||
for k, val in (sym.info as ast.Enum).vals {
|
||||
|
@ -359,7 +361,8 @@ fn (mut g Gen) gen_option_enc_dec(typ ast.Type, mut enc strings.Builder, mut dec
|
|||
}
|
||||
|
||||
@[inline]
|
||||
fn (mut g Gen) gen_sumtype_enc_dec(utyp ast.Type, sym ast.TypeSymbol, mut enc strings.Builder, mut dec strings.Builder, ret_styp string) {
|
||||
fn (mut g Gen) gen_sumtype_enc_dec(utyp ast.Type, sym ast.TypeSymbol, mut enc strings.Builder, mut dec strings.Builder,
|
||||
ret_styp string) {
|
||||
info := sym.info as ast.SumType
|
||||
type_var := g.new_tmp_var()
|
||||
typ := g.table.type_idxs[sym.name]
|
||||
|
@ -602,7 +605,8 @@ fn (mut g Gen) gen_sumtype_enc_dec(utyp ast.Type, sym ast.TypeSymbol, mut enc st
|
|||
}
|
||||
|
||||
@[inline]
|
||||
fn (mut g Gen) gen_struct_enc_dec(utyp ast.Type, type_info ast.TypeInfo, styp string, mut enc strings.Builder, mut dec strings.Builder) {
|
||||
fn (mut g Gen) gen_struct_enc_dec(utyp ast.Type, type_info ast.TypeInfo, styp string, mut enc strings.Builder,
|
||||
mut dec strings.Builder) {
|
||||
info := type_info as ast.Struct
|
||||
for field in info.fields {
|
||||
mut name := field.name
|
||||
|
@ -889,7 +893,8 @@ fn gen_js_get(styp string, tmp string, name string, mut dec strings.Builder, is_
|
|||
}
|
||||
}
|
||||
|
||||
fn gen_js_get_opt(dec_name string, field_type string, styp string, tmp string, name string, mut dec strings.Builder, is_required bool) {
|
||||
fn gen_js_get_opt(dec_name string, field_type string, styp string, tmp string, name string, mut dec strings.Builder,
|
||||
is_required bool) {
|
||||
gen_js_get(styp, tmp, name, mut dec, is_required)
|
||||
value_field_type := field_type.replace('*', '_ptr')
|
||||
dec.writeln('\t${result_name}_${value_field_type.replace('*', '_ptr')} ${tmp} = {0};')
|
||||
|
|
|
@ -142,7 +142,8 @@ fn (mut g Gen) write_orm_connection_init(connection_var_name string, db_expr &as
|
|||
}
|
||||
|
||||
// write_orm_create_table writes C code that calls ORM functions for creating tables.
|
||||
fn (mut g Gen) write_orm_create_table(node ast.SqlStmtLine, table_name string, connection_var_name string, result_var_name string) {
|
||||
fn (mut g Gen) write_orm_create_table(node ast.SqlStmtLine, table_name string, connection_var_name string,
|
||||
result_var_name string) {
|
||||
g.writeln('// sql { create table `${table_name}` }')
|
||||
g.writeln('${result_name}_void ${result_var_name} = orm__Connection_name_table[${connection_var_name}._typ]._method_create(')
|
||||
g.indent++
|
||||
|
@ -221,7 +222,8 @@ fn (mut g Gen) write_orm_drop_table(table_name string, connection_var_name strin
|
|||
}
|
||||
|
||||
// write_orm_insert writes C code that calls ORM functions for inserting structs into a table.
|
||||
fn (mut g Gen) write_orm_insert(node &ast.SqlStmtLine, table_name string, connection_var_name string, result_var_name string, or_expr &ast.OrExpr) {
|
||||
fn (mut g Gen) write_orm_insert(node &ast.SqlStmtLine, table_name string, connection_var_name string, result_var_name string,
|
||||
or_expr &ast.OrExpr) {
|
||||
last_ids_variable_name := g.new_tmp_var()
|
||||
|
||||
g.writeln('Array_orm__Primitive ${last_ids_variable_name} = __new_array_with_default_noscan(0, 0, sizeof(orm__Primitive), 0);')
|
||||
|
@ -295,7 +297,8 @@ fn (mut g Gen) write_orm_delete(node &ast.SqlStmtLine, table_name string, connec
|
|||
|
||||
// write_orm_insert_with_last_ids writes C code that calls ORM functions for
|
||||
// inserting a struct into a table, saving inserted `id` into a passed variable.
|
||||
fn (mut g Gen) write_orm_insert_with_last_ids(node ast.SqlStmtLine, connection_var_name string, table_name string, last_ids_arr string, res string, pid string, fkey string, or_expr ast.OrExpr) {
|
||||
fn (mut g Gen) write_orm_insert_with_last_ids(node ast.SqlStmtLine, connection_var_name string, table_name string,
|
||||
last_ids_arr string, res string, pid string, fkey string, or_expr ast.OrExpr) {
|
||||
mut subs := []ast.SqlStmtLine{}
|
||||
|
||||
mut subs_unwrapped_c_typ := []string{}
|
||||
|
@ -719,7 +722,8 @@ fn (mut g Gen) write_orm_where(where_expr ast.Expr) {
|
|||
}
|
||||
|
||||
// write_orm_where_expr writes C code that generates expression which is used in the `QueryData`.
|
||||
fn (mut g Gen) write_orm_where_expr(expr ast.Expr, mut fields []string, mut parentheses [][]int, mut kinds []string, mut data []ast.Expr, mut is_and []bool) {
|
||||
fn (mut g Gen) write_orm_where_expr(expr ast.Expr, mut fields []string, mut parentheses [][]int, mut kinds []string,
|
||||
mut data []ast.Expr, mut is_and []bool) {
|
||||
match expr {
|
||||
ast.InfixExpr {
|
||||
g.sql_side = .left
|
||||
|
|
|
@ -905,7 +905,8 @@ pub fn (mut f Gen) enum_decl(node ast.EnumDecl) {
|
|||
|
||||
pub fn (mut f Gen) fn_decl(node ast.FnDecl) {
|
||||
f.attrs(node.attrs)
|
||||
f.write(f.table.stringify_fn_decl(&node, f.cur_mod, f.mod2alias).replace('fn ', 'func '))
|
||||
f.write(f.table.stringify_fn_decl(&node, f.cur_mod, f.mod2alias, false).replace('fn ',
|
||||
'func '))
|
||||
f.fn_body(node)
|
||||
}
|
||||
|
||||
|
@ -1135,7 +1136,7 @@ pub fn (mut f Gen) interface_field(field ast.StructField) {
|
|||
|
||||
pub fn (mut f Gen) interface_method(method ast.FnDecl) {
|
||||
f.write('\t')
|
||||
f.write(f.table.stringify_fn_decl(&method, f.cur_mod, f.mod2alias).after('fn '))
|
||||
f.write(f.table.stringify_fn_decl(&method, f.cur_mod, f.mod2alias, false).after('fn '))
|
||||
f.writeln('')
|
||||
for param in method.params {
|
||||
f.mark_types_import_as_used(param.typ)
|
||||
|
|
|
@ -2557,7 +2557,8 @@ fn (mut g JsGen) match_expr_sumtype(node ast.MatchExpr, is_expr bool, cond_var M
|
|||
}
|
||||
}
|
||||
|
||||
fn (mut g JsGen) match_expr_switch(node ast.MatchExpr, is_expr bool, cond_var MatchCond, tmp_var string, enum_typ ast.TypeSymbol) {
|
||||
fn (mut g JsGen) match_expr_switch(node ast.MatchExpr, is_expr bool, cond_var MatchCond, tmp_var string,
|
||||
enum_typ ast.TypeSymbol) {
|
||||
mut range_branches := []ast.MatchBranch{cap: node.branches.len} // branches have RangeExpr cannot emit as switch case branch, we handle it in default branch
|
||||
mut default_generated := false
|
||||
g.empty_line = true
|
||||
|
|
|
@ -52,7 +52,8 @@ fn new_mappings() Mappings {
|
|||
}
|
||||
|
||||
// Add the given source mapping
|
||||
fn (mut m Mappings) add_mapping(gen_line u32, gen_column u32, sources_ind u32, source_position SourcePositionType, names_ind NameIndexType) {
|
||||
fn (mut m Mappings) add_mapping(gen_line u32, gen_column u32, sources_ind u32, source_position SourcePositionType,
|
||||
names_ind NameIndexType) {
|
||||
if !(gen_line > m.last.gen_line
|
||||
|| (gen_line == m.last.gen_line && gen_column >= m.last.gen_column)) {
|
||||
m.is_sorted = false
|
||||
|
|
|
@ -36,7 +36,8 @@ pub fn new_sourcemap(file string, source_root string, sources_content_inline boo
|
|||
}
|
||||
|
||||
// Add a single mapping from original source line and column to the generated source's line and column for this source map being created.
|
||||
pub fn (mut sm SourceMap) add_mapping(source_name string, source_position SourcePositionType, gen_line u32, gen_column u32, name string) {
|
||||
pub fn (mut sm SourceMap) add_mapping(source_name string, source_position SourcePositionType, gen_line u32,
|
||||
gen_column u32, name string) {
|
||||
if source_name == '' {
|
||||
panic('add_mapping, source_name should not be ""')
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@ pub fn generate_empty_map() &Generator {
|
|||
return &Generator{}
|
||||
}
|
||||
|
||||
pub fn (mut g Generator) add_map(file string, source_root string, sources_content_inline bool, line_offset int, column_offset int) &SourceMap {
|
||||
pub fn (mut g Generator) add_map(file string, source_root string, sources_content_inline bool, line_offset int,
|
||||
column_offset int) &SourceMap {
|
||||
source_map := new_sourcemap(file, source_root, sources_content_inline)
|
||||
|
||||
offset := Offset{
|
||||
|
|
|
@ -300,7 +300,8 @@ mut:
|
|||
size i64 // Symbol size.
|
||||
}
|
||||
|
||||
fn (mut g Gen) create_symbol_table_section(str_name string, info u8, bind u8, other i8, value i64, size i64, shndx i16) SymbolTableSection {
|
||||
fn (mut g Gen) create_symbol_table_section(str_name string, info u8, bind u8, other i8, value i64, size i64,
|
||||
shndx i16) SymbolTableSection {
|
||||
return SymbolTableSection{
|
||||
str_name: str_name
|
||||
info: i8(info | bind << 4)
|
||||
|
|
|
@ -16,7 +16,8 @@ struct SystemDll {
|
|||
full_path string
|
||||
}
|
||||
|
||||
fn C.SearchPathA(lp_path &char, lp_file_name &char, lp_extension &char, n_buffer_length u32, lp_buffer &char, lp_file_part &&char) u32
|
||||
fn C.SearchPathA(lp_path &char, lp_file_name &char, lp_extension &char, n_buffer_length u32, lp_buffer &char,
|
||||
lp_file_part &&char) u32
|
||||
fn C.GetLastError() u32
|
||||
|
||||
fn (mut g Gen) lookup_system_dll(dll string) !SystemDll {
|
||||
|
|
|
@ -511,7 +511,8 @@ pub fn (mut g Gen) prefix_expr(node ast.PrefixExpr, expected ast.Type) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn (mut g Gen) if_branch(ifexpr ast.IfExpr, expected ast.Type, unpacked_params []wasm.ValType, idx int, existing_rvars []Var) {
|
||||
pub fn (mut g Gen) if_branch(ifexpr ast.IfExpr, expected ast.Type, unpacked_params []wasm.ValType, idx int,
|
||||
existing_rvars []Var) {
|
||||
curr := ifexpr.branches[idx]
|
||||
|
||||
g.expr(curr.cond, ast.bool_type)
|
||||
|
|
|
@ -441,7 +441,8 @@ fn all_fn_const_and_global(ast_files []&ast.File) (map[string]ast.FnDecl, map[st
|
|||
return all_fns, all_consts, all_globals
|
||||
}
|
||||
|
||||
fn handle_vweb(mut table ast.Table, mut all_fn_root_names []string, result_name string, filter_name string, context_name string) {
|
||||
fn handle_vweb(mut table ast.Table, mut all_fn_root_names []string, result_name string, filter_name string,
|
||||
context_name string) {
|
||||
// handle vweb magic router methods:
|
||||
result_type_idx := table.find_type_idx(result_name)
|
||||
if result_type_idx != 0 {
|
||||
|
|
|
@ -272,7 +272,8 @@ fn detect_musl(mut res Preferences) {
|
|||
}
|
||||
|
||||
@[noreturn]
|
||||
fn run_code_in_tmp_vfile_and_exit(args []string, mut res Preferences, option_name string, extension string, content string) {
|
||||
fn run_code_in_tmp_vfile_and_exit(args []string, mut res Preferences, option_name string, extension string,
|
||||
content string) {
|
||||
tmp_file_path := rand.ulid()
|
||||
mut tmp_exe_file_path := res.out_name
|
||||
mut output_option := ''
|
||||
|
|
|
@ -668,7 +668,8 @@ fn new_request_app[T](global_app &T, ctx Context, tid int) &T {
|
|||
}
|
||||
|
||||
@[manualfree]
|
||||
fn handle_conn[T](mut conn net.TcpConn, global_app &T, controllers []&ControllerPath, routes &map[string]Route, tid int) {
|
||||
fn handle_conn[T](mut conn net.TcpConn, global_app &T, controllers []&ControllerPath, routes &map[string]Route,
|
||||
tid int) {
|
||||
conn.set_read_timeout(30 * time.second)
|
||||
conn.set_write_timeout(30 * time.second)
|
||||
defer {
|
||||
|
|
|
@ -522,7 +522,9 @@ fn (mut tm DynamicTemplateManager) check_tmpl_and_placeholders_size(f_path strin
|
|||
// This request is then sent to the cache handler channel, signaling either the need for a new cache or an update to an existing one.
|
||||
// The function returns the rendered immediately, without waiting for the cache to be created or updated.
|
||||
//
|
||||
fn (mut tm DynamicTemplateManager) create_template_cache_and_display(tcs CacheRequest, last_template_mod i64, unique_time i64, file_path string, tmpl_name string, cache_delay_expiration i64, placeholders &map[string]DtmMultiTypeMap, current_content_checksum string, tmpl_type TemplateType) string {
|
||||
fn (mut tm DynamicTemplateManager) create_template_cache_and_display(tcs CacheRequest, last_template_mod i64,
|
||||
unique_time i64, file_path string, tmpl_name string, cache_delay_expiration i64, placeholders &map[string]DtmMultiTypeMap,
|
||||
current_content_checksum string, tmpl_type TemplateType) string {
|
||||
// Control if cache delay expiration is correctly set. See the function itself for more details.
|
||||
check_if_cache_delay_iscorrect(cache_delay_expiration, tmpl_name) or {
|
||||
eprintln(err)
|
||||
|
@ -995,7 +997,8 @@ const allowed_tags = ['<div>', '</div>', '<h1>', '</h1>', '<h2>', '</h2>', '<h3>
|
|||
|
||||
const include_html_key_tag = '_#includehtml'
|
||||
|
||||
fn (mut tm DynamicTemplateManager) parse_tmpl_file(file_path string, tmpl_name string, placeholders &map[string]DtmMultiTypeMap, is_compressed bool, tmpl_type TemplateType) string {
|
||||
fn (mut tm DynamicTemplateManager) parse_tmpl_file(file_path string, tmpl_name string, placeholders &map[string]DtmMultiTypeMap,
|
||||
is_compressed bool, tmpl_type TemplateType) string {
|
||||
mut tmpl_ := compile_template_file(file_path, tmpl_name, placeholders)
|
||||
|
||||
// Performs a light compression of the HTML output by removing usless spaces, newlines, and tabs if user selected this option.
|
||||
|
@ -1036,7 +1039,9 @@ fn check_if_cache_delay_iscorrect(cde i64, tmpl_name string) ! {
|
|||
// It assesses various conditions such as cache existence, cache expiration settings, and last modification timestamps ( template or dynamic content )
|
||||
// to decide whether to create a new cache, update an existing or delivered a valid cache content.
|
||||
//
|
||||
fn (mut tm DynamicTemplateManager) cache_request_route(is_cache_exist bool, neg_cache_delay_expiration i64, last_template_mod i64, test_current_template_mod i64, cache_del_exp i64, gen_at i64, c_time i64, content_checksum string, current_content_checksum string) (CacheRequest, i64) {
|
||||
fn (mut tm DynamicTemplateManager) cache_request_route(is_cache_exist bool, neg_cache_delay_expiration i64,
|
||||
last_template_mod i64, test_current_template_mod i64, cache_del_exp i64, gen_at i64, c_time i64, content_checksum string,
|
||||
current_content_checksum string) (CacheRequest, i64) {
|
||||
if !is_cache_exist || neg_cache_delay_expiration == -1 {
|
||||
// Require cache creation
|
||||
unique_ts := get_current_unix_micro_timestamp()
|
||||
|
|
|
@ -130,7 +130,8 @@ fn replace_placeholders_with_data(line string, data &map[string]DtmMultiTypeMap,
|
|||
return rline
|
||||
}
|
||||
|
||||
fn insert_template_code(fn_name string, tmpl_str_start string, line string, data &map[string]DtmMultiTypeMap, state State) string {
|
||||
fn insert_template_code(fn_name string, tmpl_str_start string, line string, data &map[string]DtmMultiTypeMap,
|
||||
state State) string {
|
||||
// HTML, may include `@var`
|
||||
// escaped by cgen, unless it's a `vweb.RawHtml` string
|
||||
trailing_bs := dtm.tmpl_str_end + 'sb_${fn_name}.write_u8(92)\n' + tmpl_str_start
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue