Skip to content

shpegun60/ClangPythonTest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Intro

I am going to use LibClang as it is independent of CLang versions, you can also use LibTooling

Need Modules

Links

LibClang

LibTooling

example.cpp

#include <iostream>
#include <string>

typedef int my_type_t;

// Example class with some member variables and functions
class ExampleClass {
	int userKurwa;
public:
    int publicVar;
private:
    float privateVar;
protected:
    std::string protectedVar;

public:
    ExampleClass() : publicVar(0), privateVar(0.0f), protectedVar("protected") {}
    ~ExampleClass() {}

    void publicFunction(int arg1, float arg2) {}
private:
    float privateFunction() { return 0.0f; }
protected:
    void protectedFunction() {}
};

// Example struct with some member variables and functions
struct ExampleStruct {
    int publicVar;
private:
    float privateVar;
protected:
    std::string protectedVar;

public:
    ExampleStruct() : publicVar(0), privateVar(0.0f), protectedVar("protected") {}
    ~ExampleStruct() {}

    void publicFunction(int arg1, float arg2) {}
private:
    float privateFunction() { return 0.0f; }
	ExampleStruct aaa;
	my_type_t bbbbb;
protected:
    void protectedFunction() {}
};

int ccccccc = 0;

int main() {
    ExampleClass obj1;
    ExampleStruct obj2;

    return 0;
}

Output

............................................
All classes and structures contained in
#include <iostream>
#include <string>
...........................................

---
Class: ExampleClass
  Attributes: ['userKurwa', 'publicVar', 'privateVar', 'protectedVar']
  Methods: ['publicFunction', 'privateFunction', 'protectedFunction']
  Bases: []
  Is Abstract: (False,)
---
Struct: ExampleStruct
  Attributes: ['publicVar', 'privateVar', 'protectedVar', 'aaa', 'bbbbb']
  Methods: ['publicFunction', 'privateFunction', 'protectedFunction']
  Bases: []
  Is Abstract: (False,)
---

About

Parsing C/C++ code using the Clang/LLVM compiler on Python

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published