|
Packit Service |
28f424 |
#ifndef RECORD_H_
|
|
Packit Service |
28f424 |
#define RECORD_H_
|
|
Packit Service |
28f424 |
|
|
Packit Service |
28f424 |
#include <stdbool.h>
|
|
Packit Service |
28f424 |
#include <stdio.h>
|
|
Packit Service |
28f424 |
|
|
Packit Service |
28f424 |
#include "list.h"
|
|
Packit Service |
28f424 |
#include "stack.h"
|
|
Packit Service |
28f424 |
#include "objects.h"
|
|
Packit Service |
28f424 |
|
|
Packit Service |
28f424 |
#define RECORD_VERSION_DECLARATION -1
|
|
Packit Service |
28f424 |
|
|
Packit Service |
28f424 |
/*
|
|
Packit Service |
28f424 |
* Structure of the database record:
|
|
Packit Service |
28f424 |
*
|
|
Packit Service |
28f424 |
* key: record key, usually includes path the file, where the type is
|
|
Packit Service |
28f424 |
* defined (may include pseudo path, like <declaration>);
|
|
Packit Service |
28f424 |
* Does not contain version and the .txt suffix.
|
|
Packit Service |
28f424 |
*
|
|
Packit Service |
28f424 |
* version: type's version, used when we need to add another type of the same
|
|
Packit Service |
28f424 |
* name. It may happend, for example, when because of defines the same
|
|
Packit Service |
28f424 |
* structure has changed for different compilation units.
|
|
Packit Service |
28f424 |
*
|
|
Packit Service |
28f424 |
* It is not for the case, when the same structure defined in
|
|
Packit Service |
28f424 |
* different files -- it will have different keys, since it includes
|
|
Packit Service |
28f424 |
* the path;
|
|
Packit Service |
28f424 |
*
|
|
Packit Service |
28f424 |
* ref_count: reference counter, needed since the ownership is shared with the
|
|
Packit Service |
28f424 |
* internal database;
|
|
Packit Service |
28f424 |
*
|
|
Packit Service |
28f424 |
* cu: compilation unit, where the type for the record defined;
|
|
Packit Service |
28f424 |
*
|
|
Packit Service |
28f424 |
* origin: "File <file>:<line>" string, describing the source, where the type
|
|
Packit Service |
28f424 |
* for the record defined;
|
|
Packit Service |
28f424 |
*
|
|
Packit Service |
28f424 |
* stack: stack of types to reach this one.
|
|
Packit Service |
28f424 |
* Ex.: on the toplevel
|
|
Packit Service |
28f424 |
* struct A {
|
|
Packit Service |
28f424 |
* struct B fieldA;
|
|
Packit Service |
28f424 |
* }
|
|
Packit Service |
28f424 |
* in another file:
|
|
Packit Service |
28f424 |
* struct B {
|
|
Packit Service |
28f424 |
* basetype fieldB;
|
|
Packit Service |
28f424 |
* }
|
|
Packit Service |
28f424 |
* the "struct B" description will contain key of the "struct A"
|
|
Packit Service |
28f424 |
* description record in the stack;
|
|
Packit Service |
28f424 |
*
|
|
Packit Service |
28f424 |
* obj: pointer to the abstract type object, representing the toplevel type of
|
|
Packit Service |
28f424 |
* the record.
|
|
Packit Service |
28f424 |
*
|
|
Packit Service |
28f424 |
* link: name of weak link alisas for the weak aliases.
|
|
Packit Service |
28f424 |
*
|
|
Packit Service |
28f424 |
* free: type specific function to free the record
|
|
Packit Service |
28f424 |
* (there are normal, weak and assembly records).
|
|
Packit Service |
28f424 |
*
|
|
Packit Service |
28f424 |
* dump: type specific function for record output.
|
|
Packit Service |
28f424 |
*
|
|
Packit Service |
28f424 |
* dependents: objects that reference this record.
|
|
Packit Service |
28f424 |
*
|
|
Packit Service |
28f424 |
* list_node: node containing the record, record only belong to one list
|
|
Packit Service |
28f424 |
* at a time(usually record_list.records)
|
|
Packit Service |
28f424 |
*
|
|
Packit Service |
28f424 |
* failed: number of times the record could not be used for merging
|
|
Packit Service |
28f424 |
*/
|
|
Packit Service |
28f424 |
struct record {
|
|
Packit Service |
28f424 |
const char *key;
|
|
Packit Service |
28f424 |
int version;
|
|
Packit Service |
28f424 |
int ref_count;
|
|
Packit Service |
28f424 |
char *cu;
|
|
Packit Service |
28f424 |
const char *origin;
|
|
Packit Service |
28f424 |
stack_t *stack;
|
|
Packit Service |
28f424 |
obj_t *obj;
|
|
Packit Service |
28f424 |
char *link;
|
|
Packit Service |
28f424 |
void (*free)(struct record *);
|
|
Packit Service |
28f424 |
void (*dump)(struct record *, FILE *);
|
|
Packit Service |
28f424 |
|
|
Packit Service |
28f424 |
struct list dependents;
|
|
Packit Service |
28f424 |
struct list_node *list_node;
|
|
Packit Service |
28f424 |
unsigned int failed;
|
|
Packit Service |
28f424 |
};
|
|
Packit Service |
28f424 |
|
|
Packit Service |
28f424 |
static inline const char *record_get_key(struct record *record)
|
|
Packit Service |
28f424 |
{
|
|
Packit Service |
28f424 |
return record->key;
|
|
Packit Service |
28f424 |
}
|
|
Packit Service |
28f424 |
|
|
Packit Service |
28f424 |
static inline int record_get_version(struct record *record)
|
|
Packit Service |
28f424 |
{
|
|
Packit Service |
28f424 |
return record->version;
|
|
Packit Service |
28f424 |
}
|
|
Packit Service |
28f424 |
|
|
Packit Service |
28f424 |
static inline bool record_is_declaration(struct record *record)
|
|
Packit Service |
28f424 |
{
|
|
Packit Service |
28f424 |
return record->version == RECORD_VERSION_DECLARATION;
|
|
Packit Service |
28f424 |
}
|
|
Packit Service |
28f424 |
|
|
Packit Service |
28f424 |
bool record_same_declarations(struct record *r1, struct record *r2,
|
|
Packit Service |
28f424 |
struct set *processed);
|
|
Packit Service |
28f424 |
|
|
Packit Service |
28f424 |
#endif /* RECORD_H_ */
|