Skip to content

Commit b347f54

Browse files
authored
all: update remaining deprecated attr syntax (#19908)
1 parent 709976f commit b347f54

File tree

11 files changed

+64
-64
lines changed

11 files changed

+64
-64
lines changed

doc/docs.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2344,7 +2344,7 @@ V doesn't have default function arguments or named arguments, for that trailing
23442344
literal syntax can be used instead:
23452345

23462346
```v
2347-
[params]
2347+
@[params]
23482348
struct ButtonConfig {
23492349
text string
23502350
is_disabled bool
@@ -2470,7 +2470,7 @@ For an example, consider the following source in a directory `sample`:
24702470
```v oksyntax
24712471
module sample
24722472
2473-
[noinit]
2473+
@[noinit]
24742474
pub struct Information {
24752475
pub:
24762476
data string
@@ -4488,7 +4488,7 @@ be achieved by tagging your assert containing functions with an `[assert_continu
44884488
tag, for example running this program:
44894489

44904490
```v
4491-
[assert_continues]
4491+
@[assert_continues]
44924492
fn abc(ii int) {
44934493
assert ii == 2
44944494
}
@@ -4640,7 +4640,7 @@ data types:
46404640
```v
46414641
struct MyType {}
46424642
4643-
[unsafe]
4643+
@[unsafe]
46444644
fn (data &MyType) free() {
46454645
// ...
46464646
}
@@ -4813,7 +4813,7 @@ mut:
48134813
}
48144814
48154815
// see discussion below
4816-
[heap]
4816+
@[heap]
48174817
struct MyStruct {
48184818
n int
48194819
}
@@ -4974,7 +4974,7 @@ V's ORM provides a number of benefits:
49744974
import db.sqlite
49754975
49764976
// sets a custom table name. Default is struct name (case-sensitive)
4977-
[table: 'customers']
4977+
@[table: 'customers']
49784978
struct Customer {
49794979
id int [primary; sql: serial] // a field named `id` of integer type must be the first field
49804980
name string [nonull]
@@ -5353,7 +5353,7 @@ function/struct/enum declaration and applies only to the following declaration.
53535353
```v
53545354
// [flag] enables Enum types to be used as bitfields
53555355
5356-
[flag]
5356+
@[flag]
53575357
enum BitField {
53585358
read
53595359
write
@@ -5395,13 +5395,13 @@ Function/method deprecations:
53955395
```v
53965396
// Calling this function will result in a deprecation warning
53975397
5398-
[deprecated]
5398+
@[deprecated]
53995399
fn old_function() {
54005400
}
54015401
54025402
// It can also display a custom deprecation message
54035403
5404-
[deprecated: 'use new_function() instead']
5404+
@[deprecated: 'use new_function() instead']
54055405
fn legacy_function() {}
54065406
54075407
// You can also specify a date, after which the function will be
@@ -5413,19 +5413,19 @@ fn legacy_function() {}
54135413
// 6 months after the deprecation date, calls will be hard
54145414
// compiler errors.
54155415
5416-
[deprecated: 'use new_function2() instead']
5417-
[deprecated_after: '2021-05-27']
5416+
@[deprecated: 'use new_function2() instead']
5417+
@[deprecated_after: '2021-05-27']
54185418
fn legacy_function2() {}
54195419
```
54205420
54215421
```v nofmt
54225422
// This function's calls will be inlined.
5423-
[inline]
5423+
@[inline]
54245424
fn inlined_function() {
54255425
}
54265426
54275427
// This function's calls will NOT be inlined.
5428-
[noinline]
5428+
@[noinline]
54295429
fn function() {
54305430
}
54315431
@@ -5434,21 +5434,21 @@ fn function() {
54345434
// just like exit/1 or panic/1. Such functions can not
54355435
// have return types, and should end either in for{}, or
54365436
// by calling other `[noreturn]` functions.
5437-
[noreturn]
5437+
@[noreturn]
54385438
fn forever() {
54395439
for {}
54405440
}
54415441
54425442
// The following struct must be allocated on the heap. Therefore, it can only be used as a
54435443
// reference (`&Window`) or inside another reference (`&OuterStruct{ Window{...} }`).
54445444
// See section "Stack and Heap"
5445-
[heap]
5445+
@[heap]
54465446
struct Window {
54475447
}
54485448
54495449
// V will not generate this function and all its calls if the provided flag is false.
54505450
// To use a flag, use `v -d flag`
5451-
[if debug]
5451+
@[if debug]
54525452
fn foo() {
54535453
}
54545454
@@ -5458,7 +5458,7 @@ fn bar() {
54585458
54595459
// The memory pointed to by the pointer arguments of this function will not be
54605460
// freed by the garbage collector (if in use) before the function returns
5461-
[keep_args_alive]
5461+
@[keep_args_alive]
54625462
fn C.my_external_function(voidptr, int, voidptr) int
54635463
54645464
// Calls to following function must be in unsafe{} blocks.
@@ -5467,7 +5467,7 @@ fn C.my_external_function(voidptr, int, voidptr) int
54675467
// This is useful, when you want to have an `[unsafe]` function that
54685468
// has checks before/after a certain unsafe operation, that will still
54695469
// benefit from V's safety features.
5470-
[unsafe]
5470+
@[unsafe]
54715471
fn risky_business() {
54725472
// code that will be checked, perhaps checking pre conditions
54735473
unsafe {
@@ -5483,22 +5483,22 @@ fn risky_business() {
54835483
54845484
// V's autofree engine will not take care of memory management in this function.
54855485
// You will have the responsibility to free memory manually yourself in it.
5486-
[manualfree]
5486+
@[manualfree]
54875487
fn custom_allocations() {
54885488
}
54895489
54905490
// For C interop only, tells V that the following struct is defined with `typedef struct` in C
5491-
[typedef]
5491+
@[typedef]
54925492
pub struct C.Foo {
54935493
}
54945494
54955495
// Used to add a custom calling convention to a function, available calling convention: stdcall, fastcall and cdecl.
54965496
// This list also applies for type aliases (see below).
5497-
[callconv: "stdcall"]
5497+
@[callconv: "stdcall"]
54985498
fn C.DefWindowProc(hwnd int, msg int, lparam int, wparam int)
54995499
55005500
// Used to add a custom calling convention to a function type aliases.
5501-
[callconv: "fastcall"]
5501+
@[callconv: "fastcall"]
55025502
type FastFn = fn (int) bool
55035503
55045504
// Windows only:
@@ -5508,7 +5508,7 @@ type FastFn = fn (int) bool
55085508
// (e)println output can be seen.
55095509
// Use it to force-open a terminal to view output in, even if the app is started from Explorer.
55105510
// Valid before main() only.
5511-
[console]
5511+
@[console]
55125512
fn main() {
55135513
}
55145514
```
@@ -6776,7 +6776,7 @@ For example, `fn foo() {}` in module `bar` will result in `bar__foo()`.
67766776
To use a custom export name, use the `[export]` attribute:
67776777
67786778
```
6779-
[export: 'my_custom_c_name']
6779+
@[export: 'my_custom_c_name']
67806780
fn foo() {
67816781
}
67826782
```
@@ -6902,7 +6902,7 @@ module main
69026902
69036903
import time
69046904
6905-
[live]
6905+
@[live]
69066906
fn print_message() {
69076907
println('Hello! Modify this message while the program is running.')
69086908
}

examples/js_dom_cube/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ fn new_app() &App {
140140
return app
141141
}
142142
143-
['/'; get]
143+
@['/'; get]
144144
pub fn (mut app App) controller_get_all_task() vweb.Result {
145145
file := os.read_file('./index.html') or { panic(err) }
146146
return app.html(file)

examples/js_dom_draw/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ fn new_app() &App {
142142
return app
143143
}
144144
145-
['/'; get]
145+
@['/'; get]
146146
pub fn (mut app App) controller_get_all_task() vweb.Result {
147147
file := os.read_file('./index.html') or { panic(err) }
148148
return app.html(file)

examples/js_dom_draw_bechmark_chart/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ exit
5454
In `v_vweb_orm/src/main.v`, create a route that returns a `Response` struct.
5555

5656
```v ignore
57-
['/sqlite-memory/:count']
57+
@['/sqlite-memory/:count']
5858
pub fn (mut app App) sqlite_memory(count int) vweb.Result {
5959
mut insert_stopwatchs := []int{}
6060
mut select_stopwatchs := []int{}

examples/js_dom_draw_bechmark_chart/chart/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ In `examples/js_dom_draw_bechmark_chart/v_vweb_orm/src/main.v` path
1919
Create a route returning a `Response` struct like:
2020

2121
```v ignore
22-
['/sqlite-memory/:count']
22+
@['/sqlite-memory/:count']
2323
pub fn (mut app App) sqlite_memory(count int) vweb.Result {
2424
mut insert_stopwatchs := []int{}
2525
mut select_stopwatchs := []int{}

tutorials/C2V_translating_simple_programs_and_DOOM/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ It will create `primes.v` with the following contents:
4949
5050
5151
```v
52-
[translated]
52+
@[translated]
5353
module main
5454
5555
fn is_prime(x int) bool {
@@ -335,4 +335,4 @@ I will also be publishing the same demo with Sqlite and Quake translation.
335335
It's a huge milestone for V and gives V developers access to huge amounts of software
336336
written in C.
337337

338-
We're very excited about this release.
338+
We're very excited about this release.

tutorials/building_a_simple_web_blog_with_vweb/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fn main() {
6969
vweb.run(app, 8081)
7070
}
7171
72-
['/index']
72+
@['/index']
7373
pub fn (mut app App) index() vweb.Result {
7474
return app.text('Hello world from vweb!')
7575
}
@@ -336,7 +336,7 @@ Create `new.html`:
336336
// article.v
337337
import vweb
338338
339-
[post]
339+
@[post]
340340
pub fn (mut app App) new_article(title string, text string) vweb.Result {
341341
if title == '' || text == '' {
342342
return app.text('Empty text/title')
@@ -368,7 +368,7 @@ We need to update `index.html` to add a link to the "new article" page:
368368
Next we need to add the HTML endpoint to our code like we did with `index.html`:
369369

370370
```v ignore
371-
['/new']
371+
@['/new']
372372
pub fn (mut app App) new() vweb.Result {
373373
return $vweb.html()
374374
}
@@ -386,7 +386,7 @@ in V is very simple:
386386
// article.v
387387
import vweb
388388
389-
['/articles'; get]
389+
@['/articles'; get]
390390
pub fn (mut app App) articles() vweb.Result {
391391
articles := app.find_all_articles()
392392
return app.json(articles)

vlib/orm/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ non-option fields are defied as NOT NULL when creating tables.
3030
```v ignore
3131
import time
3232
33-
[table: 'foos']
33+
@[table: 'foos']
3434
struct Foo {
3535
id int [primary; sql: serial]
3636
name string

vlib/sokol/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const (
2121
sw_start_ms = sw.elapsed().milliseconds()
2222
)
2323
24-
[inline]
24+
@[inline]
2525
fn sintone(periods int, frame int, num_frames int) f32 {
2626
return math.sinf(f32(periods) * (2 * math.pi) * f32(frame) / f32(num_frames))
2727
}

vlib/v/fmt/tests/fn_call_with_call_expr_and_params_struct_args_keep.vv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[params]
1+
@[params]
22
struct Bar {
33
bar bool
44
}

0 commit comments

Comments
 (0)