Skip to content

Commit 63c1d53

Browse files
authored
Merge pull request #19 from guitargeek/warnings
Fix incomplete initializer lists, unused vars, and some type warnings
2 parents 30bff9d + 92949da commit 63c1d53

21 files changed

+83
-32
lines changed

src/API.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static bool Initialize()
6666
// try again to see if the interpreter is initialized
6767
if (!Py_IsInitialized()) {
6868
// give up ...
69-
std::cerr << "Error: python has not been intialized; returning." << std::endl;
69+
std::cerr << "Error: python has not been initialized; returning." << std::endl;
7070
return false;
7171
}
7272

@@ -315,7 +315,7 @@ void CPyCppyy::ExecScript(const std::string& name, const std::vector<std::string
315315
oldargv = l;
316316
}
317317

318-
// create and set (add progam name) the new command line
318+
// create and set (add program name) the new command line
319319
#if PY_VERSION_HEX < 0x03000000
320320
int argc = args.size() + 1;
321321
const char** argv = new const char*[argc];
@@ -386,7 +386,7 @@ const CPyCppyy::PyResult CPyCppyy::Eval(const std::string& expr)
386386
return PyResult();
387387
}
388388

389-
// results that require no convserion
389+
// results that require no conversion
390390
if (result == Py_None || CPPInstance_Check(result) ||
391391
PyBytes_Check(result) ||
392392
PyFloat_Check(result) || PyLong_Check(result) || PyInt_Check(result))

src/CPPClassMethod.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ PyObject* CPyCppyy::CPPClassMethod::Call(CPPInstance*&
2424

2525
// translate the arguments
2626
#if PY_VERSION_HEX >= 0x03080000
27-
// TODO: The following is not robust and should be revisited e.g. by makeing CPPOverloads
27+
// TODO: The following is not robust and should be revisited e.g. by making CPPOverloads
2828
// that have only CPPClassMethods be true Python classmethods? Note that the original
2929
// implementation wasn't 100% correct either (e.g. static size() mapped to len()).
3030
//

src/CPPDataMember.cxx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ static void dm_dealloc(CPPDataMember* dm)
216216
static PyMemberDef dm_members[] = {
217217
{(char*)"__doc__", T_OBJECT, offsetof(CPPDataMember, fDoc), 0,
218218
(char*)"writable documentation"},
219-
{NULL} /* Sentinel */
219+
{NULL, 0, 0, 0, nullptr} /* Sentinel */
220220
};
221221

222222
//= CPyCppyy datamember proxy access to internals ============================
@@ -304,6 +304,9 @@ PyTypeObject CPPDataMember_Type = {
304304
#if PY_VERSION_HEX >= 0x03040000
305305
, 0 // tp_finalize
306306
#endif
307+
#if PY_VERSION_HEX >= 0x03080000
308+
, 0 // tp_vectorcall
309+
#endif
307310
};
308311

309312
} // namespace CPyCppyy

src/CPPExcInstance.cxx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static PyObject* ep_new(PyTypeObject* subtype, PyObject* args, PyObject* kwds)
2929
PyObject* ulc = PyObject_GetAttr((PyObject*)subtype, PyStrings::gUnderlying);
3030
excobj->fCppInstance = PyType_Type.tp_call(ulc, args, kwds);
3131
if (!excobj->fCppInstance) {
32-
// if this fails, then the contruction may have been attempted from a string
32+
// if this fails, then the construction may have been attempted from a string
3333
// (e.g. from PyErr_Format); if so, drop the proxy and use fTopMessage instead
3434
PyErr_Clear();
3535
if (PyTuple_GET_SIZE(args) == 1) {
@@ -286,6 +286,9 @@ PyTypeObject CPPExcInstance_Type = {
286286
#if PY_VERSION_HEX >= 0x03040000
287287
, 0 // tp_finalize
288288
#endif
289+
#if PY_VERSION_HEX >= 0x03080000
290+
, 0 // tp_vectorcall
291+
#endif
289292
};
290293

291294
} // namespace CPyCppyy

src/CPPInstance.cxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,9 @@ PyTypeObject CPPInstance_Type = {
10831083
#if PY_VERSION_HEX >= 0x03040000
10841084
, 0 // tp_finalize
10851085
#endif
1086+
#if PY_VERSION_HEX >= 0x03080000
1087+
, 0 // tp_vectorcall
1088+
#endif
10861089
};
10871090

10881091
} // namespace CPyCppyy

src/CPPInstance.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class CPPInstance {
7575
void* GetSmartObject() { return GetObjectRaw(); }
7676
Cppyy::TCppType_t GetSmartIsA() const;
7777

78-
// cross-inheritence dispatch
78+
// cross-inheritance dispatch
7979
void SetDispatchPtr(void*);
8080

8181
// redefine pointer to object as fixed-size array

src/CPPOverload.cxx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,15 @@ static PyObject* mp_func_closure(CPPOverload* /* pymeth */, void*)
342342
Py_RETURN_NONE;
343343
}
344344

345+
// To declare a variable as unused only when compiling for Python 3.
346+
#if PY_VERSION_HEX < 0x03000000
347+
#define CPyCppyy_Py3_UNUSED(name) name
348+
#else
349+
#define CPyCppyy_Py3_UNUSED(name)
350+
#endif
351+
345352
//----------------------------------------------------------------------------
346-
static PyObject* mp_func_code(CPPOverload* pymeth, void*)
353+
static PyObject* mp_func_code(CPPOverload* CPyCppyy_Py3_UNUSED(pymeth), void*)
347354
{
348355
// Code details are used in module inspect to fill out interactive help()
349356
#if PY_VERSION_HEX < 0x03000000
@@ -410,7 +417,6 @@ static PyObject* mp_func_code(CPPOverload* pymeth, void*)
410417
return code;
411418
#else
412419
// not important for functioning of most code, so not implemented for p3 for now (TODO)
413-
pymeth = 0;
414420
Py_RETURN_NONE;
415421
#endif
416422
}
@@ -821,7 +827,7 @@ static CPPOverload* mp_descr_get(CPPOverload* pymeth, CPPInstance* pyobj, PyObje
821827
}
822828

823829
// vector calls don't get here, unless a method is looked up on an instance, for
824-
// e.g. class mathods (C++ static); notify downstream to expect a 'self'
830+
// e.g. class methods (C++ static); notify downstream to expect a 'self'
825831
newPyMeth->fFlags |= CallContext::kFromDescr;
826832

827833
#else
@@ -1043,6 +1049,9 @@ PyTypeObject CPPOverload_Type = {
10431049
#if PY_VERSION_HEX >= 0x03040000
10441050
, 0 // tp_finalize
10451051
#endif
1052+
#if PY_VERSION_HEX >= 0x03080000
1053+
, 0 // tp_vectorcall
1054+
#endif
10461055
};
10471056

10481057
} // namespace CPyCppyy

src/CPPScope.cxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,9 @@ PyTypeObject CPPScope_Type = {
704704
#if PY_VERSION_HEX >= 0x03040000
705705
, 0 // tp_finalize
706706
#endif
707+
#if PY_VERSION_HEX >= 0x03080000
708+
, 0 // tp_vectorcall
709+
#endif
707710
};
708711

709712
} // namespace CPyCppyy

src/CPyCppyyModule.cxx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ static PyTypeObject PyNullPtr_t_Type = {
158158
#if PY_VERSION_HEX >= 0x03040000
159159
, 0 // tp_finalize
160160
#endif
161+
#if PY_VERSION_HEX >= 0x03080000
162+
, 0 // tp_vectorcall
163+
#endif
161164
};
162165

163166

@@ -192,6 +195,9 @@ static PyTypeObject PyDefault_t_Type = {
192195
#if PY_VERSION_HEX >= 0x03040000
193196
, 0 // tp_finalize
194197
#endif
198+
#if PY_VERSION_HEX >= 0x03080000
199+
, 0 // tp_vectorcall
200+
#endif
195201
};
196202

197203
namespace {
@@ -206,7 +212,7 @@ PyObject _CPyCppyy_DefaultStruct = {
206212
1, &PyDefault_t_Type
207213
};
208214

209-
// TOOD: refactor with Converters.cxx
215+
// TODO: refactor with Converters.cxx
210216
struct CPyCppyy_tagCDataObject { // non-public (but stable)
211217
PyObject_HEAD
212218
char* b_ptr;
@@ -477,7 +483,7 @@ static void* GetCPPInstanceAddress(const char* fname, PyObject* args, PyObject*
477483
return &((CPPInstance*)pyobj)->GetObjectRaw();
478484

479485
} else if (CPyCppyy_PyText_Check(pyobj)) {
480-
// special cases for acces to the CPyCppyy API
486+
// special cases for access to the CPyCppyy API
481487
std::string req = CPyCppyy_PyText_AsString((PyObject*)pyobj);
482488
if (req == "Instance_AsVoidPtr")
483489
return (void*)&Instance_AsVoidPtr;
@@ -516,8 +522,8 @@ static PyObject* addressof(PyObject* /* dummy */, PyObject* args, PyObject* kwds
516522
return nullptr;
517523
}
518524

519-
Cppyy::TCppFuncAddr_t addr = methods[0]->GetFunctionAddress();
520-
return PyLong_FromLongLong((intptr_t)addr);
525+
Cppyy::TCppFuncAddr_t caddr = methods[0]->GetFunctionAddress();
526+
return PyLong_FromLongLong((intptr_t)caddr);
521527
}
522528

523529
// C functions (incl. ourselves)
@@ -1054,7 +1060,7 @@ extern "C" void initlibcppyy()
10541060
#endif
10551061

10561062
#if PY_VERSION_HEX < 0x030b0000
1057-
// prepare for lazyness (the insert is needed to capture the most generic lookup
1063+
// prepare for laziness (the insert is needed to capture the most generic lookup
10581064
// function, just in case ...)
10591065
PyObject* dict = PyDict_New();
10601066
PyObject* notstring = PyInt_FromLong(5);

src/CallContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ struct CallContext {
5858
kIsCreator = 0x000002, // if method creates python-owned objects
5959
kIsConstructor = 0x000004, // if method is a C++ constructor
6060
kHaveImplicit = 0x000008, // indicate that implicit converters are available
61-
kAllowImplicit = 0x000010, // indicate that implicit coversions are allowed
61+
kAllowImplicit = 0x000010, // indicate that implicit conversions are allowed
6262
kNoImplicit = 0x000020, // disable implicit to prevent recursion
6363
kCallDirect = 0x000040, // call wrapped method directly, no inheritance
6464
kFromDescr = 0x000080, // initiated from a descriptor

0 commit comments

Comments
 (0)