Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
d081bda
Added strict json serialization for model for better performance
Danielku15 May 23, 2021
a380c4e
Generate all for loops again as while for better performance
Danielku15 May 23, 2021
f1df069
Restructured kotlin project
Danielku15 May 23, 2021
e7b7fcb
Added base android platform implementation
Danielku15 May 23, 2021
ccea10b
Added basic test app
Danielku15 May 23, 2021
dc7f848
Added strong typed lists and maps
Danielku15 May 24, 2021
c39c7c7
WIP custom primitive collections
Danielku15 May 28, 2021
7e12a3e
WIP using strong typed collection types for better perf
Danielku15 May 30, 2021
f842a22
Adjust C# compilation
Danielku15 May 30, 2021
fa7d380
Try to fix builds
Danielku15 May 31, 2021
97b0e73
Fix tests after map rework
Danielku15 May 31, 2021
0c2504f
Merge branch 'develop' into feature/android
Danielku15 Nov 7, 2021
abf8bd5
WIP
Danielku15 Nov 27, 2021
fe462e3
Merge branch 'develop' into feature/android
Danielku15 Dec 11, 2021
3998e43
Implement typed collections
Danielku15 Dec 11, 2021
91f3e6f
Custom collection implementations
Danielku15 Dec 16, 2021
b1f84e8
Share common map logic
Danielku15 Dec 17, 2021
c5e1e11
Fix scaling issues
Danielku15 Dec 17, 2021
3d18fc5
WIP
Danielku15 Dec 20, 2021
a8fda6c
Add override keywords
Danielku15 Dec 20, 2021
05d3e74
Optimized virtual/override generation
Danielku15 Dec 20, 2021
8fd3926
WIP
Danielku15 Dec 21, 2021
d956708
WIP binary serialization
Danielku15 Dec 22, 2021
85c205a
Added binary serialization
Danielku15 Dec 22, 2021
0455ec3
WIP fixing serializer
Danielku15 Dec 22, 2021
54e58e8
Fixed binary serializer
Danielku15 Dec 22, 2021
1e73649
Fixes for Kotlin
Danielku15 Dec 22, 2021
79a811e
Performance improvements
Danielku15 Dec 22, 2021
66358fa
WIP
Danielku15 Dec 24, 2021
5ba21a8
WIP perf improvements
Danielku15 Dec 24, 2021
47007b3
Remove binary serializer again
Danielku15 Dec 24, 2021
141f614
reorganize serialization
Danielku15 Dec 24, 2021
29aa73e
Optimized memory consumption by dynamic layout configuration and deco…
Danielku15 Dec 24, 2021
b2549b3
Cleanup work (#691)
Danielku15 Dec 29, 2021
b5bfdef
Add Lazy Rendering (#689)
Danielku15 Dec 29, 2021
7a6bb16
Fix compilation issues
Danielku15 Dec 29, 2021
5eb5c11
Try to use lazy rendering in android
Danielku15 Dec 29, 2021
bd65f87
Merge branch 'develop' into feature/android
Danielku15 Dec 29, 2021
97574ed
Minor fixes
Danielku15 Dec 29, 2021
a06774c
Merge branch 'develop' into feature/android
Danielku15 Dec 29, 2021
0e3ecb4
Cleanup from merge
Danielku15 Dec 29, 2021
ca9bd2c
Added missing files
Danielku15 Dec 29, 2021
19dd686
Build fixes and optimizations
Danielku15 Dec 29, 2021
1a8e13f
Adjust kotlin project structure
Danielku15 Dec 30, 2021
2e3ff25
Adjust tests
Danielku15 Dec 30, 2021
4471f70
Adjust tests
Danielku15 Dec 30, 2021
31a8874
Run tests using Skija, use custom map also for object-object map
Danielku15 Dec 30, 2021
2042df9
Add destruction operator
Danielku15 Dec 30, 2021
70a56ed
Workaround anacrusis start issue
Danielku15 Dec 30, 2021
82a4601
Fix negative double formatting
Danielku15 Dec 30, 2021
c49ec89
Some fixes and tests on control
Danielku15 Dec 30, 2021
17e1d1c
Start custom control to virtualize rendering
Danielku15 Dec 31, 2021
515ad09
Optimize rendering pipeline
Danielku15 Dec 31, 2021
ca17464
Added player and cursor support
Danielku15 Jan 5, 2022
16888fe
Precise cursor
Danielku15 Jan 7, 2022
08bf1bc
Animated cursor
Danielku15 Jan 7, 2022
e8b32d6
Interactivity WIP
Danielku15 Jan 9, 2022
9d5ba18
Ensure right type conversion
Danielku15 Jan 9, 2022
5b011e6
Adjust visibilities
Danielku15 Jan 9, 2022
364ac87
Unneeded using
Danielku15 Jan 9, 2022
ff1c399
Merge branch 'develop' into feature/android
Danielku15 Jan 20, 2022
6f437b3
Fix some syntax errors
Danielku15 Jan 20, 2022
5b7a596
Switch image for builds
Danielku15 Jan 20, 2022
87e32b7
Some optimizations on generated code
Danielku15 Jan 23, 2022
1012a6b
Merge branch 'develop' into feature/android
Danielku15 Jan 23, 2022
67b0259
Update deps
Danielku15 Jan 24, 2022
05a3b9f
Generate type arguments to bypass Kotlin type infer issue
Danielku15 Jan 26, 2022
1aea0a0
Merge branch 'develop' into feature/android
Danielku15 Jan 26, 2022
e5991f9
Infer generics for map initializer
Danielku15 Jan 26, 2022
dd9f48c
Test release version
Danielku15 Jan 26, 2022
3d65705
Adjust gradle props
Danielku15 Jan 26, 2022
6f46782
change cache key to drop old caches before improvements
Danielku15 Jan 26, 2022
25ef7f1
Increase RAM as GHA envs should have around 7GB available
Danielku15 Jan 26, 2022
e18a48c
Merge branch 'develop' into feature/android
Danielku15 Feb 12, 2022
a1d2ae6
Restructuring
Danielku15 Feb 12, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
build_web:
name: Build and Test Web
runs-on: windows-latest
runs-on: windows-2022
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
Expand All @@ -22,7 +22,7 @@ jobs:

build_csharp:
name: Build and Test C#
runs-on: windows-latest
runs-on: windows-2022
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
Expand All @@ -39,7 +39,7 @@ jobs:

build_kotlin:
name: Build and Test Kotlin
runs-on: windows-latest
runs-on: windows-2022
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
Expand All @@ -53,9 +53,9 @@ jobs:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-cache-${{ github.job }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
key: ${{ runner.os }}-gradle-cache-v2-${{ github.job }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-cache-${{ github.job }}-
${{ runner.os }}-gradle-cache-v2-${{ github.job }}-
- run: npm install
- run: npm run build-kotlin-ci
- run: npm run test-kotlin-ci
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
nighty_web:
name: Web
runs-on: windows-latest
runs-on: windows-2022
steps:
- name: Create cache file
run: |
Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:

nightly_csharp:
name: C#
runs-on: windows-latest
runs-on: windows-2022
steps:
- name: Create cache file
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
release_web:
name: Web
runs-on: windows-latest
runs-on: windows-2022
steps:
# Checkout the repo
- uses: actions/checkout@v2
Expand All @@ -32,7 +32,7 @@ jobs:

release_csharp:
name: C#
runs-on: windows-latest
runs-on: windows-2022
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ bin/
test-results/
debug.log
src/generated/VersionInfo.ts
src.kotlin/alphaTab/src/generated/

.gradle
build/
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@
"build-ci": "npm run clean && npm run build && npm pack",
"build-csharp": "npm run generate-csharp && cd src.csharp && dotnet build -c Release",
"build-csharp-ci": "npm run clean && npm run generate-csharp && cd src.csharp && dotnet build -c Release",
"build-kotlin": "npm run generate-kotlin && cd src.kotlin/alphaTab && gradlew assemble",
"build-kotlin-ci": "npm run clean && npm run generate-kotlin && cd src.kotlin/alphaTab && gradlew assemble",
"build-kotlin": "npm run generate-kotlin && cd src.kotlin/alphaTab && gradlew assembleRelease",
"build-kotlin-ci": "npm run clean && npm run generate-kotlin && cd src.kotlin/alphaTab && gradlew assembleRelease",
"start": "node scripts/setup-playground.js && npm run build && concurrently --kill-others \"tsc --project tsconfig.build.json --watch\" \"rollup -c rollup.config.js -w\"",
"test": "npm run generate-typescript && tsc --project tsconfig.json && concurrently --kill-others \"tsc --project tsconfig.json -w\" \"karma start karma.conf.js --browsers Chrome --no-single-run --reporters spec,kjhtml\"",
"test-ci": "npm run generate-typescript && tsc --project tsconfig.json && karma start karma.conf.js --browsers ChromeHeadless --single-run --reporters spec",
"test-csharp": "cd src.csharp && dotnet test",
"test-csharp-ci": "cd src.csharp && dotnet test",
"test-kotlin": "cd src.kotlin/alphaTab && gradlew jvmTest",
"test-kotlin-ci": "cd src.kotlin/alphaTab && gradlew jvmTest"
"test-csharp": "cd src.csharp && dotnet test -c Release",
"test-csharp-ci": "cd src.csharp && dotnet test -c Release",
"test-kotlin": "cd src.kotlin/alphaTab && gradlew testReleaseUnitTest",
"test-kotlin-ci": "cd src.kotlin/alphaTab && gradlew testReleaseUnitTest"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^21.0.1",
Expand Down
18 changes: 16 additions & 2 deletions src.compiler/AstPrinterBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,13 @@ export default abstract class AstPrinterBase {
}
}

protected writeCommaSeparated<T>(values: T[], write: (p: T) => void) {
protected writeCommaSeparated<T>(values: T[], write: (p: T) => void, newLine:boolean = false) {
values.forEach((v, i) => {
if (i > 0) {
this.write(', ');
if(newLine) {
this.writeLine();
}
}
write(v);
});
Expand Down Expand Up @@ -202,7 +205,18 @@ export default abstract class AstPrinterBase {
this.write('>');
}
this.write('(');
this.writeCommaSeparated(expr.arguments, a => this.writeExpression(a));
if (expr.arguments.length > 5) {
this.writeLine();
this._indent++;
this.writeCommaSeparated(expr.arguments, a => {
this.writeExpression(a);
this.writeLine();
}, true);
this._indent--;
this.writeLine();
} else {
this.writeCommaSeparated(expr.arguments, a => this.writeExpression(a));
}
this.write(')');
}

Expand Down
98 changes: 71 additions & 27 deletions src.compiler/csharp/CSharpAstTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,19 @@ export default class CSharpAstTransformer {
path.resolve(this._context.compilerOptions.baseUrl!),
path.resolve(this._typeScriptFile.fileName)
);
fileName = path.join(context.compilerOptions.outDir!, this.removeExtension(fileName) + this.extension);
fileName = this.buildFileName(fileName, context);

this._csharpFile = {
parent: null,
tsNode: this._typeScriptFile,
nodeType: cs.SyntaxKind.SourceFile,
fileName: fileName,
usings: [
{
namespaceOrTypeName: this._context.toPascalCase('system'),
nodeType: cs.SyntaxKind.UsingDeclaration
} as cs.UsingDeclaration,
{
namespaceOrTypeName:
this._context.toPascalCase('alphaTab') + '.' + this._context.toPascalCase('core'),
usings: this._context.getDefaultUsings().map(u => {
return {
namespaceOrTypeName: u,
nodeType: cs.SyntaxKind.UsingDeclaration
} as cs.UsingDeclaration
],
} as cs.UsingDeclaration;
}),
namespace: {
parent: null,
nodeType: cs.SyntaxKind.NamespaceDeclaration,
Expand All @@ -53,6 +48,10 @@ export default class CSharpAstTransformer {
this._csharpFile.namespace.parent = this._csharpFile;
}

protected buildFileName(fileName: string, context: CSharpEmitterContext): string {
return path.join(context.compilerOptions.outDir!, this.removeExtension(fileName) + this.extension);
}

public transform() {
// if the default export is a class:
// - global statements will be put into the static constructor of the class
Expand Down Expand Up @@ -336,7 +335,6 @@ export default class CSharpAstTransformer {
return 'csharp';
}


protected visitEnumDeclaration(node: ts.EnumDeclaration) {
const csEnum: cs.EnumDeclaration = {
visibility: cs.Visibility.Public,
Expand Down Expand Up @@ -427,7 +425,7 @@ export default class CSharpAstTransformer {
});
}

if(!csInterface.skipEmit){
if (!csInterface.skipEmit) {
node.members.forEach(m => this.visitInterfaceElement(csInterface, m));
}

Expand Down Expand Up @@ -999,7 +997,7 @@ export default class CSharpAstTransformer {
type: this.createUnresolvedTypeNode(null, classElement.type ?? classElement, returnType),
skipEmit: this.shouldSkip(classElement, false),
tsNode: classElement,
tsSymbol: this._context.getSymbolForDeclaration(classElement),
tsSymbol: this._context.getSymbolForDeclaration(classElement)
};

if (this._context.markOverride(classElement)) {
Expand Down Expand Up @@ -1071,7 +1069,7 @@ export default class CSharpAstTransformer {
type: this.createUnresolvedTypeNode(null, classElement.type ?? classElement, returnType),
skipEmit: this.shouldSkip(classElement, false),
tsNode: classElement,
tsSymbol: this._context.getSymbolForDeclaration(classElement),
tsSymbol: this._context.getSymbolForDeclaration(classElement)
};

if (this._context.markOverride(classElement)) {
Expand Down Expand Up @@ -1435,7 +1433,7 @@ export default class CSharpAstTransformer {
nodeType: cs.SyntaxKind.TypeReference,
parent: variableStatement,
tsNode: s,
reference: this._context.makeTypeName('system.Exception')
reference: this._context.makeExceptionType()
} as cs.TypeReference;
} else {
variableStatement.type = this.createUnresolvedTypeNode(variableStatement, s.type ?? s, type);
Expand Down Expand Up @@ -2821,8 +2819,40 @@ export default class CSharpAstTransformer {
}

protected visitArrayLiteralExpression(parent: cs.Node, expression: ts.ArrayLiteralExpression) {
if (this.isMapInitializer(expression)) {
if (this.isMapEntry(expression)) {
return this.createMapEntry(parent, expression);
} else if (this.isMapInitializer(expression)) {
const csExpr = {
parent: parent,
tsNode: expression,
nodeType: cs.SyntaxKind.InvocationExpression,
arguments: [],
expression: {} as cs.Expression
} as cs.InvocationExpression;

csExpr.expression = this.makeMemberAccess(
csExpr,
this._context.makeTypeName('alphaTab.core.TypeHelper'),
this._context.toPascalCase('mapInitializer')
);

expression.elements.forEach(e => {
const ex = this.visitExpression(csExpr, e);
if (ex) {
csExpr.arguments.push(ex);
}
});

// steal generic from inner element
if(csExpr.arguments.length > 0 &&
cs.isInvocationExpression(csExpr.arguments[0]) &&
cs.isTypeReference(csExpr.arguments[0].expression)) {
csExpr.typeArguments = [
csExpr.arguments[0].expression
];
}

return csExpr;
} else if (this.isSetInitializer(expression)) {
const csExpr = {
parent: parent,
Expand All @@ -2838,6 +2868,11 @@ export default class CSharpAstTransformer {
this._context.toPascalCase('setInitializer')
);

const setCreation = expression.parent as ts.NewExpression;
if (setCreation.typeArguments) {
csExpr.typeArguments = setCreation.typeArguments.map(t => this.createUnresolvedTypeNode(csExpr, t));
}

expression.elements.forEach(e => {
const ex = this.visitExpression(csExpr, e);
if (ex) {
Expand Down Expand Up @@ -2895,6 +2930,15 @@ export default class CSharpAstTransformer {
}

protected isMapInitializer(expression: ts.ArrayLiteralExpression) {
const isCandidate = expression.parent.kind === ts.SyntaxKind.NewExpression;
if (!isCandidate) {
return false;
}

return this._context.typeChecker.getTypeAtLocation(expression.parent).symbol.name === 'Map';
}

protected isMapEntry(expression: ts.ArrayLiteralExpression) {
const isCandidate =
expression.elements.length === 2 &&
expression.parent.kind === ts.SyntaxKind.ArrayLiteralExpression &&
Expand Down Expand Up @@ -3237,7 +3281,6 @@ export default class CSharpAstTransformer {
}
});


if (expression.typeArguments) {
callExpression.typeArguments = [];
expression.typeArguments.forEach(a =>
Expand Down Expand Up @@ -3271,14 +3314,6 @@ export default class CSharpAstTransformer {
} as cs.NewExpression;

newExpression.type.parent = newExpression;
if (expression.arguments) {
expression.arguments.forEach(a => {
const e = this.visitExpression(newExpression, a);
if (e) {
newExpression.arguments.push(e);
}
});
}

if (expression.typeArguments) {
csType.typeArguments = [];
Expand Down Expand Up @@ -3308,6 +3343,15 @@ export default class CSharpAstTransformer {
}
}

if (expression.arguments) {
expression.arguments.forEach(a => {
const e = this.visitExpression(newExpression, a);
if (e) {
newExpression.arguments.push(e);
}
});
}

if (type && type.symbol && type.symbol.name === 'ArrayConstructor' && newExpression.arguments.length === 1) {
newExpression.arguments[0] = this.makeInt(newExpression.arguments[0]);
}
Expand Down Expand Up @@ -3424,7 +3468,7 @@ export default class CSharpAstTransformer {
(node.tsSymbol.flags & ts.SymbolFlags.Variable) === ts.SymbolFlags.Variable ||
(node.tsSymbol.flags & ts.SymbolFlags.EnumMember) === ts.SymbolFlags.EnumMember ||
(node.tsSymbol.flags & ts.SymbolFlags.FunctionScopedVariable) ===
ts.SymbolFlags.FunctionScopedVariable ||
ts.SymbolFlags.FunctionScopedVariable ||
(node.tsSymbol.flags & ts.SymbolFlags.BlockScopedVariable) === ts.SymbolFlags.BlockScopedVariable
) {
let smartCastType = this._context.getSmartCastType(expression);
Expand Down
11 changes: 11 additions & 0 deletions src.compiler/csharp/CSharpEmitterContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,10 @@ export default class CSharpEmitterContext {
return null;
}

public makeExceptionType(): cs.TypeReferenceType {
return this.makeTypeName('system.Exception')
}

public makeTypeName(tsName: string): string {
const parts = tsName.split('.');
let result = '';
Expand Down Expand Up @@ -1490,4 +1494,11 @@ export default class CSharpEmitterContext {
}
return type.flags & ts.TypeFlags.String || type.flags & ts.TypeFlags.StringLiteral;
}

public getDefaultUsings(): string[] {
return [
this.toPascalCase('system'),
this.toPascalCase('alphaTab') + '.' + this.toPascalCase('core')
];
}
}
Loading