Skip to content

Commit 234d46d

Browse files
committed
💥**breakChange**:rename to **CScripting**
1 parent 4b0ffdd commit 234d46d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1061
-927
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"type": "coreclr",
3333
"request": "launch",
3434
"preLaunchTask": "buildDemo",
35-
"program": "${workspaceFolder}/Python.SystemDemo/bin/Debug/net7.0-windows/Python.SystemDemo.exe",
35+
"program": "${workspaceFolder}/CScriptingDemo/bin/Debug/net7.0-windows/CScriptingDemo.exe",
3636
"requireExactSource": false,
3737
"args": [],
3838
"cwd": "${workspaceFolder}",

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"type": "shell",
2323
"args": [
2424
"build",
25-
"${workspaceFolder}/Python.SystemDemo/Python.SystemDemo.csproj",
25+
"${workspaceFolder}/CScriptingDemo/CScriptingDemo.csproj",
2626
// Ask dotnet build to generate full paths for file names.
2727
"/property:GenerateFullPaths=true",
2828
// Do not generate summary otherwise it leads to duplicate errors in Problems panel

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
nothing
44

55
## released
6+
- version: 0.0.0-preview2023-5-16
7+
- time: 2023年5月16日
8+
- log:
9+
1. 💥**breakChange**:rename to **CScripting**
610

711
- version: 1.0.5-pre
812
- time: 2023年5月14日

Python.System.Compare.py renamed to CScripting.Compare.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#r "nuget: Python.System, *"
1+
#r "nuget: CScripting, *"
22

33

44
addr = 0x12345678

Python.System.Demo.csx renamed to CScripting.Demo.csx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#r "nuget: Python.System, *"
2-
using static Python.System;
1+
#r "nuget: CScripting, *"
2+
using static CScripting;
33

44
var addr = 0x12345678;
55
var addrr = hex(addr);

Python.System.Demo.dib renamed to CScripting.Demo.dib

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
#!markdown
66

7-
## Python.System
7+
## CScripting
88

9-
demo of Python.System
9+
demo of CScripting
1010

1111
#!markdown
1212

@@ -15,15 +15,15 @@ demo of Python.System
1515

1616
#!csharp
1717

18-
#r "nuget: Python.System, *"
18+
#r "nuget: CScripting, *"
1919

2020
#!markdown
2121

22-
- using the static functions in `Python.System`
22+
- using the static functions in `CScripting`
2323

2424
#!csharp
2525

26-
using static Python.System;
26+
using static CScripting;
2727

2828
#!markdown
2929

CScripting.sln

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.5.33627.172
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CScripting", "CScripting\CScripting.csproj", "{9DF9921F-4A9E-4EE3-908D-2BCC79D24BE6}"
7+
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CScriptingDemo", "CScriptingDemo\CScriptingDemo.csproj", "{FFC71AD4-85B0-4050-8ED0-BAD84413CFA6}"
9+
EndProject
10+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CScriptingTests", "CScriptingTests\CScriptingTests.csproj", "{656D583E-E1A1-4127-86F4-F0A8265B2B03}"
11+
EndProject
12+
Global
13+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
14+
Debug|Any CPU = Debug|Any CPU
15+
Release|Any CPU = Release|Any CPU
16+
EndGlobalSection
17+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18+
{9DF9921F-4A9E-4EE3-908D-2BCC79D24BE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19+
{9DF9921F-4A9E-4EE3-908D-2BCC79D24BE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
20+
{9DF9921F-4A9E-4EE3-908D-2BCC79D24BE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
21+
{9DF9921F-4A9E-4EE3-908D-2BCC79D24BE6}.Release|Any CPU.Build.0 = Release|Any CPU
22+
{FFC71AD4-85B0-4050-8ED0-BAD84413CFA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{FFC71AD4-85B0-4050-8ED0-BAD84413CFA6}.Debug|Any CPU.Build.0 = Debug|Any CPU
24+
{FFC71AD4-85B0-4050-8ED0-BAD84413CFA6}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{FFC71AD4-85B0-4050-8ED0-BAD84413CFA6}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{656D583E-E1A1-4127-86F4-F0A8265B2B03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{656D583E-E1A1-4127-86F4-F0A8265B2B03}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{656D583E-E1A1-4127-86F4-F0A8265B2B03}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{656D583E-E1A1-4127-86F4-F0A8265B2B03}.Release|Any CPU.Build.0 = Release|Any CPU
30+
EndGlobalSection
31+
GlobalSection(SolutionProperties) = preSolution
32+
HideSolutionNode = FALSE
33+
EndGlobalSection
34+
GlobalSection(ExtensibilityGlobals) = postSolution
35+
SolutionGuid = {19598AB3-02E0-4316-A003-BDCAC338A7DA}
36+
EndGlobalSection
37+
EndGlobal

CScripting/Built-in/Matlab/fft.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Numerics;
4+
using System.Text;
5+
6+
#if WITH_NAME_SPACE
7+
namespace CScripting
8+
{
9+
#endif
10+
#if !MATLAB_NOT_IN_TOP_NAMESPACE
11+
public partial class CScripting
12+
{
13+
#endif
14+
public partial class matlab
15+
{
16+
public static Complex fft(object arg1, object arg2, object arg3)
17+
{
18+
19+
throw new NotImplementedException();
20+
}
21+
}
22+
#if !MATLAB_NOT_IN_TOP_NAMESPACE
23+
}
24+
#endif
25+
26+
27+
#if WITH_NAME_SPACE
28+
}
29+
#endif

CScripting/Built-in/Matlab/matlab.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Numerics;
3+
4+
public partial class CScripting
5+
{
6+
public partial class matlab
7+
{
8+
public static int[] linespace(int start, int end, int step = 1)
9+
{
10+
return new int[end - start];
11+
}
12+
}
13+
}

CScripting/Built-in/abs.cs

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
using System;
2+
using System.Numerics;
3+
4+
#if WITH_NAME_SPACE
5+
namespace CScripting
6+
{
7+
#endif
8+
9+
public partial class CScripting
10+
{
11+
#region abs
12+
//public const double e = Math.E;
13+
public const double pi = Math.PI;
14+
15+
/// <summary>
16+
/// 将复数转为绝对值
17+
/// </summary>
18+
/// <param name="num"></param>
19+
/// <returns></returns>
20+
public static double Abs(Complex num) => Abs(num.Magnitude);
21+
22+
/// <see cref=" Math.Abs"/>
23+
public static decimal Abs(decimal value) => Abs(value);
24+
25+
/// <see cref=" Math.Abs"/>
26+
public static double Abs(double value) => Abs(value);
27+
28+
/// <see cref=" Math.Abs"/>
29+
public static short Abs(short value) => Abs(value);
30+
31+
/// <see cref=" Math.Abs"/>
32+
public static int Abs(int value) => Abs(value);
33+
34+
/// <see cref=" Math.Abs"/>
35+
public static long Abs(long value) => Abs(value);
36+
37+
/// <see cref=" Math.Abs"/>
38+
public static sbyte Abs(sbyte value) => Abs(value);
39+
40+
/// <see cref=" Math.Abs"/>
41+
public static float Abs(float value) => Abs(value);
42+
43+
44+
45+
46+
47+
48+
49+
#if OBSOLETE
50+
[Obsolete("This method is deprecated, use `Abs` instead.")]
51+
#endif
52+
public static double abs(Complex num) => Math.Abs(num.Magnitude);
53+
54+
#if OBSOLETE
55+
[Obsolete("This method is deprecated, `using static System.Math;` and use `Abs` instead.")]
56+
#endif
57+
public static double abs(double num) => Math.Abs(num);
58+
59+
#if OBSOLETE
60+
[Obsolete("This method is deprecated, `using static System.Math;` and use `Abs` instead.")]
61+
#endif
62+
public static decimal abs(decimal num) => Math.Abs(num);
63+
64+
#if OBSOLETE
65+
[Obsolete("This method is deprecated, `using static System.Math;` and use `Abs` instead.")]
66+
#endif
67+
public static short abs(short num) => Math.Abs(num);
68+
69+
#if OBSOLETE
70+
[Obsolete("This method is deprecated, `using static System.Math;` and use `Abs` instead.")]
71+
#endif
72+
public static int abs(int num) => Math.Abs(num);
73+
#if OBSOLETE
74+
[Obsolete("This method is deprecated, `using static System.Math;` and use `Abs` instead.")]
75+
#endif
76+
public static long abs(long num) => Math.Abs(num);
77+
#if OBSOLETE
78+
[Obsolete("This method is deprecated, `using static System.Math;` and use `Abs` instead.")]
79+
#endif
80+
public static sbyte abs(sbyte num) => Math.Abs(num);
81+
82+
#if OBSOLETE
83+
[Obsolete("This method is deprecated, `using static System.Math;` and use `Abs` instead.")]
84+
#endif
85+
public static float abs(float num) => Math.Abs(num);
86+
87+
#endregion
88+
89+
}
90+
#if WITH_NAME_SPACE
91+
}
92+
#endif

CScripting/Built-in/all.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Numerics;
5+
6+
#if WITH_NAME_SPACE
7+
namespace CScripting
8+
{
9+
#endif
10+
11+
public partial class CScripting
12+
{
13+
#region all
14+
/// <summary>
15+
/// <see cref="Enumerable"/>
16+
/// </summary>
17+
/// <typeparam name="TSource"></typeparam>
18+
/// <param name="iterable"></param>
19+
/// <param name="predicate"></param>
20+
/// <returns></returns>
21+
public static bool All<TSource>(IEnumerable<TSource> iterable, Func<TSource, bool> predicate = null)
22+
=> All(iterable, predicate);
23+
24+
25+
26+
27+
28+
#if OBSOLETE
29+
[Obsolete("This method is deprecated, use `{nameof(All)}` instead.")]
30+
#endif
31+
public static bool all<TSource>(IEnumerable<TSource> iterable, Func<TSource, bool> predicate = null)
32+
{
33+
if (predicate == null)
34+
return iterable.All(a => Convert.ToBoolean(a));
35+
else
36+
return iterable.All(predicate);
37+
}
38+
39+
40+
#endregion
41+
42+
}
43+
#if WITH_NAME_SPACE
44+
}
45+
#endif

CScripting/Built-in/any.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Numerics;
5+
6+
#if WITH_NAME_SPACE
7+
namespace CScripting
8+
{
9+
#endif
10+
11+
public partial class CScripting
12+
{
13+
#region any
14+
/// <summary>
15+
/// <see cref="Enumerable"/>
16+
/// </summary>
17+
/// <typeparam name="TSource"></typeparam>
18+
/// <param name="iterable"></param>
19+
/// <param name="predicate"></param>
20+
/// <returns></returns>
21+
public static bool Any<TSource>(IEnumerable<TSource> iterable, Func<TSource, bool> predicate = null)
22+
=> Any(iterable, predicate);
23+
24+
25+
26+
27+
28+
#if OBSOLETE
29+
[Obsolete("This method is deprecated, use `{nameof(Any)}` instead.")]
30+
#endif
31+
public static bool any<TSource>(IEnumerable<TSource> iterable, Func<TSource, bool> predicate = null)
32+
{
33+
if (predicate == null)
34+
return iterable.Any();
35+
else
36+
return iterable.Any(predicate);
37+
}
38+
39+
#endregion
40+
41+
}
42+
#if WITH_NAME_SPACE
43+
}
44+
#endif

CScripting/Built-in/bin.cs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using System;
2+
3+
#if WITH_NAME_SPACE
4+
namespace CScripting
5+
{
6+
#endif
7+
8+
public partial class CScripting
9+
{
10+
#region bin
11+
12+
/// <summary>
13+
/// 将整形的数转为二进制
14+
/// </summary>
15+
/// <param name="x">整数</param>
16+
/// <param name="width">位宽,<see langword="null"/> 则不关注,如果转换结果大于位宽,则取位宽</param>
17+
/// <returns>二进制字符串</returns>
18+
public static string Bin(long x, int? width = null)
19+
=> Bin(x, width);
20+
21+
22+
23+
24+
25+
#if OBSOLETE
26+
[Obsolete("This method is deprecated, use `{nameof(bin)}` instead.")]
27+
#endif
28+
public static string bin(long x, int? width = null)
29+
{
30+
if (width == null || width <= 0)
31+
{
32+
return "0b" + Convert.ToString(x, 2);
33+
}
34+
else
35+
{
36+
string format = Convert.ToString(x, 2);
37+
if (format.Length < width)
38+
{
39+
string par = "";
40+
for (int c = 0; c < width - format.Length; c++)
41+
{
42+
par += "0";
43+
}
44+
return "0b" + par + format;
45+
}
46+
return "0b" + format;
47+
}
48+
}
49+
50+
#endregion
51+
}
52+
#if WITH_NAME_SPACE
53+
}
54+
#endif

0 commit comments

Comments
 (0)