Skip to content

Commit ed76ae8

Browse files
authored
Merge pull request #213 from grpc/podspec-validation
Fix a few problems found running "pod spec lint".
2 parents 1a9f7e2 + 36ea2c6 commit ed76ae8

File tree

11 files changed

+46
-52
lines changed

11 files changed

+46
-52
lines changed

Sources/CgRPC/shim/call.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void cgrpc_call_destroy(cgrpc_call *call) {
2727
free(call);
2828
}
2929

30-
grpc_call_error cgrpc_call_perform(cgrpc_call *call, cgrpc_operations *operations, int64_t tag) {
30+
grpc_call_error cgrpc_call_perform(cgrpc_call *call, cgrpc_operations *operations, void *tag) {
3131
grpc_call_error error = grpc_call_start_batch(call->call,
3232
operations->ops,
3333
operations->ops_count,

Sources/CgRPC/shim/cgrpc.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,14 @@ cgrpc_completion_queue *cgrpc_handler_get_completion_queue(cgrpc_handler *h);
172172

173173
grpc_call_error cgrpc_handler_request_call(cgrpc_handler *h,
174174
cgrpc_metadata_array *metadata,
175-
long tag);
175+
void *tag);
176176
char *cgrpc_handler_copy_host(cgrpc_handler *h);
177177
char *cgrpc_handler_copy_method(cgrpc_handler *h);
178178
char *cgrpc_handler_call_peer(cgrpc_handler *h);
179179

180180
// call support
181181
void cgrpc_call_destroy(cgrpc_call *call);
182-
grpc_call_error cgrpc_call_perform(cgrpc_call *call, cgrpc_operations *operations, int64_t tag);
182+
grpc_call_error cgrpc_call_perform(cgrpc_call *call, cgrpc_operations *operations, void *tag);
183183
void cgrpc_call_cancel(cgrpc_call *call);
184184

185185
// operations
@@ -209,7 +209,7 @@ cgrpc_byte_buffer *cgrpc_byte_buffer_create_by_copying_data(const void *source,
209209
const void *cgrpc_byte_buffer_copy_data(cgrpc_byte_buffer *bb, size_t *length);
210210

211211
// event support
212-
int64_t cgrpc_event_tag(grpc_event ev);
212+
void *cgrpc_event_tag(grpc_event ev);
213213

214214
// observers
215215

Sources/CgRPC/shim/event.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
#include "internal.h"
1717
#include "cgrpc.h"
1818

19-
int64_t cgrpc_event_tag(grpc_event ev) {
20-
return (int64_t) ev.tag;
19+
void *cgrpc_event_tag(grpc_event ev) {
20+
return ev.tag;
2121
}

Sources/CgRPC/shim/handler.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ cgrpc_completion_queue *cgrpc_handler_get_completion_queue(cgrpc_handler *h) {
7777

7878
grpc_call_error cgrpc_handler_request_call(cgrpc_handler *h,
7979
cgrpc_metadata_array *metadata,
80-
long tag) {
80+
void *tag) {
8181
if (h->server_call != NULL) {
8282
return GRPC_CALL_OK;
8383
}

Sources/CgRPC/shim/internal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include <stdio.h>
2020
#include <assert.h>
2121

22-
void *cgrpc_create_tag(intptr_t t) { return (void *)t; }
22+
void *cgrpc_create_tag(void *t) { return t; }
2323

2424
gpr_timespec cgrpc_deadline_in_seconds_from_now(float seconds) {
2525
return gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),

Sources/CgRPC/shim/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ typedef struct {
105105
} cgrpc_observer_recv_close_on_server;
106106

107107
// internal utilities
108-
void *cgrpc_create_tag(intptr_t t);
108+
void *cgrpc_create_tag(void *t);
109109
gpr_timespec cgrpc_deadline_in_seconds_from_now(float seconds);
110110

111111
void cgrpc_observer_apply(cgrpc_observer *observer, grpc_op *op);

Sources/SwiftGRPC/Core/Call.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public class Call {
8888
Call.callMutex.lock()
8989
// We need to do the perform *inside* the `completionQueue.register` call, to ensure that the queue can't get
9090
// shutdown in between registering the operation group and calling `cgrpc_call_perform`.
91-
let error = cgrpc_call_perform(underlyingCall, operations.underlyingOperations, operations.tag)
91+
let error = cgrpc_call_perform(underlyingCall, operations.underlyingOperations, UnsafeMutableRawPointer(bitPattern:operations.tag))
9292
Call.callMutex.unlock()
9393
if error != GRPC_CALL_OK {
9494
throw CallError.callError(grpcCallError: error)

Sources/SwiftGRPC/Core/CompletionQueue.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ enum CompletionType {
4444
struct CompletionQueueEvent {
4545
let type: CompletionType
4646
let success: Int32
47-
let tag: Int64
47+
let tag: Int
4848

4949
init(_ event: grpc_event) {
5050
type = CompletionType.completionType(event.type)
5151
success = event.success
52-
tag = cgrpc_event_tag(event)
52+
tag = Int(bitPattern: cgrpc_event_tag(event))
5353
}
5454
}
5555

@@ -62,7 +62,7 @@ class CompletionQueue {
6262
private let underlyingCompletionQueue: UnsafeMutableRawPointer
6363

6464
/// Operation groups that are awaiting completion, keyed by tag
65-
private var operationGroups: [Int64: OperationGroup] = [:]
65+
private var operationGroups: [Int: OperationGroup] = [:]
6666

6767
/// Mutex for synchronizing access to operationGroups
6868
private let operationGroupsMutex: Mutex = Mutex()
@@ -118,7 +118,7 @@ class CompletionQueue {
118118
let event = cgrpc_completion_queue_get_next_event(self.underlyingCompletionQueue, 600)
119119
switch event.type {
120120
case GRPC_OP_COMPLETE:
121-
let tag = cgrpc_event_tag(event)
121+
let tag = Int(bitPattern:cgrpc_event_tag(event))
122122
self.operationGroupsMutex.lock()
123123
let operationGroup = self.operationGroups[tag]
124124
self.operationGroupsMutex.unlock()

Sources/SwiftGRPC/Core/Handler.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public class Handler {
8181
/// Fills the handler properties with information about the received request
8282
///
8383
func requestCall(tag: Int) throws {
84-
let error = cgrpc_handler_request_call(underlyingHandler, requestMetadata.underlyingArray, tag)
84+
let error = cgrpc_handler_request_call(underlyingHandler, requestMetadata.underlyingArray, UnsafeMutableRawPointer(bitPattern: tag))
8585
if error != GRPC_CALL_OK {
8686
throw CallError.callError(grpcCallError: error)
8787
}

Sources/SwiftGRPC/Core/OperationGroup.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ class OperationGroup {
2323
static let tagMutex = Mutex()
2424

2525
/// Used to generate unique tags for OperationGroups
26-
private static var nextTag: Int64 = 1
26+
private static var nextTag: Int = 1
2727

2828
/// Automatically-assigned tag that is used by the completion queue that watches this group.
29-
let tag: Int64
29+
let tag: Int
3030

3131
/// The call associated with the operation group. Retained while the operations are running.
3232
// FIXME(danielalm): Is this property needed?

0 commit comments

Comments
 (0)