Ultralight C++ API 1.3.0
Loading...
Searching...
No Matches
JSHelpers.h File Reference

Go to the source code of this file.

Classes

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

Functions

void ultralight::SetJSContext (JSContextRef ctx)
 Set the current JSContext.
 
JSContextRef ultralight::GetJSContext ()
 Get the current JSContext.
 
JSObject ultralight::JSGlobalObject ()
 Get the Global Object for the current JSContext.
 
JSValue ultralight::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 &)> ultralight::JSCallback
 JSCallback typedef used for binding C++ callbacks to JavaScript functions.
 
typedef std::function< JSValue(const JSObject &, const JSArgs &)> ultralight::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.