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
+1 -1
View File
@@ -15,7 +15,7 @@ INTERNAL int SSCDECL city_hash_simplify_sse(byte const *str, int const length)
for (; ptr < end; ptr += 4) {
hash = _mm_crc32_u32(hash, *(uint32_t *)ptr);
}
for (; ptr < end; ptr++) {
for (; ptr < end; ptr++) {
hash = _mm_crc32_u16(hash, *ptr);
}
} else {
@@ -1,30 +1,25 @@
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\build\stgsharp.c.bsc
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\vc143.pdb
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\vc143.idb
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharpc.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharpc.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharpc.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\intrinsic.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\intrinsic.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\intrinsic.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\string.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\string.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\string.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat4.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat4.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat4.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\vector.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\vector.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\vector.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\hash.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\hash.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\hash.cod
c:\users\youmu\onedrive - msft\大学\毕业设计\graduationproject\build\stgsharp.c.bsc
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stb_image.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stb_image.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stb_image.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat2.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat2.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat2.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\hash.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\hash.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\hash.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\string.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\string.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\string.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat4.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat4.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat4.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharpc.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharpc.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharpc.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\vector.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\vector.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\vector.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat3.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat3.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\mat3.cod
@@ -34,18 +29,23 @@ d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\st
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\dllmain.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\dllmain.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\dllmain.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\build\stgsharp.c.dll
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\build\stgsharp.c.pdb
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\build\stgsharp.c.lib
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\build\stgsharp.c.exp
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\intrinsic.sbr
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\intrinsic.obj
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\intrinsic.cod
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\vc143.pdb
c:\users\youmu\onedrive - msft\大学\毕业设计\graduationproject\build\stgsharp.c.dll
c:\users\youmu\onedrive - msft\大学\毕业设计\graduationproject\build\stgsharp.c.pdb
c:\users\youmu\onedrive - msft\大学\毕业设计\graduationproject\build\stgsharp.c.lib
c:\users\youmu\onedrive - msft\大学\毕业设计\graduationproject\build\stgsharp.c.exp
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.ilk
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\vc143.idb
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\bscmake.command.1.tlog
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\bscmake.read.1.tlog
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\bscmake.write.1.tlog
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\cl.12408.write.1.tlog
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\cl.command.1.tlog
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\cl.items.tlog
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\cl.read.1.tlog
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\cl.write.1.tlog
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\link.command.1.tlog
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\link.read.1.tlog
d:\nitloadindustry\研究项目\1-flagship\th2020\projectfile\内核源代码\stgsharp.c\x64\debug\stgsharp.c.tlog\link.secondary.1.tlog
Binary file not shown.
Binary file not shown.
Binary file not shown.
+3
View File
@@ -4,4 +4,7 @@ D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\St
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\hash.c(31,50): warning C4244: “函数”: 从“uint64_t”转换到“unsigned char”,可能丢失数据
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\hash.c(7,15): warning C4090: “初始化”: 不同的“const”限定符
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\hash.c(7,34): warning C4090: “初始化”: 不同的“const”限定符
LINK : 没有找到 D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\build\StgSharp.C.dll 或上一个增量链接没有生成它;正在执行完全链接
正在创建库 D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\build\StgSharp.C.lib 和对象 D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\build\StgSharp.C.exp
LINK : warning LNK4098: 默认库“MSVCRT”与其他库的使用冲突;请使用 /NODEFAULTLIB:library
StgSharpC.vcxproj -> D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\build\StgSharp.C.dll
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -300,7 +300,7 @@ $LN7@city_hash_:
000d0 eb d7 jmp SHORT $LN5@city_hash_
$LN6@city_hash_:
; 18 : for (; ptr < end; ptr++) {
; 18 : for (; ptr < end; ptr++) {
000d2 eb 0b jmp SHORT $LN10@city_hash_
$LN8@city_hash_:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<ProjectOutputs>
<ProjectOutput>
<FullPath>C:\Users\Youmu\OneDrive - MSFT\大学\毕业设计\GraduationProject\build\StgSharp.C.dll</FullPath>
</ProjectOutput>
</ProjectOutputs>
<ContentFiles />
<SatelliteDlls />
<NonRecipeFileRefs />
</Project>
Binary file not shown.
@@ -0,0 +1,11 @@
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\dllmain.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\x64\Release\dllmain.obj
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\intrinsic.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\x64\Release\intrinsic.obj
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat2.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\x64\Release\mat2.obj
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat3.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\x64\Release\mat3.obj
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\x64\Release\mat4.obj
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\stb_image.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\x64\Release\stb_image.obj
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\StgSharpC.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\x64\Release\StgSharpC.obj
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\hash.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\x64\Release\hash.obj
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\string.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\x64\Release\string.obj
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\vector.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\x64\Release\vector.obj
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\vector_dot.c;D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\x64\Release\vector_dot.obj
@@ -0,0 +1,2 @@
PlatformToolSet=v143:VCToolArchitecture=Native64Bit:VCToolsVersion=14.41.34120:TargetPlatformVersion=10.0.22621.0:
Release|x64|C:\Users\Youmu\OneDrive - MSFT\大学\毕业设计\GraduationProject\|
@@ -0,0 +1,4 @@
^D:\NITLOADINDUSTRY\研究项目\1-FLAGSHIP\TH2020\PROJECTFILE\内核源代码\STGSHARP.C\GLFW3.LIB|D:\NITLOADINDUSTRY\研究项目\1-FLAGSHIP\TH2020\PROJECTFILE\内核源代码\STGSHARP.C\GLFW3DLL.LIB|D:\NITLOADINDUSTRY\研究项目\1-FLAGSHIP\TH2020\PROJECTFILE\内核源代码\STGSHARP.C\GLFW3_MT.LIB|D:\NITLOADINDUSTRY\研究项目\1-FLAGSHIP\TH2020\PROJECTFILE\内核源代码\STGSHARP.C\X64\RELEASE\DLLMAIN.OBJ|D:\NITLOADINDUSTRY\研究项目\1-FLAGSHIP\TH2020\PROJECTFILE\内核源代码\STGSHARP.C\X64\RELEASE\HASH.OBJ|D:\NITLOADINDUSTRY\研究项目\1-FLAGSHIP\TH2020\PROJECTFILE\内核源代码\STGSHARP.C\X64\RELEASE\INTRINSIC.OBJ|D:\NITLOADINDUSTRY\研究项目\1-FLAGSHIP\TH2020\PROJECTFILE\内核源代码\STGSHARP.C\X64\RELEASE\MAT2.OBJ|D:\NITLOADINDUSTRY\研究项目\1-FLAGSHIP\TH2020\PROJECTFILE\内核源代码\STGSHARP.C\X64\RELEASE\MAT3.OBJ|D:\NITLOADINDUSTRY\研究项目\1-FLAGSHIP\TH2020\PROJECTFILE\内核源代码\STGSHARP.C\X64\RELEASE\MAT4.OBJ|D:\NITLOADINDUSTRY\研究项目\1-FLAGSHIP\TH2020\PROJECTFILE\内核源代码\STGSHARP.C\X64\RELEASE\STB_IMAGE.OBJ|D:\NITLOADINDUSTRY\研究项目\1-FLAGSHIP\TH2020\PROJECTFILE\内核源代码\STGSHARP.C\X64\RELEASE\STGSHARPC.OBJ|D:\NITLOADINDUSTRY\研究项目\1-FLAGSHIP\TH2020\PROJECTFILE\内核源代码\STGSHARP.C\X64\RELEASE\STRING.OBJ|D:\NITLOADINDUSTRY\研究项目\1-FLAGSHIP\TH2020\PROJECTFILE\内核源代码\STGSHARP.C\X64\RELEASE\VECTOR.OBJ|D:\NITLOADINDUSTRY\研究项目\1-FLAGSHIP\TH2020\PROJECTFILE\内核源代码\STGSHARP.C\X64\RELEASE\VECTOR_DOT.OBJ
C:\Users\Youmu\OneDrive - MSFT\大学\毕业设计\GraduationProject\build\StgSharp.C.lib
C:\Users\Youmu\OneDrive - MSFT\大学\毕业设计\GraduationProject\build\StgSharp.C.EXP
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\x64\Release\StgSharp.C.iobj
File diff suppressed because it is too large Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -56,15 +56,16 @@ namespace StgSharp.Commom.Collections
if( _reverse.TryGetValue( key, out TFirst value ) ) {
return value;
}
throw new ArgumentException(
$"Cannot find key {key!.ToString()} in dictionary." );
throw new ArgumentException( $"Cannot find key {key!.ToString()} in dictionary." );
}
set
{
if( _reverse.TryGetValue( key, out TFirst origin ) ) {
if( _reverse.TryGetValue( key, out TFirst origin ) )
{
_reverse[ key ] = value;
_forward.Remove( origin );
} else {
} else
{
_reverse.Add( key, value );
}
_forward.Add( value, key );
@@ -78,15 +79,16 @@ namespace StgSharp.Commom.Collections
if( _forward.TryGetValue( key, out TSecond value ) ) {
return value;
}
throw new ArgumentException(
$"Cannot find key {key!.ToString()} in dictionary." );
throw new ArgumentException( $"Cannot find key {key!.ToString()} in dictionary." );
}
set
{
if( _forward.TryGetValue( key, out TSecond origin ) ) {
if( _forward.TryGetValue( key, out TSecond origin ) )
{
_forward[ key ] = value;
_reverse.Remove( origin );
} else {
} else
{
_forward.Add( key, value );
}
_reverse.Add( value, key );
@@ -109,8 +111,7 @@ namespace StgSharp.Commom.Collections
public void Add( KeyValuePair<TFirst, TSecond> item )
{
if( _forward.ContainsKey( item.Key ) || _reverse.ContainsKey(
item.Value ) ) {
if( _forward.ContainsKey( item.Key ) || _reverse.ContainsKey( item.Value ) ) {
throw new ArgumentException( "Duplicate key or value." );
}
_forward.Add( item.Key, item.Value );
@@ -134,8 +135,9 @@ namespace StgSharp.Commom.Collections
public bool Contains( KeyValuePair<TFirst, TSecond> item )
{
return _forward.Contains( item ) && _reverse.TryGetValue(
item.Value, out TFirst var ) && var!.Equals( item.Key );
return _forward.Contains( item ) &&
_reverse.TryGetValue( item.Value, out TFirst var ) &&
var!.Equals( item.Key );
}
public bool Contains( TSecond key )
@@ -148,9 +150,7 @@ namespace StgSharp.Commom.Collections
return _forward.ContainsKey( key );
}
public void CopyTo(
KeyValuePair<TFirst, TSecond>[] array,
int arrayIndex )
public void CopyTo( KeyValuePair<TFirst, TSecond>[] array, int arrayIndex )
{
if( array == null ) {
throw new ArgumentNullException( nameof( array ) );
@@ -159,8 +159,7 @@ namespace StgSharp.Commom.Collections
throw new ArgumentOutOfRangeException( nameof( arrayIndex ) );
}
if( array.Length - arrayIndex < _forward.Count ) {
throw new ArgumentException(
"The array is too small to copy the elements." );
throw new ArgumentException( "The array is too small to copy the elements." );
}
foreach( KeyValuePair<TFirst, TSecond> pair in _forward ) {
@@ -39,13 +39,17 @@ namespace StgSharp.Commom.Collections
{
public static class CapacityFixedListBuilder
{
internal static CapacityFixedList<T> Create<T>(ReadOnlySpan<T> values)
internal static CapacityFixedList<T> Create<T>( ReadOnlySpan<T> values )
{
return new CapacityFixedList<T>(values);
return new CapacityFixedList<T>( values );
}
}
[CollectionBuilder(typeof(CapacityFixedListBuilder),nameof(CapacityFixedListBuilder.Create))]
[CollectionBuilder(
typeof( CapacityFixedListBuilder ),
nameof( CapacityFixedListBuilder.Create ) )]
public class CapacityFixedList<T> : IList<T>
{
@@ -57,7 +61,7 @@ namespace StgSharp.Commom.Collections
_values = new T[size];
}
public CapacityFixedList(ReadOnlySpan<T> values)
public CapacityFixedList( ReadOnlySpan<T> values )
{
_values = values.ToArray();
}
@@ -65,13 +69,14 @@ namespace StgSharp.Commom.Collections
public T this[ int index ]
{
get => index < _index ?
_values[ index ] : throw new ArgumentOutOfRangeException(
nameof( index ) );
_values[ index ] : throw new ArgumentOutOfRangeException( nameof( index ) );
set
{
if( index < _index ) {
if( index < _index )
{
_values[ index ] = value;
} else {
} else
{
throw new ArgumentOutOfRangeException( nameof( index ) );
}
}
@@ -83,7 +88,8 @@ namespace StgSharp.Commom.Collections
public void Add( T item )
{
if( _index < capacity - 1 ) {
if( _index < capacity - 1 )
{
_index++;
this[ _index ] = item;
}
@@ -97,7 +103,8 @@ namespace StgSharp.Commom.Collections
public bool Contains( T item )
{
for( int i = 0; i <= _index; i++ ) {
for( int i = 0; i <= _index; i++ )
{
if( item.Equals( _values[ i ] ) ) {
return true;
}
@@ -120,7 +127,8 @@ namespace StgSharp.Commom.Collections
public int IndexOf( T item )
{
T v;
for( int i = 0; i <= _index; i++ ) {
for( int i = 0; i <= _index; i++ )
{
if( ( v = _values[ i ] ) != null && v.Equals( item ) ) {
return i;
}
@@ -131,8 +139,10 @@ namespace StgSharp.Commom.Collections
public bool Remove( T item )
{
T v;
for( int i = 0; i <= _index; i++ ) {
if( ( v = _values[ i ] ) != null && v.Equals( item ) ) {
for( int i = 0; i <= _index; i++ )
{
if( ( v = _values[ i ] ) != null && v.Equals( item ) )
{
_values[ i ] = _values[ _index ];
_index--;
return true;
@@ -143,8 +153,10 @@ namespace StgSharp.Commom.Collections
public void RemoveAll( Predicate<T> predicate )
{
for( int i = _index; i > 0; i-- ) {
if( predicate( _values[ i ] ) ) {
for( int i = _index; i > 0; i-- )
{
if( predicate( _values[ i ] ) )
{
_values[ i ] = _values[ _index ];
_index--;
}
@@ -153,7 +165,8 @@ namespace StgSharp.Commom.Collections
public void RemoveAt( int index )
{
if( index <= _index ) {
if( index <= _index )
{
_values[ index ] = _values[ _index ];
_index--;
}
@@ -38,51 +38,39 @@ namespace StgSharp.Commom.Collections
public interface IBidirectionalDictionary<TFirst, TSecond> : IDictionary<TFirst, TSecond>
{
public TFirst this[ TSecond key ]
{
get;
set;
}
public TFirst this[ TSecond key ] { get; set; }
public ICollection<TFirst> FirstIndex
{
get;
}
public ICollection<TFirst> FirstIndex { get; }
public ICollection<TSecond> SecondIndex
{
get;
}
public ICollection<TSecond> SecondIndex { get; }
public IReadOnlyDictionary<TFirst, TSecond> Forward
{
get;
}
public IReadOnlyDictionary<TFirst, TSecond> Forward { get; }
public IReadOnlyDictionary<TSecond, TFirst> Reverse
{
get;
}
public IReadOnlyDictionary<TSecond, TFirst> Reverse { get; }
/// <summary>
/// Determines whether the <see cref="IBidirectionalDictionary{TFirst, TSecond}" /> contains
/// the specified key.
/// Determines whether the <see cref="IBidirectionalDictionary{TFirst, TSecond}" />
/// contains the specified key.
/// </summary>
/// <param _name="key"> The value to locate in the <see cref="IBidirectionalDictionary{TFirst, TSecond}" />. </param>
/// <param _label="key">
/// The value to locate in the <see cref="IBidirectionalDictionary{TFirst, TSecond}" />.
/// </param>
/// <returns>
/// true if the <see cref="IBidirectionalDictionary{TFirst, TSecond}" /> contains an element
/// with the specified key; otherwise, false.
/// true if the <see cref="IBidirectionalDictionary{TFirst, TSecond}" /> contains an
/// element with the specified key; otherwise, false.
/// </returns>
public bool Contains( TSecond key );
/// <summary>
/// Determines whether the <see cref="IBidirectionalDictionary{TFirst, TSecond}" /> contains
/// the specified key.
/// Determines whether the <see cref="IBidirectionalDictionary{TFirst, TSecond}" />
/// contains the specified key.
/// </summary>
/// <param _name="key"> The value to locate in the <see cref="IBidirectionalDictionary{TFirst, TSecond}" />. </param>
/// <param _label="key">
/// The value to locate in the <see cref="IBidirectionalDictionary{TFirst, TSecond}" />.
/// </param>
/// <returns>
/// true if the <see cref="IBidirectionalDictionary{TFirst, TSecond}" /> contains an element
/// with the specified key; otherwise, false.
/// true if the <see cref="IBidirectionalDictionary{TFirst, TSecond}" /> contains an
/// element with the specified key; otherwise, false.
/// </returns>
public bool Contains( TFirst key );
@@ -93,8 +81,7 @@ namespace StgSharp.Commom.Collections
ICollection<TSecond> IDictionary<TFirst, TSecond>.Values => SecondIndex;
bool IDictionary<TFirst, TSecond>.ContainsKey( TFirst key ) => Contains(
key );
bool IDictionary<TFirst, TSecond>.ContainsKey( TFirst key ) => Contains( key );
#pragma warning restore CA1033
}
}
@@ -36,11 +36,7 @@ namespace StgSharp.Collections
public interface IHashMultiplexer<T> : IEqualityComparer<T>
{
int RemainedMultiplexCount
{
get;
set;
}
int RemainedMultiplexCount { get; set; }
void CacheHash( T obj, int count );
+19 -9
View File
@@ -40,10 +40,12 @@ using System.Xml.Serialization;
namespace StgSharp.Collections
{
/// <summary>
/// Part of a collection. This contains a direct reference to _origin collection, so all change
/// to _origin collection will be reflected in this object.
/// Part of a collection. This contains a direct reference to _origin collection, so all
/// change to _origin collection will be reflected in this object.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <typeparam name="T">
///
/// </typeparam>
public struct ListSegment<T> : ICollection<T>
{
@@ -56,8 +58,7 @@ namespace StgSharp.Collections
ArgumentNullException.ThrowIfNull( collection );
ArgumentOutOfRangeException.ThrowIfLessThan( begin, 0 );
ArgumentOutOfRangeException.ThrowIfLessThan( length, 0 );
ArgumentOutOfRangeException.ThrowIfLessThan(
begin + length, collection.Count );
ArgumentOutOfRangeException.ThrowIfLessThan( begin + length, collection.Count );
_collection = collection;
_begin = begin;
_length = length;
@@ -68,12 +69,22 @@ namespace StgSharp.Collections
get
{
ArgumentOutOfRangeException.ThrowIfLessThan( indexValue, 0 );
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(
indexValue, _length );
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual( indexValue, _length );
return _collection[ indexValue + _begin ];
}
}
public T this[ Index i ]
{
get
{
int offset = i.IsFromEnd ? _length - i.Value : i.Value;
ArgumentOutOfRangeException.ThrowIfLessThan( offset, 0 );
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual( offset, _length );
return _collection[ offset + _begin ];
}
}
public bool IsReadOnly => true;
public int Count => _length;
@@ -87,8 +98,7 @@ namespace StgSharp.Collections
public void CopyTo( T[] array, int arrayIndex )
{
ArgumentNullException.ThrowIfNull( array );
Span<T> span = CollectionsMarshal.AsSpan<T>( _collection )
.Slice( _begin, _length );
Span<T> span = CollectionsMarshal.AsSpan<T>( _collection ).Slice( _begin, _length );
Span<T> target = new Span<T>( array, arrayIndex, _length );
span.CopyTo( target );
}
@@ -40,17 +40,17 @@ namespace StgSharp.Collections
{
public partial class PartialDictionary<TKey, TValue> : IDictionary<TKey, TValue>
{
private readonly Dictionary<TKey, TValue> _source;
private readonly HashSet<TKey> _keys;
private readonly PartialDictionaryValues _values;
public PartialDictionary(
Dictionary<TKey, TValue> source,
TKey[] index )
public PartialDictionary( Dictionary<TKey, TValue> source, TKey[] index )
{
_source = source;
_keys = new HashSet<TKey>( index );
foreach( TKey item in _keys ) {
foreach( TKey item in _keys )
{
if( !_source.ContainsKey( item ) ) {
_source.Add( item, default! );
}
@@ -58,13 +58,12 @@ namespace StgSharp.Collections
_values = new PartialDictionaryValues( this );
}
public PartialDictionary(
Dictionary<TKey, TValue> source,
HashSet<TKey> keys )
public PartialDictionary( Dictionary<TKey, TValue> source, HashSet<TKey> keys )
{
_source = source;
_keys = keys;
foreach( TKey item in _keys ) {
foreach( TKey item in _keys )
{
if( !_source.ContainsKey( item ) ) {
_source.Add( item, default! );
}
@@ -73,20 +72,19 @@ namespace StgSharp.Collections
}
public PartialDictionary(
Dictionary<TKey, TValue> source,
TKey[] index, IHashMultiplexer<TKey> multiplexer
)
Dictionary<TKey, TValue> source,
TKey[] index,
IHashMultiplexer<TKey> multiplexer )
{
_source = source;
_keys = new HashSet<TKey>(index);
foreach (TKey item in _keys)
_keys = new HashSet<TKey>( index );
foreach( TKey item in _keys )
{
if (!_source.ContainsKey(item))
{
_source.Add(item, default!);
if( !_source.ContainsKey( item ) ) {
_source.Add( item, default! );
}
}
_values = new PartialDictionaryValues(this);
_values = new PartialDictionaryValues( this );
}
public TValue this[ TKey key ]
@@ -131,14 +129,14 @@ namespace StgSharp.Collections
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
{
foreach( TKey item in _keys ) {
yield return new KeyValuePair<TKey, TValue>(
item, _source[ item ] );
yield return new KeyValuePair<TKey, TValue>( item, _source[ item ] );
}
}
public bool TryGetValue( TKey key, out TValue value )
{
if( _keys.Contains( key ) ) {
if( _keys.Contains( key ) )
{
value = _source[ key ];
return true;
}
@@ -146,8 +144,7 @@ namespace StgSharp.Collections
return false;
}
void ICollection<KeyValuePair<TKey, TValue>>.Add(
KeyValuePair<TKey, TValue> item )
void ICollection<KeyValuePair<TKey, TValue>>.Add( KeyValuePair<TKey, TValue> item )
{
return;
}
@@ -157,8 +154,7 @@ namespace StgSharp.Collections
throw new NotSupportedException();
}
bool ICollection<KeyValuePair<TKey, TValue>>.Remove(
KeyValuePair<TKey, TValue> item )
bool ICollection<KeyValuePair<TKey, TValue>>.Remove( KeyValuePair<TKey, TValue> item )
{
throw new NotSupportedException();
}
@@ -43,8 +43,7 @@ namespace StgSharp.Collections
private readonly PartialDictionary<TKey, TValue> _values;
public PartialDictionaryValues(
PartialDictionary<TKey, TValue> value )
public PartialDictionaryValues( PartialDictionary<TKey, TValue> value )
{
_values = value;
}
@@ -55,7 +54,8 @@ namespace StgSharp.Collections
public bool Contains( TValue item )
{
foreach( KeyValuePair<TKey, TValue> kvp in _values ) {
foreach( KeyValuePair<TKey, TValue> kvp in _values )
{
if( kvp.Value != null && kvp.Value.Equals( item ) ) {
return true;
}
@@ -65,7 +65,8 @@ namespace StgSharp.Collections
public void CopyTo( TValue[] array, int arrayIndex )
{
foreach( KeyValuePair<TKey, TValue> kvp in _values ) {
foreach( KeyValuePair<TKey, TValue> kvp in _values )
{
array[ arrayIndex ] = kvp.Value;
arrayIndex++;
}
@@ -0,0 +1,185 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="RandomAccessibleStack.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Collections
{
public class RandomAccessibleStack<T> : IEnumerable<T>
{
private const int DefaultCapacity = 4;
private T[] _array;
private int _size;
private int _version;
/// <summary>
/// Initializes a new instance of the RandomAccessStack class that is empty and has the
/// default initial capacity.
/// </summary>
public RandomAccessibleStack()
{
_array = new T[DefaultCapacity];
}
/// <summary>
/// Initializes a new instance of the RandomAccessStack class that is empty and has the
/// specified initial capacity.
/// </summary>
public RandomAccessibleStack( int capacity )
{
if( capacity < 0 ) {
throw new ArgumentOutOfRangeException(
nameof( capacity ), "Capacity must be non-negative." );
}
_array = new T[capacity];
}
/// <summary>
/// Gets or sets the element at the specified index in the stack (0 = bottom, Count-1 =
/// top).
/// </summary>
public T this[ int index ]
{
get
{
if( index < 0 || index >= _size ) {
throw new ArgumentOutOfRangeException( nameof( index ) );
}
return _array[ index ];
}
/*
set
{
if( index < 0 || index >= _size ) {
throw new ArgumentOutOfRangeException( nameof( index ) );
}
_array[ index ] = value;
_version++;
}
/**/
}
/// <summary>
/// Gets the number of elements contained in the stack.
/// </summary>
public int Count => _size;
/// <summary>
/// Removes all objects from the stack.
/// </summary>
public void Clear()
{
Array.Clear( _array, 0, _size );
_size = 0;
_version++;
}
/// <summary>
/// Returns an enumerator that iterates through the stack from top to bottom. Throws if
/// the stack is modified during iteration.
/// </summary>
public IEnumerator<T> GetEnumerator()
{
int expectedVersion = _version;
for( int i = _size - 1; i >= 0; i-- )
{
if( expectedVersion != _version ) {
throw new InvalidOperationException(
"Collection was modified during enumeration." );
}
yield return _array[ i ];
}
}
/// <summary>
/// Returns the object at the top of the stack without removing it.
/// </summary>
public T Peek()
{
if( _size == 0 ) {
throw new InvalidOperationException( "Stack is empty." );
}
return _array[ _size - 1 ];
}
/// <summary>
/// Removes and returns the object at the top of the stack.
/// </summary>
public T Pop()
{
if( _size == 0 ) {
throw new InvalidOperationException( "Stack is empty." );
}
T item = _array[ --_size ];
_array[ _size ] = default!;
_version++;
return item;
}
/// <summary>
/// Adds an item to the top of the stack.
/// </summary>
public void Push( T item )
{
if( _size == _array.Length ) {
EnsureCapacity( _size + 1 );
}
_array[ _size++ ] = item;
_version++;
}
private void EnsureCapacity( int min )
{
int newCapacity = _array.Length == 0 ? DefaultCapacity : _array.Length * 2;
if( newCapacity < min ) {
newCapacity = min;
}
Array.Resize( ref _array, newCapacity );
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
}
@@ -1,6 +1,6 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="KeyMultiplexer.cs"
// file="StringHashMultiplexer.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
@@ -38,7 +38,7 @@ using System.Threading;
namespace StgSharp.Collections
{
public sealed class StringHashMultiplexer : IHashMultiplexer<string>
public sealed class StringHashMultiplexer : IHashMultiplexer<string>
{
private int _initCount, _remainedCount, _hashCache, _hashLast;
@@ -74,15 +74,15 @@ namespace StgSharp.Collections
{
int hash;
fixed( char* cPtr = obj.AsSpan() ) {
hash = InternalIO.Intrinsic
.city_hash_simplify( cPtr, obj.Length );
hash = InternalIO.Intrinsic.city_hash_simplify( cPtr, obj.Length );
}
return hash;
}
public int GetHashCode( string obj )
{
if( _remainedCount > 0 && ReferenceEquals( _source, obj ) ) {
if( _remainedCount > 0 && ReferenceEquals( _source, obj ) )
{
_remainedCount--;
return _hashCache;
}
@@ -139,8 +139,7 @@ namespace StgSharp.Collections
{
int hash;
fixed( char* cPtr = obj.AsSpan() ) {
hash = InternalIO.Intrinsic
.city_hash_simplify( cPtr, obj.Length );
hash = InternalIO.Intrinsic.city_hash_simplify( cPtr, obj.Length );
}
return hash;
}
@@ -152,7 +151,8 @@ namespace StgSharp.Collections
private void Dispose( bool disposing )
{
if( !disposedValue ) {
if( !disposedValue )
{
if( disposing ) {
_multiplexers.Dispose();
}
@@ -51,17 +51,9 @@ namespace StgSharp.Controls
get => throw new NotImplementedException();
}
public Rectangle BoundingBox
{
get;
set;
}
public Rectangle BoundingBox { get; set; }
public Vec2 Position
{
get;
set;
}
public Vec2 Position { get; set; }
public IEnumerator<PlainGeometryMesh> GetEnumerator()
{
@@ -63,22 +63,14 @@ namespace StgSharp.Controls
get => throw new NotSupportedException();
}
public Rectangle BoundingBox
{
get;
set;
}
public Rectangle BoundingBox { get; set; }
public TriggerButton CurrentButton
{
get => current;
}
public Vec2 Position
{
get;
set;
}
public Vec2 Position { get; set; }
protected List<TriggerButton> AllButton
{
@@ -52,16 +52,15 @@ namespace StgSharp.Controls
private PlainGeometryMesh _tittleMesh;
public CharacterLineIndexImage(
int length,
char defaultChar,
PlainGeometryMesh tittleMesh,
IEnumerable<(char, PlainGeometryMesh)> indexEnumeration )
int length,
char defaultChar,
PlainGeometryMesh tittleMesh,
IEnumerable<(char, PlainGeometryMesh)> indexEnumeration )
{
this.length = length;
displayIndex = new char[length];
_tittleMesh = tittleMesh;
texIndex = indexEnumeration.ToDictionary(
item => item.Item1, item => item.Item2 );
texIndex = indexEnumeration.ToDictionary( item => item.Item1, item => item.Item2 );
}
public bool IsEntity
@@ -93,8 +92,8 @@ namespace StgSharp.Controls
}
string result = ( message.Length >= length ) ?
message.Substring( message.Length - displayIndex.Length ) : message.PadLeft(
length, defaultChar );
message.Substring( message.Length - displayIndex.Length ) : message.PadLeft(
length, defaultChar );
displayIndex = result.ToCharArray();
}
@@ -42,27 +42,13 @@ namespace StgSharp.Controls
public interface ControllingItem : IEnumerable<PlainGeometryMesh>
{
public abstract bool IsEntity
{
get;
}
public abstract bool IsEntity { get; }
public abstract ReadOnlySpan<Vec4> TextureBox
{
get;
}
public abstract ReadOnlySpan<Vec4> TextureBox { get; }
public abstract Rectangle BoundingBox
{
get;
set;
}
public abstract Rectangle BoundingBox { get; set; }
public abstract Vec2 Position
{
get;
set;
}
public abstract Vec2 Position { get; set; }
IEnumerator IEnumerable.GetEnumerator()
{
@@ -57,17 +57,9 @@ namespace StgSharp.Controls
get => renderMesh.TextureCoord;
}
public Rectangle BoundingBox
{
get;
set;
}
public Rectangle BoundingBox { get; set; }
public Vec2 Position
{
get;
set;
}
public Vec2 Position { get; set; }
public IEnumerator<PlainGeometryMesh> GetEnumerator()
{
@@ -63,17 +63,9 @@ namespace StgSharp.Controls
get => marker.TextureCoord;
}
public Rectangle BoundingBox
{
get;
set;
}
public Rectangle BoundingBox { get; set; }
public Vec2 Position
{
get;
set;
}
public Vec2 Position { get; set; }
public IEnumerator<PlainGeometryMesh> GetEnumerator()
{
@@ -41,9 +41,9 @@ using System.Text;
namespace StgSharp.Controls
{
public delegate void RenderButtonTextureCallback(
ButtonStatus status,
float beginTime,
in TextureProvider texture );
ButtonStatus status,
float beginTime,
in TextureProvider texture );
public enum ButtonStatus
{
@@ -106,9 +106,11 @@ namespace StgSharp.Controls
{
add
{
if( _renderButton == null ) {
if( _renderButton == null )
{
_renderButton = value;
} else {
} else
{
_renderButton += value;
}
}
@@ -120,17 +122,9 @@ namespace StgSharp.Controls
}
}
public bool IsHighLighted
{
get;
internal set;
}
public bool IsHighLighted { get; internal set; }
public bool IsDisabled
{
get;
internal set;
}
public bool IsDisabled { get; internal set; }
public bool IsEntity => true;
@@ -139,41 +133,17 @@ namespace StgSharp.Controls
get => MemoryMarshal.Cast<Vec2, Vec4>( _texture.TextureCoordinate );
}
public Rectangle BoundingBox
{
get;
set;
}
public Rectangle BoundingBox { get; set; }
public TriggerButton Left
{
get;
internal set;
}
public TriggerButton Left { get; internal set; }
public TriggerButton Right
{
get;
internal set;
}
public TriggerButton Right { get; internal set; }
public TriggerButton Up
{
get;
internal set;
}
public TriggerButton Up { get; internal set; }
public TriggerButton Down
{
get;
internal set;
}
public TriggerButton Down { get; internal set; }
public Vec2 Position
{
get;
set;
}
public Vec2 Position { get; set; }
internal TextureProvider Texture
{
@@ -181,11 +151,7 @@ namespace StgSharp.Controls
set => _texture = value;
}
protected ButtonStatus CurrentStatus
{
get;
set;
}
protected ButtonStatus CurrentStatus { get; set; }
public void DeHighlight()
{
@@ -209,9 +175,11 @@ namespace StgSharp.Controls
public void Enable()
{
if( CurrentStatus == ButtonStatus.Disable ) {
if( CurrentStatus == ButtonStatus.Disable )
{
CurrentStatus = ButtonStatus.DisableToEnable;
} else {
} else
{
return;
}
if( enableCallback != null ) {
@@ -227,9 +195,11 @@ namespace StgSharp.Controls
public void Highlight()
{
if( CurrentStatus == ButtonStatus.Enable ) {
if( CurrentStatus == ButtonStatus.Enable )
{
CurrentStatus |= ButtonStatus.EnableToHighlight;
} else {
} else
{
return;
}
if( confirmCallback != null ) {
+3 -3
View File
@@ -215,9 +215,9 @@ namespace StgSharp
}
#pragma warning restore CA1707
#pragma warning restore CA1712
#pragma warning restore CA7008
#pragma warning restore CA1707
#pragma warning restore CA1712
#pragma warning restore CA7008
internal enum InputEquipment
{
@@ -37,15 +37,9 @@ namespace StgSharp.Controlling.UsrActivity
public interface IClickTrigger
{
public int TargetKeyOrButtonID
{
get;
}
public int TargetKeyOrButtonID { get; }
public KeyStatus TriggeredStatus
{
get;
}
public KeyStatus TriggeredStatus { get; }
}
}
@@ -70,16 +70,12 @@ namespace StgSharp.Controlling.UsrActivity
return $"Key {_stick} triggered when {_status}";
}
public static bool operator !=(
JoystickTrigger left,
JoystickTrigger right )
public static bool operator !=( JoystickTrigger left, JoystickTrigger right )
{
return !( left == right );
}
public static bool operator ==(
JoystickTrigger left,
JoystickTrigger right )
public static bool operator ==( JoystickTrigger left, JoystickTrigger right )
{
return ( left._status == right._status ) && ( left._stick == right._stick );
}
@@ -73,7 +73,8 @@ namespace StgSharp.Controlling.UsrActivity
public static bool operator ==( KeyTrigger left, KeyTrigger right )
{
return ( left._triggerStat == right._triggerStat ) && ( left._targetKey == right._targetKey );
return ( left._triggerStat == right._triggerStat ) &&
( left._targetKey == right._targetKey );
}
bool IEquatable<KeyTrigger>.Equals( KeyTrigger other )
@@ -49,42 +49,31 @@ namespace StgSharp.Controlling.UsrActivity
private static KeyTrigger keyboardtemp;
private static MouseTrigger mousetemp;
public static JoystickTrigger BuildJoystickClickTrigger(
int keyCode,
KeyStatus status )
public static JoystickTrigger BuildJoystickClickTrigger( int keyCode, KeyStatus status )
{
if( keyCode > MouseMin && keyCode < MouseMax ) {
return new JoystickTrigger( ( Joystick )keyCode, status );
}
throw new InvalidOperationException(
"Known key code or key is not on joystick." );
throw new InvalidOperationException( "Known key code or key is not on joystick." );
}
public static KeyTrigger BuildKeyboardClickTrigger(
int keyCode,
KeyStatus status )
public static KeyTrigger BuildKeyboardClickTrigger( int keyCode, KeyStatus status )
{
if( keyCode > KeyboardMin && keyCode < KeyboardMax ) {
return new KeyTrigger( ( KeyboardKey )keyCode, status );
}
throw new InvalidOperationException(
"Known key code or kay is not on keyboard." );
throw new InvalidOperationException( "Known key code or kay is not on keyboard." );
}
public static MouseTrigger BuildMouseClickTrigger(
int keyCode,
KeyStatus status )
public static MouseTrigger BuildMouseClickTrigger( int keyCode, KeyStatus status )
{
if( keyCode >= MouseMin && keyCode <= MouseMax ) {
return new MouseTrigger( ( Mouse )keyCode, status );
}
throw new InvalidOperationException(
"Known key code or key is not on mouse." );
throw new InvalidOperationException( "Known key code or key is not on mouse." );
}
public static IClickTrigger BuildTrigger(
int keyCode,
KeyStatus status )
public static IClickTrigger BuildTrigger( int keyCode, KeyStatus status )
{
if( keyCode > KeyboardMin && keyCode < KeyboardMax ) {
return new KeyTrigger( ( KeyboardKey )keyCode, status );
+1 -1
View File
@@ -38,7 +38,7 @@ using System.Threading.Tasks;
namespace StgSharp
{
public static unsafe partial class StgSharp
public static unsafe partial class World
{
private static byte leastUnusedArea;
+3 -3
View File
@@ -39,9 +39,9 @@ using System.Threading.Tasks;
namespace StgSharp.Internal
{
/// <summary>
/// An independent storage area, used as the only folder type in root folder. Contains several
/// <see cref="SSD" /> files reference as virtual disc. Data is actually stored in <see
/// cref="SSD" />s in certain RAID mode.
/// An independent storage area, used as the only folder type in root folder. Contains several
/// <see cref="SSD" /> files reference as virtual disc. Data is actually stored in <see
/// cref="SSD" />s in certain RAID mode.
/// </summary>
public partial class Area { }
}
+2 -1
View File
@@ -66,7 +66,8 @@ namespace StgSharp.Internal
public unsafe byte[] GetBytes()
{
byte[] ret = new byte[16];
fixed( M128* vptr = &data ) {
fixed( M128* vptr = &data )
{
byte* bptr = ( byte* )vptr;
for( int i = 0; i < 15; i++ ) {
ret[ i ] = *bptr;
+24 -19
View File
@@ -44,12 +44,11 @@ using System.Threading.Tasks;
namespace StgSharp.Internal
{
[StructLayout( LayoutKind.Explicit, Size = StgSharp.ssdSegmentLength * 16 )]
[StructLayout( LayoutKind.Explicit, Size = World.ssdSegmentLength * 16 )]
public unsafe struct SSDSegment : IComparable<int>, IComparable<SSDSegment>
{
[FieldOffset( 16 )] public fixed byte Data[
16 * ( StgSharp.ssdSegmentLength - 1 ) ];
[FieldOffset( 16 )] public fixed byte Data[ 16 * ( World.ssdSegmentLength - 1 ) ];
[FieldOffset( 12 )] public int DataHash;
[FieldOffset( 8 )] public int PreviousHash;
[FieldOffset( 0 * 16 )] public SSDSegmentHead Head;
@@ -63,7 +62,7 @@ namespace StgSharp.Internal
{
get
{
if( index > ( 16 * ( StgSharp.ssdSegmentLength - 1 ) ) - 1 ) {
if( index > ( 16 * ( World.ssdSegmentLength - 1 ) ) - 1 ) {
throw new IndexOutOfRangeException();
}
return Data[ index ];
@@ -71,7 +70,7 @@ namespace StgSharp.Internal
set
{
if( index > ( 16 * ( StgSharp.ssdSegmentLength - 1 ) ) - 1 ) {
if( index > ( 16 * ( World.ssdSegmentLength - 1 ) ) - 1 ) {
throw new IndexOutOfRangeException();
}
Data[ index ] = value;
@@ -98,15 +97,15 @@ namespace StgSharp.Internal
public static SSDSegment FromStream( byte[] stream )
{
if( stream.Length != 16 * StgSharp.ssdSegmentLength ) {
if( stream.Length != 16 * World.ssdSegmentLength ) {
throw new ArgumentException();
}
SSDSegment ret = new SSDSegment();
fixed( byte* bptr = stream ) {
fixed( byte* bptr = stream )
{
ret.Head.data = *( M128* )bptr;
for( int i = 1; i < StgSharp.ssdSegmentLength; i++ ) {
ret.WriteData<M128>(
i - 1, *( M128* )( bptr + ( 16 * i ) ) );
for( int i = 1; i < World.ssdSegmentLength; i++ ) {
ret.WriteData<M128>( i - 1, *( M128* )( bptr + ( 16 * i ) ) );
}
}
return ret;
@@ -114,9 +113,11 @@ namespace StgSharp.Internal
public byte[] GetBytes()
{
byte[] ret = new byte[16 * StgSharp.ssdSegmentLength];
fixed( M128* mptr = &Head.data ) {
fixed( byte* aptr = ret ) {
byte[] ret = new byte[16 * World.ssdSegmentLength];
fixed( M128* mptr = &Head.data )
{
fixed( byte* aptr = ret )
{
Vector4* vsptr = ( Vector4* )mptr;
Vector4* vtptr = ( Vector4* )aptr;
for( int i = 0; i < 18; i++ ) {
@@ -131,9 +132,10 @@ namespace StgSharp.Internal
public int GetDataHash()
{
Vector4 v = Vector4.One;
fixed( M128* mptr = &Head.data ) {
fixed( M128* mptr = &Head.data )
{
Vector4* vptr = ( Vector4* )mptr;
for( int i = 0; i < StgSharp.ssdSegmentLength - 1; i += 1 ) {
for( int i = 0; i < World.ssdSegmentLength - 1; i += 1 ) {
v += ( *vptr ) * 31;
}
}
@@ -145,9 +147,10 @@ namespace StgSharp.Internal
public override int GetHashCode()
{
int ret = 17;
fixed( M128* mptr = &Head.data ) {
fixed( M128* mptr = &Head.data )
{
Vector4* vptr = ( Vector4* )mptr;
for( int i = 0; i < StgSharp.ssdSegmentLength; i++ ) {
for( int i = 0; i < World.ssdSegmentLength; i++ ) {
ret = ( ret + ( *vptr ).GetHashCode() ) * 31;
}
}
@@ -156,7 +159,8 @@ namespace StgSharp.Internal
public unsafe T ReadData<T>( int index ) where T: struct
{
fixed( byte* bptr = Data ) {
fixed( byte* bptr = Data )
{
T* tptr = ( T* )bptr;
return *( tptr + index );
}
@@ -164,7 +168,8 @@ namespace StgSharp.Internal
public unsafe void WriteData<T>( int index, T value ) where T: struct
{
fixed( byte* bptr = Data ) {
fixed( byte* bptr = Data )
{
T* tptr = ( T* )bptr;
*( tptr + index ) = value;
}
+1 -2
View File
@@ -58,8 +58,7 @@ namespace StgSharp.Internal
public static SSD FromFile( string fileRoute )
{
return new SSD(
new FileStream( fileRoute, FileMode.Open, FileAccess.Read ) )
return new SSD( new FileStream( fileRoute, FileMode.Open, FileAccess.Read ) )
{
};
}
+2 -10
View File
@@ -60,17 +60,9 @@ namespace StgSharp.Internal.FileIO
streamSource.Read( data.AsSpan() );
}
public SSDrawHead Head
{
get;
set;
}
public SSDrawHead Head { get; set; }
public string Name
{
get;
set;
}
public string Name { get; set; }
}
+1 -1
View File
@@ -35,7 +35,7 @@ using System.Text;
namespace StgSharp.Internal
{
/// <summary>
/// A class contains a sets of methods to serialize several types
/// A class contains a sets of methods to serialize several types
/// </summary>
public static partial class Serializer { }
}
@@ -39,10 +39,7 @@ namespace StgSharp.Internal
public interface ISSDSerializable
{
public SerializableTypeCode SSDTypeCode
{
get;
}
public SerializableTypeCode SSDTypeCode { get; }
public byte[] GetBytes();
@@ -68,8 +65,7 @@ namespace StgSharp.Internal
public static partial class Serializer
{
public static T Deserialize<T>( byte[] stream )
where T: ISSDSerializable
public static T Deserialize<T>( byte[] stream ) where T: ISSDSerializable
{
T serializableObject = Activator.CreateInstance<T>();
serializableObject.FromBytes( stream );
@@ -78,7 +74,8 @@ namespace StgSharp.Internal
public static string GetNameTail( SerializableTypeCode typeCode )
{
switch( typeCode ) {
switch( typeCode )
{
case SerializableTypeCode.IndexTable:
return "_idt";
case SerializableTypeCode.PixelImage:
+9 -16
View File
@@ -41,13 +41,9 @@ namespace StgSharp.Data
public interface IValueBox
{
ref object ValueReference
{
get;
}
ref object ValueReference { get; }
static virtual IValueBox<T> AsGeneric<T>( IValueBox box )
where T: struct
static virtual IValueBox<T> AsGeneric<T>( IValueBox box ) where T: struct
{
if( box is not IValueBox<T> genericBox ) {
return null;
@@ -65,19 +61,17 @@ namespace StgSharp.Data
public interface IValueBox<T> where T: struct
{
T Value
{
get;
set;
}
T Value { get; set; }
}
/// <summary>
/// A class attempt to reduce cost of boxing, though still a bit slower than direct access to
/// _origin value type instance.
/// A class attempt to reduce cost of boxing, though still a bit slower than direct access to
/// _origin value type instance.
/// </summary>
/// <typeparam name="T"> Type of instance to be boxed. </typeparam>
/// <typeparam name="T">
/// Type of instance to be boxed.
/// </typeparam>
public class ValueBox<T> : IValueBox, IValueBox<T> where T: struct
{
@@ -88,8 +82,7 @@ namespace StgSharp.Data
_value = value;
}
public ref object ValueReference => ref Unsafe.As<T, object>(
ref _value );
public ref object ValueReference => ref Unsafe.As<T, object>( ref _value );
public T Value
{
+3 -16
View File
@@ -28,7 +28,6 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
namespace StgSharp.Entities
{
public class Enemy : IEntity
@@ -39,23 +38,11 @@ namespace StgSharp.Entities
internal Launcher<EntityPartical> _dieBulletLauncher;
public bool _selectalbe;
public Launcher<EntityPartical> AwardLauncher
{
get;
set;
}
public Launcher<EntityPartical> AwardLauncher { get; set; }
public Launcher<EntityPartical> CommonBulletLauncher
{
get;
set;
}
public Launcher<EntityPartical> CommonBulletLauncher { get; set; }
public Launcher<EntityPartical> DieBulletLauncher
{
get;
set;
}
public Launcher<EntityPartical> DieBulletLauncher { get; set; }
public override void OnRenderFrame()
{
+10 -25
View File
@@ -42,29 +42,21 @@ namespace StgSharp
protected uint _bornTick;
internal Func<int, Vec3> _movHandler;
internal LinkedList<PlainGeometry> _collisionBox;
internal PlainGeometryCollisionSensor<PlainGeometry, PlainGeometry> _collisionSensor;
internal Point _basePoint;
internal Point _pos;
internal Point _position;
internal PlainGeometryCollisionSensor<PlainGeometry, PlainGeometry> _collisionSensor;
internal string _texture;
/// <summary>
/// X position of an enenmy entity
/// X position of an enenmy entity
/// </summary>
public float X
{
get;
set;
}
public float X { get; set; }
/// <summary>
/// Y position of an enemy entity
/// Y position of an enemy entity
/// </summary>
public float Y
{
get;
set;
}
public float Y { get; set; }
public LinkedList<PlainGeometry> CollisionBox
{
@@ -73,7 +65,7 @@ namespace StgSharp
}
/// <summary>
/// A sensor used for checking out if a bullet hit a player or something else
/// A sensor used for checking out if a bullet hit a player or something else
/// </summary>
public PlainGeometryCollisionSensor<PlainGeometry, PlainGeometry> CollisionSensor
{
@@ -81,20 +73,13 @@ namespace StgSharp
set => _collisionSensor = value;
}
public string TextureGL
{
get;
set;
}
public string TextureGL { get; set; }
/// <summary>
/// A 2D vector presenting the position of an enemy entity, position can also be visited by
/// X, Y
/// A 2D vector presenting the position of an enemy entity, position can also be visited
/// by X, Y
/// </summary>
public Vec2 Location
{
get;
}
public Vec2 Location { get; }
public abstract void OnRenderFrame();
+45 -51
View File
@@ -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();
}
}
}
+3 -3
View File
@@ -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 )
{
+4 -4
View File
@@ -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;
+30 -27
View File
@@ -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;
}
}
+1 -1
View File
@@ -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
@@ -41,22 +41,16 @@ namespace StgSharp.Geometries
{
private static PlainCoordinate statndardPlainCoordination = new PlainCoordinate(
null, new Point( 0, 0, 0 ), new Vec3( 1, 0, 0 ),
new Vec3( 0, 1, 0 ) );
null, new Point( 0, 0, 0 ), new Vec3( 1, 0, 0 ), new Vec3( 0, 1, 0 ) );
public PlainCoordinate(
CoordinationBase local,
Point origin,
Vec3 xAxis,
Vec3 yAxis )
public PlainCoordinate( CoordinationBase local, Point origin, Vec3 xAxis, Vec3 yAxis )
: base( local )
{
CoordMat = Matrix44.Unit;
CoordMat.colum0 = new Vec4( xAxis, 0 );
CoordMat.colum1 = new Vec4( yAxis, 0 );
CoordMat.colum2 = new Vec4(
Linear.Normalize( Vec3.Cross( xAxis, yAxis ) ), 0 );
CoordMat.colum2 = new Vec4( Linear.Normalize( Vec3.Cross( xAxis, yAxis ) ), 0 );
LocalOrigin = origin;
}
@@ -40,11 +40,11 @@ namespace StgSharp.Geometries
{
public SpaceCoordinate(
CoordinationBase localCoordination,
Point origin,
Vec3 xAxis,
Vec3 yAxis,
Vec3 zAxis )
CoordinationBase localCoordination,
Point origin,
Vec3 xAxis,
Vec3 yAxis,
Vec3 zAxis )
: base( localCoordination ) { }
}
+4 -10
View File
@@ -36,31 +36,25 @@ namespace StgSharp.Geometries
public unsafe class ToUpperDimensionException : Exception
{
protected ToUpperDimensionException(
SerializationInfo info,
StreamingContext context )
protected ToUpperDimensionException( SerializationInfo info, StreamingContext context )
: base( info, context ) { }
public ToUpperDimensionException() { }
public ToUpperDimensionException( string message ) : base( message ) { }
public ToUpperDimensionException(
string message,
Exception innerException )
public ToUpperDimensionException( string message, Exception innerException )
: base( message, innerException ) { }
}
/// <summary>
/// 当几何体调用了过多的CalcVec方法时,产生UnusedVertexException异常
/// 当几何体调用了过多的CalcVec方法时,产生UnusedVertexException异常
/// </summary>
public class UnusedVertexException : Exception
{
protected UnusedVertexException(
SerializationInfo info,
StreamingContext context )
protected UnusedVertexException( SerializationInfo info, StreamingContext context )
: base( info, context ) { }
public UnusedVertexException() { }
@@ -40,9 +40,7 @@ using System.Text;
namespace StgSharp.Geometries
{
[UnmanagedFunctionPointer( CallingConvention.Cdecl )]
public delegate Vec3 GeometryMotionDelegate(
TimeSpanProvider timeSource,
out float rotation );
public delegate Vec3 GeometryMotionDelegate( TimeSpanProvider timeSource, out float rotation );
public class GeometryMotion
{
@@ -54,20 +52,23 @@ namespace StgSharp.Geometries
private TimeSpanProvider time;
public unsafe GeometryMotion(
bool isIncreament,
TimeSpanProvider timeSource,
GeometryMotionDelegate motionDelegate )
bool isIncreament,
TimeSpanProvider timeSource,
GeometryMotionDelegate motionDelegate )
{
isIncrementMode = isIncreament;
time = timeSource;
if( motionDelegate == null ) {
if( motionDelegate == null )
{
handle = ( IntPtr )( delegate*<TimeSpanProvider, out float, Vec3> )&defaultMotion;
movement = defaultMotion;
} else if( motionDelegate.Method.IsStatic ) {
} else if( motionDelegate.Method.IsStatic )
{
sourceIsStatic = true;
handle = Marshal.GetFunctionPointerForDelegate( motionDelegate );
movement = motionDelegate;
} else {
} else
{
movement = motionDelegate;
}
@@ -88,25 +89,27 @@ namespace StgSharp.Geometries
{
float rot;
Vec3 vec;
if( sourceIsStatic ) {
if( sourceIsStatic )
{
vec = ( ( delegate* unmanaged[Cdecl]<TimeSpanProvider, out float, Vec3> )handle )(
time, out rot );
} else {
} else
{
vec = movement( time, out rot );
}
if( isIncrementMode ) {
if( isIncrementMode )
{
coord += vec;
rotation += rot;
} else {
} else
{
coord = vec;
rotation = rot;
}
}
private static Vec3 defaultMotion(
TimeSpanProvider provider,
out float rotation )
private static Vec3 defaultMotion( TimeSpanProvider provider, out float rotation )
{
rotation = 0;
return Vec3.Zero;
+6 -21
View File
@@ -42,33 +42,18 @@ namespace StgSharp.Geometries
public interface IGeometry
{
public Point this[ int index ]
{
get;
set;
}
public Point this[ int index ] { get; set; }
#pragma warning disable CA1819
public Vec4[] VertexStream
#pragma warning restore CA1819
{
get;
}
#pragma warning restore CA1819
{ get; }
public CoordinationBase Coordination
{
get;
}
public CoordinationBase Coordination { get; }
public int VertexCount
{
get;
}
public int VertexCount { get; }
public ReadOnlySpan<int> VertexIndices
{
get;
}
public ReadOnlySpan<int> VertexIndices { get; }
}
}
+17 -41
View File
@@ -43,53 +43,29 @@ namespace StgSharp.Geometries
public interface IInstancing
{
public float Rotation
{
get { return GlobalBuffer.CoordAndRotationList[ BufferId ].W; }
set
{
Vec4 temp = GlobalBuffer.CoordAndRotationList[ BufferId ];
temp.W = value;
GlobalBuffer.CoordAndRotationList[ BufferId ] = temp;
}
}
public float Rotation { get { return GlobalBuffer.CoordAndRotationList[ BufferId ].W; } set
{
Vec4 temp = GlobalBuffer.CoordAndRotationList[
BufferId ];
temp.W = value;
GlobalBuffer.CoordAndRotationList[
BufferId ] = temp;
} }
public float Scale
{
get { return GlobalBuffer.ScalingList[ BufferId ]; }
set { GlobalBuffer.ScalingList[ BufferId ] = value; }
}
public float Scale { get { return GlobalBuffer.ScalingList[ BufferId ]; } set { GlobalBuffer.ScalingList[
BufferId ] = value; } }
public GeometryMotion Motion
{
get;
set;
}
public GeometryMotion Motion { get; set; }
public IInstancingBuffer GlobalBuffer
{
get;
internal set;
}
public IInstancingBuffer GlobalBuffer { get; internal set; }
public int BufferId
{
get;
internal set;
}
public int BufferId { get; internal set; }
public Vec3 CenterPositionGlobal
{
get;
internal set;
}
public Vec3 CenterPositionGlobal { get; internal set; }
public Vec3 Coord
{
get { return GlobalBuffer.CoordAndRotationList[ BufferId ].XYZ; }
set { GlobalBuffer.CoordAndRotationList[ BufferId ] = new Vec4(
value.reg ); }
}
public Vec3 Coord { get { return GlobalBuffer.CoordAndRotationList[ BufferId ].XYZ; } set { GlobalBuffer.CoordAndRotationList[
BufferId ] = new Vec4(
value.reg ); } }
public void Move()
{
@@ -39,35 +39,17 @@ namespace StgSharp.Geometries
public interface IInstancingBuffer
{
public Span<Vec4> CoordAndRotationSpan
{
get;
}
public Span<Vec4> CoordAndRotationSpan { get; }
public Span<float> ScalingSpan
{
get;
}
public Span<float> ScalingSpan { get; }
internal IGeometry TypicalShape
{
get;
}
internal IGeometry TypicalShape { get; }
internal List<IInstancing> InstanceList
{
get;
}
internal List<IInstancing> InstanceList { get; }
internal List<Vec4> CoordAndRotationList
{
get;
}
internal List<Vec4> CoordAndRotationList { get; }
internal List<float> ScalingList
{
get;
}
internal List<float> ScalingList { get; }
}
}
@@ -47,14 +47,11 @@ namespace StgSharp.Geometries
internal Matrix32 axis;
/// <summary>
/// The _origin of this coordinate.
/// The _origin of this coordinate.
/// </summary>
public Vec3 origin;
public PartialPlainCoordinate(
Vec3 origin,
Vec3 horiziontial,
Vec3 vertical )
public PartialPlainCoordinate( Vec3 origin, Vec3 horiziontial, Vec3 vertical )
{
this.origin = origin;
axis = new Matrix32();
@@ -66,12 +63,12 @@ namespace StgSharp.Geometries
}
/// <summary>
/// The horizontial axis of the coordinate. Point to the right direction.
/// The horizontial axis of the coordinate. Point to the right direction.
/// </summary>
public Vec3 axis_H => axis.colum0;
/// <summary>
/// The vertical axis of the coordinate. Point to the top direction.
/// The vertical axis of the coordinate. Point to the top direction.
/// </summary>
public Vec3 axis_V => axis.colum1;
@@ -41,11 +41,7 @@ namespace StgSharp.Geometries
public interface IPlainEntity
{
public Vec2 CenterPosition
{
get;
set;
}
public Vec2 CenterPosition { get; set; }
public bool CollideWith( IPlainEntity entity );
@@ -53,29 +53,13 @@ namespace StgSharp.Geometries
( ( IInstancingBuffer )buffer ).InstanceList.Add( this );
}
public GeometryMotion Motion
{
get;
set;
}
public GeometryMotion Motion { get; set; }
public IInstancingBuffer GlobalBuffer
{
get;
set;
}
public IInstancingBuffer GlobalBuffer { get; set; }
public int BufferId
{
get;
set;
}
public int BufferId { get; set; }
Vec3 IInstancing.CenterPositionGlobal
{
get;
set;
}
Vec3 IInstancing.CenterPositionGlobal { get; set; }
bool IPlainEntity.CollideWith( IPlainEntity entity )
{
@@ -37,7 +37,7 @@ using System.ComponentModel;
namespace StgSharp.Geometries
{
/// <summary>
/// Plain geometry only contains straight sides.
/// Plain geometry only contains straight sides.
/// </summary>
public abstract class PlainGeometry : IGeometry
{
@@ -58,10 +58,7 @@ namespace StgSharp.Geometries
public int VertexCount => this.vertexMat.Length;
public abstract ReadOnlySpan<int> VertexIndices
{
get;
}
public abstract ReadOnlySpan<int> VertexIndices { get; }
#pragma warning disable CA1819
public Vec4[] VertexStream => vertexMat;
@@ -85,12 +85,12 @@ namespace StgSharp.Geometries
{
get
{
if( coordArray.Length != coordList.Capacity ) {
if( coordArray.Length != coordList.Capacity )
{
FieldInfo fieldInfo = typeof( List<Vec4> ).
GetField(
"_items",
BindingFlags.NonPublic | BindingFlags.Instance );
if( fieldInfo == null ) {
GetField( "_items", BindingFlags.NonPublic | BindingFlags.Instance );
if( fieldInfo == null )
{
#pragma warning disable CA1065
#pragma warning disable CA2201
throw new NullReferenceException();
@@ -107,12 +107,12 @@ namespace StgSharp.Geometries
{
get
{
if( scaleArray.Length != coordList.Capacity ) {
if( scaleArray.Length != coordList.Capacity )
{
FieldInfo fieldInfo = typeof( List<float> ).
GetField(
"_items",
BindingFlags.NonPublic | BindingFlags.Instance );
if( fieldInfo == null ) {
GetField( "_items", BindingFlags.NonPublic | BindingFlags.Instance );
if( fieldInfo == null )
{
#pragma warning disable CA1065
#pragma warning disable CA2201
throw new NullReferenceException();
@@ -167,8 +167,7 @@ namespace StgSharp.Geometries
temp.BufferId = instance.BufferId;
coordList[ instance.BufferId ] = coordList[ coordList.Count - 1 ];
scalingList[ instance.BufferId ] = scalingList[
scalingList.Count - 1 ];
scalingList[ instance.BufferId ] = scalingList[ scalingList.Count - 1 ];
instanceList.RemoveAt( instanceList.Count - 1 );
coordList.RemoveAt( coordList.Count - 1 );
@@ -185,7 +184,8 @@ namespace StgSharp.Geometries
protected virtual void Dispose( bool disposing )
{
if( !disposedValue ) {
if( !disposedValue )
{
if( disposing ) {
mutex.Dispose();
}
@@ -204,8 +204,7 @@ namespace StgSharp.Geometries
}
}
IGeometry IInstancingBuffer.TypicalShape => throw new NotImplementedException(
);
IGeometry IInstancingBuffer.TypicalShape => throw new NotImplementedException();
#region field of mem opt
@@ -28,7 +28,6 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Math;
using System;
@@ -44,18 +43,19 @@ namespace StgSharp.Geometries
internal Point center;
public Parallelogram(
float v0x,
float v0y,
float v1x,
float v1y,
float v2x,
float v2y,
float v3x,
float v3y )
float v0x,
float v0y,
float v1x,
float v1y,
float v2x,
float v2y,
float v3x,
float v3y )
: base( v0x, v0y, v1x, v1y, v2x, v2y, v3x, v3y )
{
#if DEBUG
if( this[ 0 ].Coord + this[ 2 ].Coord != this[ 1 ].Coord + this[ 3 ].Coord ) {
if( this[ 0 ].Coord + this[ 2 ].Coord != this[ 1 ].Coord + this[ 3 ].Coord )
{
InternalIO.InternalWriteLog(
"Init of geometry item failed, because four vertices cannot form a rectangle.",
LogType.Warning );
@@ -64,19 +64,20 @@ namespace StgSharp.Geometries
}
public Parallelogram(
PlainCoordinate coordination,
float v0x,
float v0y,
float v1x,
float v1y,
float v2x,
float v2y,
float v3x,
float v3y )
PlainCoordinate coordination,
float v0x,
float v0y,
float v1x,
float v1y,
float v2x,
float v2y,
float v3x,
float v3y )
: base( coordination, v0x, v0y, v1x, v1y, v2x, v2y, v3x, v3y )
{
#if DEBUG
if( this[ 0 ].Coord + this[ 2 ].Coord != this[ 1 ].Coord + this[ 3 ].Coord ) {
if( this[ 0 ].Coord + this[ 2 ].Coord != this[ 1 ].Coord + this[ 3 ].Coord )
{
InternalIO.InternalWriteLog(
"Init of geometry item failed, because four vertices cannot form a rectangle.",
LogType.Warning );
@@ -28,7 +28,6 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Math;
using System;
@@ -56,11 +55,7 @@ namespace StgSharp.Geometries
vertexMat = rawCoord;
}
public Polygon4(
Point topLeft,
Point topRight,
Point bottomRight,
Point bottomLeft )
public Polygon4( Point topLeft, Point topRight, Point bottomRight, Point bottomLeft )
: base( PlainCoordinate.StandardPlainCoordination )
{
this[ 0 ] = topLeft;
@@ -70,12 +65,12 @@ namespace StgSharp.Geometries
}
public Polygon4(
CoordinationBase coordinate,
PlainCoordinate coordination,
Point topLeft,
Point topRight,
Point bottomRight,
Point bottomLeft )
CoordinationBase coordinate,
PlainCoordinate coordination,
Point topLeft,
Point topRight,
Point bottomRight,
Point bottomLeft )
: base( coordinate )
{
this[ 0 ] = topLeft;
@@ -85,14 +80,14 @@ namespace StgSharp.Geometries
}
public Polygon4(
float v0x,
float v0y,
float v1x,
float v1y,
float v2x,
float v2y,
float v3x,
float v3y )
float v0x,
float v0y,
float v1x,
float v1y,
float v2x,
float v2y,
float v3x,
float v3y )
: base( PlainCoordinate.StandardPlainCoordination )
{
vertexMat = new Vec4[4];
@@ -104,15 +99,15 @@ namespace StgSharp.Geometries
}
public Polygon4(
PlainCoordinate coordination,
float v0x,
float v0y,
float v1x,
float v1y,
float v2x,
float v2y,
float v3x,
float v3y )
PlainCoordinate coordination,
float v0x,
float v0y,
float v1x,
float v1y,
float v2x,
float v2y,
float v3x,
float v3y )
: base( coordination )
{
vertexMat = new Vec4[4];
@@ -28,7 +28,6 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Math;
using System;
@@ -48,16 +47,16 @@ namespace StgSharp.Geometries
}
public Polygon5(
float v0x,
float v0y,
float v1x,
float v1y,
float v2x,
float v2y,
float v3x,
float v3y,
float v4x,
float v4y )
float v0x,
float v0y,
float v1x,
float v1y,
float v2x,
float v2y,
float v3x,
float v3y,
float v4x,
float v4y )
: base( PlainCoordinate.StandardPlainCoordination )
{
vertexMat = new Vec4[5];
@@ -69,17 +68,17 @@ namespace StgSharp.Geometries
}
public Polygon5(
PlainCoordinate coordination,
float v0x,
float v0y,
float v1x,
float v1y,
float v2x,
float v2y,
float v3x,
float v3y,
float v4x,
float v4y )
PlainCoordinate coordination,
float v0x,
float v0y,
float v1x,
float v1y,
float v2x,
float v2y,
float v3x,
float v3y,
float v4x,
float v4y )
: base( coordination )
{
vertexMat = new Vec4[5];
@@ -28,7 +28,6 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Math;
using System;
@@ -48,14 +47,14 @@ namespace StgSharp.Geometries
}
public Polygon6(
PlainCoordinate coordination,
Vec2 vert0,
Vec2 vert1,
Vec2 vert2,
Vec2 vert3,
Vec2 vert4,
Vec2 vert5,
Vec2 vert6 )
PlainCoordinate coordination,
Vec2 vert0,
Vec2 vert1,
Vec2 vert2,
Vec2 vert3,
Vec2 vert4,
Vec2 vert5,
Vec2 vert6 )
: base( coordination )
{
vertexMat = new Vec4[6];
@@ -39,14 +39,14 @@ namespace StgSharp.Geometries
{
public Rectangle(
float v0x,
float v0y,
float v1x,
float v1y,
float v2x,
float v2y,
float v3x,
float v3y )
float v0x,
float v0y,
float v1x,
float v1y,
float v2x,
float v2y,
float v3x,
float v3y )
: base( v0x, v0y, v1x, v1y, v2x, v2y, v3x, v3y )
{
#if DEBUG
@@ -59,15 +59,15 @@ namespace StgSharp.Geometries
}
public Rectangle(
PlainCoordinate coordination,
float v0x,
float v0y,
float v1x,
float v1y,
float v2x,
float v2y,
float v3x,
float v3y )
PlainCoordinate coordination,
float v0x,
float v0y,
float v1x,
float v1y,
float v2x,
float v2y,
float v3x,
float v3y )
: base( coordination, v0x, v0y, v1x, v1y, v2x, v2y, v3x, v3y )
{
#if DEBUG
@@ -80,10 +80,14 @@ namespace StgSharp.Geometries
}
/// <summary>
/// Calculate movement to center
/// Calculate movement to center
/// </summary>
/// <param _name="tick"> CurrentBlueprint time tick </param>
/// <returns></returns>
/// <param _label="tick">
/// CurrentPipeline time tick
/// </param>
/// <returns>
///
/// </returns>
public virtual Vec3 MovCenter( uint tick )
{
return default( Vec3 );

Some files were not shown because too many files have changed in this diff Show More