@@ -133,6 +133,54 @@ F4_CPP_ParseFunctionBodyIFuckingHateCPlusPlus(F4_Index_ParseCtx *ctx, b32 *proto
133
133
return valid;
134
134
}
135
135
136
+ function void
137
+ F4_CPP_ParseEnumBodyIFuckingHateCPlusPlus (F4_Index_ParseCtx *ctx)
138
+ {
139
+ if (F4_Index_ParsePattern (ctx, " %t" , " {" ))
140
+ {
141
+ for (;!ctx->done ;)
142
+ {
143
+ Token *constant = 0 ;
144
+ if (F4_Index_ParsePattern (ctx, " %k%t" , TokenBaseKind_Identifier, &constant, " ," ))
145
+ {
146
+ F4_Index_MakeNote (ctx->app , ctx->file , 0 , F4_Index_StringFromToken (ctx, constant), F4_Index_NoteKind_Constant, 0 , Ii64 (constant));
147
+ }
148
+ else if (F4_Index_ParsePattern (ctx, " %k%t" , TokenBaseKind_Identifier, &constant, " =" ))
149
+ {
150
+ F4_Index_MakeNote (ctx->app , ctx->file , 0 , F4_Index_StringFromToken (ctx, constant), F4_Index_NoteKind_Constant, 0 , Ii64 (constant));
151
+
152
+ for (;!ctx->done ;)
153
+ {
154
+ Token *token = token_it_read (&ctx->it );
155
+ if (token->kind == TokenBaseKind_StatementClose)
156
+ {
157
+ F4_Index_ParseCtx_Inc (ctx, 0 );
158
+ break ;
159
+ }
160
+ else if (token->kind == TokenBaseKind_ScopeClose ||
161
+ token->kind == TokenBaseKind_ScopeOpen)
162
+ {
163
+ break ;
164
+ }
165
+ F4_Index_ParseCtx_Inc (ctx, 0 );
166
+ }
167
+ }
168
+ else if (F4_Index_ParsePattern (ctx, " %k" , TokenBaseKind_Identifier, &constant))
169
+ {
170
+ F4_Index_MakeNote (ctx->app , ctx->file , 0 , F4_Index_StringFromToken (ctx, constant), F4_Index_NoteKind_Constant, 0 , Ii64 (constant));
171
+ }
172
+ else if (F4_Index_ParsePattern (ctx, " %t" , " }" ))
173
+ {
174
+ break ;
175
+ }
176
+ else
177
+ {
178
+ F4_Index_ParseCtx_Inc (ctx, 0 );
179
+ }
180
+ }
181
+ }
182
+ }
183
+
136
184
internal F4_LANGUAGE_INDEXFILE (F4_CPP_IndexFile)
137
185
{
138
186
int scope_nest = 0 ;
@@ -187,63 +235,51 @@ internal F4_LANGUAGE_INDEXFILE(F4_CPP_IndexFile)
187
235
F4_CPP_ParseStructOrUnionBodyIFuckingHateCPlusPlus (ctx, F4_Index_NoteFlag_SumType);
188
236
}
189
237
190
- // ~ NOTE(rjf): Enum Protoypes
191
- else if (F4_Index_ParsePattern (ctx, " %t%k%t" , " enum" , TokenBaseKind_Identifier, &name, " ;" ))
238
+ // ~ NOTE(rjf): Typedef'd Enums
239
+ else if (F4_Index_ParsePattern (ctx, " %t%t%k" , " typedef" , " enum" , TokenBaseKind_Identifier, &name) ||
240
+ F4_Index_ParsePattern (ctx, " %t%t" , " typedef" , " enum" ))
192
241
{
193
242
handled = 1 ;
194
- F4_Index_MakeNote (ctx->app , ctx->file , 0 , F4_Index_StringFromToken (ctx, name),
195
- F4_Index_NoteKind_Type, 0 , Ii64 (name));
243
+ b32 prototype = 0 ;
244
+ b32 possible_name_at_end = name == 0 ;
245
+ if (F4_Index_ParsePattern (ctx, " %t" , " ;" ))
246
+ {
247
+ prototype = 1 ;
248
+ }
249
+ if (prototype == 0 )
250
+ {
251
+ F4_CPP_ParseEnumBodyIFuckingHateCPlusPlus (ctx);
252
+ }
253
+ if (possible_name_at_end)
254
+ {
255
+ if (F4_Index_ParsePattern (ctx, " %k" , TokenBaseKind_Identifier, &name))
256
+ {}
257
+ }
258
+ if (name != 0 )
259
+ {
260
+ F4_Index_MakeNote (ctx->app , ctx->file , 0 , F4_Index_StringFromToken (ctx, name),
261
+ F4_Index_NoteKind_Type, prototype ? F4_Index_NoteFlag_Prototype : 0 , Ii64 (name));
262
+ }
196
263
}
197
264
198
- // ~ NOTE(rjf): Enum Definitions
199
- else if (F4_Index_ParsePattern (ctx, " %t%k%t " , " enum" , TokenBaseKind_Identifier, &name, " { " ) ||
200
- F4_Index_ParsePattern (ctx, " %t%t " , " enum" , " { " ))
265
+ // ~ NOTE(rjf): Enums
266
+ else if (F4_Index_ParsePattern (ctx, " %t%k" , " enum" , TokenBaseKind_Identifier, &name) ||
267
+ F4_Index_ParsePattern (ctx, " %t" , " enum" ))
201
268
{
202
269
handled = 1 ;
203
- if (name != 0 )
270
+ b32 prototype = 0 ;
271
+ if (F4_Index_ParsePattern (ctx, " %t" , " ;" ))
204
272
{
205
- F4_Index_MakeNote (ctx->app , ctx->file , 0 , F4_Index_StringFromToken (ctx, name),
206
- F4_Index_NoteKind_Type, 0 , Ii64 (name));
273
+ prototype = 1 ;
207
274
}
208
- for (;!ctx-> done ; )
275
+ if (prototype == 0 )
209
276
{
210
- Token *constant = 0 ;
211
- if (F4_Index_ParsePattern (ctx, " %k%t" , TokenBaseKind_Identifier, &constant, " ," ))
212
- {
213
- F4_Index_MakeNote (ctx->app , ctx->file , 0 , F4_Index_StringFromToken (ctx, constant), F4_Index_NoteKind_Constant, 0 , Ii64 (constant));
214
- }
215
- else if (F4_Index_ParsePattern (ctx, " %k%t" , TokenBaseKind_Identifier, &constant, " =" ))
216
- {
217
- F4_Index_MakeNote (ctx->app , ctx->file , 0 , F4_Index_StringFromToken (ctx, constant), F4_Index_NoteKind_Constant, 0 , Ii64 (constant));
218
-
219
- for (;!ctx->done ;)
220
- {
221
- Token *token = token_it_read (&ctx->it );
222
- if (token->kind == TokenBaseKind_StatementClose)
223
- {
224
- F4_Index_ParseCtx_Inc (ctx, 0 );
225
- break ;
226
- }
227
- else if (token->kind == TokenBaseKind_ScopeClose ||
228
- token->kind == TokenBaseKind_ScopeOpen)
229
- {
230
- break ;
231
- }
232
- F4_Index_ParseCtx_Inc (ctx, 0 );
233
- }
234
- }
235
- else if (F4_Index_ParsePattern (ctx, " %k" , TokenBaseKind_Identifier, &constant))
236
- {
237
- F4_Index_MakeNote (ctx->app , ctx->file , 0 , F4_Index_StringFromToken (ctx, constant), F4_Index_NoteKind_Constant, 0 , Ii64 (constant));
238
- }
239
- else if (F4_Index_ParsePattern (ctx, " %t" , " }" ))
240
- {
241
- break ;
242
- }
243
- else
244
- {
245
- F4_Index_ParseCtx_Inc (ctx, 0 );
246
- }
277
+ F4_CPP_ParseEnumBodyIFuckingHateCPlusPlus (ctx);
278
+ }
279
+ if (name != 0 )
280
+ {
281
+ F4_Index_MakeNote (ctx->app , ctx->file , 0 , F4_Index_StringFromToken (ctx, name),
282
+ F4_Index_NoteKind_Type, prototype ? F4_Index_NoteFlag_Prototype : 0 , Ii64 (name));
247
283
}
248
284
}
249
285
0 commit comments