diff options
author | 2019-01-02 17:38:00 +0100 | |
---|---|---|
committer | 2019-01-04 16:54:53 +0100 | |
commit | 2bb052bea267b0ddee8571cc8606087e81229ddb (patch) | |
tree | ea2cdfae884b55a3c90504a695813235162ac505 /include | |
parent | 3b802b24b073fcbb331a8a78f99dc2b8e1fde0a2 (diff) |
binding-wrap: Add verb initialisation for C++
This new constexpr initialisation method accepts
a callback receiving a afb::req instead of a
afb_req_t.
Change-Id: I742e3dcf1e81873e76f61c319198e3cf7ef5ec0f
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'include')
-rw-r--r-- | include/afb/c++/binding-wrap.hpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/include/afb/c++/binding-wrap.hpp b/include/afb/c++/binding-wrap.hpp index 733c02a7..edca0701 100644 --- a/include/afb/c++/binding-wrap.hpp +++ b/include/afb/c++/binding-wrap.hpp @@ -571,6 +571,40 @@ constexpr afb_verb_t verb( return r; } +#if AFB_BINDING_VERSION >= 3 +void __afb__verb__cb__for__global__(afb_req_t r) +{ + void *vcbdata; + void (*callback)(req); + + vcbdata = afb_req_get_vcbdata(r); + callback = reinterpret_cast<void(*)(req)>(vcbdata); + callback(req(r)); +} + +constexpr afb_verb_t verb( + const char *name, + void (&callback)(req), + const char *info = nullptr, + uint16_t session = 0, + const afb_auth *auth = nullptr + , + bool glob = false, + void *vcbdata = nullptr +) +{ + return verb( + name, + __afb__verb__cb__for__global__, + info, + session, + auth, + glob, + reinterpret_cast<void*>(&callback) + ); +} +#endif + constexpr afb_verb_t verbend() { afb_verb_t r = verb(nullptr, nullptr); |