Ultralight C++ API 1.3.0
|
#include <AppCore/JSHelpers.h>
JavaScript variant value wrapper that automatically manages JSValueRef lifetime and provides helpful conversions.
Public Member Functions | |
JSValue () | |
Create null (empty) JSValue. | |
JSValue (JSValueNullTag) | |
Create null JSValue explicitly. | |
JSValue (JSValueUndefinedTag) | |
Create undefined JSValue. | |
JSValue (bool val) | |
Create boolean JSValue. | |
JSValue (uint32_t val) | |
Create unsigned integer JSValue (aka, Number) [will be cast to double]. | |
JSValue (int32_t val) | |
Create integer JSValue (aka, Number) [will be cast to double]. | |
JSValue (uint64_t val) | |
Create unsigned integer JSValue (aka, Number) [will be cast to double]. | |
JSValue (int64_t val) | |
Create integer JSValue (aka, Number) [will be cast to double]. | |
JSValue (double val) | |
Create double JSValue (aka, Number) | |
JSValue (const char *val) | |
Create string JSValue. | |
JSValue (const String &val) | |
Create string JSValue. | |
JSValue (JSString val) | |
Create string JSValue. | |
JSValue (JSValueRef val) | |
Create from existing JSValueRef. | |
JSValue (JSObjectRef obj) | |
Create object JSValue. | |
JSValue (const JSValue &other) | |
Copy constructor, a shallow copy is made, the constructed JSValue will point to the same JSValueRef. | |
virtual | ~JSValue () |
Destructor. | |
virtual JSValue & | operator= (const JSValue &other) |
A shallow copy is made, this JSValue will point to the same JSValueRef. | |
bool | IsNull () const |
Whether or not the value is a JavaScript Null type. | |
bool | IsUndefined () const |
Whether or not the value is a JavaScript Undefined type. | |
bool | IsBoolean () const |
Whether or not the value is a JavaScript Boolean type. | |
bool | IsNumber () const |
Whether or not the value is a JavaScript Number type. | |
bool | IsString () const |
Whether or not the value is a JavaScript String type. | |
bool | IsObject () const |
Whether or not the value is a JavaScript Object type. | |
bool | IsArray () const |
Whether or not the value is a JavaScript Array type. | |
bool | IsFunction () const |
Whether or not the value is a JavaScript Function type. | |
bool | ToBoolean () const |
Get the value as a Boolean. | |
double | ToNumber () const |
Get the value as a Number (Double) | |
int64_t | ToInteger () const |
Get the value as a Number (Integer) | |
JSString | ToString () const |
Get the value as a String. | |
JSObject | ToObject () const |
Get the value as an Object (will debug assert if not an Object) | |
JSArray | ToArray () const |
Get the value as an Array (will debug asset if not an Array) | |
JSFunction | ToFunction () const |
Get the value as a Function (will debug asset if not a Function) | |
operator bool () const | |
operator double () const | |
operator uint32_t () const | |
operator int32_t () const | |
operator uint64_t () const | |
operator int64_t () const | |
operator String () const | |
operator JSString () const | |
operator JSObject () const | |
operator JSObjectRef () const | |
operator JSArray () const | |
operator JSFunction () const | |
operator JSValueRef () const | |
Get the underlying JSValueRef. | |
JSContextRef | context () const |
Get the bound context for this JSValue (it is cached at creation). | |
void | set_context (JSContextRef context) |
Set the JSContext for this JSValue. | |
Protected Member Functions | |
JSValue (JSContextRef ctx) | |
JSValue (JSContextRef ctx, JSValueRef val) | |
virtual JSValueRef | instance () const |
Protected Attributes | |
JSContextRef | ctx_ |
JSValueRef | instance_ = nullptr |
Friends | |
class | JSFunction |
ultralight::JSValue::JSValue | ( | ) |
Create null (empty) JSValue.
ultralight::JSValue::JSValue | ( | JSValueNullTag | ) |
Create null JSValue explicitly.
ultralight::JSValue::JSValue | ( | JSValueUndefinedTag | ) |
Create undefined JSValue.
ultralight::JSValue::JSValue | ( | bool | val | ) |
Create boolean JSValue.
ultralight::JSValue::JSValue | ( | uint32_t | val | ) |
Create unsigned integer JSValue (aka, Number) [will be cast to double].
ultralight::JSValue::JSValue | ( | int32_t | val | ) |
Create integer JSValue (aka, Number) [will be cast to double].
ultralight::JSValue::JSValue | ( | uint64_t | val | ) |
Create unsigned integer JSValue (aka, Number) [will be cast to double].
ultralight::JSValue::JSValue | ( | int64_t | val | ) |
Create integer JSValue (aka, Number) [will be cast to double].
ultralight::JSValue::JSValue | ( | double | val | ) |
Create double JSValue (aka, Number)
ultralight::JSValue::JSValue | ( | const char * | val | ) |
Create string JSValue.
ultralight::JSValue::JSValue | ( | JSValueRef | val | ) |
Create from existing JSValueRef.
ultralight::JSValue::JSValue | ( | JSObjectRef | obj | ) |
Create object JSValue.
ultralight::JSValue::JSValue | ( | const JSValue & | other | ) |
Copy constructor, a shallow copy is made, the constructed JSValue will point to the same JSValueRef.
|
virtual |
Destructor.
|
protected |
|
protected |
|
inline |
Get the bound context for this JSValue (it is cached at creation).
|
protectedvirtual |
Reimplemented in ultralight::JSPropertyValue.
bool ultralight::JSValue::IsArray | ( | ) | const |
Whether or not the value is a JavaScript Array type.
bool ultralight::JSValue::IsBoolean | ( | ) | const |
Whether or not the value is a JavaScript Boolean type.
bool ultralight::JSValue::IsFunction | ( | ) | const |
Whether or not the value is a JavaScript Function type.
bool ultralight::JSValue::IsNull | ( | ) | const |
Whether or not the value is a JavaScript Null type.
bool ultralight::JSValue::IsNumber | ( | ) | const |
Whether or not the value is a JavaScript Number type.
bool ultralight::JSValue::IsObject | ( | ) | const |
Whether or not the value is a JavaScript Object type.
bool ultralight::JSValue::IsString | ( | ) | const |
Whether or not the value is a JavaScript String type.
bool ultralight::JSValue::IsUndefined | ( | ) | const |
Whether or not the value is a JavaScript Undefined type.
|
inline |
|
inline |
|
inline |
|
inline |
ultralight::JSValue::operator JSArray | ( | ) | const |
ultralight::JSValue::operator JSFunction | ( | ) | const |
ultralight::JSValue::operator JSObject | ( | ) | const |
ultralight::JSValue::operator JSObjectRef | ( | ) | const |
|
inline |
|
inline |
Get the underlying JSValueRef.
|
inline |
|
inline |
|
inline |
A shallow copy is made, this JSValue will point to the same JSValueRef.
Reimplemented in ultralight::JSPropertyValue.
|
inline |
Set the JSContext for this JSValue.
Note: JSValues created from within a JSCallback have a temporary JSContext that is destroyed when the callback returns. You will need to "move" any JSValues created within these callbacks to the View's main context (call set_context() with the main context) before using them outside the callback.
JSArray ultralight::JSValue::ToArray | ( | ) | const |
Get the value as an Array (will debug asset if not an Array)
bool ultralight::JSValue::ToBoolean | ( | ) | const |
Get the value as a Boolean.
JSFunction ultralight::JSValue::ToFunction | ( | ) | const |
Get the value as a Function (will debug asset if not a Function)
|
inline |
Get the value as a Number (Integer)
double ultralight::JSValue::ToNumber | ( | ) | const |
Get the value as a Number (Double)
JSObject ultralight::JSValue::ToObject | ( | ) | const |
Get the value as an Object (will debug assert if not an Object)
|
friend |
|
protected |
|
protected |