From 6930fff0f440339bd9d464485a9d92f87816e93a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 21 Oct 2017 23:09:22 +0200 Subject: [PATCH] Minor style changes to private webkit helper classes Include wx headers using quotes, not angle brackets. Wrap over long lines. Don't put space between the function name and its arguments. Make wxJSStringRef::ToWxString() itself, not its return value, const. Improve comments. --- include/wx/gtk/private/webkit.h | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/include/wx/gtk/private/webkit.h b/include/wx/gtk/private/webkit.h index d254e66819..1a1025ffc5 100644 --- a/include/wx/gtk/private/webkit.h +++ b/include/wx/gtk/private/webkit.h @@ -10,19 +10,27 @@ #ifndef _WX_GTK_PRIVATE_WEBKIT_H_ #define _WX_GTK_PRIVATE_WEBKIT_H_ +#include "wx/buffer.h" + #include #include -#include // ---------------------------------------------------------------------------- -// Convenience class for WebKitJavascriptResult on scope exit automatically +// RAII wrapper of WebKitJavascriptResult taking care of freeing it // ---------------------------------------------------------------------------- class wxWebKitJavascriptResult { public: - explicit wxWebKitJavascriptResult(WebKitJavascriptResult *r) : m_jsresult(r) { } - ~wxWebKitJavascriptResult() { webkit_javascript_result_unref (m_jsresult); } + explicit wxWebKitJavascriptResult(WebKitJavascriptResult *r) + : m_jsresult(r) + { + } + + ~wxWebKitJavascriptResult() + { + webkit_javascript_result_unref(m_jsresult); + } operator WebKitJavascriptResult *() const { return m_jsresult; } @@ -32,15 +40,20 @@ private: wxDECLARE_NO_COPY_CLASS(wxWebKitJavascriptResult); }; +// ---------------------------------------------------------------------------- +// RAII wrapper of JSStringRef, also providing conversion to wxString +// ---------------------------------------------------------------------------- + class wxJSStringRef { public: explicit wxJSStringRef(JSStringRef r) : m_jssref(r) { } - ~wxJSStringRef() { JSStringRelease (m_jssref); } + ~wxJSStringRef() { JSStringRelease(m_jssref); } - const wxString ToWxString() + wxString ToWxString() const { - size_t length = JSStringGetMaximumUTF8CStringSize(m_jssref); + const size_t length = JSStringGetMaximumUTF8CStringSize(m_jssref); + wxCharBuffer str(length); JSStringGetUTF8CString(m_jssref, str.data(), length);