Browse Source

Added support for missing basic Clang built-in types.

pull/685/head
Joao Matos 9 years ago
parent
commit
b7689b2d60
  1. 7
      src/AST/CppTypePrinter.cs
  2. 7
      src/AST/Type.cs
  3. 12
      src/Core/Parser/ASTConverter.cs
  4. 6
      src/CppParser/AST.h
  5. 30
      src/CppParser/Bindings/CLI/AST.h
  6. 30
      src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser.cs
  7. 30
      src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppSharp.CppParser.cs
  8. 30
      src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppSharp.CppParser.cs
  9. 30
      src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser.cs
  10. 30
      src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppSharp.CppParser.cs
  11. 30
      src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/CppSharp.CppParser.cs
  12. 8
      src/CppParser/Parser.cpp
  13. 1
      src/Generator/Generators/CLI/CLITypePrinter.cs
  14. 1
      src/Generator/Generators/CSharp/CSharpTypePrinter.cs

7
src/AST/CppTypePrinter.cs

@ -103,7 +103,8 @@ namespace CppSharp.AST
{ {
case PrimitiveType.Bool: return "bool"; case PrimitiveType.Bool: return "bool";
case PrimitiveType.Void: return "void"; case PrimitiveType.Void: return "void";
case PrimitiveType.Char16: case PrimitiveType.Char16: return "char16_t";
case PrimitiveType.Char32: return "char32_t";
case PrimitiveType.WideChar: return "wchar_t"; case PrimitiveType.WideChar: return "wchar_t";
case PrimitiveType.Char: return "char"; case PrimitiveType.Char: return "char";
case PrimitiveType.UChar: return "unsigned char"; case PrimitiveType.UChar: return "unsigned char";
@ -115,9 +116,13 @@ namespace CppSharp.AST
case PrimitiveType.ULong: return "unsigned long"; case PrimitiveType.ULong: return "unsigned long";
case PrimitiveType.LongLong: return "long long"; case PrimitiveType.LongLong: return "long long";
case PrimitiveType.ULongLong: return "unsigned long long"; case PrimitiveType.ULongLong: return "unsigned long long";
case PrimitiveType.Int128: return "__int128_t";
case PrimitiveType.UInt128: return "__uint128_t";
case PrimitiveType.Half: return "__fp16";
case PrimitiveType.Float: return "float"; case PrimitiveType.Float: return "float";
case PrimitiveType.Double: return "double"; case PrimitiveType.Double: return "double";
case PrimitiveType.LongDouble: return "long double"; case PrimitiveType.LongDouble: return "long double";
case PrimitiveType.Float128: return "__float128";
case PrimitiveType.IntPtr: return "void*"; case PrimitiveType.IntPtr: return "void*";
case PrimitiveType.UIntPtr: return "uintptr_t"; case PrimitiveType.UIntPtr: return "uintptr_t";
case PrimitiveType.Null: return "std::nullptr_t"; case PrimitiveType.Null: return "std::nullptr_t";

7
src/AST/Type.cs

@ -1015,6 +1015,8 @@ namespace CppSharp.AST
WideChar, WideChar,
Char, Char,
UChar, UChar,
Char16,
Char32,
Short, Short,
UShort, UShort,
Int, Int,
@ -1023,12 +1025,15 @@ namespace CppSharp.AST
ULong, ULong,
LongLong, LongLong,
ULongLong, ULongLong,
Int128,
UInt128,
Half,
Float, Float,
Double, Double,
LongDouble, LongDouble,
Float128,
IntPtr, IntPtr,
UIntPtr, UIntPtr,
Char16
} }
/// <summary> /// <summary>

12
src/Core/Parser/ASTConverter.cs

@ -673,6 +673,10 @@ namespace CppSharp
return AST.PrimitiveType.Char; return AST.PrimitiveType.Char;
case PrimitiveType.UChar: case PrimitiveType.UChar:
return AST.PrimitiveType.UChar; return AST.PrimitiveType.UChar;
case PrimitiveType.Char16:
return AST.PrimitiveType.Char16;
case PrimitiveType.Char32:
return AST.PrimitiveType.Char32;
case PrimitiveType.Short: case PrimitiveType.Short:
return AST.PrimitiveType.Short; return AST.PrimitiveType.Short;
case PrimitiveType.UShort: case PrimitiveType.UShort:
@ -689,12 +693,20 @@ namespace CppSharp
return AST.PrimitiveType.LongLong; return AST.PrimitiveType.LongLong;
case PrimitiveType.ULongLong: case PrimitiveType.ULongLong:
return AST.PrimitiveType.ULongLong; return AST.PrimitiveType.ULongLong;
case PrimitiveType.Int128:
return AST.PrimitiveType.Int128;
case PrimitiveType.UInt128:
return AST.PrimitiveType.UInt128;
case PrimitiveType.Half:
return AST.PrimitiveType.Half;
case PrimitiveType.Float: case PrimitiveType.Float:
return AST.PrimitiveType.Float; return AST.PrimitiveType.Float;
case PrimitiveType.Double: case PrimitiveType.Double:
return AST.PrimitiveType.Double; return AST.PrimitiveType.Double;
case PrimitiveType.LongDouble: case PrimitiveType.LongDouble:
return AST.PrimitiveType.LongDouble; return AST.PrimitiveType.LongDouble;
case PrimitiveType.Float128:
return AST.PrimitiveType.Float128;
case PrimitiveType.IntPtr: case PrimitiveType.IntPtr:
return AST.PrimitiveType.IntPtr; return AST.PrimitiveType.IntPtr;
default: default:

6
src/CppParser/AST.h

@ -258,6 +258,8 @@ enum class PrimitiveType
WideChar, WideChar,
Char, Char,
UChar, UChar,
Char16,
Char32,
Short, Short,
UShort, UShort,
Int, Int,
@ -266,9 +268,13 @@ enum class PrimitiveType
ULong, ULong,
LongLong, LongLong,
ULongLong, ULongLong,
Int128,
UInt128,
Half,
Float, Float,
Double, Double,
LongDouble, LongDouble,
Float128,
IntPtr IntPtr
}; };

30
src/CppParser/Bindings/CLI/AST.h

@ -330,18 +330,24 @@ namespace CppSharp
WideChar = 3, WideChar = 3,
Char = 4, Char = 4,
UChar = 5, UChar = 5,
Short = 6, Char16 = 6,
UShort = 7, Char32 = 7,
Int = 8, Short = 8,
UInt = 9, UShort = 9,
Long = 10, Int = 10,
ULong = 11, UInt = 11,
LongLong = 12, Long = 12,
ULongLong = 13, ULong = 13,
Float = 14, LongLong = 14,
Double = 15, ULongLong = 15,
LongDouble = 16, Int128 = 16,
IntPtr = 17 UInt128 = 17,
Half = 18,
Float = 19,
Double = 20,
LongDouble = 21,
Float128 = 22,
IntPtr = 23
}; };
public enum struct MacroLocation public enum struct MacroLocation

30
src/CppParser/Bindings/CSharp/i686-apple-darwin12.4.0/CppSharp.CppParser.cs

@ -225,18 +225,24 @@ namespace CppSharp
WideChar = 3, WideChar = 3,
Char = 4, Char = 4,
UChar = 5, UChar = 5,
Short = 6, Char16 = 6,
UShort = 7, Char32 = 7,
Int = 8, Short = 8,
UInt = 9, UShort = 9,
Long = 10, Int = 10,
ULong = 11, UInt = 11,
LongLong = 12, Long = 12,
ULongLong = 13, ULong = 13,
Float = 14, LongLong = 14,
Double = 15, ULongLong = 15,
LongDouble = 16, Int128 = 16,
IntPtr = 17 UInt128 = 17,
Half = 18,
Float = 19,
Double = 20,
LongDouble = 21,
Float128 = 22,
IntPtr = 23
} }
public enum MacroLocation public enum MacroLocation

30
src/CppParser/Bindings/CSharp/i686-pc-win32-msvc/CppSharp.CppParser.cs

@ -225,18 +225,24 @@ namespace CppSharp
WideChar = 3, WideChar = 3,
Char = 4, Char = 4,
UChar = 5, UChar = 5,
Short = 6, Char16 = 6,
UShort = 7, Char32 = 7,
Int = 8, Short = 8,
UInt = 9, UShort = 9,
Long = 10, Int = 10,
ULong = 11, UInt = 11,
LongLong = 12, Long = 12,
ULongLong = 13, ULong = 13,
Float = 14, LongLong = 14,
Double = 15, ULongLong = 15,
LongDouble = 16, Int128 = 16,
IntPtr = 17 UInt128 = 17,
Half = 18,
Float = 19,
Double = 20,
LongDouble = 21,
Float128 = 22,
IntPtr = 23
} }
public enum MacroLocation public enum MacroLocation

30
src/CppParser/Bindings/CSharp/x86_64-apple-darwin12.4.0/CppSharp.CppParser.cs

@ -225,18 +225,24 @@ namespace CppSharp
WideChar = 3, WideChar = 3,
Char = 4, Char = 4,
UChar = 5, UChar = 5,
Short = 6, Char16 = 6,
UShort = 7, Char32 = 7,
Int = 8, Short = 8,
UInt = 9, UShort = 9,
Long = 10, Int = 10,
ULong = 11, UInt = 11,
LongLong = 12, Long = 12,
ULongLong = 13, ULong = 13,
Float = 14, LongLong = 14,
Double = 15, ULongLong = 15,
LongDouble = 16, Int128 = 16,
IntPtr = 17 UInt128 = 17,
Half = 18,
Float = 19,
Double = 20,
LongDouble = 21,
Float128 = 22,
IntPtr = 23
} }
public enum MacroLocation public enum MacroLocation

30
src/CppParser/Bindings/CSharp/x86_64-linux-gnu-cxx11abi/CppSharp.CppParser.cs

@ -225,18 +225,24 @@ namespace CppSharp
WideChar = 3, WideChar = 3,
Char = 4, Char = 4,
UChar = 5, UChar = 5,
Short = 6, Char16 = 6,
UShort = 7, Char32 = 7,
Int = 8, Short = 8,
UInt = 9, UShort = 9,
Long = 10, Int = 10,
ULong = 11, UInt = 11,
LongLong = 12, Long = 12,
ULongLong = 13, ULong = 13,
Float = 14, LongLong = 14,
Double = 15, ULongLong = 15,
LongDouble = 16, Int128 = 16,
IntPtr = 17 UInt128 = 17,
Half = 18,
Float = 19,
Double = 20,
LongDouble = 21,
Float128 = 22,
IntPtr = 23
} }
public enum MacroLocation public enum MacroLocation

30
src/CppParser/Bindings/CSharp/x86_64-linux-gnu/CppSharp.CppParser.cs

@ -225,18 +225,24 @@ namespace CppSharp
WideChar = 3, WideChar = 3,
Char = 4, Char = 4,
UChar = 5, UChar = 5,
Short = 6, Char16 = 6,
UShort = 7, Char32 = 7,
Int = 8, Short = 8,
UInt = 9, UShort = 9,
Long = 10, Int = 10,
ULong = 11, UInt = 11,
LongLong = 12, Long = 12,
ULongLong = 13, ULong = 13,
Float = 14, LongLong = 14,
Double = 15, ULongLong = 15,
LongDouble = 16, Int128 = 16,
IntPtr = 17 UInt128 = 17,
Half = 18,
Float = 19,
Double = 20,
LongDouble = 21,
Float128 = 22,
IntPtr = 23
} }
public enum MacroLocation public enum MacroLocation

30
src/CppParser/Bindings/CSharp/x86_64-pc-win32-msvc/CppSharp.CppParser.cs

@ -225,18 +225,24 @@ namespace CppSharp
WideChar = 3, WideChar = 3,
Char = 4, Char = 4,
UChar = 5, UChar = 5,
Short = 6, Char16 = 6,
UShort = 7, Char32 = 7,
Int = 8, Short = 8,
UInt = 9, UShort = 9,
Long = 10, Int = 10,
ULong = 11, UInt = 11,
LongLong = 12, Long = 12,
ULongLong = 13, ULong = 13,
Float = 14, LongLong = 14,
Double = 15, ULongLong = 15,
LongDouble = 16, Int128 = 16,
IntPtr = 17 UInt128 = 17,
Half = 18,
Float = 19,
Double = 20,
LongDouble = 21,
Float128 = 22,
IntPtr = 23
} }
public enum MacroLocation public enum MacroLocation

8
src/CppParser/Parser.cpp

@ -1876,6 +1876,9 @@ static PrimitiveType WalkBuiltinType(const clang::BuiltinType* Builtin)
case clang::BuiltinType::WChar_S: case clang::BuiltinType::WChar_S:
case clang::BuiltinType::WChar_U: return PrimitiveType::WideChar; case clang::BuiltinType::WChar_U: return PrimitiveType::WideChar;
case clang::BuiltinType::Char16: return PrimitiveType::Char16;
case clang::BuiltinType::Char32: return PrimitiveType::Char32;
case clang::BuiltinType::Short: return PrimitiveType::Short; case clang::BuiltinType::Short: return PrimitiveType::Short;
case clang::BuiltinType::UShort: return PrimitiveType::UShort; case clang::BuiltinType::UShort: return PrimitiveType::UShort;
@ -1888,9 +1891,14 @@ static PrimitiveType WalkBuiltinType(const clang::BuiltinType* Builtin)
case clang::BuiltinType::LongLong: return PrimitiveType::LongLong; case clang::BuiltinType::LongLong: return PrimitiveType::LongLong;
case clang::BuiltinType::ULongLong: return PrimitiveType::ULongLong; case clang::BuiltinType::ULongLong: return PrimitiveType::ULongLong;
case clang::BuiltinType::Int128: return PrimitiveType::Int128;
case clang::BuiltinType::UInt128: return PrimitiveType::UInt128;
case clang::BuiltinType::Half: return PrimitiveType::Half;
case clang::BuiltinType::Float: return PrimitiveType::Float; case clang::BuiltinType::Float: return PrimitiveType::Float;
case clang::BuiltinType::Double: return PrimitiveType::Double; case clang::BuiltinType::Double: return PrimitiveType::Double;
case clang::BuiltinType::LongDouble: return PrimitiveType::LongDouble; case clang::BuiltinType::LongDouble: return PrimitiveType::LongDouble;
case clang::BuiltinType::Float128: return PrimitiveType::Half;
case clang::BuiltinType::NullPtr: return PrimitiveType::Null; case clang::BuiltinType::NullPtr: return PrimitiveType::Null;

1
src/Generator/Generators/CLI/CLITypePrinter.cs

@ -206,6 +206,7 @@ namespace CppSharp.Generators.CLI
case PrimitiveType.Bool: return "bool"; case PrimitiveType.Bool: return "bool";
case PrimitiveType.Void: return "void"; case PrimitiveType.Void: return "void";
case PrimitiveType.Char16: case PrimitiveType.Char16:
case PrimitiveType.Char32:
case PrimitiveType.WideChar: return "System::Char"; case PrimitiveType.WideChar: return "System::Char";
case PrimitiveType.Char: return Options.MarshalCharAsManagedChar ? "System::Char" : "char"; case PrimitiveType.Char: return Options.MarshalCharAsManagedChar ? "System::Char" : "char";
case PrimitiveType.UChar: return "unsigned char"; case PrimitiveType.UChar: return "unsigned char";

1
src/Generator/Generators/CSharp/CSharpTypePrinter.cs

@ -544,6 +544,7 @@ namespace CppSharp.Generators.CSharp
"byte" : "bool"; "byte" : "bool";
case PrimitiveType.Void: return "void"; case PrimitiveType.Void: return "void";
case PrimitiveType.Char16: case PrimitiveType.Char16:
case PrimitiveType.Char32:
case PrimitiveType.WideChar: return "char"; case PrimitiveType.WideChar: return "char";
case PrimitiveType.Char: case PrimitiveType.Char:
// returned structs must be blittable and char isn't // returned structs must be blittable and char isn't

Loading…
Cancel
Save