Ultralight C++ API 1.3.0
Loading...
Searching...
No Matches
ultralight::JSPropertyValue Class Reference

#include <AppCore/JSHelpers.h>

Details

Wrapper for JSObject property value (JSValue subclass).

Allows new value assignment to object property, binding C++ callbacks to object properties via function objects, as well as value query via the JSValue interface.

Inheritance diagram for ultralight::JSPropertyValue:
ultralight::JSValue

Public Member Functions

virtual ~JSPropertyValue ()
 
virtual JSPropertyValueoperator= (const JSValue &value)
 Assign a new value to the property (internally calls JSObjectSetProperty)
 
JSPropertyValueoperator= (const JSCallback &callback)
 Bind to native C++ callback (creates a Function object that can be called from JS)
 
JSPropertyValueoperator= (const JSCallbackWithRetval &callback)
 Bind to native C++ callback with return value (creates a Function object that can be called from JS)
 
- Public Member Functions inherited from ultralight::JSValue
 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 JSValueoperator= (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

virtual JSValueRef instance () const
 
 JSPropertyValue (JSContextRef ctx, JSObjectRef proxy_obj, unsigned idx)
 
 JSPropertyValue (JSContextRef ctx, JSObjectRef proxy_obj, JSString idx)
 
 JSPropertyValue (const JSPropertyValue &)=default
 
JSPropertyValueoperator= (const JSPropertyValue &)=delete
 
- Protected Member Functions inherited from ultralight::JSValue
 JSValue (JSContextRef ctx)
 
 JSValue (JSContextRef ctx, JSValueRef val)
 
virtual JSValueRef instance () const
 

Protected Attributes

JSObjectproxyObj_
 
bool using_numeric_idx_
 
unsigned numeric_idx_
 
JSString string_idx_
 
- Protected Attributes inherited from ultralight::JSValue
JSContextRef ctx_
 
JSValueRef instance_ = nullptr
 

Friends

class JSArray
 
class JSObject
 

Constructor & Destructor Documentation

◆ ~JSPropertyValue()

virtual ultralight::JSPropertyValue::~JSPropertyValue ( )
virtual

◆ JSPropertyValue() [1/3]

ultralight::JSPropertyValue::JSPropertyValue ( JSContextRef  ctx,
JSObjectRef  proxy_obj,
unsigned  idx 
)
protected

◆ JSPropertyValue() [2/3]

ultralight::JSPropertyValue::JSPropertyValue ( JSContextRef  ctx,
JSObjectRef  proxy_obj,
JSString  idx 
)
protected

◆ JSPropertyValue() [3/3]

ultralight::JSPropertyValue::JSPropertyValue ( const JSPropertyValue )
protecteddefault

Member Function Documentation

◆ instance()

virtual JSValueRef ultralight::JSPropertyValue::instance ( ) const
protectedvirtual

Reimplemented from ultralight::JSValue.

◆ operator=() [1/4]

JSPropertyValue & ultralight::JSPropertyValue::operator= ( const JSCallback callback)

Bind to native C++ callback (creates a Function object that can be called from JS)

◆ operator=() [2/4]

JSPropertyValue & ultralight::JSPropertyValue::operator= ( const JSCallbackWithRetval callback)

Bind to native C++ callback with return value (creates a Function object that can be called from JS)

◆ operator=() [3/4]

JSPropertyValue & ultralight::JSPropertyValue::operator= ( const JSPropertyValue )
protecteddelete

◆ operator=() [4/4]

virtual JSPropertyValue & ultralight::JSPropertyValue::operator= ( const JSValue value)
virtual

Assign a new value to the property (internally calls JSObjectSetProperty)

Reimplemented from ultralight::JSValue.

Friends And Related Symbol Documentation

◆ JSArray

friend class JSArray
friend

◆ JSObject

friend class JSObject
friend

Member Data Documentation

◆ numeric_idx_

unsigned ultralight::JSPropertyValue::numeric_idx_
protected

◆ proxyObj_

JSObject* ultralight::JSPropertyValue::proxyObj_
protected

◆ string_idx_

JSString ultralight::JSPropertyValue::string_idx_
protected

◆ using_numeric_idx_

bool ultralight::JSPropertyValue::using_numeric_idx_
protected

The documentation for this class was generated from the following file: