ObjFW  Diff

Differences From Artifact [df81aa2e85]:

To Artifact [a9afe182d2]:


38
39
40
41
42
43
44
45

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

66
67
68
69
70
71
72
38
39
40
41
42
43
44

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64

65
66
67
68
69
70
71
72







-
+



















-
+








- (instancetype)initWithMethodSignature: (OFMethodSignature *)signature
{
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();
		size_t numberOfArguments = [signature numberOfArguments];
		size_t numberOfArguments = signature.numberOfArguments;
		const char *typeEncoding;
		size_t typeSize;

		_methodSignature = [signature retain];
		_arguments = [[OFMutableArray alloc] init];

		for (size_t i = 0; i < numberOfArguments; i++) {
			OFMutableData *data;

			typeEncoding = [_methodSignature
			    argumentTypeAtIndex: i];
			typeSize = of_sizeof_type_encoding(typeEncoding);

			data = [OFMutableData dataWithItemSize: typeSize
						      capacity: 1];
			[data increaseCountBy: 1];
			[_arguments addObject: data];
		}

		typeEncoding = [_methodSignature methodReturnType];
		typeEncoding = _methodSignature.methodReturnType;
		typeSize = of_sizeof_type_encoding(typeEncoding);

		if (typeSize > 0) {
			_returnValue = [[OFMutableData alloc]
			    initWithItemSize: typeSize
				    capacity: 1];
			[_returnValue increaseCountBy: 1];
91
92
93
94
95
96
97
98

99
100
101
102
103
104
105
106

107
108
109
110
111

112
113
114
115
116

117
118
119
120
121
122
123
124
125
91
92
93
94
95
96
97

98
99
100
101
102
103
104
105

106
107
108
109
110

111
112
113
114
115

116
117
118
119
120
121
122
123
124
125







-
+







-
+




-
+




-
+









}

- (void)setArgument: (const void *)buffer
	    atIndex: (size_t)idx
{
	OFMutableData *data = [_arguments objectAtIndex: idx];

	memcpy([data items], buffer, [data itemSize]);
	memcpy(data.mutableItems, buffer, data.itemSize);
}

- (void)getArgument: (void *)buffer
	    atIndex: (size_t)idx
{
	OFData *data = [_arguments objectAtIndex: idx];

	memcpy(buffer, [data items], [data itemSize]);
	memcpy(buffer, data.items, data.itemSize);
}

- (void)setReturnValue: (const void *)buffer
{
	memcpy([_returnValue items], buffer, [_returnValue itemSize]);
	memcpy(_returnValue.mutableItems, buffer, _returnValue.itemSize);
}

- (void)getReturnValue: (void *)buffer
{
	memcpy(buffer, [_returnValue items], [_returnValue itemSize]);
	memcpy(buffer, _returnValue.items, _returnValue.itemSize);
}

#ifdef OF_INVOCATION_CAN_INVOKE
- (void)invoke
{
	of_invocation_invoke(self);
}
#endif
@end