From 25a2661d6daef0854040fde231e36d8e9e4cbae0 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Thu, 25 Jun 2015 11:22:23 -0700 Subject: [PATCH] Changed argument names in Objective-C generated code --- src/compiler/objective_c_generator.cc | 23 ++++++++++++++--------- src/objective-c/tests/InteropTests.m | 8 ++++---- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/compiler/objective_c_generator.cc b/src/compiler/objective_c_generator.cc index b235911479c..79a84b4a7a5 100644 --- a/src/compiler/objective_c_generator.cc +++ b/src/compiler/objective_c_generator.cc @@ -68,18 +68,19 @@ void PrintMethodSignature(Printer *printer, printer->Print(vars, "- ($return_type$)$method_name$With"); if (method->client_streaming()) { - printer->Print("RequestsWriter:(id)request"); + printer->Print("RequestsWriter:(id)requestWriter"); } else { printer->Print(vars, "Request:($request_class$ *)request"); } // TODO(jcanizales): Put this on a new line and align colons. - // TODO(jcanizales): eventHandler for server streaming? - printer->Print(" handler:(void(^)("); if (method->server_streaming()) { - printer->Print("BOOL done, "); + printer->Print(vars, " eventHandler:(void(^)(BOOL done, " + "$response_class$ *response, NSError *error))eventHandler"); + } else { + printer->Print(vars, " handler:(void(^)($response_class$ *response, " + "NSError *error))handler"); } - printer->Print(vars, "$response_class$ *response, NSError *error))handler"); } void PrintSimpleSignature(Printer *printer, @@ -125,11 +126,15 @@ void PrintSimpleImplementation(Printer *printer, printer->Print("{\n"); printer->Print(vars, " [[self RPCTo$method_name$With"); if (method->client_streaming()) { - printer->Print("RequestsWriter:request"); + printer->Print("RequestsWriter:requestWriter"); } else { printer->Print("Request:request"); } - printer->Print(" handler:handler] start];\n"); + if (method->server_streaming()) { + printer->Print(" eventHandler:eventHandler] start];\n"); + } else { + printer->Print(" handler:handler] start];\n"); + } printer->Print("}\n"); } @@ -141,7 +146,7 @@ void PrintAdvancedImplementation(Printer *printer, printer->Print(" requestsWriter:"); if (method->client_streaming()) { - printer->Print("request\n"); + printer->Print("requestWriter\n"); } else { printer->Print("[GRXWriter writerWithValue:request]\n"); } @@ -150,7 +155,7 @@ void PrintAdvancedImplementation(Printer *printer, printer->Print(" responsesWriteable:[GRXWriteable "); if (method->server_streaming()) { - printer->Print("writeableWithStreamHandler:handler]];\n"); + printer->Print("writeableWithStreamHandler:eventHandler]];\n"); } else { printer->Print("writeableWithSingleValueHandler:handler]];\n"); } diff --git a/src/objective-c/tests/InteropTests.m b/src/objective-c/tests/InteropTests.m index 684f7c2ff6f..74f6b231cfd 100644 --- a/src/objective-c/tests/InteropTests.m +++ b/src/objective-c/tests/InteropTests.m @@ -174,7 +174,7 @@ __block int index = 0; [_service streamingOutputCallWithRequest:request - handler:^(BOOL done, + eventHandler:^(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error){ XCTAssertNil(error, @"Finished with unexpected error: %@", error); @@ -211,7 +211,7 @@ [requestsBuffer writeValue:request]; [_service fullDuplexCallWithRequestsWriter:requestsBuffer - handler:^(BOOL done, + eventHandler:^(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error) { XCTAssertNil(error, @"Finished with unexpected error: %@", error); @@ -242,7 +242,7 @@ - (void)testEmptyStreamRPC { __weak XCTestExpectation *expectation = [self expectationWithDescription:@"EmptyStream"]; [_service fullDuplexCallWithRequestsWriter:[GRXWriter emptyWriter] - handler:^(BOOL done, + eventHandler:^(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error) { XCTAssertNil(error, @"Finished with unexpected error: %@", error); @@ -283,7 +283,7 @@ [requestsBuffer writeValue:request]; __block ProtoRPC *call = [_service RPCToFullDuplexCallWithRequestsWriter:requestsBuffer - handler:^(BOOL done, + eventHandler:^(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error) { if (receivedResponse) {