Add getType/getPrivate to Value

Summary:
Adds:
 - getType so you can switch on type
 - getPrivate

Reviewed By: lexs

Differential Revision: D3515510

fbshipit-source-id: d574b04f563ac650bacec3751b50be6345e8439a
This commit is contained in:
Andy Street 2016-07-07 04:36:00 -07:00 committed by Facebook Github Bot 8
parent 201433f05b
commit 10d41b50c2
1 changed files with 9 additions and 0 deletions

View File

@ -191,6 +191,11 @@ public:
} }
} }
template<typename ReturnType>
ReturnType* getPrivate() const {
return static_cast<ReturnType*>(JSObjectGetPrivate(m_obj));
}
JSContextRef context() const { JSContextRef context() const {
return m_context; return m_context;
} }
@ -223,6 +228,10 @@ public:
return m_value; return m_value;
} }
JSType getType() const {
return JSValueGetType(m_context, m_value);
}
bool isBoolean() const { bool isBoolean() const {
return JSValueIsBoolean(context(), m_value); return JSValueIsBoolean(context(), m_value);
} }