MCPcopy Create free account
hub / github.com/FEX-Emu/FEX / HandleStructElements

Function HandleStructElements

Scripts/DefinitionExtract.py:345–423  ·  view source on GitHub ↗
(Arch, Struct, Cursor)

Source from the content-addressed store, hash-verified

343 return Arch
344
345def HandleStructElements(Arch, Struct, Cursor):
346 for Child in Cursor.get_children():
347 # logging.info ("\t\tStruct/Union Children: Cursor \"{0}{1}\" of kind {2}".format(Arch.CurrentNamespace, Child.spelling, Child.kind))
348 if (Child.kind == CursorKind.ANNOTATE_ATTR):
349 if (Child.spelling.startswith("alias-")):
350 Sections = Child.spelling.split("-")
351 if (Sections[1] == "x86_32"):
352 Struct.Aliases.append(AliasType(Sections[2], AliasType.ALIAS_X86_32))
353 elif (Sections[1] == "x86_64"):
354 Struct.Aliases.append(AliasType(Sections[2], AliasType.ALIAS_X86_64))
355 elif (Sections[1] == "aarch64"):
356 Struct.Aliases.append(AliasType(Sections[2], AliasType.ALIAS_AARCH64))
357 elif (Sections[1] == "win32"):
358 Struct.Aliases.append(AliasType(Sections[2], AliasType.ALIAS_WIN32))
359 elif (Sections[1] == "win64"):
360 Struct.Aliases.append(AliasType(Sections[2], AliasType.ALIAS_WIN64))
361 else:
362 logging.critical ("Can't handle alias type '{0}'".format(Child.spelling))
363 Arch.Parsed = False
364
365 elif (Child.spelling == "fex-match"):
366 Struct.ExpectedFEXMatch = True
367 else:
368 # Unknown annotation
369 pass
370 elif (Child.kind == CursorKind.FIELD_DECL):
371 ParentType = Cursor.type
372 FieldType = Child.type
373 Field = FieldDefinition(
374 Name = Child.spelling,
375 Size = FieldType.get_size(),
376 OffsetOf = ParentType.get_offset(Child.spelling),
377 Alignment = FieldType.get_align())
378
379 #logging.info ("\t{0}".format(Child.spelling))
380 #logging.info ("\t\tSize of type: {0}".format(FieldType.get_size()));
381 #logging.info ("\t\tAlignment of type: {0}".format(FieldType.get_align()));
382 #logging.info ("\t\tOffsetof of type: {0}".format(ParentType.get_offset(Child.spelling)));
383 Struct.Members.append(Field)
384 Arch.FieldDecls.append(Field)
385 elif (Child.kind == CursorKind.STRUCT_DECL):
386 ParentType = Cursor.type
387 FieldType = Child.type
388 Field = FieldDefinition(
389 Name = Child.spelling,
390 Size = FieldType.get_size(),
391 OffsetOf = ParentType.get_offset(Child.spelling),
392 Alignment = FieldType.get_align())
393
394 #logging.info ("\t{0}".format(Child.spelling))
395 #logging.info ("\t\tSize of type: {0}".format(FieldType.get_size()));
396 #logging.info ("\t\tAlignment of type: {0}".format(FieldType.get_align()));
397 #logging.info ("\t\tOffsetof of type: {0}".format(ParentType.get_offset(Child.spelling)));
398 Struct.Members.append(Field)
399 Arch.FieldDecls.append(Field)
400 Arch = HandleStructDeclCursor(Arch, Child)
401 elif (Child.kind == CursorKind.UNION_DECL):
402 Struct = HandleStructElements(Arch, Struct, Child)

Callers 2

HandleStructDeclCursorFunction · 0.70
HandleUnionDeclCursorFunction · 0.70

Calls 7

appendMethod · 0.80
AliasTypeClass · 0.70
FieldDefinitionClass · 0.70
HandleStructDeclCursorFunction · 0.70
HandleTypeDefDeclCursorFunction · 0.70
HandleCursorFunction · 0.70
formatMethod · 0.45

Tested by

no test coverage detected