Loading...
Searching...
No Matches
JSHelpers.h File Reference

Classes

class  JSString
 JavaScript String wrapper that automatically manages JSStringRef lifetime and provides helpful conversions. More...
 
struct  JSValueNullTag
 Tag type used with the JSValue constructor to create "Null" types. More...
 
struct  JSValueUndefinedTag
 Tag type used with the JSValue constructor to create "Undefined" types. More...
 
class  JSValue
 JavaScript variant value wrapper that automatically manages JSValueRef lifetime and provides helpful conversions. More...
 
class  JSArgs
 A vector of JSValues, used for passing around arguments in JSCallback. More...
 
class  JSPropertyValue
 Wrapper for JSObject property value (JSValue subclass). More...
 
class  JSArray
 JSArray wrapper that automatically manages lifetime and provides convenient access to indices and Array functions. More...
 
class  JSObject
 JSObject wrapper that automatically manages lifetime and provides convenient access to properties. More...
 
class  JSFunction
 JSFunction wrapper that automatically manages lifetime and provides convenient function invocation operators. More...
 

Functions

void SetJSContext (JSContextRef ctx)
 Set the current JSContext.
 
JSContextRef GetJSContext ()
 Get the current JSContext.
 
JSObject JSGlobalObject ()
 Get the Global Object for the current JSContext.
 
JSValue JSEval (const JSString &str)
 Evaluate a string of JavaScript and return a result.
 

Namespaces

namespace  ultralight
 

Macros

#define BindJSCallback(fn)   (JSCallback)std::bind(fn, this, std::placeholders::_1, std::placeholders::_2)
 Macro to help bind C++ member functions to a JSCallback.
 
#define BindJSCallbackWithRetval(fn)   (JSCallbackWithRetval)std::bind(fn, this, std::placeholders::_1, std::placeholders::_2)
 Macro to help bind C++ member functions to a JSCallbackWithRetval.
 

Typedefs

typedef std::function< void(const JSObject &, const JSArgs &)> JSCallback
 JSCallback typedef used for binding C++ callbacks to JavaScript functions.
 
typedef std::function< JSValue(const JSObject &, const JSArgs &)> JSCallbackWithRetval
 JSCallbackWithRetval typedef used for binding C++ callbacks to JavaScript functions with an optional return value.
 

Macro Definition Documentation

◆ BindJSCallback

#define BindJSCallback ( fn)    (JSCallback)std::bind(fn, this, std::placeholders::_1, std::placeholders::_2)

Macro to help bind C++ member functions to a JSCallback.

Usage: JSCallback callback = BindJSCallback(&MyClass::MyMemberFunction);

Note
Expected to run from within an instance of 'MyClass', note the 'this' keyword in the macro.

◆ BindJSCallbackWithRetval

#define BindJSCallbackWithRetval ( fn)    (JSCallbackWithRetval)std::bind(fn, this, std::placeholders::_1, std::placeholders::_2)

Macro to help bind C++ member functions to a JSCallbackWithRetval.

Usage: JSCallback callback = BindJSCallback(&MyClass::MyMemberFunction);

Note
Expected to run from within an instance of 'MyClass', note the 'this' keyword in the macro.

Go to the source code of this file.