Skip to content

Commit

Permalink
💥**breakChange**:rename to **CScripting**
Browse files Browse the repository at this point in the history
  • Loading branch information
heartacker committed May 16, 2023
1 parent 4b0ffdd commit 234d46d
Show file tree
Hide file tree
Showing 52 changed files with 1,061 additions and 927 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"type": "coreclr",
"request": "launch",
"preLaunchTask": "buildDemo",
"program": "${workspaceFolder}/Python.SystemDemo/bin/Debug/net7.0-windows/Python.SystemDemo.exe",
"program": "${workspaceFolder}/CScriptingDemo/bin/Debug/net7.0-windows/CScriptingDemo.exe",
"requireExactSource": false,
"args": [],
"cwd": "${workspaceFolder}",
Expand Down
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"type": "shell",
"args": [
"build",
"${workspaceFolder}/Python.SystemDemo/Python.SystemDemo.csproj",
"${workspaceFolder}/CScriptingDemo/CScriptingDemo.csproj",
// Ask dotnet build to generate full paths for file names.
"/property:GenerateFullPaths=true",
// Do not generate summary otherwise it leads to duplicate errors in Problems panel
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
nothing

## released
- version: 0.0.0-preview2023-5-16
- time: 2023年5月16日
- log:
1. 💥**breakChange**:rename to **CScripting**

- version: 1.0.5-pre
- time: 2023年5月14日
Expand Down
2 changes: 1 addition & 1 deletion Python.System.Compare.py → CScripting.Compare.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#r "nuget: Python.System, *"
#r "nuget: CScripting, *"


addr = 0x12345678
Expand Down
4 changes: 2 additions & 2 deletions Python.System.Demo.csx → CScripting.Demo.csx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#r "nuget: Python.System, *"
using static Python.System;
#r "nuget: CScripting, *"
using static CScripting;

var addr = 0x12345678;
var addrr = hex(addr);
Expand Down
10 changes: 5 additions & 5 deletions Python.System.Demo.dib → CScripting.Demo.dib
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

#!markdown

## Python.System
## CScripting

demo of Python.System
demo of CScripting

#!markdown

Expand All @@ -15,15 +15,15 @@ demo of Python.System

#!csharp

#r "nuget: Python.System, *"
#r "nuget: CScripting, *"

#!markdown

- using the static functions in `Python.System`
- using the static functions in `CScripting`

#!csharp

using static Python.System;
using static CScripting;

#!markdown

Expand Down
37 changes: 37 additions & 0 deletions CScripting.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33627.172
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CScripting", "CScripting\CScripting.csproj", "{9DF9921F-4A9E-4EE3-908D-2BCC79D24BE6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CScriptingDemo", "CScriptingDemo\CScriptingDemo.csproj", "{FFC71AD4-85B0-4050-8ED0-BAD84413CFA6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CScriptingTests", "CScriptingTests\CScriptingTests.csproj", "{656D583E-E1A1-4127-86F4-F0A8265B2B03}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9DF9921F-4A9E-4EE3-908D-2BCC79D24BE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9DF9921F-4A9E-4EE3-908D-2BCC79D24BE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9DF9921F-4A9E-4EE3-908D-2BCC79D24BE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9DF9921F-4A9E-4EE3-908D-2BCC79D24BE6}.Release|Any CPU.Build.0 = Release|Any CPU
{FFC71AD4-85B0-4050-8ED0-BAD84413CFA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FFC71AD4-85B0-4050-8ED0-BAD84413CFA6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FFC71AD4-85B0-4050-8ED0-BAD84413CFA6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FFC71AD4-85B0-4050-8ED0-BAD84413CFA6}.Release|Any CPU.Build.0 = Release|Any CPU
{656D583E-E1A1-4127-86F4-F0A8265B2B03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{656D583E-E1A1-4127-86F4-F0A8265B2B03}.Debug|Any CPU.Build.0 = Debug|Any CPU
{656D583E-E1A1-4127-86F4-F0A8265B2B03}.Release|Any CPU.ActiveCfg = Release|Any CPU
{656D583E-E1A1-4127-86F4-F0A8265B2B03}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {19598AB3-02E0-4316-A003-BDCAC338A7DA}
EndGlobalSection
EndGlobal
29 changes: 29 additions & 0 deletions CScripting/Built-in/Matlab/fft.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Text;

#if WITH_NAME_SPACE
namespace CScripting
{
#endif
#if !MATLAB_NOT_IN_TOP_NAMESPACE
public partial class CScripting
{
#endif
public partial class matlab
{
public static Complex fft(object arg1, object arg2, object arg3)
{

throw new NotImplementedException();
}
}
#if !MATLAB_NOT_IN_TOP_NAMESPACE
}
#endif


#if WITH_NAME_SPACE
}
#endif
13 changes: 13 additions & 0 deletions CScripting/Built-in/Matlab/matlab.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Numerics;

public partial class CScripting
{
public partial class matlab
{
public static int[] linespace(int start, int end, int step = 1)
{
return new int[end - start];
}
}
}
92 changes: 92 additions & 0 deletions CScripting/Built-in/abs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
using System;
using System.Numerics;

#if WITH_NAME_SPACE
namespace CScripting
{
#endif

public partial class CScripting
{
#region abs
//public const double e = Math.E;
public const double pi = Math.PI;

/// <summary>
/// 将复数转为绝对值
/// </summary>
/// <param name="num"></param>
/// <returns></returns>
public static double Abs(Complex num) => Abs(num.Magnitude);

/// <see cref=" Math.Abs"/>
public static decimal Abs(decimal value) => Abs(value);

/// <see cref=" Math.Abs"/>
public static double Abs(double value) => Abs(value);

/// <see cref=" Math.Abs"/>
public static short Abs(short value) => Abs(value);

/// <see cref=" Math.Abs"/>
public static int Abs(int value) => Abs(value);

/// <see cref=" Math.Abs"/>
public static long Abs(long value) => Abs(value);

/// <see cref=" Math.Abs"/>
public static sbyte Abs(sbyte value) => Abs(value);

/// <see cref=" Math.Abs"/>
public static float Abs(float value) => Abs(value);







#if OBSOLETE
[Obsolete("This method is deprecated, use `Abs` instead.")]
#endif
public static double abs(Complex num) => Math.Abs(num.Magnitude);

#if OBSOLETE
[Obsolete("This method is deprecated, `using static System.Math;` and use `Abs` instead.")]
#endif
public static double abs(double num) => Math.Abs(num);

#if OBSOLETE
[Obsolete("This method is deprecated, `using static System.Math;` and use `Abs` instead.")]
#endif
public static decimal abs(decimal num) => Math.Abs(num);

#if OBSOLETE
[Obsolete("This method is deprecated, `using static System.Math;` and use `Abs` instead.")]
#endif
public static short abs(short num) => Math.Abs(num);

#if OBSOLETE
[Obsolete("This method is deprecated, `using static System.Math;` and use `Abs` instead.")]
#endif
public static int abs(int num) => Math.Abs(num);
#if OBSOLETE
[Obsolete("This method is deprecated, `using static System.Math;` and use `Abs` instead.")]
#endif
public static long abs(long num) => Math.Abs(num);
#if OBSOLETE
[Obsolete("This method is deprecated, `using static System.Math;` and use `Abs` instead.")]
#endif
public static sbyte abs(sbyte num) => Math.Abs(num);

#if OBSOLETE
[Obsolete("This method is deprecated, `using static System.Math;` and use `Abs` instead.")]
#endif
public static float abs(float num) => Math.Abs(num);

#endregion

}
#if WITH_NAME_SPACE
}
#endif
45 changes: 45 additions & 0 deletions CScripting/Built-in/all.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

#if WITH_NAME_SPACE
namespace CScripting
{
#endif

public partial class CScripting
{
#region all
/// <summary>
/// <see cref="Enumerable"/>
/// </summary>
/// <typeparam name="TSource"></typeparam>
/// <param name="iterable"></param>
/// <param name="predicate"></param>
/// <returns></returns>
public static bool All<TSource>(IEnumerable<TSource> iterable, Func<TSource, bool> predicate = null)
=> All(iterable, predicate);





#if OBSOLETE
[Obsolete("This method is deprecated, use `{nameof(All)}` instead.")]
#endif
public static bool all<TSource>(IEnumerable<TSource> iterable, Func<TSource, bool> predicate = null)
{
if (predicate == null)
return iterable.All(a => Convert.ToBoolean(a));
else
return iterable.All(predicate);
}


#endregion

}
#if WITH_NAME_SPACE
}
#endif
44 changes: 44 additions & 0 deletions CScripting/Built-in/any.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

#if WITH_NAME_SPACE
namespace CScripting
{
#endif

public partial class CScripting
{
#region any
/// <summary>
/// <see cref="Enumerable"/>
/// </summary>
/// <typeparam name="TSource"></typeparam>
/// <param name="iterable"></param>
/// <param name="predicate"></param>
/// <returns></returns>
public static bool Any<TSource>(IEnumerable<TSource> iterable, Func<TSource, bool> predicate = null)
=> Any(iterable, predicate);





#if OBSOLETE
[Obsolete("This method is deprecated, use `{nameof(Any)}` instead.")]
#endif
public static bool any<TSource>(IEnumerable<TSource> iterable, Func<TSource, bool> predicate = null)
{
if (predicate == null)
return iterable.Any();
else
return iterable.Any(predicate);
}

#endregion

}
#if WITH_NAME_SPACE
}
#endif
54 changes: 54 additions & 0 deletions CScripting/Built-in/bin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System;

#if WITH_NAME_SPACE
namespace CScripting
{
#endif

public partial class CScripting
{
#region bin

/// <summary>
/// 将整形的数转为二进制
/// </summary>
/// <param name="x">整数</param>
/// <param name="width">位宽,<see langword="null"/> 则不关注,如果转换结果大于位宽,则取位宽</param>
/// <returns>二进制字符串</returns>
public static string Bin(long x, int? width = null)
=> Bin(x, width);





#if OBSOLETE
[Obsolete("This method is deprecated, use `{nameof(bin)}` instead.")]
#endif
public static string bin(long x, int? width = null)
{
if (width == null || width <= 0)
{
return "0b" + Convert.ToString(x, 2);
}
else
{
string format = Convert.ToString(x, 2);
if (format.Length < width)
{
string par = "";
for (int c = 0; c < width - format.Length; c++)
{
par += "0";
}
return "0b" + par + format;
}
return "0b" + format;
}
}

#endregion
}
#if WITH_NAME_SPACE
}
#endif
Loading

0 comments on commit 234d46d

Please sign in to comment.