Skip to content

Commit e84165a

Browse files
committed
[LINT] error 713
Loss of precision (Context) (Type to Type) Signed-off-by: Jocelyn Legault <jocelynlegault@gmail.com>
1 parent 4a300f5 commit e84165a

17 files changed

Lines changed: 63 additions & 65 deletions

PythonScript/src/ConsoleDialog.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,13 @@ void ConsoleDialog::historyPrevious()
240240
if (m_changes.find(m_currentHistory) == m_changes.end())
241241
{
242242
::SetWindowTextA(m_hInput, m_historyIter->c_str());
243-
::SendMessage(m_hInput, EM_SETSEL, m_historyIter->size(), m_historyIter->size());
243+
::SendMessage(m_hInput, EM_SETSEL, m_historyIter->size(), (LPARAM)m_historyIter->size());
244244
}
245245
else
246246
{
247247
// Set it as the changed string
248248
::SetWindowTextA(m_hInput, m_changes[m_currentHistory].c_str());
249-
::SendMessage(m_hInput, EM_SETSEL, m_changes[m_currentHistory].size(), m_changes[m_currentHistory].size());
249+
::SendMessage(m_hInput, EM_SETSEL, m_changes[m_currentHistory].size(), (LPARAM)m_changes[m_currentHistory].size());
250250
}
251251
}
252252
}
@@ -281,7 +281,7 @@ void ConsoleDialog::historyNext()
281281
if (m_historyIter != m_history.end())
282282
{
283283
::SetWindowTextA(m_hInput, m_historyIter->c_str());
284-
::SendMessage(m_hInput, EM_SETSEL, m_historyIter->size(), m_historyIter->size());
284+
::SendMessage(m_hInput, EM_SETSEL, m_historyIter->size(), (LPARAM)m_historyIter->size());
285285
}
286286
else
287287
{
@@ -292,7 +292,7 @@ void ConsoleDialog::historyNext()
292292
{
293293
// Set it as the changed string
294294
::SetWindowTextA(m_hInput, m_changes[m_currentHistory].c_str());
295-
::SendMessage(m_hInput, EM_SETSEL, m_changes[m_currentHistory].size(), m_changes[m_currentHistory].size());
295+
::SendMessage(m_hInput, EM_SETSEL, m_changes[m_currentHistory].size(), (LPARAM)m_changes[m_currentHistory].size());
296296
}
297297
}
298298
}
@@ -483,8 +483,8 @@ void ConsoleDialog::writeText(size_t length, const char *text)
483483

484484
void ConsoleDialog::writeError(size_t length, const char *text)
485485
{
486-
int docLength = callScintilla(SCI_GETLENGTH);
487-
int realLength = length;
486+
size_t docLength = (size_t)callScintilla(SCI_GETLENGTH);
487+
size_t realLength = length;
488488
callScintilla(SCI_SETREADONLY, 0);
489489
for (idx_t i = 0; i < length; ++i)
490490
{

PythonScript/src/ConsoleDialog.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ class ConsoleDialog : public DockingDlgInterface
7474

7575
std::list<std::string> m_history;
7676
std::list<std::string>::iterator m_historyIter;
77-
std::map<int, std::string> m_changes;
78-
int m_currentHistory;
77+
std::map<idx_t, std::string> m_changes;
78+
idx_t m_currentHistory;
7979
bool m_runButtonIsRun;
8080

8181
HMENU m_hContext;

PythonScript/src/ConsoleInterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class ConsoleInterface
88
virtual ~ConsoleInterface() {};
99
virtual void runStatement(const char *) = 0;
1010
virtual void stopStatement() = 0;
11-
virtual void openFile(const char *filename, int lineNumber) = 0;
11+
virtual void openFile(const char *filename, idx_t lineNumber) = 0;
1212
};
1313

1414
#endif

PythonScript/src/DynamicIDManager.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ class DynamicIDManager
3636
// Prefix increment operator
3737
DynamicIDManager& operator++();
3838

39-
40-
int capacity() { return m_capacity; }
39+
size_t capacity() { return m_capacity; }
4140

4241
bool inRange(idx_t id);
4342

PythonScript/src/MenuManager.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -564,18 +564,18 @@ void MenuManager::subclassNotepadPlusPlus()
564564
FuncItem* MenuManager::getFuncItemArray(int *nbF, ItemVectorTD items, runScriptIDFunc runScript, idx_t dynamicStartIndex, idx_t scriptsMenuIndex, idx_t stopScriptIndex, idx_t runPreviousIndex)
565565
{
566566
s_runScript = runScript;
567-
567+
568568

569569
ConfigFile* configFile = ConfigFile::getInstance();
570570

571571
ConfigFile::MenuItemsTD menuItems = configFile->getMenuItems();
572-
572+
573573

574574

575575

576576
// Remove one from the count of menu items if the list is empty
577577
// as we'll only have one separator
578-
*nbF = menuItems.size() + items.size() + (menuItems.empty() ? 0 : 1);
578+
*nbF = (int)(menuItems.size() + items.size() + (menuItems.empty() ? 0 : 1));
579579

580580
m_funcItemCount = (size_t)*nbF;
581581

@@ -791,9 +791,9 @@ void MenuManager::deleteInstance()
791791
}
792792

793793

794-
int MenuManager::findPluginCommand(const TCHAR *pluginName, const TCHAR *menuOption, bool refreshCache)
794+
idx_t MenuManager::findPluginCommand(const TCHAR *pluginName, const TCHAR *menuOption, bool refreshCache)
795795
{
796-
int retVal = 0;
796+
idx_t retVal = 0;
797797
bool fromCache = false;
798798
if (!refreshCache)
799799
{
@@ -873,7 +873,7 @@ int MenuManager::findPluginCommand(const TCHAR *pluginName, const TCHAR *menuOpt
873873

874874

875875

876-
int MenuManager::findMenuCommand(const TCHAR *menuName, const TCHAR *menuOption, bool refreshCache)
876+
idx_t MenuManager::findMenuCommand(const TCHAR *menuName, const TCHAR *menuOption, bool refreshCache)
877877
{
878878
if (!refreshCache)
879879
{
@@ -885,7 +885,7 @@ int MenuManager::findMenuCommand(const TCHAR *menuName, const TCHAR *menuOption,
885885
}
886886

887887
HMENU hMenuBar = ::GetMenu(m_hNotepad);
888-
int retVal = findMenuCommand(hMenuBar, menuName, menuOption);
888+
idx_t retVal = findMenuCommand(hMenuBar, menuName, menuOption);
889889

890890
if (retVal != 0)
891891
{
@@ -906,10 +906,10 @@ tstring MenuManager::formatMenuName(const TCHAR *name)
906906
return nameStr;
907907
}
908908

909-
int MenuManager::findMenuCommand(HMENU hParentMenu, const TCHAR *menuName, const TCHAR *menuOption)
909+
idx_t MenuManager::findMenuCommand(HMENU hParentMenu, const TCHAR *menuName, const TCHAR *menuOption)
910910
{
911911
size_t iMenuItems = (size_t)GetMenuItemCount(hParentMenu);
912-
int retVal = 0;
912+
idx_t retVal = 0;
913913

914914
TCHAR strBuffer[500];
915915

@@ -940,7 +940,7 @@ int MenuManager::findMenuCommand(HMENU hParentMenu, const TCHAR *menuName, const
940940

941941
if (0 == _tcsicmp(menuOption, nameStr.c_str()))
942942
{
943-
return ::GetMenuItemID(mii.hSubMenu, subMenuPos);
943+
return ::GetMenuItemID(mii.hSubMenu, (int)subMenuPos);
944944
}
945945
}
946946
}

PythonScript/src/MenuManager.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ class MenuManager
4949

5050
void configureToolbarIcons();
5151

52-
int findPluginCommand(const TCHAR *pluginName, const TCHAR *menuOption, bool refreshCache);
53-
int findMenuCommand(const TCHAR *menuName, const TCHAR *menuOption, bool refreshCache);
52+
idx_t findPluginCommand(const TCHAR *pluginName, const TCHAR *menuOption, bool refreshCache);
53+
idx_t findMenuCommand(const TCHAR *menuName, const TCHAR *menuOption, bool refreshCache);
5454

55-
int findMenuCommand(HMENU parentMenu, const TCHAR *menuName, const TCHAR *menuOption);
55+
idx_t findMenuCommand(HMENU parentMenu, const TCHAR *menuName, const TCHAR *menuOption);
5656

5757
void updatePreviousScript(const char *filename);
5858
void updateShortcut(UINT cmdID, ShortcutKey* key);
@@ -90,9 +90,9 @@ class MenuManager
9090
runScriptFunc m_runScript;
9191

9292
typedef std::set<std::string> MachineScriptNamesTD;
93-
typedef std::map<int, std::string> ScriptCommandsTD;
93+
typedef std::map<idx_t, std::string> ScriptCommandsTD;
9494
typedef std::map<std::string, HMENU> SubmenusTD;
95-
typedef std::map<std::pair<tstring, tstring>, int> MenuCommandCacheTD;
95+
typedef std::map<std::pair<tstring, tstring>, idx_t> MenuCommandCacheTD;
9696
MenuCommandCacheTD m_menuCommandCache;
9797
MenuCommandCacheTD m_pluginCommandCache;
9898

PythonScript/src/NotepadPlusWrapper.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ void NotepadPlusWrapper::saveSession(const char *sessionFilename, boost::python:
334334
si.files[pos] = filesList[pos].get();
335335
}
336336

337-
si.nbFile = filesCount;
337+
si.nbFile = (int)filesCount;
338338

339339
Py_BEGIN_ALLOW_THREADS
340340
callNotepad(NPPM_SAVESESSION, 0, reinterpret_cast<LPARAM>(&si));
@@ -761,7 +761,7 @@ void NotepadPlusWrapper::activateBufferID(int bufferID)
761761
UINT view = (index & 0xC0000000) >> 30;
762762
index = index & 0x3FFFFFFF;
763763

764-
callNotepad(NPPM_ACTIVATEDOC, view, index);
764+
callNotepad(NPPM_ACTIVATEDOC, view, (LPARAM)index);
765765
Py_END_ALLOW_THREADS
766766
}
767767
boost::python::str NotepadPlusWrapper::getBufferFilename(int bufferID)
@@ -792,7 +792,7 @@ bool NotepadPlusWrapper::runPluginCommand(boost::python::str pluginName, boost::
792792
std::shared_ptr<TCHAR> tpluginName = WcharMbcsConverter::char2tchar(boost::python::extract<const char *>(pluginName));
793793
std::shared_ptr<TCHAR> tmenuOption = WcharMbcsConverter::char2tchar(boost::python::extract<const char *>(menuOption));
794794
Py_BEGIN_ALLOW_THREADS
795-
int commandID = menuManager->findPluginCommand(tpluginName.get(), tmenuOption.get(), refreshCache);
795+
idx_t commandID = menuManager->findPluginCommand(tpluginName.get(), tmenuOption.get(), refreshCache);
796796
if (commandID)
797797
{
798798
::SendMessage(m_nppHandle, WM_COMMAND, commandID, 0);
@@ -813,7 +813,7 @@ bool NotepadPlusWrapper::runMenuCommand(boost::python::str menuName, boost::pyth
813813
std::shared_ptr<TCHAR> tmenuName = WcharMbcsConverter::char2tchar(boost::python::extract<const char *>(menuName));
814814
std::shared_ptr<TCHAR> tmenuOption = WcharMbcsConverter::char2tchar(boost::python::extract<const char *>(menuOption));
815815
Py_BEGIN_ALLOW_THREADS
816-
int commandID = menuManager->findMenuCommand(tmenuName.get(), tmenuOption.get(), refreshCache);
816+
idx_t commandID = menuManager->findMenuCommand(tmenuName.get(), tmenuOption.get(), refreshCache);
817817
if (commandID)
818818
{
819819
::SendMessage(m_nppHandle, WM_COMMAND, commandID, 0);

PythonScript/src/NotepadPlusWrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ class NotepadPlusWrapper
559559

560560
static bool isInEvent() { return s_inEvent; };
561561

562-
typedef std::multimap<int, PyObject*> callbackT;
562+
typedef std::multimap<idx_t, PyObject*> callbackT;
563563

564564
protected:
565565
LRESULT callNotepad(UINT message, WPARAM wParam = 0, LPARAM lParam = 0)

PythonScript/src/ProcessExecute.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ bool ProcessExecute::isWindowsNT()
3232
return (osv.dwPlatformId >= VER_PLATFORM_WIN32_NT);
3333
}
3434

35-
long ProcessExecute::execute(const TCHAR *commandLine, boost::python::object pyStdout, boost::python::object pyStderr, boost::python::object /*pyStdin*/, bool spoolToFile /* = false */)
35+
DWORD ProcessExecute::execute(const TCHAR *commandLine, boost::python::object pyStdout, boost::python::object pyStderr, boost::python::object /*pyStdin*/, bool spoolToFile /* = false */)
3636
{
3737
DWORD returnValue = 0;
3838

@@ -324,7 +324,7 @@ DWORD WINAPI ProcessExecute::pipeReader(void *args)
324324
return 0;
325325
}
326326

327-
void ProcessExecute::writeToPython(PipeReaderArgs *pipeReaderArgs, int bytesRead, char *buffer)
327+
void ProcessExecute::writeToPython(PipeReaderArgs *pipeReaderArgs, DWORD bytesRead, char *buffer)
328328
{
329329
buffer[bytesRead] = '\0';
330330
PyGILState_STATE gstate = PyGILState_Ensure();
@@ -340,7 +340,7 @@ void ProcessExecute::writeToPython(PipeReaderArgs *pipeReaderArgs, int bytesRead
340340
}
341341

342342

343-
void ProcessExecute::writeToFile(PipeReaderArgs *pipeReaderArgs, int bytesRead, char *buffer)
343+
void ProcessExecute::writeToFile(PipeReaderArgs *pipeReaderArgs, DWORD bytesRead, char *buffer)
344344
{
345345
WaitForSingleObject(pipeReaderArgs->fileMutex, INFINITE);
346346

@@ -351,9 +351,8 @@ void ProcessExecute::writeToFile(PipeReaderArgs *pipeReaderArgs, int bytesRead,
351351
throw process_start_exception("Error writing to spool file");
352352

353353
char byteCount[20];
354-
_itoa_s(bytesRead, byteCount, 20, 10);
355-
strcat_s(byteCount, 20, "\n");
356-
354+
sprintf_s(byteCount, 20, "%ul\n", bytesRead);
355+
357356
pipeReaderArgs->file->write(byteCount, strlen(byteCount));
358357

359358
pipeReaderArgs->file->write(buffer, bytesRead);

PythonScript/src/ProcessExecute.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class ProcessExecute
1010
ProcessExecute();
1111
~ProcessExecute();
1212

13-
long execute(const TCHAR *commandLine, boost::python::object pyStdout, boost::python::object pyStderr, boost::python::object pyStdin, bool spoolToFile = false);
13+
DWORD execute(const TCHAR *commandLine, boost::python::object pyStdout, boost::python::object pyStderr, boost::python::object pyStdin, bool spoolToFile = false);
1414

1515
protected:
1616
static bool isWindowsNT();
@@ -20,8 +20,8 @@ class ProcessExecute
2020

2121
private:
2222
static DWORD WINAPI pipeReader(void *args);
23-
void writeToPython(PipeReaderArgs *pipeReaderArgs, int bytesRead, char *buffer);
24-
void writeToFile(PipeReaderArgs *pipeReaderArgs, int bytesRead, char *buffer);
23+
void writeToPython(PipeReaderArgs *pipeReaderArgs, DWORD bytesRead, char *buffer);
24+
void writeToFile(PipeReaderArgs *pipeReaderArgs, DWORD bytesRead, char *buffer);
2525
void spoolFile(std::fstream* file, boost::python::object pyStdout, boost::python::object pyStderr);
2626

2727
};

0 commit comments

Comments
 (0)