Skip to content
This repository has been archived by the owner on Nov 6, 2019. It is now read-only.

Commit

Permalink
Introduce generic Cast and Array methods
Browse files Browse the repository at this point in the history
  • Loading branch information
mildsunrise committed Jan 26, 2013
1 parent 82f7646 commit 5078348
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions v8u.hpp
Expand Up @@ -313,6 +313,10 @@ inline v8::Local<v8::Object> Obj() {
return v8::Object::New();
}

inline v8::Local<v8::Array> Arr(int length = 0) {
return v8::Array::New(length);
}

#define __V8_ERROR_CTOR(ERROR) \
inline v8::Local<v8::Value> ERROR##Err(const char* msg) { \
return v8::Exception::ERROR##Error(v8::String::New(msg)); \
Expand Down Expand Up @@ -360,6 +364,26 @@ inline v8::Persistent<v8::Object> Obj(v8::Persistent<v8::Value> hdl) {
return v8::Persistent<v8::Object>::Cast(hdl);
}

inline v8::Handle<v8::Array> Arr(v8::Handle<v8::Value> hdl) {
return v8::Handle<v8::Array>::Cast(hdl);
}
inline v8::Local<v8::Array> Arr(v8::Local<v8::Value> hdl) {
return v8::Local<v8::Array>::Cast(hdl);
}
inline v8::Persistent<v8::Array> Arr(v8::Persistent<v8::Value> hdl) {
return v8::Persistent<v8::Array>::Cast(hdl);
}

template <class T> inline v8::Handle<T> Cast(v8::Handle<v8::Value> hdl) {
return v8::Handle<T>::Cast(hdl);
}
template <class T> inline v8::Local<T> Cast(v8::Local<v8::Value> hdl) {
return v8::Local<T>::Cast(hdl);
}
template <class T> inline v8::Persistent<T> Cast(v8::Persistent<v8::Value> hdl) {
return v8::Persistent<T>::Cast(hdl);
}

inline bool Bool(v8::Handle<v8::Value> hdl) {
return hdl->BooleanValue();
}
Expand Down

0 comments on commit 5078348

Please sign in to comment.