10#include <emscripten/bind.h> 
   11#include <emscripten/val.h> 
   13#include <traits/functions.hpp> 
   15#include <boost/preprocessor/repetition/repeat.hpp> 
   16#include <boost/preprocessor/punctuation/comma_if.hpp> 
   17#include <boost/preprocessor/stringize.hpp> 
   19#ifndef JS_BIND_MAX_ARITY 
   25#    define JS_BIND_MAX_ARITY 16 
   28#define JS_BIND_DETAIL_ARGS_EACH(z, n, unused) BOOST_PP_COMMA_IF(n) emscripten::val 
   30#define JS_BIND_DETAIL_ARGS(COUNT) BOOST_PP_REPEAT(COUNT, JS_BIND_DETAIL_ARGS_EACH, unused) 
   32#define JS_BIND_DETAIL_EACH(z, n, return_type) \ 
   33    emscripten::class_<std::function<return_type(JS_BIND_DETAIL_ARGS(n))>>( \ 
   34        BOOST_PP_STRINGIZE(return_type) BOOST_PP_STRINGIZE(n) "ArgsFunctor") \ 
   36            .function("opcall", &std::function<return_type(JS_BIND_DETAIL_ARGS(n))>::operator()); 
 
   38#define JS_BIND_DETAIL_GENERATE_BINDINGS() \ 
   39    BOOST_PP_REPEAT(JS_BIND_MAX_ARITY, JS_BIND_DETAIL_EACH, void) \ 
   40    BOOST_PP_REPEAT(JS_BIND_MAX_ARITY, JS_BIND_DETAIL_EACH, emscripten::val) 
 
   42#define JS_BIND_FUNCTION_TYPES_EACH(z, n, return_type) \ 
   44    struct functor_t<std::is_same<return_type, void>::value, n> \ 
   46        typedef ::std::function<return_type(JS_BIND_DETAIL_ARGS(n))> type; \ 
 
   49#define JS_BIND_FUNCTION_TYPES() \ 
   50    BOOST_PP_REPEAT(JS_BIND_MAX_ARITY, JS_BIND_FUNCTION_TYPES_EACH, void) \ 
   51    BOOST_PP_REPEAT(JS_BIND_MAX_ARITY, JS_BIND_FUNCTION_TYPES_EACH, emscripten::val) 
 
   53#define JS_BIND_DETAIL_FWD(...) ::std::forward<decltype(__VA_ARGS__)>(__VA_ARGS__) 
   65    template <
class F, 
class... Args>
 
   66    emscripten::val 
bind(F&& f, Args&&... args);
 
   70        template <
typename... Args>
 
   76            static constexpr size_t value = 0;
 
 
   82            static constexpr size_t value = (std::is_placeholder<typename std::decay<T>::type>
::value) ? 1 : 0;
 
 
   85        template <
typename Arg, 
typename... Args>
 
 
   92    template <const 
bool returns_
void, const 
size_t arity>
 
   97    template <
class F, 
class... Args>
 
   98    emscripten::val 
bind(F&& f, Args&&... args)
 
  100        using emscripten::val;
 
  102        using result_type = 
typename Traits::FunctionTraits<std::decay_t<F>>::ReturnType;
 
  103        auto bind_result = std::bind(std::forward<
decltype(f)>(f), 
JS_BIND_DETAIL_FWD(args)...);
 
  109        callback_t functor = bind_result;
 
  112        auto functor_adapter =
 
  113            emscripten::val(functor)[
"opcall"].call<emscripten::val>(
"bind", emscripten::val(functor));
 
  114        return functor_adapter;
 
 
#define JS_BIND_DETAIL_FWD(...)
Definition functions.hpp:53
Definition file_dialog.hpp:6
emscripten::val bind(F &&f, Args &&... args)
Equivalent of std::bind returning a javascript functor.
Definition functions.hpp:98
Definition functions.hpp:81
static constexpr size_t value
Definition functions.hpp:82
Definition functions.hpp:71
Definition functions.hpp:93