ObjFW  Diff

Differences From Artifact [fa4bb596dc]:

To Artifact [a2a3075eb5]:


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
18
19
20
21
22
23
24




25
26
27
28
29
30
31







-
-
-
-







#include <string.h>

#import "OFInvocation.h"
#import "OFArray.h"
#import "OFData.h"
#import "OFMethodSignature.h"

#ifdef OF_INVOCATION_CAN_INVOKE
extern void of_invocation_invoke(OFInvocation *);
#endif

@implementation OFInvocation
@synthesize methodSignature = _methodSignature;

+ (instancetype)invocationWithMethodSignature: (OFMethodSignature *)signature
{
	return [[[self alloc] initWithMethodSignature: signature] autorelease];
}
48
49
50
51
52
53
54
55

56
57
58
59
60
61
62
63
64

65
66
67
68
69
70
71
44
45
46
47
48
49
50

51
52
53
54
55
56
57
58
59

60
61
62
63
64
65
66
67







-
+








-
+







		_arguments = [[OFMutableArray alloc] init];

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

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

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

		typeEncoding = _methodSignature.methodReturnType;
		typeSize = of_sizeof_type_encoding(typeEncoding);
		typeSize = OFSizeOfTypeEncoding(typeEncoding);

		if (typeSize > 0) {
			_returnValue = [[OFMutableData alloc]
			    initWithItemSize: typeSize
				    capacity: 1];
			[_returnValue increaseCountBy: 1];
		}
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
101
102
103
104
105
106
107







108







-
-
-
-
-
-
-

	memcpy(_returnValue.mutableItems, buffer, _returnValue.itemSize);
}

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

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