CtrlCore: Fixed issue with Upp::t_

git-svn-id: svn://ultimatepp.org/upp/trunk@15822 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2021-03-07 10:16:39 +00:00
parent e7d0b857d8
commit ed9ac211d1
6 changed files with 108 additions and 92 deletions

12
uppsrc/Core/mt_.h Normal file
View file

@ -0,0 +1,12 @@
// This for layouts, to avoid adding Upp:: to each t_
#ifdef t_
#undef t_
#endif
#ifdef tt_
#undef tt_
#endif
#define t_(x) Upp::t_GetLngString(x)
#define tt_(x) x

View file

@ -34,6 +34,7 @@ file
CtrlCoreInit.cpp,
TopWindow.h,
TopWindow.cpp,
lay0.h,
lay.h,
llay.h,
CtrlCore.iml,

View file

@ -1,69 +1,3 @@
//#BLITZ_APPROVE
#define LAYOUT(name, x, y) struct name##__layid {};
#define UNTYPED(variable, param)
#define ITEM(classname, var, param)
#define END_LAYOUT
#include LAYOUTFILE
#undef LAYOUT
#undef UNTYPED
#undef ITEM
#undef END_LAYOUT
#define LAYOUT(name, x, y) template<class T> \
struct With##name : public T, public name##__layid { \
static Upp::Size GetLayoutSize() { return Upp::Ctrl::LayoutZoom(x, y); }
#define UNTYPED(variable, param)
#define ITEM(classname, var, param) classname var;
#define END_LAYOUT };
#include LAYOUTFILE
#undef LAYOUT
#undef UNTYPED
#undef ITEM
#undef END_LAYOUT
#define LAYOUT(nm, x, y) template<class T> inline void SetLayout_##nm(T& parent, bool add = false, bool show = false) { \
SetLayout_Size(parent, Upp::Zx(x), Upp::Zy(y));
#define UNTYPED(var, param) parent.var.param; if(add) parent.Add(parent.var); if(show) parent.var.Show();
#define ITEM(clss, var, param) UNTYPED(var, param);
#define END_LAYOUT }
#include LAYOUTFILE
#undef LAYOUT
#undef UNTYPED
#undef ITEM
#undef END_LAYOUT
#define LAYOUT(nm, x, y) template<class T, class D> inline void SetLayout_##nm(T& ctrl, D& parent, bool add = false, bool show = false) { \
SetLayout_Size(ctrl, Upp::Zx(x), Upp::Zy(y));
#define UNTYPED(var, param) parent.var.param; if(add) ctrl.Add(parent.var); if(show) parent.var.Show();
#define ITEM(clss, var, param) UNTYPED(var, param);
#define END_LAYOUT }
#include LAYOUTFILE
#undef LAYOUT
#undef UNTYPED
#undef ITEM
#undef END_LAYOUT
#define LAYOUT(nm, x, y) template <class L, class D> \
void InitLayout(UPP::Ctrl& parent, L& layout, D& uts, nm##__layid&) { \
parent.LayoutId(#nm);
#define UNTYPED(var, param) uts.var.param; uts.var.LayoutId(#var); parent.Add(uts.var);
#define ITEM(clss, var, param) layout.var.param; layout.var.LayoutId(#var); parent.Add(layout.var);
#define END_LAYOUT }
#include LAYOUTFILE
#undef LAYOUT
#undef UNTYPED
#undef ITEM
#undef END_LAYOUT
#undef LAYOUTFILE
#include <Core/mt_.h>
#include <CtrlCore/lay0.h>
#include <Core/t_.h>

69
uppsrc/CtrlCore/lay0.h Normal file
View file

@ -0,0 +1,69 @@
//#BLITZ_APPROVE
#define LAYOUT(name, x, y) struct name##__layid {};
#define UNTYPED(variable, param)
#define ITEM(classname, var, param)
#define END_LAYOUT
#include LAYOUTFILE
#undef LAYOUT
#undef UNTYPED
#undef ITEM
#undef END_LAYOUT
#define LAYOUT(name, x, y) template<class T> \
struct With##name : public T, public name##__layid { \
static Upp::Size GetLayoutSize() { return Upp::Ctrl::LayoutZoom(x, y); }
#define UNTYPED(variable, param)
#define ITEM(classname, var, param) classname var;
#define END_LAYOUT };
#include LAYOUTFILE
#undef LAYOUT
#undef UNTYPED
#undef ITEM
#undef END_LAYOUT
#define LAYOUT(nm, x, y) template<class T> inline void SetLayout_##nm(T& parent, bool add = false, bool show = false) { \
SetLayout_Size(parent, Upp::Zx(x), Upp::Zy(y));
#define UNTYPED(var, param) parent.var.param; if(add) parent.Add(parent.var); if(show) parent.var.Show();
#define ITEM(clss, var, param) UNTYPED(var, param);
#define END_LAYOUT }
#include LAYOUTFILE
#undef LAYOUT
#undef UNTYPED
#undef ITEM
#undef END_LAYOUT
#define LAYOUT(nm, x, y) template<class T, class D> inline void SetLayout_##nm(T& ctrl, D& parent, bool add = false, bool show = false) { \
SetLayout_Size(ctrl, Upp::Zx(x), Upp::Zy(y));
#define UNTYPED(var, param) parent.var.param; if(add) ctrl.Add(parent.var); if(show) parent.var.Show();
#define ITEM(clss, var, param) UNTYPED(var, param);
#define END_LAYOUT }
#include LAYOUTFILE
#undef LAYOUT
#undef UNTYPED
#undef ITEM
#undef END_LAYOUT
#define LAYOUT(nm, x, y) template <class L, class D> \
void InitLayout(UPP::Ctrl& parent, L& layout, D& uts, nm##__layid&) { \
parent.LayoutId(#nm);
#define UNTYPED(var, param) uts.var.param; uts.var.LayoutId(#var); parent.Add(uts.var);
#define ITEM(clss, var, param) layout.var.param; layout.var.LayoutId(#var); parent.Add(layout.var);
#define END_LAYOUT }
#include LAYOUTFILE
#undef LAYOUT
#undef UNTYPED
#undef ITEM
#undef END_LAYOUT
#undef LAYOUTFILE

View file

@ -1,3 +1,3 @@
#include <Core/lt_.h>
#include <CtrlCore/lay.h>
#include <CtrlCore/lay0.h>
#include <Core/t_.h>

View file

@ -418,22 +418,22 @@ void putopt(Stream& out, const char *key, const Array<OptItem>& m) {
out << key << AsStringWhen(m[i].when) << ' ' << WriteValue(m[i].text) << ";\n\n";
}
void putp(Stream& out, const char *key, const Vector<String>& v, const String& eol)
void putp(Stream& out, const char *key, const Vector<String>& v)
{
if(v.GetCount()) {
out << key << eol;
out << key << "\n";
for(int i = 0; i < v.GetCount(); i++) {
if(i) out << "," << eol;
if(i) out << ",\n";
out << '\t' << WriteValue(v[i]);
}
out << ";" << eol << eol;
out << ";\n\n";
}
}
void putfopt(Stream& out, const char *key, const Array<OptItem>& m, const String& eol)
void putfopt(Stream& out, const char *key, const Array<OptItem>& m)
{
for(int i = 0; i < m.GetCount(); i++)
out << eol << "\t\t" << key << AsStringWhen(m[i].when) << ' ' << WriteValue(m[i].text);
out << "\n\t\t" << key << AsStringWhen(m[i].when) << ' ' << WriteValue(m[i].text);
}
String IdeCharsetName(byte charset) {
@ -452,10 +452,7 @@ void PutSpellCheckComments(StringStream& out, int sc)
}
bool Package::Save(const char *path) const {
RealizePath(path);
StringStream out;
String eol = cr ? "\r\n" : "\n";
String eol2 = eol + eol;
if(description.GetCount() || italic || bold || !IsNull(ink)) {
String d = description;
d.Cat(255);
@ -465,17 +462,17 @@ bool Package::Save(const char *path) const {
d << 'I';
if(!IsNull(ink))
d << (int)ink.GetR() << ',' << (int)ink.GetG() << ',' << (int)ink.GetB();
out << "description " << AsCString(d) << ";" << eol2;
out << "description " << AsCString(d) << ";\n\n";
}
if(charset > 0)
out << "charset " << AsCString(IdeCharsetName(charset)) << ";" << eol2;
out << "charset " << AsCString(IdeCharsetName(charset)) << ";\n\n";
if(!IsNull(tabsize))
out << "tabsize " << tabsize << ";" << eol2;
out << "tabsize " << tabsize << ";\n\n";
if(noblitz)
out << "noblitz;" << eol2;
out << "noblitz;\n\n";
if(nowarnings)
out << "options(BUILDER_OPTION) NOWARNINGS;" << eol2;
putp(out, "acceptflags", accepts, eol);
out << "options(BUILDER_OPTION) NOWARNINGS;\n\n";
putp(out, "acceptflags", accepts);
putopt(out, "flags", flag);
putopt(out, "uses", uses);
putopt(out, "target", target);
@ -511,22 +508,25 @@ bool Package::Save(const char *path) const {
if(!IsNull(f.highlight))
out << " highlight " << f.highlight;
PutSpellCheckComments(out, f.spellcheck_comments);
putfopt(out, "options", f.option, eol);
putfopt(out, "depends", f.depends, eol);
putfopt(out, "options", f.option);
putfopt(out, "depends", f.depends);
}
out << ";\n\n";
}
if(config.GetCount()) {
out << "mainconfig" << eol;
out << "mainconfig\n";
for(int i = 0; i < config.GetCount(); i++) {
const Config& f = config[i];
if(i) out << "," << eol;
if(i) out << ",\n";
out << '\t' << AsCString(f.name) << " = " << AsCString(f.param);
}
out << ";" << eol2;
out << ";\n\n";
}
PutSpellCheckComments(out, spellcheck_comments);
for(int i = 0; i < custom.GetCount(); i++)
out << custom[i].AsString();
return SaveChangedFile(path, out.GetResult());
}
String content = out.GetResult();
if(cr)
content.Replace("\n", "\r\n");
return SaveChangedFile(path, content);
}