Skip to content

Commit

Permalink
Fix jacob-carlborg#141: Improve type inference for macros, in particu…
Browse files Browse the repository at this point in the history
…lar handle type arguments.
  • Loading branch information
ciechowoj committed Oct 19, 2017
1 parent 1cc7bcf commit ea23fe9
Show file tree
Hide file tree
Showing 14 changed files with 1,100 additions and 395 deletions.
13 changes: 13 additions & 0 deletions clang/Compiler.d
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,16 @@ private:
return virtualPath_ = buildPath(root, uniform(1, 10_000_000).to!string);
}
}

string[] internalIncludeFlags()
{
import std.algorithm;
import std.array;

return Compiler.init.extraIncludePaths.map!(path => "-I" ~ path).array();
}

CXUnsavedFile[] internalHeaders()
{
return Compiler.init.extraHeaders();
}
16 changes: 15 additions & 1 deletion dstep/translator/Context.d
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ module dstep.translator.Context;

import clang.c.Index;
import clang.Cursor;
import clang.TranslationUnit;
import clang.Index;
import clang.SourceRange;
import clang.TranslationUnit;

import dstep.translator.CommentIndex;
import dstep.translator.IncludeHandler;
Expand Down Expand Up @@ -74,6 +75,19 @@ class Context
source = translUnit.source;
}

static Context fromString(string source, Options options = Options.init)
{
import clang.Compiler;

auto translationUnit = TranslationUnit.parseString(
Index(false, false),
source,
internalIncludeFlags(),
internalHeaders());

return new Context(translationUnit, options);
}

public string getAnonymousName (Cursor cursor)
{
if (auto name = cursor in anonymousNames)
Expand Down
Loading

0 comments on commit ea23fe9

Please sign in to comment.