From 82f910eb62009effe7b02f796acbd7b5829eb85d Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 4 Jan 2010 12:41:16 +0100 Subject: [PATCH] wrc: Merge the menu and menuex structures. --- tools/wrc/dumpres.c | 22 ------------ tools/wrc/genres.c | 76 ++++++++++++++--------------------------- tools/wrc/newstruc.c | 1 - tools/wrc/newstruc.h | 1 - tools/wrc/parser.y | 9 +++-- tools/wrc/translation.c | 17 --------- tools/wrc/wrctypes.h | 11 ++---- 7 files changed, 31 insertions(+), 106 deletions(-) diff --git a/tools/wrc/dumpres.c b/tools/wrc/dumpres.c index d432dcc2816..f2efe30d658 100644 --- a/tools/wrc/dumpres.c +++ b/tools/wrc/dumpres.c @@ -48,7 +48,6 @@ const char *get_typename(const resource_t* r) case res_ico: return "ICON"; case res_icog: return "GROUP_ICON"; case res_men: return "MENU"; - case res_menex: return "MENUEX"; case res_rdt: return "RCDATA"; case res_stt: return "STRINGTABLE"; case res_usr: return "UserResource"; @@ -674,24 +673,6 @@ static void dump_menu(const menu_t *men) dump_menu_item(men->items); } -/* - ***************************************************************************** - * Function : dump_menuex - * Syntax : void dump_menuex(const menuex_t *menex) - * Input : - * menex - MenuEx resource descriptor - * Output : - * Description : - * Remarks : - ***************************************************************************** -*/ -static void dump_menuex(const menuex_t *menex) -{ - dump_memopt(menex->memopt); - dump_lvc(&(menex->lvc)); - dump_menu_item(menex->items); -} - /* ***************************************************************************** * Function : dump_ver_value @@ -909,9 +890,6 @@ void dump_resources(const resource_t *top) case res_men: dump_menu(top->res.men); break; - case res_menex: - dump_menuex(top->res.menex); - break; case res_rdt: dump_rcdata(top->res.rdt); break; diff --git a/tools/wrc/genres.c b/tools/wrc/genres.c index a063ae264bf..7871c793ac4 100644 --- a/tools/wrc/genres.c +++ b/tools/wrc/genres.c @@ -778,37 +778,6 @@ static void menuitem2res(res_t *res, menu_item_t *menitem, const language_t *lan } -/* - ***************************************************************************** - * Function : menu2res - * Syntax : res_t *menu2res(name_id_t *name, menu_t *men) - * Input : - * name - Name/ordinal of the resource - * men - The menu descriptor - * Output : New .res format structure - * Description : - * Remarks : - ***************************************************************************** -*/ -static res_t *menu2res(name_id_t *name, menu_t *men) -{ - int restag; - res_t *res; - assert(name != NULL); - assert(men != NULL); - - res = new_res(); - restag = put_res_header(res, WRC_RT_MENU, NULL, name, men->memopt, win32 ? &(men->lvc) : NULL); - - put_dword(res, 0); /* Menuheader: Version and HeaderSize */ - menuitem2res(res, men->items, win32 ? men->lvc.language : NULL); - /* Set ResourceSize */ - SetResSize(res, restag); - if(win32) - put_pad(res); - return res; -} - /* ***************************************************************************** * Function : menuexitem2res @@ -846,8 +815,8 @@ static void menuexitem2res(res_t *res, menu_item_t *menitem, const language_t *l /* ***************************************************************************** - * Function : menuex2res - * Syntax : res_t *menuex2res(name_id_t *name, menuex_t *menex) + * Function : menu2res + * Syntax : res_t *menu2res(name_id_t *name, menu_t *men) * Input : * name - Name/ordinal of the resource * menex - The menuex descriptor @@ -856,33 +825,43 @@ static void menuexitem2res(res_t *res, menu_item_t *menitem, const language_t *l * Remarks : ***************************************************************************** */ -static res_t *menuex2res(name_id_t *name, menuex_t *menex) +static res_t *menu2res(name_id_t *name, menu_t *men) { int restag; res_t *res; assert(name != NULL); - assert(menex != NULL); + assert(men != NULL); res = new_res(); if(win32) { - restag = put_res_header(res, WRC_RT_MENU, NULL, name, menex->memopt, &(menex->lvc)); + restag = put_res_header(res, WRC_RT_MENU, NULL, name, men->memopt, &(men->lvc)); - put_word(res, 1); /* Menuheader: Version */ - put_word(res, 4); /* Offset */ - put_dword(res, 0); /* HelpId */ - put_pad(res); - menuexitem2res(res, menex->items, menex->lvc.language); + if (men->is_ex) + { + put_word(res, 1); /* Menuheader: Version */ + put_word(res, 4); /* Offset */ + put_dword(res, 0); /* HelpId */ + put_pad(res); + menuexitem2res(res, men->items, men->lvc.language); + } + else + { + put_dword(res, 0); /* Menuheader: Version and HeaderSize */ + menuitem2res(res, men->items, men->lvc.language); + } /* Set ResourceSize */ SetResSize(res, restag); put_pad(res); } else /* win16 */ { - /* Do not generate anything in 16-bit mode */ - free(res->data); - free(res); - return NULL; + restag = put_res_header(res, WRC_RT_MENU, NULL, name, men->memopt, NULL); + + put_dword(res, 0); /* Menuheader: Version and HeaderSize */ + menuitem2res(res, men->items, NULL); + /* Set ResourceSize */ + SetResSize(res, restag); } return res; } @@ -1807,8 +1786,7 @@ const char *get_c_typename(enum res_e type) case res_fntdir:return "FntDir"; case res_ico: return "Ico"; case res_icog: return "IcoGrp"; - case res_men: - case res_menex: return "Men"; + case res_men: return "Men"; case res_rdt: return "RCDat"; case res_stt: return "StrTab"; case res_usr: return "Usr"; @@ -1877,10 +1855,6 @@ void resources2res(resource_t *top) if(!top->binres) top->binres = menu2res(top->name, top->res.men); break; - case res_menex: - if(!top->binres) - top->binres = menuex2res(top->name, top->res.menex); - break; case res_html: if(!top->binres) top->binres = html2res(top->name, top->res.html); diff --git a/tools/wrc/newstruc.c b/tools/wrc/newstruc.c index fdb334fb758..6ed49dca1e2 100644 --- a/tools/wrc/newstruc.c +++ b/tools/wrc/newstruc.c @@ -49,7 +49,6 @@ typedef struct __NEW_STRUCT_FUNC(dialog) __NEW_STRUCT_FUNC(name_id) __NEW_STRUCT_FUNC(menu) -__NEW_STRUCT_FUNC(menuex) __NEW_STRUCT_FUNC(menu_item) __NEW_STRUCT_FUNC(control) __NEW_STRUCT_FUNC(icon) diff --git a/tools/wrc/newstruc.h b/tools/wrc/newstruc.h index 24fd3c52a3d..3bd4c29bc94 100644 --- a/tools/wrc/newstruc.h +++ b/tools/wrc/newstruc.h @@ -36,7 +36,6 @@ __NEW_STRUCT_PROTO(dialog); __NEW_STRUCT_PROTO(name_id); __NEW_STRUCT_PROTO(menu); -__NEW_STRUCT_PROTO(menuex); __NEW_STRUCT_PROTO(menu_item); __NEW_STRUCT_PROTO(control); __NEW_STRUCT_PROTO(icon); diff --git a/tools/wrc/parser.y b/tools/wrc/parser.y index 4340a01a2c0..28d4bc93c97 100644 --- a/tools/wrc/parser.y +++ b/tools/wrc/parser.y @@ -237,7 +237,6 @@ static int rsrcid_to_token(int lookahead); font_t *fnt; fontdir_t *fnd; menu_t *men; - menuex_t *menex; html_t *html; rcdata_t *rdt; stringtable_t *stt; @@ -315,9 +314,8 @@ static int rsrcid_to_token(int lookahead); %type ver_words %type ver_blocks ver_block %type ver_values ver_value -%type menu +%type menu menuex %type item_definitions menu_body itemex_definitions menuex_body -%type menuex %type itemex_p_options itemex_options %type messagetable %type userres @@ -636,7 +634,7 @@ resource_definition | menu { $$ = new_resource(res_men, $1, $1->memopt, $1->lvc.language); } | menuex { if(win32) - $$ = new_resource(res_menex, $1, $1->memopt, $1->lvc.language); + $$ = new_resource(res_men, $1, $1->memopt, $1->lvc.language); else $$ = NULL; } @@ -1295,7 +1293,8 @@ menuex : tMENUEX loadmemopts opt_lvc menuex_body { parser_warning("MENUEX not supported in 16-bit mode\n"); if(!$4) yyerror("MenuEx must contain items"); - $$ = new_menuex(); + $$ = new_menu(); + $$->is_ex = TRUE; if($2) { $$->memopt = *($2); diff --git a/tools/wrc/translation.c b/tools/wrc/translation.c index bfbf3894161..e3229011819 100644 --- a/tools/wrc/translation.c +++ b/tools/wrc/translation.c @@ -57,8 +57,6 @@ static language_t get_language(resource_t *resource) { return *resource->res.icog->lvc.language; case res_men: return *resource->res.men->lvc.language; - case res_menex: - return *resource->res.menex->lvc.language; case res_rdt: return *resource->res.rdt->data->lvc.language; case res_stt: @@ -535,18 +533,6 @@ static int compare_menu(menu_t *menu1, menu_t *menu2) { return different; } -static int compare_menuex(menuex_t *menuex1, menuex_t *menuex2) { - int different = 0; - if(!different && - ((menuex1->memopt != menuex2->memopt) || - (menuex1->lvc.version != menuex2->lvc.version) || - (menuex1->lvc.characts != menuex2->lvc.characts))) - different = 1; - if(!different) - different = compare_menu_item(menuex1->items, menuex2->items); - return different; -} - static int compare_rcdata(rcdata_t *rcdata1, rcdata_t *rcdata2) { int different = 0; if(!different && @@ -860,8 +846,6 @@ static int compare(resource_t *resource1, resource_t *resource2) { return compare_icon_group(resource1->res.icog, resource2->res.icog); case res_men: return compare_menu(resource1->res.men, resource2->res.men); - case res_menex: - return compare_menuex(resource1->res.menex, resource2->res.menex); case res_rdt: return compare_rcdata(resource1->res.rdt, resource2->res.rdt); case res_stt: @@ -963,7 +947,6 @@ static void setup_tabs(void) case res_ico: case res_icog: case res_men: - case res_menex: case res_rdt: case res_stt: case res_usr: diff --git a/tools/wrc/wrctypes.h b/tools/wrc/wrctypes.h index be7d570397b..5644d9d2d9b 100644 --- a/tools/wrc/wrctypes.h +++ b/tools/wrc/wrctypes.h @@ -183,8 +183,7 @@ enum res_e { res_dlginit = WRC_RT_DLGINIT, /* 240 */ res_toolbar = WRC_RT_TOOLBAR, /* 241 */ - res_menex = 256 + 4, - res_usr + res_usr = 256 + 6 }; /* Raw bytes in a row... */ @@ -254,15 +253,10 @@ typedef struct menu_item { typedef struct menu { DWORD memopt; lvc_t lvc; + int is_ex; menu_item_t *items; } menu_t; -typedef struct menuex { - DWORD memopt; - lvc_t lvc; - menu_item_t *items; -} menuex_t; - typedef struct itemex_opt { int id; @@ -588,7 +582,6 @@ typedef struct resource { icon_t *ico; icon_group_t *icog; menu_t *men; - menuex_t *menex; messagetable_t *msg; html_t *html; rcdata_t *rdt;