Loading...
Searching...
No Matches
JSObject

#include <AppCore/JSHelpers.h>

Overview

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]

JSObject ( )

Create empty Object.

◆ JSObject() [2/5]

Create from existing JSObjectRef from JavaScriptCore C API.

◆ JSObject() [3/5]

JSObject ( const JSObject & other)

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

◆ ~JSObject()

~JSObject ( )

◆ JSObject() [4/5]

JSObject ( JSContextRef ctx,
JSValueRef val )
protected

◆ JSObject() [5/5]

JSObject ( JSContextRef ctx,
JSObjectRef obj )
protected

Member Function Documentation

◆ context()

JSContextRef context ( ) const
inline

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

◆ DeleteProperty()

bool DeleteProperty ( JSString propertyName)

Remove a property.

◆ HasProperty()

bool HasProperty ( JSString propertyName) const

Check if a property exists.

◆ operator JSObjectRef()

operator JSObjectRef ( ) const
inline

Get the underlying JSObjectRef (JavaScriptCore C API)

◆ operator=()

JSObject & operator= ( const JSObject & other)

Assignment (shallow assignment, will point to same instance)

◆ operator[]()

JSPropertyValue operator[] ( JSString propertyName) const

Get a property by name.

◆ set_context()

void 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 ctx_
protected

◆ instance_

JSObjectRef instance_
protected

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