mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 22:31:05 +00:00
Add convenience functions for getting a def's offset and size.
This commit is contained in:
parent
d717a0b3f2
commit
8f274f5b1d
2 changed files with 33 additions and 0 deletions
|
@ -254,6 +254,24 @@ void initialize_def (struct symbol_s *sym, struct type_s *type,
|
|||
\return 1 if the defs overlap, 0 otherwise.
|
||||
*/
|
||||
int def_overlap (def_t *d1, def_t *d2);
|
||||
|
||||
/** Convenience function for obtaining a def's actual offset.
|
||||
|
||||
Takes care of an alias def's relative offset.
|
||||
|
||||
\param def The def of which to obtain the offset. May be an alias def.
|
||||
\return The actual offset of the def in the def's defspace.
|
||||
*/
|
||||
int def_offset (def_t *def);
|
||||
|
||||
/** Convenience function for obtaining a def's size.
|
||||
|
||||
Whether the def is an alias or not is irrelevant.
|
||||
|
||||
\param def The def of which to obtain the size.
|
||||
\return The size of the def.
|
||||
*/
|
||||
int def_size (def_t *def);
|
||||
//@}
|
||||
|
||||
#endif//__def_h
|
||||
|
|
|
@ -611,3 +611,18 @@ def_overlap (def_t *d1, def_t *d2)
|
|||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
def_offset (def_t *def)
|
||||
{
|
||||
int offset = def->offset;
|
||||
if (def->alias)
|
||||
offset += def->alias->offset;
|
||||
return offset;
|
||||
}
|
||||
|
||||
int
|
||||
def_size (def_t *def)
|
||||
{
|
||||
return type_size (def->type);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue