From 50783484215756d5cc49c0bb5e77664404fbafe0 Mon Sep 17 00:00:00 2001 From: Xavier Mendez Date: Sat, 26 Jan 2013 11:21:54 +0100 Subject: [PATCH] Introduce generic Cast and Array methods --- v8u.hpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/v8u.hpp b/v8u.hpp index 3b8cd7e..5ba1951 100644 --- a/v8u.hpp +++ b/v8u.hpp @@ -313,6 +313,10 @@ inline v8::Local Obj() { return v8::Object::New(); } +inline v8::Local Arr(int length = 0) { + return v8::Array::New(length); +} + #define __V8_ERROR_CTOR(ERROR) \ inline v8::Local ERROR##Err(const char* msg) { \ return v8::Exception::ERROR##Error(v8::String::New(msg)); \ @@ -360,6 +364,26 @@ inline v8::Persistent Obj(v8::Persistent hdl) { return v8::Persistent::Cast(hdl); } +inline v8::Handle Arr(v8::Handle hdl) { + return v8::Handle::Cast(hdl); +} +inline v8::Local Arr(v8::Local hdl) { + return v8::Local::Cast(hdl); +} +inline v8::Persistent Arr(v8::Persistent hdl) { + return v8::Persistent::Cast(hdl); +} + +template inline v8::Handle Cast(v8::Handle hdl) { + return v8::Handle::Cast(hdl); +} +template inline v8::Local Cast(v8::Local hdl) { + return v8::Local::Cast(hdl); +} +template inline v8::Persistent Cast(v8::Persistent hdl) { + return v8::Persistent::Cast(hdl); +} + inline bool Bool(v8::Handle hdl) { return hdl->BooleanValue(); }