Browse Source

Merge pull request #24 from ddobrev/master

Generation of function pointers
pull/23/merge
João Matos 12 years ago
parent
commit
ae719c822b
  1. 2
      build/premake4.lua
  2. 9
      src/AST/Type.cs
  3. 7
      src/Generator/Generators/CSharp/CSharpTypePrinter.cs
  4. 4
      src/Parser/Parser.cpp

2
build/premake4.lua

@ -23,7 +23,7 @@ solution "CppSharp"
flags { "Optimize" } flags { "Optimize" }
configuration "vs2012" configuration "vs2012"
framework "4.5" framework "4.0"
configuration {} configuration {}

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,

4
src/Parser/Parser.cpp

@ -179,8 +179,8 @@ void Parser::SetupHeader()
if (!Opts->NoBuiltinIncludes) if (!Opts->NoBuiltinIncludes)
{ {
std::vector<std::string> SystemDirs = GetWindowsSystemIncludeDirs(); std::vector<std::string> SystemDirs = GetWindowsSystemIncludeDirs();
for(auto Path : SystemDirs) for(int i = 0; i < SystemDirs.size(); i++)
HSOpts.AddPath(Path, frontend::System, /*IsFramework=*/false, HSOpts.AddPath(SystemDirs[i], frontend::System, /*IsFramework=*/false,
/*IgnoreSysRoot=*/false); /*IgnoreSysRoot=*/false);
} }

Loading…
Cancel
Save