1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-27 09:39:08 -05:00

Rename Deno.data to Deno.user_data

Also use the correct rust type for it.
This commit is contained in:
Bert Belder 2018-10-08 17:49:48 +02:00
parent 14b971c5f7
commit ad4c4c214a
No known key found for this signature in database
GPG key ID: 7A77887B2E2ED461
7 changed files with 16 additions and 19 deletions

View file

@ -413,7 +413,7 @@ void deno_init() {
v8::V8::Initialize();
}
void* deno_get_data(Deno* d) { return d->data; }
void* deno_get_data(Deno* d) { return d->user_data; }
const char* deno_v8_version() { return v8::V8::GetVersion(); }

View file

@ -30,10 +30,10 @@ void deno_init();
const char* deno_v8_version();
void deno_set_v8_flags(int* argc, char** argv);
Deno* deno_new(void* data, deno_recv_cb cb);
Deno* deno_new(void* user_data, deno_recv_cb cb);
void deno_delete(Deno* d);
// Returns the void* data provided in deno_new.
// Returns the void* user_data provided in deno_new.
void* deno_get_data(Deno*);
// Returns false on error.

View file

@ -14,7 +14,7 @@
namespace deno {
Deno* NewFromFileSystem(void* data, deno_recv_cb cb) {
Deno* NewFromFileSystem(void* user_data, deno_recv_cb cb) {
std::string exe_path;
CHECK(deno::ExePath(&exe_path));
std::string exe_dir = deno::Dirname(exe_path); // Always ends with a slash.
@ -30,7 +30,7 @@ Deno* NewFromFileSystem(void* data, deno_recv_cb cb) {
Deno* d = new Deno;
d->currentArgs = nullptr;
d->cb = cb;
d->data = data;
d->user_data = user_data;
v8::Isolate::CreateParams params;
params.array_buffer_allocator =
v8::ArrayBuffer::Allocator::NewDefaultAllocator();
@ -55,7 +55,7 @@ Deno* NewFromFileSystem(void* data, deno_recv_cb cb) {
} // namespace deno
extern "C" {
Deno* deno_new(void* data, deno_recv_cb cb) {
return deno::NewFromFileSystem(data, cb);
Deno* deno_new(void* user_data, deno_recv_cb cb) {
return deno::NewFromFileSystem(user_data, cb);
}
}

View file

@ -43,11 +43,11 @@ void DeserializeInternalFields(v8::Local<v8::Object> holder, int index,
deserialized_data.push_back(embedder_field);
}
Deno* NewFromSnapshot(void* data, deno_recv_cb cb) {
Deno* NewFromSnapshot(void* user_data, deno_recv_cb cb) {
Deno* d = new Deno;
d->currentArgs = nullptr;
d->cb = cb;
d->data = data;
d->user_data = user_data;
v8::Isolate::CreateParams params;
params.array_buffer_allocator =
v8::ArrayBuffer::Allocator::NewDefaultAllocator();
@ -80,7 +80,7 @@ Deno* NewFromSnapshot(void* data, deno_recv_cb cb) {
} // namespace deno
extern "C" {
Deno* deno_new(void* data, deno_recv_cb cb) {
return deno::NewFromSnapshot(data, cb);
Deno* deno_new(void* user_data, deno_recv_cb cb) {
return deno::NewFromSnapshot(user_data, cb);
}
}

View file

@ -18,7 +18,7 @@ struct deno_s {
v8::Persistent<v8::Map> async_data_map;
deno_recv_cb cb;
int32_t next_req_id;
void* data;
void* user_data;
};
}
@ -37,7 +37,7 @@ static intptr_t external_references[] = {
reinterpret_cast<intptr_t>(Send),
reinterpret_cast<intptr_t>(SetGlobalErrorHandler), 0};
Deno* NewFromSnapshot(void* data, deno_recv_cb cb);
Deno* NewFromSnapshot(void* user_data, deno_recv_cb cb);
void InitializeContext(v8::Isolate* isolate, v8::Local<v8::Context> context,
const char* js_filename, const std::string& js_source,

View file

@ -102,10 +102,7 @@ impl Isolate {
});
(*isolate).libdeno_isolate = unsafe {
libdeno::deno_new(
isolate.as_ref() as *const _ as *const c_void,
pre_dispatch,
)
libdeno::deno_new(isolate.as_mut() as *mut _ as *mut c_void, pre_dispatch)
};
isolate

View file

@ -30,10 +30,10 @@ extern "C" {
pub fn deno_init();
pub fn deno_v8_version() -> *const c_char;
pub fn deno_set_v8_flags(argc: *mut c_int, argv: *mut *mut c_char);
pub fn deno_new(data: *const c_void, cb: DenoRecvCb) -> *const isolate;
pub fn deno_new(user_data: *mut c_void, cb: DenoRecvCb) -> *const isolate;
pub fn deno_delete(i: *const isolate);
pub fn deno_last_exception(i: *const isolate) -> *const c_char;
pub fn deno_get_data(i: *const isolate) -> *const c_void;
pub fn deno_get_data(i: *const isolate) -> *mut c_void;
pub fn deno_respond(i: *const isolate, req_id: i32, buf: deno_buf);
pub fn deno_execute(
i: *const isolate,