summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2018-06-11 20:49:57 +0200
committerRyan Dahl <ry@tinyclouds.org>2018-06-11 20:49:57 +0200
commit56c3ac464eb5f9287b9bae0dad4dfabfb3534a1c (patch)
tree6ed1b57aba7162fb49857c134a7a8e110b0afa90
parent482fc3a2ce6ef6c3064486b2a8c3ddc51950a4c5 (diff)
Rename deno_load to deno_execute.
-rw-r--r--deno2/deno.cc14
-rw-r--r--deno2/include/deno.h2
-rw-r--r--deno2/mock_runtime_test.cc14
3 files changed, 15 insertions, 15 deletions
diff --git a/deno2/deno.cc b/deno2/deno.cc
index c21dc43c0..de03ed426 100644
--- a/deno2/deno.cc
+++ b/deno2/deno.cc
@@ -153,8 +153,8 @@ void Pub(const v8::FunctionCallbackInfo<v8::Value>& args) {
}
}
-bool Load(v8::Local<v8::Context> context, const char* name_s,
- const char* source_s) {
+bool Execute(v8::Local<v8::Context> context, const char* js_filename,
+ const char* js_source) {
auto* isolate = context->GetIsolate();
v8::Isolate::Scope isolate_scope(isolate);
v8::HandleScope handle_scope(isolate);
@@ -163,8 +163,8 @@ bool Load(v8::Local<v8::Context> context, const char* name_s,
v8::TryCatch try_catch(isolate);
- auto name = v8_str(name_s);
- auto source = v8_str(source_s);
+ auto name = v8_str(js_filename);
+ auto source = v8_str(js_source);
v8::ScriptOrigin origin(name);
@@ -217,7 +217,7 @@ v8::StartupData MakeSnapshot(v8::StartupData* prev_natives_blob,
auto pub_val = pub_tmpl->GetFunction(context).ToLocalChecked();
CHECK(global->Set(context, deno::v8_str("deno_pub"), pub_val).FromJust());
- bool r = Load(context, js_filename, js_source);
+ bool r = Execute(context, js_filename, js_source);
assert(r);
creator->SetDefaultContext(context);
@@ -261,13 +261,13 @@ void deno_set_flags(int* argc, char** argv) {
const char* deno_last_exception(Deno* d) { return d->last_exception.c_str(); }
-bool deno_load(Deno* d, const char* name_s, const char* source_s) {
+bool deno_execute(Deno* d, const char* js_filename, const char* js_source) {
auto* isolate = d->isolate;
v8::Locker locker(isolate);
v8::Isolate::Scope isolate_scope(isolate);
v8::HandleScope handle_scope(isolate);
auto context = d->context.Get(d->isolate);
- return deno::Load(context, name_s, source_s);
+ return deno::Execute(context, js_filename, js_source);
}
// Routes message to the javascript callback set with deno_sub().
diff --git a/deno2/include/deno.h b/deno2/include/deno.h
index c6bc82e26..4678a94af 100644
--- a/deno2/include/deno.h
+++ b/deno2/include/deno.h
@@ -29,7 +29,7 @@ Deno* deno_new(void* data, deno_sub_cb cb);
// Returns false on error.
// Get error text with deno_last_exception().
-bool deno_load(Deno* d, const char* name_s, const char* source_s);
+bool deno_execute(Deno* d, const char* js_filename, const char* js_source);
// Returns false on error.
// Get error text with deno_last_exception().
diff --git a/deno2/mock_runtime_test.cc b/deno2/mock_runtime_test.cc
index 6f6688f48..0b2966b69 100644
--- a/deno2/mock_runtime_test.cc
+++ b/deno2/mock_runtime_test.cc
@@ -6,19 +6,19 @@
TEST(MockRuntimeTest, InitializesCorrectly) {
Deno* d = deno_new(NULL, NULL);
- EXPECT_TRUE(deno_load(d, "a.js", "1 + 2"));
+ EXPECT_TRUE(deno_execute(d, "a.js", "1 + 2"));
deno_dispose(d);
}
TEST(MockRuntimeTest, CanCallFoo) {
Deno* d = deno_new(NULL, NULL);
- EXPECT_TRUE(deno_load(d, "a.js", "if (foo() != 'foo') throw Error();"));
+ EXPECT_TRUE(deno_execute(d, "a.js", "if (foo() != 'foo') throw Error();"));
deno_dispose(d);
}
TEST(MockRuntimeTest, ErrorsCorrectly) {
Deno* d = deno_new(NULL, NULL);
- EXPECT_FALSE(deno_load(d, "a.js", "throw Error()"));
+ EXPECT_FALSE(deno_execute(d, "a.js", "throw Error()"));
deno_dispose(d);
}
@@ -29,14 +29,14 @@ deno_buf strbuf(const char* str) {
TEST(MockRuntimeTest, PubSuccess) {
Deno* d = deno_new(NULL, NULL);
- EXPECT_TRUE(deno_load(d, "a.js", "subabc();"));
+ EXPECT_TRUE(deno_execute(d, "a.js", "subabc();"));
EXPECT_TRUE(deno_pub(d, strbuf("abc")));
deno_dispose(d);
}
TEST(MockRuntimeTest, PubByteLength) {
Deno* d = deno_new(NULL, NULL);
- EXPECT_TRUE(deno_load(d, "a.js", "subabc();"));
+ EXPECT_TRUE(deno_execute(d, "a.js", "subabc();"));
// We pub the wrong sized message, it should throw.
EXPECT_FALSE(deno_pub(d, strbuf("abcd")));
deno_dispose(d);
@@ -61,7 +61,7 @@ TEST(MockRuntimeTest, SubReturnEmpty) {
EXPECT_EQ(data[2], 'c');
return deno_buf{nullptr, 0};
});
- EXPECT_TRUE(deno_load(d, "a.js", "pubReturnEmpty()"));
+ EXPECT_TRUE(deno_execute(d, "a.js", "pubReturnEmpty()"));
EXPECT_EQ(count, 2);
deno_dispose(d);
}
@@ -78,7 +78,7 @@ TEST(MockRuntimeTest, SubReturnBar) {
EXPECT_EQ(data[2], 'c');
return strbuf("bar");
});
- EXPECT_TRUE(deno_load(d, "a.js", "pubReturnBar()"));
+ EXPECT_TRUE(deno_execute(d, "a.js", "pubReturnBar()"));
EXPECT_EQ(count, 1);
deno_dispose(d);
}