-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
It appears that some enums that are used to generate constants are generated with wrong integral type.
For example, here is the definition of the IMAGE_FILE_HEADER struct in C/C++, from the MSDN documentation:
typedef struct _IMAGE_FILE_HEADER {
WORD Machine;
WORD NumberOfSections;
DWORD TimeDateStamp;
DWORD PointerToSymbolTable;
DWORD NumberOfSymbols;
WORD SizeOfOptionalHeader;
WORD Characteristics;
} IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;Here is the JSON generated for this struct:
{
"Name":"IMAGE_FILE_HEADER"
,"Architectures":[]
,"Platform":null
,"Kind":"Struct"
,"Size":0
,"PackingSize":0
,"Fields":[
{"Name":"Machine","Type":{"Kind":"ApiRef","Name":"IMAGE_FILE_MACHINE","TargetKind":"Default","Api":"System.Diagnostics.Debug","Parents":[]},"Attrs":[]}
,{"Name":"NumberOfSections","Type":{"Kind":"Native","Name":"UInt16"},"Attrs":[]}
,{"Name":"TimeDateStamp","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":[]}
,{"Name":"PointerToSymbolTable","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":[]}
,{"Name":"NumberOfSymbols","Type":{"Kind":"Native","Name":"UInt32"},"Attrs":[]}
,{"Name":"SizeOfOptionalHeader","Type":{"Kind":"Native","Name":"UInt16"},"Attrs":[]}
,{"Name":"Characteristics","Type":{"Kind":"ApiRef","Name":"IMAGE_FILE_CHARACTERISTICS","TargetKind":"Default","Api":"System.Diagnostics.Debug","Parents":[]},"Attrs":[]}
]
,"NestedTypes":[
]
}The Machine field has been translated to a value of type IMAGE_FILE_MACHINE, which is defined as follows:
{
"Name":"IMAGE_FILE_MACHINE"
,"Architectures":[]
,"Platform":null
,"Kind":"Enum"
,"Flags":false
,"Scoped":false
,"Values":[
{"Name":"IMAGE_FILE_MACHINE_AXP64","Value":644}
,{"Name":"IMAGE_FILE_MACHINE_I386","Value":332}
,{"Name":"IMAGE_FILE_MACHINE_IA64","Value":512}
// More values here (omitted for brevity)
]
,"IntegerBase":"UInt32"
}The IntegerBase is UInt32, which is 4 bytes; however the original field was of type WORD, which is 2 bytes.
This seems to cause utilities such as zigwin32gen that use the output of this tool to generate incorrect code.
marler8997
Metadata
Metadata
Assignees
Labels
No labels