The struct_annote_def
class, which is derived from the
annote_def
class, is used to record the definitions of structured
annotations. Objects of this class behave just like base
annote_def
objects, except the is_structured
method
returns TRUE
. In addition, these objects contain pointers to
four functions:
from
from
function converts the annotation data from a list of
immed
values to the user's data structure. This function is
required.
to
to
function converts the user's data structure to a list of
immed
values. This function is required.
free
free
function is optional, but it should be provided if the
annotation data needs to be deallocated when the annotation is deleted.
print
print
function is also optional, but without it the data in a
structured annotation is simply printed as a hexadecimal value. This
function allows you to print the annotations in more meaningful formats.
As much as possible, the annotations should be printed in the same style
as flat annotations.
Structured annotations must be registered with the manager before the
SUIF input file is read. Otherwise, the annotations will remain as
immed
value lists, instead of being converted to the appropriate
data structures. The STRUCT_ANNOTE
macro should be used to
register structured annotations. This is just like the ANNOTE
macro except that it takes four more arguments for the
struct_annote_def
functions. For example:
char *k_struct_annote; void *ann_from(char *name, immed_list *il, suif_object *obj); immed_list *ann_to(char *name, void *data); void ann_free(void *data); STRUCT_ANNOTE(k_struct_annote, "struct_annote", TRUE, ann_from, ann_to, ann_free, NULL);
This registers the annotation "struct_annote"
as a structured
annotation. The ann_from
function will be used to convert the
annotation data from a list of immed
values; the ann_to
function will be used to convert the data back to an immed_list
;
and the ann_free
function will be used to deallocate the
annotation data. No function is provided to print the annotation data.