-
-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide option for parsing function bodies #95
Comments
Adding such an option would require also to parse the full content, handle all the syntax elements, create all the associated AST classes. Unfortunately, I don't want to support this as it would require a significant amount of work - and maintenance. |
If I'm not mistaken, if function body parsing was enabled, could I get this information from the generic |
I would believe that the visitor would still go through lots of nodes - and generate several warnings or errors along the way, but maybe be that could be fine, you will have to try. |
I conducted an inital test with the following code: [Test]
public void TestComplex()
{
ParseAssert(@"
#include <objc/runtime.h>
#define _NS_PRIVATE_SEL(accessor) (Private::Selector::s_k##accessor)
#define _NS_PRIVATE_DEF_SEL(accessor, symbol) extern SEL s_k##accessor
namespace Private
{
namespace Selector
{
_NS_PRIVATE_DEF_SEL(test,
""test"");
}
}
SEL method()
{
return _NS_PRIVATE_SEL(test);
}
",
compilation =>
{
Assert.False(compilation.HasErrors);
},
new CppParserOptions
{
SystemIncludeFolders =
{
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1",
"/Library/Developer/CommandLineTools/usr/lib/clang/15.0.0/include"
},
AdditionalArguments =
{
"-isysroot",
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk",
},
TargetCpu = CppTargetCpu.ARM64,
TargetSystem = "darwin",
TargetVendor = "apple",
ParseSystemIncludes = true,
ParseMacros = true
});
} It seemed to run without errors, with the only problem being that the method's contents are not available in the AST yet. But I think it might be possible. |
Hi there, I'm trying to use CppAst.NET to parse
metal-cpp
header files, which are a wrapper of the Objective-C API. The underlying Objective-C functions being called are contained within a macro within the function body.To generate valid C# code, I need to be able to access the string used to generate the selector inside the function bodies, however currently, function body parsing is disabled.
Could an option be added to enable function body parsing? I'm happy to PR it myself, however, I don't know what other modifications would be required.
The text was updated successfully, but these errors were encountered: