46589c9763956cce4e6a59b8cafa010649da1b57
[nit.git] / contrib / objcwrapper / src / objc_model.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 # Model of the parsed Objective-C files
16 module objc_model
17
18 # Model of all the analyzed Objective-C classes
19 class ObjcModel
20 # All analyzed classes
21 var classes = new Array[ObjcClass]
22 end
23
24 # Objective-C class
25 class ObjcClass
26 # Name of the super classes
27 var super_names = new Array[String]
28
29 # Name of this Objective-C class
30 var name: String
31
32 # Attributes of this Objective-C class
33 var attributes = new Array[ObjcAttribute]
34
35 # Methods of this Objective-C class
36 var methods = new Array[ObjcMethod]
37 end
38
39 # Method of an `ObjcClass`
40 class ObjcMethod
41 super Property
42
43 # Scope: '+' for a static class method, and '-' for an instance method
44 var scope: Char is noinit, writable
45
46 # Parameters of the method
47 var params = new Array[Param]
48
49 # Return type as a `String`
50 var return_type: String is noinit, writable
51
52 # Does this method look like a constructor/method?
53 fun is_init: Bool do return params.first.name.has_prefix("init")
54 end
55
56 # Attribute of an `ObjcClass`
57 class ObjcAttribute
58 super Property
59
60 # Name of this attribute
61 var name: String is noinit, writable
62
63 # Type of this attribute
64 var return_type: String is noinit, writable
65 end
66
67 # Property of an `ObjcClass`
68 class Property
69 # Is this property to be commented out?
70 var is_commented = false is writable
71 end
72
73 # Parameter of an `ObjcMethod`
74 class Param
75 # Parameter name, used by the caller (e.g. `withObject` in `withObject: (NSObject*) obj`)
76 var name: String is noinit, writable
77
78 # Type of the parameter name
79 var return_type: String is noinit, writable
80
81 # Argument name, used within the body (e.g. `obj` in `withObject: (NSObject*) obj`)
82 var variable_name: String is noinit, writable
83
84 # Is this a primitive array? with at least one `[]`.
85 var is_table = false is writable
86
87 # Is this a pointer type?
88 var is_pointer = false is writable
89
90 # Is this a parameter with only a `name`?
91 var is_single = false is writable
92 end