Nui
Classes | Namespaces | Macros | Functions
functions.hpp File Reference
#include <utility>
#include <functional>
#include <emscripten/bind.h>
#include <emscripten/val.h>
#include <boost/preprocessor/repetition/repeat.hpp>
#include <boost/preprocessor/punctuation/comma_if.hpp>
#include <boost/preprocessor/stringize.hpp>
#include <pre/type_traits/function_traits.hpp>
Include dependency graph for functions.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Nui::detail::placeholders_count<>
 
struct  Nui::detail::one_if_placeholder< T >
 
struct  Nui::detail::placeholders_count< Arg, Args... >
 

Namespaces

 Nui
 
 Nui::detail
 

Macros

#define JS_BIND_MAX_ARITY   16
 JS_BIND_MAX_ARITY Defines how many arguments the javascript exported C++ std::function can have. More...
 
#define JS_BIND_DETAIL_ARGS_EACH(z, n, unused)   BOOST_PP_COMMA_IF(n) emscripten::val
 
#define JS_BIND_DETAIL_ARGS(COUNT)   BOOST_PP_REPEAT(COUNT, JS_BIND_DETAIL_ARGS_EACH, unused)
 
#define JS_BIND_DETAIL_EACH(z, n, return_type)
 
#define JS_BIND_DETAIL_GENERATE_BINDINGS()
 
#define JS_BIND_FUNCTION_TYPES_EACH(z, n, return_type)
 
#define JS_BIND_FUNCTION_TYPES()
 
#define JS_BIND_DETAIL_FWD(...)   ::std::forward<decltype(__VA_ARGS__)>(__VA_ARGS__)
 

Functions

template<class F , class... Args>
emscripten::val Nui::bind (F &&f, Args &&... args)
 Equivalent of std::bind returning a javascript functor. More...
 
 Nui::JS_BIND_FUNCTION_TYPES ()
 

Macro Definition Documentation

◆ JS_BIND_DETAIL_ARGS

#define JS_BIND_DETAIL_ARGS (   COUNT)    BOOST_PP_REPEAT(COUNT, JS_BIND_DETAIL_ARGS_EACH, unused)

◆ JS_BIND_DETAIL_ARGS_EACH

#define JS_BIND_DETAIL_ARGS_EACH (   z,
  n,
  unused 
)    BOOST_PP_COMMA_IF(n) emscripten::val

◆ JS_BIND_DETAIL_EACH

#define JS_BIND_DETAIL_EACH (   z,
  n,
  return_type 
)
Value:
emscripten::class_<std::function<return_type(JS_BIND_DETAIL_ARGS(n))>>( \
BOOST_PP_STRINGIZE(return_type) BOOST_PP_STRINGIZE(n) "ArgsFunctor") \
.constructor<>() \
.function("opcall", &std::function<return_type(JS_BIND_DETAIL_ARGS(n))>::operator());
#define JS_BIND_DETAIL_ARGS(COUNT)
Definition: functions.hpp:30

◆ JS_BIND_DETAIL_FWD

#define JS_BIND_DETAIL_FWD (   ...)    ::std::forward<decltype(__VA_ARGS__)>(__VA_ARGS__)

◆ JS_BIND_DETAIL_GENERATE_BINDINGS

#define JS_BIND_DETAIL_GENERATE_BINDINGS ( )
Value:
BOOST_PP_REPEAT(JS_BIND_MAX_ARITY, JS_BIND_DETAIL_EACH, void) \
#define JS_BIND_MAX_ARITY
JS_BIND_MAX_ARITY Defines how many arguments the javascript exported C++ std::function can have.
Definition: functions.hpp:25
#define JS_BIND_DETAIL_EACH(z, n, return_type)
Definition: functions.hpp:32
emscripten::val val
Definition: val.hpp:5

◆ JS_BIND_FUNCTION_TYPES

#define JS_BIND_FUNCTION_TYPES ( )
Value:
#define JS_BIND_FUNCTION_TYPES_EACH(z, n, return_type)
Definition: functions.hpp:42

◆ JS_BIND_FUNCTION_TYPES_EACH

#define JS_BIND_FUNCTION_TYPES_EACH (   z,
  n,
  return_type 
)
Value:
template <> \
struct functor_t<std::is_same<return_type, void>::value, n> \
{ \
typedef ::std::function<return_type(JS_BIND_DETAIL_ARGS(n))> type; \
};

◆ JS_BIND_MAX_ARITY

#define JS_BIND_MAX_ARITY   16

JS_BIND_MAX_ARITY Defines how many arguments the javascript exported C++ std::function can have.

It defaults to 16, simply override it if you need more.