From d213c8c3fcadadb05790a816a300da37e631e5d8 Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Fri, 9 Aug 2013 13:21:17 +0300 Subject: [PATCH 1/3] Changed the target .NET to 4.0 because the code does not make use of 4.5 features and this way it can be compiled with VS 2010. Signed-off-by: Dimitar Dobrev --- build/premake4.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/premake4.lua b/build/premake4.lua index dde68a41..58f37077 100644 --- a/build/premake4.lua +++ b/build/premake4.lua @@ -23,7 +23,7 @@ solution "CppSharp" flags { "Optimize" } configuration "vs2012" - framework "4.5" + framework "4.0" configuration {} From d526dda89545f4ae6b5faf9ce4f84a33c13a83b2 Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Fri, 9 Aug 2013 14:02:35 +0300 Subject: [PATCH 2/3] Replaced a range-based for to ensure VS C++ 2010 compliance. Signed-off-by: Dimitar Dobrev --- src/Parser/Parser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Parser/Parser.cpp b/src/Parser/Parser.cpp index 3bf549e6..219527d1 100644 --- a/src/Parser/Parser.cpp +++ b/src/Parser/Parser.cpp @@ -179,8 +179,8 @@ void Parser::SetupHeader() if (!Opts->NoBuiltinIncludes) { std::vector SystemDirs = GetWindowsSystemIncludeDirs(); - for(auto Path : SystemDirs) - HSOpts.AddPath(Path, frontend::System, /*IsFramework=*/false, + for(int i = 0; i < SystemDirs.size(); i++) + HSOpts.AddPath(SystemDirs[i], frontend::System, /*IsFramework=*/false, /*IgnoreSysRoot=*/false); } From 7f8494ca94b7e3f04b61ecacac1caa2fea0df9ca Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Sat, 10 Aug 2013 14:08:18 +0300 Subject: [PATCH 3/3] Added generation of function pointers. Signed-off-by: Dimitar Dobrev --- src/AST/Type.cs | 9 +++++++++ src/Generator/Generators/CSharp/CSharpTypePrinter.cs | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/AST/Type.cs b/src/AST/Type.cs index 13ac6969..321c7fbe 100644 --- a/src/AST/Type.cs +++ b/src/AST/Type.cs @@ -49,6 +49,9 @@ namespace CppSharp.AST public bool IsPointer() { + var functionPointer = this as MemberPointerType; + if (functionPointer != null) + return true; var pointer = this as PointerType; if (pointer == null) return false; @@ -77,6 +80,12 @@ namespace CppSharp.AST if (ptr == null) { + var functionPointer = this as MemberPointerType; + if (functionPointer != null) + { + type = functionPointer.Pointee as T; + return type != null; + } type = null; return false; } diff --git a/src/Generator/Generators/CSharp/CSharpTypePrinter.cs b/src/Generator/Generators/CSharp/CSharpTypePrinter.cs index 6395ea3f..83237d0c 100644 --- a/src/Generator/Generators/CSharp/CSharpTypePrinter.cs +++ b/src/Generator/Generators/CSharp/CSharpTypePrinter.cs @@ -191,7 +191,12 @@ namespace CppSharp.Generators.CSharp public CSharpTypePrinterResult VisitMemberPointerType(MemberPointerType member, 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,