Skip to content

Commit

Permalink
all: update attributes to use new syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-conigliaro committed Nov 15, 2023
1 parent dd81cb9 commit 7579293
Show file tree
Hide file tree
Showing 739 changed files with 2,982 additions and 2,982 deletions.
2 changes: 1 addition & 1 deletion bench/vectors/vectors.v
Expand Up @@ -16,7 +16,7 @@ const (
separation_distance = 5.0
)

[direct_array_access]
@[direct_array_access]
fn main() {
mut positions := [boids_count]Vector{}
mut velocities := [boids_count]Vector{}
Expand Down
6 changes: 3 additions & 3 deletions cmd/tools/repeat.v
Expand Up @@ -40,7 +40,7 @@ mut:
nmaxs int // number of maximums to discard
}

[unsafe]
@[unsafe]
fn (mut result CmdResult) free() {
unsafe {
result.cmd.free()
Expand All @@ -52,7 +52,7 @@ fn (mut result CmdResult) free() {
}
}

[unsafe]
@[unsafe]
fn (mut context Context) free() {
unsafe {
context.commands.free()
Expand All @@ -75,7 +75,7 @@ mut:
nmaxs int // number of discarded slowest results
}

[unsafe]
@[unsafe]
fn (mut a Aints) free() {
unsafe { a.values.free() }
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/test_if_v_test_system_works.v
Expand Up @@ -40,7 +40,7 @@ fn cleanup_tdir() {

type MyResult = string

[noreturn]
@[noreturn]
fn (result MyResult) fail(reason string) {
eprintln('> ${reason}, but it does not. Result:\n${result}')
exit(1)
Expand Down
22 changes: 11 additions & 11 deletions cmd/tools/vast/cjson.v
Expand Up @@ -53,57 +53,57 @@ fn C.cJSON_Delete(voidptr)

fn C.cJSON_Print(voidptr) &u8

[inline]
@[inline]
fn create_object() &C.cJSON {
return C.cJSON_CreateObject()
}

[inline]
@[inline]
fn create_array() &C.cJSON {
return C.cJSON_CreateArray()
}

[inline]
@[inline]
fn create_string(val string) &C.cJSON {
return C.cJSON_CreateString(val.str)
}

[inline]
@[inline]
fn create_number(val f64) &C.cJSON {
return C.cJSON_CreateNumber(val)
}

[inline]
@[inline]
fn create_bool(val bool) &C.cJSON {
return C.cJSON_CreateBool(val)
}

[inline]
@[inline]
fn create_true() &C.cJSON {
return C.cJSON_CreateTrue()
}

[inline]
@[inline]
fn create_false() &C.cJSON {
return C.cJSON_CreateFalse()
}

[inline]
@[inline]
fn create_null() &C.cJSON {
return C.cJSON_CreateNull()
}

[inline]
@[inline]
fn delete(b voidptr) {
C.cJSON_Delete(b)
}

[inline]
@[inline]
fn add_item_to_object(obj &C.cJSON, key string, item &C.cJSON) {
C.cJSON_AddItemToObject(obj, key.str, item)
}

[inline]
@[inline]
fn add_item_to_array(obj &C.cJSON, item &C.cJSON) {
C.cJSON_AddItemToArray(obj, item)
}
Expand Down
10 changes: 5 additions & 5 deletions cmd/tools/vast/vast.v
Expand Up @@ -150,13 +150,13 @@ mut:
pub type Node = C.cJSON

// create an object node
[inline]
@[inline]
fn new_object() &Node {
return C.cJSON_CreateObject()
}

// add item to object node
[inline]
@[inline]
fn (node &Node) add(key string, child &Node) {
if context.hide_names.len > 0 && key in context.hide_names {
return
Expand All @@ -168,7 +168,7 @@ fn (node &Node) add(key string, child &Node) {
}

// add item to object node
[inline]
@[inline]
fn (node &Node) add_terse(key string, child &Node) {
if context.hide_names.len > 0 && key in context.hide_names {
return
Expand All @@ -177,13 +177,13 @@ fn (node &Node) add_terse(key string, child &Node) {
}

// create an array node
[inline]
@[inline]
fn new_array() &Node {
return C.cJSON_CreateArray()
}

// add item to array node
[inline]
@[inline]
fn (node &Node) add_item(child &Node) {
add_item_to_array(node, child)
}
Expand Down
36 changes: 18 additions & 18 deletions cmd/tools/vcreate/project_model_web.v
Expand Up @@ -151,7 +151,7 @@ div.products-table {
import vweb
['/controller/auth'; post]
@['/controller/auth'; post]
pub fn (mut app App) controller_auth(username string, password string) vweb.Result {
response := app.service_auth(username, password) or {
app.set_status(400, '')
Expand All @@ -167,8 +167,8 @@ pub fn (mut app App) controller_auth(username string, password string) vweb.Resu
content: 'module main
struct AuthRequestDto {
username string [nonull]
password string [nonull]
username string @[nonull]
password string @[nonull]
}
'
}
Expand Down Expand Up @@ -399,7 +399,7 @@ import vweb
import encoding.base64
import json
['/controller/products'; get]
@['/controller/products'; get]
pub fn (mut app App) controller_get_all_products() vweb.Result {
token := app.req.header.get_custom('token') or { '' }
Expand All @@ -425,7 +425,7 @@ pub fn (mut app App) controller_get_all_products() vweb.Result {
// return app.text('response')
}
['/controller/product/create'; post]
@['/controller/product/create'; post]
pub fn (mut app App) controller_create_product(product_name string) vweb.Result {
if product_name == '' {
app.set_status(400, '')
Expand Down Expand Up @@ -461,12 +461,12 @@ pub fn (mut app App) controller_create_product(product_name string) vweb.Result
path: join_path(c.name, 'src', 'product_entities.v')
content: "module main
[table: 'products']
@[table: 'products']
struct Product {
id int [primary; sql: serial]
id int @[primary; sql: serial]
user_id int
name string [nonull; sql_type: 'TEXT']
created_at string [default: 'CURRENT_TIMESTAMP']
name string @[nonull; sql_type: 'TEXT']
created_at string @[default: 'CURRENT_TIMESTAMP']
}
"
}
Expand Down Expand Up @@ -562,7 +562,7 @@ pub fn get_product(token string) ![]User {
import vweb
['/products'; get]
@['/products'; get]
pub fn (mut app App) products() !vweb.Result {
token := app.get_cookie('token') or {
app.set_status(400, '')
Expand All @@ -586,7 +586,7 @@ import vweb
import encoding.base64
import json
['/controller/users'; get]
@['/controller/users'; get]
pub fn (mut app App) controller_get_all_user() vweb.Result {
// token := app.get_cookie('token') or { '' }
token := app.req.header.get_custom('token') or { '' }
Expand All @@ -603,7 +603,7 @@ pub fn (mut app App) controller_get_all_user() vweb.Result {
return app.json(response)
}
['/controller/user'; get]
@['/controller/user'; get]
pub fn (mut app App) controller_get_user() vweb.Result {
// token := app.get_cookie('token') or { '' }
token := app.req.header.get_custom('token') or { '' }
Expand All @@ -629,7 +629,7 @@ pub fn (mut app App) controller_get_user() vweb.Result {
return app.json(response)
}
['/controller/user/create'; post]
@['/controller/user/create'; post]
pub fn (mut app App) controller_create_user(username string, password string) vweb.Result {
if username == '' {
app.set_status(400, '')
Expand All @@ -652,14 +652,14 @@ pub fn (mut app App) controller_create_user(username string, password string) vw
path: join_path(c.name, 'src', 'user_entities.v')
content: "module main
[table: 'users']
@[table: 'users']
pub struct User {
mut:
id int [primary; sql: serial]
username string [nonull; sql_type: 'TEXT'; unique]
password string [nonull; sql_type: 'TEXT']
id int @[primary; sql: serial]
username string @[nonull; sql_type: 'TEXT'; unique]
password string @[nonull; sql_type: 'TEXT']
active bool
products []Product [fkey: 'user_id']
products []Product @[fkey: 'user_id']
}
"
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/vdoc/tests/vdoc_file_test.v
Expand Up @@ -114,7 +114,7 @@ fn clean_line_endings(s string) string {
return res
}

[params]
@[params]
struct CheckOutputParams {
program string = 'some/dir/main.v'
cmd string = 'v doc'
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/vdoc/utils.v
Expand Up @@ -9,7 +9,7 @@ import v.token
import strings
import v.pref

[inline]
@[inline]
fn slug(title string) string {
return title.replace(' ', '-')
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/tools/vdoc/vdoc.v
Expand Up @@ -21,9 +21,9 @@ enum OutputType {
stdout
}

[heap]
@[heap]
struct VDoc {
cfg Config [required]
cfg Config @[required]
mut:
docs []doc.Doc
assets map[string]string
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/vfmt.v
Expand Up @@ -351,7 +351,7 @@ fn get_compile_name_of_potential_v_project(file string) string {
return pfolder
}

[noreturn]
@[noreturn]
fn verror(s string) {
util.verror('vfmt error', s)
}
2 changes: 1 addition & 1 deletion cmd/tools/vls.v
Expand Up @@ -418,7 +418,7 @@ fn (upd VlsUpdater) error_details(err IError) string {
}
}

[noreturn]
@[noreturn]
fn (upd VlsUpdater) cli_error(err IError) {
match upd.output {
.text {
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/vpm/common.v
Expand Up @@ -39,7 +39,7 @@ mut:
exec_err bool
}

[params]
@[params]
struct ErrorOptions {
details string
verbose bool // is used to only output the error message if the verbose setting is enabled.
Expand Down
4 changes: 2 additions & 2 deletions cmd/tools/vwatch.v
Expand Up @@ -64,7 +64,7 @@ struct VFileStat {
mtime i64
}

[unsafe]
@[unsafe]
fn (mut vfs VFileStat) free() {
unsafe { vfs.path.free() }
}
Expand Down Expand Up @@ -98,7 +98,7 @@ mut:
only_watch []string // If not empty, *all* files that trigger updates, should match *at least one* of these s.match_glob() patterns. This is also triggered for vweb apps, to monitor for just *.v,*.js,*.css,*.html in vweb projects.
}

[if debug_vwatch ?]
@[if debug_vwatch ?]
fn (mut context Context) elog(msg string) {
eprintln('> vwatch ${context.pid}, ${msg}')
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/tools/vwhere/finder.v
Expand Up @@ -235,9 +235,9 @@ fn (fdr Finder) str() string {

// Match is one result of the search_for_matches() process
struct Match {
path string [required]
line int [required]
text string [required]
path string @[required]
line int @[required]
text string @[required]
}

fn (mtc Match) show() {
Expand Down

0 comments on commit 7579293

Please sign in to comment.