py3: fox compiler warnings

issue 0000995
This commit is contained in:
wmayer
2017-06-04 00:17:57 +02:00
parent 2ec941ae25
commit 729cfd8155
11 changed files with 87 additions and 22 deletions

View File

@@ -221,7 +221,12 @@ Application::Application(std::map<std::string,std::string> &mConfig)
// setting up Python binding
Base::PyGILStateLocker lock;
#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef FreeCADModuleDef = {PyModuleDef_HEAD_INIT,"FreeCAD", FreeCAD_doc, -1, Application::Methods};
static struct PyModuleDef FreeCADModuleDef = {
PyModuleDef_HEAD_INIT,
"FreeCAD", FreeCAD_doc, -1,
Application::Methods,
NULL, NULL, NULL, NULL
};
PyObject* pAppModule = PyModule_Create(&FreeCADModuleDef);
_PyImport_FixupBuiltin(pAppModule, "FreeCAD");
#else
@@ -230,7 +235,12 @@ Application::Application(std::map<std::string,std::string> &mConfig)
Py::Module(pAppModule).setAttr(std::string("ActiveDocument"),Py::None());
#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef ConsoleModuleDef = {PyModuleDef_HEAD_INIT, "__FreeCADConsole__", Console_doc, -1, ConsoleSingleton::Methods};
static struct PyModuleDef ConsoleModuleDef = {
PyModuleDef_HEAD_INIT,
"__FreeCADConsole__", Console_doc, -1,
ConsoleSingleton::Methods,
NULL, NULL, NULL, NULL
};
PyObject* pConsoleModule = PyModule_Create(&ConsoleModuleDef);
#else
PyObject* pConsoleModule = Py_InitModule3("__FreeCADConsole__", ConsoleSingleton::Methods, Console_doc);
@@ -253,7 +263,11 @@ Application::Application(std::map<std::string,std::string> &mConfig)
// remove these types from the FreeCAD module.
#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef BaseModuleDef = {PyModuleDef_HEAD_INIT, "__FreeCADBase__", Base_doc, -1, NULL};
static struct PyModuleDef BaseModuleDef = {
PyModuleDef_HEAD_INIT,
"__FreeCADBase__", Base_doc, -1,
NULL, NULL, NULL, NULL, NULL
};
PyObject* pBaseModule = PyModule_Create(&BaseModuleDef);
#else
PyObject* pBaseModule = Py_InitModule3("__FreeCADBase__", NULL, Base_doc);
@@ -280,7 +294,12 @@ Application::Application(std::map<std::string,std::string> &mConfig)
//insert Units module
#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef UnitsModuleDef = {PyModuleDef_HEAD_INIT, "Units", "The Unit API", -1, Base::UnitsApi::Methods};
static struct PyModuleDef UnitsModuleDef = {
PyModuleDef_HEAD_INIT,
"Units", "The Unit API", -1,
Base::UnitsApi::Methods,
NULL, NULL, NULL, NULL
};
PyObject* pUnitsModule = PyModule_Create(&UnitsModuleDef);
#else
PyObject* pUnitsModule = Py_InitModule3("Units", Base::UnitsApi::Methods,"The Unit API");

View File

@@ -48,7 +48,7 @@
""#_class_"", \
0, 0, 0, 0, 0, 0, 0, 0, 0, \
&_subclass_::Type, \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 \
}; \
_class_::_class_(Base::BaseClass *pcObject, PyTypeObject *T) \
: _subclass_(reinterpret_cast<_subclass_::PointerType>(pcObject), T) \

View File

@@ -790,6 +790,8 @@ PyObject* InterpreterSingleton::createSWIGPointerObj(const char* Module, const c
result = Swig_1_3_40::createSWIGPointerObj_T(TypeName, Pointer, &proxy, own);
break;
default:
#else
(void)Module;
#endif
#if (defined(HAVE_SWIG) && (HAVE_SWIG == 1))
result = Swig_python::createSWIGPointerObj_T(TypeName, Pointer, &proxy, own);
@@ -842,6 +844,8 @@ bool InterpreterSingleton::convertSWIGPointerObj(const char* Module, const char*
result = Swig_1_3_40::convertSWIGPointerObj_T(TypeName, obj, ptr, flags);
break;
default:
#else
(void)Module;
#endif
#if (defined(HAVE_SWIG) && (HAVE_SWIG == 1))
result = Swig_python::convertSWIGPointerObj_T(TypeName, obj, ptr, flags);

View File

@@ -28,6 +28,9 @@
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated-register"
#elif defined (__GNUC__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#endif
namespace Swig_python {
#define SWIG_PYTHON_NO_BUILD_NONE
@@ -36,6 +39,8 @@ namespace Swig_python {
}
#if defined(__clang__)
# pragma clang diagnostic pop
#elif defined (__GNUC__)
# pragma GCC diagnostic pop
#endif
#endif // HAVE_SWIG

View File

@@ -187,7 +187,7 @@ namespace Py
: public PythonExtensionBase
{
protected:
explicit PythonClass( PythonClassInstance *self, Tuple &args, Dict &kwds )
explicit PythonClass( PythonClassInstance *self, Tuple &/*args*/, Dict &/*kwds*/ )
: PythonExtensionBase()
, m_class_instance( self )
{
@@ -235,7 +235,7 @@ namespace Py
return *p;
}
static PyObject *extension_object_new( PyTypeObject *subtype, PyObject *args, PyObject *kwds )
static PyObject *extension_object_new( PyTypeObject *subtype, PyObject * /*args*/, PyObject * /*kwds*/ )
{
#ifdef PYCXX_DEBUG
std::cout << "extension_object_new()" << std::endl;

View File

@@ -1487,7 +1487,7 @@ int PythonExtensionBase::buffer_get( Py_buffer * /* buf */, int /* flags */ )
return -1;
}
int PythonExtensionBase::buffer_release( Py_buffer *buf )
int PythonExtensionBase::buffer_release( Py_buffer * /*buf*/ )
{
/* This method is optional and only required if the buffer's
memory is dynamic. */

View File

@@ -302,7 +302,12 @@ Application::Application(bool GUIenabled)
// otherwise the executable was launched
PyObject *module = PyImport_AddModule("FreeCADGui");
if (!module) {
static struct PyModuleDef FreeCADGuiModuleDef = {PyModuleDef_HEAD_INIT,"FreeCADGui", FreeCADGui_doc, -1, Application::Methods};
static struct PyModuleDef FreeCADGuiModuleDef = {
PyModuleDef_HEAD_INIT,
"FreeCADGui", FreeCADGui_doc, -1,
Application::Methods,
NULL, NULL, NULL, NULL
};
module = PyModule_Create(&FreeCADGuiModuleDef);
_PyImport_FixupBuiltin(module, "FreeCADGui");
}
@@ -327,7 +332,12 @@ Application::Application(bool GUIenabled)
//insert Selection module
#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef SelectionModuleDef = {PyModuleDef_HEAD_INIT,"Selection", "Selection module", -1, SelectionSingleton::Methods};
static struct PyModuleDef SelectionModuleDef = {
PyModuleDef_HEAD_INIT,
"Selection", "Selection module", -1,
SelectionSingleton::Methods,
NULL, NULL, NULL, NULL
};
PyObject* pSelectionModule = PyModule_Create(&SelectionModuleDef);
#else
PyObject* pSelectionModule = Py_InitModule3("Selection", SelectionSingleton::Methods,"Selection module");

View File

@@ -79,11 +79,13 @@ Py::Object PythonStdout::write(const Py::Tuple& args)
try {
Py::Object output(args[0]);
if (PyUnicode_Check(output.ptr())) {
PyObject* unicode = PyUnicode_AsEncodedObject(output.ptr(), "utf-8", "strict");
if (unicode) {
#if PY_MAJOR_VERSION >= 3
PyObject* unicode = PyUnicode_AsEncodedString(output.ptr(), "utf-8", 0);
if (unicode) {
const char* string = PyBytes_AsString(unicode);
#else
PyObject* unicode = PyUnicode_AsEncodedObject(output.ptr(), "utf-8", "strict");
if (unicode) {
const char* string = PyString_AsString(unicode);
#endif
int maxlen = qstrlen(string) > 10000 ? 10000 : -1;
@@ -154,11 +156,13 @@ Py::Object PythonStderr::write(const Py::Tuple& args)
try {
Py::Object output(args[0]);
if (PyUnicode_Check(output.ptr())) {
PyObject* unicode = PyUnicode_AsEncodedObject(output.ptr(), "utf-8", "strict");
if (unicode) {
#if PY_MAJOR_VERSION >= 3
PyObject* unicode = PyUnicode_AsEncodedString(output.ptr(), "utf-8", 0);
if (unicode) {
const char* string = PyBytes_AsString(unicode);
#else
PyObject* unicode = PyUnicode_AsEncodedObject(output.ptr(), "utf-8", "strict");
if (unicode) {
const char* string = PyString_AsString(unicode);
#endif
int maxlen = qstrlen(string) > 10000 ? 10000 : -1;
@@ -228,11 +232,13 @@ Py::Object OutputStdout::write(const Py::Tuple& args)
try {
Py::Object output(args[0]);
if (PyUnicode_Check(output.ptr())) {
PyObject* unicode = PyUnicode_AsEncodedObject(output.ptr(), "utf-8", "strict");
if (unicode) {
#if PY_MAJOR_VERSION >= 3
PyObject* unicode = PyUnicode_AsEncodedString(output.ptr(), "utf-8", 0);
if (unicode) {
const char* string = PyBytes_AsString(unicode);
#else
PyObject* unicode = PyUnicode_AsEncodedObject(output.ptr(), "utf-8", "strict");
if (unicode) {
const char* string = PyString_AsString(unicode);
#endif
Base::Console().Message("%s",string);
@@ -300,11 +306,13 @@ Py::Object OutputStderr::write(const Py::Tuple& args)
try {
Py::Object output(args[0]);
if (PyUnicode_Check(output.ptr())) {
PyObject* unicode = PyUnicode_AsEncodedObject(output.ptr(), "utf-8", "strict");
if (unicode) {
#if PY_MAJOR_VERSION >= 3
PyObject* unicode = PyUnicode_AsEncodedString(output.ptr(), "utf-8", 0);
if (unicode) {
const char* string = PyBytes_AsString(unicode);
#else
PyObject* unicode = PyUnicode_AsEncodedObject(output.ptr(), "utf-8", "strict");
if (unicode) {
const char* string = PyString_AsString(unicode);
#endif
Base::Console().Error("%s",string);

View File

@@ -328,7 +328,12 @@ PyMOD_INIT_FUNC(FreeCADGui)
App::Application::Config()["CopyrightInfo"] = "\xc2\xa9 Juergen Riegel, Werner Mayer, Yorik van Havre 2001-2017\n";
Gui::Application::initApplication();
#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef FreeCADGuiModuleDef = {PyModuleDef_HEAD_INIT,"FreeCADGui", "FreeCAD GUI module\n", -1, FreeCADGui_methods};
static struct PyModuleDef FreeCADGuiModuleDef = {
PyModuleDef_HEAD_INIT,
"FreeCADGui", "FreeCAD GUI module\n", -1,
FreeCADGui_methods,
NULL, NULL, NULL, NULL
};
PyObject* module = PyModule_Create(&FreeCADGuiModuleDef);
return module;
#else

View File

@@ -348,7 +348,11 @@ PyMOD_INIT_FUNC(Part)
Base::Interpreter().addType(&Attacher::AttachEnginePy ::Type,partModule,"AttachEngine");
#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef BRepOffsetAPIDef = {PyModuleDef_HEAD_INIT,"BRepOffsetAPI", "BRepOffsetAPI", -1, 0};
static struct PyModuleDef BRepOffsetAPIDef = {
PyModuleDef_HEAD_INIT,
"BRepOffsetAPI", "BRepOffsetAPI", -1, 0,
NULL, NULL, NULL, NULL
};
PyObject* brepModule = PyModule_Create(&BRepOffsetAPIDef);
#else
PyObject* brepModule = Py_InitModule3("BRepOffsetAPI", 0, "BrepOffsetAPI");
@@ -359,7 +363,11 @@ PyMOD_INIT_FUNC(Part)
// Geom2d package
#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef geom2dDef = {PyModuleDef_HEAD_INIT,"Geom2dD", "Geom2d", -1, 0};
static struct PyModuleDef geom2dDef = {
PyModuleDef_HEAD_INIT,
"Geom2dD", "Geom2d", -1, 0,
NULL, NULL, NULL, NULL
};
PyObject* geom2dModule = PyModule_Create(&geom2dDef);
#else
PyObject* geom2dModule = Py_InitModule3("Geom2d", 0, "Geom2d");

View File

@@ -123,7 +123,13 @@ PyMOD_INIT_FUNC(PartGui)
Base::Console().Log("Loading GUI of Part module... done\n");
#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef pAttachEngineTextsModuleDef = {PyModuleDef_HEAD_INIT,"AttachEngineResources", "AttachEngineResources", -1, 0};
static struct PyModuleDef pAttachEngineTextsModuleDef = {
PyModuleDef_HEAD_INIT,
"AttachEngineResources",
"AttachEngineResources", -1,
AttacherGui::AttacherGuiPy::Methods,
NULL, NULL, NULL, NULL
};
PyObject* pAttachEngineTextsModule = PyModule_Create(&pAttachEngineTextsModuleDef);
#else
PyObject* pAttachEngineTextsModule = Py_InitModule3("AttachEngineResources", AttacherGui::AttacherGuiPy::Methods,