Skip to content

Commit c277e90

Browse files
committed
fix: clang warnings
1 parent 203b655 commit c277e90

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

src/module.cpp

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <climits>
44
#include <cuchar>
55
#include <bitset>
6+
#include <exception>
67

78
#include <plugify/logger.hpp>
89
#include <plugify/provider.hpp>
@@ -11,8 +12,6 @@
1112
#include <plg/any.hpp>
1213
#include <plg/format.hpp>
1314

14-
#include <module_export.h>
15-
1615
#include "plugify/enum_object.hpp"
1716
#include "plugify/enum_value.hpp"
1817

@@ -1460,16 +1459,16 @@ namespace py3lm {
14601459

14611460
template<typename T>
14621461
PyObject* CreatePyObjectList(const plg::vector<T>& arrayArg) {
1463-
const auto size = static_cast<Py_ssize_t>(arrayArg.size());
1462+
const auto size = arrayArg.size();
14641463
PyObject* const arrayObject = PyList_New(size);
14651464
if (arrayObject) {
1466-
for (Py_ssize_t i = 0; i < size; ++i) {
1465+
for (size_t i = 0; i < size; ++i) {
14671466
PyObject* const valueObject = CreatePyObject(arrayArg[i]);
14681467
if (!valueObject) {
14691468
Py_DECREF(arrayObject);
14701469
return nullptr;
14711470
}
1472-
PyList_SET_ITEM(arrayObject, i, valueObject);
1471+
PyList_SET_ITEM(arrayObject, static_cast<Py_ssize_t>(i), valueObject);
14731472
}
14741473
}
14751474
return arrayObject;
@@ -1482,16 +1481,16 @@ namespace py3lm {
14821481

14831482
template<typename T>
14841483
PyObject* CreatePyEnumObjectList(const EnumObject& enumerator, const plg::vector<T>& arrayArg) {
1485-
const auto size = static_cast<Py_ssize_t>(arrayArg.size());
1484+
const auto size = arrayArg.size();
14861485
PyObject* const arrayObject = PyList_New(size);
14871486
if (arrayObject) {
1488-
for (Py_ssize_t i = 0; i < size; ++i) {
1487+
for (size_t i = 0; i < size; ++i) {
14891488
PyObject* const valueObject = CreatePyEnumObject(enumerator, arrayArg[i]);
14901489
if (!valueObject) {
14911490
Py_DECREF(arrayObject);
14921491
return nullptr;
14931492
}
1494-
PyList_SET_ITEM(arrayObject, i, valueObject);
1493+
PyList_SET_ITEM(arrayObject, static_cast<Py_ssize_t>(i), valueObject);
14951494
}
14961495
}
14971496
return arrayObject;
@@ -2952,8 +2951,8 @@ namespace py3lm {
29522951

29532952
const auto& paramTypes = method->GetParamTypes();
29542953
const auto paramCount = paramTypes.size();
2955-
const Py_ssize_t size = PyTuple_Size(args);
2956-
if (size != static_cast<Py_ssize_t>(paramCount)) {
2954+
const size_t size = static_cast<size_t>(PyTuple_Size(args));
2955+
if (size != paramCount) {
29572956
const std::string error(std::format("Wrong number of parameters, {} when {} required.", size, paramCount));
29582957
PyErr_SetString(PyExc_TypeError, error.c_str());
29592958
ret.Set<void*>(nullptr);
@@ -2971,14 +2970,14 @@ namespace py3lm {
29712970
BeginExternalCall(retType.GetType(), a);
29722971
}
29732972

2974-
for (Py_ssize_t i = 0; i < size; ++i) {
2973+
for (size_t i = 0; i < size; ++i) {
29752974
const Property& paramType = paramTypes[i];
29762975
if (paramType.IsRef()) {
29772976
++refParamsCount;
29782977
}
29792978
using PushParamFunc = bool (*)(const Property&, PyObject*, ArgsScope&);
29802979
PushParamFunc const pushParamFunc = paramType.IsRef() ? &PushObjectAsRefParam : &PushObjectAsParam;
2981-
const bool pushResult = pushParamFunc(paramType, PyTuple_GetItem(args, i), a);
2980+
const bool pushResult = pushParamFunc(paramType, PyTuple_GetItem(args, static_cast<Py_ssize_t>(i)), a);
29822981
if (!pushResult) {
29832982
// pushParamFunc set error
29842983
ret.Set<void*>(nullptr);
@@ -3002,7 +3001,7 @@ namespace py3lm {
30023001

30033002
PyTuple_SET_ITEM(retTuple, k++, retObj); // retObj ref taken by tuple
30043003

3005-
for (Py_ssize_t i = 0, j = hasHiddenParam; i < size; ++i) {
3004+
for (size_t i = 0, j = hasHiddenParam; i < size; ++i) {
30063005
const Property& paramType = paramTypes[i];
30073006
if (!paramType.IsRef()) {
30083007
continue;
@@ -4423,9 +4422,9 @@ namespace py3lm {
44234422
}
44244423

44254424
Python3LanguageModule g_py3lm;
4425+
}
44264426

4427-
extern "C"
4428-
PY3LM_EXPORT ILanguageModule* GetLanguageModule() {
4429-
return &g_py3lm;
4430-
}
4427+
extern "C"
4428+
PY3LM_EXPORT ILanguageModule* GetLanguageModule() {
4429+
return &py3lm::g_py3lm;
44314430
}

src/module.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <map>
1616
#include <unordered_map>
1717
#include <unordered_set>
18-
#include <exception>
18+
#include <module_export.h>
1919

2020
using namespace plugify;
2121

@@ -205,3 +205,6 @@ namespace py3lm {
205205
PythonInternalEnumMap _internalEnumMap;
206206
};
207207
}
208+
209+
extern "C" PY3LM_EXPORT ILanguageModule* GetLanguageModule();
210+

0 commit comments

Comments
 (0)