mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 04:39:45 +00:00
widl: Add a structure packing command line option.
This commit is contained in:
parent
70804336aa
commit
bbb3a85c51
@ -108,6 +108,7 @@ const char *string_of_type(unsigned char type)
|
||||
case RPC_FC_CARRAY: return "FC_CARRAY";
|
||||
case RPC_FC_CVARRAY: return "FC_CVARRAY";
|
||||
case RPC_FC_BOGUS_ARRAY: return "FC_BOGUS_ARRAY";
|
||||
case RPC_FC_ALIGNM2: return "FC_ALIGNM2";
|
||||
case RPC_FC_ALIGNM4: return "FC_ALIGNM4";
|
||||
case RPC_FC_ALIGNM8: return "FC_ALIGNM8";
|
||||
case RPC_FC_POINTER: return "FC_POINTER";
|
||||
@ -1094,6 +1095,7 @@ static unsigned int field_memsize(const type_t *type, unsigned int *offset)
|
||||
static unsigned int fields_memsize(const var_list_t *fields, unsigned int *align)
|
||||
{
|
||||
unsigned int size = 0;
|
||||
unsigned int max_align;
|
||||
const var_t *v;
|
||||
|
||||
if (!fields) return 0;
|
||||
@ -1102,11 +1104,15 @@ static unsigned int fields_memsize(const var_list_t *fields, unsigned int *align
|
||||
unsigned int falign = 0;
|
||||
unsigned int fsize = type_memsize(v->type, &falign);
|
||||
if (*align < falign) *align = falign;
|
||||
if (falign > packing) falign = packing;
|
||||
size = ROUND_SIZE(size, falign);
|
||||
size += fsize;
|
||||
}
|
||||
|
||||
size = ROUND_SIZE(size, *align);
|
||||
max_align = *align;
|
||||
if(max_align > packing) max_align = packing;
|
||||
size = ROUND_SIZE(size, max_align);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
@ -1144,6 +1150,7 @@ int get_padding(const var_list_t *fields)
|
||||
type_t *ft = f->type;
|
||||
unsigned int align = 0;
|
||||
unsigned int size = type_memsize(ft, &align);
|
||||
if (align > packing) align = packing;
|
||||
if (align > salign) salign = align;
|
||||
offset = ROUND_SIZE(offset, align);
|
||||
offset += size;
|
||||
@ -2210,6 +2217,7 @@ static void write_struct_members(FILE *file, const type_t *type,
|
||||
type_t *ft = field->type;
|
||||
unsigned int align = 0;
|
||||
unsigned int size = type_memsize(ft, &align);
|
||||
if(align > packing) align = packing;
|
||||
if (salign < align) salign = align;
|
||||
|
||||
if (!is_conformant_array(ft) || type_array_is_decl_as_ptr(ft))
|
||||
@ -2219,6 +2227,9 @@ static void write_struct_members(FILE *file, const type_t *type,
|
||||
unsigned char fc = 0;
|
||||
switch (align)
|
||||
{
|
||||
case 2:
|
||||
fc = RPC_FC_ALIGNM2;
|
||||
break;
|
||||
case 4:
|
||||
fc = RPC_FC_ALIGNM4;
|
||||
break;
|
||||
|
@ -44,7 +44,6 @@
|
||||
#include "header.h"
|
||||
|
||||
/* future options to reserve characters for: */
|
||||
/* a = alignment of structures */
|
||||
/* A = ACF input filename */
|
||||
/* J = do not search standard include path */
|
||||
/* O = generate interpreted stubs */
|
||||
@ -53,6 +52,7 @@
|
||||
static const char usage[] =
|
||||
"Usage: widl [options...] infile.idl\n"
|
||||
" or: widl [options...] --dlldata-only name1 [name2...]\n"
|
||||
" -a n Set structure alignment to 'n'\n"
|
||||
" -b arch Set the target architecture\n"
|
||||
" -c Generate client stub\n"
|
||||
" -C file Name of client stub file (default is infile_c.c)\n"
|
||||
@ -111,6 +111,7 @@ int no_preprocess = 0;
|
||||
int old_names = 0;
|
||||
int do_win32 = 1;
|
||||
int do_win64 = 1;
|
||||
int packing = 8;
|
||||
|
||||
char *input_name;
|
||||
char *header_name;
|
||||
@ -153,7 +154,7 @@ enum {
|
||||
};
|
||||
|
||||
static const char short_options[] =
|
||||
"b:cC:d:D:EhH:I:m:NpP:sS:tT:uU:VW";
|
||||
"a:b:cC:d:D:EhH:I:m:NpP:sS:tT:uU:VW";
|
||||
static const struct option long_options[] = {
|
||||
{ "dlldata", 1, 0, DLLDATA_OPTION },
|
||||
{ "dlldata-only", 0, 0, DLLDATA_ONLY_OPTION },
|
||||
@ -521,6 +522,11 @@ int main(int argc,char *argv[])
|
||||
do_win32 = 0;
|
||||
do_win64 = 1;
|
||||
break;
|
||||
case 'a':
|
||||
packing = strtol(optarg, NULL, 0);
|
||||
if(packing != 2 && packing != 4 && packing != 8)
|
||||
error("Packing must be one of 2, 4 or 8\n");
|
||||
break;
|
||||
case 'b':
|
||||
set_target( optarg );
|
||||
break;
|
||||
|
@ -46,6 +46,7 @@ extern int do_dlldata;
|
||||
extern int old_names;
|
||||
extern int do_win32;
|
||||
extern int do_win64;
|
||||
extern int packing;
|
||||
|
||||
extern char *input_name;
|
||||
extern char *header_name;
|
||||
|
Loading…
Reference in New Issue
Block a user