Daily update on 20250618-051714 by Nitload Youmu. Additional Message : Brief support to collection operation in EXPRESS. A collection type added in core lib and compilestack.

Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
Nitload
2025-06-18 05:17:14 +08:00
parent 74c01effe4
commit c624a8ca38
300 changed files with 12227 additions and 4303 deletions
+18 -21
View File
@@ -40,14 +40,12 @@ namespace StgSharp.MVVM.ViewModel
{
#nullable enable
[UnmanagedFunctionPointer( CallingConvention.Cdecl )]
[UnmanagedFunctionPointer( CallingConvention.Cdecl )]
public delegate ref object BindingDataGetter();
[UnmanagedFunctionPointer( CallingConvention.Cdecl )]
public delegate void BindingDataSetter( ref object value );
[UnmanagedFunctionPointer( CallingConvention.Cdecl )]
public delegate bool MethodLookUpDelegate(
string name,
out Action callback );
public delegate bool MethodLookUpDelegate( string name, out Action callback );
public abstract partial class ViewModelBase
{
@@ -55,24 +53,28 @@ namespace StgSharp.MVVM.ViewModel
public bool MethodLookup( string methodName, out Action callback )
{
MethodInfo method = GetType().GetMethod( methodName )!;
if( method == null ) {
if( method == null )
{
callback = null!;
return false;
}
try {
callback = ( Action )Delegate.CreateDelegate(
typeof( Action ), this, methodName );
try
{
callback = ( Action )Delegate.CreateDelegate( typeof( Action ), this, methodName );
return true;
}
catch( MissingMethodException ) {
catch( MissingMethodException )
{
callback = null!;
return false;
}
catch( MethodAccessException ) {
catch( MethodAccessException )
{
callback = null!;
return false;
}
catch( Exception ) {
catch( Exception )
{
throw;
}
}
@@ -88,8 +90,8 @@ namespace StgSharp.MVVM.ViewModel
[FieldOffset( 0 )] private M128 _mask;
public DataBindingEntry(
[NotNull] BindingDataGetter gettingCallback,
[NotNull] BindingDataSetter settingCallback )
[NotNull] BindingDataGetter gettingCallback,
[NotNull] BindingDataSetter settingCallback )
{
getterPtr = Marshal.GetFunctionPointerForDelegate( gettingCallback );
setterPtr = Marshal.GetFunctionPointerForDelegate( settingCallback );
@@ -130,20 +132,15 @@ namespace StgSharp.MVVM.ViewModel
public void SetValue( ref object value )
{
( ( delegate* unmanaged[Cdecl]<ref object, void> )setterPtr )(
ref value );
( ( delegate* unmanaged[Cdecl]<ref object, void> )setterPtr )( ref value );
}
public static bool operator !=(
DataBindingEntry left,
DataBindingEntry right )
public static bool operator !=( DataBindingEntry left, DataBindingEntry right )
{
return left._mask != right._mask;
}
public static bool operator ==(
DataBindingEntry left,
DataBindingEntry right )
public static bool operator ==( DataBindingEntry left, DataBindingEntry right )
{
return left._mask == right._mask;
}
+20 -19
View File
@@ -1,7 +1,7 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ShowViewPort.cs"
// Project: StgSharp
// Project: StepVisualizer
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
@@ -30,7 +30,7 @@
//-----------------------------------------------------------------------
using StgSharp.Controls;
using StgSharp.Graphics;
using StgSharp.MVVM.View;
using StgSharp.MVVM;
using StgSharp.Threading;
using StgSharp.Timing;
@@ -54,14 +54,13 @@ namespace StgSharp.MVVM.ViewModel
}
/// <summary>
/// CustomizeInit this form and render it on screen, and respond with operation
/// CustomizeInit this form and render it on screen, and respond with operation
/// </summary>
public unsafe void UseViewModel( string viewEntryName )
{
CustomizeInitialize();
UseViewInNextFrame( viewEntryName );
TimeSpanAwaitingToken fpsCountingToken = fpsCountProvider.ParticipantSpanAwaiting(
1 );
TimeSpanAwaitingToken fpsCountingToken = fpsCountProvider.ParticipantSpanAwaiting( 1 );
fpsCountingToken.TimeSpanRefreshed += CountFps;
fpsCountingToken.MissTimeSpanRefreshed += CountFps;
if( _nextView != _currentView ) {
@@ -69,21 +68,25 @@ namespace StgSharp.MVVM.ViewModel
}
Thread renderThread = new Thread(
( token ) => {
try {
try
{
ProcessFrameWithoutEvent();
}
catch( Exception ex ) {
catch( Exception ex )
{
InternalIO.InternalWriteLog(
$"Critical error when rendering:\n" + $"{ex}",
LogType.Error );
$"Critical error when rendering:\n" + $"{ex}", LogType.Error );
ShouldClose = true;
throw;
}
} );
renderThread.Start();
/**/
using( TimeSpanAwaitingToken eventAwaitingToken = frameTimeProvider.ParticipantSpanAwaiting(
1 ) ) {
while( _closed ) {
1 ) )
{
while( _closed )
{
if( _nextView != _currentView ) {
Interlocked.Exchange( ref _currentView, _nextView );
}
@@ -112,16 +115,12 @@ namespace StgSharp.MVVM.ViewModel
{
Interlocked.Exchange( ref _frameSpeed, _frameCount );
Interlocked.Exchange( ref _frameCount, 0 );
/*
Console.Clear();
Console.WriteLine( FrameSpeed );
/**/
}
private unsafe void PrivateShow()
{
if( 0 == InternalIO.glfwWindowShouldClose(
this.viewPortDisplay.ViewPortID ) ) {
if( 0 == InternalIO.glfwWindowShouldClose( this.viewPortDisplay.ViewPortHandle ) )
{
CurrentView.Use();
RenderStream.PollEvents();
}
@@ -130,9 +129,11 @@ namespace StgSharp.MVVM.ViewModel
private void ProcessFrameWithoutEvent()
{
using( TimeSpanAwaitingToken renderAwaitingToken = frameTimeProvider.ParticipantSpanAwaiting(
1 ) ) {
1 ) )
{
renderAwaitingToken.TimeSpanRefreshed += ( _, _ ) => { };
while( _closed ) {
while( _closed )
{
foreach( ViewPort context in CurrentView.Render ) {
context.FlushSize();
}
+2 -4
View File
@@ -30,7 +30,7 @@
//-----------------------------------------------------------------------
using StgSharp.Graphics;
using StgSharp.Graphics.OpenGL;
using StgSharp.MVVM.View;
using StgSharp.MVVM;
using System;
using System.Collections.Generic;
@@ -44,9 +44,7 @@ namespace StgSharp.MVVM.ViewModel
private Dictionary<string, ViewBase> allView;
public T CreateAndBindView<T>(
string name,
(int x, int y, int z) unitCubeSize )
public T CreateAndBindView<T>( string name, (int x, int y, int z) unitCubeSize )
where T: ViewBase, new()
{
T ret = new T();
+43 -56
View File
@@ -1,7 +1,7 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ViewModel.cs"
// Project: StgSharp
// Project: StepVisualizer
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
@@ -32,7 +32,7 @@ using StgSharp.Controlling.UsrActivity;
using StgSharp.Graphics;
using StgSharp.Graphics.OpenGL;
using StgSharp.Math;
using StgSharp.MVVM.View;
using StgSharp.MVVM;
using StgSharp.MVVM.ViewModel;
using StgSharp.Threading;
using StgSharp.Timing;
@@ -69,12 +69,10 @@ namespace StgSharp.MVVM.ViewModel
{
viewPortDisplay = new ViewPort();
allView = new();
fpsCountProvider = new TimeSpanProvider(
1.0, TimeSpanProvider.DefaultProvider );
fpsCountProvider = new TimeSpanProvider( 1.0, TimeSpanProvider.DefaultProvider );
_frameSpeed = 0;
_frameCount = 0;
long frameLength = ( FrameSpeed > 0 ) ?
( ( 1000L * 1000L ) / FrameSpeed ) : 0;
long frameLength = ( FrameSpeed > 0 ) ? ( ( 1000L * 1000L ) / FrameSpeed ) : 0;
frameTimeProvider = new TimeSpanProvider(
frameLength, TimeSpanProvider.DefaultProvider );
FrameSizeCallback = DefaultFrameRewsizeCallback;
@@ -84,12 +82,10 @@ namespace StgSharp.MVVM.ViewModel
{
viewPortDisplay = new ViewPort();
allView = new();
fpsCountProvider = new TimeSpanProvider(
1.0, TimeSpanProvider.DefaultProvider );
fpsCountProvider = new TimeSpanProvider( 1.0, TimeSpanProvider.DefaultProvider );
_frameSpeed = 0;
_frameCount = 0;
long _frameLength = ( FrameSpeed > 0 ) ?
( ( long )( 1000 * frameLength ) ) : 0;
long _frameLength = ( FrameSpeed > 0 ) ? ( ( long )( 1000 * frameLength ) ) : 0;
frameTimeProvider = new TimeSpanProvider(
_frameLength, TimeSpanProvider.DefaultProvider );
FrameSizeCallback = DefaultFrameRewsizeCallback;
@@ -99,12 +95,10 @@ namespace StgSharp.MVVM.ViewModel
{
viewPortDisplay = vBinding;
allView = new();
fpsCountProvider = new TimeSpanProvider(
1.0, TimeSpanProvider.DefaultProvider );
fpsCountProvider = new TimeSpanProvider( 1.0, TimeSpanProvider.DefaultProvider );
_frameSpeed = 0;
_frameCount = 0;
long frameLength = ( frameSpeed > 0 ) ?
( ( 1000L * 1000L ) / frameSpeed ) : 0;
long frameLength = ( frameSpeed > 0 ) ? ( ( 1000L * 1000L ) / frameSpeed ) : 0;
frameTimeProvider = new TimeSpanProvider(
frameLength, TimeSpanProvider.DefaultProvider );
FrameSizeCallback = DefaultFrameRewsizeCallback;
@@ -114,12 +108,10 @@ namespace StgSharp.MVVM.ViewModel
{
viewPortDisplay = vBinding;
allView = new();
fpsCountProvider = new TimeSpanProvider(
1.0, TimeSpanProvider.DefaultProvider );
fpsCountProvider = new TimeSpanProvider( 1.0, TimeSpanProvider.DefaultProvider );
_frameSpeed = 0;
_frameCount = 0;
long _frameLength = ( frameLength > 0 ) ?
( ( long )( 1000 * frameLength ) ) : 0;
long _frameLength = ( frameLength > 0 ) ? ( ( long )( 1000 * frameLength ) ) : 0;
frameTimeProvider = new TimeSpanProvider(
_frameLength, TimeSpanProvider.DefaultProvider );
FrameSizeCallback = DefaultFrameRewsizeCallback;
@@ -129,8 +121,7 @@ namespace StgSharp.MVVM.ViewModel
{
get
{
if( this.TryGetObjectReference(
name, out DataBindingEntry entry ) ) {
if( this.TryGetObjectReference( name, out DataBindingEntry entry ) ) {
return entry;
}
throw new KeyNotFoundException();
@@ -139,10 +130,9 @@ namespace StgSharp.MVVM.ViewModel
public bool ShouldClose
{
get => InternalIO.glfwWindowShouldClose(
viewPortDisplay.ViewPortID ) != 0;
get => InternalIO.glfwWindowShouldClose( viewPortDisplay.ViewPortHandle ) != 0;
set => InternalIO.glfwSetWindowShouldClose(
viewPortDisplay.ViewPortID, value ? 1 : 0 );
viewPortDisplay.ViewPortHandle, value ? 1 : 0 );
}
public int CurrentFrameCount => frameTimeProvider.CurrentSpan;
@@ -150,7 +140,7 @@ namespace StgSharp.MVVM.ViewModel
public int FrameSpeed => _frameSpeed;
/// <summary>
/// Height of this form, represent in <see cref="int" />
/// Height of this form, represent in <see cref="int" />
/// </summary>
public int Height
{
@@ -158,7 +148,7 @@ namespace StgSharp.MVVM.ViewModel
}
/// <summary>
/// Width of this form, represent in <see cref="int" />
/// Width of this form, represent in <see cref="int" />
/// </summary>
public int Width
{
@@ -167,7 +157,7 @@ namespace StgSharp.MVVM.ViewModel
public unsafe IntPtr WindowID
{
get => viewPortDisplay.ViewPortID;
get => viewPortDisplay.ViewPortHandle;
}
public string Name
@@ -176,7 +166,7 @@ namespace StgSharp.MVVM.ViewModel
}
/// <summary>
/// Width of this form, represent in <see cref="int" />
/// Width of this form, represent in <see cref="int" />
/// </summary>
public Vec2 Size
{
@@ -194,10 +184,9 @@ namespace StgSharp.MVVM.ViewModel
set
{
_resizeCallback = value;
IntPtr handlerPtr = Marshal.GetFunctionPointerForDelegate(
value );
IntPtr handlerPtr = Marshal.GetFunctionPointerForDelegate( value );
InternalIO.glfwSetFramebufferSizeCallback(
viewPortDisplay.ViewPortID, handlerPtr );
viewPortDisplay.ViewPortHandle, handlerPtr );
}
}
#pragma warning restore CA1044
@@ -205,51 +194,49 @@ namespace StgSharp.MVVM.ViewModel
public abstract void CustomizeInitialize();
/// <summary>
/// Set the size limit of current form
/// Set the size limit of current form
/// </summary>
/// <param _name="minSize">
/// Minimum size of current form. In form of a <see cref="Vec2" /> of (width,height)
/// <param _label="minSize">
/// Minimum size of current form. In form of a <see cref="Vec2" /> of (width,height)
/// </param>
/// <param _name="maxSize">
/// Maximum size of current form. In form of a <see cref="Vec2" /> of (width,height)
/// <param _label="maxSize">
/// Maximum size of current form. In form of a <see cref="Vec2" /> of (width,height)
/// </param>
[MethodImpl( MethodImplOptions.AggressiveInlining )]
public void SetSizeLimit( Vec2 minSize, Vec2 maxSize )
{
ThreadHelper.MainThreadAssert();
InternalIO.glfwSetWindowSizeLimits(
this.viewPortDisplay.ViewPortID, ( int )minSize.X,
( int )minSize.Y, ( int )maxSize.X, ( int )maxSize.Y );
this.viewPortDisplay.ViewPortHandle, ( int )minSize.X, ( int )minSize.Y,
( int )maxSize.X, ( int )maxSize.Y );
}
/// <summary>
/// Set the size limit of current form
/// Set the size limit of current form
/// </summary>
/// <param _name="minWidth"> Minimum width of current form </param>
/// <param _name="minHeight"> Minimum height of current form </param>
/// <param _name="maxWidth"> Maximum width of current form </param>
/// <param _name="maxHeight"> Maximum height of current form </param>
/// <param _label="minWidth">
/// Minimum width of current form
/// </param>
/// <param _label="minHeight">
/// Minimum height of current form
/// </param>
/// <param _label="maxWidth">
/// Maximum width of current form
/// </param>
/// <param _label="maxHeight">
/// Maximum height of current form
/// </param>
[MethodImpl( MethodImplOptions.AggressiveInlining )]
public void SetSizeLimit(
int minWidth,
int minHeight,
int maxWidth,
int maxHeight )
public void SetSizeLimit( int minWidth, int minHeight, int maxWidth, int maxHeight )
{
ThreadHelper.MainThreadAssert();
InternalIO.glfwSetWindowSizeLimits(
this.viewPortDisplay.ViewPortID, minWidth, minHeight, maxWidth,
maxHeight );
this.viewPortDisplay.ViewPortHandle, minWidth, minHeight, maxWidth, maxHeight );
}
public abstract bool TryGetObjectReference(
string name,
out DataBindingEntry entry );
public abstract bool TryGetObjectReference( string name, out DataBindingEntry entry );
private void DefaultFrameRewsizeCallback(
IntPtr windowHandle,
int width,
int height )
private void DefaultFrameRewsizeCallback( IntPtr windowHandle, int width, int height )
{
ViewPort.GetExistedViewPort( windowHandle, out ViewPort vp );
vp.RequestFlushSizeInNextFrame( width, height );