Skip to content

Commit 0ac3720

Browse files
committed
SWIG: Warnings cleanup
* Remove a SWIG pragma from Frame.h (gcc warns on it) * Place the equivalent %warnfilter in the openshot.i files * Set openshot.i PROPERTY GENERATED_COMPILE_OPTIONS with flags to disable warning spew in generated SWIG code, if -Wall is used (Also, remove 'using namespace std' from Frame.h, and add std:: prefixes to necessary variables.)
1 parent ed4b32d commit 0ac3720

File tree

5 files changed

+25
-11
lines changed

5 files changed

+25
-11
lines changed

include/Frame.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,6 @@
6565
#include "MagickUtilities.h"
6666
#endif
6767

68-
#pragma SWIG nowarn=362
69-
using namespace std;
70-
7168
namespace openshot
7269
{
7370
/**
@@ -131,7 +128,7 @@ namespace openshot
131128
int width;
132129
int height;
133130
int sample_rate;
134-
string color;
131+
std::string color;
135132
int64_t max_audio_sample; ///< The max audio sample count added to this frame
136133

137134
/// Constrain a color value from 0 to 255
@@ -147,13 +144,13 @@ namespace openshot
147144
Frame();
148145

149146
/// Constructor - image only (48kHz audio silence)
150-
Frame(int64_t number, int width, int height, string color);
147+
Frame(int64_t number, int width, int height, std::string color);
151148

152149
/// Constructor - audio only (300x200 blank image)
153150
Frame(int64_t number, int samples, int channels);
154151

155152
/// Constructor - image & audio
156-
Frame(int64_t number, int width, int height, string color, int samples, int channels);
153+
Frame(int64_t number, int width, int height, std::string color, int samples, int channels);
157154

158155
/// Copy constructor
159156
Frame ( const Frame &other );
@@ -165,7 +162,7 @@ namespace openshot
165162
virtual ~Frame();
166163

167164
/// Add (or replace) pixel data to the frame (based on a solid color)
168-
void AddColor(int new_width, int new_height, string new_color);
165+
void AddColor(int new_width, int new_height, std::string new_color);
169166

170167
/// Add (or replace) pixel data to the frame
171168
void AddImage(int new_width, int new_height, int bytes_per_pixel, QImage::Format type, const unsigned char *pixels_);
@@ -283,7 +280,7 @@ namespace openshot
283280
void SampleRate(int orig_sample_rate) { sample_rate = orig_sample_rate; };
284281

285282
/// Save the frame image to the specified path. The image format can be BMP, JPG, JPEG, PNG, PPM, XBM, XPM
286-
void Save(string path, float scale, string format="PNG", int quality=100);
283+
void Save(std::string path, float scale, std::string format="PNG", int quality=100);
287284

288285
/// Set frame number
289286
void SetFrameNumber(int64_t number);
@@ -293,8 +290,8 @@ namespace openshot
293290

294291
/// Thumbnail the frame image with tons of options to the specified path. The image format is determined from the extension (i.e. image.PNG, image.JPEG).
295292
/// This method allows for masks, overlays, background color, and much more accurate resizing (including padding and centering)
296-
void Thumbnail(string path, int new_width, int new_height, string mask_path, string overlay_path,
297-
string background_color, bool ignore_aspect, string format="png", int quality=100, float rotate=0.0);
293+
void Thumbnail(std::string path, int new_width, int new_height, std::string mask_path, std::string overlay_path,
294+
std::string background_color, bool ignore_aspect, std::string format="png", int quality=100, float rotate=0.0);
298295

299296
/// Play audio samples for this frame
300297
void Play();

src/bindings/python/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ if (PYTHONLIBS_FOUND AND PYTHONINTERP_FOUND)
5050
set_property(SOURCE openshot.i PROPERTY SWIG_MODULE_NAME openshot)
5151
SET(CMAKE_SWIG_FLAGS "")
5252

53+
### Suppress a ton of warnings in the generated SWIG C++ code
54+
set(SWIG_CXX_FLAGS "-Wno-unused-variable -Wno-unused-function -Wno-deprecated-copy -Wno-class-memaccess -Wno-cast-function-type \
55+
-Wno-unused-parameter -Wno-catch-value -Wno-sign-compare -Wno-ignored-qualifiers")
56+
separate_arguments(sw_flags UNIX_COMMAND ${SWIG_CXX_FLAGS})
57+
set_property(SOURCE openshot.i PROPERTY GENERATED_COMPILE_OPTIONS ${sw_flags})
58+
5359
### Add the SWIG interface file (which defines all the SWIG methods)
5460
if (CMAKE_VERSION VERSION_LESS 3.8.0)
5561
swig_add_module(pyopenshot python openshot.i)
@@ -65,7 +71,7 @@ if (PYTHONLIBS_FOUND AND PYTHONINTERP_FOUND)
6571
target_link_libraries(${SWIG_MODULE_pyopenshot_REAL_NAME}
6672
${PYTHON_LIBRARIES} openshot)
6773

68-
### Check if the following Debian-friendly python module path exists
74+
### Check if the following Debian-friendly python module path exists
6975
SET(PYTHON_MODULE_PATH "${CMAKE_INSTALL_PREFIX}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages")
7076
if (NOT EXISTS ${PYTHON_MODULE_PATH})
7177

src/bindings/python/openshot.i

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727

2828
%module openshot
2929

30+
/* Suppress warnings about ignored operator= */
31+
%warnfilter(362);
32+
3033
/* Enable inline documentation */
3134
%feature("autodoc", "1");
3235

src/bindings/ruby/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ IF (RUBY_FOUND)
5151
set_property(SOURCE openshot.i PROPERTY SWIG_MODULE_NAME openshot)
5252

5353
SET(CMAKE_SWIG_FLAGS "")
54+
### Suppress a ton of warnings in the generated SWIG C++ code
55+
set(SWIG_CXX_FLAGS "-Wno-unused-variable -Wno-unused-function -Wno-deprecated-copy -Wno-class-memaccess -Wno-cast-function-type \
56+
-Wno-unused-parameter -Wno-catch-value -Wno-sign-compare -Wno-ignored-qualifiers")
57+
separate_arguments(sw_flags UNIX_COMMAND ${SWIG_CXX_FLAGS})
58+
set_property(SOURCE openshot.i PROPERTY GENERATED_COMPILE_OPTIONS ${sw_flags})
5459

5560
### Add the SWIG interface file (which defines all the SWIG methods)
5661
if (CMAKE_VERSION VERSION_LESS 3.8.0)

src/bindings/ruby/openshot.i

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727

2828
%module openshot
2929

30+
/* Suppress warnings about ignored operator= */
31+
%warnfilter(362);
32+
3033
/* Enable inline documentation */
3134
%feature("autodoc", "1");
3235

0 commit comments

Comments
 (0)