File type.c

RCS Header: /home/amb/CVS/cxref/src/type.c,v 1.18 2004-11-20 14:14:53 amb Exp

C Cross Referencing & Documentation tool. Version 1.6a.
Collects the typedef stuff.


Included Files


Preprocessor definitions

Control the output of debugging information in this file.

#define DEBUG 0


External Variables

CurFile
The file that is currently being processed.

extern File CurFile

Defined in: cxref.c

in_typedef
Whether we are parsing a typedef or not.

extern int in_typedef

Defined in: parse-yacc.c

Local Variables

typedefs
The defined types that we have seen.

static StringList2 typedefs

Used in: IsATypeName()  
  ResetTypeAnalyser()  
  SeenTypedefName()  

cur_su
The current struct / union or enum definition.

static StructUnion cur_su

Used in: ResetTypeAnalyser()  
  SeenStructUnionComp()  
  SeenStructUnionEnd()  
  SeenStructUnionStart()  

cur_type_su
The current struct / union if seen in a typedef.

static StructUnion cur_type_su

Used in: ResetTypeAnalyser()  
  SeenStructUnionEnd()  
  SeenTypedef()  

last_typedef
The last typedef seen, used when two types share a typedef statement.

static Typedef last_typedef

Used in: ResetTypeAnalyser()  
  SeenTypedef()  

type_lineno
The line number that a typedef or structure was seen on.

static int type_lineno

Used in: SeenStructUnionEnd()  
  SeenStructUnionStart()  
  SeenTypedef()  

Global Function DeleteTypedefType()

Delete the specified Typedef type.

void DeleteTypedefType ( Typedef type )

Typedef type
The Typedef type to be deleted.
Prototyped in: cxref.h
Calls: DeleteStructUnionType() type.c
  SafeFree() memory.c
Called by: DeleteFile() file.c

Global Function IsATypeName()

Function that is called when an IDENTIFIER is seen in the current file, it may be a defined type.

int IsATypeName ( char* name )

int IsATypeName
Returns 1 if the argument is a type that has been defined.
char* name
The name of the possible defined type.
Prototyped in: cxref.h
Calls: strcmp()
Called by: yylex() parse-lex.c
  yyparse() parse-yacc.c
References Variables: typedefs type.c

Global Function ResetTypeAnalyser()

Tidy up all of the local variables in case of a problem and abnormal parser termination.

void ResetTypeAnalyser ( void )

Prototyped in: cxref.h
Calls: DeleteStringList2() slist.c
  DeleteStructUnionType() type.c
Called by: main() cxref.c
References Variables: cur_su type.c
  cur_type_su type.c
  last_typedef type.c
  typedefs type.c

Global Function SeenStructUnionComp()

Function called when a component of a struct / union / enum is seen.

void SeenStructUnionComp ( char* name, int depth )

char* name
The name of the struct / union / enum component.
int depth
The depth within the nested struct / union / enum.
Prototyped in: cxref.h
Calls: ConcatStrings() memory.c
  CopyStructUnion() type.c
  GetCurrentComment() comment.c
  NewStructUnionType() type.c
  NewTypedefType() type.c
  SafeFree() memory.c
  SafeMalloc() memory.c
  SafeMallocString() memory.c
  SafeRealloc() memory.c
  strchr(), strcmp()
Called by: yyparse() parse-yacc.c
References Variables: CurFile cxref.c
  cur_su type.c

Global Function SeenStructUnionEnd()

Function that is called when the end of a struct or union or enum definition is seen.

void SeenStructUnionEnd ( void )

Prototyped in: cxref.h
Calls: NewTypedefType() type.c
  strlen(), strncmp()
Called by: yyparse() parse-yacc.c
References Variables: CurFile cxref.c
  cur_su type.c
  cur_type_su type.c
  in_typedef parse-yacc.c
  type_lineno type.c

Global Function SeenStructUnionStart()

Function that is called when the start of a struct or union or enum definition is seen.

void SeenStructUnionStart ( char* name )

char* name
The name of the struct type.
Prototyped in: cxref.h
Calls: DeleteStructUnionType() type.c
  GetCurrentComment() comment.c
  NewStructUnionType() type.c
  SafeMallocString() memory.c
Called by: yyparse() parse-yacc.c
References Variables: cur_su type.c
  in_typedef parse-yacc.c
  parse_line parse-lex.c
  type_lineno type.c

Global Function SeenTypedef()

Function that is called when a typedef is seen in the current file. This is recorded fully for later output.

void SeenTypedef ( char* name, char* type )

char* name
The name of the defined type.
char* type
The type that it is defined to be.
Prototyped in: cxref.h
Calls: GetCurrentComment() comment.c
  NewTypedefType() type.c
  SafeMallocString() memory.c
  strlen(), strncmp()
Called by: yyparse() parse-yacc.c
References Variables: CurFile cxref.c
  cur_type_su type.c
  last_typedef type.c
  parse_line parse-lex.c
  type_lineno type.c

Global Function SeenTypedefName()

Function that is called when a typedef is seen in the current file. The name of the typedef is stored for future reference.

void SeenTypedefName ( char* name, int what_type )

char* name
The name of the defined type.
int what_type
Set to 1 for normal types or -1 for a function type (not pointer to function).
Prototyped in: cxref.h
Calls: AddToStringList2() slist.c
  NewStringList2() slist.c
Called by: yyparse() parse-yacc.c
References Variables: typedefs type.c

Local Function CopyStructUnion()

Make a copy of the specified Struct / Union structure.

static StructUnion CopyStructUnion ( StructUnion su )

StructUnion CopyStructUnion
Returns a malloced copy of the specified struct / union.
StructUnion su
The struct / union to copy.
This needs to call itself recursively.

Prototyped in: type.c
Calls: CopyStructUnion() type.c
  NewStructUnionType() type.c
  SafeMalloc() memory.c
  SafeMallocString() memory.c
Called by: CopyStructUnion() type.c
  SeenStructUnionComp() type.c

Local Function DeleteStructUnionType()

Free the memory associated with a Struct / Union structure.

static void DeleteStructUnionType ( StructUnion su )

StructUnion su
The struct / union to delete.
This needs to call itself recursively.

Prototyped in: type.c
Calls: DeleteStructUnionType() type.c
  SafeFree() memory.c
Called by: DeleteStructUnionType() type.c
  DeleteTypedefType() type.c
  ResetTypeAnalyser() type.c
  SeenStructUnionStart() type.c

Local Function NewStructUnionType()

Create a new struct / union type.

static StructUnion NewStructUnionType ( char* name )

StructUnion NewStructUnionType
Return the new StructUnion type.
char* name
The name of the new struct / union.
Prototyped in: type.c
Calls: SafeCalloc() memory.c
  SafeMallocString() memory.c
Called by: CopyStructUnion() type.c
  SeenStructUnionComp() type.c
  SeenStructUnionStart() type.c

Local Function NewTypedefType()

Create a new Typedef type.

static Typedef NewTypedefType ( char* name, char* type )

Typedef NewTypedefType
Returns the new type.
char* name
The name of the type.
char* type
The type of the type.
Prototyped in: type.c
Calls: SafeCalloc() memory.c
  SafeMallocString() memory.c
Called by: SeenStructUnionComp() type.c
  SeenStructUnionEnd() type.c
  SeenTypedef() type.c