Giter Club home page Giter Club logo

cppast.net's People

Contributors

amerkoleci avatar assumenothing avatar balazssomogyi avatar curioustama avatar daliziql avatar electrostar avatar fangfang1984 avatar kevingliewe avatar leafgarland avatar mugisoba avatar mvento3 avatar srxqds avatar stephenhodgson avatar wackoisgod avatar waldnercharles avatar xkein avatar xoofx avatar zombieyang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cppast.net's Issues

Expose statements as classes

If you plan to extend the project to .c/.cpp files too, i'd suggest to expose statements too
For instance, for an IfStatement , it would expose its Condition block, its IfTrue block and its Else

class IfStatement : Statement
{
    IfStatement(Block condition, Block trueCond, Block elseBlock) {
        this.condition = condition;
        this.trueCond = trueCond;
        this.elseBlock = trueCond;
    }

    public bool hasElse {get; set;};

    public Statement condition {get; set;};
    public Block trueCond {get; set;};
    public Block elseBlock {get; set;}; // null if not present
    
}

Something like this. Note that Block could be a Statement e.g. when we have a single statement IF (without brackets).

Parsing comments

Hi,

Do I have a way to parse the following comments:

int field; /* comment */

As I see such comment is ignored.

Thanks in advance,
Dennis.

Parsing function definitions from a windows header file

Hello

I am trying to print the functions names , their parameters and return value from some windows header files.
What is the correct way to do that?

This doesn't seem to work:

var options = new CppParserOptions().ConfigureForWindowsMsvc(); 
var compilation = CppParser.Parse(@"
#include <windows.h>
#include <processthreadsapi.h>
"
);
  foreach (var cppFunction in compilation2.Functions)
                Log(cppFunction.Name);

Thanks

NullReferenceException when parsing instantiation of a previously partially specialised template

Parsing the following code causes a NullReferenceException:

template<typename A, typename B>
struct foo {};

template<typename B>
struct foo<int, B> {};

foo<int, int> foobar;

CppModelBuilder.GetOrCreateDeclarationContainer doesn't handle ClassTemplatePartialSpecialization cursors. This causes it to return null, which later causes the exception when trying to create a declaration container for the instantiation.

new bugs regarding anonymous unions

Following my last issue i found another problem. (Thanks for that fix btw.)

struct VECTOR
{
  union
  {
    float fX;
    float fRho;
    float fR;
    float fH;
  };

  union
  {
    float fY;
    float fTheta;
    float fG;
    float fS;
  };

  union
  {
    float fZ;
    float fPhi;
    float fB;
    float fL;
    float fV;
  };
};

There are 3 fields in the CppClass object of the VECTOR struct, like expected. One for every anonymous union.
But only the first union gets recognized. All 3 fields have this union as type. The Classes member also only lists this one union, not the following two.

Infinite loop occurs when parentheses are included in a comment

I found an infinite loop on v0.7.0.

// [infinite loop)
void x() {}

If comments contain parentheses,
this loop cannot be escaped because parenCount has never become zero.

// CppModelBuilder.cs Line 2133
var parenCount = 1;
for (var lastBegin = begin; parenCount != 0; lastBegin = begin)
{
    if (TokenIsBefore(begin, "("))
        --parenCount;
    else if (TokenIsBefore(begin, ")"))
        ++parenCount;

    begin = GetPrevLocation(begin, 1);  // GetPrevLocation() returns CXSourceLocation.Null
}

wiki out-of-date?

I'd appreciate it for the project's informative and categorical documentations.
Unfortunately, some of the docs seem inaccurate.

CppAst.NET type-system gives a clarified description of the possible variants of CppTypes, but CppTemplateParameterType is not included.

I'd ask if the wiki is up-to-date, or anything else I'd take care if I use this project?

Attributes on line preceding the function are not parsed

I'm working with custom attributes for a serializer, and for readability purposes I'd like to have attributes on the line before the function the attribute is for, eg:

[[test::attr]]
void myFunc();

Unfortunately, CppAst cannot correctly identify the attribute in that case.

However, if I put the attribute on the same line:

[[test::attr]] void myFunc();

it works fine. As far as I know, the standard does allow the attributes to be before as per the former example. I'm not sure if this is an issue with CppAst or with libclang itself, but it would be great if attributes could be on the line before the function.

Typedef in different Namespace wrong

Hi there,

i encountered a bug where typedefs are not resolved properly when they are defined in another namespace:

Here is an minimal example:

namespace A
{
    typedef int (*a)(int b);
}
A::a c;

The Type of c will be resolved to int (*)()*. So naigther the typedef nor the parameters are getting the correct values.

how to check for exact CppType in the compilation?

Hello,

this seems like a newbie question however I can't seem to find a way to check for the exact CppType in any location.

suppose I have a function and the return type is "Unsigned int"

the function.ReturnType is CppType and that Cpptype is an abstract class that based on the type other classed implement it like CppPrimitiveType etc.

my question is that In the VS2019 debugger I can see that the "Kind" field is there however it's not public and I don't want to use reflection to get the value. how can I know which primitive type I'm dealing with? like how can I compare it with CppPrimitiveType members or CppPrimitiveKind members to see exactly what primitive that is?

CppParserOptions.ParseMacros null reference using windows headers

Hi,
I'm trying to parse windows headers (d3d11.h) in this case and if I set ParseMacros to true it crashes internally with NullReferenceException.

var sdkPath = @"C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um";
            var options = new CppParserOptions
            {
                ParseMacros = true,
            };
            options.SystemIncludeFolders.Add(sdkPath);
            var headerFile = "d3d11.h";
            var compilation = CppParser.ParseFile(Path.Combine(sdkPath, headerFile), options); /* Crash here */

StackTrace:

   at CppAst.CppModelBuilder.ParseMacro(CXCursor cursor)
   at CppAst.CppModelBuilder.VisitMember(CXCursor cursor, CXCursor parent, CXClientData data)
   at CppAst.CppModelBuilder.VisitTranslationUnit(CXCursor cursor, CXCursor parent, CXClientData data)
   at ClangSharp.clang.visitChildren(CXCursor parent, CXCursorVisitor visitor, CXClientData client_data)
   at CppAst.CppParser.ParseInternal(List`1 cppFiles, CppParserOptions options)
   at CppAst.CppParser.ParseFiles(List`1 cppFilenameList, CppParserOptions options)
   at CppAst.CppParser.ParseFile(String cppFilename, CppParserOptions options)
   at ConsoleApp2.Program.Main(String[] args) in C:\Test\Program.cs:line 45

Any thought?

GetCursorSpelling should return back CString not ToString()

The reason I don't like that the function uses ToString() is that it does not retain the casing on the cursor name. So if you have specific naming conventions on your code and you want to retain that convention post parse all the names of the decl will be lowercase because that is what ToString is doing.

If we don't want to change GetCursorSpelling to use the CString then we should at least have another field that retains the original name of the decl.

Getting comments from the side of a function

I have been testing this library for my raylib bindings.

I am processing a header and I am not sure how to get the comments that are to the side of a function. I can get them from a struct or enum but I also would like to get the spacing so I can line them up.

RLAPI void InitWindow(int width, int height, const char *title);  // Initialize window and OpenGL context
// Texture2D type
// NOTE: Data stored in GPU memory
typedef struct Texture2D {
    unsigned int id;        // OpenGL texture id
    int width;              // Texture base width
    int height;             // Texture base height
    int mipmaps;            // Mipmap levels, 1 by default
    int format;             // Data format (PixelFormat type)
} Texture2D;

I am not sure the best way to do this. Maybe if there is a way to get the full line from a function as a string then I can access the spacing and split the string to get the comment.

How to update CppAst to v0.12.0

I'm using SkiaSharpGenerator to generate P/Invoke API files, it depends on CppAst v0.8.0,
when I execute dotnet add package CppAst --version 0.12.0, nuget showing error below

error: NU1102: Unable to find package CppAst with version (>= 0.12.0)
error:   - Found 3 version(s) in dotnet-public [ Nearest version: 0.8.0 ]
error:   - Found 0 version(s) in dotnet-eng
error:   - Found 0 version(s) in dotnet6
error:   - Found 0 version(s) in dotnet7
error:   - Found 0 version(s) in dotnet8

I have no idea why 0.9.0 or later version not available?

clang_EnumDecl_isScoped not found

Hi,

after a long day, I finally managed to supply the right arguments for the MingW64 8.1.0 Include folders and try to parse a header based on that.

however I think the Enum parser is broken (all other parsers work fine) , and when the parser sees an enum i get this exception in the visual studio 2019 debugger :

System.EntryPointNotFoundException: 'Unable to find an entry point named 'clang_EnumDecl_isScoped' in DLL 'libclang'.'
in CppModelBuilder.cs line 1039:cppEnum.IsScoped = cursor.EnumDecl_IsScoped;

the same error is produced if I try the sample from the main page with an enum in it:

var compilation = CppParser.Parse(@"
enum MyEnum { MyEnum_0, MyEnum_1 };
void function0(int a, int b);
struct MyStruct { int field0; int field1;};
typedef MyStruct* MyStructPtr;
"
);

any ideas?

Support for extra/extended syntaxes?

I'm curious if this has built-in support for extended C++ syntaxes such as Microsoft's extras ... and are there any specific considerations that need to be made for things like C++/CLR, C++/Cx, C++/WinRT headers, etc? Any difficulties with quirky COM-related code in Win32 headers? Or does it just process all of it just fine?

I was actually about to end up having to write one of these myself, from scratch, but then decided to look here first and see if my favorite person to steal from already had a solution available to use and, as I'd hoped, you already had a whole AST system defined. Looks like ClangSharp is providing the back-end service for it, which is a project I'm very, very interested in but haven't had a chance to use yet. I've been working with CsWin32 and Win32Metadata a bit lately, but I'm definitely very interested in what ClangSharp can do and how it differs from those Microsoft projects. I've been gradually making a custom, lightweight .NET 7 interop wrapper for DirectX 11/12 and have been trying to explore alternative tools, libraries, etc that can benefit my work and add some value ...

[Q] `'stddef.h' file not found` error

I got 1 warning and 1 error as follow:

warning: argument unused during compilation: '-fsyntax-only'

error: 'stddef.h' file not found

Is this related to CppAst or should I install something else to fix the error?

Stack overflow in CppModelBuilder::GetOrCreateDeclarationContainer() after release 0.10.0

Hi! Thank you for this tool. We encountered some problems with the latest releases in our project.
Parsing code using any release after 0.10.0 results in stack overflow in CppModelBuilder::GetOrCreateDeclarationContainer().
The error occurs even when parsing the provided example code.

Here is our setup:
Platform Windows x64
TargetFramework net7.0
LLVM 17.0.2
ClangSharp 16.0.0
ClangSharp.Interop 16.0.0
libClangSharp 16.0.6
libClangSharp.runtime.win-x64 16.0.6
libclang.runtime.win-x64 16.0.6

You can try our setup yourself, you will find the CppParser.Parse in DB::Load()
GDExtensionTemplate_CppAsp.Net-Impl

My guess is that this is due to a version mismatch.

Error reporting

I am trying to parse a file and it fails with following error:

(412, 2): error: expected unqualified-id

Thing is file i am parsing is just 190 lines. Any idea why this could be happening and how could we get errors with accurate line numbers? My first thought was that preprocessor somehow inflates line numbers but that does not quite make sense to me..

Having trouble building...

I'm trying to build the project on Windows 7 with VS2017 or 2019 with a few issues.
First, on the CppAst project no a target framework is set, and the option is grayed out and can't be set anyway. So I created a new project using the original sources and .NET 4.7.2. There I added ClangSharp 3.8.0, libclang 9.0 etc. However, I get error messages such as:

  • Error CS1061 'CXCursor' does not contain a definition for 'Location'.
    So, thinking it was the wrong version of ClangSharp, I updated to v. 8.0.0 beta. With this version I get error messages like:
  • Error CS0246 The type or namespace name 'CXCursor' could not be found...
    since they seemed to have renamed "CXCursor" to "Cursor" in the new version.
    What version of ClangSharp are you using? It seems that neither version 3.8.0 or 8.0.0 of ClangSharp is compatible with the source code.

Issue parsing a class field which its type is a template class

Hi,
Consider the following code:
class TemplateTesterClass
{
public:
TestTemplate a;
TestNamespace::TestTemplate2 b;
};

Field 'a' is parsed correctly, its type is fully available by using the Type.GetDisplayName() I get "TestTemplate", from which I can extract the "int".
However in field 'b' the parser reacts differently and I get only "TestTemplate2" from the parser by using the Type.GetDisplayName().
The difference is TestTemplate2 is in a namespace named "TestNamespace".

The problem is the type "int" for field 'b' is not available from the parser.

How to get original parameter type and not an expanded typedef

Let's say I have the following code

template<class T>
class MyTemplateClass
{
    ....
};

typedef unsigned int MyInt;
typedef ::MyTemplateClass<char> MyCharClass;
typedef ::MyTemplateClass<::MyInt> MyMyIntClass;

class MyTestClass
{
    void TestMethod1(::MyInt param);
    void TestMethod2(::MyCharClass& param);
    void TestMethod3(::MyMyIntClass& param);
};

When I parse this, I get the following parameter information for the methods:
TestMethod1 -> param type is unsigned int
TestMethod2 -> param type is MyTemplateClass (wihtout the template arguments!)
TestMethod3 -> param type is MyTemplateClass (wihtout the template arguments!)

When I look at the C interface of clang, it seems that this is solved by using the canonical types, where the original (non-expanded type) is the actual type and holds a pointer to the underlying expanded type (not tested as I am writing C# code using this library).
However using this library, I am not able to get the original type as it is declared in the method signature.

I would like to know the original parameter type as it is written in the code and not the already expanded typedef. My parse configuration is as follows:

new CppParserOptions
{
    AutoSquashTypedef = false,
    ParseAsCpp = true,
    ParseAttributes = false,
    ParseComments = false,
    ParseMacros = true,
    ParseSystemIncludes = false,
    TargetCpu = CppTargetCpu.X86,
    TargetSystem = @"windows",
    TargetVendor = @"pc"
};

preserve order when auto-squashing typedefs

I'm using F# where the order of declaring functions, structs, etc somewhat matters. If I can, I'd like to preserve that order (coming from a C header). the auto-squashing type defs would be nice, but when I iterate through the parsed children ICppDeclaration s they are thrown in after all the squashed classes, causing the order to break.
Would this be an easy fix, or should I just turn off auto-squashing and parse the typedefs?

by the way, thanks for making this! it's saving me a lot of time.

STL1000: Unexpected compiler version, expected Clang 11.0.0 or newer.

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\yvals_core.h(551, 2): error: STL1000: Unexpected compiler version, expected Clang 11.0.0 or newer.

I have Visual Studio 2019 Version 16.11.2 installed and when I try to parse file with CppParser.ParseFiles, I am getting the above error.

I have both Visual Studio 2017 and also an older MSVC build tool (14.20.27508) installed but how do I make the library use these older versions? Is there a setting or configuration for the library that can be changed?

Installation guide?

Trying to use this library on Windows 10, getting the following error message:

Failed to resolve libClang or libClangSharp.
If you are running as a dotnet tool, you may need to manually copy the appropriate DLLs from NuGet due to limitations in the dotnet tool support.
System.DllNotFoundException: Unable to load DLL 'libclang' or one of its dependencies: The specified module could not be found. (0x8007007E)
   at ClangSharp.Interop.clang.createIndex(Int32 excludeDeclarationsFromPCH, Int32 displayDiagnostics)
   at CppAst.CppParser.ParseInternal(List`1 cppFiles, CppParserOptions options)
   at CppAst.CppParser.ParseFiles(List`1 cppFilenameList, CppParserOptions options)

I’m not running as a dotnet tool, using Visual Studio 2022 to run a console app based on .NET 6.0.
The libClang or libClangSharp packages didn’t help, same exception.

Eventually, I’ve solved by installing this package:
https://www.nuget.org/packages/ClangSharp/

Maybe you have forgot to add a dependency?

`#pragma once` gets ignored resulting in `error: redefinition of blah`

First off, awesome work on this! It's going to save me crazy amounts of time. Many thanks!

I'm running into an issue while trying to parse a library where the #pragma once is ignored and it results in duplicate struct/enum definitions due to multiple files including one other.

A simple example given these files passed to CppParser.ParseFiles:

matrix.h
vector.h
graphics.h -> includes matrix.h and vector.h

All the headers are protected by a #pragma once but this seems to get ignored and the types get added multiple times causing an error.

Is there any way around this behavior?

Can`t parse attributes defined by macro

I try to parse DirectX headers and parser doesn't handle uuid attribute if it is defined by macro:

MIDL_INTERFACE("9d06dffa-d1e5-4d07-83a8-1bb123f2f841")
ID3D11Device2 : public ID3D11Device1

As a workaround, replacing MIDL_INTERFACE by regex works and parser returns correct attributes

struct __declspec(uuid("9d06dffa-d1e5-4d07-83a8-1bb123f2f841")) __declspec(novtable)
ID3D11Device2 : public ID3D11Device1

Both ParseAttributes and ParseMacros are set to true

You can reproduce it if you replace input text in TestStructAttributes and enable macros parsing.

@"
#ifndef DECLSPEC_NOVTABLE
#if (_MSC_VER >= 1100) && defined(__cplusplus)
#define DECLSPEC_NOVTABLE __declspec(novtable)
#else
#define DECLSPEC_NOVTABLE
#endif
#endif

#ifndef DECLSPEC_UUID
#if (_MSC_VER >= 1100) && defined(__cplusplus)
#define DECLSPEC_UUID(x) __declspec(uuid(x))
#else
#define DECLSPEC_UUID(x)
#endif
#endif

#define MIDL_INTERFACE(x)   struct DECLSPEC_UUID(x) DECLSPEC_NOVTABLE

MIDL_INTERFACE(""9d06dffa-d1e5-4d07-83a8-1bb123f2f841"") Test{
    int a;
    int b;
};"

Try to parse Urho3D headers

I try to bind Urho3D header files and I got an error

Error: System.ArgumentException: 'An item with the same key has already been added. Key: c:@T@RPCNOTIFICATION_ROUTINE'

   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at CppAst.CppModelBuilder.VisitTypeDefDecl(CXCursor cursor, CXCursor parent, CXClientData data)
   at CppAst.CppModelBuilder.VisitMember(CXCursor cursor, CXCursor parent, CXClientData data)
   at CppAst.CppModelBuilder.VisitTranslationUnit(CXCursor cursor, CXCursor parent, CXClientData data)
   at ClangSharp.clang.visitChildren(CXCursor parent, CXCursorVisitor visitor, CXClientData client_data)
   at CppAst.CppParser.ParseInternal(List`1 cppFiles, CppParserOptions options)
   at CppAst.CppParser.ParseFiles(List`1 cppFilenameList, CppParserOptions options)
   at SimdJson.Program.Main(String[] args)

It's weird I can see in there is a checking before add new item to typedefs. I cannot understand why it's will be pass the checking duplicate item!
https://github.com/xoofx/CppAst/blob/0.3.0/src/CppAst/CppModelBuilder.cs#L1359

User-defined attributes?

Does this library supports parsing user-defined C++11 attributes? I was hoping to annotate some of my C++ code with them and generate C# bindings from classes with specific attributes. I just ran a quick test on my code and this library reports no attributes.

https://github.com/DethRaid/SanityEngine/blob/trunk/SanityEngine/src/sanity_engine.hpp#L21 is the class I'm trying to generate bindings for, https://github.com/DethRaid/SanityEngine/blob/trunk/SanityEngine.Codegen.NET/CodegenProgram.cs#L45 is where I'm checking for my attribute.

I've inspected the CppAst.ClassCompilation for my class in the Visual Studio debugger - there's no attributes, or really much of anything. Is there something that's making my class really hard to parse?

NullReferenceException in CppParser.ParseFile

I am trying to parse this file: https://github.com/lemire/simdjson/blob/master/singleheader/simdjson.h (simdjson single header). using the following code:

var cpo = new CppParserOptions();
cpo.ConfigureForWindowsMsvc(CppTargetCpu.X86_64); 
//btw, I'd made ConfigureForWindowsMsvc static + fluent interface :-) 
cpo.AdditionalArguments.Add("-std=c++17");
var compilation = CppParser.ParseFile(@"C:\prj\simdjson.h", cpo);

but getting an NRE.
The lib looks great! CppSharp is not that easy to use

how to get field position of anonymous struct/union?

struct operator 
{
    int type;
    union 
    {
        int intNum;
        float floatNum;
        double doubleNum;
    };
};

Taking this C snippet as an example. Is it possible to find out if the union is located after or before the "type" field?
The union is not listed as a field, which is understandable. But if I use the "Children" method of the parent struct, the union is listed before the "type" field.

can't work on macos?

on macos, I simple try to use CppParser.Parse. It always can't find some standard c++ header(for example the stdio.h).
whether specific parse options need to set?

CppParser.ParseFiles() functions differently when run during a pre-build event in VS19, but works normally elsewhere

I am developing a small preprocessor for a game engine that I am working on with some friends, and we are using CppAST.Net in the preprocessor to autogenerate some files for runtime reflection.

The development of the preprocessor was going well, until I tried to run it during a pre-build event in visual studio where it wouldn't parse all of the files that I gave it. When run from the debugger or from a local published version of the application the program generates the AST in 30-40 seconds, finds 19 classes, 4 of which have the reflectable attribute, and generates 4 files for each of those classes (16 in total). But when the application is run during a pre-build event it only takes 5-6 seconds, finds 8 classes (non of which are reflectable) and generates no files.

I have been testing and debugging for the last week and I am completely at a loss. If anyone has any ideas on what this could be any help would be appreciated.

Some of my suspicions that I have yet to be able to prove/disprove is that the VS19 build output cmd prompt may have some different env variables that prevent certain functions from being called or are blocking certain .Net libraries. I have also checked my output, and there are no errors to be found.

CppParameter doesn't expose default value

A small feature request:

#define DEFAULTMAXDEPTH 1024
bool allocateCapacity(size_t len, size_t maxdepth = DEFAULTMAXDEPTH);

Currently it's not possible to extract that default value for maxdepth = 1024

Empty field name for anonymous union with defined field name

Referencing my comment from the last issue: #66 (comment)

struct STRUCTURE
{
  unsigned long long u64GUID;
  unsigned long long u64OwnerGUID;
  unsigned int u32Flags;
  unsigned int u32RefCount;

  union
  {
    void* stLinkListNode;
    void* stTreeNode;
  } stStorage;

};

Although the union has a field named "stStorage" an unnamed field gets listed right before "stStorage" having the same union as field type.

There is a regression with the fix for that bug. As I would expect there is one field now instead of two. But this time I get an unnamed field instead of one named "stStorage".

`GetDisplayName ()` for the type parsed from `const char * const *` seems to be wrong

        let compilation =
            CppParser.Parse(
                """
#define TEST 1
int main (int argc, const char * const*argv) {
    return 0;
}
""",
                cppOpts
            )
        if compilation.HasErrors then
            failwithf $"compilation error: %A{compilation.Diagnostics}"
        printfn $"macros = %A{compilation.Macros}"
        printfn $"function = %A{compilation.Functions}"
        for fn in compilation.Functions do
            printfn $"name = %s{fn.Name}, return = %A{fn.ReturnType}"
            for param in fn.Parameters do
                printfn $"%s{param.Name}: %A{param.Type.TypeKind} %s{param.Type.GetDisplayName()}"

Prints following:

macros = seq [TEST = 1]
function = seq [int main(int argc, const const char** argv)]
name = main, return = int
argc: Primitive int
argv: Pointer const const char**

The argv should be printed as const char * const * but not.

Integer type sizes incorrectly handled on Linux

Some platforms define 8-byte types like uint64_t as unsigned long int and causes CppAst to return CppPrimitiveType objects with the wrong byte size. A possible fix would be something like:

// Old
case CXTypeKind.CXType_ULong:
    return CppPrimitiveType.UnsignedInt;

// New
case CXTypeKind.CXType_ULong:
    return type.SizeOf == 8 ? CppPrimitiveType.UnsignedLongLong : CppPrimitiveType.UnsignedInt;

private CppType GetCppTypeInternal(CXCursor cursor, CXType type, CXCursor parent, void* data)
{
switch (type.kind)
{
case CXTypeKind.CXType_Void:
return CppPrimitiveType.Void;
case CXTypeKind.CXType_Bool:
return CppPrimitiveType.Bool;
case CXTypeKind.CXType_UChar:
return CppPrimitiveType.UnsignedChar;
case CXTypeKind.CXType_UShort:
return CppPrimitiveType.UnsignedShort;
case CXTypeKind.CXType_UInt:
return CppPrimitiveType.UnsignedInt;
case CXTypeKind.CXType_ULong:
return CppPrimitiveType.UnsignedInt;
case CXTypeKind.CXType_ULongLong:
return CppPrimitiveType.UnsignedLongLong;

Should headerdoc comments be parsed when ParseComments is false?

I've noticed that headerdoc comments, (/*! MyComment */), get parsed even when ParseComments is set to false.
Is this expected behavior?

Test case to prove assertion:

ParseAssert(@"// This is a comment is ignored
int f0;

/*! This comment is parsed */
int f1;

/* This comment is ignored */
int f2;",
compilation => { ... },
new CppParserOptions { ParseComments = false });

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.