Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/API.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -315,7 +315,7 @@ void CPyCppyy::ExecScript(const std::string& name, const std::vector<std::string
oldargv = l;
}

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

// results that require no convserion
// results that require no conversion
if (result == Py_None || CPPInstance_Check(result) ||
PyBytes_Check(result) ||
PyFloat_Check(result) || PyLong_Check(result) || PyInt_Check(result))
Expand Down
2 changes: 1 addition & 1 deletion src/CPPClassMethod.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ PyObject* CPyCppyy::CPPClassMethod::Call(CPPInstance*&

// translate the arguments
#if PY_VERSION_HEX >= 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()).
//
Expand Down
5 changes: 4 additions & 1 deletion src/CPPDataMember.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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 ============================
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/CPPExcInstance.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
3 changes: 3 additions & 0 deletions src/CPPInstance.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/CPPInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 12 additions & 3 deletions src/CPPOverload.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/CPPScope.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 11 additions & 5 deletions src/CPyCppyyModule.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
};


Expand Down Expand Up @@ -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 {
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/CallContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/Converters.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -2512,7 +2512,7 @@ static PyObject* WrapperCacheEraser(PyObject*, PyObject* pyref)
Py_RETURN_NONE;
}
static PyMethodDef gWrapperCacheEraserMethodDef = {
const_cast<char*>("interal_WrapperCacheEraser"),
const_cast<char*>("internal_WrapperCacheEraser"),
(PyCFunction)WrapperCacheEraser,
METH_O, nullptr
};
Expand Down Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions src/CustomPyTypes.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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 ================
Expand Down Expand Up @@ -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
};


Expand Down Expand Up @@ -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
};


Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions src/Executors.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1074,9 +1074,9 @@ struct InitExecFactories_t {
gf[CCOMPLEX_D " ptr"] = gf["std::complex<double> 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*"];
Expand Down
7 changes: 5 additions & 2 deletions src/LowLevelViews.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/MemoryRegulator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/ProxyWrappers.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/Pythonize.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 3 additions & 0 deletions src/TemplateProxy.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading