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

#include <AppCore/JSHelpers.h>

Details

JSObject wrapper that automatically manages lifetime and provides convenient access to properties.

Public Member Functions

 JSObject ()
 Create empty Object.
 
 JSObject (JSObjectRef obj)
 Create from existing JSObjectRef from JavaScriptCore C API.
 
 JSObject (const JSObject &other)
 Copy constructor (shallow copy, will point to same instance)
 
 ~JSObject ()
 
JSObjectoperator= (const JSObject &other)
 Assignment (shallow assignment, will point to same instance)
 
JSPropertyValue operator[] (JSString propertyName) const
 Get a property by name.
 
bool HasProperty (JSString propertyName) const
 Check if a property exists.
 
bool DeleteProperty (JSString propertyName)
 Remove a property.
 
 operator JSObjectRef () const
 Get the underlying JSObjectRef (JavaScriptCore C API)
 
JSContextRef context () const
 Get the bound context for this JSObject (it is cached at creation).
 
void set_context (JSContextRef context)
 Set the JSContext for this JSObject.
 

Protected Member Functions

 JSObject (JSContextRef ctx, JSValueRef val)
 
 JSObject (JSContextRef ctx, JSObjectRef obj)
 

Protected Attributes

JSContextRef ctx_
 
JSObjectRef instance_
 

Friends

class JSValue
 
class JSPropertyValue
 

Constructor & Destructor Documentation

◆ JSObject() [1/5]

ultralight::JSObject::JSObject ( )

Create empty Object.

◆ JSObject() [2/5]

ultralight::JSObject::JSObject ( JSObjectRef  obj)

Create from existing JSObjectRef from JavaScriptCore C API.

◆ JSObject() [3/5]

ultralight::JSObject::JSObject ( const JSObject other)

Copy constructor (shallow copy, will point to same instance)

◆ ~JSObject()

ultralight::JSObject::~JSObject ( )

◆ JSObject() [4/5]

ultralight::JSObject::JSObject ( JSContextRef  ctx,
JSValueRef  val 
)
protected

◆ JSObject() [5/5]

ultralight::JSObject::JSObject ( JSContextRef  ctx,
JSObjectRef  obj 
)
protected

Member Function Documentation

◆ context()

JSContextRef ultralight::JSObject::context ( ) const
inline

Get the bound context for this JSObject (it is cached at creation).

◆ DeleteProperty()

bool ultralight::JSObject::DeleteProperty ( JSString  propertyName)

Remove a property.

◆ HasProperty()

bool ultralight::JSObject::HasProperty ( JSString  propertyName) const

Check if a property exists.

◆ operator JSObjectRef()

ultralight::JSObject::operator JSObjectRef ( ) const
inline

Get the underlying JSObjectRef (JavaScriptCore C API)

◆ operator=()

JSObject & ultralight::JSObject::operator= ( const JSObject other)

Assignment (shallow assignment, will point to same instance)

◆ operator[]()

JSPropertyValue ultralight::JSObject::operator[] ( JSString  propertyName) const

Get a property by name.

◆ set_context()

void ultralight::JSObject::set_context ( JSContextRef  context)
inline

Set the JSContext for this JSObject.

Note: JSObjects created from within a JSCallback have a temporary JSContext that is destroyed when the callback returns. You will need to "move" any JSObjects created within these callbacks to the View's main context (call set_context() with the main context) before using them outside the callback.

Friends And Related Symbol Documentation

◆ JSPropertyValue

friend class JSPropertyValue
friend

◆ JSValue

friend class JSValue
friend

Member Data Documentation

◆ ctx_

JSContextRef ultralight::JSObject::ctx_
protected

◆ instance_

JSObjectRef ultralight::JSObject::instance_
protected

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