File tree 2 files changed +10
-6
lines changed 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -362,11 +362,15 @@ impl Cursor {
362
362
363
363
/// Get the unsigned constant value for this cursor's enum variant referent.
364
364
///
365
- /// Returns `ULLONG_MAX` if the cursor's referent is not an enum variant,
366
- /// which is also a valid enum value, so callers should check the cursor
367
- /// kind before calling this method (see issue #128).
368
- pub fn enum_val_unsigned ( & self ) -> u64 {
369
- unsafe { clang_getEnumConstantDeclUnsignedValue ( self . x ) as u64 }
365
+ /// Returns None if the cursor's referent is not an enum variant.
366
+ pub fn enum_val_unsigned ( & self ) -> Option < u64 > {
367
+ unsafe {
368
+ if self . kind ( ) == CXCursor_EnumConstantDecl {
369
+ Some ( clang_getEnumConstantDeclUnsignedValue ( self . x ) as u64 )
370
+ } else {
371
+ None
372
+ }
373
+ }
370
374
}
371
375
372
376
/// Given that this cursor's referent is a `typedef`, get the `Type` that is
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ impl Enum {
75
75
let value = if is_signed {
76
76
cursor. enum_val_signed ( ) . map ( EnumVariantValue :: Signed )
77
77
} else {
78
- Some ( EnumVariantValue :: Unsigned ( cursor. enum_val_unsigned ( ) ) )
78
+ cursor. enum_val_unsigned ( ) . map ( EnumVariantValue :: Unsigned )
79
79
} ;
80
80
if let Some ( val) = value {
81
81
let name = cursor. spelling ( ) ;
You can’t perform that action at this time.
0 commit comments