Skip to content

Class jac::FunctionFactory

ClassList > jac > FunctionFactory

Various methods for wrapping C++ functions into javascript functions. More...

  • #include <functionFactory.h>

Public Functions

Type Name
FunctionFactory (ContextRef context)
Function newFunction (Func func)
Wraps a C++ function into a javascript function object.
Function newFunctionThis (Func func)
Wraps a C++ function into a javascript function object.
Function newFunctionThisVariadic (Func func)
Wraps a C++ function into a javascript function object.
Function newFunctionVariadic (Func func)
Wraps a C++ function into a javascript function object.

Detailed Description

About exceptions propagation:

When jac::Exception is thrown, the wrapped value or given error type is thrown. When std::exception is thrown, an InternalError is thrown. When any other exception is thrown, an InternalError is thrown with the message "unknown error".

Public Functions Documentation

function FunctionFactory

inline jac::FunctionFactory::FunctionFactory (
    ContextRef context
) 

function newFunction

Wraps a C++ function into a javascript function object.

template<class Func class Func>
inline Function jac::FunctionFactory::newFunction (
    Func func
) 

The expected signature of the function object is Res(Args...). Arguments and the result of the function call are automatically converted to and from javascript values. Exceptions thrown within the function are automatically propagated to the javascript side.

Template parameters:

  • Func type of the function to be wrapped

Parameters:

  • func the function object to be wrapped

Returns:

The created function object

function newFunctionThis

Wraps a C++ function into a javascript function object.

template<class Func class Func>
inline Function jac::FunctionFactory::newFunctionThis (
    Func func
) 

The expected signature of the function object is Res(ContextRef, ValueWeak, Args...). Arguments and the result of the function call are automatically converted to and from javascript values. Exceptions thrown within the function are automatically propagated to the javascript side.

Template parameters:

  • Func type of the function to be wrapped

Parameters:

  • func the function object to be wrapped

Returns:

The created function object

function newFunctionThisVariadic

Wraps a C++ function into a javascript function object.

template<class Func class Func>
inline Function jac::FunctionFactory::newFunctionThisVariadic (
    Func func
) 

The expected signature of the function object is Res(ContextRef, ValueWeak, std::vector<ValueWeak>). The vector will contain all arguments passed to the function. The the result of the function call is automatically converted from a javascript value. Exceptions thrown within the function are automatically propagated to the javascript side.

Template parameters:

  • Func type of the function to be wrapped

Parameters:

  • func the function object to be wrapped

Returns:

The created function object

function newFunctionVariadic

Wraps a C++ function into a javascript function object.

template<class Func class Func>
inline Function jac::FunctionFactory::newFunctionVariadic (
    Func func
) 

The expected signature of the function object is Res(std::vector<ValueWeak>). The vector will contain all arguments passed to the function. The result of the function call is automatically converted from a javascript value. Exceptions thrown within the function are automatically propagated to the javascript side.

Template parameters:

  • Func type of the function to be wrapped

Parameters:

  • func the function object to be wrapped

Returns:

The created function object


The documentation for this class was generated from the following file src/jac/machine/functionFactory.h