Skip to content

Commit

Permalink
Refactor count-handwritten-decoders to make it easier to add exclusio…
Browse files Browse the repository at this point in the history
…ns (and add a few more exclusions)

https://bugs.webkit.org/show_bug.cgi?id=265428
rdar://118865137

Reviewed by Alex Christensen.

When adding some more exclusions, I got tired of the thrown together way of adding exclusions.
So I made it easier to add exclusions.

Also rename to count-handwritten-decoders-cocoa to represent the target platforms.

* Tools/Scripts/count-handwritten-decoders:

Canonical link: https://commits.webkit.org/271237@main
  • Loading branch information
beidson committed Nov 28, 2023
1 parent 61aa265 commit 26e8252
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 16 deletions.
46 changes: 46 additions & 0 deletions Tools/Scripts/count-handwritten-cocoa-decoders
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/sh
#
# This script scans Source for certain types of handwritten serialization logic and provides a count
#

cd "$(dirname "$0")/../../Source/"

exclusions_array=(
"Scripts/webkit/tests"
"generate-serializers.py"
"WTF/wtf/ArgumentCoder.h"
"JavaScriptCore/runtime/CachedTypes.cpp"
"gtk"
"glib"
"IPC/win"
"IPC/unix"
"IPC/DaemonCoders.cpp"
"win/WebCoreArgumentCodersWin.cpp"
"Cocoa/ArgumentCodersCocoa.h"
"Cocoa/CoreIPCNSCFObject.h"
"WebCore/platform/graphics/gbm"
);

exclusions_string="";

for ((i = 0; i < ${#exclusions_array[@]}; i++))
do
exclusions_string+="grep -vi ";
exclusions_string+=${exclusions_array[$i]};
exclusions_string+=" | ";
done

exclusions_and_count_string="$exclusions_string wc -l | xargs";

optionalsString="grep -riE \"> decode\((Decoder|IPC::Decoder)\" . | $exclusions_and_count_string";
boolsString="grep -riE \"bool decode\((Decoder|IPC::Decoder)\" . | $exclusions_and_count_string";

enumtraits=$(grep -ri "struct EnumTraits<" | wc -l | xargs);
optionals=$(eval "$optionalsString");
bools=$(eval "$boolsString");

echo "EnumTraits remaining: $enumtraits"
echo "Decoders that return std::optional<>: $optionals"
echo "Legacy decoders that return bool: $bools"
sum=$(($optionals+$bools))
echo "Total decoders remaining: $sum"
16 changes: 0 additions & 16 deletions Tools/Scripts/count-handwritten-decoders

This file was deleted.

0 comments on commit 26e8252

Please sign in to comment.