1 #ifndef UNDO_HISTORY_H_
2 #define UNDO_HISTORY_H_
6 // TODO(#1030): UndoHistory context size is fixed
7 // If we treated it as a stack we could store
8 // the elements with variable size.
9 #define CONTEXT_SIZE 256
11 #define ASSERT_CONTEXT_SIZE(context) \
12 trace_assert(sizeof(context) <= CONTEXT_SIZE)
15 char data[CONTEXT_SIZE];
18 typedef void (*RevertAction)(void *layer, Context context);
27 Action create_action(void *layer, RevertAction revert,
29 size_t context_data_size)
33 trace_assert(context_data_size < CONTEXT_SIZE);
41 memcpy(action.context.data, context_data, context_data_size);
47 typedef struct UndoHistory UndoHistory;
49 UndoHistory *create_undo_history(void);
50 void destroy_undo_history(UndoHistory *undo_history);
52 void undo_history_push(UndoHistory *undo_history, Action action);
53 void undo_history_pop(UndoHistory *undo_history);
55 #endif // UNDO_HISTORY_H_