Skip to content

Commit 82b7e3d

Browse files
committed
[LINT] error 578
Declaration of symbol 'Symbol' hides symbol 'Symbol' Usage of `using namespace` muddied the global namespace with a lot of names that had a very real potential for colliding. Only because cl.exe (VS's compiler) tank-like abilities to compile anything was this working in some cases. There are still some 'error 578' left, but we'll take care of that in a later commit. Signed-off-by: Jocelyn Legault <jocelynlegault@gmail.com>
1 parent 361f808 commit 82b7e3d

22 files changed

+415
-478
lines changed

PythonScript/src/ConfigFile.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
#include "resource.h"
55
#include "WcharMbcsConverter.h"
66

7-
using namespace std;
8-
97
ConfigFile* ConfigFile::s_instance;
108

119
ConfigFile* ConfigFile::create(const TCHAR *configDir, const TCHAR *pluginDir, HINSTANCE hInst)
@@ -44,7 +42,7 @@ ConfigFile::~ConfigFile()
4442

4543
void ConfigFile::readConfig()
4644
{
47-
basic_ifstream<TCHAR> startupFile(m_configFilename.c_str());
45+
std::basic_ifstream<TCHAR> startupFile(m_configFilename.c_str());
4846

4947
TCHAR buffer[500];
5048

@@ -64,7 +62,7 @@ void ConfigFile::readConfig()
6462
{
6563
element = _tcstok_s(NULL, _T("/"), &context);
6664
m_menuItems.push_back(tstring(element));
67-
m_menuScripts.push_back(string(WcharMbcsConverter::tchar2char(element).get()));
65+
m_menuScripts.push_back(std::string(WcharMbcsConverter::tchar2char(element).get()));
6866
}
6967

7068
// Toolbar item
@@ -83,13 +81,13 @@ void ConfigFile::readConfig()
8381
}
8482

8583

86-
m_toolbarItems.push_back(pair<tstring, pair<HBITMAP, tstring> >(tstring(element), pair<HBITMAP, tstring>(hIcon, iconPath ? tstring(iconPath) : tstring())));
84+
m_toolbarItems.push_back(std::pair<tstring, std::pair<HBITMAP, tstring> >(tstring(element), std::pair<HBITMAP, tstring>(hIcon, iconPath ? tstring(iconPath) : tstring())));
8785
}
8886
else if (0 == _tcscmp(element, _T("SETTING")))
8987
{
9088
element = _tcstok_s(NULL, _T("/"), &context);
9189
TCHAR *settingValue = _tcstok_s(NULL, _T("/"), &context);
92-
m_settings.insert(pair<tstring, tstring>(tstring(element), tstring(settingValue)));
90+
m_settings.insert(std::pair<tstring, tstring>(tstring(element), tstring(settingValue)));
9391
}
9492
}
9593

@@ -106,7 +104,7 @@ void ConfigFile::clearItems()
106104

107105
void ConfigFile::save()
108106
{
109-
basic_ofstream<TCHAR> startupFile(m_configFilename.c_str(), ios_base::out | ios_base::trunc);
107+
std::basic_ofstream<TCHAR> startupFile(m_configFilename.c_str(), std::ios_base::out | std::ios_base::trunc);
110108
for(MenuItemsTD::iterator it = m_menuItems.begin(); it != m_menuItems.end(); ++it)
111109
{
112110
startupFile << "ITEM/" << (*it) << "\n";
@@ -130,13 +128,13 @@ void ConfigFile::save()
130128
void ConfigFile::addMenuItem(const tstring scriptPath)
131129
{
132130
m_menuItems.push_back(scriptPath);
133-
m_menuScripts.push_back(string(WcharMbcsConverter::tchar2char(scriptPath.c_str()).get()));
131+
m_menuScripts.push_back(std::string(WcharMbcsConverter::tchar2char(scriptPath.c_str()).get()));
134132
}
135133

136134
void ConfigFile::addToolbarItem(const tstring scriptPath, const tstring iconPath)
137135
{
138136
HBITMAP hIcon = static_cast<HBITMAP>(LoadImage(m_hInst, iconPath.c_str(), IMAGE_BITMAP, 16, 16, LR_LOADMAP3DCOLORS));
139-
m_toolbarItems.push_back(pair<tstring, pair<HBITMAP, tstring> >(scriptPath, pair<HBITMAP, tstring>(hIcon, iconPath)));
137+
m_toolbarItems.push_back(std::pair<tstring, std::pair<HBITMAP, tstring> >(scriptPath, std::pair<HBITMAP, tstring>(hIcon, iconPath)));
140138
}
141139

142140
void ConfigFile::setSetting(const tstring& settingName, const tstring settingValue)

PythonScript/src/ConsoleDialog.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
#include "PluginInterface.h"
99
#include "Docking.h"
1010

11-
using namespace std;
12-
1311
ConsoleDialog::ConsoleDialog()
1412
: DockingDlgInterface(IDD_CONSOLE),
1513
m_data(new tTbData),
@@ -199,11 +197,11 @@ void ConsoleDialog::historyPrevious()
199197
{
200198
if (m_changes.find(m_currentHistory) == m_changes.end())
201199
{
202-
m_changes.insert(pair<int, string>(m_currentHistory, string(buffer)));
200+
m_changes.insert(std::pair<int, std::string>(m_currentHistory, std::string(buffer)));
203201
}
204202
else
205203
{
206-
m_changes[m_currentHistory] = string(buffer);
204+
m_changes[m_currentHistory] = std::string(buffer);
207205
}
208206
}
209207

@@ -239,11 +237,11 @@ void ConsoleDialog::historyNext()
239237
{
240238
if (m_changes.find(m_currentHistory) == m_changes.end())
241239
{
242-
m_changes.insert(pair<int, string>(m_currentHistory, string(buffer)));
240+
m_changes.insert(std::pair<int, std::string>(m_currentHistory, std::string(buffer)));
243241
}
244242
else
245243
{
246-
m_changes[m_currentHistory] = string(buffer);
244+
m_changes[m_currentHistory] = std::string(buffer);
247245
}
248246
}
249247

@@ -279,7 +277,7 @@ void ConsoleDialog::historyAdd(const char *line)
279277
{
280278
if (line && line[0])
281279
{
282-
m_history.push_back(string(line));
280+
m_history.push_back(std::string(line));
283281
m_currentHistory = m_history.size();
284282
}
285283

PythonScript/src/CreateWrapper.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,20 @@
3939
}
4040

4141
castsL = {
42-
'boost::python::str' : lambda name: "reinterpret_cast<LPARAM>(static_cast<const char*>(extract<const char *>(" + name + ")))",
42+
'boost::python::str' : lambda name: "reinterpret_cast<LPARAM>(static_cast<const char*>(boost::python::extract<const char *>(" + name + ")))",
4343
# Hack - assume a tuple is a colour
4444
'boost::python::tuple': lambda name: "MAKECOLOUR(" + name + ")".format(name)
4545
}
4646

4747
castsW = {
48-
'boost::python::str' : lambda name: "reinterpret_cast<WPARAM>(static_cast<const char*>(extract<const char *>(" + name + ")))",
48+
'boost::python::str' : lambda name: "reinterpret_cast<WPARAM>(static_cast<const char*>(boost::python::extract<const char *>(" + name + ")))",
4949
# Hack - assume a tuple is a colour
5050
'boost::python::tuple': lambda name: "MAKECOLOUR(" + name + ")".format(name)
5151
}
5252

5353
castsRet = {
5454
'bool' : lambda val: 'return 0 != (' + val + ')',
55-
'boost::python::tuple': lambda val: 'int retVal = callScintilla(' + val + ');\n\treturn make_tuple(COLOUR_RED(retVal), COLOUR_GREEN(retVal), COLOUR_BLUE(retVal))'
55+
'boost::python::tuple': lambda val: 'int retVal = callScintilla(' + val + ');\n\treturn boost::python::make_tuple(COLOUR_RED(retVal), COLOUR_GREEN(retVal), COLOUR_BLUE(retVal))'
5656

5757
}
5858

@@ -92,15 +92,15 @@ def cellsBody(v, out):
9292

9393

9494
def constString(v, out):
95-
out.write("\tconst char *raw = extract<const char *>(" + v["Param2Name"] + ".attr(\"__str__\")());\n")
95+
out.write("\tconst char *raw = boost::python::extract<const char *>(" + v["Param2Name"] + ".attr(\"__str__\")());\n")
9696
out.write("\treturn callScintilla(" + symbolName(v) + ", len(" + v["Param2Name"] + "), reinterpret_cast<LPARAM>(raw));\n");
9797

9898
def retString(v, out):
9999
out.write("\tint resultLength = callScintilla(" + symbolName(v) + ");\n")
100100
out.write("\tchar *result = (char *)malloc(resultLength + 1);\n")
101101
out.write("\tcallScintilla(" + symbolName(v) + ", resultLength + 1, reinterpret_cast<LPARAM>(result));\n")
102102
out.write("\tresult[resultLength] = '\\0';\n")
103-
out.write("\tstr o = str((const char *)result);\n")
103+
out.write("\tboost::python::str o = boost::python::str(result);\n")
104104
out.write("\tfree(result);\n")
105105
out.write("\treturn o;\n")
106106

@@ -116,7 +116,7 @@ def getLineBody(v, out):
116116
out.write("\t\tchar *result = (char *)malloc(resultLength + 1);\n")
117117
out.write("\t\tcallScintilla(" + symbolName(v) + ", line, reinterpret_cast<LPARAM>(result));\n")
118118
out.write("\t\tresult[resultLength] = '\\0';\n")
119-
out.write("\t\tstr o = str((const char *)result);\n")
119+
out.write("\t\tboost::python::str o = boost::python::str(result);\n")
120120
out.write("\t\tfree(result);\n")
121121
out.write("\t\treturn o;\n")
122122
out.write("\t}\n")
@@ -148,19 +148,19 @@ def retStringNoLength(v, out):
148148

149149
out.write(", reinterpret_cast<LPARAM>(result));\n")
150150
out.write("\tresult[resultLength] = '\\0';\n")
151-
out.write("\tstr o = str((const char *)result);\n")
151+
out.write("\tboost::python::str o = boost::python::str(result);\n")
152152
out.write("\tfree(result);\n")
153153
out.write("\treturn o;\n")
154154

155155
def findTextBody(v, out):
156156
out.write('\tSci_TextToFind src;\n')
157157
out.write('\tsrc.chrg.cpMin = start;\n')
158158
out.write('\tsrc.chrg.cpMax = end;\n')
159-
out.write('\tsrc.lpstrText = const_cast<char*>((const char *)extract<const char *>({0}.attr("__str__")()));\n'.format(v['Param2Name']))
159+
out.write('\tsrc.lpstrText = const_cast<char*>((const char *)boost::python::extract<const char *>({0}.attr("__str__")()));\n'.format(v['Param2Name']))
160160
out.write('\tint result = callScintilla({0}, {1}, reinterpret_cast<LPARAM>(&src));\n'.format(symbolName(v), v["Param1Name"]))
161161
out.write('\tif (-1 == result)\n')
162-
out.write('\t{\n\t\treturn object();\n\t}\n')
163-
out.write('\telse\n\t{\n\t\treturn make_tuple(src.chrgText.cpMin, src.chrgText.cpMax);\n\t}\n')
162+
out.write('\t{\n\t\treturn boost::python::object();\n\t}\n')
163+
out.write('\telse\n\t{\n\t\treturn boost::python::make_tuple(src.chrgText.cpMin, src.chrgText.cpMax);\n\t}\n')
164164

165165

166166
def getTextRangeBody(v, out):
@@ -175,7 +175,7 @@ def getTextRangeBody(v, out):
175175
out.write('\tsrc.chrg.cpMax = end;\n')
176176
out.write('\tsrc.lpstrText = new char[(end-start) + 1];\n')
177177
out.write('\tcallScintilla({0}, 0, reinterpret_cast<LPARAM>(&src));\n'.format(symbolName(v)))
178-
out.write('\tstr ret(const_cast<const char*>(src.lpstrText));\n')
178+
out.write('\tboost::python::str ret(const_cast<const char*>(src.lpstrText));\n')
179179
out.write('\tdelete src.lpstrText;\n')
180180
out.write('\treturn ret;\n')
181181

@@ -192,18 +192,18 @@ def getStyledTextBody(v, out):
192192
out.write('\tsrc.chrg.cpMax = end;\n')
193193
out.write('\tsrc.lpstrText = new char[((end-start) * 2) + 2];\n')
194194
out.write('\tcallScintilla({0}, 0, reinterpret_cast<LPARAM>(&src));\n'.format(symbolName(v)))
195-
out.write('\tlist styles;\n')
195+
out.write('\tboost::python::list styles;\n')
196196
out.write('\tchar *result = new char[(end-start) + 1];\n')
197197
out.write('\tfor(int pos = 0; pos < (end - start); pos++)\n')
198198
out.write('\t{\n')
199199
out.write('\t\tresult[pos] = src.lpstrText[pos * 2];\n')
200200
out.write('\t\tstyles.append((int)(src.lpstrText[(pos * 2) + 1]));\n')
201201
out.write('\t}\n')
202202
out.write("\tresult[end-start] = '\\0';\n")
203-
out.write('\tstr resultStr(const_cast<const char*>(result));\n')
203+
out.write('\tboost::python::str resultStr(const_cast<const char*>(result));\n')
204204
out.write('\tdelete src.lpstrText;\n')
205205
out.write('\tdelete result;\n')
206-
out.write('\treturn make_tuple(resultStr, styles);\n')
206+
out.write('\treturn boost::python::make_tuple(resultStr, styles);\n')
207207

208208

209209

@@ -451,12 +451,12 @@ def writeEnumsWrapperFile(f, out):
451451
for name in f.enums:
452452
v = f.enums[name]
453453
if v.get('Values'):
454-
out.write('\tenum_<{0}>("{1}")'.format(name, name.upper()))
454+
out.write('\tboost::python::enum_<{0}>("{1}")'.format(name, name.upper()))
455455
for val in v['Values']:
456456
out.write('\n\t\t.value("{0}", PYSCR_{1})'.format(val[0][len(v['Value']):].upper(), val[0]))
457457
out.write(';\n\n')
458458

459-
out.write('\tenum_<ScintillaNotification>("SCINTILLANOTIFICATION")'.format(name, name.upper()))
459+
out.write('\tboost::python::enum_<ScintillaNotification>("SCINTILLANOTIFICATION")'.format(name, name.upper()))
460460

461461
for name in f.order:
462462
v = f.features[name]
@@ -465,7 +465,7 @@ def writeEnumsWrapperFile(f, out):
465465
out.write('\n\t\t.value("{0}", PYSCR_SCN_{1})'.format(name.upper(), name.upper()))
466466
out.write(';\n\n')
467467

468-
out.write('\tenum_<ScintillaMessage>("SCINTILLAMESSAGE")'.format(name, name.upper()))
468+
out.write('\tboost::python::enum_<ScintillaMessage>("SCINTILLAMESSAGE")'.format(name, name.upper()))
469469
for name in f.order:
470470
v = f.features[name]
471471
if v["Category"] != "Deprecated":

PythonScript/src/DynamicIDManager.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
#include "DynamicIDManager.h"
55
#include "IDAllocator.h"
66

7-
using namespace std;
8-
9-
107
void DynamicIDManager::reserve(int quantity)
118
{
129
if (quantity > m_capacity)
@@ -17,7 +14,7 @@ void DynamicIDManager::reserve(int quantity)
1714

1815
void DynamicIDManager::addBlock(int start, int quantity)
1916
{
20-
m_idList.push_back(pair<int, int>(start, quantity));
17+
m_idList.push_back(std::pair<int, int>(start, quantity));
2118

2219
// Assume no overlaps (should really fix this, but we just need to use this carefully)
2320
m_capacity += quantity;
@@ -42,7 +39,7 @@ void DynamicIDManager::reserveAdditional(int quantity)
4239

4340
else // Otherwise just add a new block
4441
{
45-
m_idList.push_back(pair<int, int>(start, quantity));
42+
m_idList.push_back(std::pair<int, int>(start, quantity));
4643
}
4744

4845
m_capacity += quantity;
@@ -94,7 +91,7 @@ DynamicIDManager& DynamicIDManager::operator++(int)
9491
--m_current;
9592
if (m_nextID >= (m_current->first + m_current->second))
9693
{
97-
throw exception("Out of IDs");
94+
throw std::exception("Out of IDs");
9895
}
9996
else
10097
{
@@ -131,7 +128,7 @@ bool DynamicIDManager::allocateIDs(int quantity, int *start)
131128
bool DynamicIDManager::inRange(int id)
132129
{
133130
bool retVal = false;
134-
list< pair<int, int> >::iterator it = m_idList.begin();
131+
std::list< std::pair<int, int> >::iterator it = m_idList.begin();
135132
for(;it != m_idList.end(); ++it)
136133
{
137134
if (it->first > id)

0 commit comments

Comments
 (0)