Skip to content

Commit 19fe714

Browse files
committed
use less ptr keyword in code
1 parent 8712bb5 commit 19fe714

File tree

9 files changed

+216
-219
lines changed

9 files changed

+216
-219
lines changed

examples/box.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var box = Box(
2020
contains: [1, 2, 3]
2121
)
2222

23-
proc box_area(ctx: ptr JSContext, this: JSValue, argc: cint, argv: ptr UncheckedArray[JSValue]): JSValue {.cdecl.} =
23+
proc box_area(ctx: JSContext, this: JSValue, argc: cint, argv: ptr UncheckedArray[JSValue]): JSValue {.cdecl.} =
2424
assert this.tag == JS_TAG_OBJECT
2525
var width, height: int64
2626
discard JS_ToInt64(ctx, addr width, JS_GetPropertyStr(ctx, this, "width"))

examples/fib.nim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ proc fib(n: int32): int32 =
1010

1111

1212

13-
proc js_fib(ctx: ptr JSContext, this_val: JSValue, argc: cint, argv: ptr UncheckedArray[JSValue]): JSValue {.cdecl.} =
13+
proc js_fib(ctx: JSContext, this_val: JSValue, argc: cint, argv: ptr UncheckedArray[JSValue]): JSValue {.cdecl.} =
1414
var n: int32
1515

1616
if JS_ToInt32(ctx, addr n, argv[0]) != 0:
@@ -21,11 +21,11 @@ let js_fib_funcs = [
2121
JS_CFUNC_DEF("fib", 1, js_fib)
2222
]
2323

24-
proc js_fib_init(ctx: ptr JSContext, m: ptr JSModuleDef): cint {.cdecl.} =
24+
proc js_fib_init(ctx: JSContext, m: JSModuleDef): cint {.cdecl.} =
2525
JS_SetModuleExportList(ctx, m, unsafeAddr js_fib_funcs[0], js_fib_funcs.len.cint)
2626

2727

28-
proc js_init_module*(ctx: ptr JSContext, moduleName: cstring): ptr JSModuleDef {.exportc, dynlib.} =
28+
proc js_init_module*(ctx: JSContext, moduleName: cstring): JSModuleDef {.exportc, dynlib.} =
2929
result = JS_NewCModule(ctx, module_name, js_fib_init);
3030
if result != nil:
3131
discard JS_AddModuleExportList(ctx, result, unsafeAddr js_fib_funcs[0], js_fib_funcs.len.cint);

examples/hello.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var hello = [byte(0x02), 0x04, 0x0e, 0x63, 0x6f, 0x6e, 0x73, 0x6f,
1414

1515
var args: array[1, cstring]
1616

17-
proc JS_NewCustomContext(rt: ptr JSRuntime): ptr JSContext {.cdecl.} =
17+
proc JS_NewCustomContext(rt: JSRuntime): JSContext {.cdecl.} =
1818
result = JS_NewContextRaw(rt)
1919
if result != nil:
2020
JS_AddIntrinsicBaseObjects(result)

examples/hello_function.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import quickjs
22

33

4-
proc hello(ctx: ptr JSContext, this_val: JSValue, argc: cint, argv: ptr UncheckedArray[JSValue]): JSValue {.cdecl.} =
4+
proc hello(ctx: JSContext, this_val: JSValue, argc: cint, argv: ptr UncheckedArray[JSValue]): JSValue {.cdecl.} =
55
echo "Hello world, greating from Nim!"
66

77

examples/hello_object.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import quickjs
22

33

4-
proc hello_greating(ctx: ptr JSContext, this_val: JSValue, argc: cint, argv: ptr UncheckedArray[JSValue]): JSValue {.cdecl.} =
4+
proc hello_greating(ctx: JSContext, this_val: JSValue, argc: cint, argv: ptr UncheckedArray[JSValue]): JSValue {.cdecl.} =
55
let name = JS_ToCString(ctx, argv[0])
66
echo "Hello world, greating from ", name
77

src/quickjs.nim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ export core, helpers, libc
33

44
type
55
Engine* = object
6-
ctx: ptr JSContext
7-
rt: ptr JSRuntime
6+
ctx: JSContext
7+
rt: JSRuntime
88

99
proc `=destroy`*(e: var Engine) =
1010
JS_FreeContext(e.ctx)
1111
JS_FreeRuntime(e.rt)
1212

1313

14-
proc initCustomContext(rt: ptr JSRuntime): ptr JSContext {.cdecl.} =
14+
proc initCustomContext(rt: JSRuntime): JSContext {.cdecl.} =
1515
result = JS_NewContextRaw(rt)
1616
if result != nil:
1717
JS_AddIntrinsicEval(result)

src/quickjs/core.nim

Lines changed: 186 additions & 189 deletions
Large diffs are not rendered by default.

src/quickjs/helpers.nim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ proc JS_CFUNC_DEF*(name: string, length: uint8, fn1: JSCFunction): JSCFunctionLi
1212
cfunc: JSCFunctionType(generic: fn1)
1313
)))
1414

15-
proc JS_CFUNC_MAGIC_DEF*(name: string, length: uint8, fn1: proc (ctx: ptr JSContext; this_val: JSValue; argc: int32; argv: ptr UncheckedArray[JSValue]; magic: int32): JSValue {.cdecl.}, magic: int16): JSCFunctionListEntry {.inline.} =
15+
proc JS_CFUNC_MAGIC_DEF*(name: string, length: uint8, fn1: proc (ctx: JSContext; this_val: JSValue; argc: int32; argv: ptr UncheckedArray[JSValue]; magic: int32): JSValue {.cdecl.}, magic: int16): JSCFunctionListEntry {.inline.} =
1616
result = JSCFunctionListEntry(
1717
name: name,
1818
prop_flags: JS_PROP_WRITABLE or JS_PROP_CONFIGURABLE,
@@ -27,7 +27,7 @@ proc JS_CFUNC_MAGIC_DEF*(name: string, length: uint8, fn1: proc (ctx: ptr JSCon
2727

2828
#proc JS_CFUNC_SPECIAL_DEF*(name: string, length: uint8, cproto, func1) { name, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE, JS_DEF_CFUNC, 0, .u = { .func = { length, JS_CFUNC_ ## cproto, { .cproto = func1 } } } }
2929

30-
proc JS_ITERATOR_NEXT_DEF*(name: string, length: uint8, fn1: proc (ctx: ptr JSContext; this_val: JSValue; argc: int32; argv: ptr UncheckedArray[JSValue]; pdone: ptr int32; magic: int32): JSValue {.cdecl.}, magic: int16): JSCFunctionListEntry {.inline.} =
30+
proc JS_ITERATOR_NEXT_DEF*(name: string, length: uint8, fn1: proc (ctx: JSContext; this_val: JSValue; argc: int32; argv: ptr UncheckedArray[JSValue]; pdone: ptr int32; magic: int32): JSValue {.cdecl.}, magic: int16): JSCFunctionListEntry {.inline.} =
3131
result = JSCFunctionListEntry(
3232
name: name,
3333
prop_flags: JS_PROP_WRITABLE or JS_PROP_CONFIGURABLE,
@@ -41,7 +41,7 @@ proc JS_ITERATOR_NEXT_DEF*(name: string, length: uint8, fn1: proc (ctx: ptr JSCo
4141
iterator_next: fn1)
4242
)))
4343

44-
proc JS_CGETSET_DEF*(name: string, fgetter: proc (ctx: ptr JSContext; this_val: JSValue): JSValue {.cdecl.}, fsetter: proc (ctx: ptr JSContext; this_val: JSValue; val: JSValue): JSValue {.cdecl.}): JSCFunctionListEntry {.inline.} =
44+
proc JS_CGETSET_DEF*(name: string, fgetter: proc (ctx: JSContext; this_val: JSValue): JSValue {.cdecl.}, fsetter: proc (ctx: JSContext; this_val: JSValue; val: JSValue): JSValue {.cdecl.}): JSCFunctionListEntry {.inline.} =
4545
result = JSCFunctionListEntry(
4646
name: name,
4747
prop_flags: JS_PROP_CONFIGURABLE,
@@ -50,7 +50,7 @@ proc JS_CGETSET_DEF*(name: string, fgetter: proc (ctx: ptr JSContext; this_val:
5050
result.u.getset.fget.getter = fgetter
5151
result.u.getset.fset.setter = fsetter
5252

53-
proc JS_CGETSET_MAGIC_DEF*(name: string, fgetter: proc (ctx: ptr JSContext; this_val: JSValue, magic: int32): JSValue {.cdecl.}, fsetter: proc (ctx: ptr JSContext; this_val: JSValue; val: JSValue, magic: int32): JSValue {.cdecl.}, magic: int16): JSCFunctionListEntry {.inline.} =
53+
proc JS_CGETSET_MAGIC_DEF*(name: string, fgetter: proc (ctx: JSContext; this_val: JSValue, magic: int32): JSValue {.cdecl.}, fsetter: proc (ctx: JSContext; this_val: JSValue; val: JSValue, magic: int32): JSValue {.cdecl.}, magic: int16): JSCFunctionListEntry {.inline.} =
5454
result = JSCFunctionListEntry(
5555
name: name,
5656
prop_flags: JS_PROP_CONFIGURABLE,

src/quickjs/libc.nim

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
import private/build_config, core
22

3-
proc js_init_module_std*(ctx: ptr JSContext,
4-
module_name: cstring): ptr JSModuleDef {.importc: "js_init_module_std",
3+
proc js_init_module_std*(ctx: JSContext,
4+
module_name: cstring): JSModuleDef {.importc: "js_init_module_std",
55
header: headerquickjs.}
6-
proc js_init_module_os*(ctx: ptr JSContext,
7-
module_name: cstring): ptr JSModuleDef {.importc: "js_init_module_os",
6+
proc js_init_module_os*(ctx: JSContext,
7+
module_name: cstring): JSModuleDef {.importc: "js_init_module_os",
88
header: headerquickjs.}
9-
proc js_std_add_helpers*(ctx: ptr JSContext, argc: int32, argv: ptr cstring) {.
9+
proc js_std_add_helpers*(ctx: JSContext, argc: int32, argv: ptr cstring) {.
1010
importc: "js_std_add_helpers", header: headerquickjs.}
11-
proc js_std_loop*(ctx: ptr JSContext) {.importc: "js_std_loop",
11+
proc js_std_loop*(ctx: JSContext) {.importc: "js_std_loop",
1212
header: headerquickjs.}
13-
proc js_std_init_handlers*(tr: ptr JsRunTime) {.importc: "js_std_init_handlers",
13+
proc js_std_init_handlers*(tr: JSRunTime) {.importc: "js_std_init_handlers",
1414
header: headerquickjs.}
15-
proc js_std_free_handlers*(rt: ptr JSRuntime) {.importc: "js_std_free_handlers",
15+
proc js_std_free_handlers*(rt: JSRuntime) {.importc: "js_std_free_handlers",
1616
header: headerquickjs.}
17-
proc js_std_dump_error*(ctx: ptr JSContext) {.importc: "js_std_dump_error",
17+
proc js_std_dump_error*(ctx: JSContext) {.importc: "js_std_dump_error",
1818
header: headerquickjs.}
19-
proc js_load_file*(ctx: ptr JSContext, pbuf_len: ptr uint32,
19+
proc js_load_file*(ctx: JSContext, pbuf_len: ptr uint32,
2020
filename: cstring): ptr uint8 {.importc: "js_load_file",
2121
header: headerquickjs.}
22-
proc js_module_set_import_meta*(ctx: ptr JSContext, func_val: JSValueConst,
22+
proc js_module_set_import_meta*(ctx: JSContext, func_val: JSValueConst,
2323
use_realpath: bool, is_main: bool): int {.importc: "js_module_set_import_meta",
2424
header: headerquickjs.}
25-
proc js_module_loader*(ctx: ptr JSContext, module_name: cstring,
26-
opaque: pointer): ptr JSModuleDef {.importc, cdecl.}
27-
proc js_std_eval_binary*(ctx: ptr JSContext, buf: ptr uint8, buf_len: uint32,
25+
proc js_module_loader*(ctx: JSContext, module_name: cstring,
26+
opaque: pointer): JSModuleDef {.importc, cdecl.}
27+
proc js_std_eval_binary*(ctx: JSContext, buf: ptr uint8, buf_len: uint32,
2828
flags: int32) {.importc: "js_std_eval_binary", header: headerquickjs.}
29-
proc js_std_promise_rejection_tracker*(ctx: ptr JSContext, promise: JSValueConst,
29+
proc js_std_promise_rejection_tracker*(ctx: JSContext, promise: JSValueConst,
3030
reason: JSValueConst, is_handled: bool, opaque: pointer) {.importc: "js_std_promise_rejection_tracker",
3131
header: headerquickjs.}
32-
proc js_std_set_worker_new_context_func*(fn: proc(rt: ptr JSRuntime): ptr JSContext {.cdecl.}) {.importc: "js_std_set_worker_new_context_func",
32+
proc js_std_set_worker_new_context_func*(fn: proc(rt: JSRuntime): JSContext {.cdecl.}) {.importc: "js_std_set_worker_new_context_func",
3333
header: headerquickjs.}

0 commit comments

Comments
 (0)