Skip to content

Commit d8a7fbe

Browse files
authored
Merge pull request #36 from canhorn/feature/update_ts_parser
New NodeJS AST Parser Implementation
2 parents 00f2a84 + 25d0cb5 commit d8a7fbe

File tree

122 files changed

+4040
-1664
lines changed

Some content is hidden

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

122 files changed

+4040
-1664
lines changed

.editorconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ charset = utf-8
1717
[*.{cs,vb}]
1818
# Organize usings
1919
dotnet_sort_system_directives_first = true
20+
# 'using' directive preferences
21+
csharp_using_directive_placement = inside_namespace:warning
2022
# this. preferences
2123
dotnet_style_qualification_for_field = false:silent
2224
dotnet_style_qualification_for_property = false:silent

.github/workflows/dotnet-core.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v2
16-
- name: Setup .NET Core
16+
- name: Setup .NET 5
1717
uses: actions/setup-dotnet@v1
1818
with:
19-
dotnet-version: '5.0.100-rc.2.20479.15'
19+
dotnet-version: '5.0.100'
20+
- name: Setup NodeJS
21+
uses: actions/setup-node@v2
22+
with:
23+
dotnet-version: '12'
2024
- name: Install dependencies
2125
run: dotnet restore
2226
- name: Build

.github/workflows/dotnet-package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ jobs:
2525
additionalArguments: '/updateAssemblyInfo'
2626
- run: |
2727
echo "NuGetVersionV2: ${{ steps.gitversion.outputs.NuGetVersionV2 }}"
28-
- name: Setup .NET Core
28+
- name: Setup .NET 5
2929
uses: actions/setup-dotnet@v1
3030
with:
31-
dotnet-version: '5.0.100-rc.2.20479.15'
31+
dotnet-version: '5.0.100'
3232
- name: Build with dotnet
3333
run: dotnet build --configuration Release
3434
- name: Pack with dotnet

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ ClientBin/
188188
*.dbproj.schemaview
189189
*.pfx
190190
*.publishsettings
191-
node_modules/
191+
**/node_modules/
192192
orleans.codegen.cs
193193

194194
# RIA/Silverlight projects

EventHorizon.Blazor.TypeScript.Interop.Generator.sln

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
66
ProjectSection(SolutionItems) = preProject
77
.editorconfig = .editorconfig
88
.gitignore = .gitignore
9+
Directory.Build.props = Directory.Build.props
910
.github\workflows\dotnet-core.yml = .github\workflows\dotnet-core.yml
1011
.github\workflows\dotnet-package.yml = .github\workflows\dotnet-package.yml
1112
.github\workflows\main-tag-bump.yml = .github\workflows\main-tag-bump.yml
@@ -28,7 +29,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EventHorizon.BabylonJS.Inte
2829
EndProject
2930
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tool", "Tool", "{C261DE2D-65FB-4616-B02A-5A7461C6D767}"
3031
EndProject
31-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventHorizon.Blazor.TypeScript.Interop.Tool", "Tool\EventHorizon.Blazor.TypeScript.Interop.Tool\EventHorizon.Blazor.TypeScript.Interop.Tool.csproj", "{5893EDD4-24E7-4260-9A43-EFF21EE23F97}"
32+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EventHorizon.Blazor.TypeScript.Interop.Tool", "Tool\EventHorizon.Blazor.TypeScript.Interop.Tool\EventHorizon.Blazor.TypeScript.Interop.Tool.csproj", "{5893EDD4-24E7-4260-9A43-EFF21EE23F97}"
3233
EndProject
3334
Global
3435
GlobalSection(SolutionConfigurationPlatforms) = preSolution

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ The interop project can be found in the [canhorn/EventHorizon.Blazor.Interop](ht
2626

2727
* [.NET Core](https://dotnet.microsoft.com/)
2828
* [TypeScript](https://www.typescriptlang.org/)
29+
* [NodeJS](https://nodejs.org/)
2930

3031
## Supported API's Generated
3132

Sample/EventHorizon.BabylonJS.Interop.Generator.ConsoleApp/Program.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ namespace EventHorizon.Blazor.TypeScript.Interop.Generator.ConsoleApp
1010
public class Program
1111
{
1212
static void Main(string[] args)
13+
{
14+
//Run(AstParser.Model.ASTParserType.NodeJS); // 75084ms/71877ms to generate.
15+
Run(AstParser.Model.ASTParserType.Sdcb); // 22027ms/19835ms/18236ms to generate.
16+
}
17+
static void Run(AstParser.Model.ASTParserType type)
1318
{
1419
var stopwatch = Stopwatch.StartNew();
1520
var projectAssembly = "EventHorizon.Blazor.BabylonJS.WASM";
@@ -29,11 +34,13 @@ static void Main(string[] args)
2934
);
3035
var sourceFiles = new List<string>
3136
{
37+
//"testing.d.ts",
3238
"babylon.d.ts",
3339
"babylon.gui.d.ts",
3440
};
3541
var generationList = new List<string>
3642
{
43+
//"Everything",
3744
"Scene",
3845
"VertexBuffer",
3946
"ICameraInput",
@@ -89,12 +96,12 @@ static void Main(string[] args)
8996
new Dictionary<string, string>
9097
{
9198
{ "BABYLON.PointerInfoBase | type", "int" }
92-
}
99+
},
100+
type
93101
);
94102
stopwatch.Stop();
95103
GlobalLogger.Info("Removed Generation Directory");
96104
GlobalLogger.Info($"Took {stopwatch.ElapsedMilliseconds}ms to generate.");
97-
98105
}
99106
}
100107
}
Lines changed: 95 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,97 @@
11

2-
export class Engine {
3-
constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
2+
declare module BABYLON.GUI {
3+
//export type Nullable<T> = T | null;
4+
//export type Vector3 = { x: number; };
5+
//export class AbstractMesh { }
6+
//export class Otherthing { }
7+
//export interface IDisposable { }
8+
//export interface IInterfaceResponseType { }
9+
//export enum EnumDeclaration { Value1 }
10+
11+
export class Everything<T> extends Otherthing implements IDisposable {
12+
//export class Everything<T> {
13+
// Static Accessors
14+
//static get Now(): number;
15+
//static get NowValues(): number[];
16+
//static get UNITMODE_PERCENTAGE(): number;
17+
//static get Up(): Vector3;
18+
//static get Downs(): Vector3[];
19+
20+
//// Static Properties
21+
//static readonly NoneLogLevel: number;
22+
//static readonly LogLevels: number[];
23+
//static readonly Vector3LogLevel: Vector3;
24+
//static readonly Vector3List: Vector3[];
25+
//static readonly Vector3Promise: Promise<Vector3>;
26+
27+
//// Static Methods
28+
//static makeObserverTopPriority(observer: Observer<T>): void; // No Return Type
29+
//// TODO: [ACTION_METHODS] : This is not supported, it is the ability to add a callback.
30+
//static OnNewCacheEntry: (entry: string) => void; // Action Type
31+
//static Identity(): Matrix2D; // Class
32+
//static Identitys(): Matrix2D[]; // Array Class
33+
//static numberArray(): number[]; // Array
34+
//static numberMethod(): number; // Primitive
35+
//static numberArrayObj(): Array<number>; // Array
36+
//static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
37+
//static get InterfaceResponseType(): IInterfaceResponseType;
38+
39+
//// Accessors
40+
//get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
41+
//get observers(): Array<Observer<T>>;
42+
//get texts(): string[];
43+
//get text(): string;
44+
//set text(value: string);
45+
//get style(): BABYLON.Nullable<Style>;
46+
//set style(value: BABYLON.Nullable<Style>);
47+
//get surroundingMeshes(): Nullable<AbstractMesh[]>;
48+
//set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
49+
50+
//// Properties
51+
//num: number;
52+
//width: string;
53+
//widths: string[];
54+
//height: Vector2;
55+
//matrix: Vector2[];
56+
//floatArrayExample: FloatArray;
57+
//float32ArrayExample: Float32Array;
58+
//indicesArrayExample: IndicesArray;
59+
//uint8ArrayExample: Uint8Array;
60+
//webkitURL: typeof URL;
61+
62+
//// Constructor
63+
//constructor(arg1: string,
64+
// arg2: Class1 | Class2,
65+
// arg3: number | undefined | null,
66+
// arg4?: number,
67+
// arg5?: Class3,
68+
// arg6?: { item: string; });
69+
70+
// Methods
71+
// Property that is a Method
72+
javaScriptApiFunctionClass: Function;
73+
//literalTypeArgument(literal: { prop1: string }): void;
74+
//isEqualsTo(other: Measure): boolean;
75+
//isBooleans(): boolean[];
76+
//Matrixices(): Vector2[];
77+
//TheMatrix(): Vector2;
78+
//makeObserverTopPriority(observer: Observer<T>): void;
79+
//add(callback: (eventData: T, eventState: EventState) => void,
80+
// mask?: number,
81+
// insertFirst?: boolean,
82+
// scope?: any,
83+
// unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
84+
//theOtherMatrix<D>(methodData: D, classData: T): Vector2;
85+
//promiseVoid(): Promise<void>;
86+
//nullableClassStyle(): Nullable<Style>;
87+
//nullableGenericNumber(): Nullable<number>;
88+
//orderNullArguments(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
89+
//literalTypesMethod(scene: { name: string }, animatables: Nullable<{ name: string }>, targetConverter?: Array<{ node: Node }>): Promise<{ name: string }>;
90+
//promiseTyped(): Promise<Array<Node>>;
91+
92+
//// modifiers
93+
//public publicProperty: string;
94+
//private privateProperty: string;
95+
//protected protectedProperty: string;
96+
}
497
}

Sample/_generated/EventHorizon.Blazor.BabylonJS.WASM/Tools.cs

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -246,27 +246,19 @@ public static CachedEntity CustomRequestHeaders
246246
}
247247
}
248248

249-
private static GetDOMTextContent __GetDOMTextContent;
250-
public static GetDOMTextContent GetDOMTextContent
249+
250+
public static string GetDOMTextContent
251251
{
252252
get
253253
{
254-
if(__GetDOMTextContent == null)
255-
{
256-
__GetDOMTextContent = EventHorizonBlazorInterop.GetClass<GetDOMTextContent>(
254+
return EventHorizonBlazorInterop.Get<string>(
257255
"BABYLON",
258-
"Tools.GetDOMTextContent",
259-
(entity) =>
260-
{
261-
return new GetDOMTextContent() { ___guid = entity.___guid };
262-
}
256+
"Tools.GetDOMTextContent"
263257
);
264258
}
265-
return __GetDOMTextContent;
266-
}
267259
set
268260
{
269-
__GetDOMTextContent = null;
261+
270262
EventHorizonBlazorInterop.Set(
271263
"BABYLON",
272264
"Tools.GetDOMTextContent",
@@ -335,27 +327,19 @@ public static decimal AllLogLevel
335327
}
336328
}
337329

338-
private static IsWindowObjectExist __IsWindowObjectExist;
339-
public static IsWindowObjectExist IsWindowObjectExist
330+
331+
public static bool IsWindowObjectExist
340332
{
341333
get
342334
{
343-
if(__IsWindowObjectExist == null)
344-
{
345-
__IsWindowObjectExist = EventHorizonBlazorInterop.GetClass<IsWindowObjectExist>(
335+
return EventHorizonBlazorInterop.Get<bool>(
346336
"BABYLON",
347-
"Tools.IsWindowObjectExist",
348-
(entity) =>
349-
{
350-
return new IsWindowObjectExist() { ___guid = entity.___guid };
351-
}
337+
"Tools.IsWindowObjectExist"
352338
);
353339
}
354-
return __IsWindowObjectExist;
355-
}
356340
set
357341
{
358-
__IsWindowObjectExist = null;
342+
359343
EventHorizonBlazorInterop.Set(
360344
"BABYLON",
361345
"Tools.IsWindowObjectExist",

Source/EventHorizon.Blazor.TypeScript.Interop.Generator.Model/GenerationIdentifiedTypes.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
51
namespace EventHorizon.Blazor.TypeScript.Interop.Generator.Model
62
{
73
public class GenerationIdentifiedTypes
@@ -23,5 +19,6 @@ public class GenerationIdentifiedTypes
2319
public const string Int = "int";
2420
public const string Float = "float";
2521
public const string Array = "Array";
22+
public const string TypeQuery = "TypeQuery";
2623
}
2724
}

0 commit comments

Comments
 (0)