File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed
sources/ClangSharp.PInvokeGenerator
tests/ClangSharp.PInvokeGenerator.UnitTests Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ private void VisitBinaryOperator(BinaryOperator binaryOperator)
42
42
outputBuilder . Write ( binaryOperator . OpcodeStr ) ;
43
43
outputBuilder . Write ( ' ' ) ;
44
44
45
- if ( binaryOperator . IsShiftOp || binaryOperator . IsShiftAssignOp )
45
+ if ( ( binaryOperator . IsShiftOp || binaryOperator . IsShiftAssignOp ) && binaryOperator . RHS . Type . Kind != CXType_Int )
46
46
{
47
47
// RHS of shift operation in C# must be an int
48
48
outputBuilder . Write ( "(int)" ) ;
Original file line number Diff line number Diff line change @@ -284,7 +284,13 @@ public static partial class Methods
284
284
public Task UnsignedIntBitshiftTest ( )
285
285
{
286
286
var inputContents = @"#define LEFT 1 << 1U
287
- #define RIGHT 1 >> 1U" ;
287
+ #define RIGHT 1 >> 1U
288
+ #define INT 1 << 1
289
+ #define LONG 1 << 1L
290
+ #define LONGLONG 1 << 1LL
291
+ #define ULONG 1 << 1UL
292
+ #define ULONGLONG 1 << 1ULL
293
+ " ;
288
294
289
295
var expectedOutputContents = @"namespace ClangSharp.Test
290
296
{
@@ -295,6 +301,21 @@ public static partial class Methods
295
301
296
302
[NativeTypeName(""#define RIGHT 1 >> 1U"")]
297
303
public const int RIGHT = 1 >> (int)(1U);
304
+
305
+ [NativeTypeName(""#define INT 1 << 1"")]
306
+ public const int INT = 1 << 1;
307
+
308
+ [NativeTypeName(""#define LONG 1 << 1L"")]
309
+ public const int LONG = 1 << (int)(1);
310
+
311
+ [NativeTypeName(""#define LONGLONG 1 << 1LL"")]
312
+ public const int LONGLONG = 1 << (int)(1L);
313
+
314
+ [NativeTypeName(""#define ULONG 1 << 1UL"")]
315
+ public const int ULONG = 1 << (int)(1U);
316
+
317
+ [NativeTypeName(""#define ULONGLONG 1 << 1ULL"")]
318
+ public const int ULONGLONG = 1 << (int)(1UL);
298
319
}
299
320
}
300
321
" ;
You can’t perform that action at this time.
0 commit comments