dwarves: Introduce function__prototype

Basically a wrapper for ftype__fprintf(&function__proto, ...) for the
cases we want the prototype rendered to a buffer, not to a file.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2008-07-30 18:33:33 -04:00
parent 33ba723280
commit 51bcb5f9e5
2 changed files with 22 additions and 0 deletions

View File

@ -1479,6 +1479,20 @@ const char *function__name(struct function *self, const struct cu *cu)
return self->name;
}
const char *function__prototype(const struct function *self,
const struct cu *cu, char *bf, size_t len)
{
FILE *bfp = fmemopen(bf, len, "w");
if (bfp != NULL) {
ftype__fprintf(&self->proto, cu, NULL, 0, 0, 0, bfp);
fclose(bfp);
} else
snprintf(bf, len, "<ERROR(%s): fmemopen failed!>", __func__);
return bf;
}
int ftype__has_parm_of_type(const struct ftype *self, const struct tag *target,
const struct cu *cu)
{

View File

@ -382,6 +382,11 @@ static inline struct function *tag__function(const struct tag *self)
return (struct function *)self;
}
static inline struct tag *function__tag(const struct function *self)
{
return (struct tag *)self;
}
/**
* function__for_each_parameter - iterate thru all the parameters
* @self: struct function instance to iterate
@ -490,6 +495,9 @@ extern const char *function__name(struct function *self, const struct cu *cu);
extern size_t function__fprintf_stats(const struct tag *tag_self,
const struct cu *cu,
FILE *fp);
extern const char *function__prototype(const struct function *self,
const struct cu *cu,
char *bf, size_t len);
void lexblock__add_inline_expansion(struct lexblock *self,
struct inline_expansion *exp);