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:
@@ -46,59 +46,45 @@ namespace StgSharp
|
||||
|
||||
private static Process? _dialogueProcess;
|
||||
private static AnonymousPipeServerStream _dialogueClientPipe,_dialogueServerPipe;
|
||||
private static ConcurrentBag<string> msgCache = new ConcurrentBag<string>(
|
||||
);
|
||||
private static ConcurrentBag<string> msgCache = new ConcurrentBag<string>();
|
||||
private static int _readAndWriteThreadId;
|
||||
private static ProcessStartInfo _dialogueProcessInfo;
|
||||
private static StreamReader _dr;
|
||||
private static StreamWriter _dw;
|
||||
|
||||
public static bool NeedShowWhenStartup
|
||||
public static bool NeedShowWhenStartup { get; set; }
|
||||
|
||||
public static void PostError( Exception ex )
|
||||
{
|
||||
get;
|
||||
set;
|
||||
CreateDialogueProcessIfNotExist();
|
||||
|
||||
_dw.WriteLine( $"posterror {ex.Message}" );
|
||||
|
||||
_dialogueProcess!.Exited -= DialogueProcessExitCallback;
|
||||
}
|
||||
|
||||
public static void SetReadAndWriteThread(Thread thread)
|
||||
public static void SetReadAndWriteThread( Thread thread )
|
||||
{
|
||||
_readAndWriteThreadId = thread.ManagedThreadId;
|
||||
}
|
||||
|
||||
private static void AssertThread()
|
||||
{
|
||||
if (_readAndWriteThreadId != Environment.CurrentManagedThreadId)
|
||||
{
|
||||
throw new InvalidOperationException("Communication with dialogue can only call from certain thread.");
|
||||
}
|
||||
}
|
||||
|
||||
internal static void CreateDialogueProcessIfNotExist()
|
||||
{
|
||||
if( _dialogueProcess != null ) {
|
||||
return;
|
||||
}
|
||||
if (!File.Exists(_dialogueProcessInfo.FileName))
|
||||
{
|
||||
|
||||
}
|
||||
if( !File.Exists( _dialogueProcessInfo.FileName ) ) { }
|
||||
_dialogueProcess = Process.Start( _dialogueProcessInfo );
|
||||
|
||||
_dr = new StreamReader(_dialogueClientPipe);
|
||||
_dw = new StreamWriter(_dialogueServerPipe);
|
||||
_dr = new StreamReader( _dialogueClientPipe );
|
||||
_dw = new StreamWriter( _dialogueServerPipe );
|
||||
|
||||
_dialogueProcess!.Exited += DialogueProcessExitCallback;
|
||||
_dialogueProcess!.Exited += DialogueProcessExitCallback;
|
||||
|
||||
_dialogueServerPipe.DisposeLocalCopyOfClientHandle();
|
||||
_dialogueClientPipe.DisposeLocalCopyOfClientHandle();
|
||||
}
|
||||
|
||||
private static void DialogueProcessExitCallback(object? sender, EventArgs e)
|
||||
{
|
||||
_dialogueProcess = null;
|
||||
_dr.Close();
|
||||
_dw.Close();
|
||||
}
|
||||
|
||||
internal static void LoadDialogue()
|
||||
{
|
||||
_dialogueServerPipe = new AnonymousPipeServerStream(
|
||||
@@ -106,21 +92,25 @@ namespace StgSharp
|
||||
_dialogueClientPipe = new AnonymousPipeServerStream(
|
||||
PipeDirection.In, HandleInheritability.Inheritable );
|
||||
|
||||
string route = Assembly.GetAssembly( typeof( StgSharp ) ).Location;
|
||||
string route = Assembly.GetAssembly( typeof( World ) ).Location;
|
||||
string path = Path.GetDirectoryName( route );
|
||||
|
||||
string exeName;
|
||||
|
||||
if( RuntimeInformation.IsOSPlatform( OSPlatform.Windows ) ) {
|
||||
if( RuntimeInformation.IsOSPlatform( OSPlatform.Windows ) )
|
||||
{
|
||||
exeName = ".exe";
|
||||
} else if( RuntimeInformation.IsOSPlatform( OSPlatform.Linux ) || RuntimeInformation.IsOSPlatform(
|
||||
OSPlatform.OSX ) ) {
|
||||
} else if( RuntimeInformation.IsOSPlatform( OSPlatform.Linux ) ||
|
||||
RuntimeInformation.IsOSPlatform( OSPlatform.OSX ) )
|
||||
{
|
||||
exeName = string.Empty;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
throw new PlatformNotSupportedException( "Unknown OS platform" );
|
||||
}
|
||||
|
||||
string consoleRoute = Path.Combine(path, @"StgSharpTerminalDialogue", $@"StgSharpTerminalDialogue{exeName}");
|
||||
string consoleRoute = Path.Combine(
|
||||
path, @"StgSharpTerminalDialogue", $@"StgSharpTerminalDialogue{exeName}" );
|
||||
|
||||
_dialogueProcessInfo = new ProcessStartInfo
|
||||
{
|
||||
@@ -129,26 +119,13 @@ namespace StgSharp
|
||||
UseShellExecute = true,
|
||||
RedirectStandardOutput = false,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
internal static void PostMessage(
|
||||
string instruction,
|
||||
params string[] operands)
|
||||
internal static void PostMessage( string instruction, params string[] operands )
|
||||
{
|
||||
CreateDialogueProcessIfNotExist();
|
||||
|
||||
_dw.WriteLine($"{instruction} {operands}");
|
||||
|
||||
}
|
||||
|
||||
public static void PostError(Exception ex)
|
||||
{
|
||||
CreateDialogueProcessIfNotExist();
|
||||
|
||||
_dw.WriteLine($"posterror {ex.Message}");
|
||||
|
||||
_dialogueProcess!.Exited -= DialogueProcessExitCallback;
|
||||
_dw.WriteLine( $"{instruction} {operands}" );
|
||||
}
|
||||
|
||||
internal static void UnloadDialogue()
|
||||
@@ -169,10 +146,12 @@ namespace StgSharp
|
||||
}
|
||||
|
||||
string temp = string .Empty;
|
||||
do {
|
||||
do
|
||||
{
|
||||
temp = _dr.ReadLine();
|
||||
temp = temp ?? string.Empty;
|
||||
if( !temp!.StartsWith( target ) ) {
|
||||
if( !temp!.StartsWith( target ) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
} while (true);
|
||||
@@ -181,5 +160,20 @@ namespace StgSharp
|
||||
return index != -1 ? temp.Substring( index + 1 ) : string.Empty;
|
||||
}
|
||||
|
||||
private static void AssertThread()
|
||||
{
|
||||
if( _readAndWriteThreadId != Environment.CurrentManagedThreadId ) {
|
||||
throw new InvalidOperationException(
|
||||
"Communication with dialogue can only call from certain thread." );
|
||||
}
|
||||
}
|
||||
|
||||
private static void DialogueProcessExitCallback( object? sender, EventArgs e )
|
||||
{
|
||||
_dialogueProcess = null;
|
||||
_dr.Close();
|
||||
_dw.Close();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="GlobalSetting.cs"
|
||||
// Project: StgSharp
|
||||
// Project: World
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
@@ -39,7 +39,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp
|
||||
{
|
||||
public static unsafe partial class StgSharp
|
||||
public static unsafe partial class World
|
||||
{
|
||||
|
||||
internal const int ssdSegmentLength = 16;
|
||||
@@ -74,7 +74,7 @@ namespace StgSharp
|
||||
|
||||
/// <summary>
|
||||
/// CustomizeInit an instance of OpenGL program, This method should be called before any
|
||||
/// other StgSharp api.
|
||||
/// other World api.
|
||||
/// </summary>
|
||||
public static void InitGL( int majorVersion, int minorVersion )
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp
|
||||
{
|
||||
public static partial class StgSharp
|
||||
public static partial class World
|
||||
{
|
||||
|
||||
private static unsafe IntPtr[] monitorsArray;
|
||||
@@ -48,12 +48,12 @@ namespace StgSharp
|
||||
{
|
||||
get
|
||||
{
|
||||
if( monitorsArray == null ) {
|
||||
if( monitorsArray == null )
|
||||
{
|
||||
int count = 0;
|
||||
IntPtr* arrayhandle = InternalIO.glfwGetMonitors( &count );
|
||||
monitorsArray = new IntPtr[count];
|
||||
Marshal.Copy(
|
||||
( IntPtr )arrayhandle, monitorsArray, 0, count );
|
||||
Marshal.Copy( ( IntPtr )arrayhandle, monitorsArray, 0, count );
|
||||
Marshal.FreeHGlobal( ( IntPtr )arrayhandle );
|
||||
}
|
||||
return monitorsArray;
|
||||
|
||||
@@ -28,11 +28,6 @@
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// using StgSharp.Envitronment;
|
||||
// using StgSharp.Envitronment.Win32;
|
||||
// using StgSharp.Graphics;
|
||||
// using StgSharp.Math;
|
||||
|
||||
using StgSharp.Internal;
|
||||
using StgSharp.Internal.Intrinsic;
|
||||
|
||||
@@ -71,12 +66,12 @@ namespace StgSharp
|
||||
|
||||
}
|
||||
|
||||
public static partial class StgSharp
|
||||
public static partial class World
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Version of current StgSharp platform. Main version represent in hundred's digit, and sub
|
||||
/// version represent in ten's digit.
|
||||
/// Version of current World platform. Main version represent in hundred's digit, and sub
|
||||
/// version represent in ten's digit.
|
||||
/// </summary>
|
||||
public const long version = 430;
|
||||
|
||||
@@ -92,8 +87,7 @@ namespace StgSharp
|
||||
InternalIO.glfwInit();
|
||||
InternalIO.InternalAppendLog( "\n\n\n" );
|
||||
InternalIO.InternalWriteLog(
|
||||
$"Program {Assembly.GetEntryAssembly()!.FullName} Started.",
|
||||
LogType.Info );
|
||||
$"Program {Assembly.GetEntryAssembly()!.FullName} Started.", LogType.Info );
|
||||
_mainThreadID = Environment.CurrentManagedThreadId;
|
||||
|
||||
|
||||
@@ -122,8 +116,7 @@ namespace StgSharp
|
||||
|
||||
public static void LogWarning( Exception notVerySeriesException )
|
||||
{
|
||||
InternalIO.InternalWriteLog(
|
||||
notVerySeriesException.Message, LogType.Warning );
|
||||
InternalIO.InternalWriteLog( notVerySeriesException.Message, LogType.Warning );
|
||||
}
|
||||
|
||||
public static void Mark( bool needConsole )
|
||||
@@ -142,12 +135,12 @@ namespace StgSharp
|
||||
}
|
||||
|
||||
public static void Track(
|
||||
object target,
|
||||
string message,
|
||||
bool isConsole,
|
||||
[CallerFilePath] string filePath = "",
|
||||
[CallerMemberName] string callerName = "",
|
||||
[CallerLineNumber] int lineNumber = 0 )
|
||||
object target,
|
||||
string message,
|
||||
bool isConsole,
|
||||
[CallerFilePath] string filePath = "",
|
||||
[CallerMemberName] string callerName = "",
|
||||
[CallerLineNumber] int lineNumber = 0 )
|
||||
{
|
||||
Type t = target.GetType();
|
||||
string log = $"Tracked object: {nameof(target)}\t\tType:{t.Name}\n";
|
||||
@@ -159,18 +152,24 @@ namespace StgSharp
|
||||
}
|
||||
log += $"Tracking at:\n{filePath}\t{callerName}\tline {lineNumber}\n";
|
||||
log += $"Additional information:\n{message}\n";
|
||||
if( isConsole ) {
|
||||
if( isConsole )
|
||||
{
|
||||
Console.WriteLine( log );
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
InternalIO.InternalWriteLog( log, LogType.Info );
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write a log message to log file, and mark the _level of this message.
|
||||
/// Write a log message to log file, and mark the _level of this message.
|
||||
/// </summary>
|
||||
/// <param _name="message"> A string contains information of how current evironment runs. </param>
|
||||
/// <param _name="logType"> The severity of current message. </param>
|
||||
/// <param _label="message">
|
||||
/// A string contains information of how current evironment runs.
|
||||
/// </param>
|
||||
/// <param _label="logType">
|
||||
/// The severity of current message.
|
||||
/// </param>
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static void WriteLog( string message, LogType logType )
|
||||
{
|
||||
@@ -183,10 +182,12 @@ namespace StgSharp
|
||||
throw new InvalidCastException(
|
||||
"Failed to convert api, the function pointer is zero." );
|
||||
}
|
||||
try {
|
||||
try
|
||||
{
|
||||
return Marshal.GetDelegateForFunctionPointer<TDele>( funcPtr );
|
||||
}
|
||||
catch( Exception ) {
|
||||
catch( Exception )
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@@ -197,10 +198,12 @@ namespace StgSharp
|
||||
throw new InvalidCastException(
|
||||
"Failed to convert api, the function pointer is zero." );
|
||||
}
|
||||
try {
|
||||
try
|
||||
{
|
||||
return Marshal.GetDelegateForFunctionPointer( funcPtr, T );
|
||||
}
|
||||
catch( Exception ) {
|
||||
catch( Exception )
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp
|
||||
{
|
||||
public static partial class StgSharp
|
||||
public static partial class World
|
||||
{
|
||||
|
||||
private static ConcurrentDictionary<int, KeyStatus> keyListener
|
||||
|
||||
Reference in New Issue
Block a user