From 0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 14 May 2020 13:23:58 +0200 Subject: Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027. --- platform/iphone/in_app_store.mm | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'platform/iphone/in_app_store.mm') diff --git a/platform/iphone/in_app_store.mm b/platform/iphone/in_app_store.mm index c5a8ed2b2b..f3e8ff141b 100644 --- a/platform/iphone/in_app_store.mm +++ b/platform/iphone/in_app_store.mm @@ -80,7 +80,6 @@ void InAppStore::_bind_methods() { @implementation ProductsDelegate - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response { - NSArray *products = response.products; Dictionary ret; ret["type"] = "product_info"; @@ -93,7 +92,6 @@ void InAppStore::_bind_methods() { PackedStringArray currency_codes; for (NSUInteger i = 0; i < [products count]; i++) { - SKProduct *product = [products objectAtIndex:i]; const char *str = [product.localizedTitle UTF8String]; @@ -116,7 +114,6 @@ void InAppStore::_bind_methods() { PackedStringArray invalid_ids; for (NSString *ipid in response.invalidProductIdentifiers) { - invalid_ids.push_back(String::utf8([ipid UTF8String])); }; ret["invalid_ids"] = invalid_ids; @@ -129,7 +126,6 @@ void InAppStore::_bind_methods() { @end Error InAppStore::request_product_info(Variant p_params) { - Dictionary params = p_params; ERR_FAIL_COND_V(!params.has("product_ids"), ERR_INVALID_PARAMETER); @@ -155,7 +151,6 @@ Error InAppStore::request_product_info(Variant p_params) { }; Error InAppStore::restore_purchases() { - printf("restoring purchases!\n"); [[SKPaymentQueue defaultQueue] restoreCompletedTransactions]; @@ -169,10 +164,8 @@ Error InAppStore::restore_purchases() { @implementation TransObserver - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions { - printf("transactions updated!\n"); for (SKPaymentTransaction *transaction in transactions) { - switch (transaction.transactionState) { case SKPaymentTransactionStatePurchased: { printf("status purchased!\n"); @@ -189,11 +182,9 @@ Error InAppStore::restore_purchases() { int sdk_version = 6; if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) { - NSURL *receiptFileURL = nil; NSBundle *bundle = [NSBundle mainBundle]; if ([bundle respondsToSelector:@selector(appStoreReceiptURL)]) { - // Get the transaction receipt file path location in the app bundle. receiptFileURL = [bundle appStoreReceiptURL]; @@ -263,7 +254,6 @@ Error InAppStore::restore_purchases() { @end Error InAppStore::purchase(Variant p_params) { - ERR_FAIL_COND_V(![SKPaymentQueue canMakePayments], ERR_UNAVAILABLE); if (![SKPaymentQueue canMakePayments]) return ERR_UNAVAILABLE; @@ -286,7 +276,6 @@ int InAppStore::get_pending_event_count() { }; Variant InAppStore::pop_pending_event() { - Variant front = pending_events.front()->get(); pending_events.pop_front(); @@ -294,12 +283,10 @@ Variant InAppStore::pop_pending_event() { }; void InAppStore::_post_event(Variant p_event) { - pending_events.push_back(p_event); }; void InAppStore::_record_purchase(String product_id) { - String skey = "purchased/" + product_id; NSString *key = [[[NSString alloc] initWithUTF8String:skey.utf8().get_data()] autorelease]; [[NSUserDefaults standardUserDefaults] setBool:YES forKey:key]; @@ -307,7 +294,6 @@ void InAppStore::_record_purchase(String product_id) { }; InAppStore *InAppStore::get_singleton() { - return instance; }; -- cgit v1.2.3 From 07bc4e2f96f8f47991339654ff4ab16acc19d44f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 14 May 2020 14:29:06 +0200 Subject: Style: Enforce separation line between function definitions I couldn't find a tool that enforces it, so I went the manual route: ``` find -name "thirdparty" -prune \ -o -name "*.cpp" -o -name "*.h" -o -name "*.m" -o -name "*.mm" \ -o -name "*.glsl" > files perl -0777 -pi -e 's/\n}\n([^#])/\n}\n\n\1/g' $(cat files) misc/scripts/fix_style.sh -c ``` This adds a newline after all `}` on the first column, unless they are followed by `#` (typically `#endif`). This leads to having lots of places with two lines between function/class definitions, but clang-format then fixes it as we enforce max one line of separation. This doesn't fix potential occurrences of function definitions which are indented (e.g. for a helper class defined in a .cpp), but it's better than nothing. Also can't be made to run easily on CI/hooks so we'll have to be careful with new code. Part of #33027. --- platform/iphone/in_app_store.mm | 1 + 1 file changed, 1 insertion(+) (limited to 'platform/iphone/in_app_store.mm') diff --git a/platform/iphone/in_app_store.mm b/platform/iphone/in_app_store.mm index f3e8ff141b..a2efd6691b 100644 --- a/platform/iphone/in_app_store.mm +++ b/platform/iphone/in_app_store.mm @@ -57,6 +57,7 @@ NSMutableDictionary *pending_transactions = [NSMutableDictionary dictionary]; [numberFormatter release]; return formattedString; } + @end InAppStore *InAppStore::instance = NULL; -- cgit v1.2.3