File tree 4 files changed +47
-3
lines changed
src.kotlin/alphaTab/android/src/main/java/alphaTab/io
4 files changed +47
-3
lines changed Original file line number Diff line number Diff line change @@ -1322,6 +1322,15 @@ export default class CSharpEmitterContext {
1322
1322
return true ;
1323
1323
}
1324
1324
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
+
1325
1334
// some core types
1326
1335
if ( contextualType . symbol ) {
1327
1336
switch ( contextualType . symbol . name ) {
Original file line number Diff line number Diff line change @@ -1279,14 +1279,30 @@ export default class KotlinAstPrinter extends AstPrinterBase {
1279
1279
1280
1280
let hasDefault = false ;
1281
1281
1282
- s . caseClauses . forEach ( c => {
1282
+ for ( let i = 0 ; i < s . caseClauses . length ; i ++ ) {
1283
+ const c = s . caseClauses [ i ] ;
1283
1284
if ( cs . isDefaultClause ( c ) ) {
1284
1285
hasDefault = true ;
1285
1286
this . writeDefaultClause ( c as cs . DefaultClause ) ;
1286
1287
} 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
+ }
1288
1304
}
1289
- } ) ;
1305
+ }
1290
1306
1291
1307
if ( ! hasDefault ) {
1292
1308
this . writeLine ( 'else -> { }' ) ;
Original file line number Diff line number Diff line change 1
1
using System ;
2
+ using System . Runtime . InteropServices ;
2
3
3
4
namespace AlphaTab . Io ;
4
5
@@ -9,6 +10,16 @@ public static double BytesToFloat32LE(Uint8Array array)
9
10
return BitConverter . ToSingle ( array . Data . Array ! , array . Data . Offset ) ;
10
11
}
11
12
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
+
12
23
public static double BytesToFloat64LE ( Uint8Array array )
13
24
{
14
25
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 {
42
42
.order(java.nio.ByteOrder .LITTLE_ENDIAN )
43
43
return buffer.getInt().toDouble()
44
44
}
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
+ }
45
53
}
46
54
}
You can’t perform that action at this time.
0 commit comments