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)
21 char data[CONTEXT_SIZE];
24 typedef void (*RevertAction)(void *layer, Context context);
33 Action create_action(void *layer, RevertAction revert,
35 size_t context_data_size)
39 trace_assert(context_data_size < CONTEXT_SIZE);
47 memcpy(action.context.data, context_data, context_data_size);
53 typedef struct UndoHistory UndoHistory;
55 UndoHistory *create_undo_history(void);
56 void destroy_undo_history(UndoHistory *undo_history);
58 void undo_history_push(UndoHistory *undo_history, Action action);
59 void undo_history_pop(UndoHistory *undo_history);
61 #endif // UNDO_HISTORY_H_