feat update

This commit is contained in:
tqcq 2024-03-03 18:21:25 +08:00
parent 838e33df0b
commit e17ae812be
4 changed files with 29 additions and 8 deletions

View File

@ -9,13 +9,15 @@ CLASS(Test)
{ {
public: public:
META("Constructor") META("Constructor")
Test() : a_(0) {} Test() : b_(0), a_(0) {}
Test(int a) : a_(a) {} Test(int a) : b_(0), a_(a) {}
META("Test") META("Test")
int GetA() const { return a_; } int GetA() const { return a_; }
int kk(int, void *);
private: private:
struct Void {}; struct Void {};
@ -25,6 +27,7 @@ private:
int a; int a;
}; };
const int b_;
int a_; int a_;
}; };

View File

@ -19,6 +19,18 @@ public:
virtual bool ShouldGenerate() const { return !properties_.empty(); } virtual bool ShouldGenerate() const { return !properties_.empty(); }
bool IsPublic() const { return clang_getCXXAccessSpecifier(cursor_.handle()) == CX_CXXPublic; }
bool IsPrivate() const
{
return clang_getCXXAccessSpecifier(cursor_.handle()) == CX_CXXPrivate;
}
bool IsProtected() const
{
return clang_getCXXAccessSpecifier(cursor_.handle()) == CX_CXXProtected;
}
bool HasProperty(const std::string &property) const bool HasProperty(const std::string &property) const
{ {
return std::find(properties_.begin(), properties_.end(), property) != properties_.end(); return std::find(properties_.begin(), properties_.end(), property) != properties_.end();

View File

@ -11,11 +11,8 @@ Method::Method(const Cursor &cursor,
parent_(parent), parent_(parent),
return_type_(clang_getResultType(cursor.GetType().handle())) return_type_(clang_getResultType(cursor.GetType().handle()))
{ {
unsigned args_num = clang_Cursor_getNumArguments(cursor.handle()); for (unsigned i = 0; i < cursor.GetType().GetArgumentCount(); ++i) {
arguments_.push_back(cursor.GetType().GetArgument(i));
for (unsigned i = 0; i < args_num; ++i) {
Cursor arg = clang_Cursor_getArgument(cursor.handle(), i);
arguments_.push_back(arg.GetType());
} }
} }
@ -29,8 +26,16 @@ Method::ToString() const
ss << arguments_[i].GetDisplayName(); ss << arguments_[i].GetDisplayName();
if (i < arguments_.size() - 1) { ss << ", "; } if (i < arguments_.size() - 1) { ss << ", "; }
} }
// get function const
ss << ")"; ss << ")";
return ss.str() + " /*" + sled::StrJoin(properties(), ",") + "*/"; if (IsConst()) { ss << " const"; }
return ss.str() + " /*" + sled::StrJoin(properties(), ",") + "*/;";
} }
bool
Method::IsConst() const
{
return clang_CXXMethod_isConst(cursor_.handle());
};
}// namespace meta }// namespace meta

View File

@ -12,6 +12,7 @@ public:
std::string ToString() const override; std::string ToString() const override;
bool IsConst() const;
CursorType return_type() const; CursorType return_type() const;
CursorType argument(unsigned index) const; CursorType argument(unsigned index) const;
std::vector<CursorType> arguments() const; std::vector<CursorType> arguments() const;