From 1f6b4591b4697a3acf228e694c490cc5f75ae4e4 Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Tue, 29 Sep 2015 20:38:53 +0300 Subject: Add rest of missing Card exceptions. --- libkms++/card.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libkms++/card.cpp b/libkms++/card.cpp index 626c424..7aa8bdb 100644 --- a/libkms++/card.cpp +++ b/libkms++/card.cpp @@ -136,7 +136,7 @@ Property* Card::get_prop(const char *name) const return prop; } - throw invalid_argument("foo"); + throw invalid_argument(string("Card property ") + name + " not found"); } Connector* Card::get_first_connected_connector() const @@ -193,7 +193,7 @@ Crtc* Card::get_crtc_by_index(uint32_t idx) const if (crtc && crtc->idx() == idx) return crtc; } - throw invalid_argument("fob"); + throw invalid_argument(string("Crtc #") + to_string(idx) + "not found"); } Crtc* Card::get_crtc(uint32_t id) const { return dynamic_cast(get_object(id)); } @@ -221,7 +221,9 @@ std::vector Card::get_connected_pipelines() } if (!crtc) - throw invalid_argument("fob"); + throw invalid_argument(string("Connector #") + + to_string(conn->idx()) + + " has no possible crtcs"); outputs.push_back(Pipeline { crtc, conn }); } -- cgit v1.2.3 From ef7fa369385fc99be4c861e5b3d444e32c5c101b Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Tue, 29 Sep 2015 20:41:19 +0300 Subject: There is no need to convert exception strings to .c_str(). --- libkms++/card.cpp | 6 +++--- libkms++/connector.cpp | 2 +- libkms++/drmobject.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libkms++/card.cpp b/libkms++/card.cpp index 7aa8bdb..52a0f7a 100644 --- a/libkms++/card.cpp +++ b/libkms++/card.cpp @@ -26,8 +26,8 @@ Card::Card() int fd = open(card, O_RDWR | O_CLOEXEC); if (fd < 0) - throw invalid_argument((string(strerror(errno)) + - " opening " + card).c_str()); + throw invalid_argument(string(strerror(errno)) + " opening " + + card); m_fd = fd; int r; @@ -222,7 +222,7 @@ std::vector Card::get_connected_pipelines() if (!crtc) throw invalid_argument(string("Connector #") + - to_string(conn->idx()) + + to_string(conn->idx()) + " has no possible crtcs"); outputs.push_back(Pipeline { crtc, conn }); diff --git a/libkms++/connector.cpp b/libkms++/connector.cpp index b045b8b..0731f2b 100644 --- a/libkms++/connector.cpp +++ b/libkms++/connector.cpp @@ -98,7 +98,7 @@ Videomode Connector::get_mode(const char *mode) const if (sMode == c->modes[i].name) return drm_mode_to_video_mode(c->modes[i]); - throw invalid_argument((sMode + ": mode not found").c_str()); + throw invalid_argument(sMode + ": mode not found"); } bool Connector::connected() const diff --git a/libkms++/drmobject.cpp b/libkms++/drmobject.cpp index a79370f..f48153a 100644 --- a/libkms++/drmobject.cpp +++ b/libkms++/drmobject.cpp @@ -64,6 +64,6 @@ uint64_t DrmObject::get_prop_value(const char *name) const return m_prop_values.at(prop->id()); } - throw invalid_argument((string(name) + ": property not found").c_str()); + throw invalid_argument(string(name) + ": property not found"); } } -- cgit v1.2.3 From 5d42bc1af257681985ba9bb55a34eb9e9afe050c Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Wed, 30 Sep 2015 11:40:11 +0300 Subject: Add Connector::get_mode(const std::string &mode), remove const char * variant --- libkms++/connector.cpp | 7 +++---- libkms++/connector.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/libkms++/connector.cpp b/libkms++/connector.cpp index 0731f2b..8ff5a5f 100644 --- a/libkms++/connector.cpp +++ b/libkms++/connector.cpp @@ -89,16 +89,15 @@ Videomode Connector::get_default_mode() const return drm_mode_to_video_mode(drmmode); } -Videomode Connector::get_mode(const char *mode) const +Videomode Connector::get_mode(const string& mode) const { auto c = m_priv->drm_connector; - string sMode(mode); for (int i = 0; i < c->count_modes; i++) - if (sMode == c->modes[i].name) + if (mode == c->modes[i].name) return drm_mode_to_video_mode(c->modes[i]); - throw invalid_argument(sMode + ": mode not found"); + throw invalid_argument(mode + ": mode not found"); } bool Connector::connected() const diff --git a/libkms++/connector.h b/libkms++/connector.h index 198a6dd..14e6b36 100644 --- a/libkms++/connector.h +++ b/libkms++/connector.h @@ -34,7 +34,7 @@ public: Videomode get_default_mode() const; - Videomode get_mode(const char *mode) const; + Videomode get_mode(const std::string& mode) const; Crtc* get_current_crtc() const { return m_current_crtc; } std::vector get_possible_crtcs() const; -- cgit v1.2.3 From ed9cb183b240702f74477351cada83d59da3144b Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Wed, 30 Sep 2015 14:34:52 +0300 Subject: Add std::string support to swig for lua and python. --- lua/luakms.i | 1 + py/pykms.i | 1 + 2 files changed, 2 insertions(+) diff --git a/lua/luakms.i b/lua/luakms.i index 60931f1..2920c46 100644 --- a/lua/luakms.i +++ b/lua/luakms.i @@ -5,6 +5,7 @@ using namespace kms; %} +%include "std_string.i" %include "stdint.i" %include "decls.h" diff --git a/py/pykms.i b/py/pykms.i index 6a6ad11..b9d61df 100644 --- a/py/pykms.i +++ b/py/pykms.i @@ -5,6 +5,7 @@ using namespace kms; %} +%include "std_string.i" %include "stdint.i" %include "decls.h" -- cgit v1.2.3