refactor(undo): switch oakundo to refcounted value handles, migrate consumers

- OakUndoCommand/OakUndoStack become neutral by-value handles
  {ctx, addref, release, abi_version}; a handle is a shared_ptr
  equivalent at the ABI level, internals untouched (box owns/observes
  flag; containers adopt, boxes created by factories own)
- oaknode command factories and undoable variants return/write value
  handles; timeline command classes hold value handles; task import
  take_command returns a value handle
- tests updated everywhere; suites green: oakundo 22, oaktimeline 117,
  oaktask 106, oaknode 96, oakrender 44, oakcodec 18, oakcommon 193,
  oakaudio 36
This commit is contained in:
2026-08-07 15:48:34 +08:00
parent da2ab512c6
commit 295ea1bfe5
41 changed files with 837 additions and 684 deletions
+1 -1
View File
@@ -84,7 +84,7 @@ OakNodeNode *oaknode_folder_as_node(OakNodeFolder *folder);
* @brief Create an undoable FolderAddChild command. Owned; free with
* oakundo_command_free().
*/
OakUndoCommand *oaknode_command_create_folder_add_child(
OakUndoCommand oaknode_command_create_folder_add_child(
OakNodeFolder *folder, OakNodeNode *child);
/**
+2 -2
View File
@@ -88,7 +88,7 @@ int oaknode_group_add_input_passthrough_undoable(OakNodeGroup *group,
OakNodeNode *node,
const char *input_id,
int element,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/**
* @brief Remove the passthrough for (`node`, `input_id`, `element`)
@@ -137,7 +137,7 @@ int oaknode_group_set_output_passthrough(OakNodeGroup *group,
* (olive::NodeGroupSetOutputPassthrough).
*/
int oaknode_group_set_output_passthrough_undoable(
OakNodeGroup *group, OakNodeNode *node, OakUndoCommand **out_command);
OakNodeGroup *group, OakNodeNode *node, OakUndoCommand *out_command);
/**
* @brief Resolve an input through group passthroughs
+5 -5
View File
@@ -109,7 +109,7 @@ int oaknode_keyframe_set_time(OakNodeKeyframe *keyframe, int64_t time_num,
*/
int oaknode_keyframe_set_time_undoable(OakNodeKeyframe *keyframe,
int64_t time_num, int64_t time_den,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/**
* @brief Read the keyframe's value mapped into `out`. Values without a
@@ -132,7 +132,7 @@ int oaknode_keyframe_set_value(OakNodeKeyframe *keyframe,
*/
int oaknode_keyframe_set_value_undoable(OakNodeKeyframe *keyframe,
const oaknode_value *v,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/**
* @brief Read a string value. Two-stage getter.
@@ -154,7 +154,7 @@ int oaknode_keyframe_set_value_string(OakNodeKeyframe *keyframe,
*/
int oaknode_keyframe_set_value_string_undoable(OakNodeKeyframe *keyframe,
const char *value,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/**
* @brief The keyframe's interpolation type (oaknode_keyframe_type).
@@ -171,7 +171,7 @@ int oaknode_keyframe_set_type(OakNodeKeyframe *keyframe, int type);
* @brief Create a set-type command (same semantics as the live variant).
*/
int oaknode_keyframe_set_type_undoable(OakNodeKeyframe *keyframe, int type,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/**
* @brief A bezier control point (`handle` is an
@@ -192,7 +192,7 @@ int oaknode_keyframe_set_bezier_control(OakNodeKeyframe *keyframe, int handle,
*/
int oaknode_keyframe_set_bezier_control_undoable(OakNodeKeyframe *keyframe,
int handle, double x, double y,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/**
* @brief The keyframe's track index.
+13 -13
View File
@@ -171,7 +171,7 @@ int oaknode_node_set_label(OakNodeNode *node, const char *label);
* @return OAKNODE_OK or a negative OAKNODE_E_* error code.
*/
int oaknode_node_set_label_undoable(OakNodeNode *node, const char *label,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/**
* @brief The node's override color index (Node::get_override_color();
@@ -196,7 +196,7 @@ int oaknode_node_set_override_color(OakNodeNode *node, int index);
* @return OAKNODE_OK or a negative OAKNODE_E_* error code.
*/
int oaknode_node_set_override_color_undoable(OakNodeNode *node, int index,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/**
* @brief 1 if the node is enabled (the boolean "enabled_in" input's
@@ -220,7 +220,7 @@ int oaknode_node_set_enabled(OakNodeNode *node, int enabled);
* @return OAKNODE_OK or a negative OAKNODE_E_* error code.
*/
int oaknode_node_set_enabled_undoable(OakNodeNode *node, int enabled,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/* ---- Input introspection ------------------------------------------------ */
@@ -310,7 +310,7 @@ int oaknode_node_set_input(OakNodeNode *node, const char *input_id,
*/
int oaknode_node_set_input_undoable(OakNodeNode *node, const char *input_id,
const oaknode_value *v,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/**
* @brief Read a string-family input's standard value. Two-stage getter.
@@ -331,7 +331,7 @@ int oaknode_node_set_input_string(OakNodeNode *node, const char *input_id,
int oaknode_node_set_input_string_undoable(OakNodeNode *node,
const char *input_id,
const char *value,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/* ---- Graph editing -------------------------------------------------------- */
@@ -356,7 +356,7 @@ int oaknode_node_connect(OakNodeNode *output_node, OakNodeNode *input_node,
int oaknode_node_connect_undoable(OakNodeNode *output_node,
OakNodeNode *input_node,
const char *input_id,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/**
* @brief Remove the edge feeding `input_node`'s `input_id` directly
@@ -371,7 +371,7 @@ int oaknode_node_disconnect(OakNodeNode *input_node, const char *input_id);
*/
int oaknode_node_disconnect_undoable(OakNodeNode *input_node,
const char *input_id,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/**
* @brief Number of outgoing edges (Node::output_connections()).
@@ -422,7 +422,7 @@ int oaknode_node_unlink(OakNodeNode *a, OakNodeNode *b, int *out_unlinked);
* `link` != 0 links, 0 unlinks).
*/
int oaknode_node_link_undoable(OakNodeNode *a, OakNodeNode *b, int link,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/**
* @brief 1 if the two nodes are linked (Node::are_linked()).
@@ -477,7 +477,7 @@ int oaknode_node_set_context_position(OakNodeNode *node, OakNodeNode *context,
int oaknode_node_set_context_position_undoable(OakNodeNode *node,
OakNodeNode *context, double x,
double y, int expanded,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/**
* @brief Remove the node from `context` directly (live).
@@ -504,7 +504,7 @@ OakNodeNode *oaknode_node_create_copy(const OakNodeNode *node);
* until then. Returns NULL on failure.
*/
OakNodeNode *oaknode_node_copy_in_graph(OakNodeNode *node,
OakUndoCommand **out_command);
OakUndoCommand *out_command);
/**
* @brief Get the project this node belongs to (borrowed). *out may be
@@ -537,7 +537,7 @@ int oaknode_node_disconnect_element(OakNodeNode *input_node,
* @brief Create a command that adds a node to a project's graph
* (olive::NodeAddCommand). Owned; free with oakundo_command_free().
*/
OakUndoCommand *oaknode_command_create_add_node(OakNodeProject *graph,
OakUndoCommand oaknode_command_create_add_node(OakNodeProject *graph,
OakNodeNode *node);
/**
@@ -545,7 +545,7 @@ OakUndoCommand *oaknode_command_create_add_node(OakNodeProject *graph,
* repositions its dependencies recursively
* (olive::NodeSetPositionAndDependenciesRecursivelyCommand). Owned.
*/
OakUndoCommand *oaknode_command_create_set_position_recursive(
OakUndoCommand oaknode_command_create_set_position_recursive(
OakNodeNode *node, OakNodeNode *context, double x, double y);
/**
@@ -607,7 +607,7 @@ int oaknode_node_find_input_footage(const OakNodeNode *node,
* Owned command handle; free with oakundo_command_free(). Returns NULL
* on failure.
*/
OakUndoCommand *oaknode_command_create_remove_node(OakNodeNode *node);
OakUndoCommand oaknode_command_create_remove_node(OakNodeNode *node);
/**
* @brief Destroy an OWNED node immediately (C++ delete). NULL is a no-op.
+1 -1
View File
@@ -57,7 +57,7 @@ OakTaskTask *oaktask_create_project_import(OakNodeFolder *folder,
int url_count);
/** @brief Take the import's undo command (ownership transfer). */
OakUndoCommand *oaktask_import_take_command(OakTaskTask *t);
OakUndoCommand oaktask_import_take_command(OakTaskTask *t);
int oaktask_import_footage_count(OakTaskTask *t);
+11 -11
View File
@@ -41,60 +41,60 @@ extern "C" {
*/
/** @brief olive::TimelineAddTrackCommand. */
OakUndoCommand *oaktimeline_add_track_command(OakNodeTrackList *list);
OakUndoCommand oaktimeline_add_track_command(OakNodeTrackList *list);
/** @brief olive::TimelineRemoveTrackCommand. */
OakUndoCommand *oaktimeline_remove_track_command(OakNodeTrack *track);
OakUndoCommand oaktimeline_remove_track_command(OakNodeTrack *track);
/** @brief olive::TrackPlaceBlockCommand. */
OakUndoCommand *oaktimeline_place_block_command(OakNodeTrackList *list,
OakUndoCommand oaktimeline_place_block_command(OakNodeTrackList *list,
int track_index,
OakNodeBlock *block,
int64_t in_num,
int64_t in_den);
/** @brief olive::TrackReplaceBlockWithGapCommand. */
OakUndoCommand *oaktimeline_replace_block_with_gap_command(
OakUndoCommand oaktimeline_replace_block_with_gap_command(
OakNodeTrack *track, OakNodeBlock *block);
/**
* @brief olive::BlockTrimCommand. `mode` is an OakTimelineMovementMode
* value (k_trim_in / k_trim_out).
*/
OakUndoCommand *oaktimeline_trim_command(OakNodeTrack *track,
OakUndoCommand oaktimeline_trim_command(OakNodeTrack *track,
OakNodeBlock *block,
int64_t new_length_num,
int64_t new_length_den, int mode);
/** @brief olive::BlockSplitCommand on a set of blocks at one point. */
OakUndoCommand *oaktimeline_split_command(OakNodeBlock *const *blocks,
OakUndoCommand oaktimeline_split_command(OakNodeBlock *const *blocks,
int count, int64_t point_num,
int64_t point_den);
/** @brief olive::BlockSplitPreservingLinksCommand. */
OakUndoCommand *oaktimeline_split_preserving_links_command(
OakUndoCommand oaktimeline_split_preserving_links_command(
OakNodeBlock *const *blocks, int count, const int64_t *point_nums,
const int64_t *point_dens, int time_count);
/** @brief olive::TimelineRippleDeleteGapsAtRegionsCommand. */
OakUndoCommand *oaktimeline_ripple_delete_gaps_command(
OakUndoCommand oaktimeline_ripple_delete_gaps_command(
OakNodeSequence *sequence, const int64_t *in_nums,
const int64_t *in_dens, const int64_t *out_nums,
const int64_t *out_dens, OakNodeTrack *const *tracks, int range_count);
/** @brief olive::TrackSlideCommand. */
OakUndoCommand *oaktimeline_slide_command(
OakUndoCommand oaktimeline_slide_command(
OakNodeTrack *track, OakNodeBlock *const *blocks, int block_count,
OakNodeBlock *in_adjacent, OakNodeBlock *out_adjacent,
int64_t movement_num, int64_t movement_den);
/** @brief olive::TrackRippleRemoveAreaCommand. */
OakUndoCommand *oaktimeline_ripple_remove_area_command(
OakUndoCommand oaktimeline_ripple_remove_area_command(
OakNodeTrack *track, int64_t in_num, int64_t in_den, int64_t out_num,
int64_t out_den);
/** @brief olive::TrackListInsertGaps. */
OakUndoCommand *oaktimeline_insert_gaps_command(OakNodeTrackList *list,
OakUndoCommand oaktimeline_insert_gaps_command(OakNodeTrackList *list,
int64_t point_num,
int64_t point_den,
int64_t length_num,
+4 -4
View File
@@ -65,7 +65,7 @@ int oaktimeline_marker_at(const OakTimelineMarkerList *list, int index,
* Owned command; free with oakundo_command_free(). Redo it directly or
* push it on an undo stack. Returns NULL on failure.
*/
OakUndoCommand *oaktimeline_marker_add_command(
OakUndoCommand oaktimeline_marker_add_command(
OakTimelineMarkerList *list, int in_num, int in_den, int out_num,
int out_den, const char *name, int color);
@@ -74,13 +74,13 @@ OakUndoCommand *oaktimeline_marker_add_command(
* OAKTIMELINE_E_NOT_FOUND (as NULL result documented by error) is
* reported by returning NULL.
*/
OakUndoCommand *oaktimeline_marker_remove_at_command(
OakUndoCommand oaktimeline_marker_remove_at_command(
OakTimelineMarkerList *list, int index);
/**
* @brief Create a command that sets a marker's time range.
*/
OakUndoCommand *oaktimeline_marker_set_time_command(
OakUndoCommand oaktimeline_marker_set_time_command(
OakTimelineMarkerList *list, int index, int in_num, int in_den,
int out_num, int out_den);
@@ -89,7 +89,7 @@ OakUndoCommand *oaktimeline_marker_set_time_command(
* `name` may be NULL to leave the name unchanged (color still applies
* when >= 0; both NULL-name and color < 0 is a no-op error).
*/
OakUndoCommand *oaktimeline_marker_set_props_command(
OakUndoCommand oaktimeline_marker_set_props_command(
OakTimelineMarkerList *list, int index, int color, const char *name);
/**
+2 -2
View File
@@ -60,7 +60,7 @@ int oaktimeline_workarea_set_range(OakTimelineWorkArea *w, int in_num,
* The old range must be supplied by the caller (facade knows what it
* changed from). Owned; free with oakundo_command_free().
*/
OakUndoCommand *oaktimeline_workarea_set_range_command(
OakUndoCommand oaktimeline_workarea_set_range_command(
OakTimelineWorkArea *w, int in_num, int in_den, int out_num,
int out_den, int old_in_num, int old_in_den, int old_out_num,
int old_out_den);
@@ -68,7 +68,7 @@ OakUndoCommand *oaktimeline_workarea_set_range_command(
/**
* @brief Create a set-enabled command (olive::WorkareaSetEnabledCommand).
*/
OakUndoCommand *oaktimeline_workarea_set_enabled_command(
OakUndoCommand oaktimeline_workarea_set_enabled_command(
OakTimelineWorkArea *w, int enabled);
/**
+47 -35
View File
@@ -21,31 +21,43 @@
#ifndef OAK_EDITOR_UNDO_UNDOCOMMAND_H
#define OAK_EDITOR_UNDO_UNDOCOMMAND_H
#include <stdint.h>
#include "undo/error.h"
#ifdef __cplusplus
extern "C" {
#endif
#define OAKUNDO_ABI_VERSION 1
/**
* @brief Opaque handle to an undo command (olive::UndoCommand).
* @brief Reference-counted handle to an undo command
* (olive::UndoCommand).
*
* Handles created by oakundo_command_init() /
* oakundo_command_init_multi() own the underlying command and must be
* released with oakundo_command_free() UNLESS they are pushed onto an
* OakUndoStack, which takes ownership. Handles returned by
* oakundo_command_multi_child() are borrowed wrappers: free the wrapper
* with oakundo_command_free(), the underlying command stays owned by the
* multi command.
* The object never leaves the library that created it; every external
* reference is one of these handles. Semantics are shared_ptr-like:
* init/factory functions return a handle with count 1, addref(ctx)
* takes another reference, release(ctx) drops one and the library
* destroys the object when the count reaches zero.
*
* Pushing a command onto an OakUndoStack transfers one reference to the
* stack (the stack releases it when the command is discarded); callers
* may keep their own reference or release it right after the push.
*/
typedef struct OakUndoCommand OakUndoCommand;
typedef struct OakUndoCommand {
void *ctx; /**< Opaque pointer to the reference-counted object. */
void (*addref)(void *ctx); /**< Atomically increments the count. */
void (*release)(void *ctx); /**< Decrements the count, destroys at 0. */
uint32_t abi_version; /**< OAKUNDO_ABI_VERSION. */
} OakUndoCommand;
/**
* @brief Callback table backing a caller-defined undo command.
*
* Any callback may be NULL; a NULL redo/undo makes that direction a
* no-op. free_fn is invoked when the command is destroyed (whether pushed
* onto a stack or freed directly) and releases userdata.
* no-op. free_fn is invoked when the command is destroyed (whether held
* by a stack or released directly) and releases userdata.
*/
typedef struct OakUndoCommandVtable {
void (*redo)(void *userdata);
@@ -58,30 +70,30 @@ typedef struct OakUndoCommandVtable {
*
* The command takes ownership of `userdata`; `vtable` is copied.
*
* @return Command handle, or NULL on invalid argument or allocation
* failure.
* @return Command handle with count 1; ctx is NULL on invalid argument
* or allocation failure.
*/
OakUndoCommand *oakundo_command_init(const OakUndoCommandVtable *vtable,
void *userdata);
OakUndoCommand oakundo_command_init(const OakUndoCommandVtable *vtable,
void *userdata);
/**
* @brief Create an empty multi command (olive::MultiUndoCommand).
*
* @return Command handle, or NULL on allocation failure.
* @return Command handle with count 1; ctx is NULL on allocation
* failure.
*/
OakUndoCommand *oakundo_command_init_multi(void);
OakUndoCommand oakundo_command_init_multi(void);
/**
* @brief Add `child` to the multi command `multi`.
*
* On success the multi command takes ownership of the underlying child
* command; the child handle wrapper is consumed and must not be used or
* freed afterwards.
* The multi command takes one reference to the child; the caller keeps
* its own reference and may release it after the call.
*
* @return OAKUNDO_OK or a negative OAKUNDO_E_* error code.
*/
int oakundo_command_multi_add_child(OakUndoCommand *multi,
OakUndoCommand *child);
int oakundo_command_multi_add_child(OakUndoCommand multi,
OakUndoCommand child);
/**
* @brief Query the number of children in a multi command.
@@ -90,19 +102,20 @@ int oakundo_command_multi_add_child(OakUndoCommand *multi,
*
* @return OAKUNDO_OK or a negative OAKUNDO_E_* error code.
*/
int oakundo_command_multi_child_count(OakUndoCommand *multi, int *out_count);
int oakundo_command_multi_child_count(OakUndoCommand multi,
int *out_count);
/**
* @brief Borrow a handle to the child at `index` of a multi command.
* @brief Reference to the child at `index` of a multi command.
*
* The returned handle is a wrapper owned by the caller (free with
* oakundo_command_free()); the underlying command is owned by `multi`.
* The returned handle carries its own reference; release it with
* oakundo_command_free().
*
* @return OAKUNDO_OK, OAKUNDO_E_NOT_FOUND for an out-of-range index, or
* another negative OAKUNDO_E_* error code.
*/
int oakundo_command_multi_child(OakUndoCommand *multi, int index,
OakUndoCommand **out_child);
int oakundo_command_multi_child(OakUndoCommand multi, int index,
OakUndoCommand *out_child);
/**
* @brief Execute the command's redo without a stack
@@ -110,7 +123,7 @@ int oakundo_command_multi_child(OakUndoCommand *multi, int index,
*
* @return OAKUNDO_OK or a negative OAKUNDO_E_* error code.
*/
int oakundo_command_redo_now(OakUndoCommand *command);
int oakundo_command_redo_now(OakUndoCommand command);
/**
* @brief Execute the command's undo without a stack
@@ -118,15 +131,14 @@ int oakundo_command_redo_now(OakUndoCommand *command);
*
* @return OAKUNDO_OK or a negative OAKUNDO_E_* error code.
*/
int oakundo_command_undo_now(OakUndoCommand *command);
int oakundo_command_undo_now(OakUndoCommand command);
/**
* @brief Destroy a command handle.
* @brief Release one reference to a command handle.
*
* Owned handles destroy the underlying command; borrowed handles (from
* oakundo_command_multi_child()) only destroy the wrapper. Commands
* pushed onto an OakUndoStack are owned by the stack and must not be
* freed by the caller. NULL is a no-op.
* Convenience wrapper around handle.release(handle.ctx): destroys the
* command when the count reaches zero. NULL handle or NULL ctx is a
* no-op; clears `command->ctx` after releasing.
*/
void oakundo_command_free(OakUndoCommand *command);
+35 -26
View File
@@ -31,50 +31,59 @@ extern "C" {
#endif
/**
* @brief Opaque handle to an undo stack (olive::UndoStack).
* @brief Reference-counted handle to an undo stack (olive::UndoStack).
*
* Same ownership/count semantics as OakUndoCommand (see
* undo/undocommand.h).
*/
typedef struct OakUndoStack OakUndoStack;
typedef struct OakUndoStack {
void *ctx; /**< Opaque pointer to the reference-counted object. */
void (*addref)(void *ctx); /**< Atomically increments the count. */
void (*release)(void *ctx); /**< Decrements the count, destroys at 0. */
uint32_t abi_version; /**< OAKUNDO_ABI_VERSION. */
} OakUndoStack;
/**
* @brief Create an undo stack.
* @brief Create an undo stack (count 1).
*
* A fresh stack contains a single "New/Open Project" empty command,
* matching olive::UndoStack::clear().
*
* @return Stack handle, or NULL on allocation failure.
* @return Stack handle; ctx is NULL on allocation failure.
*/
OakUndoStack *oakundo_undostack_init(void);
OakUndoStack oakundo_undostack_init(void);
/**
* @brief Destroy an undo stack and all commands it owns.
* @brief Release one reference to an undo stack.
*
* NULL is a no-op.
* NULL handle or NULL ctx is a no-op; clears `stack->ctx` after
* releasing.
*/
void oakundo_undostack_free(OakUndoStack *stack);
/**
* @brief Push `command` onto the stack and execute its redo.
*
* On success the stack takes ownership of the underlying command; the
* handle wrapper is consumed and must not be used or freed afterwards.
* An empty multi command is deleted immediately (not pushed), matching
* olive::UndoStack::push. `name` is the user-visible label (NULL behaves
* like an empty label).
* The stack takes one reference to the command; the caller keeps its
* own reference and may release it after the call. An empty multi
* command is deleted immediately (not pushed), matching
* olive::UndoStack::push. `name` is the user-visible label (NULL
* behaves like an empty label).
*
* @return OAKUNDO_OK or a negative OAKUNDO_E_* error code.
*/
int oakundo_undostack_push(OakUndoStack *stack, OakUndoCommand *command,
int oakundo_undostack_push(OakUndoStack stack, OakUndoCommand command,
const char *name);
/**
* @brief Push a command that has already been executed (redo skipped).
*
* Ownership rules match oakundo_undostack_push().
* Reference rules match oakundo_undostack_push().
*
* @return OAKUNDO_OK or a negative OAKUNDO_E_* error code.
*/
int oakundo_undostack_push_pre_executed(OakUndoStack *stack,
OakUndoCommand *command,
int oakundo_undostack_push_pre_executed(OakUndoStack stack,
OakUndoCommand command,
const char *name);
/**
@@ -82,14 +91,14 @@ int oakundo_undostack_push_pre_executed(OakUndoStack *stack,
*
* @return OAKUNDO_OK or a negative OAKUNDO_E_* error code.
*/
int oakundo_undostack_undo(OakUndoStack *stack);
int oakundo_undostack_undo(OakUndoStack stack);
/**
* @brief Redo the most recently undone command, if any.
*
* @return OAKUNDO_OK or a negative OAKUNDO_E_* error code.
*/
int oakundo_undostack_redo(OakUndoStack *stack);
int oakundo_undostack_redo(OakUndoStack stack);
/**
* @brief Undo/redo until the done-command count equals `index`
@@ -97,7 +106,7 @@ int oakundo_undostack_redo(OakUndoStack *stack);
*
* @return OAKUNDO_OK or a negative OAKUNDO_E_* error code.
*/
int oakundo_undostack_jump(OakUndoStack *stack, int64_t index);
int oakundo_undostack_jump(OakUndoStack stack, int64_t index);
/**
* @brief Delete all commands and push the fresh "New/Open Project" empty
@@ -105,7 +114,7 @@ int oakundo_undostack_jump(OakUndoStack *stack, int64_t index);
*
* @return OAKUNDO_OK or a negative OAKUNDO_E_* error code.
*/
int oakundo_undostack_clear(OakUndoStack *stack);
int oakundo_undostack_clear(OakUndoStack stack);
/**
* @brief Query whether undo (redo) is currently possible.
@@ -114,8 +123,8 @@ int oakundo_undostack_clear(OakUndoStack *stack);
*
* @return OAKUNDO_OK or a negative OAKUNDO_E_* error code.
*/
int oakundo_undostack_can_undo(OakUndoStack *stack, int *out_value);
int oakundo_undostack_can_redo(OakUndoStack *stack, int *out_value);
int oakundo_undostack_can_undo(OakUndoStack stack, int *out_value);
int oakundo_undostack_can_redo(OakUndoStack stack, int *out_value);
/**
* @brief Total number of history rows (done + undone commands).
@@ -124,7 +133,7 @@ int oakundo_undostack_can_redo(OakUndoStack *stack, int *out_value);
*
* @return OAKUNDO_OK or a negative OAKUNDO_E_* error code.
*/
int oakundo_undostack_count(OakUndoStack *stack, int64_t *out_count);
int oakundo_undostack_count(OakUndoStack stack, int64_t *out_count);
/**
* @brief Current position in the history: the number of done commands
@@ -134,7 +143,7 @@ int oakundo_undostack_count(OakUndoStack *stack, int64_t *out_count);
*
* @return OAKUNDO_OK or a negative OAKUNDO_E_* error code.
*/
int oakundo_undostack_index(OakUndoStack *stack, int64_t *out_index);
int oakundo_undostack_index(OakUndoStack stack, int64_t *out_index);
/**
* @brief Label of the history row at `row` (0-based, two-stage getter).
@@ -143,7 +152,7 @@ int oakundo_undostack_index(OakUndoStack *stack, int64_t *out_index);
* (non-negative), OAKUNDO_E_NOT_FOUND for an invalid row, or
* another negative OAKUNDO_E_* error code.
*/
int oakundo_undostack_command_text(OakUndoStack *stack, int64_t row,
int oakundo_undostack_command_text(OakUndoStack stack, int64_t row,
char *buf, int buf_size);
/**
@@ -154,7 +163,7 @@ int oakundo_undostack_command_text(OakUndoStack *stack, int64_t row,
* @return OAKUNDO_OK, OAKUNDO_E_NOT_FOUND for an invalid row, or another
* negative OAKUNDO_E_* error code.
*/
int oakundo_undostack_command_is_done(OakUndoStack *stack, int64_t row,
int oakundo_undostack_command_is_done(OakUndoStack stack, int64_t row,
int *out_value);
#ifdef __cplusplus