Browse Source

Added generation of function pointers.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/22/head
Dimitar Dobrev 12 years ago
parent
commit
7f8494ca94
  1. 9
      src/AST/Type.cs
  2. 7
      src/Generator/Generators/CSharp/CSharpTypePrinter.cs

9
src/AST/Type.cs

@ -49,6 +49,9 @@ namespace CppSharp.AST
public bool IsPointer() public bool IsPointer()
{ {
var functionPointer = this as MemberPointerType;
if (functionPointer != null)
return true;
var pointer = this as PointerType; var pointer = this as PointerType;
if (pointer == null) if (pointer == null)
return false; return false;
@ -77,6 +80,12 @@ namespace CppSharp.AST
if (ptr == null) if (ptr == null)
{ {
var functionPointer = this as MemberPointerType;
if (functionPointer != null)
{
type = functionPointer.Pointee as T;
return type != null;
}
type = null; type = null;
return false; return false;
} }

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

@ -191,7 +191,12 @@ namespace CppSharp.Generators.CSharp
public CSharpTypePrinterResult VisitMemberPointerType(MemberPointerType member, public CSharpTypePrinterResult VisitMemberPointerType(MemberPointerType member,
TypeQualifiers quals) TypeQualifiers quals)
{ {
throw new NotImplementedException(); FunctionType functionType;
if (member.IsPointerTo(out functionType))
{
return functionType.Visit(this, quals);
}
throw new InvalidOperationException("A function pointer not pointing to a function type.");
} }
public CSharpTypePrinterResult VisitBuiltinType(BuiltinType builtin, public CSharpTypePrinterResult VisitBuiltinType(BuiltinType builtin,

Loading…
Cancel
Save