Skip to content

Commit

Permalink
Temp
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianStehle committed Apr 16, 2024
1 parent 0d2f2e3 commit ecb1dc5
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 80 deletions.
10 changes: 5 additions & 5 deletions YDotNet/Document/Doc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ internal Doc(nint handle, Doc? parent, bool isDeleted)

return (DocChannel.ObserveClear(doc, nint.Zero, callback), callback);
},
(doc, s) => DocChannel.UnobserveClear(doc, s));
(doc, s) => DocChannel.Unobserve(s));

onUpdateV1 = new EventSubscriber<UpdateEvent>(
EventManager,
Expand All @@ -89,7 +89,7 @@ internal Doc(nint handle, Doc? parent, bool isDeleted)

return (DocChannel.ObserveUpdatesV1(Handle, nint.Zero, callback), callback);
},
(doc, s) => DocChannel.UnobserveUpdatesV1(doc, s));
(doc, s) => DocChannel.Unobserve(s));

onUpdateV2 = new EventSubscriber<UpdateEvent>(
EventManager,
Expand All @@ -101,7 +101,7 @@ internal Doc(nint handle, Doc? parent, bool isDeleted)

return (DocChannel.ObserveUpdatesV2(Handle, nint.Zero, callback), callback);
},
(doc, s) => DocChannel.UnobserveUpdatesV2(doc, s));
(doc, s) => DocChannel.Unobserve(s));

onAfterTransaction = new EventSubscriber<AfterTransactionEvent>(
EventManager,
Expand All @@ -114,7 +114,7 @@ internal Doc(nint handle, Doc? parent, bool isDeleted)

return (DocChannel.ObserveAfterTransaction(doc, nint.Zero, callback), callback);
},
(doc, s) => DocChannel.UnobserveAfterTransaction(doc, s));
(doc, s) => DocChannel.Unobserve(s));

onSubDocs = new EventSubscriber<SubDocsEvent>(
EventManager,
Expand All @@ -126,7 +126,7 @@ internal Doc(nint handle, Doc? parent, bool isDeleted)

return (DocChannel.ObserveSubDocs(doc, nint.Zero, callback), callback);
},
(doc, s) => DocChannel.UnobserveSubDocs(doc, s));
(doc, s) => DocChannel.Unobserve(s));
}

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion YDotNet/Document/Types/Arrays/Array.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using YDotNet.Document.Types.Branches;
using YDotNet.Infrastructure;
using YDotNet.Infrastructure.Extensions;
using YDotNet.Native.Document;
using YDotNet.Native.StickyIndex;
using YDotNet.Native.Types;

Expand All @@ -31,7 +32,7 @@ internal Array(nint handle, Doc doc, bool isDeleted)

return (ArrayChannel.Observe(array, nint.Zero, callback), callback);
},
ArrayChannel.Unobserve);
(_, s) => DocChannel.Unobserve(s));
}

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion YDotNet/Document/Types/Branches/Branch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using YDotNet.Document.Transactions;
using YDotNet.Document.Types.Events;
using YDotNet.Infrastructure;
using YDotNet.Native.Document;
using YDotNet.Native.Document.Events;
using YDotNet.Native.Types.Branches;

Expand Down Expand Up @@ -36,7 +37,7 @@ internal protected Branch(nint handle, Doc doc, bool isDeleted)

return (BranchChannel.ObserveDeep(branch, nint.Zero, callback), callback);
},
(branch, s) => BranchChannel.UnobserveDeep(branch, s));
(_, s) => DocChannel.Unobserve(s));
#pragma warning restore CA1806 // Do not ignore method results
}

Expand Down
3 changes: 2 additions & 1 deletion YDotNet/Document/Types/Maps/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using YDotNet.Document.Types.Maps.Events;
using YDotNet.Infrastructure;
using YDotNet.Infrastructure.Extensions;
using YDotNet.Native.Document;
using YDotNet.Native.Types.Maps;

namespace YDotNet.Document.Types.Maps;
Expand All @@ -29,7 +30,7 @@ internal Map(nint handle, Doc doc, bool isDeleted)

return (MapChannel.Observe(map, nint.Zero, callback), callback);
},
MapChannel.Unobserve);
(_, s) => DocChannel.Unobserve(s));
}

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion YDotNet/Document/Types/Texts/Text.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using YDotNet.Document.Types.Texts.Events;
using YDotNet.Infrastructure;
using YDotNet.Infrastructure.Extensions;
using YDotNet.Native.Document;
using YDotNet.Native.StickyIndex;
using YDotNet.Native.Types.Texts;

Expand All @@ -31,7 +32,7 @@ internal Text(nint handle, Doc doc, bool isDeleted)

return (TextChannel.Observe(text, nint.Zero, callback), callback);
},
TextChannel.Unobserve);
(_, s) => DocChannel.Unobserve(s));
}

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion YDotNet/Document/Types/XmlElements/XmlElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using YDotNet.Document.Types.XmlTexts;
using YDotNet.Infrastructure;
using YDotNet.Infrastructure.Extensions;
using YDotNet.Native.Document;
using YDotNet.Native.Types;

namespace YDotNet.Document.Types.XmlElements;
Expand All @@ -31,7 +32,7 @@ internal XmlElement(nint handle, Doc doc, bool isDeleted)

return (XmlElementChannel.Observe(xmlElement, nint.Zero, callback), callback);
},
XmlElementChannel.Unobserve);
(_, s) => DocChannel.Unobserve(s));
}

/// <summary>
Expand Down
5 changes: 3 additions & 2 deletions YDotNet/Document/UndoManagers/UndoManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using YDotNet.Document.Types.Branches;
using YDotNet.Document.UndoManagers.Events;
using YDotNet.Infrastructure;
using YDotNet.Native.Document;
using YDotNet.Native.UndoManager;
using YDotNet.Native.UndoManager.Events;

Expand Down Expand Up @@ -36,7 +37,7 @@ public UndoManager(Doc doc, Branch branch, UndoManagerOptions? options = null)

return (UndoManagerChannel.ObserveAdded(Handle, nint.Zero, callback), callback);
},
(owner, s) => UndoManagerChannel.UnobserveAdded(owner, s));
(_, s) => DocChannel.Unobserve(s));

onPopped = new EventSubscriber<UndoEvent>(
doc.EventManager,
Expand All @@ -48,7 +49,7 @@ public UndoManager(Doc doc, Branch branch, UndoManagerOptions? options = null)

return (UndoManagerChannel.ObservePopped(Handle, nint.Zero, callback), callback);
},
(owner, s) => UndoManagerChannel.UnobservePopped(owner, s));
(_, s) => DocChannel.Unobserve(s));
#pragma warning restore CA1806 // Do not ignore method results
}

Expand Down
28 changes: 2 additions & 26 deletions YDotNet/Native/Document/DocChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,48 +120,24 @@ internal static class DocChannel
EntryPoint = "ydoc_observe_clear")]
public static extern uint ObserveClear(nint doc, nint state, ObserveClearCallback callback);

[DllImport(
ChannelSettings.NativeLib,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "ydoc_unobserve_clear")]
public static extern uint UnobserveClear(nint doc, uint subscriptionId);

[DllImport(
ChannelSettings.NativeLib,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "ydoc_observe_updates_v1")]
public static extern uint ObserveUpdatesV1(nint doc, nint state, ObserveUpdatesCallback callback);

[DllImport(
ChannelSettings.NativeLib,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "ydoc_unobserve_updates_v1")]
public static extern uint UnobserveUpdatesV1(nint doc, uint subscriptionId);

[DllImport(
ChannelSettings.NativeLib,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "ydoc_observe_updates_v2")]
public static extern uint ObserveUpdatesV2(nint doc, nint state, ObserveUpdatesCallback callback);

[DllImport(
ChannelSettings.NativeLib,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "ydoc_unobserve_updates_v2")]
public static extern uint UnobserveUpdatesV2(nint doc, uint subscriptionId);

[DllImport(
ChannelSettings.NativeLib,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "ydoc_observe_after_transaction")]
public static extern uint ObserveAfterTransaction(nint doc, nint state, ObserveAfterTransactionCallback callback);

[DllImport(
ChannelSettings.NativeLib,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "ydoc_unobserve_after_transaction")]
public static extern uint UnobserveAfterTransaction(nint doc, uint subscriptionId);

[DllImport(
ChannelSettings.NativeLib,
CallingConvention = CallingConvention.Cdecl,
Expand All @@ -171,6 +147,6 @@ internal static class DocChannel
[DllImport(
ChannelSettings.NativeLib,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "ydoc_unobserve_subdocs")]
public static extern uint UnobserveSubDocs(nint doc, uint subscriptionId);
EntryPoint = "yunobserve")]
public static extern uint Unobserve(uint subscriptionId);
}
6 changes: 0 additions & 6 deletions YDotNet/Native/Types/ArrayChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,4 @@ internal static class ArrayChannel
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "yarray_event_delta")]
public static extern nint ObserveEventDelta(nint arrayEvent, out uint length);

[DllImport(
ChannelSettings.NativeLib,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "yarray_unobserve")]
public static extern void Unobserve(nint array, uint subscriptionId);
}
6 changes: 0 additions & 6 deletions YDotNet/Native/Types/Branches/BranchChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ internal static class BranchChannel
EntryPoint = "yobserve_deep")]
public static extern uint ObserveDeep(nint type, nint state, ObserveCallback callback);

[DllImport(
ChannelSettings.NativeLib,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "yunobserve_deep")]
public static extern uint UnobserveDeep(nint type, uint subscriptionId);

[DllImport(
ChannelSettings.NativeLib,
CallingConvention = CallingConvention.Cdecl,
Expand Down
6 changes: 0 additions & 6 deletions YDotNet/Native/Types/Maps/MapChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,4 @@ internal static class MapChannel
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "ymap_event_target")]
public static extern nint ObserveEventTarget(nint mapEvent);

[DllImport(
ChannelSettings.NativeLib,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "ymap_unobserve")]
public static extern void Unobserve(nint map, uint subscriptionId);
}
6 changes: 0 additions & 6 deletions YDotNet/Native/Types/Texts/TextChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,4 @@ internal static class TextChannel
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "ytext_event_target")]
public static extern nint ObserveEventTarget(nint textEvent);

[DllImport(
ChannelSettings.NativeLib,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "ytext_unobserve")]
public static extern void Unobserve(nint text, uint subscriptionId);
}
6 changes: 0 additions & 6 deletions YDotNet/Native/Types/XmlElementChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,4 @@ internal static class XmlElementChannel
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "yxmlelem_event_keys")]
public static extern nint ObserveEventKeys(nint eventHandle, out uint length);

[DllImport(
ChannelSettings.NativeLib,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "yxmlelem_unobserve")]
public static extern void Unobserve(nint handle, uint subscriptionId);
}
12 changes: 0 additions & 12 deletions YDotNet/Native/UndoManager/UndoManagerChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,12 @@ internal static class UndoManagerChannel
EntryPoint = "yundo_manager_observe_added")]
public static extern uint ObserveAdded(nint undoManager, nint state, ObserveAddedCallback callback);

[DllImport(
ChannelSettings.NativeLib,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "yundo_manager_unobserve_added")]
public static extern uint UnobserveAdded(nint undoManager, uint subscriptionId);

[DllImport(
ChannelSettings.NativeLib,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "yundo_manager_observe_popped")]
public static extern uint ObservePopped(nint undoManager, nint state, ObservePoppedCallback callback);

[DllImport(
ChannelSettings.NativeLib,
CallingConvention = CallingConvention.Cdecl,
EntryPoint = "yundo_manager_unobserve_popped")]
public static extern uint UnobservePopped(nint undoManager, uint subscriptionId);

[DllImport(
ChannelSettings.NativeLib,
CallingConvention = CallingConvention.Cdecl,
Expand Down

0 comments on commit ecb1dc5

Please sign in to comment.