Some more APIs fixes.
This commit is contained in:
parent
8e056672bc
commit
e6db1875d0
4 changed files with 26 additions and 14 deletions
|
@ -32,7 +32,12 @@
|
|||
#define MATE_TRUE(isolate) v8::True(isolate)
|
||||
#define MATE_FALSE(isolate) v8::False(isolate)
|
||||
#define MATE_ARRAY_NEW(isolate, size) v8::Array::New(isolate, size)
|
||||
#define MATE_NUMBER_NEW(isolate, data) v8::Number::New(isolate, data)
|
||||
#define MATE_INTEGER_NEW(isolate, data) v8::Integer::New(isolate, data)
|
||||
#define MATE_INTEGER_NEW_UNSIGNED(isolate, data) \
|
||||
v8::Integer::NewFromUnsigned(isolate, data)
|
||||
#define MATE_EXTERNAL_NEW(isolate, data) v8::External::New(isolate, data)
|
||||
#define MATE_BOOLEAN_NEW(isolate, data) v8::Boolean::New(isolate, data)
|
||||
|
||||
#define MATE_SET_INTERNAL_FIELD_POINTER(object, index, value) \
|
||||
object->SetAlignedPointerInInternalField(index, value)
|
||||
|
@ -55,6 +60,9 @@
|
|||
#define MATE_WEAK_CALLBACK_INIT(c_type) \
|
||||
c_type* self = data.GetParameter()
|
||||
|
||||
#define MATE_THROW_EXCEPTION(isolate, value) \
|
||||
isolate->ThrowException(value)
|
||||
|
||||
#else // Node 0.8 and 0.10
|
||||
|
||||
#define MATE_HANDLE_SCOPE(isolate) v8::HandleScope handle_scope
|
||||
|
@ -81,7 +89,12 @@
|
|||
#define MATE_TRUE(isolate) v8::True()
|
||||
#define MATE_FALSE(isolate) v8::False()
|
||||
#define MATE_ARRAY_NEW(isolate, size) v8::Array::New(size)
|
||||
#define MATE_NUMBER_NEW(isolate, data) v8::Number::New(data)
|
||||
#define MATE_INTEGER_NEW(isolate, data) v8::Integer::New(data)
|
||||
#define MATE_INTEGER_NEW_UNSIGNED(isolate, data) \
|
||||
v8::Integer::NewFromUnsigned(data)
|
||||
#define MATE_EXTERNAL_NEW(isolate, data) v8::External::New(data)
|
||||
#define MATE_BOOLEAN_NEW(isolate, data) v8::Boolean::New(data)
|
||||
|
||||
#define MATE_SET_INTERNAL_FIELD_POINTER(object, index, value) \
|
||||
object->SetPointerInInternalField(index, value)
|
||||
|
@ -105,6 +118,9 @@
|
|||
#define MATE_WEAK_CALLBACK_INIT(c_type) \
|
||||
c_type* self = static_cast<c_type*>(parameter)
|
||||
|
||||
#define MATE_THROW_EXCEPTION(isolate, value) \
|
||||
v8::ThrowException(value)
|
||||
|
||||
#endif // (NODE_MODULE_VERSION > 0x000B)
|
||||
|
||||
|
||||
|
@ -113,8 +129,4 @@
|
|||
#define MATE_METHOD(name) \
|
||||
MATE_METHOD_RETURN_TYPE name(const MATE_METHOD_ARGS_TYPE& info)
|
||||
|
||||
// In lastest V8 ThrowException would need to pass isolate, be prepared for it.
|
||||
#define MATE_THROW_EXCEPTION(isolate, value) \
|
||||
v8::ThrowException(value)
|
||||
|
||||
#endif // NATIVE_MATE_COMPAT_H_
|
||||
|
|
|
@ -21,7 +21,7 @@ using v8::Value;
|
|||
namespace mate {
|
||||
|
||||
Handle<Value> Converter<bool>::ToV8(Isolate* isolate, bool val) {
|
||||
return Boolean::New(val);
|
||||
return MATE_BOOLEAN_NEW(isolate, val);
|
||||
}
|
||||
|
||||
bool Converter<bool>::FromV8(Isolate* isolate, Handle<Value> val, bool* out) {
|
||||
|
@ -32,7 +32,7 @@ bool Converter<bool>::FromV8(Isolate* isolate, Handle<Value> val, bool* out) {
|
|||
}
|
||||
|
||||
Handle<Value> Converter<int32_t>::ToV8(Isolate* isolate, int32_t val) {
|
||||
return Integer::New(val);
|
||||
return MATE_INTEGER_NEW(isolate, val);
|
||||
}
|
||||
|
||||
bool Converter<int32_t>::FromV8(Isolate* isolate, Handle<Value> val,
|
||||
|
@ -44,7 +44,7 @@ bool Converter<int32_t>::FromV8(Isolate* isolate, Handle<Value> val,
|
|||
}
|
||||
|
||||
Handle<Value> Converter<uint32_t>::ToV8(Isolate* isolate, uint32_t val) {
|
||||
return Integer::NewFromUnsigned(val);
|
||||
return MATE_INTEGER_NEW_UNSIGNED(isolate, val);
|
||||
}
|
||||
|
||||
bool Converter<uint32_t>::FromV8(Isolate* isolate, Handle<Value> val,
|
||||
|
@ -56,7 +56,7 @@ bool Converter<uint32_t>::FromV8(Isolate* isolate, Handle<Value> val,
|
|||
}
|
||||
|
||||
Handle<Value> Converter<int64_t>::ToV8(Isolate* isolate, int64_t val) {
|
||||
return Number::New(static_cast<double>(val));
|
||||
return MATE_NUMBER_NEW(isolate, static_cast<double>(val));
|
||||
}
|
||||
|
||||
bool Converter<int64_t>::FromV8(Isolate* isolate, Handle<Value> val,
|
||||
|
@ -70,7 +70,7 @@ bool Converter<int64_t>::FromV8(Isolate* isolate, Handle<Value> val,
|
|||
}
|
||||
|
||||
Handle<Value> Converter<uint64_t>::ToV8(Isolate* isolate, uint64_t val) {
|
||||
return Number::New(static_cast<double>(val));
|
||||
return MATE_NUMBER_NEW(isolate, static_cast<double>(val));
|
||||
}
|
||||
|
||||
bool Converter<uint64_t>::FromV8(Isolate* isolate, Handle<Value> val,
|
||||
|
@ -82,7 +82,7 @@ bool Converter<uint64_t>::FromV8(Isolate* isolate, Handle<Value> val,
|
|||
}
|
||||
|
||||
Handle<Value> Converter<float>::ToV8(Isolate* isolate, float val) {
|
||||
return Number::New(val);
|
||||
return MATE_NUMBER_NEW(isolate, val);
|
||||
}
|
||||
|
||||
bool Converter<float>::FromV8(Isolate* isolate, Handle<Value> val,
|
||||
|
@ -94,7 +94,7 @@ bool Converter<float>::FromV8(Isolate* isolate, Handle<Value> val,
|
|||
}
|
||||
|
||||
Handle<Value> Converter<double>::ToV8(Isolate* isolate, double val) {
|
||||
return Number::New(val);
|
||||
return MATE_NUMBER_NEW(isolate, val);
|
||||
}
|
||||
|
||||
bool Converter<double>::FromV8(Isolate* isolate, Handle<Value> val,
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace mate {
|
|||
|
||||
Dictionary::Dictionary(v8::Isolate* isolate)
|
||||
: isolate_(isolate),
|
||||
object_(v8::Object::New()) {
|
||||
object_(v8::Object::New(isolate)) {
|
||||
}
|
||||
|
||||
Dictionary::Dictionary(v8::Isolate* isolate,
|
||||
|
@ -22,7 +22,7 @@ Dictionary::~Dictionary() {
|
|||
|
||||
Dictionary Dictionary::CreateEmpty(v8::Isolate* isolate) {
|
||||
Dictionary dictionary(isolate);
|
||||
dictionary.object_ = v8::Object::New();
|
||||
dictionary.object_ = v8::Object::New(isolate);
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace mate {
|
|||
namespace internal {
|
||||
|
||||
CallbackHolderBase::CallbackHolderBase(v8::Isolate* isolate)
|
||||
: MATE_PERSISTENT_INIT(isolate, v8_ref_, v8::External::New(this)) {
|
||||
: MATE_PERSISTENT_INIT(isolate, v8_ref_, MATE_EXTERNAL_NEW(isolate, this)) {
|
||||
MATE_PERSISTENT_SET_WEAK(v8_ref_, this, &CallbackHolderBase::WeakCallback);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue