Skip to content

Commit

Permalink
all: update remaining deprecated attr syntax (#19908)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm authored Nov 17, 2023
1 parent 709976f commit b347f54
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 64 deletions.
50 changes: 25 additions & 25 deletions doc/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2344,7 +2344,7 @@ V doesn't have default function arguments or named arguments, for that trailing
literal syntax can be used instead:

```v
[params]
@[params]
struct ButtonConfig {
text string
is_disabled bool
Expand Down Expand Up @@ -2470,7 +2470,7 @@ For an example, consider the following source in a directory `sample`:
```v oksyntax
module sample
[noinit]
@[noinit]
pub struct Information {
pub:
data string
Expand Down Expand Up @@ -4488,7 +4488,7 @@ be achieved by tagging your assert containing functions with an `[assert_continu
tag, for example running this program:

```v
[assert_continues]
@[assert_continues]
fn abc(ii int) {
assert ii == 2
}
Expand Down Expand Up @@ -4640,7 +4640,7 @@ data types:
```v
struct MyType {}
[unsafe]
@[unsafe]
fn (data &MyType) free() {
// ...
}
Expand Down Expand Up @@ -4813,7 +4813,7 @@ mut:
}
// see discussion below
[heap]
@[heap]
struct MyStruct {
n int
}
Expand Down Expand Up @@ -4974,7 +4974,7 @@ V's ORM provides a number of benefits:
import db.sqlite
// sets a custom table name. Default is struct name (case-sensitive)
[table: 'customers']
@[table: 'customers']
struct Customer {
id int [primary; sql: serial] // a field named `id` of integer type must be the first field
name string [nonull]
Expand Down Expand Up @@ -5353,7 +5353,7 @@ function/struct/enum declaration and applies only to the following declaration.
```v
// [flag] enables Enum types to be used as bitfields
[flag]
@[flag]
enum BitField {
read
write
Expand Down Expand Up @@ -5395,13 +5395,13 @@ Function/method deprecations:
```v
// Calling this function will result in a deprecation warning
[deprecated]
@[deprecated]
fn old_function() {
}
// It can also display a custom deprecation message
[deprecated: 'use new_function() instead']
@[deprecated: 'use new_function() instead']
fn legacy_function() {}
// You can also specify a date, after which the function will be
Expand All @@ -5413,19 +5413,19 @@ fn legacy_function() {}
// 6 months after the deprecation date, calls will be hard
// compiler errors.
[deprecated: 'use new_function2() instead']
[deprecated_after: '2021-05-27']
@[deprecated: 'use new_function2() instead']
@[deprecated_after: '2021-05-27']
fn legacy_function2() {}
```
```v nofmt
// This function's calls will be inlined.
[inline]
@[inline]
fn inlined_function() {
}
// This function's calls will NOT be inlined.
[noinline]
@[noinline]
fn function() {
}
Expand All @@ -5434,21 +5434,21 @@ fn function() {
// just like exit/1 or panic/1. Such functions can not
// have return types, and should end either in for{}, or
// by calling other `[noreturn]` functions.
[noreturn]
@[noreturn]
fn forever() {
for {}
}
// The following struct must be allocated on the heap. Therefore, it can only be used as a
// reference (`&Window`) or inside another reference (`&OuterStruct{ Window{...} }`).
// See section "Stack and Heap"
[heap]
@[heap]
struct Window {
}
// V will not generate this function and all its calls if the provided flag is false.
// To use a flag, use `v -d flag`
[if debug]
@[if debug]
fn foo() {
}
Expand All @@ -5458,7 +5458,7 @@ fn bar() {
// The memory pointed to by the pointer arguments of this function will not be
// freed by the garbage collector (if in use) before the function returns
[keep_args_alive]
@[keep_args_alive]
fn C.my_external_function(voidptr, int, voidptr) int
// Calls to following function must be in unsafe{} blocks.
Expand All @@ -5467,7 +5467,7 @@ fn C.my_external_function(voidptr, int, voidptr) int
// This is useful, when you want to have an `[unsafe]` function that
// has checks before/after a certain unsafe operation, that will still
// benefit from V's safety features.
[unsafe]
@[unsafe]
fn risky_business() {
// code that will be checked, perhaps checking pre conditions
unsafe {
Expand All @@ -5483,22 +5483,22 @@ fn risky_business() {
// V's autofree engine will not take care of memory management in this function.
// You will have the responsibility to free memory manually yourself in it.
[manualfree]
@[manualfree]
fn custom_allocations() {
}
// For C interop only, tells V that the following struct is defined with `typedef struct` in C
[typedef]
@[typedef]
pub struct C.Foo {
}
// Used to add a custom calling convention to a function, available calling convention: stdcall, fastcall and cdecl.
// This list also applies for type aliases (see below).
[callconv: "stdcall"]
@[callconv: "stdcall"]
fn C.DefWindowProc(hwnd int, msg int, lparam int, wparam int)
// Used to add a custom calling convention to a function type aliases.
[callconv: "fastcall"]
@[callconv: "fastcall"]
type FastFn = fn (int) bool
// Windows only:
Expand All @@ -5508,7 +5508,7 @@ type FastFn = fn (int) bool
// (e)println output can be seen.
// Use it to force-open a terminal to view output in, even if the app is started from Explorer.
// Valid before main() only.
[console]
@[console]
fn main() {
}
```
Expand Down Expand Up @@ -6776,7 +6776,7 @@ For example, `fn foo() {}` in module `bar` will result in `bar__foo()`.
To use a custom export name, use the `[export]` attribute:
```
[export: 'my_custom_c_name']
@[export: 'my_custom_c_name']
fn foo() {
}
```
Expand Down Expand Up @@ -6902,7 +6902,7 @@ module main
import time
[live]
@[live]
fn print_message() {
println('Hello! Modify this message while the program is running.')
}
Expand Down
2 changes: 1 addition & 1 deletion examples/js_dom_cube/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ fn new_app() &App {
return app
}
['/'; get]
@['/'; get]
pub fn (mut app App) controller_get_all_task() vweb.Result {
file := os.read_file('./index.html') or { panic(err) }
return app.html(file)
Expand Down
2 changes: 1 addition & 1 deletion examples/js_dom_draw/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ fn new_app() &App {
return app
}
['/'; get]
@['/'; get]
pub fn (mut app App) controller_get_all_task() vweb.Result {
file := os.read_file('./index.html') or { panic(err) }
return app.html(file)
Expand Down
2 changes: 1 addition & 1 deletion examples/js_dom_draw_bechmark_chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ exit
In `v_vweb_orm/src/main.v`, create a route that returns a `Response` struct.

```v ignore
['/sqlite-memory/:count']
@['/sqlite-memory/:count']
pub fn (mut app App) sqlite_memory(count int) vweb.Result {
mut insert_stopwatchs := []int{}
mut select_stopwatchs := []int{}
Expand Down
2 changes: 1 addition & 1 deletion examples/js_dom_draw_bechmark_chart/chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ In `examples/js_dom_draw_bechmark_chart/v_vweb_orm/src/main.v` path
Create a route returning a `Response` struct like:

```v ignore
['/sqlite-memory/:count']
@['/sqlite-memory/:count']
pub fn (mut app App) sqlite_memory(count int) vweb.Result {
mut insert_stopwatchs := []int{}
mut select_stopwatchs := []int{}
Expand Down
4 changes: 2 additions & 2 deletions tutorials/C2V_translating_simple_programs_and_DOOM/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ It will create `primes.v` with the following contents:
```v
[translated]
@[translated]
module main
fn is_prime(x int) bool {
Expand Down Expand Up @@ -335,4 +335,4 @@ I will also be publishing the same demo with Sqlite and Quake translation.
It's a huge milestone for V and gives V developers access to huge amounts of software
written in C.

We're very excited about this release.
We're very excited about this release.
8 changes: 4 additions & 4 deletions tutorials/building_a_simple_web_blog_with_vweb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fn main() {
vweb.run(app, 8081)
}
['/index']
@['/index']
pub fn (mut app App) index() vweb.Result {
return app.text('Hello world from vweb!')
}
Expand Down Expand Up @@ -336,7 +336,7 @@ Create `new.html`:
// article.v
import vweb
[post]
@[post]
pub fn (mut app App) new_article(title string, text string) vweb.Result {
if title == '' || text == '' {
return app.text('Empty text/title')
Expand Down Expand Up @@ -368,7 +368,7 @@ We need to update `index.html` to add a link to the "new article" page:
Next we need to add the HTML endpoint to our code like we did with `index.html`:

```v ignore
['/new']
@['/new']
pub fn (mut app App) new() vweb.Result {
return $vweb.html()
}
Expand All @@ -386,7 +386,7 @@ in V is very simple:
// article.v
import vweb
['/articles'; get]
@['/articles'; get]
pub fn (mut app App) articles() vweb.Result {
articles := app.find_all_articles()
return app.json(articles)
Expand Down
2 changes: 1 addition & 1 deletion vlib/orm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ non-option fields are defied as NOT NULL when creating tables.
```v ignore
import time
[table: 'foos']
@[table: 'foos']
struct Foo {
id int [primary; sql: serial]
name string
Expand Down
2 changes: 1 addition & 1 deletion vlib/sokol/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const (
sw_start_ms = sw.elapsed().milliseconds()
)
[inline]
@[inline]
fn sintone(periods int, frame int, num_frames int) f32 {
return math.sinf(f32(periods) * (2 * math.pi) * f32(frame) / f32(num_frames))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[params]
@[params]
struct Bar {
bar bool
}
Expand Down
Loading

0 comments on commit b347f54

Please sign in to comment.