mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
Wrap deno library in a namespace.
This commit is contained in:
parent
9df9cdae07
commit
092ec21381
4 changed files with 14 additions and 6 deletions
|
@ -32,6 +32,8 @@ IN THE SOFTWARE.
|
||||||
|
|
||||||
#define CHECK(x) assert(x) // TODO(ry) use V8's CHECK.
|
#define CHECK(x) assert(x) // TODO(ry) use V8's CHECK.
|
||||||
|
|
||||||
|
namespace deno {
|
||||||
|
|
||||||
// Extracts a C string from a v8::V8 Utf8Value.
|
// Extracts a C string from a v8::V8 Utf8Value.
|
||||||
const char* ToCString(const v8::String::Utf8Value& value) {
|
const char* ToCString(const v8::String::Utf8Value& value) {
|
||||||
return *value ? *value : "<string conversion failed>";
|
return *value ? *value : "<string conversion failed>";
|
||||||
|
@ -354,3 +356,5 @@ void deno_dispose(Deno* d) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void deno_terminate_execution(Deno* d) { d->isolate->TerminateExecution(); }
|
void deno_terminate_execution(Deno* d) { d->isolate->TerminateExecution(); }
|
||||||
|
|
||||||
|
} // namespace deno
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "v8/include/v8.h"
|
#include "v8/include/v8.h"
|
||||||
|
|
||||||
|
namespace deno {
|
||||||
|
|
||||||
// Data that gets transmitted.
|
// Data that gets transmitted.
|
||||||
struct buf_s {
|
struct buf_s {
|
||||||
void* data;
|
void* data;
|
||||||
|
@ -52,4 +54,6 @@ const char* deno_last_exception(Deno* d);
|
||||||
void deno_dispose(Deno* d);
|
void deno_dispose(Deno* d);
|
||||||
void deno_terminate_execution(Deno* d);
|
void deno_terminate_execution(Deno* d);
|
||||||
|
|
||||||
|
} // namespace deno
|
||||||
|
|
||||||
#endif // DENO_H_
|
#endif // DENO_H_
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include "snapshot_deno.cc"
|
#include "snapshot_deno.cc"
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
v8_init();
|
deno::v8_init();
|
||||||
|
|
||||||
auto natives_blob = *StartupBlob_natives();
|
auto natives_blob = *StartupBlob_natives();
|
||||||
printf("natives_blob %d bytes\n", natives_blob.raw_size);
|
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::SetNativesDataBlob(&natives_blob);
|
||||||
v8::V8::SetSnapshotDataBlob(&snapshot_blob);
|
v8::V8::SetSnapshotDataBlob(&snapshot_blob);
|
||||||
|
|
||||||
Deno* d = deno_from_snapshot(&snapshot_blob, NULL, NULL);
|
deno::Deno* d = deno::deno_from_snapshot(&snapshot_blob, NULL, NULL);
|
||||||
int r = deno_load(d, "main2.js", "foo();");
|
int r = deno::deno_load(d, "main2.js", "foo();");
|
||||||
if (r != 0) {
|
if (r != 0) {
|
||||||
printf("Error! %s\n", deno_last_exception(d));
|
printf("Error! %s\n", deno::deno_last_exception(d));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ int main(int argc, char** argv) {
|
||||||
const char* natives_out_cc = argv[4];
|
const char* natives_out_cc = argv[4];
|
||||||
const char* snapshot_out_cc = argv[5];
|
const char* snapshot_out_cc = argv[5];
|
||||||
|
|
||||||
v8_init();
|
deno::v8_init();
|
||||||
|
|
||||||
auto js_data = ReadFile(js_fn);
|
auto js_data = ReadFile(js_fn);
|
||||||
auto natives_blob = ReadFile(natives_in_bin);
|
auto natives_blob = ReadFile(natives_in_bin);
|
||||||
|
@ -134,7 +134,7 @@ int main(int argc, char** argv) {
|
||||||
v8::V8::SetNativesDataBlob(&natives_blob);
|
v8::V8::SetNativesDataBlob(&natives_blob);
|
||||||
v8::V8::SetSnapshotDataBlob(&snapshot_in_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);
|
StartupDataCppWriter nativesWriter("natives", natives_out_cc, natives_blob);
|
||||||
nativesWriter.Write();
|
nativesWriter.Write();
|
||||||
|
|
Loading…
Add table
Reference in a new issue