Use Local instead of Handle

This commit is contained in:
Cheng Zhao 2015-05-22 19:11:22 +08:00
parent b169ac016e
commit d78efe7c22
54 changed files with 185 additions and 185 deletions

View file

@ -21,7 +21,7 @@ namespace {
class Archive : public mate::Wrappable {
public:
static v8::Handle<v8::Value> Create(v8::Isolate* isolate,
static v8::Local<v8::Value> Create(v8::Isolate* isolate,
const base::FilePath& path) {
scoped_ptr<asar::Archive> archive(new asar::Archive(path));
if (!archive->Init())
@ -34,7 +34,7 @@ class Archive : public mate::Wrappable {
: archive_(archive.Pass()) {}
// Reads the offset and size of file.
v8::Handle<v8::Value> GetFileInfo(v8::Isolate* isolate,
v8::Local<v8::Value> GetFileInfo(v8::Isolate* isolate,
const base::FilePath& path) {
asar::Archive::FileInfo info;
if (!archive_ || !archive_->GetFileInfo(path, &info))
@ -47,7 +47,7 @@ class Archive : public mate::Wrappable {
}
// Returns a fake result of fs.stat(path).
v8::Handle<v8::Value> Stat(v8::Isolate* isolate,
v8::Local<v8::Value> Stat(v8::Isolate* isolate,
const base::FilePath& path) {
asar::Archive::Stats stats;
if (!archive_ || !archive_->Stat(path, &stats))
@ -62,7 +62,7 @@ class Archive : public mate::Wrappable {
}
// Returns all files under a directory.
v8::Handle<v8::Value> Readdir(v8::Isolate* isolate,
v8::Local<v8::Value> Readdir(v8::Isolate* isolate,
const base::FilePath& path) {
std::vector<base::FilePath> files;
if (!archive_ || !archive_->Readdir(path, &files))
@ -71,7 +71,7 @@ class Archive : public mate::Wrappable {
}
// Returns the path of file with symbol link resolved.
v8::Handle<v8::Value> Realpath(v8::Isolate* isolate,
v8::Local<v8::Value> Realpath(v8::Isolate* isolate,
const base::FilePath& path) {
base::FilePath realpath;
if (!archive_ || !archive_->Realpath(path, &realpath))
@ -80,7 +80,7 @@ class Archive : public mate::Wrappable {
}
// Copy the file out into a temporary file and returns the new path.
v8::Handle<v8::Value> CopyFileOut(v8::Isolate* isolate,
v8::Local<v8::Value> CopyFileOut(v8::Isolate* isolate,
const base::FilePath& path) {
base::FilePath new_path;
if (!archive_ || !archive_->CopyFileOut(path, &new_path))
@ -120,8 +120,8 @@ class Archive : public mate::Wrappable {
};
void InitAsarSupport(v8::Isolate* isolate,
v8::Handle<v8::Value> process,
v8::Handle<v8::Value> require) {
v8::Local<v8::Value> process,
v8::Local<v8::Value> require) {
// Evaluate asar_init.coffee.
v8::Local<v8::Script> asar_init = v8::Script::Compile(v8::String::NewFromUtf8(
isolate,
@ -131,8 +131,8 @@ void InitAsarSupport(v8::Isolate* isolate,
v8::Local<v8::Value> result = asar_init->Run();
// Initialize asar support.
base::Callback<void(v8::Handle<v8::Value>,
v8::Handle<v8::Value>,
base::Callback<void(v8::Local<v8::Value>,
v8::Local<v8::Value>,
std::string)> init;
if (mate::ConvertFromV8(isolate, result, &init)) {
init.Run(process,
@ -141,8 +141,8 @@ void InitAsarSupport(v8::Isolate* isolate,
}
}
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
mate::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("createArchive", &Archive::Create);
dict.SetMethod("initAsarSupport", &InitAsarSupport);

View file

@ -19,7 +19,7 @@ namespace mate {
template<>
struct Converter<ui::ClipboardType> {
static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
ui::ClipboardType* out) {
std::string type;
if (!Converter<std::string>::FromV8(isolate, val, &type))
@ -78,8 +78,8 @@ void Clear(ui::ClipboardType type) {
ui::Clipboard::GetForCurrentThread()->Clear(type);
}
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
mate::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("_has", &Has);
dict.SetMethod("_read", &Read);

View file

@ -16,15 +16,15 @@ namespace mate {
template<>
struct Converter<std::map<std::string, std::string> > {
static bool FromV8(v8::Isolate* isolate,
v8::Handle<v8::Value> val,
v8::Local<v8::Value> val,
std::map<std::string, std::string>* out) {
if (!val->IsObject())
return false;
v8::Handle<v8::Object> dict = val->ToObject();
v8::Handle<v8::Array> keys = dict->GetOwnPropertyNames();
v8::Local<v8::Object> dict = val->ToObject();
v8::Local<v8::Array> keys = dict->GetOwnPropertyNames();
for (uint32_t i = 0; i < keys->Length(); ++i) {
v8::Handle<v8::Value> key = keys->Get(i);
v8::Local<v8::Value> key = keys->Get(i);
(*out)[V8ToString(key)] = V8ToString(dict->Get(key));
}
return true;
@ -35,8 +35,8 @@ struct Converter<std::map<std::string, std::string> > {
namespace {
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
using crash_reporter::CrashReporter;
mate::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("start",

View file

@ -23,7 +23,7 @@ IDWeakMap::IDWeakMap()
IDWeakMap::~IDWeakMap() {
}
int32_t IDWeakMap::Add(v8::Isolate* isolate, v8::Handle<v8::Object> object) {
int32_t IDWeakMap::Add(v8::Isolate* isolate, v8::Local<v8::Object> object) {
int32_t key = GetNextID();
object->SetHiddenValue(mate::StringToV8(isolate, "IDWeakMapKey"),
mate::Converter<int32_t>::ToV8(isolate, key));
@ -33,7 +33,7 @@ int32_t IDWeakMap::Add(v8::Isolate* isolate, v8::Handle<v8::Object> object) {
return key;
}
v8::Handle<v8::Value> IDWeakMap::Get(v8::Isolate* isolate, int32_t key) {
v8::Local<v8::Value> IDWeakMap::Get(v8::Isolate* isolate, int32_t key) {
if (!Has(key)) {
node::ThrowError("Invalid key");
return v8::Undefined(isolate);
@ -67,7 +67,7 @@ int IDWeakMap::GetNextID() {
// static
void IDWeakMap::BuildPrototype(v8::Isolate* isolate,
v8::Handle<v8::ObjectTemplate> prototype) {
v8::Local<v8::ObjectTemplate> prototype) {
mate::ObjectTemplateBuilder(isolate, prototype)
.SetMethod("add", &IDWeakMap::Add)
.SetMethod("get", &IDWeakMap::Get)
@ -91,8 +91,8 @@ void IDWeakMap::WeakCallback(
namespace {
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
using atom::api::IDWeakMap;
v8::Isolate* isolate = context->GetIsolate();
v8::Local<v8::Function> constructor = mate::CreateConstructor<IDWeakMap>(

View file

@ -23,13 +23,13 @@ class IDWeakMap : public mate::Wrappable {
IDWeakMap();
static void BuildPrototype(v8::Isolate* isolate,
v8::Handle<v8::ObjectTemplate> prototype);
v8::Local<v8::ObjectTemplate> prototype);
private:
virtual ~IDWeakMap();
int32_t Add(v8::Isolate* isolate, v8::Handle<v8::Object> object);
v8::Handle<v8::Value> Get(v8::Isolate* isolate, int32_t key);
int32_t Add(v8::Isolate* isolate, v8::Local<v8::Object> object);
v8::Local<v8::Value> Get(v8::Isolate* isolate, int32_t key);
bool Has(int32_t key) const;
std::vector<int32_t> Keys() const;
void Remove(int32_t key);

View file

@ -145,14 +145,14 @@ mate::ObjectTemplateBuilder NativeImage::GetObjectTemplateBuilder(
isolate, v8::Local<v8::ObjectTemplate>::New(isolate, template_));
}
v8::Handle<v8::Value> NativeImage::ToPNG(v8::Isolate* isolate) {
v8::Local<v8::Value> NativeImage::ToPNG(v8::Isolate* isolate) {
scoped_refptr<base::RefCountedMemory> png = image_.As1xPNGBytes();
return node::Buffer::New(isolate,
reinterpret_cast<const char*>(png->front()),
png->size());
}
v8::Handle<v8::Value> NativeImage::ToJPEG(v8::Isolate* isolate, int quality) {
v8::Local<v8::Value> NativeImage::ToJPEG(v8::Isolate* isolate, int quality) {
std::vector<unsigned char> output;
gfx::JPEG1xEncodedDataFromImage(image_, quality, &output);
return node::Buffer::New(isolate,
@ -225,7 +225,7 @@ mate::Handle<NativeImage> NativeImage::CreateFromPath(
// static
mate::Handle<NativeImage> NativeImage::CreateFromBuffer(
mate::Arguments* args, v8::Handle<v8::Value> buffer) {
mate::Arguments* args, v8::Local<v8::Value> buffer) {
double scale_factor = 1.;
args->GetNext(&scale_factor);
@ -258,8 +258,8 @@ mate::Handle<NativeImage> NativeImage::CreateFromDataURL(
namespace {
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
mate::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("createEmpty", &atom::api::NativeImage::CreateEmpty);
dict.SetMethod("createFromPath", &atom::api::NativeImage::CreateFromPath);

View file

@ -41,7 +41,7 @@ class NativeImage : public mate::Wrappable {
static mate::Handle<NativeImage> CreateFromPath(
v8::Isolate* isolate, const base::FilePath& path);
static mate::Handle<NativeImage> CreateFromBuffer(
mate::Arguments* args, v8::Handle<v8::Value> buffer);
mate::Arguments* args, v8::Local<v8::Value> buffer);
static mate::Handle<NativeImage> CreateFromDataURL(
v8::Isolate* isolate, const GURL& url);
@ -59,8 +59,8 @@ class NativeImage : public mate::Wrappable {
v8::Isolate* isolate) override;
private:
v8::Handle<v8::Value> ToPNG(v8::Isolate* isolate);
v8::Handle<v8::Value> ToJPEG(v8::Isolate* isolate, int quality);
v8::Local<v8::Value> ToPNG(v8::Isolate* isolate);
v8::Local<v8::Value> ToJPEG(v8::Isolate* isolate, int quality);
std::string ToDataURL();
bool IsEmpty();
gfx::Size GetSize();

View file

@ -13,8 +13,8 @@
namespace {
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
mate::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("showItemInFolder", &platform_util::ShowItemInFolder);
dict.SetMethod("openItem", &platform_util::OpenItem);

View file

@ -10,31 +10,31 @@
namespace {
v8::Handle<v8::Object> CreateObjectWithName(v8::Isolate* isolate,
v8::Handle<v8::String> name) {
v8::Local<v8::Object> CreateObjectWithName(v8::Isolate* isolate,
v8::Local<v8::String> name) {
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
t->SetClassName(name);
return t->GetFunction()->NewInstance();
}
v8::Handle<v8::Value> GetHiddenValue(v8::Handle<v8::Object> object,
v8::Handle<v8::String> key) {
v8::Local<v8::Value> GetHiddenValue(v8::Local<v8::Object> object,
v8::Local<v8::String> key) {
return object->GetHiddenValue(key);
}
void SetHiddenValue(v8::Handle<v8::Object> object,
v8::Handle<v8::String> key,
v8::Handle<v8::Value> value) {
void SetHiddenValue(v8::Local<v8::Object> object,
v8::Local<v8::String> key,
v8::Local<v8::Value> value) {
object->SetHiddenValue(key, value);
}
int32_t GetObjectHash(v8::Handle<v8::Object> object) {
int32_t GetObjectHash(v8::Local<v8::Object> object) {
return object->GetIdentityHash();
}
void SetDestructor(v8::Isolate* isolate,
v8::Handle<v8::Object> object,
v8::Handle<v8::Function> callback) {
v8::Local<v8::Object> object,
v8::Local<v8::Function> callback) {
atom::ObjectLifeMonitor::BindTo(isolate, object, callback);
}
@ -42,8 +42,8 @@ void TakeHeapSnapshot(v8::Isolate* isolate) {
isolate->GetHeapProfiler()->TakeHeapSnapshot();
}
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
mate::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("createObjectWithName", &CreateObjectWithName);
dict.SetMethod("getHiddenValue", &GetHiddenValue);

View file

@ -49,7 +49,7 @@ AtomBindings::~AtomBindings() {
}
void AtomBindings::BindTo(v8::Isolate* isolate,
v8::Handle<v8::Object> process) {
v8::Local<v8::Object> process) {
v8::V8::SetFatalErrorHandler(FatalErrorCallback);
mate::Dictionary dict(isolate, process);

View file

@ -24,7 +24,7 @@ class AtomBindings {
// Add process.atomBinding function, which behaves like process.binding but
// load native code from atom-shell instead.
void BindTo(v8::Isolate* isolate, v8::Handle<v8::Object> process);
void BindTo(v8::Isolate* isolate, v8::Local<v8::Object> process);
private:
void ActivateUVLoop(v8::Isolate* isolate);

View file

@ -11,8 +11,8 @@ namespace atom {
// static
void ObjectLifeMonitor::BindTo(v8::Isolate* isolate,
v8::Handle<v8::Object> target,
v8::Handle<v8::Value> destructor) {
v8::Local<v8::Object> target,
v8::Local<v8::Value> destructor) {
target->SetHiddenValue(MATE_STRING_NEW(isolate, "destructor"), destructor);
ObjectLifeMonitor* olm = new ObjectLifeMonitor();

View file

@ -13,8 +13,8 @@ namespace atom {
class ObjectLifeMonitor {
public:
static void BindTo(v8::Isolate* isolate,
v8::Handle<v8::Object> target,
v8::Handle<v8::Value> destructor);
v8::Local<v8::Object> target,
v8::Local<v8::Value> destructor);
private:
ObjectLifeMonitor();