Skip to content

Commit

Permalink
Pass along result pointer in bare_load()
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperisager committed Jun 21, 2024
1 parent 411b113 commit c690b2a
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bin/bare.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ main (int argc, char *argv[]) {

uv_buf_t source = uv_buf_init((char *) bare_bundle, bare_bundle_len);

bare_load(bare, "/bare.bundle", &source);
bare_load(bare, "/bare.bundle", &source, NULL);

err = bare_run(bare);
assert(err == 0);
Expand Down
2 changes: 1 addition & 1 deletion include/bare.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ bare_teardown (bare_t *bare, int *exit_code);
* supported module formats.
*/
int
bare_load (bare_t *bare, const char *filename, const uv_buf_t *source);
bare_load (bare_t *bare, const char *filename, const uv_buf_t *source, js_value_t **result);

/**
* Run the I/O event loop.
Expand Down
5 changes: 3 additions & 2 deletions src/bare.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ bare_teardown (bare_t *bare, int *exit_code) {
}

int
bare_load (bare_t *bare, const char *filename, const uv_buf_t *source) {
bare_load (bare_t *bare, const char *filename, const uv_buf_t *source, js_value_t **result) {
int err;

bare_runtime_t *runtime = bare->process.runtime;
Expand All @@ -90,7 +90,8 @@ bare_load (bare_t *bare, const char *filename, const uv_buf_t *source) {
source ? source->base : NULL,
source ? source->len : 0
),
}
},
result
);

return err;
Expand Down
2 changes: 1 addition & 1 deletion src/bare.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,5 +266,5 @@ const Module = require('bare-module')
const url = require('bare-url')

bare.load = function load (filename, source) {
Module.load(url.pathToFileURL(filename), source ? Buffer.from(source) : null)
return Module.load(url.pathToFileURL(filename), source ? Buffer.from(source) : null)
}
4 changes: 2 additions & 2 deletions src/runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ bare_runtime_teardown (bare_runtime_t *runtime, int *exit_code) {
}

int
bare_runtime_load (bare_runtime_t *runtime, const char *filename, bare_source_t source) {
bare_runtime_load (bare_runtime_t *runtime, const char *filename, bare_source_t source, js_value_t **result) {
int err;

js_env_t *env = runtime->env;
Expand Down Expand Up @@ -1133,7 +1133,7 @@ bare_runtime_load (bare_runtime_t *runtime, const char *filename, bare_source_t
err = js_get_global(env, &global);
assert(err == 0);

js_call_function(env, global, load, 2, args, NULL);
js_call_function(env, global, load, 2, args, result);

err = js_close_handle_scope(env, scope);
assert(err == 0);
Expand Down
2 changes: 1 addition & 1 deletion src/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ int
bare_runtime_teardown (bare_runtime_t *runtime, int *exit_code);

int
bare_runtime_load (bare_runtime_t *runtime, const char *filename, bare_source_t source);
bare_runtime_load (bare_runtime_t *runtime, const char *filename, bare_source_t source, js_value_t **result);

int
bare_runtime_run (bare_runtime_t *runtime);
Expand Down
2 changes: 1 addition & 1 deletion src/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ bare_thread_entry (void *opaque) {
runtime->process->on_thread((bare_t *) runtime->process, env);
}

bare_runtime_load(runtime, thread->filename, source);
bare_runtime_load(runtime, thread->filename, source, NULL);

err = bare_runtime_run(runtime);
assert(err == 0);
Expand Down
2 changes: 1 addition & 1 deletion test/argv-empty.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ main (int argc, char *argv[]) {

uv_buf_t source = uv_buf_init("", 0);

bare_load(bare, "/test.js", &source);
bare_load(bare, "/test.js", &source, NULL);

e = bare_run(bare);
assert(e == 0);
Expand Down
2 changes: 1 addition & 1 deletion test/restart.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ main (int argc, char *argv[]) {

uv_buf_t source = uv_buf_init(code, strlen(code));

bare_load(bare, "/test.js", &source);
bare_load(bare, "/test.js", &source, NULL);

e = bare_run(bare);
assert(e == 0);
Expand Down

0 comments on commit c690b2a

Please sign in to comment.