ObjFW  Diff

Differences From Artifact [0f410ad5c9]:

To Artifact [29f21ecbe7]:


84
85
86
87
88
89
90

91
92
93
94
95
96
97
	OFString *host;
	uint16_t port;
	id target;
	SEL selector;
#ifdef OF_HAVE_BLOCKS
	of_tcpsocket_async_connect_block_t connectBlock;
#endif

}

- initWithSourceThread: (OFThread*)sourceThread
		socket: (OFTCPSocket*)socket
		  host: (OFString*)host
		  port: (uint16_t)port
		target: (id)target







>







84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
	OFString *host;
	uint16_t port;
	id target;
	SEL selector;
#ifdef OF_HAVE_BLOCKS
	of_tcpsocket_async_connect_block_t connectBlock;
#endif
	OFException *exception;
}

- initWithSourceThread: (OFThread*)sourceThread
		socket: (OFTCPSocket*)socket
		  host: (OFString*)host
		  port: (uint16_t)port
		target: (id)target
159
160
161
162
163
164
165

166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192

193
194



195
196
197
198
199
200
201
	[sourceThread release];
	[sock release];
	[host release];
	[target release];
#ifdef OF_HAVE_BLOCKS
	[connectBlock release];
#endif


	[super dealloc];
}

- (void)didConnect
{
	[self join];

#ifdef OF_HAVE_BLOCKS
	if (connectBlock != NULL)
		connectBlock(sock);
	else {
#endif
		void (*func)(id, SEL, OFTCPSocket*) =
		    (void(*)(id, SEL, OFTCPSocket*))[target
		    methodForSelector: selector];

		func(target, selector, sock);
#ifdef OF_HAVE_BLOCKS
	}
#endif
}

- (id)main
{
	void *pool = objc_autoreleasePoolPush();


	[sock connectToHost: host
		       port: port];




	[self performSelector: @selector(didConnect)
		     onThread: sourceThread
		waitUntilDone: NO];

	objc_autoreleasePoolPop(pool);








>










|


|
|


|









>
|
|
>
>
>







160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
	[sourceThread release];
	[sock release];
	[host release];
	[target release];
#ifdef OF_HAVE_BLOCKS
	[connectBlock release];
#endif
	[exception release];

	[super dealloc];
}

- (void)didConnect
{
	[self join];

#ifdef OF_HAVE_BLOCKS
	if (connectBlock != NULL)
		connectBlock(sock, exception);
	else {
#endif
		void (*func)(id, SEL, OFTCPSocket*, OFException*) =
		    (void(*)(id, SEL, OFTCPSocket*, OFException*))[target
		    methodForSelector: selector];

		func(target, selector, sock, exception);
#ifdef OF_HAVE_BLOCKS
	}
#endif
}

- (id)main
{
	void *pool = objc_autoreleasePoolPush();

	@try {
		[sock connectToHost: host
			       port: port];
	} @catch (OFException *e) {
		exception = [[e retain] autorelease];
	}

	[self performSelector: @selector(didConnect)
		     onThread: sourceThread
		waitUntilDone: NO];

	objc_autoreleasePoolPop(pool);