diff --git a/source/dpp/runtime/options.d b/source/dpp/runtime/options.d index b81d9461..0a89a408 100644 --- a/source/dpp/runtime/options.d +++ b/source/dpp/runtime/options.d @@ -30,6 +30,7 @@ struct Options { bool hardFail; bool cppStdLib; bool ignoreMacros; + string[] ignoredMacros; bool detailedUntranslatable; string[] ignoredNamespaces; string[] ignoredCursors; @@ -125,6 +126,7 @@ struct Options { "hard-fail", "Translate nothing if any part fails", &hardFail, "c++-std-lib", "Link to the C++ standard library", &cppStdLib, "ignore-macros", "Ignore preprocessor macros", &ignoreMacros, + "ignore-specified-macros", "Ignore the specified preprocessor macros", &ignoredMacros, "ignore-ns", "Ignore a C++ namespace", &ignoredNamespaces, "ignore-cursor", "Ignore a C++ cursor", &ignoredCursors, "ignore-path", "Ignore a file path, note it globs so you will want to use *", &ignoredPaths, @@ -146,6 +148,7 @@ struct Options { ); clangOptions = map!(e => e.split(" "))(clangOptions).join(); + ignoredMacros = map!(e => e.split(","))(ignoredMacros).join(); if(helpInfo.helpWanted) { () @trusted { diff --git a/source/dpp/translation/macro_.d b/source/dpp/translation/macro_.d index c4d9e8f6..e7ac0f5c 100644 --- a/source/dpp/translation/macro_.d +++ b/source/dpp/translation/macro_.d @@ -15,9 +15,10 @@ string[] translateMacro(in from!"clang".Cursor cursor, // we want non-built-in macro definitions to be defined and then preprocessed // again - if(isBuiltinMacro(cursor)) return []; + if (context.options.ignoredMacros.canFind(cursor.spelling)) return []; + const tokens = cursor.tokens; // the only sane way for us to be able to see a macro definition