Skip to content

Commit

Permalink
Merge pull request #1087 from dictoon/master
Browse files Browse the repository at this point in the history
Fix MIS bug + sort #include clauses
  • Loading branch information
est77 committed Sep 11, 2016
2 parents e842a3e + 539bf7e commit 49ce05a
Show file tree
Hide file tree
Showing 82 changed files with 130 additions and 123 deletions.
41 changes: 23 additions & 18 deletions scripts/sortincludes.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@
import sys


#--------------------------------------------------------------------------------------------------
# Utility functions.
#--------------------------------------------------------------------------------------------------

def walk(directory, recursive):
if recursive:
for dirpath, dirnames, filenames in os.walk(directory):
for filename in filenames:
yield os.path.join(dirpath, filename)
else:
dirpath, dirnames, filenames = os.walk(directory).next()
for filename in filenames:
yield os.path.join(dirpath, filename)


#--------------------------------------------------------------------------------------------------
# Processing code.
#--------------------------------------------------------------------------------------------------
Expand All @@ -52,7 +67,7 @@ def process_file(filepath):

if section_begin != -1 and line in ["\n", "\r\n"]:
if all(clause.startswith("#include") for clause in lines[section_begin:index]):
lines[section_begin:index] = sorted(lines[section_begin:index])
lines[section_begin:index] = sorted(lines[section_begin:index], key=lambda s: s.lower())
section_begin = -1

with open(filepath + ".processed", "wt") as f:
Expand All @@ -61,13 +76,6 @@ def process_file(filepath):

os.remove(filepath)
os.rename(filepath + ".processed", filepath)

def process_recursively():
for dirpath, dirnames, filenames in os.walk("."):
for filename in filenames:
ext = os.path.splitext(filename)[1]
if ext == ".h" or ext == ".cpp":
process_file(os.path.join(dirpath, filename))


#--------------------------------------------------------------------------------------------------
Expand All @@ -78,19 +86,16 @@ def main():
parser = argparse.ArgumentParser(description="sort #include clauses in c++ source code.")
parser.add_argument("-r", "--recursive", action='store_true', dest='recursive',
help="process all files in the specified directory and all its subdirectories")
parser.add_argument("filepath", nargs="?", help="file to process")
parser.add_argument("path", help="file or directory to process")
args = parser.parse_args()

if args.filepath:
if args.recursive:
print("cannot simultaneously specify a file path and use the --recursive flag.")
sys.exit(1)
print(args.filepath)
if os.path.isfile(args.path):
process_file(args.path)
else:
if not args.recursive:
print("either a file path or the --recursive flag must be specified.")
sys.exit(1)
process_recursively()
for filepath in walk(args.path, args.recursive):
ext = os.path.splitext(filepath)[1]
if ext == ".h" or ext == ".cpp":
process_file(filepath)

if __name__ == '__main__':
main()
2 changes: 1 addition & 1 deletion src/appleseed.python/bindshadergroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
#include "renderer/api/shadergroup.h"

// appleseed.foundation headers.
#include "foundation/utility/autoreleaseptr.h"
#include "foundation/utility/api/specializedapiarrays.h"
#include "foundation/utility/autoreleaseptr.h"
#include "foundation/utility/searchpaths.h"

// Standard headers.
Expand Down
2 changes: 1 addition & 1 deletion src/appleseed.python/bindtexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
#include "unalignedtransform.h"

// appleseed.renderer headers.
#include "renderer/api/texture.h"
#include "renderer/api/scene.h"
#include "renderer/api/texture.h"

// appleseed.foundation headers.
#include "foundation/utility/searchpaths.h"
Expand Down
2 changes: 1 addition & 1 deletion src/appleseed.python/dict2dict.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

// appleseed.foundation headers.
#include "foundation/math/vector.h"
#include "foundation/utility/containers/dictionary.h"
#include "foundation/utility/api/specializedapiarrays.h"
#include "foundation/utility/containers/dictionary.h"
#include "foundation/utility/foreach.h"
#include "foundation/utility/iostreamop.h"
#include "foundation/utility/string.h"
Expand Down
2 changes: 1 addition & 1 deletion src/appleseed.python/metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
#include "dict2dict.h"

// appleseed.foundation headers.
#include "foundation/utility/containers/dictionary.h"
#include "foundation/utility/api/specializedapiarrays.h"
#include "foundation/utility/containers/dictionary.h"

namespace detail
{
Expand Down
4 changes: 2 additions & 2 deletions src/appleseed.studio/mainwindow/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@

// appleseed.studio headers.
#include "help/about/aboutwindow.h"
#include "mainwindow/project/attributeeditor.h"
#include "mainwindow/project/projectexplorer.h"
#include "mainwindow/logwidget.h"
#include "mainwindow/minimizebutton.h"
#include "mainwindow/project/attributeeditor.h"
#include "mainwindow/project/projectexplorer.h"
#include "utility/interop.h"
#include "utility/miscellaneous.h"
#include "utility/settingskeys.h"
Expand Down
2 changes: 1 addition & 1 deletion src/appleseed.studio/mainwindow/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
#include "debug/benchmarks/benchmarkwindow.h"
#include "debug/tests/testwindow.h"
#include "mainwindow/project/projectmanager.h"
#include "mainwindow/qtlogtarget.h"
#include "mainwindow/rendering/renderingmanager.h"
#include "mainwindow/rendering/rendertab.h"
#include "mainwindow/qtlogtarget.h"
#include "mainwindow/renderingsettingswindow.h"
#include "mainwindow/statusbar.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
#include "renderer/api/material.h"

// appleseed.foundation headers.
#include "foundation/utility/containers/dictionary.h"
#include "foundation/utility/api/specializedapiarrays.h"
#include "foundation/utility/containers/dictionary.h"

// Qt headers.
#include <QPushButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
#include "entityeditorformfactorybase.h"

// appleseed.foundation headers.
#include "foundation/utility/containers/dictionary.h"
#include "foundation/utility/api/specializedapiarrays.h"
#include "foundation/utility/containers/dictionary.h"

// Standard headers.
#include <cstddef>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@

// appleseed.foundation headers.
#include "foundation/math/transform.h"
#include "foundation/utility/containers/dictionary.h"
#include "foundation/utility/autoreleaseptr.h"
#include "foundation/utility/containers/dictionary.h"
#include "foundation/utility/searchpaths.h"
#include "foundation/utility/uid.h"

Expand Down
2 changes: 1 addition & 1 deletion src/appleseed.studio/mainwindow/project/projectbuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
// appleseed.foundation headers.
#include "foundation/core/concepts/noncopyable.h"
#include "foundation/math/transform.h"
#include "foundation/utility/containers/dictionary.h"
#include "foundation/utility/autoreleaseptr.h"
#include "foundation/utility/containers/dictionary.h"
#include "foundation/utility/uid.h"

// Qt headers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
#include "foundation/image/image.h"
#include "foundation/platform/defaulttimers.h"
#include "foundation/platform/types.h"
#include "foundation/utility/job/iabortswitch.h"
#include "foundation/utility/foreach.h"
#include "foundation/utility/job/iabortswitch.h"
#include "foundation/utility/string.h"

// Boost headers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
// appleseed.foundation headers.
#include "foundation/math/transform.h"
#include "foundation/platform/thread.h"
#include "foundation/utility/job/abortswitch.h"
#include "foundation/utility/autoreleaseptr.h"
#include "foundation/utility/job/abortswitch.h"

// Qt headers.
#include <QObject>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
#include "ui_renderingsettingswindow.h"

// appleseed.studio headers.
#include "mainwindow/project/projectmanager.h"
#include "mainwindow/configurationmanagerwindow.h"
#include "mainwindow/project/projectmanager.h"
#include "utility/foldablepanelwidget.h"
#include "utility/inputwidgetproxies.h"
#include "utility/miscellaneous.h"
Expand Down
2 changes: 1 addition & 1 deletion src/appleseed.studio/utility/widgetzoomhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
#include <QLayout>
#include <QScrollArea>
#include <QScrollBar>
#include <QWidget>
#include <QWheelEvent>
#include <QWidget>

// Standard headers.
#include <algorithm>
Expand Down
2 changes: 1 addition & 1 deletion src/appleseed/foundation/math/bsp/bsp_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@

// appleseed.foundation headers.
#include "foundation/core/concepts/noncopyable.h"
#include "foundation/math/bsp/bsp_node.h"
#include "foundation/math/aabb.h"
#include "foundation/math/bsp/bsp_node.h"

// Standard headers.
#include <cstddef>
Expand Down
2 changes: 1 addition & 1 deletion src/appleseed/foundation/math/bvh/bvh_sbvhpartitioner.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@

// appleseed.foundation headers.
#include "foundation/core/concepts/noncopyable.h"
#include "foundation/math/bvh/bvh_bboxsortpredicate.h"
#include "foundation/math/aabb.h"
#include "foundation/math/bvh/bvh_bboxsortpredicate.h"
#include "foundation/math/scalar.h"
#include "foundation/math/split.h"
#include "foundation/platform/types.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
#define APPLESEED_FOUNDATION_MATH_INTERSECTION_FRUSTUMSEGMENT_H

// appleseed.foundation headers.
#include "foundation/math/intersection/planesegment.h"
#include "foundation/math/frustum.h"
#include "foundation/math/intersection/planesegment.h"
#include "foundation/math/vector.h"

// Standard headers.
Expand Down
2 changes: 1 addition & 1 deletion src/appleseed/foundation/math/knn/knn_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@

// appleseed.foundation headers.
#include "foundation/core/concepts/noncopyable.h"
#include "foundation/math/aabb.h"
#include "foundation/math/knn/knn_node.h"
#include "foundation/math/knn/knn_tree.h"
#include "foundation/math/aabb.h"
#include "foundation/math/permutation.h"
#include "foundation/math/split.h"
#include "foundation/math/vector.h"
Expand Down
4 changes: 2 additions & 2 deletions src/appleseed/foundation/math/knn/knn_query.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@

// appleseed.foundation headers.
#include "foundation/core/concepts/noncopyable.h"
#include "foundation/math/distance.h"
#include "foundation/math/fp.h"
#include "foundation/math/knn/knn_answer.h"
#include "foundation/math/knn/knn_statistics.h"
#include "foundation/math/knn/knn_tree.h"
#include "foundation/math/distance.h"
#include "foundation/math/fp.h"
#include "foundation/math/scalar.h"
#include "foundation/math/vector.h"
#include "foundation/platform/compiler.h"
Expand Down
2 changes: 1 addition & 1 deletion src/appleseed/foundation/math/noise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
#include "noise.h"

// appleseed.foundation headers.
#include "foundation/math/rng/mersennetwister.h"
#include "foundation/math/permutation.h"
#include "foundation/math/rng/mersennetwister.h"

namespace foundation
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@

// appleseed.foundation headers.
#include "foundation/core/exceptions/exceptionnotimplemented.h"
#include "foundation/math/rng/distribution.h"
#include "foundation/math/permutation.h"
#include "foundation/math/primes.h"
#include "foundation/math/qmc.h"
#include "foundation/math/rng/distribution.h"
#include "foundation/math/vector.h"
#include "foundation/utility/test/helpers.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@

// appleseed.foundation headers.
#include "foundation/core/concepts/noncopyable.h"
#include "foundation/math/sampling/mappings.h"
#include "foundation/math/area.h"
#include "foundation/math/cdf.h"
#include "foundation/math/sampling/mappings.h"
#include "foundation/math/scalar.h"
#include "foundation/math/sphericaltriangle.h"
#include "foundation/math/vector.h"
Expand All @@ -42,9 +42,9 @@

// Standard headers.
#include <algorithm>
#include <cmath>
#include <cstddef>
#include <cstdio>
#include <cmath>
#include <map>
#include <vector>

Expand Down
2 changes: 1 addition & 1 deletion src/appleseed/foundation/math/voxel/voxel_intersector.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@

// appleseed.foundation headers.
#include "foundation/core/concepts/noncopyable.h"
#include "foundation/math/voxel/voxel_statistics.h"
#include "foundation/math/ray.h"
#include "foundation/math/voxel/voxel_statistics.h"

// Standard headers.
#include <cassert>
Expand Down
2 changes: 1 addition & 1 deletion src/appleseed/foundation/math/voxel/voxel_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@

// appleseed.foundation headers.
#include "foundation/core/concepts/noncopyable.h"
#include "foundation/math/voxel/voxel_node.h"
#include "foundation/math/aabb.h"
#include "foundation/math/split.h"
#include "foundation/math/vector.h"
#include "foundation/math/voxel/voxel_node.h"
#include "foundation/platform/types.h"
#include "foundation/utility/bufferedfile.h"

Expand Down
2 changes: 1 addition & 1 deletion src/appleseed/foundation/mesh/objmeshfilewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
#include "objmeshfilewriter.h"

// appleseed.foundation headers.
#include "foundation/core/exceptions/exceptionioerror.h"
#include "foundation/core/appleseed.h"
#include "foundation/core/exceptions/exceptionioerror.h"
#include "foundation/mesh/imeshwalker.h"
#include "foundation/platform/types.h"
#include "foundation/utility/otherwise.h"
Expand Down
2 changes: 1 addition & 1 deletion src/appleseed/foundation/meta/benchmarks/benchmark_cdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
//

// appleseed.foundation headers.
#include "foundation/math/cdf.h"
#include "foundation/math/rng/distribution.h"
#include "foundation/math/rng/xorshift.h"
#include "foundation/math/cdf.h"
#include "foundation/utility/benchmark.h"

// Standard headers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
//

// appleseed.foundation headers.
#include "foundation/math/fastmath.h"
#include "foundation/math/rng/distribution.h"
#include "foundation/math/rng/mersennetwister.h"
#include "foundation/math/fastmath.h"
#include "foundation/platform/compiler.h"
#include "foundation/utility/benchmark.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
//

// appleseed.foundation headers.
#include "foundation/math/aabb.h"
#include "foundation/math/intersection/rayaabb.h"
#include "foundation/math/intersection/raytrianglemt.h"
#include "foundation/math/intersection/raytrianglessk.h"
#include "foundation/math/ray.h"
#include "foundation/math/rng/distribution.h"
#include "foundation/math/rng/mersennetwister.h"
#include "foundation/math/sampling/mappings.h"
#include "foundation/math/aabb.h"
#include "foundation/math/ray.h"
#include "foundation/math/vector.h"
#include "foundation/platform/compiler.h"
#include "foundation/utility/benchmark.h"
Expand Down
2 changes: 1 addition & 1 deletion src/appleseed/foundation/meta/benchmarks/benchmark_knn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
//

// appleseed.foundation headers.
#include "foundation/math/knn.h"
#include "foundation/math/rng/distribution.h"
#include "foundation/math/rng/mersennetwister.h"
#include "foundation/math/rng/xorshift.h"
#include "foundation/math/knn.h"
#include "foundation/math/vector.h"
#include "foundation/platform/timers.h"
#include "foundation/platform/types.h"
Expand Down
Loading

0 comments on commit 49ce05a

Please sign in to comment.