diff --git a/src/API.cxx b/src/API.cxx index 7648f35e..ae286b57 100644 --- a/src/API.cxx +++ b/src/API.cxx @@ -66,7 +66,7 @@ static bool Initialize() // try again to see if the interpreter is initialized if (!Py_IsInitialized()) { // give up ... - std::cerr << "Error: python has not been intialized; returning." << std::endl; + std::cerr << "Error: python has not been initialized; returning." << std::endl; return false; } @@ -315,7 +315,7 @@ void CPyCppyy::ExecScript(const std::string& name, const std::vector= 0x03080000 -// TODO: The following is not robust and should be revisited e.g. by makeing CPPOverloads +// TODO: The following is not robust and should be revisited e.g. by making CPPOverloads // that have only CPPClassMethods be true Python classmethods? Note that the original // implementation wasn't 100% correct either (e.g. static size() mapped to len()). // diff --git a/src/CPPDataMember.cxx b/src/CPPDataMember.cxx index 5ed8cb22..bb250158 100644 --- a/src/CPPDataMember.cxx +++ b/src/CPPDataMember.cxx @@ -216,7 +216,7 @@ static void dm_dealloc(CPPDataMember* dm) static PyMemberDef dm_members[] = { {(char*)"__doc__", T_OBJECT, offsetof(CPPDataMember, fDoc), 0, (char*)"writable documentation"}, - {NULL} /* Sentinel */ + {NULL, 0, 0, 0, nullptr} /* Sentinel */ }; //= CPyCppyy datamember proxy access to internals ============================ @@ -304,6 +304,9 @@ PyTypeObject CPPDataMember_Type = { #if PY_VERSION_HEX >= 0x03040000 , 0 // tp_finalize #endif +#if PY_VERSION_HEX >= 0x03080000 + , 0 // tp_vectorcall +#endif }; } // namespace CPyCppyy diff --git a/src/CPPExcInstance.cxx b/src/CPPExcInstance.cxx index ab107486..68c366e1 100644 --- a/src/CPPExcInstance.cxx +++ b/src/CPPExcInstance.cxx @@ -29,7 +29,7 @@ static PyObject* ep_new(PyTypeObject* subtype, PyObject* args, PyObject* kwds) PyObject* ulc = PyObject_GetAttr((PyObject*)subtype, PyStrings::gUnderlying); excobj->fCppInstance = PyType_Type.tp_call(ulc, args, kwds); if (!excobj->fCppInstance) { - // if this fails, then the contruction may have been attempted from a string + // if this fails, then the construction may have been attempted from a string // (e.g. from PyErr_Format); if so, drop the proxy and use fTopMessage instead PyErr_Clear(); if (PyTuple_GET_SIZE(args) == 1) { @@ -286,6 +286,9 @@ PyTypeObject CPPExcInstance_Type = { #if PY_VERSION_HEX >= 0x03040000 , 0 // tp_finalize #endif +#if PY_VERSION_HEX >= 0x03080000 + , 0 // tp_vectorcall +#endif }; } // namespace CPyCppyy diff --git a/src/CPPInstance.cxx b/src/CPPInstance.cxx index 303ac437..9cc4f47d 100644 --- a/src/CPPInstance.cxx +++ b/src/CPPInstance.cxx @@ -1083,6 +1083,9 @@ PyTypeObject CPPInstance_Type = { #if PY_VERSION_HEX >= 0x03040000 , 0 // tp_finalize #endif +#if PY_VERSION_HEX >= 0x03080000 + , 0 // tp_vectorcall +#endif }; } // namespace CPyCppyy diff --git a/src/CPPInstance.h b/src/CPPInstance.h index aa3e4763..f61c041e 100644 --- a/src/CPPInstance.h +++ b/src/CPPInstance.h @@ -75,7 +75,7 @@ class CPPInstance { void* GetSmartObject() { return GetObjectRaw(); } Cppyy::TCppType_t GetSmartIsA() const; -// cross-inheritence dispatch +// cross-inheritance dispatch void SetDispatchPtr(void*); // redefine pointer to object as fixed-size array diff --git a/src/CPPOverload.cxx b/src/CPPOverload.cxx index 169b988d..f123b0bd 100644 --- a/src/CPPOverload.cxx +++ b/src/CPPOverload.cxx @@ -342,8 +342,15 @@ static PyObject* mp_func_closure(CPPOverload* /* pymeth */, void*) Py_RETURN_NONE; } +// To declare a variable as unused only when compiling for Python 3. +#if PY_VERSION_HEX < 0x03000000 +#define CPyCppyy_Py3_UNUSED(name) name +#else +#define CPyCppyy_Py3_UNUSED(name) +#endif + //---------------------------------------------------------------------------- -static PyObject* mp_func_code(CPPOverload* pymeth, void*) +static PyObject* mp_func_code(CPPOverload* CPyCppyy_Py3_UNUSED(pymeth), void*) { // Code details are used in module inspect to fill out interactive help() #if PY_VERSION_HEX < 0x03000000 @@ -410,7 +417,6 @@ static PyObject* mp_func_code(CPPOverload* pymeth, void*) return code; #else // not important for functioning of most code, so not implemented for p3 for now (TODO) - pymeth = 0; Py_RETURN_NONE; #endif } @@ -821,7 +827,7 @@ static CPPOverload* mp_descr_get(CPPOverload* pymeth, CPPInstance* pyobj, PyObje } // vector calls don't get here, unless a method is looked up on an instance, for -// e.g. class mathods (C++ static); notify downstream to expect a 'self' +// e.g. class methods (C++ static); notify downstream to expect a 'self' newPyMeth->fFlags |= CallContext::kFromDescr; #else @@ -1043,6 +1049,9 @@ PyTypeObject CPPOverload_Type = { #if PY_VERSION_HEX >= 0x03040000 , 0 // tp_finalize #endif +#if PY_VERSION_HEX >= 0x03080000 + , 0 // tp_vectorcall +#endif }; } // namespace CPyCppyy diff --git a/src/CPPScope.cxx b/src/CPPScope.cxx index 8d2f0f6c..0750ce6c 100644 --- a/src/CPPScope.cxx +++ b/src/CPPScope.cxx @@ -704,6 +704,9 @@ PyTypeObject CPPScope_Type = { #if PY_VERSION_HEX >= 0x03040000 , 0 // tp_finalize #endif +#if PY_VERSION_HEX >= 0x03080000 + , 0 // tp_vectorcall +#endif }; } // namespace CPyCppyy diff --git a/src/CPyCppyyModule.cxx b/src/CPyCppyyModule.cxx index 87e285f7..20b2c8fb 100644 --- a/src/CPyCppyyModule.cxx +++ b/src/CPyCppyyModule.cxx @@ -158,6 +158,9 @@ static PyTypeObject PyNullPtr_t_Type = { #if PY_VERSION_HEX >= 0x03040000 , 0 // tp_finalize #endif +#if PY_VERSION_HEX >= 0x03080000 + , 0 // tp_vectorcall +#endif }; @@ -192,6 +195,9 @@ static PyTypeObject PyDefault_t_Type = { #if PY_VERSION_HEX >= 0x03040000 , 0 // tp_finalize #endif +#if PY_VERSION_HEX >= 0x03080000 + , 0 // tp_vectorcall +#endif }; namespace { @@ -206,7 +212,7 @@ PyObject _CPyCppyy_DefaultStruct = { 1, &PyDefault_t_Type }; -// TOOD: refactor with Converters.cxx +// TODO: refactor with Converters.cxx struct CPyCppyy_tagCDataObject { // non-public (but stable) PyObject_HEAD char* b_ptr; @@ -477,7 +483,7 @@ static void* GetCPPInstanceAddress(const char* fname, PyObject* args, PyObject* return &((CPPInstance*)pyobj)->GetObjectRaw(); } else if (CPyCppyy_PyText_Check(pyobj)) { - // special cases for acces to the CPyCppyy API + // special cases for access to the CPyCppyy API std::string req = CPyCppyy_PyText_AsString((PyObject*)pyobj); if (req == "Instance_AsVoidPtr") return (void*)&Instance_AsVoidPtr; @@ -516,8 +522,8 @@ static PyObject* addressof(PyObject* /* dummy */, PyObject* args, PyObject* kwds return nullptr; } - Cppyy::TCppFuncAddr_t addr = methods[0]->GetFunctionAddress(); - return PyLong_FromLongLong((intptr_t)addr); + Cppyy::TCppFuncAddr_t caddr = methods[0]->GetFunctionAddress(); + return PyLong_FromLongLong((intptr_t)caddr); } // C functions (incl. ourselves) @@ -1054,7 +1060,7 @@ extern "C" void initlibcppyy() #endif #if PY_VERSION_HEX < 0x030b0000 -// prepare for lazyness (the insert is needed to capture the most generic lookup +// prepare for laziness (the insert is needed to capture the most generic lookup // function, just in case ...) PyObject* dict = PyDict_New(); PyObject* notstring = PyInt_FromLong(5); diff --git a/src/CallContext.h b/src/CallContext.h index 597970cb..3ea8f65c 100644 --- a/src/CallContext.h +++ b/src/CallContext.h @@ -58,7 +58,7 @@ struct CallContext { kIsCreator = 0x000002, // if method creates python-owned objects kIsConstructor = 0x000004, // if method is a C++ constructor kHaveImplicit = 0x000008, // indicate that implicit converters are available - kAllowImplicit = 0x000010, // indicate that implicit coversions are allowed + kAllowImplicit = 0x000010, // indicate that implicit conversions are allowed kNoImplicit = 0x000020, // disable implicit to prevent recursion kCallDirect = 0x000040, // call wrapped method directly, no inheritance kFromDescr = 0x000080, // initiated from a descriptor diff --git a/src/Converters.cxx b/src/Converters.cxx index 6acf878c..602e3c92 100644 --- a/src/Converters.cxx +++ b/src/Converters.cxx @@ -1234,7 +1234,7 @@ bool CPyCppyy::CStringConverter::SetArg( // use internal buffer as workaround fBuffer = std::string(cstr, len); if (fMaxSize != std::string::npos) - fBuffer.resize(fMaxSize, '\0'); // padd remainder of buffer as needed + fBuffer.resize(fMaxSize, '\0'); // pad remainder of buffer as needed cstr = fBuffer.c_str(); } else SetLifeLine(ctxt->fPyContext, pyobject, (intptr_t)this); @@ -1297,7 +1297,7 @@ bool CPyCppyy::CStringConverter::ToMemory(PyObject* value, void* address, PyObje // the pointer value is non-zero and not ours: assume byte copy if (fMaxSize != std::string::npos) - strncpy(*(char**)address, cstr, fMaxSize); // padds remainder + strncpy(*(char**)address, cstr, fMaxSize); // pads remainder else // coverity[secure_coding] - can't help it, it's intentional. strcpy(*(char**)address, cstr); @@ -2512,7 +2512,7 @@ static PyObject* WrapperCacheEraser(PyObject*, PyObject* pyref) Py_RETURN_NONE; } static PyMethodDef gWrapperCacheEraserMethodDef = { - const_cast("interal_WrapperCacheEraser"), + const_cast("internal_WrapperCacheEraser"), (PyCFunction)WrapperCacheEraser, METH_O, nullptr }; @@ -2612,7 +2612,7 @@ static void* PyFunction_AsCPointer(PyObject* pyobject, // start function body Utility::ConstructCallbackPreamble(rettype, argtypes, code); - // create a referencable pointer + // create a referenceable pointer PyObject** ref = new PyObject*{pyobject}; // function call itself and cleanup diff --git a/src/CustomPyTypes.cxx b/src/CustomPyTypes.cxx index 592deed3..69621b5c 100644 --- a/src/CustomPyTypes.cxx +++ b/src/CustomPyTypes.cxx @@ -164,6 +164,9 @@ PyTypeObject TypedefPointerToClass_Type = { #if PY_VERSION_HEX >= 0x03040000 , 0 // tp_finalize #endif +#if PY_VERSION_HEX >= 0x03080000 + , 0 // tp_vectorcall +#endif }; //= instancemethod object with a more efficient call function ================ @@ -329,6 +332,9 @@ PyTypeObject CustomInstanceMethod_Type = { #if PY_VERSION_HEX >= 0x03040000 , 0 // tp_finalize #endif +#if PY_VERSION_HEX >= 0x03080000 + , 0 // tp_vectorcall +#endif }; @@ -380,6 +386,9 @@ PyTypeObject IndexIter_Type = { #if PY_VERSION_HEX >= 0x03040000 , 0 // tp_finalize #endif +#if PY_VERSION_HEX >= 0x03080000 + , 0 // tp_vectorcall +#endif }; @@ -439,6 +448,9 @@ PyTypeObject VectorIter_Type = { #if PY_VERSION_HEX >= 0x03040000 , 0 // tp_finalize #endif +#if PY_VERSION_HEX >= 0x03080000 + , 0 // tp_vectorcall +#endif }; } // namespace CPyCppyy diff --git a/src/Executors.cxx b/src/Executors.cxx index b853fdd5..7354146a 100644 --- a/src/Executors.cxx +++ b/src/Executors.cxx @@ -1074,9 +1074,9 @@ struct InitExecFactories_t { gf[CCOMPLEX_D " ptr"] = gf["std::complex ptr"]; // factories for special cases - gf["const char*"] = (ef_t)+[]() { static CStringExecutor e{}; return &e; }; + gf["const char*"] = (ef_t)+[](cdims_t) { static CStringExecutor e{}; return &e; }; gf["char*"] = gf["const char*"]; - gf["const char*&"] = (ef_t)+[]() { static CStringRefExecutor e{}; return &e; }; + gf["const char*&"] = (ef_t)+[](cdims_t) { static CStringRefExecutor e{}; return &e; }; gf["char*&"] = gf["const char*&"]; gf["const signed char*"] = gf["const char*"]; gf["signed char*"] = gf["char*"]; diff --git a/src/LowLevelViews.cxx b/src/LowLevelViews.cxx index bf5c7a03..028873c3 100644 --- a/src/LowLevelViews.cxx +++ b/src/LowLevelViews.cxx @@ -247,14 +247,14 @@ static char* lookup_dimension(Py_buffer& view, char* ptr, int dim, Py_ssize_t in index += nitems; else { PyErr_Format(PyExc_IndexError, - "negative index not supporte on dimension %d with unknown size", dim + 1); + "negative index not supported on dimension %d with unknown size", dim + 1); return nullptr; } } if (view.strides[dim] == CPyCppyy::UNKNOWN_SIZE) { PyErr_Format(PyExc_IndexError, - "multi index not supporte on dimension %d with unknown stride", dim + 1); + "multi index not supported on dimension %d with unknown stride", dim + 1); return nullptr; } @@ -953,6 +953,9 @@ PyTypeObject LowLevelView_Type = { #if PY_VERSION_HEX >= 0x03040000 , 0 // tp_finalize #endif +#if PY_VERSION_HEX >= 0x03080000 + , 0 // tp_vectorcall +#endif }; } // namespace CPyCppyy diff --git a/src/MemoryRegulator.cxx b/src/MemoryRegulator.cxx index 39780aba..37cc394a 100644 --- a/src/MemoryRegulator.cxx +++ b/src/MemoryRegulator.cxx @@ -99,7 +99,7 @@ CPyCppyy::MemoryRegulator::MemoryRegulator() bool CPyCppyy::MemoryRegulator::RecursiveRemove( Cppyy::TCppObject_t cppobj, Cppyy::TCppType_t klass) { -// if registerd by the framework, called whenever a cppobj gets destroyed +// if registered by the framework, called whenever a cppobj gets destroyed if (!cppobj) return false; diff --git a/src/ProxyWrappers.cxx b/src/ProxyWrappers.cxx index 0fbe70ae..80133771 100644 --- a/src/ProxyWrappers.cxx +++ b/src/ProxyWrappers.cxx @@ -579,7 +579,7 @@ PyObject* CPyCppyy::CreateScopeProxy(const std::string& name, PyObject* parent, } if (!(bool)klass) { - // could be an enum, which are treated seperately in CPPScope (TODO: maybe they + // could be an enum, which are treated separately in CPPScope (TODO: maybe they // should be handled here instead anyway??) if (Cppyy::IsEnum(lookup)) return nullptr; diff --git a/src/Pythonize.cxx b/src/Pythonize.cxx index 1f7ac07e..2b21b9f7 100644 --- a/src/Pythonize.cxx +++ b/src/Pythonize.cxx @@ -824,7 +824,7 @@ static PyObject* MapFromPairs(PyObject* self, PyObject* pairs) PyObject* MapInit(PyObject* self, PyObject* args, PyObject* /* kwds */) { // Specialized map constructor to allow construction from mapping containers and -// from tuples of pairs ("intializer_list style"). +// from tuples of pairs ("initializer_list style"). // PyMapping_Check is not very discriminatory, as it basically only checks for the // existence of __getitem__, hence the most common cases of tuple and list are @@ -1026,7 +1026,7 @@ PyObject* CheckedGetItem(PyObject* self, PyObject* obj) { // Implement a generic python __getitem__ for STL-like classes that are missing the // reflection info for their iterators. This is then used for iteration by means of -// consecutive indeces, it such index is of integer type. +// consecutive indices, it such index is of integer type. Py_ssize_t size = PySequence_Size(self); Py_ssize_t idx = PyInt_AsSsize_t(obj); if ((size == (Py_ssize_t)-1 || idx == (Py_ssize_t)-1) && PyErr_Occurred()) { @@ -1653,7 +1653,7 @@ bool CPyCppyy::Pythonize(PyObject* pyclass, const std::string& name) // Python will iterate over __getitem__ using integers, but C++ operator[] will never raise // a StopIteration. A checked getitem (raising IndexError if beyond size()) works in some // cases but would mess up if operator[] is meant to implement an associative container. So, - // this has to be implemented as an interator protocol. + // this has to be implemented as an iterator protocol. ((PyTypeObject*)pyclass)->tp_iter = (getiterfunc)index_iter; Utility::AddToClass(pyclass, "__iter__", (PyCFunction)index_iter, METH_NOARGS); } diff --git a/src/TemplateProxy.cxx b/src/TemplateProxy.cxx index e014a8dd..a80a0ef1 100644 --- a/src/TemplateProxy.cxx +++ b/src/TemplateProxy.cxx @@ -957,6 +957,9 @@ PyTypeObject TemplateProxy_Type = { #if PY_VERSION_HEX >= 0x03040000 , 0 // tp_finalize #endif +#if PY_VERSION_HEX >= 0x03080000 + , 0 // tp_vectorcall +#endif }; } // namespace CPyCppyy diff --git a/src/TupleOfInstances.cxx b/src/TupleOfInstances.cxx index 1744f32a..2f8e6c93 100644 --- a/src/TupleOfInstances.cxx +++ b/src/TupleOfInstances.cxx @@ -114,6 +114,9 @@ PyTypeObject InstanceArrayIter_Type = { #if PY_VERSION_HEX >= 0x03040000 , 0 // tp_finalize #endif +#if PY_VERSION_HEX >= 0x03080000 + , 0 // tp_vectorcall +#endif }; @@ -242,6 +245,9 @@ PyTypeObject TupleOfInstances_Type = { #if PY_VERSION_HEX >= 0x03040000 , 0 // tp_finalize #endif +#if PY_VERSION_HEX >= 0x03080000 + , 0 // tp_vectorcall +#endif }; } // namespace CPyCppyy diff --git a/src/TypeManip.cxx b/src/TypeManip.cxx index 59d2e2b0..3a979ddc 100644 --- a/src/TypeManip.cxx +++ b/src/TypeManip.cxx @@ -164,7 +164,7 @@ std::string CPyCppyy::TypeManip::compound(const std::string& name) // for easy identification of fixed size arrays if (!cpd.empty() && cpd.back() == ']') { if (cpd.front() == '[') - return "[]"; // fixed array any; dimensions handled seperately + return "[]"; // fixed array any; dimensions handled separately std::ostringstream scpd; scpd << cpd.substr(0, cpd.find('[')) << "[]"; @@ -260,7 +260,7 @@ std::vector CPyCppyy::TypeManip::extract_arg_types(const std::strin //---------------------------------------------------------------------------- Py_ssize_t CPyCppyy::TypeManip::array_size(const std::string& name) { -// Extrac the array size from a given type name (assumes 1D arrays) +// Extract the array size from a given type name (assumes 1D arrays) std::string cleanName = remove_const(name); if (cleanName[cleanName.size()-1] == ']') { std::string::size_type idx = cleanName.rfind('['); diff --git a/src/Utility.cxx b/src/Utility.cxx index f7bb7d87..49415f10 100644 --- a/src/Utility.cxx +++ b/src/Utility.cxx @@ -599,7 +599,7 @@ std::string CPyCppyy::Utility::ConstructTemplateArgs( PyObject* tn = justOne ? tpArgs : PyTuple_GET_ITEM(tpArgs, i); if (CPyCppyy_PyText_Check(tn)) { tmpl_name.append(CPyCppyy_PyText_AsString(tn)); - // some commmon numeric types (separated out for performance: checking for + // some common numeric types (separated out for performance: checking for // __cpp_name__ and/or __name__ is rather expensive) } else { if (!AddTypeName(tmpl_name, tn, (args ? PyTuple_GET_ITEM(args, i) : nullptr), pref, pcnt)) {