Skip to content

Commit

Permalink
Code Format using clang-format's Google style defaults. (#383)
Browse files Browse the repository at this point in the history
Updated codebase using clang-format's Google style basis without any further one-off customizations.

Clang-format seemingly. does some odd things to objective-c files.  Therefore directories known to contain objective-c files are ignored by defining a local .clang-format file which disables clang-format. Objective C .mm files are ignored in mixed-language directories, and Obj-C headers are detected by the format_code.py script which search for Obj-c language tags.
  • Loading branch information
DellaBitta authored Apr 22, 2021
1 parent f3ec436 commit b43e145
Show file tree
Hide file tree
Showing 460 changed files with 1,589 additions and 1,532 deletions.
9 changes: 0 additions & 9 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
BasedOnStyle: Google
Standard: Cpp11
ColumnLimit: 80
BinPackParameters: false
AllowAllParametersOfDeclarationOnNextLine: true
SpacesInContainerLiterals: true
DerivePointerAlignment: false
PointerAlignment: Left
AllowShortFunctionsOnASingleLine: None
IncludeBlocks: Preserve
4 changes: 2 additions & 2 deletions admob/integration_test/src/integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,8 @@ TEST_F(FirebaseAdMobTest, TestRewardedVideoAd) {
// Test runs & compiles for phones only.

struct ThreadArgs {
firebase::admob::BannerView* banner;
sem_t* semaphore;
firebase::admob::BannerView* banner;
sem_t* semaphore;
};

static void* DeleteBannerViewOnSignal(void* args) {
Expand Down
46 changes: 27 additions & 19 deletions admob/src/android/ad_request_converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
* limitations under the License.
*/

#include "admob/src/android/ad_request_converter.h"

#include <assert.h>
#include <jni.h>

#include <cstdarg>
#include <cstddef>

#include "admob/admob_resources.h"
#include "admob/src/android/ad_request_converter.h"
#include "admob/src/android/admob_android.h"
#include "admob/src/common/admob_common.h"
#include "admob/src/include/firebase/admob.h"
Expand All @@ -35,7 +36,8 @@ namespace admob {
static const char* kAdMobAdapterClassName =
"com/google/ads/mediation/admob/AdMobAdapter";

METHOD_LOOKUP_DEFINITION(ad_request_builder, PROGUARD_KEEP_CLASS
METHOD_LOOKUP_DEFINITION(ad_request_builder,
PROGUARD_KEEP_CLASS
"com/google/android/gms/ads/AdRequest$Builder",
ADREQUESTBUILDER_METHODS);

Expand All @@ -54,18 +56,20 @@ AdRequestConverter::AdRequestConverter(AdRequest request) {

builder = util::ContinueBuilder(
env, builder,
env->CallObjectMethod(builder, ad_request_builder::GetMethodId(
ad_request_builder::kSetGender),
static_cast<int>(request.gender)));
env->CallObjectMethod(
builder,
ad_request_builder::GetMethodId(ad_request_builder::kSetGender),
static_cast<int>(request.gender)));

// Child-drected treatment.
if (request.tagged_for_child_directed_treatment !=
kChildDirectedTreatmentStateUnknown) {
builder = util::ContinueBuilder(
env, builder,
env->CallObjectMethod(
builder, ad_request_builder::GetMethodId(
ad_request_builder::kTagForChildDirectedTreatment),
builder,
ad_request_builder::GetMethodId(
ad_request_builder::kTagForChildDirectedTreatment),
(request.tagged_for_child_directed_treatment ==
kChildDirectedTreatmentStateTagged)));
}
Expand All @@ -75,9 +79,10 @@ AdRequestConverter::AdRequestConverter(AdRequest request) {
jstring test_device_str = env->NewStringUTF(request.test_device_ids[i]);
builder = util::ContinueBuilder(
env, builder,
env->CallObjectMethod(builder, ad_request_builder::GetMethodId(
ad_request_builder::kAddTestDevice),
test_device_str));
env->CallObjectMethod(
builder,
ad_request_builder::GetMethodId(ad_request_builder::kAddTestDevice),
test_device_str));
env->DeleteLocalRef(test_device_str);
}

Expand All @@ -86,9 +91,10 @@ AdRequestConverter::AdRequestConverter(AdRequest request) {
jstring keyword_str = env->NewStringUTF(request.keywords[i]);
builder = util::ContinueBuilder(
env, builder,
env->CallObjectMethod(builder, ad_request_builder::GetMethodId(
ad_request_builder::kAddKeyword),
keyword_str));
env->CallObjectMethod(
builder,
ad_request_builder::GetMethodId(ad_request_builder::kAddKeyword),
keyword_str));
env->DeleteLocalRef(keyword_str);
}

Expand All @@ -109,9 +115,10 @@ AdRequestConverter::AdRequestConverter(AdRequest request) {
if (date_ref != nullptr) {
builder = util::ContinueBuilder(
env, builder,
env->CallObjectMethod(builder, ad_request_builder::GetMethodId(
ad_request_builder::kSetBirthday),
date_ref));
env->CallObjectMethod(
builder,
ad_request_builder::GetMethodId(ad_request_builder::kSetBirthday),
date_ref));
} else {
LogWarning(
"Skipping invalid AdRequest birthday fields (Y: %d, M: %d, D: %d).",
Expand Down Expand Up @@ -164,9 +171,10 @@ AdRequestConverter::AdRequestConverter(AdRequest request) {
env->NewStringUTF(firebase::admob::GetRequestAgentString());
builder = util::ContinueBuilder(
env, builder,
env->CallObjectMethod(builder, ad_request_builder::GetMethodId(
ad_request_builder::kSetRequestAgent),
agent_str));
env->CallObjectMethod(
builder,
ad_request_builder::GetMethodId(ad_request_builder::kSetRequestAgent),
agent_str));
env->DeleteLocalRef(agent_str);

// Build request and load ad.
Expand Down
6 changes: 2 additions & 4 deletions admob/src/android/banner_view_internal_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,9 @@ BannerViewInternalAndroid::BannerViewInternalAndroid(BannerView* base)
env->DeleteLocalRef(helper_ref);
}


void DestroyOnDeleteCallback(const Future<void>& result,
void* sem_data) {
void DestroyOnDeleteCallback(const Future<void>& result, void* sem_data) {
if (sem_data != nullptr) {
Semaphore* semaphore = static_cast<Semaphore*>(sem_data);
Semaphore* semaphore = static_cast<Semaphore*>(sem_data);
semaphore->Post();
}
}
Expand Down
3 changes: 2 additions & 1 deletion admob/src/android/interstitial_ad_internal_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

#include "admob/src/android/interstitial_ad_internal_android.h"

#include <assert.h>
#include <jni.h>

Expand All @@ -23,7 +25,6 @@
#include "admob/admob_resources.h"
#include "admob/src/android/ad_request_converter.h"
#include "admob/src/android/admob_android.h"
#include "admob/src/android/interstitial_ad_internal_android.h"
#include "admob/src/common/admob_common.h"
#include "admob/src/include/firebase/admob.h"
#include "admob/src/include/firebase/admob/interstitial_ad.h"
Expand Down
23 changes: 14 additions & 9 deletions admob/src/android/native_express_ad_view_internal_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

#include "admob/src/android/native_express_ad_view_internal_android.h"

#include <assert.h>
#include <jni.h>

Expand All @@ -23,7 +25,6 @@
#include "admob/admob_resources.h"
#include "admob/src/android/ad_request_converter.h"
#include "admob/src/android/admob_android.h"
#include "admob/src/android/native_express_ad_view_internal_android.h"
#include "admob/src/common/admob_common.h"
#include "admob/src/include/firebase/admob.h"
#include "admob/src/include/firebase/admob/native_express_ad_view.h"
Expand Down Expand Up @@ -91,8 +92,9 @@ Future<void> NativeExpressAdViewInternalAndroid::Initialize(

jstring ad_unit_id_str = env->NewStringUTF(ad_unit_id);

env->CallVoidMethod(helper_, native_express_ad_view_helper::GetMethodId(
native_express_ad_view_helper::kInitialize),
env->CallVoidMethod(helper_,
native_express_ad_view_helper::GetMethodId(
native_express_ad_view_helper::kInitialize),
reinterpret_cast<jlong>(callback_data), activity,
ad_unit_id_str, static_cast<jint>(size.ad_size_type),
static_cast<jint>(size.width),
Expand All @@ -112,8 +114,9 @@ Future<void> NativeExpressAdViewInternalAndroid::LoadAd(
jobject request_ref = converter.GetJavaRequestObject();

::firebase::admob::GetJNI()->CallVoidMethod(
helper_, native_express_ad_view_helper::GetMethodId(
native_express_ad_view_helper::kLoadAd),
helper_,
native_express_ad_view_helper::GetMethodId(
native_express_ad_view_helper::kLoadAd),
reinterpret_cast<jlong>(callback_data), request_ref);

return GetLastResult(kNativeExpressAdViewFnLoadAd);
Expand Down Expand Up @@ -151,8 +154,9 @@ Future<void> NativeExpressAdViewInternalAndroid::MoveTo(int x, int y) {
CreateFutureCallbackData(&future_data_, kNativeExpressAdViewFnMoveTo);

::firebase::admob::GetJNI()->CallVoidMethod(
helper_, native_express_ad_view_helper::GetMethodId(
native_express_ad_view_helper::kMoveToXY),
helper_,
native_express_ad_view_helper::GetMethodId(
native_express_ad_view_helper::kMoveToXY),
reinterpret_cast<jlong>(callback_data), x, y);

return GetLastResult(kNativeExpressAdViewFnMoveTo);
Expand All @@ -164,8 +168,9 @@ Future<void> NativeExpressAdViewInternalAndroid::MoveTo(
CreateFutureCallbackData(&future_data_, kNativeExpressAdViewFnMoveTo);

::firebase::admob::GetJNI()->CallVoidMethod(
helper_, native_express_ad_view_helper::GetMethodId(
native_express_ad_view_helper::kMoveToPosition),
helper_,
native_express_ad_view_helper::GetMethodId(
native_express_ad_view_helper::kMoveToPosition),
reinterpret_cast<jlong>(callback_data), static_cast<int>(position));

return GetLastResult(kNativeExpressAdViewFnMoveTo);
Expand Down
10 changes: 6 additions & 4 deletions admob/src/android/rewarded_video_internal_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
* limitations under the License.
*/

#include "admob/src/android/rewarded_video_internal_android.h"

#include <assert.h>
#include <jni.h>

#include "admob/admob_resources.h"
#include "admob/src/android/ad_request_converter.h"
#include "admob/src/android/admob_android.h"
#include "admob/src/android/rewarded_video_internal_android.h"
#include "admob/src/common/rewarded_video_internal.h"
#include "admob/src/include/firebase/admob/rewarded_video.h"
#include "admob/src/include/firebase/admob/types.h"
Expand Down Expand Up @@ -66,9 +67,10 @@ Future<void> RewardedVideoInternalAndroid::Initialize() {

JNIEnv* env = ::firebase::admob::GetJNI();

env->CallVoidMethod(helper_, rewarded_video_helper::GetMethodId(
rewarded_video_helper::kInitialize),
reinterpret_cast<jlong>(callback_data));
env->CallVoidMethod(
helper_,
rewarded_video_helper::GetMethodId(rewarded_video_helper::kInitialize),
reinterpret_cast<jlong>(callback_data));

return GetLastResult(kRewardedVideoFnInitialize);
}
Expand Down
26 changes: 14 additions & 12 deletions admob/src/common/admob_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "admob/src/common/admob_common.h"

#include <assert.h>

#include <vector>

#include "admob/src/include/firebase/admob.h"
Expand All @@ -28,18 +29,19 @@
#include "app/src/include/firebase/version.h"
#include "app/src/util.h"

FIREBASE_APP_REGISTER_CALLBACKS(admob,
{
if (app == ::firebase::App::GetInstance()) {
return firebase::admob::Initialize(*app);
}
return kInitResultSuccess;
},
{
if (app == ::firebase::App::GetInstance()) {
firebase::admob::Terminate();
}
});
FIREBASE_APP_REGISTER_CALLBACKS(
admob,
{
if (app == ::firebase::App::GetInstance()) {
return firebase::admob::Initialize(*app);
}
return kInitResultSuccess;
},
{
if (app == ::firebase::App::GetInstance()) {
firebase::admob::Terminate();
}
});

namespace firebase {
namespace admob {
Expand Down
1 change: 1 addition & 0 deletions admob/src/common/admob_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define FIREBASE_ADMOB_CLIENT_CPP_SRC_COMMON_ADMOB_COMMON_H_

#include <stdarg.h>

#include <vector>

#include "app/src/cleanup_notifier.h"
Expand Down
1 change: 1 addition & 0 deletions admob/src/common/banner_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#include "admob/src/include/firebase/admob/banner_view.h"

#include "admob/src/common/admob_common.h"
#include "admob/src/common/banner_view_internal.h"
#include "app/src/assert.h"
Expand Down
1 change: 1 addition & 0 deletions admob/src/common/interstitial_ad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#include "admob/src/include/firebase/admob/interstitial_ad.h"

#include "admob/src/common/admob_common.h"
#include "admob/src/common/interstitial_ad_internal.h"
#include "app/src/assert.h"
Expand Down
1 change: 1 addition & 0 deletions admob/src/common/native_express_ad_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#include "admob/src/include/firebase/admob/native_express_ad_view.h"

#include "admob/src/common/admob_common.h"
#include "admob/src/common/native_express_ad_view_internal.h"
#include "app/src/include/firebase/future.h"
Expand Down
1 change: 1 addition & 0 deletions admob/src/common/rewarded_video.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#include "admob/src/include/firebase/admob/rewarded_video.h"

#include "admob/src/common/admob_common.h"
#include "admob/src/common/rewarded_video_internal.h"
#include "app/src/assert.h"
Expand Down
2 changes: 2 additions & 0 deletions admob/src/ios/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DisableFormat: true
SortIncludes: false
4 changes: 1 addition & 3 deletions admob/src/stub/banner_view_internal_stub.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ class BannerViewInternalStub : public BannerViewInternal {
return BannerView::PresentationState::kPresentationStateHidden;
}

BoundingBox GetBoundingBox() const override {
return BoundingBox();
}
BoundingBox GetBoundingBox() const override { return BoundingBox(); }

private:
Future<void> CreateAndCompleteFutureStub(BannerViewFn fn) {
Expand Down
2 changes: 2 additions & 0 deletions analytics/ios_headers/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DisableFormat: true
SortIncludes: false
6 changes: 3 additions & 3 deletions analytics/src/analytics_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,9 @@ Future<std::string> GetAnalyticsInstanceId() {
FutureHandle handle(future_id);
future_data->api()->CompleteWithResult(
handle, success ? 0 : -1,
success ? ""
: status_message ? status_message
: "Unknown error occurred",
success ? ""
: status_message ? status_message
: "Unknown error occurred",
// Both JStringToString and GetMessageFromException are
// able to handle a nullptr being passed in, and neither
// deletes the object passed in (so delete it below).
Expand Down
Loading

0 comments on commit b43e145

Please sign in to comment.