widl: Add abi_prefix parameter to format_namespace.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2020-12-01 15:01:54 +01:00 committed by Alexandre Julliard
parent 495f24ebb8
commit 13592f0cdb
4 changed files with 13 additions and 12 deletions

View File

@ -132,7 +132,7 @@ static void write_guid(FILE *f, const char *guid_prefix, const char *name, const
static void write_uuid_decl(FILE *f, type_t *type, const UUID *uuid) static void write_uuid_decl(FILE *f, type_t *type, const UUID *uuid)
{ {
char *name = format_namespace(type->namespace, "", "::", type->name); char *name = format_namespace(type->namespace, "", "::", type->name, use_abi_namespace ? "ABI" : NULL);
fprintf(f, "#ifdef __CRT_UUID_DECL\n"); fprintf(f, "#ifdef __CRT_UUID_DECL\n");
fprintf(f, "__CRT_UUID_DECL(%s, 0x%08x, 0x%04x, 0x%04x, 0x%02x,0x%02x, 0x%02x," fprintf(f, "__CRT_UUID_DECL(%s, 0x%08x, 0x%04x, 0x%04x, 0x%02x,0x%02x, 0x%02x,"
"0x%02x,0x%02x,0x%02x,0x%02x,0x%02x)\n", "0x%02x,0x%02x,0x%02x,0x%02x,0x%02x)\n",

View File

@ -1922,7 +1922,7 @@ type_t *reg_type(type_t *type, const char *name, struct namespace *namespace, in
if (is_global_namespace(namespace)) if (is_global_namespace(namespace))
type->c_name = name; type->c_name = name;
else else
type->c_name = format_namespace(namespace, "__x_", "_C", name); type->c_name = format_namespace(namespace, "__x_", "_C", name, use_abi_namespace ? "ABI" : NULL);
nt->type = type; nt->type = type;
nt->t = t; nt->t = t;
nt->next = namespace->type_hash[hash]; nt->next = namespace->type_hash[hash];

View File

@ -89,38 +89,38 @@ const char *type_get_name(const type_t *type, enum name_type name_type)
return NULL; return NULL;
} }
static char *append_namespace(char *ptr, struct namespace *namespace, const char *separator) static char *append_namespace(char *ptr, struct namespace *namespace, const char *separator, const char *abi_prefix)
{ {
if(is_global_namespace(namespace)) { if(is_global_namespace(namespace)) {
if(!use_abi_namespace) if(!abi_prefix) return ptr;
return ptr; strcpy(ptr, abi_prefix);
strcpy(ptr, "ABI");
strcat(ptr, separator); strcat(ptr, separator);
return ptr + strlen(ptr); return ptr + strlen(ptr);
} }
ptr = append_namespace(ptr, namespace->parent, separator); ptr = append_namespace(ptr, namespace->parent, separator, abi_prefix);
strcpy(ptr, namespace->name); strcpy(ptr, namespace->name);
strcat(ptr, separator); strcat(ptr, separator);
return ptr + strlen(ptr); return ptr + strlen(ptr);
} }
char *format_namespace(struct namespace *namespace, const char *prefix, const char *separator, const char *suffix) char *format_namespace(struct namespace *namespace, const char *prefix, const char *separator, const char *suffix,
const char *abi_prefix)
{ {
unsigned len = strlen(prefix) + strlen(suffix); unsigned len = strlen(prefix) + strlen(suffix);
unsigned sep_len = strlen(separator); unsigned sep_len = strlen(separator);
struct namespace *iter; struct namespace *iter;
char *ret, *ptr; char *ret, *ptr;
if(use_abi_namespace && !is_global_namespace(namespace)) if(abi_prefix)
len += 3 /* strlen("ABI") */ + sep_len; len += strlen(abi_prefix) + sep_len;
for(iter = namespace; !is_global_namespace(iter); iter = iter->parent) for(iter = namespace; !is_global_namespace(iter); iter = iter->parent)
len += strlen(iter->name) + sep_len; len += strlen(iter->name) + sep_len;
ret = xmalloc(len+1); ret = xmalloc(len+1);
strcpy(ret, prefix); strcpy(ret, prefix);
ptr = append_namespace(ret + strlen(ret), namespace, separator); ptr = append_namespace(ret + strlen(ret), namespace, separator, abi_prefix);
strcpy(ptr, suffix); strcpy(ptr, suffix);
return ret; return ret;

View File

@ -613,7 +613,8 @@ var_list_t *append_var(var_list_t *list, var_t *var);
void init_loc_info(loc_info_t *); void init_loc_info(loc_info_t *);
char *format_namespace(struct namespace *namespace, const char *prefix, const char *separator, const char *suffix); char *format_namespace(struct namespace *namespace, const char *prefix, const char *separator, const char *suffix,
const char *abi_prefix);
static inline enum type_type type_get_type_detect_alias(const type_t *type) static inline enum type_type type_get_type_detect_alias(const type_t *type)
{ {