git-svn-id: svn://db.shs.com.ru/pip@591 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2018-02-07 08:52:41 +00:00
parent beb23e5a50
commit 9a1c5deadd
175 changed files with 215 additions and 181 deletions

View File

@@ -1,7 +1,7 @@
/*
PIP - Platform Independent Primitives
C++ code info structs
Copyright (C) 2017 Ivan Pelipenko peri4ko@yandex.ru
Copyright (C) 2018 Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -4,7 +4,7 @@
/*
PIP - Platform Independent Primitives
C++ code info structs
Copyright (C) 2017 Ivan Pelipenko peri4ko@yandex.ru
Copyright (C) 2018 Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -40,10 +40,12 @@ enum TypeFlag {
};
typedef PIFlags<PICodeInfo::TypeFlag> TypeFlags;
typedef PIMap<PIString, PIString> MetaMap;
struct TypeInfo {
TypeInfo(const PIString & n = PIString(), const PIString & t = PIString(), PICodeInfo::TypeFlags f = 0, int b = -1) {name = n; type = t; flags = f; bits = b;}
const bool isBitfield() const {return bits > 0;}
MetaMap meta;
PIString name;
PIString type;
PICodeInfo::TypeFlags flags;
@@ -51,6 +53,7 @@ struct TypeInfo {
};
struct FunctionInfo {
MetaMap meta;
PIString name;
TypeInfo return_type;
PIVector<PICodeInfo::TypeInfo> arguments;
@@ -58,6 +61,7 @@ struct FunctionInfo {
struct ClassInfo {
ClassInfo() {has_name = true;}
MetaMap meta;
bool has_name;
PIString type;
PIString name;
@@ -69,6 +73,7 @@ struct ClassInfo {
struct EnumeratorInfo {
EnumeratorInfo(const PIString & n = PIString(), int v = 0) {name = n; value = v;}
MetaMap meta;
PIString name;
int value;
};
@@ -76,6 +81,7 @@ struct EnumeratorInfo {
struct EnumInfo {
PIString memberName(int value) const;
int memberValue(const PIString & name) const;
MetaMap meta;
PIString name;
PIVector<PICodeInfo::EnumeratorInfo> members;
};

View File

@@ -1,7 +1,7 @@
/*
PIP - Platform Independent Primitives
Module includes
Copyright (C) 2017 Ivan Pelipenko peri4ko@yandex.ru
Copyright (C) 2018 Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,7 +1,7 @@
/*
PIP - Platform Independent Primitives
C++ code parser
Copyright (C) 2017 Ivan Pelipenko peri4ko@yandex.ru
Copyright (C) 2018 Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -439,10 +439,10 @@ bool PICodeParser::parseEnum(Entity * parent, const PIString & name, PIString fc
vn = v; ind = v.find("=");
if (ind > 0) {cv = v.right(v.size_s() - ind - 1).toInt(); vn = v.left(ind);}
if (ind < 0) ++cv;
e.members << Enumerator(vn.trim(), cv);
e.members << EnumeratorInfo(vn.trim(), cv);
}
if (!e.members.isEmpty())
if (e.members.back().first.isEmpty())
if (e.members.back().name.isEmpty())
e.members.pop_back();
enums << e;
return true;
@@ -802,6 +802,7 @@ PIString PICodeParser::procMacros(PIString fc) {
if (line.left(1) == "#") {
mifcond = line.mid(1);
mif = mifcond.takeCWord();
//piCout << mif;
//piCout << "mif mifcond" << mif << mifcond << ifcnt;
if (skip || grab) {
if (mif.left(2) == "if") ifcnt++;
@@ -877,6 +878,8 @@ bool PICodeParser::parseDirective(PIString d) {
}
if (dname == "define") {
PIString mname = d.takeCWord();
//piCout << mname;
if (mname == "PIMETA") return true;
if (d.left(1) == "(") { // macro
PIStringList args = d.takeRange("(", ")").split(",").trim();
macros << Macro(mname, d.trim(), args);

View File

@@ -4,7 +4,7 @@
/*
PIP - Platform Independent Primitives
C++ code parser
Copyright (C) 2017 Ivan Pelipenko peri4ko@yandex.ru
Copyright (C) 2018 Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -48,8 +48,8 @@ public:
typedef PIFlags<Attribute> Attributes;
typedef PIPair<PIString, PIString> Define;
typedef PIPair<PIString, PIString> Typedef;
typedef PIPair<PIString, int> Enumerator;
typedef PIMap<PIString, PIString> MetaMap;
struct PIP_EXPORT Macro {
Macro(const PIString & n = PIString(), const PIString & v = PIString(), const PIStringList & a = PIStringList()) {
name = n;
@@ -71,6 +71,7 @@ public:
attributes = NoAttributes;
}
const bool isBitfield() const {return bits > 0;}
MetaMap meta;
PIString type;
PIString name;
PIStringList arguments_full;
@@ -90,6 +91,7 @@ public:
size = 0;
parent_scope = 0;
}
MetaMap meta;
PIString type;
PIString name;
PIString file;
@@ -103,13 +105,21 @@ public:
PIVector<Member> members;
PIVector<Typedef> typedefs;
};
struct PIP_EXPORT EnumeratorInfo {
EnumeratorInfo(const PIString & n = PIString(), int v = 0) {name = n; value = v;}
MetaMap meta;
PIString name;
int value;
};
struct PIP_EXPORT Enum {
Enum(const PIString & n = PIString()) {
name = n;
}
MetaMap meta;
PIString name;
PIVector<Enumerator> members;
PIVector<EnumeratorInfo> members;
};
void parseFile(const PIString & file, bool follow_includes = true);