irccd  3.0.3
irccd_api.hpp
1 /*
2  * irccd_api.hpp -- Irccd API
3  *
4  * Copyright (c) 2013-2019 David Demelier <markand@malikania.fr>
5  *
6  * Permission to use, copy, modify, and/or distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #ifndef IRCCD_JS_IRCCD_API_HPP
20 #define IRCCD_JS_IRCCD_API_HPP
21 
27 #include <cerrno>
28 #include <cstring>
29 #include <string>
30 #include <system_error>
31 
32 #include <boost/system/system_error.hpp>
33 
34 #include "api.hpp"
35 
36 namespace irccd {
37 
38 namespace daemon {
39 
40 class bot;
41 
42 } // !daemon
43 
44 namespace js {
45 
50 class irccd_api : public api {
51 public:
55  auto get_name() const noexcept -> std::string_view override;
56 
60  void load(daemon::bot& bot, js::plugin& plugin) override;
61 };
62 
63 namespace duk {
64 
68 template <>
69 struct type_traits<daemon::bot> {
76  static auto self(duk_context* ctx) -> daemon::bot&;
77 };
78 
82 template <>
83 struct type_traits<std::system_error> {
90  static void raise(duk_context* ctx, const std::system_error& ex);
91 };
92 
96 template <>
97 struct type_traits<boost::system::system_error> {
104  static void raise(duk_context* ctx, const boost::system::system_error& ex);
105 };
106 
107 } // !duk
108 
109 } // !js
110 
111 } // !irccd
112 
113 #endif // !IRCCD_JS_IRCCD_API_HPP
irccd::js::irccd_api::load
void load(daemon::bot &bot, js::plugin &plugin) override
irccd::js::plugin
Javascript plugins for irccd.
Definition: plugin.hpp:44
irccd::js::irccd_api
Irccd Javascript API.
Definition: irccd_api.hpp:50
irccd::daemon::bot
Irccd main instance.
Definition: bot.hpp:58
irccd::js::api
Javascript API module.
Definition: api.hpp:51
irccd::js::irccd_api::get_name
auto get_name() const noexcept -> std::string_view override
irccd
Parent namespace.
Definition: acceptor.hpp:43
std
Definition: bot.hpp:253
irccd::js::duk::type_traits
Operations on different types.
Definition: duk.hpp:254