106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
# File 'lib/cocoapods-kz/helpers/repair_dynamic_swift.rb', line 106
def get_oc_feature_contexts
new_class_context = []
class_name = ""
superClass_and_protocol = []
class_line = @type_str.gsub(/\s+/, "")
class_line = class_line.split("class")[1]
if class_line.include?(":")
colon_infos = class_line.split(":")
class_name = colon_infos[0]
colon_right = colon_infos[1]
colon_right = colon_right.sub("{", "")
superClass_and_protocol = colon_right.split(",")
else
class_name = class_line.sub("{", "")
end
return @type_contexts if class_name == ""
have_super_class = false
if superClass_and_protocol.length > 0
have_super_class = !superClass_and_protocol[0].end_with?("Protocol")
end
have_objc_class = false
have_objc_members = false
for ornament in @type_ornament
if ornament.start_with?("@objc ") || ornament.start_with?("@objc(") || ornament == "@objc" || ornament == "@objc\n"
have_objc_class = true
end
have_objc_members = true if ornament.start_with?("@objcMembers")
end
new_class_context.concat(@type_header)
if !have_objc_members
new_class_context.insert(0, "@objcMembers\n")
end
if !have_objc_class && !have_super_class
new_class_context.insert(0, "@objc\n")
end
if !have_objc_class && !have_super_class
if superClass_and_protocol.length > 0
if !@system_nsobject_class.include?(superClass_and_protocol[0])
@type_str = @type_str.sub(":", ": NSObject,")
end
else
@type_str = @type_str.sub("{", ": NSObject {")
end
end
new_class_context << @type_str
new_swift_types = KZSwiftFileAnalyse.analyse_swift_file(@type_body, !have_super_class)
new_swift_types.each do |swift_type|
new_class_context.concat(swift_type.get_oc_feature_contexts())
end
new_class_context << "}\n"
new_class_context
end
|