1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -05:00

Wrap deno library in a namespace.

This commit is contained in:
Ryan Dahl 2018-06-10 02:24:34 +02:00
parent 9df9cdae07
commit 092ec21381
4 changed files with 14 additions and 6 deletions

View file

@ -32,6 +32,8 @@ IN THE SOFTWARE.
#define CHECK(x) assert(x) // TODO(ry) use V8's CHECK.
namespace deno {
// Extracts a C string from a v8::V8 Utf8Value.
const char* ToCString(const v8::String::Utf8Value& value) {
return *value ? *value : "<string conversion failed>";
@ -354,3 +356,5 @@ void deno_dispose(Deno* d) {
}
void deno_terminate_execution(Deno* d) { d->isolate->TerminateExecution(); }
} // namespace deno

View file

@ -6,6 +6,8 @@
#include <string>
#include "v8/include/v8.h"
namespace deno {
// Data that gets transmitted.
struct buf_s {
void* data;
@ -52,4 +54,6 @@ const char* deno_last_exception(Deno* d);
void deno_dispose(Deno* d);
void deno_terminate_execution(Deno* d);
} // namespace deno
#endif // DENO_H_

View file

@ -10,7 +10,7 @@
#include "snapshot_deno.cc"
int main(int argc, char** argv) {
v8_init();
deno::v8_init();
auto natives_blob = *StartupBlob_natives();
printf("natives_blob %d bytes\n", natives_blob.raw_size);
@ -21,10 +21,10 @@ int main(int argc, char** argv) {
v8::V8::SetNativesDataBlob(&natives_blob);
v8::V8::SetSnapshotDataBlob(&snapshot_blob);
Deno* d = deno_from_snapshot(&snapshot_blob, NULL, NULL);
int r = deno_load(d, "main2.js", "foo();");
deno::Deno* d = deno::deno_from_snapshot(&snapshot_blob, NULL, NULL);
int r = deno::deno_load(d, "main2.js", "foo();");
if (r != 0) {
printf("Error! %s\n", deno_last_exception(d));
printf("Error! %s\n", deno::deno_last_exception(d));
exit(1);
}

View file

@ -125,7 +125,7 @@ int main(int argc, char** argv) {
const char* natives_out_cc = argv[4];
const char* snapshot_out_cc = argv[5];
v8_init();
deno::v8_init();
auto js_data = ReadFile(js_fn);
auto natives_blob = ReadFile(natives_in_bin);
@ -134,7 +134,7 @@ int main(int argc, char** argv) {
v8::V8::SetNativesDataBlob(&natives_blob);
v8::V8::SetSnapshotDataBlob(&snapshot_in_blob);
auto snapshot_blob = deno_make_snapshot(js_fn, js_data.data);
auto snapshot_blob = deno::deno_make_snapshot(js_fn, js_data.data);
StartupDataCppWriter nativesWriter("natives", natives_out_cc, natives_blob);
nativesWriter.Write();