Skip to content

Commit 192cd25

Browse files
authored
Merge branch 'openscad:master' into master
2 parents aabddc3 + ce6161c commit 192cd25

16 files changed

+326
-259
lines changed

.clang-tidy

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,35 @@
1-
Checks: '
2-
-*,
3-
boost-*,
4-
bugprone-*,
5-
-bugprone-easily-swappable-parameters,
6-
-bugprone-exception-escape,
7-
-bugprone-narrowing-conversions,
8-
clang-analyzer-*,
9-
-clang-analyzer-cplusplus.NewDelete,
10-
-clang-analyzer-cplusplus.NewDeleteLeaks,
11-
misc-*,
12-
-misc-definitions-in-headers,
13-
-misc-no-recursion,
14-
-misc-non-private-member-variables-in-classes,
15-
modernize-*,
16-
-modernize-avoid-c-arrays,
17-
-modernize-use-nodiscard,
18-
-modernize-use-trailing-return-type,
19-
performance-*
20-
'
1+
Checks:
2+
- '-*'
3+
- 'boost-*'
4+
# We use ranges where it suits us, but not everywhere.
5+
- '-boost-use-ranges'
6+
- 'bugprone-*'
7+
# We have too much code violating this. Consider re-enabling in the future (nice to have)
8+
- '-bugprone-easily-swappable-parameters'
9+
# We should enable this, but we have some tricky cases to fix first
10+
- '-bugprone-exception-escape'
11+
# We have too much code violating this. Consider re-enabling in the future
12+
- '-bugprone-narrowing-conversions'
13+
# Sometimes, assignment in if make code more readable
14+
- '-bugprone-assignment-in-if-condition'
15+
- 'clang-analyzer-*'
16+
- 'misc-*'
17+
# We do allow using recursive functions
18+
- '-misc-no-recursion'
19+
# We have too much code violating this. Consider re-enabling in the future.
20+
- '-misc-non-private-member-variables-in-classes'
21+
- 'modernize-*'
22+
# We have too much code violating this. Consider re-enabling in the future.
23+
- '-modernize-avoid-c-arrays'
24+
# We use nodiscard in some key classes, but it's a bit noisy to enable everywhere.
25+
- '-modernize-use-nodiscard'
26+
# We're not using trailing return types for regular functions
27+
- '-modernize-use-trailing-return-type'
28+
- 'performance-*'
29+
# We use std::endl in some places, where we want to flush the stream
30+
- '-performance-avoid-endl'
31+
32+
CheckOptions:
33+
misc-include-cleaner.IgnoreHeaders: 'boost/.*;fontconfig/.*;glib.h'
34+
2135
WarningsAsErrors: ''

src/Feature.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#include "Feature.h"
22

3-
#include <cstdio>
43
#include <string>
4+
#include <utility>
5+
56
#include <boost/algorithm/string/join.hpp>
67
#include <boost/range/adaptor/transformed.hpp>
7-
#include <utility>
88

9+
#include "utils/exceptions.h"
910
#include "utils/printutils.h"
1011

1112
/**

src/Feature.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#pragma once
22

3-
#include <cstdio>
43
#include <string>
54
#include <map>
65
#include <vector>

src/FontCache.cc

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,34 @@
2626

2727
#include "FontCache.h"
2828

29+
#include <cassert>
30+
#include <cstdlib>
2931
#include <cstdint>
32+
#include <ctime>
33+
#include <filesystem>
3034
#include <iostream>
35+
#include <string>
36+
#include <utility>
3137
#include <vector>
3238

33-
#include <filesystem>
3439
#include <boost/algorithm/string.hpp>
35-
#include <string>
36-
#include <utility>
40+
#include <hb.h>
41+
#include <fontconfig/fontconfig.h>
42+
#include <ft2build.h>
43+
#include FT_FREETYPE_H
44+
#include FT_TYPES_H
45+
#include FT_TRUETYPE_IDS_H
3746

3847
#include "platform/PlatformUtils.h"
3948
#include "utils/printutils.h"
4049
#include "utils/version_helper.h"
4150

4251
extern std::vector<std::string> librarypath;
43-
4452
std::vector<std::string> fontpath;
4553

4654
namespace fs = std::filesystem;
4755

48-
const std::string get_fontconfig_version()
56+
std::string get_fontconfig_version()
4957
{
5058
const unsigned int version = FcGetVersion();
5159

@@ -54,7 +62,7 @@ const std::string get_fontconfig_version()
5462
return OpenSCAD::get_version_string(header_version, runtime_version);
5563
}
5664

57-
const std::string get_harfbuzz_version()
65+
std::string get_harfbuzz_version()
5866
{
5967
unsigned int major, minor, micro;
6068
hb_version(&major, &minor, &micro);
@@ -64,7 +72,7 @@ const std::string get_harfbuzz_version()
6472
return OpenSCAD::get_version_string(header_version, runtime_version);
6573
}
6674

67-
const std::string get_freetype_version()
75+
std::string get_freetype_version()
6876
{
6977
return FontCache::instance()->get_freetype_version();
7078
}
@@ -128,7 +136,7 @@ FontCache::FontCache()
128136
// If we've got a bundled fonts.conf, initialize fontconfig with our own config
129137
// by overriding the built-in fontconfig path.
130138
// For system installs and dev environments, we leave this alone
131-
fs::path fontdir(PlatformUtils::resourcePath("fonts"));
139+
const fs::path fontdir(PlatformUtils::resourcePath("fonts"));
132140
if (fs::is_regular_file(fontdir / "fonts.conf")) {
133141
auto abspath = fontdir.empty() ? fs::current_path() : fs::absolute(fontdir);
134142
PlatformUtils::setenv("FONTCONFIG_PATH", (abspath.generic_string()).c_str(), 0);
@@ -167,7 +175,7 @@ FontCache::FontCache()
167175
for (string_split_iterator it = boost::make_split_iterator(paths, boost::first_finder(sep, boost::is_iequal())); it != string_split_iterator(); ++it) {
168176
const fs::path p(boost::copy_range<std::string>(*it));
169177
if (fs::exists(p) && fs::is_directory(p)) {
170-
std::string path = fs::absolute(p).string();
178+
const std::string path = fs::absolute(p).string();
171179
add_font_dir(path);
172180
}
173181
}
@@ -243,7 +251,7 @@ std::vector<uint32_t> FontCache::filter(const std::u32string& str) const
243251
FcPattern *pattern = FcPatternCreate();
244252
init_pattern(pattern);
245253
FcCharSet *charSet = FcCharSetCreate();
246-
for (char32_t a : str) {
254+
for (const char32_t a : str) {
247255
FcCharSetAddChar(charSet, a);
248256
}
249257
FcValue charSetValue;
@@ -287,11 +295,11 @@ FontInfoList *FontCache::list_fonts() const
287295
FcValue style_value;
288296
FcPatternGet(p, FC_STYLE, 0, &style_value);
289297

290-
std::string family((const char *) family_value.u.s);
291-
std::string style((const char *) style_value.u.s);
292-
std::string file((const char *) file_value.u.s);
298+
const std::string family((const char *) family_value.u.s);
299+
const std::string style((const char *) style_value.u.s);
300+
const std::string file((const char *) file_value.u.s);
293301

294-
list->push_back(FontInfo(family, style, file, FcPatternHash(p)));
302+
list->emplace_back(family, style, file, FcPatternHash(p));
295303
}
296304
FcFontSetDestroy(font_set);
297305

@@ -405,7 +413,7 @@ FT_Face FontCache::find_face_fontconfig(const std::string& font) const
405413
}
406414

407415
FT_Face face;
408-
FT_Error error = FT_New_Face(this->library, (const char *) file_value.u.s, font_index.u.i, &face);
416+
const FT_Error error = FT_New_Face(this->library, (const char *) file_value.u.s, font_index.u.i, &face);
409417

410418
FcPatternDestroy(pattern);
411419
FcPatternDestroy(match);
@@ -460,7 +468,7 @@ bool FontCache::is_windows_symbol_font(const FT_Face& face) const
460468
}
461469

462470
FT_UInt gindex;
463-
FT_ULong charcode = FT_Get_First_Char(face, &gindex);
471+
const FT_ULong charcode = FT_Get_First_Char(face, &gindex);
464472
if ((gindex == 0) || (charcode < 0xf000)) {
465473
return false;
466474
}

src/FontCache.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,21 @@
2525
*/
2626
#pragma once
2727

28-
#include <utility>
2928
#include <cstdint>
29+
#include <ctime>
3030
#include <map>
3131
#include <string>
32-
33-
#include <ctime>
32+
#include <string>
33+
#include <utility>
34+
#include <vector>
3435

3536
#include <ft2build.h>
3637
#include FT_FREETYPE_H
37-
#include FT_TRUETYPE_IDS_H
38-
39-
#include <vector>
40-
#include <string>
4138
#include <fontconfig/fontconfig.h>
4239

43-
#include <hb.h>
44-
#include <hb-ft.h>
40+
std::string get_fontconfig_version();
41+
std::string get_harfbuzz_version();
42+
std::string get_freetype_version();
4543

4644
class FontInfo
4745
{

src/LibraryInfo.cc

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
#include "LibraryInfo.h"
2+
3+
#include <cstdlib>
24
#include <sstream>
3-
#include <glib.h>
45
#include <string>
56
#include <vector>
67

7-
#include "utils/version_check.h"
8-
#include "platform/PlatformUtils.h"
9-
#include "version.h"
10-
#include "Feature.h"
118
#include <clipper2/clipper.version.h>
9+
#include <Eigen/Core>
10+
#include <glib.h>
1211

13-
#define STRINGIFY(x) #x
14-
#define TOSTRING(x) STRINGIFY(x)
1512

1613
#ifndef OPENSCAD_NOGUI
14+
#include <QtGlobal>
1715
#include <Qsci/qsciglobal.h>
1816
#include "gui/input/InputDriverManager.h"
1917
#endif
2018

2119
#ifdef ENABLE_CGAL
22-
#include "geometry/cgal/cgal.h"
20+
#include <CGAL/version.h>
2321
#include <boost/algorithm/string.hpp>
22+
#include "geometry/cgal/cgal.h"
2423
#if defined(__GNUG__)
2524
#define GCC_INT_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100)
2625
#if GCC_INT_VERSION > 40600 || defined(__clang__)
@@ -48,6 +47,9 @@
4847
#define OPENCSG_VERSION_STRING "<not enabled>"
4948
#endif
5049

50+
#define STRINGIFY(x) #x
51+
#define TOSTRING(x) STRINGIFY(x)
52+
5153
#ifdef ENABLE_MANIFOLD
5254
#include <manifold/version.h> // if it is new enough for us, it has version.h
5355
#define MANIFOLD_VERSION_STRING \
@@ -58,55 +60,57 @@
5860
#define MANIFOLD_VERSION_STRING "<not enabled>"
5961
#endif
6062

63+
#include "platform/PlatformUtils.h"
64+
#include "version.h"
65+
#include "Feature.h"
66+
#include "FontCache.h"
67+
6168
extern std::vector<std::string> librarypath;
6269
extern std::vector<std::string> fontpath;
6370
extern const std::string get_cairo_version();
6471
extern const std::string get_lib3mf_version();
65-
extern const std::string get_fontconfig_version();
66-
extern const std::string get_harfbuzz_version();
67-
extern const std::string get_freetype_version();
6872
extern const char *LODEPNG_VERSION_STRING;
6973

7074
std::string LibraryInfo::info()
7175
{
7276
std::ostringstream s;
7377

7478
#if defined(__x86_64__) || defined(_M_X64)
75-
std::string bits(" 64bit");
79+
const std::string bits(" 64bit");
7680
#elif defined(__i386) || defined(_M_IX86)
77-
std::string bits(" 32bit");
81+
const std::string bits(" 32bit");
7882
#else
79-
std::string bits("");
83+
const std::string bits("");
8084
#endif
8185

8286
#if defined(__GNUG__) && !defined(__clang__)
83-
std::string compiler_info("GCC " + std::string(TOSTRING(__VERSION__)) + bits);
87+
const std::string compiler_info("GCC " + std::string(TOSTRING(__VERSION__)) + bits);
8488
#elif defined(_MSC_VER)
85-
std::string compiler_info("MSVC " + std::string(TOSTRING(_MSC_FULL_VER)) + bits);
89+
const std::string compiler_info("MSVC " + std::string(TOSTRING(_MSC_FULL_VER)) + bits);
8690
#elif defined(__clang__)
87-
std::string compiler_info("Clang " + std::string(TOSTRING(__clang_version__)) + bits);
91+
const std::string compiler_info("Clang " + std::string(TOSTRING(__clang_version__)) + bits);
8892
#else
89-
std::string compiler_info("unknown compiler");
93+
const std::string compiler_info("unknown compiler");
9094
#endif
9195

9296
#if defined(__MINGW64__)
93-
std::string mingwstatus("MingW64");
97+
const std::string mingwstatus("MingW64");
9498
#elif defined(__MINGW32__)
95-
std::string mingwstatus("MingW32");
99+
const std::string mingwstatus("MingW32");
96100
#else
97-
std::string mingwstatus("No");
101+
const std::string mingwstatus("No");
98102
#endif
99103

100104
#ifdef DEBUG
101-
std::string debugstatus("Yes");
105+
const std::string debugstatus("Yes");
102106
#else
103-
std::string debugstatus("No");
107+
const std::string debugstatus("No");
104108
#endif
105109

106110
#ifdef QT_VERSION
107-
std::string qtVersion = qVersion();
111+
const std::string qtVersion = qVersion();
108112
#else
109-
std::string qtVersion = "Qt disabled - Commandline Test Version";
113+
const std::string qtVersion = "Qt disabled - Commandline Test Version";
110114
#endif
111115

112116
#ifdef ENABLE_CGAL

0 commit comments

Comments
 (0)