Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

Add source formatting check (#689)

Shinya Kitaoka6fa9acbd5f94
diff --git a/ci-scripts/osx/travis-build.sh b/ci-scripts/osx/travis-build.sh
index 21809457c..f8bab6b9a 100644
--- a/ci-scripts/osx/travis-build.sh
+++ b/ci-scripts/osx/travis-build.sh
@@ -1,4 +1,8 @@
#!/bin/bash
+pushd toonz/sources
+clang-format --version
+git ls-files | egrep \\.\(c\|cpp\|h\|hpp\)$ | xargs clang-format -i && git diff --exit-code || exit 1
+popd
pushd thirdparty/tiff-4.0.3
./configure && make
popd
diff --git a/ci-scripts/osx/travis-install.sh b/ci-scripts/osx/travis-install.sh
index 9f8423930..5a2358d13 100644
--- a/ci-scripts/osx/travis-install.sh
+++ b/ci-scripts/osx/travis-install.sh
@@ -1,3 +1,5 @@
#!/bin/bash
brew update
brew install qt55 glew lz4 lzo libusb
+brew tap tcr/tcr
+brew install clang-format
diff --git a/toonz/sources/beautification.bat b/toonz/sources/beautification.bat
deleted file mode 100644
index 46134aa05..000000000
--- a/toonz/sources/beautification.bat
+++ /dev/null
@@ -1,5 +0,0 @@
-@echo off
-
-for /R %%F in (*.cpp;*.hpp;*.c;*.h) do (
- clang-format -i "%%F"
-)
diff --git a/toonz/sources/beautification.sh b/toonz/sources/beautification.sh
old mode 100644
new mode 100755
index 1d6939bbb..b68938528
--- a/toonz/sources/beautification.sh
+++ b/toonz/sources/beautification.sh
@@ -1,2 +1,2 @@
#!/bin/sh
-git ls-files | egrep \\.\(c\|cpp\|h\|hpp\)$ | xargs clang-format -i
+git diff master --name-only | egrep \\.\(c\|cpp\|h\|hpp\)$ | xargs clang-format -i
diff --git a/toonz/sources/common/trop/tblur.cpp b/toonz/sources/common/trop/tblur.cpp
index 33611943b..d3a21c91b 100644
--- a/toonz/sources/common/trop/tblur.cpp
+++ b/toonz/sources/common/trop/tblur.cpp
@@ -799,7 +799,7 @@ void doBlurRgb(TRasterPT<T> &dstRas, TRasterPT<T> &srcRas, double blur, int dx,
r1->lock();
fbuffer = (BlurPixel<P> *)r1->getRawData(); // new CASM_FPIXEL [llx *ly];
row1 = new T[llx + 2 * brad];
- col1 = new BlurPixel<P>[lly + 2 * brad];
+ col1 = new BlurPixel<P>[ lly + 2 * brad ];
col2 = new T[lly];
}
diff --git a/toonz/sources/common/twain/twain.h b/toonz/sources/common/twain/twain.h
index fc05afc1d..c7dee179c 100644
--- a/toonz/sources/common/twain/twain.h
+++ b/toonz/sources/common/twain/twain.h
@@ -1483,23 +1483,15 @@ typedef struct {
0x0203 /* TW_UINT32 handle to WAV, (AIFF Mac) Added 1.8 */
/* misplaced */
-#define DAT_ICCPROFILE \
- 0x0401 /* TW_MEMORY Added 1.91 This Data Argument is misplaced but \ \ \ \
- \ \
- belongs to the DG_IMAGE Data Group */
-#define DAT_IMAGEMEMFILEXFER \
- 0x0402 /* TW_IMAGEMEMXFER Added 1.91 This Data Argument is misplaced but \
- \ \
- \ \ \
- \ \ \ \
- \ \ \ \ \
- belongs to the DG_IMAGE Data Group */
-#define DAT_ENTRYPOINT \
- 0x0403 /* TW_ENTRYPOINT Added 2.0 This Data Argument is misplaced but \ \
- \ \
- \ \ \
- \ \ \ \
- belongs to the DG_CONTROL Data Group */
+/* TW_MEMORY Added 1.91 This Data Argument is misplaced but belongs to the
+ * DG_IMAGE Data Group */
+#define DAT_ICCPROFILE 0x0401
+/* TW_IMAGEMEMXFER Added 1.91 This Data Argument is misplaced but belongs to
+ * the DG_IMAGE Data Group */
+#define DAT_IMAGEMEMFILEXFER 0x0402
+/* TW_ENTRYPOINT Added 2.0 This Data Argument is misplaced but belongs to
+ * the DG_CONTROL Data Group */
+#define DAT_ENTRYPOINT 0x0403
/****************************************************************************
* Messages *
diff --git a/toonz/sources/include/tfx.h b/toonz/sources/include/tfx.h
index fe2b81b22..c26028b5b 100644
--- a/toonz/sources/include/tfx.h
+++ b/toonz/sources/include/tfx.h
@@ -539,7 +539,6 @@ inline std::string TFx::getFxType() const { return getDeclaration()->getId(); }
//-------------------------------------------------------------------
#define FX_DECLARATION(T) \
- \
public: \
const TPersistDeclaration *getDeclaration() const override;
diff --git a/toonz/sources/include/tpersist.h b/toonz/sources/include/tpersist.h
index c5b15b880..769c31c17 100644
--- a/toonz/sources/include/tpersist.h
+++ b/toonz/sources/include/tpersist.h
@@ -142,10 +142,9 @@ public:
class TPersistDeclarationT
*/
#define PERSIST_DECLARATION(T) \
- \
private: \
static TPersistDeclarationT<T> m_declaration; \
- \
+ \
public: \
const TPersistDeclaration *getDeclaration() const override { \
return &m_declaration; \
diff --git a/toonz/sources/include/trenderresourcemanager.h b/toonz/sources/include/trenderresourcemanager.h
index 559274a19..cbb6da760 100644
--- a/toonz/sources/include/trenderresourcemanager.h
+++ b/toonz/sources/include/trenderresourcemanager.h
@@ -132,11 +132,10 @@ static TRenderResourceManagerGenerator* gen();
*/
#define T_RENDER_RESOURCE_MANAGER \
- \
public: \
static TRenderResourceManagerGenerator *gen(); \
static TRenderResourceManagerGenerator *deps(); \
- \
+ \
private:
//--------------------------------------------------------------------------------
diff --git a/toonz/sources/include/tsmartpointer.h b/toonz/sources/include/tsmartpointer.h
index 2cebef1c0..7f14e23cc 100644
--- a/toonz/sources/include/tsmartpointer.h
+++ b/toonz/sources/include/tsmartpointer.h
@@ -87,10 +87,9 @@ private:
};
#define DECLARE_CLASS_CODE \
- \
private: \
static const TSmartObject::ClassCode m_classCode; \
- \
+ \
public: \
inline static TINT32 getInstanceCount() { \
return TSmartObject::getInstanceCount(m_classCode); \
diff --git a/toonz/sources/stdfx/stdfx.h b/toonz/sources/stdfx/stdfx.h
index bd0cb0aff..d32644d19 100644
--- a/toonz/sources/stdfx/stdfx.h
+++ b/toonz/sources/stdfx/stdfx.h
@@ -15,7 +15,6 @@ class PaletteFilterFxRenderData;
static const std::string PLUGIN_PREFIX("STD");
#define FX_PLUGIN_DECLARATION(T) \
- \
public: \
const TPersistDeclaration *getDeclaration() const override;