src: add ClearWrap() to util.h

Counterpart to Wrap(), clears the previously assigned internal field.
Will be used in an upcoming commit.

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
This commit is contained in:
Ben Noordhuis 2014-09-04 04:23:03 +02:00 committed by Trevor Norris
parent de9a444ab4
commit 1e99486cc8
2 changed files with 6 additions and 0 deletions

View File

@ -107,6 +107,10 @@ void Wrap(v8::Local<v8::Object> object, TypeName* pointer) {
object->SetAlignedPointerInInternalField(0, pointer);
}
void ClearWrap(v8::Local<v8::Object> object) {
Wrap<void>(object, NULL);
}
template <typename TypeName>
TypeName* Unwrap(v8::Local<v8::Object> object) {
assert(!object.IsEmpty());

View File

@ -112,6 +112,8 @@ inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate,
inline void Wrap(v8::Local<v8::Object> object, void* pointer);
inline void ClearWrap(v8::Local<v8::Object> object);
template <typename TypeName>
inline TypeName* Unwrap(v8::Local<v8::Object> object);