1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 03:28:20 +02:00

Got rid of Action<T>/Func<T>

This commit is contained in:
Brian Fiete 2020-05-08 07:10:35 -07:00
parent 44bd9c698f
commit b52db47d55
37 changed files with 94 additions and 88 deletions

View file

@ -53,7 +53,7 @@ namespace Beefy.theme.dark
public FontAlign mLabelAlign = FontAlign.Centered;
public FrameKind mFrameKind = .OnWindow;
public Event<Action<Menu>> mPopulateMenuAction ~ _.Dispose();
public Event<delegate void(Menu)> mPopulateMenuAction ~ _.Dispose();
public CBMenuWidget mCurMenuWidget;
bool mJustClosed;
public uint32 mBkgColor;

View file

@ -842,8 +842,8 @@ namespace Beefy.theme.dark
public SortType mSortType = SortType() ~ { mSortType.mColumn = -1; };
public Insets mInsets ~ delete _;
public Event<Action<DragEvent>> mOnDragUpdate ~ _.Dispose();
public Event<Action<DragEvent>> mOnDragEnd ~ _.Dispose();
public Event<delegate void(DragEvent)> mOnDragUpdate ~ _.Dispose();
public Event<delegate void(DragEvent)> mOnDragEnd ~ _.Dispose();
public this()
{

View file

@ -14,7 +14,7 @@ namespace Beefy.theme.dark
public bool mAllowEdit = true;
public Object mValue;
public List<Widget> mMoveWidgets;
public Action<DarkSmartEdit> mValueChangedAction;
public delegate void(DarkSmartEdit) mValueChangedAction;
bool mCancelingEdit;
float mMouseDownX;

View file

@ -397,7 +397,7 @@ namespace Beefy.theme.dark
return tabCount;
}
public override void WithTabs(Action<TabbedView.TabButton> func)
public override void WithTabs(delegate void(TabbedView.TabButton) func)
{
for (var tab in mTabs)
func(tab);

View file

@ -111,7 +111,7 @@ namespace Beefy.utils
Clear();
}
public void WithActions(Action<UndoAction> func)
public void WithActions(delegate void(UndoAction) func)
{
for (var action in mUndoList)
func(action);

View file

@ -376,7 +376,7 @@ namespace Beefy.widgets
}
protected void SerializeTimeline<T>(StructuredData data, TimelineData<T> timelineData, String name,
String[] componentNames, Action<StructuredData, T>[] writeActions, T theDefault) where T : IEquatable<T>
String[] componentNames, Delegate[] writeActions, T theDefault) where T : IEquatable<T>
{
/*if ((timelineData.mEntries != null) && (timelineData.mEntries.Count > 0))
{
@ -433,7 +433,7 @@ namespace Beefy.widgets
data.Add("ResId", resIdStr);
}
SerializeTimeline(data, mTimelineAnchor, "Anchor",
/*SerializeTimeline(data, mTimelineAnchor, "Anchor",
scope String[] { "X", "Y" },
scope Action<StructuredData, CompositionPos>[] { scope => CompositionPos.WriteX, scope => CompositionPos.WriteY },
CompositionPos(0, 0));
@ -451,7 +451,7 @@ namespace Beefy.widgets
SerializeTimeline(data, mTimelineRot, "Rotation",
scope String[] { "Angle" },
null,
0.0f);
0.0f);*/
}
public void RebuildChildIndices()

View file

@ -213,7 +213,7 @@ namespace Beefy.widgets
return parentFrame;
}
public void WithAllDockedWidgets(Action<DockedWidget> func)
public void WithAllDockedWidgets(delegate void(DockedWidget) func)
{
for (var dockedWidget in mDockedWidgets)
{

View file

@ -137,7 +137,7 @@ namespace Beefy.widgets
}
}
public void WithItems(Action<ListViewItem> func)
public void WithItems(delegate void(ListViewItem) func)
{
if (mChildItems != null)
{
@ -149,7 +149,7 @@ namespace Beefy.widgets
}
}
public void WithSelectedItems(Action<ListViewItem> func, bool skipSelectedChildrenOnSelectedItems = false, bool skipClosed = false)
public void WithSelectedItems(delegate void(ListViewItem) func, bool skipSelectedChildrenOnSelectedItems = false, bool skipClosed = false)
{
bool selfSelected = Selected;
if (selfSelected)
@ -684,7 +684,7 @@ namespace Beefy.widgets
protected ListViewItem mRoot;
public bool mListSizeDirty;
public float mHeaderHeight;
public Event<Action<ListViewItem>> mOnFocusChanged ~ _.Dispose();
public Event<delegate void(ListViewItem)> mOnFocusChanged ~ _.Dispose();
public float mBottomInset = 8;
public bool mAllowMultiSelect = true;
public Event<delegate void(ListViewItem item, float x, float y, int32 btnNum, int32 btnCount)> mOnItemMouseDown ~ _.Dispose();

View file

@ -110,7 +110,7 @@ namespace Beefy.widgets
public float mMaxContainerWidth = Int32.MaxValue;
public Insets mPopupInsets = new Insets() ~ delete _;
public bool mHasClosed;
public Event<Action<int>> mOnSelectionChanged ~ _.Dispose();
public Event<delegate void(int)> mOnSelectionChanged ~ _.Dispose();
public bool mWasInitialized;
public this(Menu menu)

View file

@ -14,7 +14,7 @@ namespace Beefy.widgets
{
public Scrollbar mScrollbar;
public DragHelper mDraggableHelper ~ delete _;
public Event<Action<float, float>> mOnDrag ~ _.Dispose();
public Event<delegate void(float, float)> mOnDrag ~ _.Dispose();
public this()
{

View file

@ -346,7 +346,7 @@ namespace Beefy.widgets
int32 mRefCount = 1;
public Event<OpenNewWindowDelegate> mOpenNewWindowDelegate ~ _.Dispose();
public Event<Action<TabbedView>> mTabbedViewClosed ~ _.Dispose();
public Event<delegate void(TabbedView)> mTabbedViewClosed ~ _.Dispose();
public SharedData Ref()
{
@ -363,7 +363,7 @@ namespace Beefy.widgets
public delegate void OpenNewWindowDelegate(TabbedView tabbedView, WidgetWindow newWindow);
public Action<Menu> mPopulateMenuEvent;
public delegate void(Menu) mPopulateMenuEvent;
public float mTabHeight;
public float mTabAreaWidth;
public bool mNeedResizeTabs;
@ -417,7 +417,7 @@ namespace Beefy.widgets
return mTabs.Count;
}
public virtual void WithTabs(Action<TabbedView.TabButton> func)
public virtual void WithTabs(delegate void(TabbedView.TabButton) func)
{
for (var tab in mTabs)
func(tab);

View file

@ -80,7 +80,7 @@ namespace Beefy.widgets
public Event<RemovedFromParentHandler> mOnRemovedFromParent ~ _.Dispose();
public Event<AddedToParentHandler> mOnAddedToParent ~ _.Dispose();
public Event<KeyDownHandler> mOnKeyDown ~ _.Dispose();
public Event<Action<Widget>> mOnDeleted ~ _.Dispose();
public Event<delegate void(Widget)> mOnDeleted ~ _.Dispose();
public Matrix Transform
{

View file

@ -29,7 +29,7 @@ namespace Beefy.widgets
public Event<MouseWheelHandler> mOnMouseWheel ~ _.Dispose();
public Event<MenuItemSelectedHandler> mOnMenuItemSelected ~ _.Dispose();
public Event<KeyDownHandler> mOnWindowKeyDown ~ _.Dispose();
public Event<Func<int32, int32, HitTestResult>> mOnHitTest ~ _.Dispose();
public Event<delegate HitTestResult(int32, int32)> mOnHitTest ~ _.Dispose();
public static Event<MouseLeftWindowHandler> sOnMouseLeftWindow ~ _.Dispose();
public static Event<WindowLostFocusHandler> sOnWindowLostFocus ~ _.Dispose();

View file

@ -1,10 +0,0 @@
namespace System
{
public delegate void Action();
public delegate void Action<T>(T obj);
public delegate void Action<T1, T2>(T1 p1, T2 p2);
public delegate void Action<T1, T2, T3>(T1 p1, T2 p2, T3 p3);
public delegate void Action<T1, T2, T3, T4>(T1 p1, T2 p2, T3 p3, T4 p4);
public delegate int Comparison<T>(T lhs, T rhs);
}

View file

@ -1,4 +0,0 @@
namespace System.Collections
{
}

View file

@ -39,6 +39,8 @@ namespace System
}
}
delegate void Action();
struct Function : int
{

View file

@ -1,7 +0,0 @@
namespace System
{
delegate TResult Func<TResult>();
delegate TResult Func<T1, TResult>(T1 p1);
delegate TResult Func<T1, T2, TResult>(T1 p1, T2 p2);
delegate TResult Func<T1, T2, T3, TResult>(T1 p1, T2 p2, T3 p3);
}

View file

@ -72,4 +72,6 @@ namespace System
{
}
public delegate int Comparison<T>(T lhs, T rhs);
}

View file

@ -195,7 +195,7 @@ namespace System.IO
public this(
bool isRead,
Func<Object, int> func, Object state,
delegate int(Object) func, Object state,
Stream stream, uint8[] buffer, int offset, int count, AsyncCallback callback) :
base(func, state, CancellationToken.None, TaskCreationOptions.DenyChildAttach)
{

View file

@ -32,7 +32,7 @@ namespace System.Threading.Tasks
}
public this(Func<Object, TResult> func, Object state, CancellationToken cancellationToken, TaskCreationOptions creationOptions)
public this(delegate TResult(Object) func, Object state, CancellationToken cancellationToken, TaskCreationOptions creationOptions)
: this(func, state, Task.[Friend]InternalCurrentIfAttached(creationOptions), cancellationToken,
creationOptions, InternalTaskOptions.None, null)
{
@ -40,7 +40,7 @@ namespace System.Threading.Tasks
//PossiblyCaptureContext(ref stackMark);
}
this(Func<TResult> valueSelector, Task parent, CancellationToken cancellationToken,
this(delegate TResult() valueSelector, Task parent, CancellationToken cancellationToken,
TaskCreationOptions creationOptions, InternalTaskOptions internalOptions, TaskScheduler scheduler) :
base(valueSelector, null, parent, cancellationToken, creationOptions, internalOptions, scheduler)
{
@ -103,9 +103,9 @@ namespace System.Threading.Tasks
return m_result;
}
List<Action<Task<TResult>>> mContinuations = new List<Action<Task<TResult>>>() ~ delete _;
List<delegate void(Task<TResult>)> mContinuations = new .() ~ delete _;
public Task ContinueWith(Action<Task<TResult>> continuationAction)
public Task ContinueWith(delegate void(Task<TResult>) continuationAction)
{
bool callDirectly = false;
using (mMonitor.Enter())
@ -130,7 +130,7 @@ namespace System.Threading.Tasks
public void Notify(bool allowDelete = true)
{
var continueList = scope List<Action<Task<TResult>>>(16);
var continueList = scope List<delegate void(Task<TResult>)>(16);
using (mMonitor.Enter())
{
mHasCompleted = true;

View file

@ -255,7 +255,7 @@ namespace System.Threading.Tasks
}
public this(Action<Object> action, Object state, CancellationToken cancellationToken, TaskCreationOptions creationOptions)
public this(delegate void(Object) action, Object state, CancellationToken cancellationToken, TaskCreationOptions creationOptions)
: this(action, state, Task.InternalCurrentIfAttached(creationOptions), cancellationToken, creationOptions, InternalTaskOptions.None, null)
{
//StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
@ -1121,7 +1121,7 @@ namespace System.Threading.Tasks
action();
return;
}
var actionWithState = m_action as Action<Object>;
var actionWithState = m_action as delegate void(Object);
if (actionWithState != null)
{
actionWithState(m_stateObject);

View file

@ -835,7 +835,7 @@ namespace BeefPerf
OpenedNew
}
public void WithDocumentTabbedViews(Action<DarkTabbedView> func)
public void WithDocumentTabbedViews(delegate void(DarkTabbedView) func)
{
for (int32 windowIdx = 0; windowIdx < mWindows.Count; windowIdx++)
{
@ -860,7 +860,7 @@ namespace BeefPerf
}
}
public void WithTabs(Action<TabbedView.TabButton> func)
public void WithTabs(delegate void(TabbedView.TabButton) func)
{
WithDocumentTabbedViews(scope (documentTabbedView) =>
{

View file

@ -1383,7 +1383,7 @@ namespace BeefPerf
return dc.mSelection;
}
void WithNodes(TrackNode node, Action<TrackNode> act)
void WithNodes(TrackNode node, delegate void(TrackNode) act)
{
act(node);
var group = node as TrackNodeGroup;

View file

@ -24,7 +24,7 @@ OtherLinkFlags = ""
TargetDirectory = "$(WorkspaceDir)/dist"
TargetName = "BeefIDE_d"
OtherLinkFlags = "$(LinkFlags) Comdlg32.lib kernel32.lib user32.lib advapi32.lib shell32.lib IDEHelper64_d.lib"
DebugCommandArguments = "-proddir=E:\\_Beef\\TestAPp"
DebugCommandArguments = "-proddir=C:\\Beef\\IDE"
DebugWorkingDirectory = "c:\\Beef"
EnvironmentVars = ["_NO_DEBUG_HEAP=1"]
@ -48,7 +48,7 @@ OtherLinkFlags = ""
TargetDirectory = "$(WorkspaceDir)/dist"
TargetName = "BeefIDE_d2"
OtherLinkFlags = "$(LinkFlags) Comdlg32.lib kernel32.lib user32.lib advapi32.lib shell32.lib IDEHelper64_d.lib BeefySysLib64_d.lib wsock32.lib"
DebugCommandArguments = "-workspace=c:\\beef\\ide\\mintest"
DebugCommandArguments = "-workspace=C:\\Beef\\IDEHelper\\Tests"
DebugWorkingDirectory = "$(ProjectDir)\\dist"
EnvironmentVars = ["_NO_DEBUG_HEAP=1"]

View file

@ -529,12 +529,6 @@ namespace System
}
}
delegate void Action();
delegate void Action<T1>(T1 p1);
delegate void Action<T1, T2>(T1 p1, T2 p2);
delegate TResult Func<TResult>();
delegate TResult Func<T1, TResult>(T1 p1);
delegate TResult Func<T1, T2, TResult>(T1 p1, T2 p2);
delegate int32 Comparison<T>(T a, T b);
}

View file

@ -5,26 +5,48 @@ using System.Diagnostics;
using System.Threading;
using System.Collections;
[Obsolete("This is old", false)]
class Bloops
struct Zoops
{
public int mA = 123;
public int mB = 234;
public static implicit operator Zoops(float f)
{
Zoops val = default;
val.mA = (.)f;
val.mB = 200;
return val;
}
public static implicit operator Zoops(float[2] f)
{
Zoops val = default;
val.mA = (.)f[0];
val.mB = (.)f[1];
return val;
}
}
struct Blurg
{
[LinkName(.Empty)]
public static void Hello()
public void Foo<T>()
{
}
public void Zarf<T>()
{
T Yorp<T2>(T2 val)
{
return default;
}
}
[CallingConvention(.Cdecl)]
public static void Hey()
{
Hello();
//int a = LinkNameAttribute(.);
}
}

View file

@ -301,6 +301,7 @@ namespace IDE.Compiler
BfPassInstance passInstance = null;
bool didPassInstanceAlloc = false;
bool wantsRemoveOldData = false;
mBfSystem.Lock(0);
@ -488,8 +489,7 @@ namespace IDE.Compiler
QueueDeferredResolveAll();
delete resolvePassData;
mBfSystem.RemoveOldParsers();
mBfSystem.RemoveOldData();
wantsRemoveOldData = true;
passKind = .Classify;
// End after resolveAll
@ -520,6 +520,12 @@ namespace IDE.Compiler
gApp.mErrorsPanel.ProcessPassInstance(passInstance, passKind);
delete passInstance;
}
if (wantsRemoveOldData)
{
mBfSystem.RemoveOldParsers();
mBfSystem.RemoveOldData();
}
}
void HandleOptions(BfProject hotBfProject, int32 hotIdx)

View file

@ -558,7 +558,7 @@ namespace IDE
#endif
}
public void Update(Action<String, String, WatcherChangeTypes> fileChangeHandler = null)
public void Update(delegate void(String, String, WatcherChangeTypes) fileChangeHandler = null)
{
while (true)
{

View file

@ -209,7 +209,7 @@ namespace IDE
public Targets mTargets = new Targets() ~ delete _;
public DebugManager mDebugger ~ delete _;
public String mSymSrvStatus = new String() ~ delete _;
public Action<String> mPendingDebugExprHandler = null;
public delegate void(String) mPendingDebugExprHandler = null;
public bool mIsImmediateDebugExprEval;
public BookmarkManager mBookmarkManager = new BookmarkManager() ~ delete _;
public HistoryManager mHistoryManager = new HistoryManager() ~ delete _;
@ -435,9 +435,9 @@ namespace IDE
public String mTempFileName ~ delete _;
public int32 mParallelGroup = -1;
public Task<String> mReadTask /*~ delete _*/;
public Action<Task<String>> mOnReadTaskComplete /*~ delete _*/;
public delegate void(Task<String>) mOnReadTaskComplete /*~ delete _*/;
public Task<String> mErrorTask /*~ delete _*/;
public Action<Task<String>> mOnErrorTaskComplete /*~ delete _*/;
public delegate void(Task<String>) mOnErrorTaskComplete /*~ delete _*/;
public Monitor mMonitor = new Monitor() ~ delete _;
public String mStdInData ~ delete _;
@ -5243,7 +5243,7 @@ namespace IDE
});
}
public void WithDocumentTabbedViews(Action<DarkTabbedView> func)
public void WithDocumentTabbedViews(delegate void(DarkTabbedView) func)
{
for (int32 windowIdx = 0; windowIdx < mWindows.Count; windowIdx++)
{
@ -5347,7 +5347,7 @@ namespace IDE
return null;
}
public void WithTabs(Action<TabbedView.TabButton> func)
public void WithTabs(delegate void(TabbedView.TabButton) func)
{
WithDocumentTabbedViews(scope (documentTabbedView) =>
{
@ -5366,7 +5366,7 @@ namespace IDE
return tab;
}
public void WithSourceViewPanels(Action<SourceViewPanel> func)
public void WithSourceViewPanels(delegate void(SourceViewPanel) func)
{
WithTabs(scope (tab) =>
{
@ -5839,7 +5839,7 @@ namespace IDE
if (showType != SourceShowType.New)
{
Action<TabbedView.TabButton> tabFunc = scope [&] (tabButton) =>
delegate void(TabbedView.TabButton) tabFunc = scope [&] (tabButton) =>
{
var darkTabButton = (DarkTabbedView.DarkTabButton)tabButton;
if (tabButton.mContent is SourceViewPanel)
@ -10866,7 +10866,8 @@ namespace IDE
Pending
}
public EvalResult DebugEvaluate(String expectedType, String expr, String outVal, int cursorPos = -1, DebugManager.Language language = .NotSet, DebugManager.EvalExpressionFlags expressionFlags = .None, Action<String> pendingHandler = null)
public EvalResult DebugEvaluate(String expectedType, String expr, String outVal, int cursorPos = -1, DebugManager.Language language = .NotSet,
DebugManager.EvalExpressionFlags expressionFlags = .None, delegate void(String) pendingHandler = null)
{
defer
{

View file

@ -2184,7 +2184,7 @@ namespace IDE
}
public void WithProjectItems(Action<ProjectItem> func)
public void WithProjectItems(delegate void(ProjectItem) func)
{
List<int32> idxStack = scope List<int32>();
List<ProjectFolder> folderStack = scope List<ProjectFolder>();

View file

@ -1027,7 +1027,7 @@ namespace IDE
}
}
public void WithProjectItems(Action<ProjectItem> func)
public void WithProjectItems(delegate void(ProjectItem) func)
{
for (var project in mProjects)
{

View file

@ -60,7 +60,7 @@ namespace IDE.ui
public String mPendingEvalStr ~ delete _;
public String mCurEvalExpr ~ delete _;
public Breakpoint mPendingMemoryBreakpoint ~ { if (_ != null) _.Deref(); };
public Action<int, int, String> mOnPendingMemoryBreakpoint ~ delete _;
public delegate void(int, int, String) mOnPendingMemoryBreakpoint ~ delete _;
public this()
{
@ -488,7 +488,7 @@ namespace IDE.ui
return true;
}
public MemoryBreakpointResult TryCreateMemoryBreakpoint(String evalStr, out int addr, out int32 byteCount, String addrType, Action<int, int, String> pendingHandler)
public MemoryBreakpointResult TryCreateMemoryBreakpoint(String evalStr, out int addr, out int32 byteCount, String addrType, delegate void(int, int, String) pendingHandler)
{
addr = 0;
byteCount = 0;

View file

@ -427,7 +427,7 @@ namespace IDE.ui
Menu menu = new Menu();
Action<String, bool> addSubMenu = scope (label, useRepType) => {
delegate void(String, bool) addSubMenu = scope (label, useRepType) => {
Menu subMenu = menu.AddItem(label);

View file

@ -17,7 +17,7 @@ namespace IDE.ui
mIsReadOnly = true;
}
public Event<Func<int, int, bool>> mGotoReferenceEvent ~ _.Dispose();
public Event<delegate bool(int, int)> mGotoReferenceEvent ~ _.Dispose();
public bool GotoRefrenceAtLine(int line, int lineOfs = 0)
{
//bool selectLine = true;

View file

@ -177,10 +177,10 @@ namespace IDE.ui
OnlyShowInvoke = 4
}
public Action<char32, AutoCompleteOptions> mOnGenerateAutocomplete ~ delete _;
public delegate void(char32, AutoCompleteOptions) mOnGenerateAutocomplete ~ delete _;
public Action mOnFinishAsyncAutocomplete ~ delete _;
public Action mOnCancelAsyncAutocomplete ~ delete _;
public Func<bool> mOnEscape ~ delete _; // returns 'true' if did work
public delegate bool() mOnEscape ~ delete _; // returns 'true' if did work
public AutoComplete mAutoComplete ~ delete _;
List<QueuedTextEntry> mQueuedText = new List<QueuedTextEntry>() ~ delete _;
List<QueuedUnderlineEntry> mQueuedUnderlines = new List<QueuedUnderlineEntry>() ~ delete _;

View file

@ -6641,7 +6641,7 @@ namespace IDE.ui
}
public void WithTrackedElementsAtCursor<T>(List<T> trackedElementList, Action<T> func) where T : TrackedTextElement
public void WithTrackedElementsAtCursor<T>(List<T> trackedElementList, delegate void(T) func) where T : TrackedTextElement
{
int lineIdx;
int lineCharIdx;

View file

@ -2800,7 +2800,7 @@ namespace IDE.ui
}
}
void WithSelected(Action<ListViewItem> func)
void WithSelected(delegate void(ListViewItem) func)
{
var root = listView.GetRoot();
root.WithSelectedItems(func, false, true);