diff --git a/deno2/deno.cc b/deno2/deno.cc index caea85ffb3..baf5e96a5c 100644 --- a/deno2/deno.cc +++ b/deno2/deno.cc @@ -311,9 +311,9 @@ bool deno_pub(Deno* d, const char* channel, deno_buf buf) { return true; } -void deno_dispose(Deno* d) { +void deno_delete(Deno* d) { d->isolate->Dispose(); - delete (d); + delete d; } void deno_terminate_execution(Deno* d) { d->isolate->TerminateExecution(); } diff --git a/deno2/include/deno.h b/deno2/include/deno.h index b8d4e59a41..3c42abd72f 100644 --- a/deno2/include/deno.h +++ b/deno2/include/deno.h @@ -26,8 +26,8 @@ void deno_init(); const char* deno_v8_version(); void deno_set_flags(int* argc, char** argv); -// Constructor Deno* deno_new(void* data, deno_sub_cb cb); +void deno_delete(Deno* d); // Returns false on error. // Get error text with deno_last_exception(). @@ -39,7 +39,6 @@ bool deno_pub(Deno* d, const char* channel, deno_buf buf); const char* deno_last_exception(Deno* d); -void deno_dispose(Deno* d); void deno_terminate_execution(Deno* d); #ifdef __cplusplus diff --git a/deno2/main.cc b/deno2/main.cc index 4ea843bbb7..820f15a095 100644 --- a/deno2/main.cc +++ b/deno2/main.cc @@ -14,5 +14,5 @@ int main(int argc, char** argv) { printf("Error! %s\n", deno_last_exception(d)); exit(1); } - deno_dispose(d); + deno_delete(d); } diff --git a/deno2/mock_runtime_test.cc b/deno2/mock_runtime_test.cc index 9297936453..44037044a6 100644 --- a/deno2/mock_runtime_test.cc +++ b/deno2/mock_runtime_test.cc @@ -7,20 +7,20 @@ TEST(MockRuntimeTest, InitializesCorrectly) { Deno* d = deno_new(NULL, NULL); EXPECT_TRUE(deno_execute(d, "a.js", "1 + 2")); - deno_dispose(d); + deno_delete(d); } TEST(MockRuntimeTest, CanCallFunction) { Deno* d = deno_new(NULL, NULL); EXPECT_TRUE(deno_execute(d, "a.js", "if (CanCallFunction() != 'foo') throw Error();")); - deno_dispose(d); + deno_delete(d); } TEST(MockRuntimeTest, ErrorsCorrectly) { Deno* d = deno_new(NULL, NULL); EXPECT_FALSE(deno_execute(d, "a.js", "throw Error()")); - deno_dispose(d); + deno_delete(d); } deno_buf strbuf(const char* str) { return deno_buf{str, strlen(str)}; } @@ -29,7 +29,7 @@ TEST(MockRuntimeTest, PubSuccess) { Deno* d = deno_new(NULL, NULL); EXPECT_TRUE(deno_execute(d, "a.js", "PubSuccess()")); EXPECT_TRUE(deno_pub(d, "PubSuccess", strbuf("abc"))); - deno_dispose(d); + deno_delete(d); } TEST(MockRuntimeTest, PubByteLength) { @@ -37,14 +37,14 @@ TEST(MockRuntimeTest, PubByteLength) { EXPECT_TRUE(deno_execute(d, "a.js", "PubByteLength()")); // We pub the wrong sized message, it should throw. EXPECT_FALSE(deno_pub(d, "PubByteLength", strbuf("abcd"))); - deno_dispose(d); + deno_delete(d); } TEST(MockRuntimeTest, PubNoCallback) { Deno* d = deno_new(NULL, NULL); // We didn't call deno_sub(), pubing should fail. EXPECT_FALSE(deno_pub(d, "PubNoCallback", strbuf("abc"))); - deno_dispose(d); + deno_delete(d); } TEST(MockRuntimeTest, SubReturnEmpty) { @@ -60,7 +60,7 @@ TEST(MockRuntimeTest, SubReturnEmpty) { }); EXPECT_TRUE(deno_execute(d, "a.js", "SubReturnEmpty()")); EXPECT_EQ(count, 2); - deno_dispose(d); + deno_delete(d); } TEST(MockRuntimeTest, SubReturnBar) { @@ -76,7 +76,7 @@ TEST(MockRuntimeTest, SubReturnBar) { }); EXPECT_TRUE(deno_execute(d, "a.js", "SubReturnBar()")); EXPECT_EQ(count, 1); - deno_dispose(d); + deno_delete(d); } int main(int argc, char** argv) {