/
GBMethodArgument.h
111 lines (83 loc) · 5.2 KB
/
GBMethodArgument.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//
// GBMethodArgument.h
// appledoc
//
// Created by Tomaz Kragelj on 26.7.10.
// Copyright (C) 2010, Gentle Bytes. All rights reserved.
//
#import <Foundation/Foundation.h>
/** Defines a single method argument. */
@interface GBMethodArgument : NSObject {
@private
NSString *_argumentName;
NSArray *_argumentTypes;
NSString *_argumentVar;
NSArray *_terminationMacros;
}
///---------------------------------------------------------------------------------------
/// @name Initialization & disposal
///---------------------------------------------------------------------------------------
/** Returns autoreleased method argument with the given parameters.
Internally this sends allocated instance `initWithName:types:var:terminationMacros:` message, so check it's documentation for details.
@param argument The name of the method argument, part of method selector.
@param types Array of argument types in the form of `NSString` instances or `nil` if not used.
@param var Array of arguments in the form of `GBMethodArgument` instances or `nil` if not used.
@param macros Array of variable arg termination macros or `nil` if not variable arg.
@return Returns initialized object or `nil` if initialization fails.
@exception NSException Thrown if either of the given parameters is invalid.
@see initWithName:types:var:
*/
+ (id)methodArgumentWithName:(NSString *)name types:(NSArray *)types var:(NSString *)var terminationMacros:(NSArray *)macros;
/** Returns autoreleased method argument with the given parameters.
Internally this sends allocated instance `initWithName:types:var:terminationMacros:` message, so check it's documentation for details.
@param argument The name of the method argument, part of method selector.
@param types Array of argument types in the form of `NSString` instances or `nil` if not used.
@param var Array of arguments in the form of `GBMethodArgument` instances or `nil` if not used.
@return Returns initialized object or `nil` if initialization fails.
@exception NSException Thrown if either of the given parameters is invalid.
@see initWithName:types:var:
*/
+ (id)methodArgumentWithName:(NSString *)name types:(NSArray *)types var:(NSString *)var;
/** Returns autoreleased type-less method argument.
Internally this sends allocated instance `initWithName:types:var:terminationMacros:` message, so check it's documentation for details.
@param argument The name of the method argument, part of method selector.
@return Returns initialized object or `nil` if initialization fails.
@exception NSException Thrown if the argument is `nil` or empty string.
@see initWithName:
*/
+ (id)methodArgumentWithName:(NSString *)name;
/** Initializes method argument with the given parameters.
This is the designated initializer. You can either use it to specify method argument with all parameters, in such case you must supply all parameters, or you can use it to specify method argument without type. In such case you should set types and var to `nil`. If the argument is variable arg type, you should pass in optional termination macros or empty array if no termination macro is used. To specify standard argument, pass `nil` for termination macros instead!
@warning *Note:* If you use the selector for type-less argument, both initializer parameters - types and var must be `nil`. If only one of these is `nil`, exception is thrown.
@param argument The name of the method argument, part of method selector.
@param types Array of argument types in the form of `NSString` instances or `nil` if not used.
@param var Array of arguments in the form of `GBMethodArgument` instances or `nil` if not used.
@param macros Array of variable arg termination macros or `nil` if not variable arg.
@return Returns initialized object or `nil` if initialization fails.
@exception NSException Thrown if either of the given parameters is invalid.
*/
- (id)initWithName:(NSString *)argument types:(NSArray *)types var:(NSString *)var terminationMacros:(NSArray *)macros;
///---------------------------------------------------------------------------------------
/// @name Argument data
///---------------------------------------------------------------------------------------
/** The name of the argument.
Argument is part of method selector and defines -(result)*arg*:(type)var part of method.
*/
@property (readonly) NSString *argumentName;
/** Array of argument types.
Types array define -(result)arg:(*type*)var part of method. If argument doesn't use types, this is `nil`.
*/
@property (readonly) NSArray *argumentTypes;
/** The name of the argument variable.
Argument variable defines -(result)arg:(type)*var* part of method. If argument doesn't use variable, this is `nil`.
*/
@property (readonly) NSString *argumentVar;
/** Array of variable arguments termination macros.
Termination macros array define -(result)arg:(type)var,...*macros* part of method. If argument isn't variable or doesn't have termination macros, this is `nil`.
*/
@property (readonly) NSArray *terminationMacros;
/** Specifies whether the argument is typed or not. The argument is typed if it uses type and var. */
@property (readonly) BOOL isTyped;
/** Specifies whether the argument is variable arg or not. */
@property (assign) BOOL isVariableArg;
@end