widl: Use proper macro name for forward declarations of interfaces inside a namespace.
This commit is contained in:
parent
ddc493a805
commit
867b0f8278
|
@ -1219,8 +1219,8 @@ static void write_function_proto(FILE *header, const type_t *iface, const var_t
|
|||
|
||||
static void write_forward(FILE *header, type_t *iface)
|
||||
{
|
||||
fprintf(header, "#ifndef __%s_FWD_DEFINED__\n", iface->name);
|
||||
fprintf(header, "#define __%s_FWD_DEFINED__\n", iface->name);
|
||||
fprintf(header, "#ifndef __%s_FWD_DEFINED__\n", iface->c_name);
|
||||
fprintf(header, "#define __%s_FWD_DEFINED__\n", iface->c_name);
|
||||
fprintf(header, "typedef interface %s %s;\n", iface->name, iface->name);
|
||||
fprintf(header, "#endif\n\n" );
|
||||
}
|
||||
|
|
|
@ -1971,6 +1971,8 @@ int is_type(const char *name)
|
|||
type_t *get_type(enum type_type type, char *name, struct namespace *namespace, int t)
|
||||
{
|
||||
type_t *tp;
|
||||
if (!namespace)
|
||||
namespace = &global_namespace;
|
||||
if (name) {
|
||||
tp = find_type(name, namespace, t);
|
||||
if (tp) {
|
||||
|
@ -1980,6 +1982,11 @@ type_t *get_type(enum type_type type, char *name, struct namespace *namespace, i
|
|||
}
|
||||
tp = make_type(type);
|
||||
tp->name = name;
|
||||
tp->namespace = namespace;
|
||||
if (is_global_namespace(namespace))
|
||||
tp->c_name = name;
|
||||
else
|
||||
tp->c_name = format_namespace(namespace, "__x_", "_C", name);
|
||||
if (!name) return tp;
|
||||
return reg_type(tp, name, namespace, t);
|
||||
}
|
||||
|
|
|
@ -45,8 +45,10 @@ type_t *make_type(enum type_type type)
|
|||
{
|
||||
type_t *t = alloc_type();
|
||||
t->name = NULL;
|
||||
t->namespace = NULL;
|
||||
t->type_type = type;
|
||||
t->attrs = NULL;
|
||||
t->c_name = NULL;
|
||||
t->orig = NULL;
|
||||
memset(&t->details, 0, sizeof(t->details));
|
||||
t->typestring_offset = 0;
|
||||
|
@ -76,6 +78,35 @@ static const var_t *find_arg(const var_list_t *args, const char *name)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static char *append_namespace(char *ptr, struct namespace *namespace, const char *separator)
|
||||
{
|
||||
if(is_global_namespace(namespace))
|
||||
return ptr;
|
||||
|
||||
ptr = append_namespace(ptr, namespace->parent, separator);
|
||||
strcpy(ptr, namespace->name);
|
||||
strcat(ptr, separator);
|
||||
return ptr + strlen(ptr);
|
||||
}
|
||||
|
||||
char *format_namespace(struct namespace *namespace, const char *prefix, const char *separator, const char *suffix)
|
||||
{
|
||||
unsigned len = strlen(prefix) + strlen(suffix);
|
||||
unsigned sep_len = strlen(separator);
|
||||
struct namespace *iter;
|
||||
char *ret, *ptr;
|
||||
|
||||
for(iter = namespace; !is_global_namespace(iter); iter = iter->parent)
|
||||
len += strlen(iter->name) + sep_len;
|
||||
|
||||
ret = xmalloc(len+1);
|
||||
strcpy(ret, prefix);
|
||||
ptr = append_namespace(ret + strlen(ret), namespace, separator);
|
||||
strcpy(ptr, suffix);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
type_t *type_new_function(var_list_t *args)
|
||||
{
|
||||
var_t *arg;
|
||||
|
|
|
@ -412,6 +412,7 @@ enum type_type
|
|||
|
||||
struct _type_t {
|
||||
const char *name;
|
||||
struct namespace *namespace;
|
||||
enum type_type type_type;
|
||||
attr_list_t *attrs;
|
||||
union
|
||||
|
@ -427,6 +428,7 @@ struct _type_t {
|
|||
struct pointer_details pointer;
|
||||
struct bitfield_details bitfield;
|
||||
} details;
|
||||
const char *c_name;
|
||||
type_t *orig; /* dup'd types */
|
||||
unsigned int typestring_offset;
|
||||
unsigned int ptrdesc; /* used for complex structs */
|
||||
|
@ -570,6 +572,8 @@ var_list_t *append_var(var_list_t *list, var_t *var);
|
|||
|
||||
void init_loc_info(loc_info_t *);
|
||||
|
||||
char *format_namespace(struct namespace *namespace, const char *prefix, const char *separator, const char *suffix);
|
||||
|
||||
static inline var_list_t *type_get_function_args(const type_t *func_type)
|
||||
{
|
||||
return func_type->details.function->args;
|
||||
|
@ -599,4 +603,9 @@ static inline int statements_has_func(const statement_list_t *stmts)
|
|||
return has_func;
|
||||
}
|
||||
|
||||
static inline int is_global_namespace(const struct namespace *namespace)
|
||||
{
|
||||
return !namespace->name;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue