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)
4242 outputBuilder . Write ( binaryOperator . OpcodeStr ) ;
4343 outputBuilder . Write ( ' ' ) ;
4444
45- if ( binaryOperator . IsShiftOp || binaryOperator . IsShiftAssignOp )
45+ if ( ( binaryOperator . IsShiftOp || binaryOperator . IsShiftAssignOp ) && binaryOperator . RHS . Type . Kind != CXType_Int )
4646 {
4747 // RHS of shift operation in C# must be an int
4848 outputBuilder . Write ( "(int)" ) ;
Original file line number Diff line number Diff line change @@ -284,7 +284,13 @@ public static partial class Methods
284284 public Task UnsignedIntBitshiftTest ( )
285285 {
286286 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+ " ;
288294
289295 var expectedOutputContents = @"namespace ClangSharp.Test
290296{
@@ -295,6 +301,21 @@ public static partial class Methods
295301
296302 [NativeTypeName(""#define RIGHT 1 >> 1U"")]
297303 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);
298319 }
299320}
300321" ;
You can’t perform that action at this time.
0 commit comments