File tree Expand file tree Collapse file tree 5 files changed +49
-4
lines changed
src.kotlin/alphaTab/android/src/main/java/alphaTab/io Expand file tree Collapse file tree 5 files changed +49
-4
lines changed Original file line number Diff line number Diff line change @@ -1322,6 +1322,15 @@ export default class CSharpEmitterContext {
13221322 return true ;
13231323 }
13241324
1325+ // no casts to "object"
1326+ if (
1327+ 'objectFlags' in contextualType &&
1328+ 'intrinsicName' in contextualType &&
1329+ contextualType . intrinsicName === 'object'
1330+ ) {
1331+ return true ;
1332+ }
1333+
13251334 // some core types
13261335 if ( contextualType . symbol ) {
13271336 switch ( contextualType . symbol . name ) {
Original file line number Diff line number Diff line change @@ -1279,14 +1279,30 @@ export default class KotlinAstPrinter extends AstPrinterBase {
12791279
12801280 let hasDefault = false ;
12811281
1282- s . caseClauses . forEach ( c => {
1282+ for ( let i = 0 ; i < s . caseClauses . length ; i ++ ) {
1283+ const c = s . caseClauses [ i ] ;
12831284 if ( cs . isDefaultClause ( c ) ) {
12841285 hasDefault = true ;
12851286 this . writeDefaultClause ( c as cs . DefaultClause ) ;
12861287 } else {
1287- this . writeCaseClause ( c as cs . CaseClause ) ;
1288+ // avoid "value", "value2", else ->
1289+ // but write directly else ->
1290+ let hasNonElseStatement = false ;
1291+ for ( let j = i ; j < s . caseClauses . length ; j ++ ) {
1292+ const c2 = s . caseClauses [ j ] ;
1293+ if ( cs . isDefaultClause ( c2 ) ) {
1294+ break ;
1295+ } else if ( ( c2 as cs . CaseClause ) . statements . length > 0 ) {
1296+ hasNonElseStatement = true ;
1297+ break ;
1298+ }
1299+ }
1300+
1301+ if ( hasNonElseStatement ) {
1302+ this . writeCaseClause ( c as cs . CaseClause ) ;
1303+ }
12881304 }
1289- } ) ;
1305+ }
12901306
12911307 if ( ! hasDefault ) {
12921308 this . writeLine ( 'else -> { }' ) ;
Original file line number Diff line number Diff line change 11using System ;
2+ using System . Runtime . InteropServices ;
23
34namespace AlphaTab . Io ;
45
@@ -9,6 +10,16 @@ public static double BytesToFloat32LE(Uint8Array array)
910 return BitConverter . ToSingle ( array . Data . Array ! , array . Data . Offset ) ;
1011 }
1112
13+ public static Uint8Array Float32BEToBytes ( double v )
14+ {
15+ var bytes = BitConverter . GetBytes ( ( float ) v ) ;
16+ if ( BitConverter . IsLittleEndian )
17+ {
18+ bytes . Reverse ( ) ;
19+ }
20+ return new Uint8Array ( new ArrayBuffer ( bytes ) ) ;
21+ }
22+
1223 public static double BytesToFloat64LE ( Uint8Array array )
1324 {
1425 return BitConverter . ToDouble ( array . Data . Array ! , array . Data . Offset ) ;
Original file line number Diff line number Diff line change @@ -42,5 +42,13 @@ internal class TypeConversions {
4242 .order(java.nio.ByteOrder .LITTLE_ENDIAN )
4343 return buffer.getInt().toDouble()
4444 }
45+
46+ fun float32BEToBytes (v : Double ): Uint8Array {
47+ val buffer = ByteArray (4 );
48+ java.nio.ByteBuffer .wrap(buffer)
49+ .order(java.nio.ByteOrder .BIG_ENDIAN )
50+ .putFloat(v.toFloat());
51+ return Uint8Array (buffer.toUByteArray());
52+ }
4553 }
4654}
Original file line number Diff line number Diff line change @@ -275,7 +275,8 @@ export class BinaryStylesheet {
275275 case 'string' :
276276 return DataType . String ;
277277 case 'number' :
278- return ( value as number ) == ( ( value as number ) | 0 ) ? DataType . Integer : DataType . Float ;
278+ const withoutFraction : number = ( value as number ) | 0 ;
279+ return ( value as number ) == withoutFraction ? DataType . Integer : DataType . Float ;
279280 case 'object' :
280281 if ( value instanceof BendPoint ) {
281282 return DataType . Point ;
You can’t perform that action at this time.
0 commit comments