Skip to content

Commit

Permalink
Sort visibility modifiers correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
MonsterDruide1 committed Oct 14, 2023
1 parent c70fab6 commit 0338057
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 16 deletions.
16 changes: 8 additions & 8 deletions lib/al/include/Library/Screen/ScreenFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ class SceneCameraInfo;
class ScreenCapture;

class ScreenCaptureExecutor : IUseHioNode {
private:
sead::PtrArray<ScreenCapture> mArray;
bool mIsCaptured;

public:
ScreenCaptureExecutor(s32);
~ScreenCaptureExecutor();
Expand All @@ -35,17 +31,21 @@ class ScreenCaptureExecutor : IUseHioNode {
void offDraw();

bool isDraw(s32) const;
};

class ScreenCoverCtrl {
private:
s32 mFrameTimer;
bool mIsActive;
sead::PtrArray<ScreenCapture> mArray;
bool mIsCaptured;
};

class ScreenCoverCtrl {
public:
ScreenCoverCtrl();
void requestCaptureScreenCover(s32 totalFrames);
void update();

private:
s32 mFrameTimer;
bool mIsActive;
};

u32 getDisplayWidth();
Expand Down
16 changes: 8 additions & 8 deletions lib/al/include/Project/Scene/SceneCreator.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ class AudioDirector;
class Scene;

class SceneCreator {
private:
GameSystemInfo* mGameSystemInfo;
GameDataHolderBase* mGameDataHolder;
ScreenCaptureExecutor* mScreenCaptureExecutor;
alSceneFunction::SceneFactory* mSceneFactory;
InitializeThread* mInitializeThread;
AudioDirector* mAudioDirector;

public:
SceneCreator(const GameSystemInfo*, GameDataHolderBase*, ScreenCaptureExecutor*,
alSceneFunction::SceneFactory*, AudioDirector*);
Expand All @@ -31,6 +23,14 @@ class SceneCreator {
void setSceneAndInit(Scene*, const char*, s32, const char*);
bool tryEndInitThread();
bool isExistInitThread();

private:
GameSystemInfo* mGameSystemInfo;
GameDataHolderBase* mGameDataHolder;
ScreenCaptureExecutor* mScreenCaptureExecutor;
alSceneFunction::SceneFactory* mSceneFactory;
InitializeThread* mInitializeThread;
AudioDirector* mAudioDirector;
};

} // namespace al
32 changes: 32 additions & 0 deletions tools/check-format.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,37 @@ def common_newline_eof(c, path):
def header_pragma_once(c, path):
CHECK(lambda a:a=="#pragma once", c.splitlines()[0], "Headers must start with \"#pragma once\"!", path)

def header_sorted_visibility(c, path):
visibilities_ordered = ["public:", "protected:", "private:"]
nest_level = [-1] # outermost for macro definitions
for line in c.splitlines():
line = line[0:line.find("//")] if "//" in line else line
if line.endswith("\\"): line = line[0:-1].rstrip()
if "{" in line and "}" in line:
if CHECK(lambda a:a.count("{")==a.count("}") or (a.lstrip().startswith("{") and a.endswith("}};")), line, "Unbalanced \"{\" and \"}\" in the same line! (exception: end of brace-initialized array)", path): return
if line.lstrip().startswith("{") and line.endswith("}};"):
del nest_level[-1]
continue

if CHECK(lambda a:[b for b in visibilities_ordered if b in a and a!=b]==[], line.strip(), "visibility modificator must be its own line!", path): return
if CHECK(lambda a:a.count("{")+a.count("}")<=1, line, "Only one \"{\" and \"}\" is allowed per line!", path): return

if line in visibilities_ordered:
i = visibilities_ordered.index(line)
if CHECK(lambda a:i>nest_level[-1], line, "Wrong order of visibilities: Must be public, protected, private!", path): return
nest_level[-1] = i
continue
elif "{" in line:
nest_level.append(-1)
elif "}" in line:
del nest_level[-1]

if len(nest_level) != 1:
print("ERROR: nest_level not empty at end of the file!")
print("nest_level", nest_level)
exit(1)



# Source files

Expand All @@ -107,6 +138,7 @@ def check_header(c, path):
common_newline_eof(c, path)
common_no_namespace_qualifiers(c, path)
header_pragma_once(c, path)
header_sorted_visibility(c, path)

def check_file(file_str):
file = open(file_str, mode="r")
Expand Down

0 comments on commit 0338057

Please sign in to comment.