T_address, T_event, T_place, T_source_citation, T_text,
T_note_sub, T_multimedia_link, T_lds_event, T_user_ref_number,
T_change_date, T_personal_name, T_family_link, T_pedigree,
- T_association, T_source_event, T_source_description
-} OBJ_TYPE;
-
-/* Assumptions for context:
- - In case of error, NULL is passed as context
- - If not NULL, the ctxt_ptr of the context is not NULL also
- - UNEXPECTED_CONTEXT is not treated as an error, but as a warning
-*/
+ T_association, T_source_event, T_source_description,
-struct Gom_ctxt_struct {
- int ctxt_type;
- OBJ_TYPE obj_type;
- void* ctxt_ptr;
-};
+ T_LAST
+} OBJ_TYPE;
+struct Gom_ctxt_struct;
typedef struct Gom_ctxt_struct *Gom_ctxt;
Gom_ctxt make_gom_ctxt(int ctxt_type, OBJ_TYPE obj_type, void *ctxt_ptr);
-void destroy_gom_ctxt(Gom_ctxt ctxt);
+Gom_ctxt dup_gom_ctxt(Gom_ctxt ctxt, int ctxt_type);
+void* safe_ctxt_cast(Gom_ctxt ctxt, OBJ_TYPE type, const char* file, int line);
+int ctxt_type(Gom_ctxt ctxt);
+OBJ_TYPE ctxt_obj_type(Gom_ctxt ctxt);
+
void gom_cast_error(const char* file, int line,
OBJ_TYPE expected, OBJ_TYPE found);
void gom_no_context(const char* file, int line);
void gom_unexpected_context(const char* file, int line, OBJ_TYPE found);
void gom_xref_already_in_use(const char *xrefstr);
+void gom_move_error(const char* type);
+void gom_find_error(const char* type);
+void unref_xref_value(struct xref_value *xref);
int gom_write_xref_list(Gedcom_write_hndl hndl,
Gedcom_elt elt, int tag, int parent_rec_or_elt,
make_gom_ctxt(CTXT_TYPE, T_ ## STRUCTTYPE, CTXT_PTR)
#define SAFE_CTXT_CAST(STRUCTTYPE, VAL) \
- (((VAL)->obj_type == T_ ## STRUCTTYPE) ? \
- (VAL)->ctxt_ptr : \
- (gom_cast_error(__FILE__, __LINE__, T_ ## STRUCTTYPE, (VAL)->obj_type), \
- (VAL)->ctxt_ptr))
+ safe_ctxt_cast(VAL, T_ ## STRUCTTYPE, __FILE__, __LINE__)
#define SAFE_FREE(PTR) \
if (PTR) { \
void NULL_DESTROY(void* anything);
-#define xref_list_cleanup NULL_DESTROY
-
#include "func_template.h"
+DECLARE_UNREFALLFUNC(xref_list);
+DECLARE_CLEANFUNC(xref_list);
+
#endif /* __GOM_INTERNAL_H */