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
+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);
/**