wrc: Explicitly define structure creation functions instead of playing with macros.

This commit is contained in:
Alexandre Julliard 2010-12-30 12:30:36 +01:00
parent 5fabc5cca7
commit d0a6c806a9
2 changed files with 153 additions and 51 deletions

View File

@ -45,31 +45,144 @@ typedef struct
} BITMAPOS2HEADER;
#include <poppack.h>
/* Generate new_* functions that have no parameters (NOTE: no ';') */
__NEW_STRUCT_FUNC(dialog)
__NEW_STRUCT_FUNC(name_id)
__NEW_STRUCT_FUNC(menu)
__NEW_STRUCT_FUNC(menu_item)
__NEW_STRUCT_FUNC(control)
__NEW_STRUCT_FUNC(icon)
__NEW_STRUCT_FUNC(cursor)
__NEW_STRUCT_FUNC(versioninfo)
__NEW_STRUCT_FUNC(ver_value)
__NEW_STRUCT_FUNC(ver_block)
__NEW_STRUCT_FUNC(stt_entry)
__NEW_STRUCT_FUNC(accelerator)
__NEW_STRUCT_FUNC(event)
__NEW_STRUCT_FUNC(raw_data)
__NEW_STRUCT_FUNC(lvc)
__NEW_STRUCT_FUNC(res_count)
__NEW_STRUCT_FUNC(string)
__NEW_STRUCT_FUNC(toolbar_item)
__NEW_STRUCT_FUNC(ani_any)
/* New instances for all types of structures */
/* Very inefficient (in size), but very functional :-]
* Especially for type-checking.
*/
dialog_t *new_dialog(void)
{
dialog_t *ret = xmalloc( sizeof(*ret) );
memset( ret, 0, sizeof(*ret) );
return ret;
}
name_id_t *new_name_id(void)
{
name_id_t *ret = xmalloc( sizeof(*ret) );
memset( ret, 0, sizeof(*ret) );
return ret;
}
menu_t *new_menu(void)
{
menu_t *ret = xmalloc( sizeof(*ret) );
memset( ret, 0, sizeof(*ret) );
return ret;
}
menu_item_t *new_menu_item(void)
{
menu_item_t *ret = xmalloc( sizeof(*ret) );
memset( ret, 0, sizeof(*ret) );
return ret;
}
control_t *new_control(void)
{
control_t *ret = xmalloc( sizeof(*ret) );
memset( ret, 0, sizeof(*ret) );
return ret;
}
icon_t *new_icon(void)
{
icon_t *ret = xmalloc( sizeof(*ret) );
memset( ret, 0, sizeof(*ret) );
return ret;
}
cursor_t *new_cursor(void)
{
cursor_t *ret = xmalloc( sizeof(*ret) );
memset( ret, 0, sizeof(*ret) );
return ret;
}
versioninfo_t *new_versioninfo(void)
{
versioninfo_t *ret = xmalloc( sizeof(*ret) );
memset( ret, 0, sizeof(*ret) );
return ret;
}
ver_value_t *new_ver_value(void)
{
ver_value_t *ret = xmalloc( sizeof(*ret) );
memset( ret, 0, sizeof(*ret) );
return ret;
}
ver_block_t *new_ver_block(void)
{
ver_block_t *ret = xmalloc( sizeof(*ret) );
memset( ret, 0, sizeof(*ret) );
return ret;
}
stt_entry_t *new_stt_entry(void)
{
stt_entry_t *ret = xmalloc( sizeof(*ret) );
memset( ret, 0, sizeof(*ret) );
return ret;
}
accelerator_t *new_accelerator(void)
{
accelerator_t *ret = xmalloc( sizeof(*ret) );
memset( ret, 0, sizeof(*ret) );
return ret;
}
event_t *new_event(void)
{
event_t *ret = xmalloc( sizeof(*ret) );
memset( ret, 0, sizeof(*ret) );
return ret;
}
raw_data_t *new_raw_data(void)
{
raw_data_t *ret = xmalloc( sizeof(*ret) );
memset( ret, 0, sizeof(*ret) );
return ret;
}
lvc_t *new_lvc(void)
{
lvc_t *ret = xmalloc( sizeof(*ret) );
memset( ret, 0, sizeof(*ret) );
return ret;
}
res_count_t *new_res_count(void)
{
res_count_t *ret = xmalloc( sizeof(*ret) );
memset( ret, 0, sizeof(*ret) );
return ret;
}
string_t *new_string(void)
{
string_t *ret = xmalloc( sizeof(*ret) );
memset( ret, 0, sizeof(*ret) );
return ret;
}
toolbar_item_t *new_toolbar_item(void)
{
toolbar_item_t *ret = xmalloc( sizeof(*ret) );
memset( ret, 0, sizeof(*ret) );
return ret;
}
ani_any_t *new_ani_any(void)
{
ani_any_t *ret = xmalloc( sizeof(*ret) );
memset( ret, 0, sizeof(*ret) );
return ret;
}
resource_t *new_resource(enum res_e t, void *res, int memopt, language_t *lan)
{
resource_t *r = xmalloc(sizeof(resource_t));

View File

@ -23,36 +23,25 @@
#include "wrctypes.h"
#define __NEW_STRUCT_FUNC(p) \
p##_t *new_##p(void)\
{\
p##_t * ret = xmalloc(sizeof(*ret)); \
memset( ret, 0, sizeof(*ret) ); \
return ret; \
}
#define __NEW_STRUCT_PROTO(p) p##_t *new_##p(void)
__NEW_STRUCT_PROTO(dialog);
__NEW_STRUCT_PROTO(name_id);
__NEW_STRUCT_PROTO(menu);
__NEW_STRUCT_PROTO(menu_item);
__NEW_STRUCT_PROTO(control);
__NEW_STRUCT_PROTO(icon);
__NEW_STRUCT_PROTO(cursor);
__NEW_STRUCT_PROTO(versioninfo);
__NEW_STRUCT_PROTO(ver_value);
__NEW_STRUCT_PROTO(ver_block);
__NEW_STRUCT_PROTO(stt_entry);
__NEW_STRUCT_PROTO(accelerator);
__NEW_STRUCT_PROTO(event);
__NEW_STRUCT_PROTO(raw_data);
__NEW_STRUCT_PROTO(lvc);
__NEW_STRUCT_PROTO(res_count);
__NEW_STRUCT_PROTO(string);
__NEW_STRUCT_PROTO(toolbar_item);
__NEW_STRUCT_PROTO(ani_any);
dialog_t *new_dialog(void);
name_id_t *new_name_id(void);
menu_t *new_menu(void);
menu_item_t *new_menu_item(void);
control_t *new_control(void);
icon_t *new_icon(void);
cursor_t *new_cursor(void);
versioninfo_t *new_versioninfo(void);
ver_value_t *new_ver_value(void);
ver_block_t *new_ver_block(void);
stt_entry_t *new_stt_entry(void);
accelerator_t *new_accelerator(void);
event_t *new_event(void);
raw_data_t *new_raw_data(void);
lvc_t *new_lvc(void);
res_count_t *new_res_count(void);
string_t *new_string(void);
toolbar_item_t *new_toolbar_item(void);
ani_any_t *new_ani_any(void);
resource_t *new_resource(enum res_e t, void *res, int memopt, language_t *lan);
version_t *new_version(DWORD v);
characts_t *new_characts(DWORD c);