From 1b7bb4656818c322ccc38478271ab09063ac4f33 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 22 Oct 2017 17:30:30 +0200 Subject: [PATCH] Don't use dollar sign in the JavaScript variable name neither While it is allowed there, it is confusing and unnecessary. Also improve the comment explaining why do we need this output variable name at all and why does it need to be unique. --- include/wx/private/jsscriptwrapper.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/include/wx/private/jsscriptwrapper.h b/include/wx/private/jsscriptwrapper.h index 399d6c3ec5..367b41d19e 100644 --- a/include/wx/private/jsscriptwrapper.h +++ b/include/wx/private/jsscriptwrapper.h @@ -21,9 +21,14 @@ class wxJSScriptWrapper public: wxJSScriptWrapper(const wxString& js, int* runScriptCount) : m_jsscript(js) { - // __outputVarName is used to have a different variable on every - // RunScript call, to not lose variable values between calls - m_outputVarName = wxString::Format("__wx$%i", (*runScriptCount)++); + // We assign the return value of JavaScript snippet we execute to the + // variable with this name in order to be able to access it later if + // needed. + // + // Note that we use a different name for it for each call to + // RunScript() (which creates a new wxJSScriptWrapper every time) to + // avoid any possible conflict between different calls. + m_outputVarName = wxString::Format("__wxOut%i", (*runScriptCount)++); } // This method is used to add a double quote level into a JavaScript code