summaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
authorMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-07-12 15:59:37 +0200
committerMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-08-08 17:24:00 +0200
commit54c34361d08386c751897ee215554c9ea1efd108 (patch)
tree28ae052b7e819d9f5308b3545beb029c88a476d7 /src/main.cpp
parent628df48e0238391658dab54f81dfa1c62dbfb3ec (diff)
Generating binding API glue code using generate-binding.py
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp100
1 files changed, 7 insertions, 93 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 5c9df33..23b1b4d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -16,7 +16,6 @@ struct afb_instance {
std::unique_ptr<wl::display> display;
std::unique_ptr<genivi::controller> controller;
std::vector<std::unique_ptr<wl::output>> outputs;
-
wm::App app;
afb_instance() : display{new wl::display}, controller{nullptr}, outputs{}, app{} {}
@@ -57,6 +56,10 @@ int afb_instance::init() {
// Third level objects
this->display->roundtrip();
+ // Init the app's members
+ this->app.display = this->display.get();
+ this->app.controller = this->controller.get();
+
return 0;
}
@@ -202,98 +205,9 @@ int binding_init() noexcept {
return -1;
}
-// _ _ _ _ ____
-// __| | ___| |__ _ _ __ _ ___| |_ __ _| |_ _ _ ___ / /\ \
-// / _` |/ _ \ '_ \| | | |/ _` | / __| __/ _` | __| | | / __| | | |
-// | (_| | __/ |_) | |_| | (_| | \__ \ || (_| | |_| |_| \__ \ | | |
-// \__,_|\___|_.__/ \__,_|\__, |___|___/\__\__,_|\__|\__,_|___/ | | |
-// |___/_____| \_\/_/
-void debug_status(struct afb_req req) {
- // Quick and dirty, dump current surfaces and layers
- AFB_REQ_DEBUG(req, "status");
-
- // auto r = g_afb_instance->app.api.debug_status();
- // if (r.is_err()) {
- // afb_req_fail(req, "failed", r.e.value());
- // return;
- // }
-
- auto o = json_object_new_object();
- json_object_object_add(o, "surfaces",
- to_json(g_afb_instance->controller->sprops));
- json_object_object_add(o, "layers", to_json(g_afb_instance->controller->lprops));
-// json_object_object_add(o, "screens",
-// to_json(g_afb_instance->controller->screens));
-
- afb_req_success(req, o, "status");
-}
-
-void debug_surfaces(afb_req req) {
- afb_req_success(req, to_json(g_afb_instance->controller->sprops), "surfaces");
-}
-
-void debug_layers(afb_req req) {
- afb_req_success(req, to_json(g_afb_instance->controller->lprops), "layers");
-}
-
-// Dummy register_surface implementation
-void register_surface(afb_req req) {
- AFB_DEBUG("register_surface");
-
- auto jo = afb_req_json(req);
- json_object *jappid;
- if (! json_object_object_get_ex(jo, "appid", &jappid)) {
- afb_req_fail(req, "failed", "register_surface needs 'appid' integer argument");
- return;
- }
-
- json_object *jsurfid;
- if (! json_object_object_get_ex(jo, "surfaceid", &jsurfid)) {
- afb_req_fail(req, "failed", "register_surface needs 'surfaceid' integer argument");
- return;
- }
-
- uint32_t appid = json_object_get_int(jappid);
- uint32_t surfid = json_object_get_int(jsurfid);
-
- if (appid > 0xff) {
- afb_req_fail(req, "failed", "invalid appid");
- return;
- }
-
- if (surfid > 0xffff) {
- afb_req_fail(req, "failed", "invalid surfaceid");
- return;
- }
-
- lognotice("register_surface, got appid %d and surfaceid %d", appid, surfid);
-
- afb_req_success(req, json_object_new_int((appid << 16) + surfid), "success");
-}
-
-#define WRAP(F) \
- [](afb_req req) noexcept { \
- if (g_afb_instance == nullptr) { \
- afb_req_fail(req, "failed", \
- "Binding not initialized, did the compositor die?"); \
- return; \
- } \
- try { \
- F(req); \
- } catch (std::exception & e) { \
- afb_req_fail_f(req, "failed", "Uncaught exception: %s", e.what()); \
- } \
- }
-
-const struct afb_verb_v2 verbs[] = {
- {"debug::status", WRAP(debug_status), NULL, NULL, AFB_SESSION_NONE_V2},
- {"debug::layers", WRAP(debug_layers), NULL, NULL, AFB_SESSION_NONE_V2},
- {"debug::surfaces", WRAP(debug_surfaces), NULL, NULL, AFB_SESSION_NONE_V2},
+} // namespace
- {"register_surface", WRAP(register_surface), NULL, NULL, AFB_SESSION_NONE_V2},
- {}
-};
-} // namespace
+#include "afb_binding.inl"
extern "C" const struct afb_binding_v2 afbBindingV2 = {
- "winman", NULL, NULL, verbs, NULL, binding_init, NULL, 1};
+ "winman", NULL, NULL, winman_verbs, NULL, binding_init, NULL, 1};