Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
XuJiandong committed Oct 12, 2023
1 parent d2fe23a commit a220c57
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 21 deletions.
14 changes: 1 addition & 13 deletions docs/syscalls.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ and `index`.

Example:
```js
ckb.mount(source, index)
ckb.mount(index, source)
```

Arguments: source (the source of the cell to load), index (the index of the cell
Expand Down Expand Up @@ -404,18 +404,6 @@ Return value(s): memory size in bytes

See also: [`ckb_current_memory` syscall](https://github.com/nervosnetwork/rfcs/pull/418/files)

#### ckb.mount
Description: Load the file system in the cell.

Example:
```js
ckb.mount(2, ckb.SOURCE_CELL_DEP)
```

Arguments: index (the index of the cell), source (the source of the cell)

Return value(s): none

## Exported Constants

Most constants here are directly taken from [ckb_consts.h](https://github.com/nervosnetwork/ckb-system-scripts/blob/master/c/ckb_consts.h):
Expand Down
9 changes: 2 additions & 7 deletions quickjs/ckb_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ static JSValue mount(JSContext *ctx, JSValueConst this_value, int argc, JSValueC
uint8_t *addr = JS_GetArrayBuffer(ctx, &psize, buf);
int err = ckb_load_fs(addr, psize);
if (err != 0) {
ThrowError(ctx, SyscallErrorUnknown, "ckb_load_fs failed");
return JS_EXCEPTION;
} else {
return JS_UNDEFINED;
Expand Down Expand Up @@ -536,14 +537,8 @@ int js_init_module_ckb(JSContext *ctx) {
JS_SetPropertyStr(ctx, ckb, "set_content", JS_NewCFunction(ctx, syscall_set_content, "set_content", 1));
JS_SetPropertyStr(ctx, ckb, "get_memory_limit",
JS_NewCFunction(ctx, syscall_get_memory_limit, "get_memory_limit", 0));
<<<<<<< HEAD
JS_SetPropertyStr(ctx, ckb, "current_memory",
JS_NewCFunction(ctx, syscall_current_memory, "current_memory", 0));
JS_SetPropertyStr(ctx, ckb, "mount",
JS_NewCFunction(ctx, mount, "mount", 2));
=======
JS_SetPropertyStr(ctx, ckb, "current_memory", JS_NewCFunction(ctx, syscall_current_memory, "current_memory", 0));
>>>>>>> 8e446b0 (Add simple UDT example)
JS_SetPropertyStr(ctx, ckb, "mount", JS_NewCFunction(ctx, mount, "mount", 2));
JS_SetPropertyStr(ctx, ckb, "SOURCE_INPUT", JS_NewInt64(ctx, CKB_SOURCE_INPUT));
JS_SetPropertyStr(ctx, ckb, "SOURCE_OUTPUT", JS_NewInt64(ctx, CKB_SOURCE_OUTPUT));
JS_SetPropertyStr(ctx, ckb, "SOURCE_CELL_DEP", JS_NewInt64(ctx, CKB_SOURCE_CELL_DEP));
Expand Down
2 changes: 1 addition & 1 deletion quickjs/qjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void js_std_dump_error(JSContext *ctx) {
void js_std_loop(JSContext *ctx) {
JSContext *ctx1;
int err;
for(;;) {
for (;;) {
err = JS_ExecutePendingJob(JS_GetRuntime(ctx), &ctx1);
if (err <= 0) {
if (err < 0) {
Expand Down

0 comments on commit a220c57

Please sign in to comment.