version 3.13.2
This commit is contained in:
@@ -3,7 +3,7 @@ cmake_policy(SET CMP0017 NEW) # need include() with .cmake
|
|||||||
project(PIP)
|
project(PIP)
|
||||||
set(PIP_MAJOR 3)
|
set(PIP_MAJOR 3)
|
||||||
set(PIP_MINOR 13)
|
set(PIP_MINOR 13)
|
||||||
set(PIP_REVISION 1)
|
set(PIP_REVISION 2)
|
||||||
set(PIP_SUFFIX )
|
set(PIP_SUFFIX )
|
||||||
set(PIP_COMPANY SHS)
|
set(PIP_COMPANY SHS)
|
||||||
set(PIP_DOMAIN org.SHS)
|
set(PIP_DOMAIN org.SHS)
|
||||||
|
|||||||
@@ -323,7 +323,7 @@ void PICodeParser::clear() {
|
|||||||
<< "a2"
|
<< "a2"
|
||||||
<< "n2"
|
<< "n2"
|
||||||
<< "a3"
|
<< "a3"
|
||||||
<< "n3");
|
<< "n3");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -445,6 +445,7 @@ bool PICodeParser::parseFileContent(PIString & fc, bool main) {
|
|||||||
PIString prev_namespace = cur_namespace, ccmn;
|
PIString prev_namespace = cur_namespace, ccmn;
|
||||||
cur_namespace += pfc.takeCWord() + s_ns;
|
cur_namespace += pfc.takeCWord() + s_ns;
|
||||||
ccmn = pfc.takeRange('{', '}');
|
ccmn = pfc.takeRange('{', '}');
|
||||||
|
// piCout << "namespace" << cur_namespace;
|
||||||
parseClass(0, ccmn, true);
|
parseClass(0, ccmn, true);
|
||||||
cur_namespace = prev_namespace;
|
cur_namespace = prev_namespace;
|
||||||
continue;
|
continue;
|
||||||
@@ -462,12 +463,15 @@ bool PICodeParser::parseFileContent(PIString & fc, bool main) {
|
|||||||
}
|
}
|
||||||
if (pfc.left(5) == s_class || pfc.left(6) == s_struct || pfc.left(5) == s_union) {
|
if (pfc.left(5) == s_class || pfc.left(6) == s_struct || pfc.left(5) == s_union) {
|
||||||
int dind = pfc.find('{', 0), find = pfc.find(';', 0);
|
int dind = pfc.find('{', 0), find = pfc.find(';', 0);
|
||||||
|
// piCout << pfc.left(6) << dind << find;
|
||||||
if (dind < 0 && find < 0) {
|
if (dind < 0 && find < 0) {
|
||||||
pfc.cutLeft(6);
|
pfc.cutLeft(6);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (dind < 0 || find < dind) {
|
if (dind < 0 || find < dind) {
|
||||||
pfc.cutLeft(6);
|
// piCout << "skip FC" << (find + 1) << pfc.left(find + 1);
|
||||||
|
pfc.cutLeft(find + 1);
|
||||||
|
// pfc.cutLeft(6);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ccmn = pfc.left(dind) + s_bo + pfc.mid(dind).takeRange('{', '}') + s_bc;
|
ccmn = pfc.left(dind) + s_bo + pfc.mid(dind).takeRange('{', '}') + s_bc;
|
||||||
@@ -557,7 +561,7 @@ PICodeParser::Entity * PICodeParser::parseClassDeclaration(const PIString & fc)
|
|||||||
bool has_name = !cn.isEmpty();
|
bool has_name = !cn.isEmpty();
|
||||||
if (cn.isEmpty()) cn = PIStringAscii("<unnamed_") + PIString::fromNumber(anon_num++) + '>';
|
if (cn.isEmpty()) cn = PIStringAscii("<unnamed_") + PIString::fromNumber(anon_num++) + '>';
|
||||||
// piCout << "found " << typename_ << cn;
|
// piCout << "found " << typename_ << cn;
|
||||||
if (cn.isEmpty()) return 0;
|
if (cn.isEmpty()) return nullptr;
|
||||||
Entity * e = new Entity();
|
Entity * e = new Entity();
|
||||||
e->meta = meta;
|
e->meta = meta;
|
||||||
e->name = cur_namespace + cn;
|
e->name = cur_namespace + cn;
|
||||||
@@ -587,10 +591,6 @@ void PICodeParser::parseClass(Entity * parent, PIString & fc, bool is_namespace)
|
|||||||
Visibility prev_vis = cur_def_vis;
|
Visibility prev_vis = cur_def_vis;
|
||||||
int dind = fc.find('{'), find = fc.find(';'), end = 0;
|
int dind = fc.find('{'), find = fc.find(';'), end = 0;
|
||||||
if (dind < 0 && find < 0) return;
|
if (dind < 0 && find < 0) return;
|
||||||
if (dind < 0 || find < dind) {
|
|
||||||
fc.left(find);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// piCout << "parse class <****\n" << fc << "\n****>";
|
// piCout << "parse class <****\n" << fc << "\n****>";
|
||||||
Entity * ce = parent;
|
Entity * ce = parent;
|
||||||
if (!is_namespace) {
|
if (!is_namespace) {
|
||||||
@@ -598,7 +598,6 @@ void PICodeParser::parseClass(Entity * parent, PIString & fc, bool is_namespace)
|
|||||||
fc.trim().cutLeft(1).cutRight(1).trim();
|
fc.trim().cutLeft(1).cutRight(1).trim();
|
||||||
}
|
}
|
||||||
// piCout << "found class <****\n" << fc << "\n****>";
|
// piCout << "found class <****\n" << fc << "\n****>";
|
||||||
/// if (!ce) return PIString();
|
|
||||||
if (ce) {
|
if (ce) {
|
||||||
if (parent) parent->children << ce;
|
if (parent) parent->children << ce;
|
||||||
ce->parent_scope = parent;
|
ce->parent_scope = parent;
|
||||||
@@ -636,6 +635,7 @@ void PICodeParser::parseClass(Entity * parent, PIString & fc, bool is_namespace)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cw == s_class || cw == s_struct || cw == s_union) {
|
if (cw == s_class || cw == s_struct || cw == s_union) {
|
||||||
|
// piCout << cw << isDeclaration(fc, 0, &end);
|
||||||
if (isDeclaration(fc, 0, &end)) {
|
if (isDeclaration(fc, 0, &end)) {
|
||||||
fc.cutLeft(end);
|
fc.cutLeft(end);
|
||||||
fc.takeSymbol();
|
fc.takeSymbol();
|
||||||
|
|||||||
69
main.cpp
69
main.cpp
@@ -1,4 +1,5 @@
|
|||||||
#include "pibytearray.h"
|
#include "pibytearray.h"
|
||||||
|
#include "picodeparser.h"
|
||||||
#include "piiostream.h"
|
#include "piiostream.h"
|
||||||
#include "pijson.h"
|
#include "pijson.h"
|
||||||
#include "pimathbase.h"
|
#include "pimathbase.h"
|
||||||
@@ -7,73 +8,9 @@
|
|||||||
|
|
||||||
using namespace PICoutManipulators;
|
using namespace PICoutManipulators;
|
||||||
|
|
||||||
struct SomeType {
|
|
||||||
int i;
|
|
||||||
float f;
|
|
||||||
};
|
|
||||||
|
|
||||||
PICout operator<<(PICout c, const SomeType & v) {
|
|
||||||
c << "SomeType(" << v.i << "," << v.f << ")";
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
REGISTER_VARIANT(SomeType);
|
|
||||||
REGISTER_VARIANT_CAST(SomeType, PIString) {
|
|
||||||
return PIString::fromNumber(v.i) + ";" + PIString::fromNumber(v.f);
|
|
||||||
}
|
|
||||||
REGISTER_VARIANT_CAST(PIString, SomeType) {
|
|
||||||
PIStringList sl = v.split(';').resize(2);
|
|
||||||
return SomeType{sl[0].toInt(), sl[1].toFloat()};
|
|
||||||
}
|
|
||||||
#include "piliterals.h"
|
|
||||||
|
|
||||||
int main(int argc, char * argv[]) {
|
int main(int argc, char * argv[]) {
|
||||||
/*PIValueTree root;
|
PICodeParser cp;
|
||||||
root.addChild({"bool", PIVariant(false)});
|
cp.parseFile("kmm_types.h", false);
|
||||||
root.addChild({"integer", PIVariant(256)});
|
|
||||||
root.addChild({"string", PIVariant("str")});
|
|
||||||
for (auto it: root.children()) {
|
|
||||||
piCout << it.name() << it.value();
|
|
||||||
}
|
|
||||||
piCout << piSerialize(root);*/
|
|
||||||
// PIVariant v = PIVariant::fromType(PIVariant::typeID<double>());
|
|
||||||
// piCout << v;
|
|
||||||
// piCout << v.toString();
|
|
||||||
// v.setValueFromString("2E-3");
|
|
||||||
// piCout << v.value<double>();
|
|
||||||
// piCout << v.toString();
|
|
||||||
|
|
||||||
// piCout << PITime();
|
|
||||||
// piCout << PITime::fromString("05:12:56");
|
|
||||||
// piCout << PITime::fromString("05: 12:56");
|
|
||||||
// piCout << PITime::fromString("05.12:56");
|
|
||||||
// piCout << PITime::fromString("05.12:56:333", "h.m.s");
|
|
||||||
// piCout << PIDateTime::fromString(PIDateTime::current().toString("__yyyy_MM_d__hh_mm_ss__"), "__yyyy_MM_d__hh_mm_ss__");
|
|
||||||
|
|
||||||
/*piCout << PIVariantTypes::Color();
|
|
||||||
piCout << PIVariantTypes::Color(0xFF00FFff);
|
|
||||||
PIVariant v = PIVariant::fromType(PIVariant::typeName<PIVariantTypes::Color>());
|
|
||||||
piCout << PIVariant::typeName<PIPointd>();
|
|
||||||
piCout << PIVariant::typeFromName(PIVariant::typeName<PIVariantTypes::Color>());
|
|
||||||
piCout << PIVariant::typeIDFromName(PIVariant::typeName<PIVariantTypes::Color>());
|
|
||||||
piCout << PIVariant::typeIDFromType(PIVariant::pivColor);
|
|
||||||
v.setValueFromString("0xFF00FFff");
|
|
||||||
piCout << v;*/
|
|
||||||
|
|
||||||
// PIVariantTypes::Enum e;
|
|
||||||
// e.enum_name = "MyEnum";
|
|
||||||
// e << PIVariantTypes::Enumerator(10105, "Null") << PIVariantTypes::Enumerator(20, "Sec") << PIVariantTypes::Enumerator(100, "Fir");
|
|
||||||
// e.selectValue(20);
|
|
||||||
|
|
||||||
// piCout << e.toString();
|
|
||||||
// piCout << PIVariantTypes::Enum::fromString(e.toString()).toString();
|
|
||||||
// piCout << PIVariantTypes::Enum::fromString("\"MyEnum\"(\"Null\":10105 \"Sec\":20 \"Fir\":100) 20").toString();
|
|
||||||
|
|
||||||
{
|
|
||||||
PIScopeExitCall ec([]() { piCout << "exit"; });
|
|
||||||
ec.cancel();
|
|
||||||
}
|
|
||||||
piCout << PIVariantTypes::Enum::fromString("(\"DeformationWithTemperature2\":1\n;Sigma1:2\n;Tau:3)").toString();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user