Skip to content

Commit b305fa5

Browse files
committed
docs: cleanup doc comments of public APIs in builtin (found by find_doc_comments_with_no_dots.v)
1 parent a011888 commit b305fa5

20 files changed

+75
-83
lines changed

vlib/builtin/array.v

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ fn new_array_from_c_array_no_alloc(len int, cap int, elm_size int, c_array voidp
186186
return arr
187187
}
188188

189-
// ensure_cap increases the `cap` of an array to the required value
190-
// by copying the data to a new memory location (creating a clone),
189+
// ensure_cap increases the `cap` of an array to the required value, if needed.
190+
// It does so by copying the data to a new memory location (creating a clone),
191191
// unless `a.cap` is already large enough.
192192
pub fn (mut a array) ensure_cap(required int) {
193193
if required <= a.cap {
@@ -916,8 +916,8 @@ pub fn (mut a array) sort_with_compare(callback fn (voidptr, voidptr) int) {
916916
}
917917
}
918918

919-
// sorted_with_compare sorts a clone of the array, using the results of the
920-
// given function to determine sort order. The original array is not modified.
919+
// sorted_with_compare sorts a clone of the array. The original array is not modified.
920+
// It uses the results of the given function to determine sort order.
921921
// See also .sort_with_compare()
922922
pub fn (a &array) sorted_with_compare(callback fn (voidptr, voidptr) int) array {
923923
$if freestanding {
@@ -930,15 +930,14 @@ pub fn (a &array) sorted_with_compare(callback fn (voidptr, voidptr) int) array
930930
return array{}
931931
}
932932

933-
// contains determines whether an array includes a certain value among its elements
933+
// contains determines whether an array includes a certain value among its elements.
934934
// It will return `true` if the array contains an element with this value.
935935
// It is similar to `.any` but does not take an `it` expression.
936936
//
937937
// Example: [1, 2, 3].contains(4) == false
938938
pub fn (a array) contains(value voidptr) bool
939939

940-
// index returns the first index at which a given element can be found in the array
941-
// or `-1` if the value is not found.
940+
// index returns the first index at which a given element can be found in the array or `-1` if the value is not found.
942941
pub fn (a array) index(value voidptr) int
943942

944943
@[direct_array_access; unsafe]
@@ -955,7 +954,7 @@ pub fn (mut a []string) free() {
955954
// The following functions are type-specific functions that apply
956955
// to arrays of different types in different ways.
957956

958-
// str returns a string representation of an array of strings
957+
// str returns a string representation of an array of strings.
959958
// Example: ['a', 'b', 'c'].str() // => "['a', 'b', 'c']".
960959
@[direct_array_access; manualfree]
961960
pub fn (a []string) str() string {

vlib/builtin/backtraces.c.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module builtin
22

3-
// print_backtrace shows a backtrace of the current call stack on stdout
3+
// print_backtrace shows a backtrace of the current call stack on stdout.
44
pub fn print_backtrace() {
55
// At the time of backtrace_symbols_fd call, the C stack would look something like this:
66
// * print_backtrace_skipping_top_frames

vlib/builtin/backtraces_nix.c.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module builtin
22

3-
// print_backtrace_skipping_top_frames prints the backtrace skipping N top frames
3+
// print_backtrace_skipping_top_frames prints the backtrace skipping N top frames.
44
pub fn print_backtrace_skipping_top_frames(xskipframes int) bool {
55
$if no_backtrace ? {
66
return false

vlib/builtin/backtraces_windows.c.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module builtin
33
// dbghelp.h is already included in cheaders.v
44
#flag windows -l dbghelp
55

6-
// SymbolInfo is used by print_backtrace_skipping_top_frames_msvc
6+
// SymbolInfo is used by print_backtrace_skipping_top_frames_msvc.
77
pub struct SymbolInfo {
88
pub mut:
99
f_size_of_struct u32 // must be 88 to be recognised by SymFromAddr
@@ -61,7 +61,7 @@ const symopt_include_32bit_modules = 0x00002000
6161
const symopt_allow_zero_address = 0x01000000
6262
const symopt_debug = u32(0x80000000)
6363

64-
// print_backtrace_skipping_top_frames prints the backtrace skipping N top frames
64+
// print_backtrace_skipping_top_frames prints the backtrace skipping N top frames.
6565
pub fn print_backtrace_skipping_top_frames(skipframes int) bool {
6666
$if msvc {
6767
return print_backtrace_skipping_top_frames_msvc(skipframes)

vlib/builtin/builtin.c.v

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,7 @@ pub fn memdup_uncollectable(src voidptr, sz isize) voidptr {
757757
}
758758
}
759759

760+
// GCHeapUsage contains stats about the current heap usage of your program.
760761
pub struct GCHeapUsage {
761762
pub:
762763
heap_size usize
@@ -766,7 +767,7 @@ pub:
766767
bytes_since_gc usize
767768
}
768769

769-
// gc_heap_usage returns the info about heap usage
770+
// gc_heap_usage returns the info about heap usage.
770771
pub fn gc_heap_usage() GCHeapUsage {
771772
$if gcboehm ? {
772773
mut res := GCHeapUsage{}
@@ -778,7 +779,7 @@ pub fn gc_heap_usage() GCHeapUsage {
778779
}
779780
}
780781

781-
// gc_memory_use returns the total memory use in bytes by all allocated blocks
782+
// gc_memory_use returns the total memory use in bytes by all allocated blocks.
782783
pub fn gc_memory_use() usize {
783784
$if gcboehm ? {
784785
return C.GC_get_memory_use()

vlib/builtin/builtin.v

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ fn __as_cast(obj voidptr, obj_type int, expected_type int) voidptr {
3636
return obj
3737
}
3838

39-
// VAssertMetaInfo is used during assertions. An instance of it is filled in by
40-
// compile time generated code, when an assertion fails.
39+
// VAssertMetaInfo is used during assertions. An instance of it is filled in by compile time generated code, when an assertion fails.
4140
pub struct VAssertMetaInfo {
4241
pub:
4342
fpath string // the source file path of the assertion

vlib/builtin/builtin_d_gcboehm.c.v

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,14 @@ pub fn gc_enable() {
178178
C.GC_enable()
179179
}
180180

181-
// gc_disable explicitly disables the GC. Do not forget to enable it again by calling gc_enable(),
182-
// when your program is otherwise idle, and can afford it.
181+
// gc_disable explicitly disables the GC. Do not forget to enable it again by calling gc_enable(), when your program is otherwise idle, and can afford it.
183182
// See also gc_enable() and gc_collect().
184183
// Note that gc_disable() is a NOP with `-gc none`.
185184
pub fn gc_disable() {
186185
C.GC_disable()
187186
}
188187

189-
// for leak detection it is advisable to do explicit garbage collections
188+
// gc_check_leaks is useful for leak detection (it does an explicit garbage collections, but only when a program is compiled with `-gc boehm_leak`).
190189
pub fn gc_check_leaks() {
191190
$if gcboehm_leak ? {
192191
C.GC_gcollect()
@@ -220,18 +219,19 @@ fn C.GC_remove_roots(voidptr, voidptr)
220219
fn C.GC_get_sp_corrector() fn (voidptr, voidptr)
221220
fn C.GC_set_sp_corrector(fn (voidptr, voidptr))
222221

223-
// GC warnings are silenced by default, but can be redirected to a custom cb function by programs too:
222+
// FnGC_WarnCB is the type of the callback, that you have to define, if you want to redirect GC warnings and handle them.
223+
// Note: GC warnings are silenced by default. Use gc_set_warn_proc/1 to set your own handler for them.
224224
pub type FnGC_WarnCB = fn (msg &char, arg usize)
225225

226226
fn C.GC_get_warn_proc() FnGC_WarnCB
227227
fn C.GC_set_warn_proc(cb FnGC_WarnCB)
228228

229-
// gc_get_warn_proc returns the current callback fn, that will be used for printing GC warnings
229+
// gc_get_warn_proc returns the current callback fn, that will be used for printing GC warnings.
230230
pub fn gc_get_warn_proc() FnGC_WarnCB {
231231
return C.GC_get_warn_proc()
232232
}
233233

234-
// gc_set_warn_proc sets the callback fn, that will be used for printing GC warnings
234+
// gc_set_warn_proc sets the callback fn, that will be used for printing GC warnings.
235235
pub fn gc_set_warn_proc(cb FnGC_WarnCB) {
236236
C.GC_set_warn_proc(cb)
237237
}

vlib/builtin/builtin_notd_gcboehm.c.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ pub fn gc_is_enabled() bool {
3939
// Note that gc_enable() is a NOP with `-gc none`.
4040
pub fn gc_enable() {}
4141

42-
// gc_disable explicitly disables the GC. Do not forget to enable it again by calling gc_enable(),
43-
// when your program is otherwise idle, and can afford it.
42+
// gc_disable explicitly disables the GC.
43+
// Do not forget to enable it again by calling gc_enable(), when your program is otherwise idle, and can afford it.
4444
// See also gc_enable() and gc_collect().
4545
// Note that gc_disable() is a NOP with `-gc none`.
4646
pub fn gc_disable() {}

vlib/builtin/int.v

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@ pub struct VContext {
99

1010
pub type byte = u8
1111

12-
// ptr_str returns the address of `ptr` as a `string`.
12+
// ptr_str returns a string with the address of `ptr`.
1313
pub fn ptr_str(ptr voidptr) string {
1414
buf1 := u64(ptr).hex()
1515
return buf1
1616
}
1717

18-
// str returns string equivalent of x
18+
// str returns the string equivalent of x.
1919
pub fn (x isize) str() string {
2020
return i64(x).str()
2121
}
2222

23-
// str returns string equivalent of x
23+
// str returns the string equivalent of x.
2424
pub fn (x usize) str() string {
2525
return u64(x).str()
2626
}
2727

28-
// str returns string equivalent of cptr
28+
// str returns a string with the address stored in the pointer cptr.
2929
pub fn (cptr &char) str() string {
3030
return u64(cptr).hex()
3131
}
@@ -63,10 +63,10 @@ pub const max_u32 = u32(4294967295)
6363
pub const min_u64 = u64(0)
6464
pub const max_u64 = u64(18446744073709551615)
6565

66-
// This implementation is the quickest with gcc -O2
6766
// str_l returns the string representation of the integer nn with max chars.
6867
@[direct_array_access; inline]
6968
fn (nn int) str_l(max int) string {
69+
// This implementation is the quickest with gcc -O2
7070
unsafe {
7171
mut n := i64(nn)
7272
mut d := 0
@@ -554,10 +554,9 @@ pub fn (b []u8) bytestr() string {
554554
}
555555
}
556556

557-
// byterune attempts to decode a sequence of bytes
558-
// from utf8 to utf32 and return the result as a rune
559-
// it will produce an error if there are more than
560-
// four bytes in the array.
557+
// byterune attempts to decode a sequence of bytes, from utf8 to utf32.
558+
// It return the result as a rune.
559+
// It will produce an error, if there are more than four bytes in the array.
561560
pub fn (b []u8) byterune() !rune {
562561
r := b.utf8_to_utf32()!
563562
return rune(r)

vlib/builtin/js/array.js.v

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ fn v_sort(mut arr array, comparator fn (voidptr, voidptr) int) {
6767
}
6868
}
6969

70-
// trim trims the array length to "index" without modifying the allocated data. If "index" is greater
71-
// than len nothing will be changed.
70+
// trim trims the array length to "index" without modifying the allocated data. If "index" is greater than len nothing will be changed.
7271
pub fn (mut a array) trim(index int) {
7372
if index < a.len {
7473
a.len = index
@@ -285,7 +284,7 @@ fn arr_copy(mut dst array, src array, count int) {
285284
}
286285
}
287286

288-
// delete_many deletes `size` elements beginning with index `i`
287+
// delete_many deletes `size` elements beginning with index `i`.
289288
pub fn (mut a array) delete_many(i int, size int) {
290289
#a.val.arr.make_copy()
291290
#a.val.arr.arr.splice(i.valueOf(),size.valueOf())
@@ -320,8 +319,7 @@ pub fn (mut a array) clear() {
320319
#a.val.arr.arr.length = 0
321320
}
322321

323-
// reduce executes a given reducer function on each element of the array,
324-
// resulting in a single output value.
322+
// reduce executes a given reducer function on each element of the array, resulting in a single output value.
325323
pub fn (a array) reduce(iter fn (int, int) int, accum_start int) int {
326324
mut accum_ := accum_start
327325
/*#for (let i = 0;i < a.arr.length;i++) {

0 commit comments

Comments
 (0)