Browse Source

Sent a missed changed about reading the function type in the parser.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/816/head
Dimitar Dobrev 8 years ago
parent
commit
6d63508d3f
  1. 34
      src/AST/CppTypePrinter.cs
  2. 4
      src/CppParser/Parser.cpp

34
src/AST/CppTypePrinter.cs

@ -241,8 +241,36 @@ namespace CppSharp.AST @@ -241,8 +241,36 @@ namespace CppSharp.AST
{
if (type.Type == typeof(string))
return quals.IsConst ? "const char*" : "char*";
throw new NotImplementedException(string.Format("Unhandled .NET type: {0}", type.Type));
switch (System.Type.GetTypeCode(type.Type))
{
case TypeCode.Boolean:
return VisitBuiltinType(new BuiltinType(PrimitiveType.Bool), quals);
case TypeCode.Char:
case TypeCode.SByte:
case TypeCode.Byte:
return VisitBuiltinType(new BuiltinType(PrimitiveType.Char), quals);
case TypeCode.Int16:
return VisitBuiltinType(new BuiltinType(PrimitiveType.Short), quals);
case TypeCode.UInt16:
return VisitBuiltinType(new BuiltinType(PrimitiveType.UShort), quals);
case TypeCode.Int32:
return VisitBuiltinType(new BuiltinType(PrimitiveType.Int), quals);
case TypeCode.UInt32:
return VisitBuiltinType(new BuiltinType(PrimitiveType.UInt), quals);
case TypeCode.Int64:
return VisitBuiltinType(new BuiltinType(PrimitiveType.Long), quals);
case TypeCode.UInt64:
return VisitBuiltinType(new BuiltinType(PrimitiveType.ULong), quals);
case TypeCode.Single:
return VisitBuiltinType(new BuiltinType(PrimitiveType.Float), quals);
case TypeCode.Double:
return VisitBuiltinType(new BuiltinType(PrimitiveType.Double), quals);
case TypeCode.String:
return quals.IsConst ? "const char*" : "char*";
}
return "void*";
}
public virtual string VisitUnsupportedType(UnsupportedType type, TypeQualifiers quals)
@ -363,7 +391,7 @@ namespace CppSharp.AST @@ -363,7 +391,7 @@ namespace CppSharp.AST
public virtual string VisitMethodDecl(Method method)
{
// HACK: this should never happen but there's an inexplicable crash with the 32-bit Windows CI - I have no time to fix it right now
var functionType = method.FunctionType.Type as FunctionType;
var functionType = method.FunctionType.Type.Desugar() as FunctionType;
if (functionType == null)
return string.Empty;
var returnType = method.IsConstructor || method.IsDestructor ||

4
src/CppParser/Parser.cpp

@ -2923,7 +2923,11 @@ void Parser::WalkFunction(const clang::FunctionDecl* FD, Function* F, @@ -2923,7 +2923,11 @@ void Parser::WalkFunction(const clang::FunctionDecl* FD, Function* F,
HandlePreprocessedEntities(F, headRange, MacroLocation::FunctionHead);
HandlePreprocessedEntities(F, FTL.getParensRange(), MacroLocation::FunctionParameters);
}
else
F->qualifiedType = GetQualifiedType(FD->getType());
}
else
F->qualifiedType = GetQualifiedType(FD->getType());
F->returnType = GetQualifiedType(FD->getReturnType(), &RTL);

Loading…
Cancel
Save