aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMirko Bonadei <mbonadei@webrtc.org>2020-07-16 21:57:01 +0200
committerCommit Bot <commit-bot@chromium.org>2020-07-17 09:57:50 +0000
commitd74c0e600a7f5bc43c2bcb75d4903b3038677459 (patch)
tree956d93f9e3dca083de90281b7cb7636b1b85fc0f
parent3cb525b378fd9cb683b19b0d5f18946a85fdef34 (diff)
downloadwebrtc-d74c0e600a7f5bc43c2bcb75d4903b3038677459.tar.gz
Add presubmit test to use RTC_OBJC_TYPE on RTC_OBJC_EXPORT types.
Bug: None Change-Id: I0962cadbcf7db920b5e400b80cfd04c937cdcedc Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/179524 Reviewed-by: Kári Helgason <kthelgason@webrtc.org> Reviewed-by: Tommi <tommi@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31755}
-rwxr-xr-xPRESUBMIT.py31
-rw-r--r--sdk/objc/api/peerconnection/RTCRtpSender.h4
2 files changed, 33 insertions, 2 deletions
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 47a1be68f7..b5d4534c0b 100755
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -941,6 +941,8 @@ def CommonChecks(input_api, output_api):
input_api, output_api, non_third_party_sources))
results.extend(CheckBannedAbslMakeUnique(
input_api, output_api, non_third_party_sources))
+ results.extend(CheckObjcApiSymbols(
+ input_api, output_api, non_third_party_sources))
return results
@@ -1017,6 +1019,35 @@ def CheckBannedAbslMakeUnique(input_api, output_api, source_file_filter):
files)]
return []
+def CheckObjcApiSymbols(input_api, output_api, source_file_filter):
+ rtc_objc_export = re.compile(r'RTC_OBJC_EXPORT(.|\n){26}',
+ re.MULTILINE | re.DOTALL)
+ file_filter = lambda f: (f.LocalPath().endswith(('.h'))
+ and source_file_filter(f))
+
+ files = []
+ file_filter = lambda x: (input_api.FilterSourceFile(x)
+ and source_file_filter(x))
+ for f in input_api.AffectedSourceFiles(file_filter):
+ if not f.LocalPath().endswith('.h') or not 'sdk/objc' in f.LocalPath():
+ continue
+ contents = input_api.ReadFile(f)
+ for match in rtc_objc_export.finditer(contents):
+ export_block = match.group(0)
+ if 'RTC_OBJC_TYPE' not in export_block:
+ files.append(f.LocalPath())
+
+ if len(files):
+ return [output_api.PresubmitError(
+ 'RTC_OBJC_EXPORT types must be wrapped into an RTC_OBJC_TYPE() ' +
+ 'macro.\n\n' +
+ 'For example:\n' +
+ 'RTC_OBJC_EXPORT @protocol RTC_OBJC_TYPE(RtcFoo)\n\n' +
+ 'RTC_OBJC_EXPORT @interface RTC_OBJC_TYPE(RtcFoo)\n\n' +
+ 'Please fix the following files:',
+ files)]
+ return []
+
def CheckAbslMemoryInclude(input_api, output_api, source_file_filter):
pattern = input_api.re.compile(
r'^#include\s*"absl/memory/memory.h"', input_api.re.MULTILINE)
diff --git a/sdk/objc/api/peerconnection/RTCRtpSender.h b/sdk/objc/api/peerconnection/RTCRtpSender.h
index 41bb083d2e..fcdf199869 100644
--- a/sdk/objc/api/peerconnection/RTCRtpSender.h
+++ b/sdk/objc/api/peerconnection/RTCRtpSender.h
@@ -21,8 +21,8 @@ RTC_OBJC_EXPORT
@protocol RTC_OBJC_TYPE
(RTCRtpSender)<NSObject>
- /** A unique identifier for this sender. */
- @property(nonatomic, readonly) NSString *senderId;
+/** A unique identifier for this sender. */
+@property(nonatomic, readonly) NSString *senderId;
/** The currently active RTCRtpParameters, as defined in
* https://www.w3.org/TR/webrtc/#idl-def-RTCRtpParameters.