![]() |
Ultralight C++ API 1.3.0
|
#include <AppCore/JSHelpers.h>
JSFunction wrapper that automatically manages lifetime and provides convenient function invocation operators.
Public Member Functions | |
| JSFunction () | |
| Create an empty Function. | |
| JSFunction (const JSFunction &other) | |
| Copy constructor (shallow copy, will point to same instance) | |
| ~JSFunction () | |
| JSFunction & | operator= (const JSFunction &other) |
| Assignment (shallow assignment, will point to same instance) | |
| bool | IsValid () const |
| Whether or not this is a valid, callable Function object. | |
| JSValue | operator() (const JSArgs &args) |
| Call function (using Global Object for 'this') and return the result. | |
| JSValue | operator() (const JSObject &thisObject, const JSArgs &args) |
| Call function (with explicit object for 'this') and return the result. | |
| operator JSObjectRef () const | |
| Get the underlying JSObjectRef (JavaScriptCore C API) | |
| JSContextRef | context () const |
| Get the bound context for this JSFunction (it is cached at creation). | |
| void | set_context (JSContextRef context) |
| Set the JSContext for this JSFunction. | |
Protected Member Functions | |
| JSFunction (JSContextRef ctx, JSValueRef val) | |
Protected Attributes | |
| JSContextRef | ctx_ |
| JSObjectRef | instance_ |
Friends | |
| class | JSValue |
| ultralight::JSFunction::JSFunction | ( | ) |
Create an empty Function.
NOTE: It is OKAY to create this without calling SetJSContext() first.
| ultralight::JSFunction::JSFunction | ( | const JSFunction & | other | ) |
Copy constructor (shallow copy, will point to same instance)
| ultralight::JSFunction::~JSFunction | ( | ) |
|
protected |
|
inline |
Get the bound context for this JSFunction (it is cached at creation).
| bool ultralight::JSFunction::IsValid | ( | ) | const |
Whether or not this is a valid, callable Function object.
|
inline |
Get the underlying JSObjectRef (JavaScriptCore C API)
Call function (using Global Object for 'this') and return the result.
Call function (with explicit object for 'this') and return the result.
| JSFunction & ultralight::JSFunction::operator= | ( | const JSFunction & | other | ) |
Assignment (shallow assignment, will point to same instance)
|
inline |
Set the JSContext for this JSFunction.
Note: JSFunctions created from within a JSCallback have a temporary JSContext that is destroyed when the callback returns. You will need to "move" any JSFunctions created within these callbacks to the View's main context (call set_context() with the main context) before using them outside the callback.
|
friend |
|
protected |
|
protected |