Skip to content

Commit

Permalink
all: replace fn name '@xxx' with 'xxx'
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyi98 committed Oct 12, 2024
1 parent e1e44e3 commit 180d36d
Show file tree
Hide file tree
Showing 40 changed files with 141 additions and 141 deletions.
2 changes: 1 addition & 1 deletion examples/coroutines/coroutines_bench.v
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const run_time = 10 * time.second
fn request(mut mu sync.Mutex, count &int) {
for {
http.get('http://vlang.io/utc_now') or { panic(err) }
mu.@lock()
mu.lock()
unsafe {
(*count)++
}
Expand Down
20 changes: 10 additions & 10 deletions examples/js_dom_draw_benchmark_chart/chart/main.v
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ mut:
}

struct FrameworkBenchmarkResponse {
insert []int
@select []int
update []int
insert []int
select []int
update []int
}

struct FrameworkPlatform {
Expand Down Expand Up @@ -125,9 +125,9 @@ fn insert_framework_benchmark_times() !FrameworkPlatform {

fn select_framework_benchmark_times() !FrameworkPlatform {
numbers := FrameworkPlatform{
v_sqlite_memory: v_sqlite_memory()!.@select
// v_sqlite_file: v_sqlite_file()!.@select
typescript_sqlite_memory: typescript_sqlite_memory()!.@select
v_sqlite_memory: v_sqlite_memory()!.select
// v_sqlite_file: v_sqlite_file()!.select
typescript_sqlite_memory: typescript_sqlite_memory()!.select
}

return numbers
Expand All @@ -136,7 +136,7 @@ fn select_framework_benchmark_times() !FrameworkPlatform {
fn update_framework_benchmark_times() !FrameworkPlatform {
numbers := FrameworkPlatform{
v_sqlite_memory: v_sqlite_memory()!.update
// v_sqlite_file: v_sqlite_file()!.@select
// v_sqlite_file: v_sqlite_file()!.select
typescript_sqlite_memory: typescript_sqlite_memory()!.update
}

Expand All @@ -162,9 +162,9 @@ fn v_sqlite_file() !FrameworkBenchmarkResponse {
// res := http.get(url) or { panic(err) }
// framework_benchmark_response := json.decode(FrameworkBenchmarkResponse, res.body)!
framework_benchmark_response := FrameworkBenchmarkResponse{
insert: []
@select: []
update: []
insert: []
select: []
update: []
}
return framework_benchmark_response
}
Expand Down
30 changes: 15 additions & 15 deletions examples/js_dom_draw_benchmark_chart/v_vweb_orm/src/main.v
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ mut:
}

struct Response {
insert []int
@select []int
update []int
insert []int
select []int
update []int
}

fn main() {
Expand Down Expand Up @@ -93,39 +93,39 @@ pub fn (mut app App) sqlite_memory(count int) vweb.Result {
} or { panic(err) }

response := Response{
insert: insert_stopwatchs
@select: select_stopwatchs
update: update_stopwatchs
insert: insert_stopwatchs
select: select_stopwatchs
update: update_stopwatchs
}
return app.json(response)
}

@['/sqlite-file/:count']
pub fn (mut app App) sqlite_file(count int) vweb.Result {
response := Response{
insert: []
@select: []
update: []
insert: []
select: []
update: []
}
return app.json(response)
}

@['/postgres/:count']
pub fn (mut app App) postgres(count int) vweb.Result {
response := Response{
insert: []
@select: []
update: []
insert: []
select: []
update: []
}
return app.json(response)
}

@['/mysql/:count']
pub fn (mut app App) mysql(count int) vweb.Result {
response := Response{
insert: []
@select: []
update: []
insert: []
select: []
update: []
}
return app.json(response)
}
10 changes: 5 additions & 5 deletions vlib/clipboard/x11/clipboard.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ pub fn (mut cb Clipboard) free() {
}

pub fn (mut cb Clipboard) clear() {
cb.mutex.@lock()
cb.mutex.lock()
C.XSetSelectionOwner(cb.display, cb.selection, Window(0), C.CurrentTime)
C.XFlush(cb.display)
cb.is_owner = false
Expand All @@ -237,7 +237,7 @@ pub fn (mut cb Clipboard) set_text(text string) bool {
if cb.window == Window(0) {
return false
}
cb.mutex.@lock()
cb.mutex.lock()
cb.text = text
cb.is_owner = true
cb.take_ownership()
Expand Down Expand Up @@ -281,7 +281,7 @@ fn (mut cb Clipboard) transmit_selection(xse &C.XSelectionEvent) bool {
C.XChangeProperty(xse.display, xse.requestor, xse.property, cb.get_atom(.xa_atom),
32, C.PropModeReplace, targets.data, targets.len)
} else if cb.is_supported_target(xse.target) && cb.is_owner && cb.text != '' {
cb.mutex.@lock()
cb.mutex.lock()
C.XChangeProperty(xse.display, xse.requestor, xse.property, xse.target, 8, C.PropModeReplace,
cb.text.str, cb.text.len)
cb.mutex.unlock()
Expand Down Expand Up @@ -313,7 +313,7 @@ fn (mut cb Clipboard) start_listener() {
if unsafe { event.xselectionclear.window == cb.window } && unsafe {
event.xselectionclear.selection == cb.selection
} {
cb.mutex.@lock()
cb.mutex.lock()
cb.is_owner = false
cb.text = ''
cb.mutex.unlock()
Expand Down Expand Up @@ -358,7 +358,7 @@ fn (mut cb Clipboard) start_listener() {
} else if unsafe { event.xselection.target == to_be_requested } {
sent_request = false
to_be_requested = Atom(0)
cb.mutex.@lock()
cb.mutex.lock()
prop := unsafe {
read_property(event.xselection.display, event.xselection.requestor,
event.xselection.property)
Expand Down
6 changes: 3 additions & 3 deletions vlib/context/cancel.v
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ pub fn (ctx &CancelContext) deadline() ?time.Time {
}

pub fn (mut ctx CancelContext) done() chan int {
ctx.mutex.@lock()
ctx.mutex.lock()
done := ctx.done
ctx.mutex.unlock()
return done
}

pub fn (mut ctx CancelContext) err() IError {
ctx.mutex.@lock()
ctx.mutex.lock()
err := ctx.err
ctx.mutex.unlock()
return err
Expand All @@ -89,7 +89,7 @@ fn (mut ctx CancelContext) cancel(remove_from_parent bool, err IError) {
panic('context: internal error: missing cancel error')
}

ctx.mutex.@lock()
ctx.mutex.lock()
if ctx.err !is none {
ctx.mutex.unlock()
// already canceled
Expand Down
4 changes: 2 additions & 2 deletions vlib/context/onecontext/onecontext.v
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub fn (octx OneContext) done() chan int {
}

pub fn (mut octx OneContext) err() IError {
octx.err_mutex.@lock()
octx.err_mutex.lock()
defer {
octx.err_mutex.unlock()
}
Expand Down Expand Up @@ -102,7 +102,7 @@ pub fn (octx OneContext) str() string {

pub fn (mut octx OneContext) cancel(err IError) {
octx.cancel_fn()
octx.err_mutex.@lock()
octx.err_mutex.lock()
octx.err = err
octx.err_mutex.unlock()
if !octx.done.closed {
Expand Down
2 changes: 1 addition & 1 deletion vlib/db/mysql/mysql_orm_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ fn test_mysql_orm() {
data: [orm.string_to_primitive('Louis'), orm.int_to_primitive(101)]
}) or { panic(err) }

res := db.@select(orm.SelectConfig{
res := db.select(orm.SelectConfig{
table: 'Test'
has_where: true
fields: ['id', 'name', 'age']
Expand Down
4 changes: 2 additions & 2 deletions vlib/db/mysql/orm.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module mysql
import orm
import time

// @select is used internally by V's ORM for processing `SELECT ` queries.
pub fn (db DB) @select(config orm.SelectConfig, data orm.QueryData, where orm.QueryData) ![][]orm.Primitive {
// select is used internally by V's ORM for processing `SELECT ` queries.
pub fn (db DB) select(config orm.SelectConfig, data orm.QueryData, where orm.QueryData) ![][]orm.Primitive {
query := orm.orm_select_gen(config, '`', false, '?', 0, where)
mut result := [][]orm.Primitive{}
mut stmt := db.init_stmt(query)
Expand Down
4 changes: 2 additions & 2 deletions vlib/db/pg/orm.v
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import net.conv

// sql expr

// @select is used internally by V's ORM for processing `SELECT ` queries
pub fn (db DB) @select(config orm.SelectConfig, data orm.QueryData, where orm.QueryData) ![][]orm.Primitive {
// select is used internally by V's ORM for processing `SELECT ` queries
pub fn (db DB) select(config orm.SelectConfig, data orm.QueryData, where orm.QueryData) ![][]orm.Primitive {
query := orm.orm_select_gen(config, '"', true, '$', 1, where)

rows := pg_stmt_worker(db, query, where, data)!
Expand Down
2 changes: 1 addition & 1 deletion vlib/db/pg/pg_orm_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ fn test_pg_orm() {
data: [orm.string_to_primitive('Louis'), orm.int_to_primitive(101)]
}) or { panic(err) }

res := db.@select(orm.SelectConfig{
res := db.select(orm.SelectConfig{
table: 'Test'
is_count: false
has_where: true
Expand Down
6 changes: 3 additions & 3 deletions vlib/db/sqlite/orm.v
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ module sqlite
import orm
import time

// @select is used internally by V's ORM for processing `SELECT ` queries
pub fn (db DB) @select(config orm.SelectConfig, data orm.QueryData, where orm.QueryData) ![][]orm.Primitive {
// select is used internally by V's ORM for processing `SELECT ` queries
pub fn (db DB) select(config orm.SelectConfig, data orm.QueryData, where orm.QueryData) ![][]orm.Primitive {
// 1. Create query and bind necessary data
query := orm.orm_select_gen(config, '`', true, '?', 1, where)
$if trace_sqlite ? {
eprintln('> @select query: "${query}"')
eprintln('> select query: "${query}"')
}
stmt := db.new_init_stmt(query)!
defer {
Expand Down
2 changes: 1 addition & 1 deletion vlib/db/sqlite/sqlite_orm_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn test_sqlite_orm() {
data: [orm.string_to_primitive('Louis'), orm.i64_to_primitive(100)]
}) or { panic(err) }

res := db.@select(orm.SelectConfig{
res := db.select(orm.SelectConfig{
table: 'Test'
has_where: true
fields: ['id', 'name', 'age']
Expand Down
14 changes: 7 additions & 7 deletions vlib/log/safe_log.v
Original file line number Diff line number Diff line change
Expand Up @@ -32,51 +32,51 @@ pub fn (mut x ThreadSafeLog) free() {

// set_level changes the log level
pub fn (mut x ThreadSafeLog) set_level(level Level) {
x.mu.@lock()
x.mu.lock()
x.Log.set_level(level)
x.mu.unlock()
}

// set_always_flush called with true, will make the log flush after every single .fatal(), .error(), .warn(), .info(), .debug() call.
// That can be much slower, if you plan to do lots of frequent calls, but if your program exits early or crashes, your logs will be more complete.
pub fn (mut x ThreadSafeLog) set_always_flush(should_flush bool) {
x.mu.@lock()
x.mu.lock()
x.Log.set_always_flush(should_flush)
x.mu.unlock()
}

// debug logs a debug message
pub fn (mut x ThreadSafeLog) debug(s string) {
x.mu.@lock()
x.mu.lock()
x.Log.debug(s)
x.mu.unlock()
}

// info logs an info messagep
pub fn (mut x ThreadSafeLog) info(s string) {
x.mu.@lock()
x.mu.lock()
x.Log.info(s)
x.mu.unlock()
}

// warn logs a warning message
pub fn (mut x ThreadSafeLog) warn(s string) {
x.mu.@lock()
x.mu.lock()
x.Log.warn(s)
x.mu.unlock()
}

// error logs an error message
pub fn (mut x ThreadSafeLog) error(s string) {
x.mu.@lock()
x.mu.lock()
x.Log.error(s)
x.mu.unlock()
}

// fatal logs a fatal message, and panics
@[noreturn]
pub fn (mut x ThreadSafeLog) fatal(s string) {
x.mu.@lock()
x.mu.lock()
defer {
// TODO: Log.fatal() is marked as noreturn, but this defer is allowed.
// Think whether it should be, or if it should be a compiler notice at least,
Expand Down
2 changes: 1 addition & 1 deletion vlib/net/aasocket.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fn C.ioctlsocket(s int, cmd int, argp &u32) int

fn C.fcntl(fd int, cmd int, arg ...voidptr) int

fn C.@select(ndfs int, readfds &C.fd_set, writefds &C.fd_set, exceptfds &C.fd_set, timeout &C.timeval) int
fn C.select(ndfs int, readfds &C.fd_set, writefds &C.fd_set, exceptfds &C.fd_set, timeout &C.timeval) int

fn C.FD_ZERO(fdset &C.fd_set)

Expand Down
10 changes: 5 additions & 5 deletions vlib/net/common.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub fn close(handle int) ! {
}

// Select waits for an io operation (specified by parameter `test`) to be available
fn @select(handle int, test Select, timeout time.Duration) !bool {
fn select(handle int, test Select, timeout time.Duration) !bool {
set := C.fd_set{}

C.FD_ZERO(&set)
Expand All @@ -130,13 +130,13 @@ fn @select(handle int, test Select, timeout time.Duration) !bool {

match test {
.read {
socket_error(C.@select(handle + 1, &set, C.NULL, C.NULL, timeval_timeout))!
socket_error(C.select(handle + 1, &set, C.NULL, C.NULL, timeval_timeout))!
}
.write {
socket_error(C.@select(handle + 1, C.NULL, &set, C.NULL, timeval_timeout))!
socket_error(C.select(handle + 1, C.NULL, &set, C.NULL, timeval_timeout))!
}
.except {
socket_error(C.@select(handle + 1, C.NULL, C.NULL, &set, timeval_timeout))!
socket_error(C.select(handle + 1, C.NULL, C.NULL, &set, timeval_timeout))!
}
}

Expand All @@ -149,7 +149,7 @@ fn select_deadline(handle int, test Select, deadline time.Time) !bool {
infinite := deadline.unix() == 0
for infinite || time.now() <= deadline {
timeout := if infinite { infinite_timeout } else { deadline - time.now() }
ready := @select(handle, test, timeout) or {
ready := select(handle, test, timeout) or {
if err.code() == C.EINTR {
// errno is 4, Spurious wakeup from signal, keep waiting
continue
Expand Down
Loading

0 comments on commit 180d36d

Please sign in to comment.