Browse Source

Added string as a primitive type to the type system.

This will make it less hacky to represent proper strings in our AST model.
pull/778/head
Joao Matos 9 years ago
parent
commit
4a653b00bd
  1. 14
      src/AST/CppTypePrinter.cs
  2. 3
      src/AST/Type.cs
  3. 1
      src/Generator/Generators/CLI/CLITypePrinter.cs
  4. 1
      src/Generator/Generators/CSharp/CSharpTypePrinter.cs

14
src/AST/CppTypePrinter.cs

@ -142,6 +142,20 @@ namespace CppSharp.AST
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 PrintFlavorKind == CppTypePrintFlavorKind.Cpp ? "std::nullptr_t" : "NULL"; case PrimitiveType.Null: return PrintFlavorKind == CppTypePrintFlavorKind.Cpp ? "std::nullptr_t" : "NULL";
case PrimitiveType.String:
{
switch (PrintFlavorKind)
{
case CppTypePrintFlavorKind.C:
return "const char*";
case CppTypePrintFlavorKind.Cpp:
return "std::string";
case CppTypePrintFlavorKind.ObjC:
return "NSString";;
default:
throw new ArgumentOutOfRangeException();
}
}
} }
throw new NotSupportedException(); throw new NotSupportedException();

3
src/AST/Type.cs

@ -1132,7 +1132,8 @@ namespace CppSharp.AST
LongDouble, LongDouble,
Float128, Float128,
IntPtr, IntPtr,
UIntPtr UIntPtr,
String
} }
/// <summary> /// <summary>

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

@ -232,6 +232,7 @@ namespace CppSharp.Generators.CLI
case PrimitiveType.IntPtr: return "IntPtr"; case PrimitiveType.IntPtr: return "IntPtr";
case PrimitiveType.UIntPtr: return "UIntPtr"; case PrimitiveType.UIntPtr: return "UIntPtr";
case PrimitiveType.Null: return "void*"; case PrimitiveType.Null: return "void*";
case PrimitiveType.String: return "System::String";
} }
throw new NotSupportedException(); throw new NotSupportedException();

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

@ -558,6 +558,7 @@ namespace CppSharp.Generators.CSharp
case PrimitiveType.IntPtr: return IntPtrType; case PrimitiveType.IntPtr: return IntPtrType;
case PrimitiveType.UIntPtr: return "global::System.UIntPtr"; case PrimitiveType.UIntPtr: return "global::System.UIntPtr";
case PrimitiveType.Null: return "void*"; case PrimitiveType.Null: return "void*";
case PrimitiveType.String: return "string";
} }
throw new NotSupportedException(); throw new NotSupportedException();

Loading…
Cancel
Save