diff --git a/README.md b/README.md index d980a4822..8e7acf87d 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Rapid development is achieved by the [smart and aggressive use of C++](https://w The U++ integrated development environment, TheIDE, introduces modular concepts to C++ programming. It features BLITZ-build technology to speedup C++ rebuilds up to 4 times, Visual designers for U++ libraries, a [Topic++](https://www.ultimatepp.org/app$ide$Topic$en-us.html) system for documenting code and creating rich text resources for applications (like help and code documentation) and [Assist++](https://www.ultimatepp.org/app$ide$Assist$en-us.html) - a powerful C++ code analyzer that provides features like code completion, navigation and transformation. -TheIDE can work with GCC, MinGW and Visual C++ and contains a full featured debugger. TheIDE can also be used to develop non-U++ applications. +TheIDE can work with GCC, Clang, MinGW and Visual C++ and contains a full featured debugger. TheIDE can also be used to develop non-U++ applications. U++ supports following platforms on the production level: **Windows**, **macOS**, **GNU/Linux** & **FreeBSD**. @@ -44,30 +44,40 @@ Below is the code of trivial GUI application that displays "Hello World" string ```c++ #include -class MyAppWindow : public Upp::TopWindow { +class MyApp: public Upp::TopWindow { public: - MyAppWindow() { - Title("My application").Zoomable().Sizeable(); + MyApp() + { + Title("My application").Zoomable().Sizeable().SetRect(0, 0, 320, 200); } - virtual void Paint(Upp::Draw& w) override { + virtual void Paint(Upp::Draw& w) override + { w.DrawRect(GetSize(), Upp::SWhite); - w.DrawText(20, 20, "Hello world!", Upp::Arial(30), Upp::Magenta); + w.DrawText(10, 10, "Hello, world!", Upp::Arial(30), Upp::Magenta); } }; GUI_APP_MAIN { - MyAppWindow app; - app.SetRect(0, 0, 200, 100); - app.Run(); + MyApp().Run(); } ``` +### TheIDE + +Standard part of U++ framework is integrated development environment, TheIDE. + +

+ TheIDE - U++ Integrated Developemnt Enviroment +

+ ### Additional examples See here: [examples](https://www.ultimatepp.org/www$uppweb$examples$en-us.html). Moreover, exactly the same examples can be found in the **examples** and **references** directories located in this repository. +If you would like to see more screenshots, click [here](https://www.ultimatepp.org/www$uppweb$ss$en-us.html). + # Repository ## Repository layout diff --git a/uppsrc/Docedit/Copying b/archive/PaintGL/Copying similarity index 100% rename from uppsrc/Docedit/Copying rename to archive/PaintGL/Copying diff --git a/uppsrc/PaintGL/PaintGL.cpp b/archive/PaintGL/PaintGL.cpp similarity index 95% rename from uppsrc/PaintGL/PaintGL.cpp rename to archive/PaintGL/PaintGL.cpp index 37f97eb26..e40ba1f22 100644 --- a/uppsrc/PaintGL/PaintGL.cpp +++ b/archive/PaintGL/PaintGL.cpp @@ -1,98 +1,98 @@ -#include "PaintGL.h" - -#pragma comment( lib, "opengl32.lib" ) // Search For OpenGL32.lib While Linking -#pragma comment( lib, "glu32.lib" ) // Search For GLu32.lib While Linking -#pragma comment( lib, "glaux.lib" ) // Search For GLaux.lib While Linking - -PaintGL::PaintGL() -{ - size = Null; - hbmp = ohbmp = NULL; - hdc = NULL; - hrc = NULL; -} - -PaintGL::~PaintGL() -{ - Free(); -} - -void PaintGL::Free() -{ - if(hrc) { - wglMakeCurrent(NULL, NULL); - wglDeleteContext(hrc); - SelectObject(hdc, ohbmp); - DeleteDC(hdc); - DeleteObject(hbmp); - hrc = NULL; - hbmp = ohbmp = NULL; - hdc = NULL; - hbmp = NULL; - } - size = Null; -} - - -void PaintGL::Init(Size sz) { - Free(); - - size = sz; - - BITMAPINFOHEADER bih; - memset(&bih, 0, sizeof(bih)); - bih.biSize = sizeof(bih); - bih.biWidth = ((((int) sz.cx * 8) + 31) & ~31) >> 3; - bih.biHeight = sz.cy; - bih.biPlanes = 1; - bih.biBitCount = 32; - bih.biCompression = BI_RGB; - - hdc = CreateCompatibleDC(NULL); - - void *dummy; - - hbmp = CreateDIBSection(hdc, (BITMAPINFO*)&bih, DIB_PAL_COLORS, &dummy, NULL, 0); - - ohbmp = (HBITMAP)SelectObject(hdc, hbmp); - - PIXELFORMATDESCRIPTOR pfd; - memset(&pfd, 0, sizeof(pfd)); - pfd.nSize = sizeof(pfd); - pfd.nVersion = 1; - pfd.dwFlags = PFD_DRAW_TO_BITMAP | PFD_SUPPORT_OPENGL/* | PFD_SUPPORT_GDI | PFD_ACCELERATED*/; - pfd.iPixelType = PFD_TYPE_RGBA; - pfd.cColorBits = 32; - pfd.cDepthBits = 32; - pfd.iLayerType = PFD_MAIN_PLANE; - - GLuint PixelFormat = ChoosePixelFormat(hdc, &pfd); - SetPixelFormat(hdc, PixelFormat, &pfd); - hrc = wglCreateContext(hdc); - wglMakeCurrent(hdc, hrc); - - glShadeModel(GL_SMOOTH); - glClearColor(0.0f, 0.0f, 0.0f, 0.5f); - glClearDepth(1.0f); - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_LEQUAL); - glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); - - glViewport(0, 0, (GLsizei)sz.cx, (GLsizei)sz.cy); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(45.0f, (GLfloat)(sz.cx)/(GLfloat)(sz.cy), 1.0f, 100.0f); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -void PaintGL::Paint(Draw& w, const Rect& r, Callback gl) -{ - if(r.Size() != size) - Init(r.Size()); - gl(); - glFlush(); - HDC whdc = w.BeginGdi(); - BitBlt(whdc, 0, 0, size.cx, size.cy, hdc, r.left, r.top, SRCCOPY); - w.EndGdi(); -} +#include "PaintGL.h" + +#pragma comment( lib, "opengl32.lib" ) // Search For OpenGL32.lib While Linking +#pragma comment( lib, "glu32.lib" ) // Search For GLu32.lib While Linking +#pragma comment( lib, "glaux.lib" ) // Search For GLaux.lib While Linking + +PaintGL::PaintGL() +{ + size = Null; + hbmp = ohbmp = NULL; + hdc = NULL; + hrc = NULL; +} + +PaintGL::~PaintGL() +{ + Free(); +} + +void PaintGL::Free() +{ + if(hrc) { + wglMakeCurrent(NULL, NULL); + wglDeleteContext(hrc); + SelectObject(hdc, ohbmp); + DeleteDC(hdc); + DeleteObject(hbmp); + hrc = NULL; + hbmp = ohbmp = NULL; + hdc = NULL; + hbmp = NULL; + } + size = Null; +} + + +void PaintGL::Init(Size sz) { + Free(); + + size = sz; + + BITMAPINFOHEADER bih; + memset(&bih, 0, sizeof(bih)); + bih.biSize = sizeof(bih); + bih.biWidth = ((((int) sz.cx * 8) + 31) & ~31) >> 3; + bih.biHeight = sz.cy; + bih.biPlanes = 1; + bih.biBitCount = 32; + bih.biCompression = BI_RGB; + + hdc = CreateCompatibleDC(NULL); + + void *dummy; + + hbmp = CreateDIBSection(hdc, (BITMAPINFO*)&bih, DIB_PAL_COLORS, &dummy, NULL, 0); + + ohbmp = (HBITMAP)SelectObject(hdc, hbmp); + + PIXELFORMATDESCRIPTOR pfd; + memset(&pfd, 0, sizeof(pfd)); + pfd.nSize = sizeof(pfd); + pfd.nVersion = 1; + pfd.dwFlags = PFD_DRAW_TO_BITMAP | PFD_SUPPORT_OPENGL/* | PFD_SUPPORT_GDI | PFD_ACCELERATED*/; + pfd.iPixelType = PFD_TYPE_RGBA; + pfd.cColorBits = 32; + pfd.cDepthBits = 32; + pfd.iLayerType = PFD_MAIN_PLANE; + + GLuint PixelFormat = ChoosePixelFormat(hdc, &pfd); + SetPixelFormat(hdc, PixelFormat, &pfd); + hrc = wglCreateContext(hdc); + wglMakeCurrent(hdc, hrc); + + glShadeModel(GL_SMOOTH); + glClearColor(0.0f, 0.0f, 0.0f, 0.5f); + glClearDepth(1.0f); + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LEQUAL); + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); + + glViewport(0, 0, (GLsizei)sz.cx, (GLsizei)sz.cy); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(45.0f, (GLfloat)(sz.cx)/(GLfloat)(sz.cy), 1.0f, 100.0f); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +void PaintGL::Paint(Draw& w, const Rect& r, Callback gl) +{ + if(r.Size() != size) + Init(r.Size()); + gl(); + glFlush(); + HDC whdc = w.BeginGdi(); + BitBlt(whdc, 0, 0, size.cx, size.cy, hdc, r.left, r.top, SRCCOPY); + w.EndGdi(); +} diff --git a/uppsrc/PaintGL/PaintGL.h b/archive/PaintGL/PaintGL.h similarity index 92% rename from uppsrc/PaintGL/PaintGL.h rename to archive/PaintGL/PaintGL.h index 81246f6ce..2ac78de9c 100644 --- a/uppsrc/PaintGL/PaintGL.h +++ b/archive/PaintGL/PaintGL.h @@ -1,27 +1,27 @@ -#ifndef _PaintGL_PaintGL_h -#define _PaintGL_PaintGL_h - -#include - -#include -#include -#include - -class PaintGL { - Size size; - HBITMAP hbmp, ohbmp; - HDC hdc; - HGLRC hrc; - - void Free(); - void Init(Size sz); - -public: - void Paint(Draw& w, const Rect& r, Callback gl); - - PaintGL(); - ~PaintGL(); -}; - - -#endif +#ifndef _PaintGL_PaintGL_h +#define _PaintGL_PaintGL_h + +#include + +#include +#include +#include + +class PaintGL { + Size size; + HBITMAP hbmp, ohbmp; + HDC hdc; + HGLRC hrc; + + void Free(); + void Init(Size sz); + +public: + void Paint(Draw& w, const Rect& r, Callback gl); + + PaintGL(); + ~PaintGL(); +}; + + +#endif diff --git a/uppsrc/PaintGL/PaintGL.upp b/archive/PaintGL/PaintGL.upp similarity index 91% rename from uppsrc/PaintGL/PaintGL.upp rename to archive/PaintGL/PaintGL.upp index 271326666..0c93bd5b7 100644 --- a/uppsrc/PaintGL/PaintGL.upp +++ b/archive/PaintGL/PaintGL.upp @@ -1,6 +1,6 @@ -file - PaintGL.h, - PaintGL.cpp, - Info readonly separator, - Copying; - +file + PaintGL.h, + PaintGL.cpp, + Info readonly separator, + Copying; + diff --git a/uppsrc/RichBook/RichBook.cpp b/archive/RichBook/RichBook.cpp similarity index 96% rename from uppsrc/RichBook/RichBook.cpp rename to archive/RichBook/RichBook.cpp index 7879363b3..8ab6caeee 100644 --- a/uppsrc/RichBook/RichBook.cpp +++ b/archive/RichBook/RichBook.cpp @@ -1,677 +1,677 @@ -#include "RichBook.h" - -#include -#include - -namespace Upp { - -struct FieldTypeVarCls : public RichPara::FieldType -{ - virtual Array Evaluate(const String& param, VectorMap& vars, - const RichPara::CharFormat& fmt); -}; - -Array FieldTypeVarCls::Evaluate(const String& dest, - VectorMap& vars, const RichPara::CharFormat& linkfmt) -{ - RichPara para; - RichPara::CharFormat fmt = linkfmt; - int f = vars.Find(dest); - if(f < 0) { - fmt.ink = LtRed(); - fmt.paper = WhiteGray(); - para.Cat(dest, fmt); - } - else - para.Cat(StdFormat(vars[f]), fmt); - return para.part; -} - -RichPara::FieldType& GLOBAL_V(FieldTypeVarCls, FieldTypeVar); - -Id FieldTypeVarID() -{ - static Id ftv("VAR"); - return ftv; -} - -INITBLOCK { - RichPara::Register(FieldTypeVarID(), FieldTypeVar()); -} - -/* -RichPara::FieldType& FieldTypeIndexEntry() -{ -} - -Id FieldTypeIndexEntryID() -{ -} - -String EncodeIndexEntry(const RichIndexEntry& idx) -{ -} - -RichIndexEntry DecodeIndexEntry(String encoded_indexentry) -{ -} -*/ - -RichBookSection::RichBookSection() -{ -// pagesize = pg; - columns = 1; - firstpage = 1; - margin = Rect(0, 0, 0, 0); - header_space = 200; - footer_space = 200; - column_space = 200; -// footer[1] = "- # -"; -} - -Rect RichBookSection::GetPageRect(Size pagesize) const -{ - return Rect(pagesize).Deflated(margin); -} - -Rect RichBookSection::GetTextRect(Size pagesize, int colindex) const -{ - Rect textarea = GetPageRect(pagesize).Deflated(0, header_space, 0, footer_space); - if(columns <= 1) - return textarea; - int colwd = (textarea.Width() - column_space * (columns - 1)) / columns; - int offset = iscale(textarea.Width() - colwd, colindex, columns - 1); - textarea.left += offset; - textarea.right = textarea.left + colwd; - return textarea; -} - -Size RichBookSection::GetTextSize(Size pagesize) const -{ - return GetTextRect(pagesize, 0).Size(); -} - -class RichSectionPageDraw : public PageDraw -{ -public: - RichSectionPageDraw(Size drawingsize, Gate2 progress, int& progress_pos); - - virtual Draw& Page(int page); - virtual Draw& Info(); - - Vector Close(); - -private: - Gate2 progress; - int& progress_pos; - Size drawingsize; - Vector pages; - DrawingDraw ddraw; - DrawingDraw info; - int currentpage; -}; - -RichSectionPageDraw::RichSectionPageDraw(Size dsz, Gate2 progress, int& progress_pos) -: progress(progress) -, progress_pos(progress_pos) -{ - currentpage = -1; - info.Create(drawingsize = dsz); -} - -Draw& RichSectionPageDraw::Page(int page) -{ - if(page != currentpage) { - ASSERT(ddraw.GetCloffLevel() == 0); - progress(progress_pos + page, -1); - if(currentpage >= 0) - pages.At(currentpage) = ddraw; - ddraw.Create(drawingsize); - ddraw.DrawDrawing(drawingsize, pages.At(currentpage = page)); - } - return ddraw; -} - -Draw& RichSectionPageDraw::Info() -{ - return Page(0); -} - -Vector RichSectionPageDraw::Close() -{ - if(currentpage >= 0) { - ASSERT(ddraw.GetCloffLevel() == 0); - pages.At(currentpage) = ddraw; - } - return pages; -} - -static String ExpandHFText(const char *text, int pageno) -{ - String out; - for(char c; c = *text++;) - if(c == '#') - switch(*text++) { - case 'r': out.Cat(FormatIntRoman(pageno, false)); break; - case 'R': out.Cat(FormatIntRoman(pageno, true)); break; - case 'a': out.Cat(FormatIntAlpha(pageno, false)); break; - case 'A': out.Cat(FormatIntAlpha(pageno, true)); break; - default: text--; out.Cat(FormatInt(pageno)); break; - } - else - out.Cat(c); - return out; -} - -Vector RichPrintSection::Print(Size pagesize, Gate2 progress, int& progress_pos) const -{ - ASSERT(columns > 0); - Size drawingsize = GetTextSize(pagesize); - RichSectionPageDraw spdraw(drawingsize, progress, progress_pos); - PaintInfo paintinfo; - paintinfo.top = PageY(0, 0); - paintinfo.bottom = PageY(32767, 0); - paintinfo.indexentry = Null; - text.Paint(spdraw, drawingsize, paintinfo); - Vector in = spdraw.Close(); - Vector out; - for(int i = 0; i < in.GetCount(); i += columns) { - int pageno = firstpage + out.GetCount(); - DrawingDraw ddraw(pagesize); - Rect pagerect = GetPageRect(pagesize); - for(int c = 0; c < columns && c + i < in.GetCount(); c++) - ddraw.DrawDrawing(GetTextRect(pagesize, c), in[i + c]); - for(int hf = 0; hf < 3; hf++) { - if(!IsNull(header[hf])) { - String s = ExpandHFText(header[hf], pageno); - Size sz = UPP::GetTextSize(s, charformat); - int x; - switch(hf) { - case 0: x = pagerect.left; break; - case 1: x = (pagerect.left + pagerect.right - sz.cx) >> 1; break; - case 2: x = pagerect.right - sz.cx; break; - } - ddraw.DrawText(x, pagerect.top, s, charformat); - } - if(!IsNull(footer[hf])) { - String s = ExpandHFText(footer[hf], pageno); - Size sz = UPP::GetTextSize(s, charformat); - int x; - switch(hf) { - case 0: x = pagerect.left; break; - case 1: x = (pagerect.left + pagerect.right - sz.cx) >> 1; break; - case 2: x = pagerect.right - sz.cx; break; - } - ddraw.DrawText(x, pagerect.bottom - sz.cy, s, charformat); - } - } - out.Add() = ddraw; - } - return out; -} - -String GetLangSuffix(int language = GetCurrentLanguage()) -{ - String lt = LNGAsText(language); - String out; - out << '$' << (char)ToLower(lt[0]) << (char)ToLower(lt[1]) << '-' << (char)ToLower(lt[3]) << (char)ToLower(lt[4]); - return out; -} - -void MakeStdToc(RichText& out, const RichToc& toc, int print_width) -{ - VectorMap< String, ArrayMap > subparts; - String suffix = GetLangSuffix(); - for(int i = 0; i < toc.entries.GetCount(); i++) { - const RichTocEntry& e = toc.entries[i]; - RichPara::Format pfmt = out.GetStyle(out.GetStyleId("Toc" + FormatInt(e.level))).format; - RichPara para; - para.format = pfmt; - WString name = e.text; - String tname = e.topic, subpart; - int th = tname.Find('#'); - if(th >= 0) { - subpart = tname.Mid(th); - tname.Trim(th); - } - tname.Cat(suffix); - Topic tp = GetTopic(tname); - if(!IsNull(name)) - para.Cat(name, pfmt); - else { - if(!IsNull(subpart)) { - int sp = subparts.Find(tname); - if(sp < 0) { - sp = subparts.GetCount(); - ArrayMap& spmap = subparts.Add(tname); - RichText rt = ParseQTF(tp.text); - for(int p = 0; p < rt.GetPartCount(); p++) - if(rt.IsPara(p)) { - RichPara rp = rt.Get(p); -// if(*rp.format.label == '#') - spmap.AddPick("#" + rp.format.label, rp); - } - } - para <<= subparts[sp].Get(subpart, RichPara()); - Array objs; - String packed = para.Pack(para.format, objs); - para.Unpack(packed, objs, pfmt); - } - else if(!IsNull(tp.title)) - para.Cat(FromUtf8(tp.title), pfmt); - } - if(para.part.IsEmpty()) { - pfmt.ink = LtRed(); - pfmt.paper = WhiteGray(); - para.Cat((WString)(tname + subpart), pfmt); - } - para.Cat("\t", pfmt); - para.Cat(FieldTypeVarID(), String().Cat() << tname << subpart << "$page", pfmt); - out.Cat(para); - } - RLOG("MakeStdToc:\n" << AsQTF(out)); -} - -void MakeOnlineToc(RichText& out, const RichToc& toc) -{ - String suffix = GetLangSuffix(); - VectorMap< String, ArrayMap > subparts; - for(int i = 0; i < toc.entries.GetCount(); i++) { - const RichTocEntry& e = toc.entries[i]; - RichPara::Format pfmt = out.GetStyle(out.GetStyleId("Topics" + FormatInt(e.level))).format; - RichPara para; - para.format = pfmt; - WString name = e.text; - String tname = e.topic, subpart; - int th = tname.Find('#'); - if(th >= 0) { - subpart = tname.Mid(th); - tname.Trim(th); - } - tname.Cat(suffix); - Topic tp = GetTopic(tname); - pfmt.link = tname; - if(!IsNull(name)) - para.Cat(name, pfmt); - else { - if(!IsNull(subpart)) { - int sp = subparts.Find(tname); - if(sp < 0) { - sp = subparts.GetCount(); - ArrayMap& spmap = subparts.Add(tname); - RichText rt = ParseQTF(tp.text); - for(int p = 0; p < rt.GetPartCount(); p++) - if(rt.IsPara(p)) { - RichPara rp = rt.Get(p); -// if(*rp.format.label == '#') - spmap.AddPick("#" + rp.format.label, rp); - } - } - para <<= subparts[sp].Get(subpart, RichPara()); - Array objs; - String packed = para.Pack(para.format, objs); - para.Unpack(packed, objs, pfmt); - } - else if(!IsNull(tp.title)) - para.Cat(FromUtf8(tp.title), pfmt); - } - if(para.part.IsEmpty()) { - pfmt.ink = LtRed(); - pfmt.paper = WhiteGray(); - para.Cat((WString)(tname + subpart), pfmt); - } - out.Cat(para); - } - RLOG("MakeOnlineToc:\n" << AsQTF(out)); -} - -void MakeTocTopics(RichText& out, const RichToc& toc) -{ - String suffix = GetLangSuffix(); - VectorMap< String, VectorMap > topic_tocrefs; - for(int i = 0; i < toc.entries.GetCount(); i++) { - String tname = toc.entries[i].topic; - int th = tname.Find('#'); - if(th >= 0) - topic_tocrefs.GetAdd(tname.Left(th)).GetAdd(tname.Mid(th), i); - } - Index done; - for(int i = 0; i < toc.entries.GetCount(); i++) { - const RichTocEntry& e = toc.entries[i]; - WString name = e.text; - String tname = e.topic; - int th = tname.Find('#'); - if(th >= 0) - tname.Trim(th); - int tr = topic_tocrefs.Find(tname); - tname << suffix; - if(done.Find(tname) >= 0) - continue; - done.Add(tname); - Topic tp = GetTopic(tname); - RichPara title_para; - title_para.format = out.GetStyle(out.GetStyleId("Heading" + FormatInt(e.level))).format; - if(IsNull(name) && IsNull(name = FromUtf8(tp.title))) { - name = (WString)tname; - title_para.format.ink = LtRed(); - title_para.format.paper = WhiteGray(); - } - title_para.format.label = tname; - title_para.Cat(name, title_para.format); - out.Cat(title_para); - RichText data = ParseQTF(tp.text); - int pcount = out.GetPartCount(); - out.CatPick(data); - for(int t = pcount; t < out.GetPartCount(); t++) - if(out.IsPara(t)) { - RichPara p = out.Get(t); - String lbl = "#" + p.format.label; - int tx; - if(tr >= 0 && (tx = topic_tocrefs[tr].Find(lbl)) >= 0) { - const RichTocEntry& ex = toc.entries[topic_tocrefs[tr][tx]]; - Array objs; - String pack = p.Pack(p.format, objs); - p.format = out.GetStyle(out.GetStyleId("Heading" + FormatInt(ex.level))).format; - p.Unpack(pack, objs, p.format); - p.format.label = tname + lbl; - out.Set(t, p, out.GetStyles()); - } - } - } -} - -//RichText MakeStdIndex( - -RichBook::RichBook(Size pg) -: page_size(pg) -{ - RichStyle toc1, toc2, toc3, toc4; - RichPara::Tab& t1tab = toc1.format.tab.Add(); - t1tab.pos = pg.cx - 300; - t1tab.align = ALIGN_RIGHT; - t1tab.fillchar = 1; - toc2 = toc3 = toc4 = toc1; - t1tab.fillchar = 0; - - toc1.name = "Toc1"; - (Font&)toc1.format = Arial(90).Bold(); - toc1.format.indent = 100; - toc1.format.before = 100; - toc1.format.number[0] = RichPara::NUMBER_1; - - toc2.name = "Toc2"; - (Font&)toc2.format = Arial(84).Bold(); - toc2.format.indent = 200; - toc2.format.lm = 200; - toc2.format.number[0] = toc2.format.number[1] = RichPara::NUMBER_1; - - toc3.name = "Toc3"; - (Font&)toc3.format = Arial(84); - toc3.format.indent = 300; - toc3.format.lm = 300; - toc3.format.number[0] = toc3.format.number[1] = toc3.format.number[2] = RichPara::NUMBER_1; - - toc4.name = "Toc4"; - toc4.format.number[0] = toc4.format.number[1] = toc4.format.number[2] = toc4.format.number[3] = RichPara::NUMBER_1; - - RichStyle head1, head2, head3, head4; - head1.name = "Heading1"; - (Font&)head1.format = Arial(144).Bold(); - head1.format.newpage = true; - head1.format.before = 300; - head1.format.after = 100; - head1.format.indent = 150; - head1.format.number[0] = RichPara::NUMBER_1; - - head2.name = "Heading2"; - (Font&)head2.format = Arial(120).Bold(); - head2.format.before = 200; - head2.format.after = 100; - head2.format.indent = 200; - head2.format.number[0] = head2.format.number[1] = RichPara::NUMBER_1; - - head3.name = "Heading3"; - (Font&)head3.format = Arial(100).Bold(); - head3.format.before = 100; - head3.format.after = 50; - head3.format.indent = 250; - head3.format.number[0] = head3.format.number[1] = head3.format.number[2] = RichPara::NUMBER_1; - - head4 = head3; - head4.name = "Heading4"; - head4.format.number[0] = head4.format.number[1] = head4.format.number[2] = head4.format.number[3] = RichPara::NUMBER_1; - - default_styles.Add(Uuid::Create(), toc1); - default_styles.Add(Uuid::Create(), toc2); - default_styles.Add(Uuid::Create(), toc3); - default_styles.Add(Uuid::Create(), toc4); - - default_styles.Add(Uuid::Create(), head1); - default_styles.Add(Uuid::Create(), head2); - default_styles.Add(Uuid::Create(), head3); - default_styles.Add(Uuid::Create(), head4); -} - -RichPrintSection& RichBook::AddSection() -{ - RichText init; - init.OverrideStyles(default_styles); - return sections.Add(new RichPrintSection(default_section, init)); -} - -Vector RichBook::Print(Size pagesize, Gate2 progress) -{ - Vector out; - int pos = 0; - - VectorMap vars; - vars.GetAdd("$book") = 1; - bool stable = false; - enum { MAX_PASSES = 10 }; - int pass; - for(pass = 1; !stable && pass <= MAX_PASSES; pass++) { - if(progress(pass, 0)) - throw AbortExc(); - stable = true; - int pageno = 1; - Index chkdup; - for(int s = 0; s < sections.GetCount(); s++) { - RichPrintSection& psec = sections[s]; - if(psec.text.GetPartCount() > 0 && psec.text.IsPara(0)) { - RichPara p0 = psec.text.Get(0); - if(p0.format.newpage) { - p0.format.newpage = false; - psec.text.Set(0, p0, psec.text.GetStyles()); - } - } - Size textsize = psec.GetTextSize(pagesize); - PageY begin; - pageno = Nvl(psec.firstpage, pageno); - psec.text.EvaluateFields(vars); - int numpages = psec.text.GetHeight(textsize).page / psec.columns + 1; - Vector posinfo = psec.text.GetValPos(textsize, RichText::LABELS); - for(int i = 0; i < posinfo.GetCount(); i++) { - String key = posinfo[i].data.ToString() + "$page"; - if(chkdup.Find(key) >= 0) { - if(pass == 1) - RLOG("Duplicate: " << key); - continue; - } - chkdup.Add(key); - int oldpage = vars.Get(key, Value()); - int newpage = pageno + posinfo[i].py.page; - if(newpage != oldpage) { - if(pass > 2) - RLOG("Unstable: " << key << ": " << oldpage << " -> " << newpage); - vars.GetAdd(key) = newpage; - stable = false; - } - } - pageno += numpages; - } - } - for(int i = 0; i < sections.GetCount(); i++) - out.AppendPick(sections[i].Print(pagesize, progress, pos)); -#ifdef _DEBUG - RichText symtext; - Vector order = GetSortOrder(vars.GetKeys()); - for(int o = 0; o < order.GetCount(); o++) { - RichPara para; - para.Cat(NFormat("<%s> %vt", vars.GetKey(order[o]), vars[order[o]]), para.format); - symtext.Cat(para); - } - RichPrintSection symsec(default_section, symtext); - out.AppendPick(symsec.Print(pagesize, progress, pos)); -#endif - return out; -} - -void CreateHelpBook(RichBook& book) -{ - Progress progress(t_("Typesetting page %d...")); - DocReport report; - Vector pages = book.Print(report.GetPageSize(), progress); - progress.SetText(t_("Printing page %d...")); - for(int i = 0; i < pages.GetCount(); i++) { - if(progress.SetCanceled(i, pages.GetCount())) - throw AbortExc(); - if(i) - report.NextPage(); - report.DrawDrawing(pages[i].GetSize(), pages[i]); - } - report.Perform(); -} - -String CreateHelpPDF(RichBook& book) -{ - PdfDraw pdf(210 * 6000 / 254, 297 * 6000 / 254); - Rect margin = Rect(pdf.GetPagePixels()).Deflated(236); - Progress progress(t_("Typesetting...")); - Vector pages = book.Print(margin.Size(), progress); - progress.SetText(t_("Exporting PDF...")); - progress.SetTotal(pages.GetCount()); - for(int i = 0; i < pages.GetCount(); i++) { - if(progress.StepCanceled()) - throw AbortExc(); - pdf.StartPage(); - pdf.DrawDrawing(margin, pages[i]); - pdf.EndPage(); - } - return pdf.Finish(); -} - -String CreateHelpRTF(RichBook& book, byte charset) -{ - RichText richtext; - for(int i = 0; i < book.sections.GetCount(); i++) - richtext.CatPick(book.sections[i].text); - return EncodeRTF(richtext, charset); -} - -RichBookHtml::RichBookHtml() -{ -} - -void RichBookHtml::AddFile(String url, String data) -{ -} - -void RichBookHtml::AddImage(String url, String data) -{ -} - -String RichBookHtml::GetURLFile(String url) const -{ - String out; - return out; -} - -void CreateHelpHtml(RichBook& book, RichBookHtml& html) -{ -} - -GLOBAL_VAR(Callback1, DefaultBook) - -void CreateDefaultBook() -{ - RichBook book; - DefaultBook()(book); - CreateHelpBook(book); -} - -void CreateDefaultPDF() -{ - RichBook book; - DefaultBook()(book); - try { - String data = CreateHelpPDF(book); - FileSelector fsel; - fsel.Type(t_("PDF documents (*.pdf)"), "*.pdf") - .DefaultExt("pdf") - .AllFilesType(); - static String recent; - fsel <<= recent; - if(fsel.ExecuteSaveAs(t_("PDF export"))) { - recent = ~fsel; - if(!SaveFile(recent, data)) - throw Exc(NFormat("Error saving file '%s' (%d B).", recent, data.GetLength())); - } - } - catch(Exc e) { - ShowExc(e); - } -} - -void CreateDefaultRTF() -{ - RichBook book; - DefaultBook()(book); - try { - String data = CreateHelpRTF(book, GetDefaultCharset()); - FileSelector fsel; - fsel.Type(t_("Rich text documents (*.rtf)"), "*.rtf") - .DefaultExt("rtf") - .AllFilesType(); - static String recent; - fsel <<= recent; - if(fsel.ExecuteSaveAs(t_("Save manual as"))) { - recent = ~fsel; - if(!SaveFile(recent, data)) - throw Exc(NFormat("Error saving file '%s' (%d B).", recent, data.GetLength())); - } - } - catch(Exc e) { - ShowExc(e); - } -} - -void CreateDefaultHTML() -{ - RichBook book; - DefaultBook()(book); - try { - RichBookHtml html; - CreateHelpHtml(book, html); - } - catch(Exc e) { - ShowExc(e); - } -} - -void ManualMenu() -{ - MenuBar menu; - bool isdb = DefaultBook(); - menu.Add(isdb, t_("Print manual"), callback(&CreateDefaultBook)); - menu.Add(isdb, t_("PDF export"), callback(&CreateDefaultPDF)); - menu.Add(isdb, t_("RTF export"), callback(&CreateDefaultRTF)); - menu.Add(isdb, t_("HTML export"), callback(&CreateDefaultHTML)); - menu.Execute(); -} - -void HelpBookMenu(Bar& bar) -{ - bar.Add(t_("Save manual"), CtrlImg::save(), callback(&ManualMenu)); -} - -} +#include "RichBook.h" + +#include +#include + +namespace Upp { + +struct FieldTypeVarCls : public RichPara::FieldType +{ + virtual Array Evaluate(const String& param, VectorMap& vars, + const RichPara::CharFormat& fmt); +}; + +Array FieldTypeVarCls::Evaluate(const String& dest, + VectorMap& vars, const RichPara::CharFormat& linkfmt) +{ + RichPara para; + RichPara::CharFormat fmt = linkfmt; + int f = vars.Find(dest); + if(f < 0) { + fmt.ink = LtRed(); + fmt.paper = WhiteGray(); + para.Cat(dest, fmt); + } + else + para.Cat(StdFormat(vars[f]), fmt); + return para.part; +} + +RichPara::FieldType& GLOBAL_V(FieldTypeVarCls, FieldTypeVar); + +Id FieldTypeVarID() +{ + static Id ftv("VAR"); + return ftv; +} + +INITBLOCK { + RichPara::Register(FieldTypeVarID(), FieldTypeVar()); +} + +/* +RichPara::FieldType& FieldTypeIndexEntry() +{ +} + +Id FieldTypeIndexEntryID() +{ +} + +String EncodeIndexEntry(const RichIndexEntry& idx) +{ +} + +RichIndexEntry DecodeIndexEntry(String encoded_indexentry) +{ +} +*/ + +RichBookSection::RichBookSection() +{ +// pagesize = pg; + columns = 1; + firstpage = 1; + margin = Rect(0, 0, 0, 0); + header_space = 200; + footer_space = 200; + column_space = 200; +// footer[1] = "- # -"; +} + +Rect RichBookSection::GetPageRect(Size pagesize) const +{ + return Rect(pagesize).Deflated(margin); +} + +Rect RichBookSection::GetTextRect(Size pagesize, int colindex) const +{ + Rect textarea = GetPageRect(pagesize).Deflated(0, header_space, 0, footer_space); + if(columns <= 1) + return textarea; + int colwd = (textarea.Width() - column_space * (columns - 1)) / columns; + int offset = iscale(textarea.Width() - colwd, colindex, columns - 1); + textarea.left += offset; + textarea.right = textarea.left + colwd; + return textarea; +} + +Size RichBookSection::GetTextSize(Size pagesize) const +{ + return GetTextRect(pagesize, 0).Size(); +} + +class RichSectionPageDraw : public PageDraw +{ +public: + RichSectionPageDraw(Size drawingsize, Gate2 progress, int& progress_pos); + + virtual Draw& Page(int page); + virtual Draw& Info(); + + Vector Close(); + +private: + Gate2 progress; + int& progress_pos; + Size drawingsize; + Vector pages; + DrawingDraw ddraw; + DrawingDraw info; + int currentpage; +}; + +RichSectionPageDraw::RichSectionPageDraw(Size dsz, Gate2 progress, int& progress_pos) +: progress(progress) +, progress_pos(progress_pos) +{ + currentpage = -1; + info.Create(drawingsize = dsz); +} + +Draw& RichSectionPageDraw::Page(int page) +{ + if(page != currentpage) { + ASSERT(ddraw.GetCloffLevel() == 0); + progress(progress_pos + page, -1); + if(currentpage >= 0) + pages.At(currentpage) = ddraw; + ddraw.Create(drawingsize); + ddraw.DrawDrawing(drawingsize, pages.At(currentpage = page)); + } + return ddraw; +} + +Draw& RichSectionPageDraw::Info() +{ + return Page(0); +} + +Vector RichSectionPageDraw::Close() +{ + if(currentpage >= 0) { + ASSERT(ddraw.GetCloffLevel() == 0); + pages.At(currentpage) = ddraw; + } + return pages; +} + +static String ExpandHFText(const char *text, int pageno) +{ + String out; + for(char c; c = *text++;) + if(c == '#') + switch(*text++) { + case 'r': out.Cat(FormatIntRoman(pageno, false)); break; + case 'R': out.Cat(FormatIntRoman(pageno, true)); break; + case 'a': out.Cat(FormatIntAlpha(pageno, false)); break; + case 'A': out.Cat(FormatIntAlpha(pageno, true)); break; + default: text--; out.Cat(FormatInt(pageno)); break; + } + else + out.Cat(c); + return out; +} + +Vector RichPrintSection::Print(Size pagesize, Gate2 progress, int& progress_pos) const +{ + ASSERT(columns > 0); + Size drawingsize = GetTextSize(pagesize); + RichSectionPageDraw spdraw(drawingsize, progress, progress_pos); + PaintInfo paintinfo; + paintinfo.top = PageY(0, 0); + paintinfo.bottom = PageY(32767, 0); + paintinfo.indexentry = Null; + text.Paint(spdraw, drawingsize, paintinfo); + Vector in = spdraw.Close(); + Vector out; + for(int i = 0; i < in.GetCount(); i += columns) { + int pageno = firstpage + out.GetCount(); + DrawingDraw ddraw(pagesize); + Rect pagerect = GetPageRect(pagesize); + for(int c = 0; c < columns && c + i < in.GetCount(); c++) + ddraw.DrawDrawing(GetTextRect(pagesize, c), in[i + c]); + for(int hf = 0; hf < 3; hf++) { + if(!IsNull(header[hf])) { + String s = ExpandHFText(header[hf], pageno); + Size sz = UPP::GetTextSize(s, charformat); + int x; + switch(hf) { + case 0: x = pagerect.left; break; + case 1: x = (pagerect.left + pagerect.right - sz.cx) >> 1; break; + case 2: x = pagerect.right - sz.cx; break; + } + ddraw.DrawText(x, pagerect.top, s, charformat); + } + if(!IsNull(footer[hf])) { + String s = ExpandHFText(footer[hf], pageno); + Size sz = UPP::GetTextSize(s, charformat); + int x; + switch(hf) { + case 0: x = pagerect.left; break; + case 1: x = (pagerect.left + pagerect.right - sz.cx) >> 1; break; + case 2: x = pagerect.right - sz.cx; break; + } + ddraw.DrawText(x, pagerect.bottom - sz.cy, s, charformat); + } + } + out.Add() = ddraw; + } + return out; +} + +String GetLangSuffix(int language = GetCurrentLanguage()) +{ + String lt = LNGAsText(language); + String out; + out << '$' << (char)ToLower(lt[0]) << (char)ToLower(lt[1]) << '-' << (char)ToLower(lt[3]) << (char)ToLower(lt[4]); + return out; +} + +void MakeStdToc(RichText& out, const RichToc& toc, int print_width) +{ + VectorMap< String, ArrayMap > subparts; + String suffix = GetLangSuffix(); + for(int i = 0; i < toc.entries.GetCount(); i++) { + const RichTocEntry& e = toc.entries[i]; + RichPara::Format pfmt = out.GetStyle(out.GetStyleId("Toc" + FormatInt(e.level))).format; + RichPara para; + para.format = pfmt; + WString name = e.text; + String tname = e.topic, subpart; + int th = tname.Find('#'); + if(th >= 0) { + subpart = tname.Mid(th); + tname.Trim(th); + } + tname.Cat(suffix); + Topic tp = GetTopic(tname); + if(!IsNull(name)) + para.Cat(name, pfmt); + else { + if(!IsNull(subpart)) { + int sp = subparts.Find(tname); + if(sp < 0) { + sp = subparts.GetCount(); + ArrayMap& spmap = subparts.Add(tname); + RichText rt = ParseQTF(tp.text); + for(int p = 0; p < rt.GetPartCount(); p++) + if(rt.IsPara(p)) { + RichPara rp = rt.Get(p); +// if(*rp.format.label == '#') + spmap.AddPick("#" + rp.format.label, rp); + } + } + para <<= subparts[sp].Get(subpart, RichPara()); + Array objs; + String packed = para.Pack(para.format, objs); + para.Unpack(packed, objs, pfmt); + } + else if(!IsNull(tp.title)) + para.Cat(FromUtf8(tp.title), pfmt); + } + if(para.part.IsEmpty()) { + pfmt.ink = LtRed(); + pfmt.paper = WhiteGray(); + para.Cat((WString)(tname + subpart), pfmt); + } + para.Cat("\t", pfmt); + para.Cat(FieldTypeVarID(), String().Cat() << tname << subpart << "$page", pfmt); + out.Cat(para); + } + RLOG("MakeStdToc:\n" << AsQTF(out)); +} + +void MakeOnlineToc(RichText& out, const RichToc& toc) +{ + String suffix = GetLangSuffix(); + VectorMap< String, ArrayMap > subparts; + for(int i = 0; i < toc.entries.GetCount(); i++) { + const RichTocEntry& e = toc.entries[i]; + RichPara::Format pfmt = out.GetStyle(out.GetStyleId("Topics" + FormatInt(e.level))).format; + RichPara para; + para.format = pfmt; + WString name = e.text; + String tname = e.topic, subpart; + int th = tname.Find('#'); + if(th >= 0) { + subpart = tname.Mid(th); + tname.Trim(th); + } + tname.Cat(suffix); + Topic tp = GetTopic(tname); + pfmt.link = tname; + if(!IsNull(name)) + para.Cat(name, pfmt); + else { + if(!IsNull(subpart)) { + int sp = subparts.Find(tname); + if(sp < 0) { + sp = subparts.GetCount(); + ArrayMap& spmap = subparts.Add(tname); + RichText rt = ParseQTF(tp.text); + for(int p = 0; p < rt.GetPartCount(); p++) + if(rt.IsPara(p)) { + RichPara rp = rt.Get(p); +// if(*rp.format.label == '#') + spmap.AddPick("#" + rp.format.label, rp); + } + } + para <<= subparts[sp].Get(subpart, RichPara()); + Array objs; + String packed = para.Pack(para.format, objs); + para.Unpack(packed, objs, pfmt); + } + else if(!IsNull(tp.title)) + para.Cat(FromUtf8(tp.title), pfmt); + } + if(para.part.IsEmpty()) { + pfmt.ink = LtRed(); + pfmt.paper = WhiteGray(); + para.Cat((WString)(tname + subpart), pfmt); + } + out.Cat(para); + } + RLOG("MakeOnlineToc:\n" << AsQTF(out)); +} + +void MakeTocTopics(RichText& out, const RichToc& toc) +{ + String suffix = GetLangSuffix(); + VectorMap< String, VectorMap > topic_tocrefs; + for(int i = 0; i < toc.entries.GetCount(); i++) { + String tname = toc.entries[i].topic; + int th = tname.Find('#'); + if(th >= 0) + topic_tocrefs.GetAdd(tname.Left(th)).GetAdd(tname.Mid(th), i); + } + Index done; + for(int i = 0; i < toc.entries.GetCount(); i++) { + const RichTocEntry& e = toc.entries[i]; + WString name = e.text; + String tname = e.topic; + int th = tname.Find('#'); + if(th >= 0) + tname.Trim(th); + int tr = topic_tocrefs.Find(tname); + tname << suffix; + if(done.Find(tname) >= 0) + continue; + done.Add(tname); + Topic tp = GetTopic(tname); + RichPara title_para; + title_para.format = out.GetStyle(out.GetStyleId("Heading" + FormatInt(e.level))).format; + if(IsNull(name) && IsNull(name = FromUtf8(tp.title))) { + name = (WString)tname; + title_para.format.ink = LtRed(); + title_para.format.paper = WhiteGray(); + } + title_para.format.label = tname; + title_para.Cat(name, title_para.format); + out.Cat(title_para); + RichText data = ParseQTF(tp.text); + int pcount = out.GetPartCount(); + out.CatPick(data); + for(int t = pcount; t < out.GetPartCount(); t++) + if(out.IsPara(t)) { + RichPara p = out.Get(t); + String lbl = "#" + p.format.label; + int tx; + if(tr >= 0 && (tx = topic_tocrefs[tr].Find(lbl)) >= 0) { + const RichTocEntry& ex = toc.entries[topic_tocrefs[tr][tx]]; + Array objs; + String pack = p.Pack(p.format, objs); + p.format = out.GetStyle(out.GetStyleId("Heading" + FormatInt(ex.level))).format; + p.Unpack(pack, objs, p.format); + p.format.label = tname + lbl; + out.Set(t, p, out.GetStyles()); + } + } + } +} + +//RichText MakeStdIndex( + +RichBook::RichBook(Size pg) +: page_size(pg) +{ + RichStyle toc1, toc2, toc3, toc4; + RichPara::Tab& t1tab = toc1.format.tab.Add(); + t1tab.pos = pg.cx - 300; + t1tab.align = ALIGN_RIGHT; + t1tab.fillchar = 1; + toc2 = toc3 = toc4 = toc1; + t1tab.fillchar = 0; + + toc1.name = "Toc1"; + (Font&)toc1.format = Arial(90).Bold(); + toc1.format.indent = 100; + toc1.format.before = 100; + toc1.format.number[0] = RichPara::NUMBER_1; + + toc2.name = "Toc2"; + (Font&)toc2.format = Arial(84).Bold(); + toc2.format.indent = 200; + toc2.format.lm = 200; + toc2.format.number[0] = toc2.format.number[1] = RichPara::NUMBER_1; + + toc3.name = "Toc3"; + (Font&)toc3.format = Arial(84); + toc3.format.indent = 300; + toc3.format.lm = 300; + toc3.format.number[0] = toc3.format.number[1] = toc3.format.number[2] = RichPara::NUMBER_1; + + toc4.name = "Toc4"; + toc4.format.number[0] = toc4.format.number[1] = toc4.format.number[2] = toc4.format.number[3] = RichPara::NUMBER_1; + + RichStyle head1, head2, head3, head4; + head1.name = "Heading1"; + (Font&)head1.format = Arial(144).Bold(); + head1.format.newpage = true; + head1.format.before = 300; + head1.format.after = 100; + head1.format.indent = 150; + head1.format.number[0] = RichPara::NUMBER_1; + + head2.name = "Heading2"; + (Font&)head2.format = Arial(120).Bold(); + head2.format.before = 200; + head2.format.after = 100; + head2.format.indent = 200; + head2.format.number[0] = head2.format.number[1] = RichPara::NUMBER_1; + + head3.name = "Heading3"; + (Font&)head3.format = Arial(100).Bold(); + head3.format.before = 100; + head3.format.after = 50; + head3.format.indent = 250; + head3.format.number[0] = head3.format.number[1] = head3.format.number[2] = RichPara::NUMBER_1; + + head4 = head3; + head4.name = "Heading4"; + head4.format.number[0] = head4.format.number[1] = head4.format.number[2] = head4.format.number[3] = RichPara::NUMBER_1; + + default_styles.Add(Uuid::Create(), toc1); + default_styles.Add(Uuid::Create(), toc2); + default_styles.Add(Uuid::Create(), toc3); + default_styles.Add(Uuid::Create(), toc4); + + default_styles.Add(Uuid::Create(), head1); + default_styles.Add(Uuid::Create(), head2); + default_styles.Add(Uuid::Create(), head3); + default_styles.Add(Uuid::Create(), head4); +} + +RichPrintSection& RichBook::AddSection() +{ + RichText init; + init.OverrideStyles(default_styles); + return sections.Add(new RichPrintSection(default_section, init)); +} + +Vector RichBook::Print(Size pagesize, Gate2 progress) +{ + Vector out; + int pos = 0; + + VectorMap vars; + vars.GetAdd("$book") = 1; + bool stable = false; + enum { MAX_PASSES = 10 }; + int pass; + for(pass = 1; !stable && pass <= MAX_PASSES; pass++) { + if(progress(pass, 0)) + throw AbortExc(); + stable = true; + int pageno = 1; + Index chkdup; + for(int s = 0; s < sections.GetCount(); s++) { + RichPrintSection& psec = sections[s]; + if(psec.text.GetPartCount() > 0 && psec.text.IsPara(0)) { + RichPara p0 = psec.text.Get(0); + if(p0.format.newpage) { + p0.format.newpage = false; + psec.text.Set(0, p0, psec.text.GetStyles()); + } + } + Size textsize = psec.GetTextSize(pagesize); + PageY begin; + pageno = Nvl(psec.firstpage, pageno); + psec.text.EvaluateFields(vars); + int numpages = psec.text.GetHeight(textsize).page / psec.columns + 1; + Vector posinfo = psec.text.GetValPos(textsize, RichText::LABELS); + for(int i = 0; i < posinfo.GetCount(); i++) { + String key = posinfo[i].data.ToString() + "$page"; + if(chkdup.Find(key) >= 0) { + if(pass == 1) + RLOG("Duplicate: " << key); + continue; + } + chkdup.Add(key); + int oldpage = vars.Get(key, Value()); + int newpage = pageno + posinfo[i].py.page; + if(newpage != oldpage) { + if(pass > 2) + RLOG("Unstable: " << key << ": " << oldpage << " -> " << newpage); + vars.GetAdd(key) = newpage; + stable = false; + } + } + pageno += numpages; + } + } + for(int i = 0; i < sections.GetCount(); i++) + out.AppendPick(sections[i].Print(pagesize, progress, pos)); +#ifdef _DEBUG + RichText symtext; + Vector order = GetSortOrder(vars.GetKeys()); + for(int o = 0; o < order.GetCount(); o++) { + RichPara para; + para.Cat(NFormat("<%s> %vt", vars.GetKey(order[o]), vars[order[o]]), para.format); + symtext.Cat(para); + } + RichPrintSection symsec(default_section, symtext); + out.AppendPick(symsec.Print(pagesize, progress, pos)); +#endif + return out; +} + +void CreateHelpBook(RichBook& book) +{ + Progress progress(t_("Typesetting page %d...")); + DocReport report; + Vector pages = book.Print(report.GetPageSize(), progress); + progress.SetText(t_("Printing page %d...")); + for(int i = 0; i < pages.GetCount(); i++) { + if(progress.SetCanceled(i, pages.GetCount())) + throw AbortExc(); + if(i) + report.NextPage(); + report.DrawDrawing(pages[i].GetSize(), pages[i]); + } + report.Perform(); +} + +String CreateHelpPDF(RichBook& book) +{ + PdfDraw pdf(210 * 6000 / 254, 297 * 6000 / 254); + Rect margin = Rect(pdf.GetPagePixels()).Deflated(236); + Progress progress(t_("Typesetting...")); + Vector pages = book.Print(margin.Size(), progress); + progress.SetText(t_("Exporting PDF...")); + progress.SetTotal(pages.GetCount()); + for(int i = 0; i < pages.GetCount(); i++) { + if(progress.StepCanceled()) + throw AbortExc(); + pdf.StartPage(); + pdf.DrawDrawing(margin, pages[i]); + pdf.EndPage(); + } + return pdf.Finish(); +} + +String CreateHelpRTF(RichBook& book, byte charset) +{ + RichText richtext; + for(int i = 0; i < book.sections.GetCount(); i++) + richtext.CatPick(book.sections[i].text); + return EncodeRTF(richtext, charset); +} + +RichBookHtml::RichBookHtml() +{ +} + +void RichBookHtml::AddFile(String url, String data) +{ +} + +void RichBookHtml::AddImage(String url, String data) +{ +} + +String RichBookHtml::GetURLFile(String url) const +{ + String out; + return out; +} + +void CreateHelpHtml(RichBook& book, RichBookHtml& html) +{ +} + +GLOBAL_VAR(Callback1, DefaultBook) + +void CreateDefaultBook() +{ + RichBook book; + DefaultBook()(book); + CreateHelpBook(book); +} + +void CreateDefaultPDF() +{ + RichBook book; + DefaultBook()(book); + try { + String data = CreateHelpPDF(book); + FileSelector fsel; + fsel.Type(t_("PDF documents (*.pdf)"), "*.pdf") + .DefaultExt("pdf") + .AllFilesType(); + static String recent; + fsel <<= recent; + if(fsel.ExecuteSaveAs(t_("PDF export"))) { + recent = ~fsel; + if(!SaveFile(recent, data)) + throw Exc(NFormat("Error saving file '%s' (%d B).", recent, data.GetLength())); + } + } + catch(Exc e) { + ShowExc(e); + } +} + +void CreateDefaultRTF() +{ + RichBook book; + DefaultBook()(book); + try { + String data = CreateHelpRTF(book, GetDefaultCharset()); + FileSelector fsel; + fsel.Type(t_("Rich text documents (*.rtf)"), "*.rtf") + .DefaultExt("rtf") + .AllFilesType(); + static String recent; + fsel <<= recent; + if(fsel.ExecuteSaveAs(t_("Save manual as"))) { + recent = ~fsel; + if(!SaveFile(recent, data)) + throw Exc(NFormat("Error saving file '%s' (%d B).", recent, data.GetLength())); + } + } + catch(Exc e) { + ShowExc(e); + } +} + +void CreateDefaultHTML() +{ + RichBook book; + DefaultBook()(book); + try { + RichBookHtml html; + CreateHelpHtml(book, html); + } + catch(Exc e) { + ShowExc(e); + } +} + +void ManualMenu() +{ + MenuBar menu; + bool isdb = DefaultBook(); + menu.Add(isdb, t_("Print manual"), callback(&CreateDefaultBook)); + menu.Add(isdb, t_("PDF export"), callback(&CreateDefaultPDF)); + menu.Add(isdb, t_("RTF export"), callback(&CreateDefaultRTF)); + menu.Add(isdb, t_("HTML export"), callback(&CreateDefaultHTML)); + menu.Execute(); +} + +void HelpBookMenu(Bar& bar) +{ + bar.Add(t_("Save manual"), CtrlImg::save(), callback(&ManualMenu)); +} + +} diff --git a/uppsrc/RichBook/RichBook.h b/archive/RichBook/RichBook.h similarity index 96% rename from uppsrc/RichBook/RichBook.h rename to archive/RichBook/RichBook.h index 63630b6f7..15d9a96a3 100644 --- a/uppsrc/RichBook/RichBook.h +++ b/archive/RichBook/RichBook.h @@ -1,134 +1,134 @@ -#ifndef _RichBook_RichBook_h -#define _RichBook_RichBook_h - -#include - -namespace Upp { - -RichPara::FieldType& FieldTypeVar(); -Id FieldTypeVarID(); - -class RichIndexEntry : DeepCopyOption -{ -public: - RichIndexEntry() {} - RichIndexEntry(const RichIndexEntry& rti, bool deep) : reflist(rti.reflist, deep) {} - -public: - Vector reflist; -}; - -RichPara::FieldType& FieldTypeIndexEntry(); -Id FieldTypeIndexEntryID(); -String EncodeIndexEntry(const RichIndexEntry& idx); -RichIndexEntry DecodeIndexEntry(String encoded_indexentry); - -class RichBookSection { -public: - RichBookSection(); - - Rect GetPageRect(Size pagesize) const; - Rect GetTextRect(Size pagesize, int columnindex) const; - Size GetTextSize(Size pagesize) const; - -public: - bool nested; - int columns; - int firstpage; - Rect margin; - int header_space; - int footer_space; - int column_space; - String header[3], footer[3]; - RichPara::CharFormat charformat; -}; - -class RichPrintSection : public RichBookSection { -public: - RichPrintSection(const RichBookSection& s, pick_ RichText& t) - : RichBookSection(s), text(t) {} - - Vector Print(Size pagesize, Gate2 progress, int& progress_pos) const; - -public: - RichText text; -}; - -class RichTocEntry { -public: - RichTocEntry(String topic = Null, int level = 1, bool numbered = true, bool appendix = false, WString text = Null) - : topic(topic), level(level), numbered(numbered), text(text) {} - - String topic; - int level; - bool numbered; - bool appendix; - WString text; -}; - -class RichToc : DeepCopyOption { -public: - RichToc() {} - RichToc(const RichToc& rtoc, int deep) : entries(rtoc.entries, deep) {} - - void Add(String topic, int level, bool numbered = true, bool appendix = false, WString text = Null) - { entries.Add(new RichTocEntry(topic, level, numbered, appendix, text)); } - - Array entries; -}; - -void MakeOnlineToc(RichText& out, const RichToc& toc); -void MakeStdToc(RichText& out, const RichToc& toc, int print_width); -void MakeTocTopics(RichText& out, const RichToc& toc); -//RichText MakeStdIndex( - -class RichBook { -public: - RichBook(Size page_size = Size(3968, 6074)); - - RichPrintSection& AddSection(); - - Vector Print(Size pagesize, Gate2 progress); - -public: - Size page_size; - RichBookSection default_section; - RichStyles default_styles; - enum { TOC_DEPTH = 4 }; - Array sections; -}; - -void CreateHelpBook(RichBook& book); -String CreateHelpPDF(RichBook& book); -String CreateHelpRTF(RichBook& book, byte charset); - -class RichBookHtml { -public: - RichBookHtml(); - - void AddFile(String url, String data); - void AddImage(String url, String data); - String GetURLFile(String url) const; - -public: - String output_path; - enum { STYLE_DEEP, STYLE_FLAT, STYLE_ONEFILE }; - int style; - VectorMap files; - VectorMap images; -}; - -void CreateHelpHtml(const RichBook& book, RichBookHtml& html); - -Callback1& DefaultBook(); - -void CreateDefaultBook(); -void CreateDefaultPDF(); -void CreateDefaultRTF(); -void CreateDefaultHTML(); - -void HelpBookMenu(Bar& bar); - -} - -#endif +#ifndef _RichBook_RichBook_h +#define _RichBook_RichBook_h + +#include + +namespace Upp { + +RichPara::FieldType& FieldTypeVar(); +Id FieldTypeVarID(); + +class RichIndexEntry : DeepCopyOption +{ +public: + RichIndexEntry() {} + RichIndexEntry(const RichIndexEntry& rti, bool deep) : reflist(rti.reflist, deep) {} + +public: + Vector reflist; +}; + +RichPara::FieldType& FieldTypeIndexEntry(); +Id FieldTypeIndexEntryID(); +String EncodeIndexEntry(const RichIndexEntry& idx); +RichIndexEntry DecodeIndexEntry(String encoded_indexentry); + +class RichBookSection { +public: + RichBookSection(); + + Rect GetPageRect(Size pagesize) const; + Rect GetTextRect(Size pagesize, int columnindex) const; + Size GetTextSize(Size pagesize) const; + +public: + bool nested; + int columns; + int firstpage; + Rect margin; + int header_space; + int footer_space; + int column_space; + String header[3], footer[3]; + RichPara::CharFormat charformat; +}; + +class RichPrintSection : public RichBookSection { +public: + RichPrintSection(const RichBookSection& s, pick_ RichText& t) + : RichBookSection(s), text(t) {} + + Vector Print(Size pagesize, Gate2 progress, int& progress_pos) const; + +public: + RichText text; +}; + +class RichTocEntry { +public: + RichTocEntry(String topic = Null, int level = 1, bool numbered = true, bool appendix = false, WString text = Null) + : topic(topic), level(level), numbered(numbered), text(text) {} + + String topic; + int level; + bool numbered; + bool appendix; + WString text; +}; + +class RichToc : DeepCopyOption { +public: + RichToc() {} + RichToc(const RichToc& rtoc, int deep) : entries(rtoc.entries, deep) {} + + void Add(String topic, int level, bool numbered = true, bool appendix = false, WString text = Null) + { entries.Add(new RichTocEntry(topic, level, numbered, appendix, text)); } + + Array entries; +}; + +void MakeOnlineToc(RichText& out, const RichToc& toc); +void MakeStdToc(RichText& out, const RichToc& toc, int print_width); +void MakeTocTopics(RichText& out, const RichToc& toc); +//RichText MakeStdIndex( + +class RichBook { +public: + RichBook(Size page_size = Size(3968, 6074)); + + RichPrintSection& AddSection(); + + Vector Print(Size pagesize, Gate2 progress); + +public: + Size page_size; + RichBookSection default_section; + RichStyles default_styles; + enum { TOC_DEPTH = 4 }; + Array sections; +}; + +void CreateHelpBook(RichBook& book); +String CreateHelpPDF(RichBook& book); +String CreateHelpRTF(RichBook& book, byte charset); + +class RichBookHtml { +public: + RichBookHtml(); + + void AddFile(String url, String data); + void AddImage(String url, String data); + String GetURLFile(String url) const; + +public: + String output_path; + enum { STYLE_DEEP, STYLE_FLAT, STYLE_ONEFILE }; + int style; + VectorMap files; + VectorMap images; +}; + +void CreateHelpHtml(const RichBook& book, RichBookHtml& html); + +Callback1& DefaultBook(); + +void CreateDefaultBook(); +void CreateDefaultPDF(); +void CreateDefaultRTF(); +void CreateDefaultHTML(); + +void HelpBookMenu(Bar& bar); + +} + +#endif diff --git a/uppsrc/RichBook/RichBook.t b/archive/RichBook/RichBook.t similarity index 94% rename from uppsrc/RichBook/RichBook.t rename to archive/RichBook/RichBook.t index 1be4fc304..2bfa537ab 100644 --- a/uppsrc/RichBook/RichBook.t +++ b/archive/RichBook/RichBook.t @@ -1,38 +1,38 @@ - -// RichBook.cpp - -T_("Typesetting page %d...") -csCZ("Sázím stranu %d...") - -T_("Printing page %d...") -csCZ("Tisknu stranu %d...") - -T_("Typesetting...") -csCZ("Sázím...") - -T_("Exporting PDF...") -csCZ("Exportuji PDF...") - -T_("PDF documents (*.pdf)") -csCZ("Dokumenty PDF (*.pdf)") - -T_("PDF export") -csCZ("Export PDF") - -T_("Rich text documents (*.rtf)") -csCZ("Dokumenty Rich text (*.rtf)") - -T_("Save manual as") -csCZ("Uložit příručku jako") - -T_("Print manual") -csCZ("Tisk příručky") - -T_("RTF export") -csCZ("Export do RTF") - -T_("HTML export") -csCZ("Export do HTML") - -T_("Save manual") -csCZ("Uložit příručku") + +// RichBook.cpp + +T_("Typesetting page %d...") +csCZ("Sázím stranu %d...") + +T_("Printing page %d...") +csCZ("Tisknu stranu %d...") + +T_("Typesetting...") +csCZ("Sázím...") + +T_("Exporting PDF...") +csCZ("Exportuji PDF...") + +T_("PDF documents (*.pdf)") +csCZ("Dokumenty PDF (*.pdf)") + +T_("PDF export") +csCZ("Export PDF") + +T_("Rich text documents (*.rtf)") +csCZ("Dokumenty Rich text (*.rtf)") + +T_("Save manual as") +csCZ("Uložit příručku jako") + +T_("Print manual") +csCZ("Tisk příručky") + +T_("RTF export") +csCZ("Export do RTF") + +T_("HTML export") +csCZ("Export do HTML") + +T_("Save manual") +csCZ("Uložit příručku") diff --git a/uppsrc/RichBook/RichBook.upp b/archive/RichBook/RichBook.upp similarity index 91% rename from uppsrc/RichBook/RichBook.upp rename to archive/RichBook/RichBook.upp index be67ca334..1434e3afc 100644 --- a/uppsrc/RichBook/RichBook.upp +++ b/archive/RichBook/RichBook.upp @@ -1,9 +1,9 @@ -uses - RichText, - CtrlLib; - -file - RichBook.h, - RichBook_init.icpp, - RichBook.t, - RichBook.cpp; +uses + RichText, + CtrlLib; + +file + RichBook.h, + RichBook_init.icpp, + RichBook.t, + RichBook.cpp; diff --git a/uppsrc/RichBook/RichBook_init.icpp b/archive/RichBook/RichBook_init.icpp similarity index 92% rename from uppsrc/RichBook/RichBook_init.icpp rename to archive/RichBook/RichBook_init.icpp index 96e3c053e..cad4d0d72 100644 --- a/uppsrc/RichBook/RichBook_init.icpp +++ b/archive/RichBook/RichBook_init.icpp @@ -1,8 +1,8 @@ -#include "RichBook.h" - -namespace Upp { - -#define TFILE -#include - -} +#include "RichBook.h" + +namespace Upp { + +#define TFILE +#include + +} diff --git a/uppsrc/PaintGL/Copying b/archive/uppsrc/Docedit/Copying similarity index 100% rename from uppsrc/PaintGL/Copying rename to archive/uppsrc/Docedit/Copying diff --git a/uppsrc/Docedit/DocItem.cpp b/archive/uppsrc/Docedit/DocItem.cpp similarity index 95% rename from uppsrc/Docedit/DocItem.cpp rename to archive/uppsrc/Docedit/DocItem.cpp index 42b181199..f74185469 100644 --- a/uppsrc/Docedit/DocItem.cpp +++ b/archive/uppsrc/Docedit/DocItem.cpp @@ -1,346 +1,346 @@ -#include "Docedit.h" - -#define IMAGECLASS DppImg -#define IMAGEFILE -#include - -bool IsCppKeyword(const String& id) -{ - static Index kw; - if(kw.GetCount() == 0) - for(int i = 0; CppKeyword[i]; i++) - kw.Add(CppKeyword[i]); - return kw.Find(id) >= 0; -} - -void DocItemDisplay::Paint(Draw& w, const Rect& r, const Value& q, - Color _ink, Color paper, dword style) const -{ - ValueArray va = q; - String txt = va.Get(0); - String name = va.Get(1); - int kind = va.Get(2); - int access = va.Get(3); - int status = va.Get(4); - String pname = va.Get(5); - String tname = va.Get(6); - Color c = Color(230, 255, 230); - switch(status) { - case DocDir::IGNORED: c = SGray; break; - case DocDir::OBSOLETELINK: - case DocDir::OBSOLETE: c = SLtRed; break; - case DocDir::UNDOCUMENTED: c = paper; break; - } - w.DrawRect(r, style & (FOCUS|CURSOR) ? paper : c); - if(IsNull(q)) return; - int x0 = r.left; - if(access == PROTECTED) - w.DrawImage(x0, r.top + 1, DppImg::Protected()); - x0 += 6; - Image img = DppImg::Other(); - switch(kind) { - case FUNCTION: - img = DppImg::Function(); - break; - case INSTANCEFUNCTION: - img = DppImg::InstanceFunction(); - break; - case CLASSFUNCTION: - img = DppImg::ClassFunction(); - break; - case FUNCTIONTEMPLATE: - img = DppImg::FunctionTemplate(); - break; - case INSTANCEFUNCTIONTEMPLATE: - img = DppImg::InstanceFunctionTemplate(); - break; - case CLASSFUNCTIONTEMPLATE: - img = DppImg::ClassFunctionTemplate(); - break; - case STRUCT: - img = DppImg::Struct(); - break; - case STRUCTTEMPLATE: - img = DppImg::StructTemplate(); - break; - case INSTANCEVARIABLE: - img = DppImg::InstanceVariable(); - break; - case CLASSVARIABLE: - img = DppImg::ClassVariable(); - break; - case VARIABLE: - img = DppImg::Variable(); - break; - case ENUM: - img = DppImg::Enum(); - break; - case INLINEFRIEND: - img = DppImg::InlineFriend(); - break; - case TYPEDEF: - img = DppImg::Typedef(); - break; - case CONSTRUCTOR: - img = DppImg::Constructor(); - break; - case DESTRUCTOR: - img = DppImg::Destructor(); - break; - case MACRO: - img = DppImg::Macro(); - break; - } - if(style & (CURSOR|FOCUS)) - DrawHighlightImage(w, x0, r.top + 1, img); - else - w.DrawImage(x0, r.top + 1, img); - x0 += 20; - int x = x0; - int y = r.top + 2; - const char *s = txt; - while(*s && y < r.bottom) { - Font f = Arial(11); - Color ink = SBlack; - int n = 1; - if(*s >= '0' && *s <= '9') { - while(s[n] >= '0' && s[n] <= '9') - n++; - ink = SRed; - } - else - if(iscid(*s)) { - if(strncmp(s, name, name.GetLength()) == 0 && !iscid(s[name.GetLength()])) { - f = Arial(11).Bold(); - n = name.GetLength(); - name.Clear(); - } - else { - String id; - n = 0; - while(IsAlNum(s[n]) || s[n] == '_') { - id.Cat(s[n]); - n++; - } - if(IsCppKeyword(id)) - ink = SLtBlue; - else - if(InScList(id, pname)) { - ink = SRed; - f = Arial(11).Bold(); - } - else - if(InScList(id, tname)) { - ink = SGreen; - f = Arial(11).Bold(); - } - } - } - else - ink = SMagenta; - if(style & (CURSOR|FOCUS)) ink = _ink; - Size fsz = w.GetTextSize(s, f, n); - if(x + fsz.cx >= r.right && fsz.cx < r.Width()) { - if(x0 + 70 < r.right) - x = x0 + 24; - else - x = x0; - y += fsz.cy; - } - w.DrawText(x, y, s, f, ink, n); - x += fsz.cx; - s += n; - } -} - -void DocNestDisplay::Paint(Draw& w, const Rect& r, const Value& q, - Color _ink, Color paper, dword style) const -{ - String text = q; - w.DrawRect(r, paper); - if(IsNull(text)) { - w.DrawText(r.left, r.top, "Globals", Arial(11).Bold().Italic(), - style & (CURSOR|FOCUS) ? _ink : SBlue); - return; - } - int x = r.left; - int y = r.top; - const char *s = text; - Font idf = Arial(11).Bold(); - Color idink = SBlack; - while(*s && y < r.bottom) { - Font f = Arial(11); - Color ink = SBlack; - int n = 1; - if(*s >= '0' && *s <= '9') { - while(s[n] >= '0' && s[n] <= '9') - n++; - ink = SRed; - } - else - if(iscid(*s)) { - String id; - n = 0; - while(IsAlNum(s[n]) || s[n] == '_') { - id.Cat(s[n]); - n++; - } - if(IsCppKeyword(id)) { - ink = SLtBlue; - if(id == "class" || id == "typename") - idink = SGreen; - } - else { - ink = idink; - f = idf; - idink = SBlack; - idf = Arial(11); - } - } - else { - ink = SMagenta; - if(*s == ':') { - idf = Arial(11).Bold(); - idink = SBlack; - } - } - if(style & (CURSOR|FOCUS)) ink = _ink; - Size fsz = w.GetTextSize(s, f, n); - w.DrawText(x, y, s, f, ink, n); - x += fsz.cx; - s += n; - } -} - -int GetItemHeight(const String& txt, const String& nm, const String& pname, - const String& tname, int cx) -{ - String name = nm; - int x = 26; - int y = ScreenInfo().GetFontInfo(Arial(11)).GetHeight() + 3; - const char *s = txt; - while(*s) { - Font f = Arial(11); - int n = 1; - if(*s >= '0' && *s <= '9') - while(s[n] >= '0' && s[n] <= '9') - n++; - else - if(iscid(*s)) { - if(strncmp(s, name, name.GetLength()) == 0 && !iscid(s[name.GetLength()])) { - f = Arial(11).Bold(); - n = name.GetLength(); - name.Clear(); - } - else { - String id; - n = 0; - while(IsAlNum(s[n]) || s[n] == '_') { - id.Cat(s[n]); - n++; - } - if(!IsCppKeyword(id) && InScList(id, pname) || InScList(id, tname)) - f = Arial(11).Bold(); - } - } - Size fsz = ScreenInfo().GetTextSize(s, f, n); - if(x + fsz.cx >= cx && fsz.cx < cx) { - if(26 + 70 < cx) - x = 26 + 24; - else - x = 26; - y += fsz.cy; - } - x += fsz.cx; - s += n; - } - return y; -} - -void InitItemArray(ArrayCtrl& item) -{ - item.NoHeader(); - item.AddIndex(); - item.AddIndex().Accel(); - item.AddIndex(); - item.AddIndex(); - item.AddIndex(); - item.AddIndex(); - item.AddIndex(); - item.AddIndex(); - item.AddIndex(); - item.AddColumnAt(0, "").Add(1).Add(2).Add(3).Add(4).Add(5).Add(6).Add(7).Add(8) - .SetDisplay(Single()).Accel().HeaderTab().SetMargin(0); - item.HeaderObject().Tab(0).SetMargin(0); -} - -void LoadItems(const DocSet& set, const String& nameing, const String& nesting, ArrayCtrl& item) -{ - const ArrayMap& nt = set.Get(~nameing).Get(nesting); - item.Clear(); - int cx = item.HeaderObject().GetTabWidth(0) - 2 * item.HeaderObject().Tab(0).GetMargin(); - for(int i = 0; i < nt.GetCount(); i++) { - const DocItem& im = nt[i]; - if(im.cppitem) { - item.Add(nt.GetKey(i), im.cppitem->name, im.cppitem->kind, im.cppitem->access, - im.status, im.cppitem->pname, im.cppitem->tname, - im.package, im.cppitem->file, im.cppitem->line); - item.SetLineCy(item.GetCount() - 1, - GetItemHeight(nt.GetKey(i), im.cppitem->name, - im.cppitem->pname, im.cppitem->tname, cx)); - } - else { - item.Add(nt.GetKey(i), Null, Null, Null, im.status, Null, Null, im.package, - Null, Null); - item.SetLineCy(item.GetCount() - 1, - GetItemHeight(nt.GetKey(i), Null, Null, Null, cx)); - } - } -} - -int ByOrder(int a1, int a2, int *order) -{ - if(a1 == a2) return 0; - while(*order != -1) { - if(a1 == *order) return -1; - if(a2 == *order) return 1; - order++; - } - return 0; -} - -int CompareItems(const Vector& row1, const Vector& row2) -{ - int q; - int status_order[] = { - STATUS_UNDOCUMENTED, STATUS_OBSOLETE, STATUS_IGNORED, STATUS_EXTERNAL, STATUS_NORMAL, - -1 - }; - int kind1 = row1[2]; - int kind2 = row2[2]; - if(kind1 != STRUCT && kind2 != STRUCT && kind1 != STRUCTTEMPLATE && kind2 != STRUCTTEMPLATE) { - q = (int)row2[3] - (int)row1[3]; - if(q) return q; - q = ByOrder(row1[4], row2[4], status_order); - if(q) return q; - } - int kind_order[] = { - STRUCT, STRUCTTEMPLATE, - MACRO, - CONSTRUCTOR, DESTRUCTOR, - ENUM, TYPEDEF, - INSTANCEFUNCTION, CLASSFUNCTION, INLINEFRIEND, - INSTANCEVARIABLE, CLASSVARIABLE, - INSTANCEFUNCTION, INSTANCEVARIABLE, - VARIABLE, FUNCTION, FUNCTIONTEMPLATE, - -1 - }; - q = ByOrder(kind1, kind2, kind_order); - if(q) return q; - return strcmp((String)row1[1], (String)row2[1]); -} - -int CompareNests(const Value& v1, const Value& v2) -{ - return strcmp(String(v1), String(v2)); -} +#include "Docedit.h" + +#define IMAGECLASS DppImg +#define IMAGEFILE +#include + +bool IsCppKeyword(const String& id) +{ + static Index kw; + if(kw.GetCount() == 0) + for(int i = 0; CppKeyword[i]; i++) + kw.Add(CppKeyword[i]); + return kw.Find(id) >= 0; +} + +void DocItemDisplay::Paint(Draw& w, const Rect& r, const Value& q, + Color _ink, Color paper, dword style) const +{ + ValueArray va = q; + String txt = va.Get(0); + String name = va.Get(1); + int kind = va.Get(2); + int access = va.Get(3); + int status = va.Get(4); + String pname = va.Get(5); + String tname = va.Get(6); + Color c = Color(230, 255, 230); + switch(status) { + case DocDir::IGNORED: c = SGray; break; + case DocDir::OBSOLETELINK: + case DocDir::OBSOLETE: c = SLtRed; break; + case DocDir::UNDOCUMENTED: c = paper; break; + } + w.DrawRect(r, style & (FOCUS|CURSOR) ? paper : c); + if(IsNull(q)) return; + int x0 = r.left; + if(access == PROTECTED) + w.DrawImage(x0, r.top + 1, DppImg::Protected()); + x0 += 6; + Image img = DppImg::Other(); + switch(kind) { + case FUNCTION: + img = DppImg::Function(); + break; + case INSTANCEFUNCTION: + img = DppImg::InstanceFunction(); + break; + case CLASSFUNCTION: + img = DppImg::ClassFunction(); + break; + case FUNCTIONTEMPLATE: + img = DppImg::FunctionTemplate(); + break; + case INSTANCEFUNCTIONTEMPLATE: + img = DppImg::InstanceFunctionTemplate(); + break; + case CLASSFUNCTIONTEMPLATE: + img = DppImg::ClassFunctionTemplate(); + break; + case STRUCT: + img = DppImg::Struct(); + break; + case STRUCTTEMPLATE: + img = DppImg::StructTemplate(); + break; + case INSTANCEVARIABLE: + img = DppImg::InstanceVariable(); + break; + case CLASSVARIABLE: + img = DppImg::ClassVariable(); + break; + case VARIABLE: + img = DppImg::Variable(); + break; + case ENUM: + img = DppImg::Enum(); + break; + case INLINEFRIEND: + img = DppImg::InlineFriend(); + break; + case TYPEDEF: + img = DppImg::Typedef(); + break; + case CONSTRUCTOR: + img = DppImg::Constructor(); + break; + case DESTRUCTOR: + img = DppImg::Destructor(); + break; + case MACRO: + img = DppImg::Macro(); + break; + } + if(style & (CURSOR|FOCUS)) + DrawHighlightImage(w, x0, r.top + 1, img); + else + w.DrawImage(x0, r.top + 1, img); + x0 += 20; + int x = x0; + int y = r.top + 2; + const char *s = txt; + while(*s && y < r.bottom) { + Font f = Arial(11); + Color ink = SBlack; + int n = 1; + if(*s >= '0' && *s <= '9') { + while(s[n] >= '0' && s[n] <= '9') + n++; + ink = SRed; + } + else + if(iscid(*s)) { + if(strncmp(s, name, name.GetLength()) == 0 && !iscid(s[name.GetLength()])) { + f = Arial(11).Bold(); + n = name.GetLength(); + name.Clear(); + } + else { + String id; + n = 0; + while(IsAlNum(s[n]) || s[n] == '_') { + id.Cat(s[n]); + n++; + } + if(IsCppKeyword(id)) + ink = SLtBlue; + else + if(InScList(id, pname)) { + ink = SRed; + f = Arial(11).Bold(); + } + else + if(InScList(id, tname)) { + ink = SGreen; + f = Arial(11).Bold(); + } + } + } + else + ink = SMagenta; + if(style & (CURSOR|FOCUS)) ink = _ink; + Size fsz = w.GetTextSize(s, f, n); + if(x + fsz.cx >= r.right && fsz.cx < r.Width()) { + if(x0 + 70 < r.right) + x = x0 + 24; + else + x = x0; + y += fsz.cy; + } + w.DrawText(x, y, s, f, ink, n); + x += fsz.cx; + s += n; + } +} + +void DocNestDisplay::Paint(Draw& w, const Rect& r, const Value& q, + Color _ink, Color paper, dword style) const +{ + String text = q; + w.DrawRect(r, paper); + if(IsNull(text)) { + w.DrawText(r.left, r.top, "Globals", Arial(11).Bold().Italic(), + style & (CURSOR|FOCUS) ? _ink : SBlue); + return; + } + int x = r.left; + int y = r.top; + const char *s = text; + Font idf = Arial(11).Bold(); + Color idink = SBlack; + while(*s && y < r.bottom) { + Font f = Arial(11); + Color ink = SBlack; + int n = 1; + if(*s >= '0' && *s <= '9') { + while(s[n] >= '0' && s[n] <= '9') + n++; + ink = SRed; + } + else + if(iscid(*s)) { + String id; + n = 0; + while(IsAlNum(s[n]) || s[n] == '_') { + id.Cat(s[n]); + n++; + } + if(IsCppKeyword(id)) { + ink = SLtBlue; + if(id == "class" || id == "typename") + idink = SGreen; + } + else { + ink = idink; + f = idf; + idink = SBlack; + idf = Arial(11); + } + } + else { + ink = SMagenta; + if(*s == ':') { + idf = Arial(11).Bold(); + idink = SBlack; + } + } + if(style & (CURSOR|FOCUS)) ink = _ink; + Size fsz = w.GetTextSize(s, f, n); + w.DrawText(x, y, s, f, ink, n); + x += fsz.cx; + s += n; + } +} + +int GetItemHeight(const String& txt, const String& nm, const String& pname, + const String& tname, int cx) +{ + String name = nm; + int x = 26; + int y = ScreenInfo().GetFontInfo(Arial(11)).GetHeight() + 3; + const char *s = txt; + while(*s) { + Font f = Arial(11); + int n = 1; + if(*s >= '0' && *s <= '9') + while(s[n] >= '0' && s[n] <= '9') + n++; + else + if(iscid(*s)) { + if(strncmp(s, name, name.GetLength()) == 0 && !iscid(s[name.GetLength()])) { + f = Arial(11).Bold(); + n = name.GetLength(); + name.Clear(); + } + else { + String id; + n = 0; + while(IsAlNum(s[n]) || s[n] == '_') { + id.Cat(s[n]); + n++; + } + if(!IsCppKeyword(id) && InScList(id, pname) || InScList(id, tname)) + f = Arial(11).Bold(); + } + } + Size fsz = ScreenInfo().GetTextSize(s, f, n); + if(x + fsz.cx >= cx && fsz.cx < cx) { + if(26 + 70 < cx) + x = 26 + 24; + else + x = 26; + y += fsz.cy; + } + x += fsz.cx; + s += n; + } + return y; +} + +void InitItemArray(ArrayCtrl& item) +{ + item.NoHeader(); + item.AddIndex(); + item.AddIndex().Accel(); + item.AddIndex(); + item.AddIndex(); + item.AddIndex(); + item.AddIndex(); + item.AddIndex(); + item.AddIndex(); + item.AddIndex(); + item.AddColumnAt(0, "").Add(1).Add(2).Add(3).Add(4).Add(5).Add(6).Add(7).Add(8) + .SetDisplay(Single()).Accel().HeaderTab().SetMargin(0); + item.HeaderObject().Tab(0).SetMargin(0); +} + +void LoadItems(const DocSet& set, const String& nameing, const String& nesting, ArrayCtrl& item) +{ + const ArrayMap& nt = set.Get(~nameing).Get(nesting); + item.Clear(); + int cx = item.HeaderObject().GetTabWidth(0) - 2 * item.HeaderObject().Tab(0).GetMargin(); + for(int i = 0; i < nt.GetCount(); i++) { + const DocItem& im = nt[i]; + if(im.cppitem) { + item.Add(nt.GetKey(i), im.cppitem->name, im.cppitem->kind, im.cppitem->access, + im.status, im.cppitem->pname, im.cppitem->tname, + im.package, im.cppitem->file, im.cppitem->line); + item.SetLineCy(item.GetCount() - 1, + GetItemHeight(nt.GetKey(i), im.cppitem->name, + im.cppitem->pname, im.cppitem->tname, cx)); + } + else { + item.Add(nt.GetKey(i), Null, Null, Null, im.status, Null, Null, im.package, + Null, Null); + item.SetLineCy(item.GetCount() - 1, + GetItemHeight(nt.GetKey(i), Null, Null, Null, cx)); + } + } +} + +int ByOrder(int a1, int a2, int *order) +{ + if(a1 == a2) return 0; + while(*order != -1) { + if(a1 == *order) return -1; + if(a2 == *order) return 1; + order++; + } + return 0; +} + +int CompareItems(const Vector& row1, const Vector& row2) +{ + int q; + int status_order[] = { + STATUS_UNDOCUMENTED, STATUS_OBSOLETE, STATUS_IGNORED, STATUS_EXTERNAL, STATUS_NORMAL, + -1 + }; + int kind1 = row1[2]; + int kind2 = row2[2]; + if(kind1 != STRUCT && kind2 != STRUCT && kind1 != STRUCTTEMPLATE && kind2 != STRUCTTEMPLATE) { + q = (int)row2[3] - (int)row1[3]; + if(q) return q; + q = ByOrder(row1[4], row2[4], status_order); + if(q) return q; + } + int kind_order[] = { + STRUCT, STRUCTTEMPLATE, + MACRO, + CONSTRUCTOR, DESTRUCTOR, + ENUM, TYPEDEF, + INSTANCEFUNCTION, CLASSFUNCTION, INLINEFRIEND, + INSTANCEVARIABLE, CLASSVARIABLE, + INSTANCEFUNCTION, INSTANCEVARIABLE, + VARIABLE, FUNCTION, FUNCTIONTEMPLATE, + -1 + }; + q = ByOrder(kind1, kind2, kind_order); + if(q) return q; + return strcmp((String)row1[1], (String)row2[1]); +} + +int CompareNests(const Value& v1, const Value& v2) +{ + return strcmp(String(v1), String(v2)); +} diff --git a/uppsrc/Docedit/DocLink.cpp b/archive/uppsrc/Docedit/DocLink.cpp similarity index 95% rename from uppsrc/Docedit/DocLink.cpp rename to archive/uppsrc/Docedit/DocLink.cpp index 0d27dd0a3..4624c1fae 100644 --- a/uppsrc/Docedit/DocLink.cpp +++ b/archive/uppsrc/Docedit/DocLink.cpp @@ -1,114 +1,114 @@ -#include "Docedit.h" - -void DocLinkDlg::Nameing() -{ - nesting.Clear(); - if(IsNull(nameing)) { - Nesting(); - return; - } - const VectorMap >& ns = set->Get(~nameing); - nesting.Clear(); - for(int i = 0; i < ns.GetCount(); i++) - nesting.Add(ns.GetKey(i)); - nesting.Sort(0, CompareNests); - nesting.GoBegin(); - Nesting(); -} - -void DocLinkDlg::Nesting() -{ - item.Clear(); - if(!nesting.IsCursor()) { - Item(); - return; - } - LoadItems(*set, ~nameing, nesting.GetKey(), item); - if(sort) - item.Sort(CompareItems); - item.GoBegin(); -} - -String DocLinkDlg::Get() -{ - return "dpp://" + String(~nameing) + "/" + String(nesting.GetKey()) + "/" - + String(item.GetKey()); -} - -void DocLinkDlg::Item() -{ - link <<= Get(); - String s = doc_dir.GetText(DocKey(~nameing, nesting.GetKey(), item.GetKey(), lang)); - label.KillCursor(); - label.Clear(); - label.Disable(); - if(IsNull(s)) return; - Array pi = ParseQTF(s).GetPosInfo(Rect(0, 0, 5000, 5000), PageY()); - for(int i = 0; i < pi.GetCount(); i++) - if(pi[i].type == RichPosInfo::LABEL) - label.Add(FromUnicode(pi[i].data, CHARSET_WIN1252)); - if(label.GetCount()) - label.Enable(); -} - -void DocLinkDlg::Label() -{ - if(label.IsCursor()) - link <<= Get() + "#" + String(label.GetKey()); -} - -bool DocLinkDlg::Perform(const DocSet& _set, bool _sort, String& _link, dword _lang, - const String& _nameing, const String& _nesting) -{ - lang = _lang; - set = &_set; - sort = _sort; - nameing.Clear(); - for(int i = 0; i < _set.GetCount(); i++) - nameing.Add(_set.GetKey(i)); - if(nameing.GetCount()) - nameing.SetIndex(0); - if(!IsNull(_nameing) && nameing.HasKey(_nameing)) - nameing <<= _nameing; - Nameing(); - if(!IsNull(_nesting)) - nesting.FindSetCursor(_nesting); - link <<= _link; - link.SetFocus(); - if(Execute() == IDOK) { - link.AddHistory(); - _link = link; - return true; - } - return false; -} - -DocLinkDlg::DocLinkDlg() -{ - CtrlLayoutOKCancel(*this, "Link"); - nesting.AddColumn().SetDisplay(Single()); - nesting.NoHeader().NoGrid(); - nameing <<= THISBACK(Nameing); - nesting.WhenEnterRow = THISBACK(Nesting); - InitItemArray(item); - item.WhenLeftClick = THISBACK(Item); - label.NoHeader().NoGrid(); - label.AddColumn(); - label.WhenLeftClick = THISBACK(Label); -} - -bool ParseLink(const String& link, DocKey& key, String& label) -{ - if(memcmp(link, "dpp://", 6)) return false; - Vector p = Split(~link + 6, '/', false); - if(p.GetCount() != 3) return false; - key.nameing = p[0]; - key.nesting = p[1]; - key.item = p[2]; - int q = key.item.Find('#'); - label = Null; - if(q < 0) return true; - label = key.item.Mid(q + 1); - key.item = key.item.Mid(0, q); - return true; -} +#include "Docedit.h" + +void DocLinkDlg::Nameing() +{ + nesting.Clear(); + if(IsNull(nameing)) { + Nesting(); + return; + } + const VectorMap >& ns = set->Get(~nameing); + nesting.Clear(); + for(int i = 0; i < ns.GetCount(); i++) + nesting.Add(ns.GetKey(i)); + nesting.Sort(0, CompareNests); + nesting.GoBegin(); + Nesting(); +} + +void DocLinkDlg::Nesting() +{ + item.Clear(); + if(!nesting.IsCursor()) { + Item(); + return; + } + LoadItems(*set, ~nameing, nesting.GetKey(), item); + if(sort) + item.Sort(CompareItems); + item.GoBegin(); +} + +String DocLinkDlg::Get() +{ + return "dpp://" + String(~nameing) + "/" + String(nesting.GetKey()) + "/" + + String(item.GetKey()); +} + +void DocLinkDlg::Item() +{ + link <<= Get(); + String s = doc_dir.GetText(DocKey(~nameing, nesting.GetKey(), item.GetKey(), lang)); + label.KillCursor(); + label.Clear(); + label.Disable(); + if(IsNull(s)) return; + Array pi = ParseQTF(s).GetPosInfo(Rect(0, 0, 5000, 5000), PageY()); + for(int i = 0; i < pi.GetCount(); i++) + if(pi[i].type == RichPosInfo::LABEL) + label.Add(FromUnicode(pi[i].data, CHARSET_WIN1252)); + if(label.GetCount()) + label.Enable(); +} + +void DocLinkDlg::Label() +{ + if(label.IsCursor()) + link <<= Get() + "#" + String(label.GetKey()); +} + +bool DocLinkDlg::Perform(const DocSet& _set, bool _sort, String& _link, dword _lang, + const String& _nameing, const String& _nesting) +{ + lang = _lang; + set = &_set; + sort = _sort; + nameing.Clear(); + for(int i = 0; i < _set.GetCount(); i++) + nameing.Add(_set.GetKey(i)); + if(nameing.GetCount()) + nameing.SetIndex(0); + if(!IsNull(_nameing) && nameing.HasKey(_nameing)) + nameing <<= _nameing; + Nameing(); + if(!IsNull(_nesting)) + nesting.FindSetCursor(_nesting); + link <<= _link; + link.SetFocus(); + if(Execute() == IDOK) { + link.AddHistory(); + _link = link; + return true; + } + return false; +} + +DocLinkDlg::DocLinkDlg() +{ + CtrlLayoutOKCancel(*this, "Link"); + nesting.AddColumn().SetDisplay(Single()); + nesting.NoHeader().NoGrid(); + nameing <<= THISBACK(Nameing); + nesting.WhenEnterRow = THISBACK(Nesting); + InitItemArray(item); + item.WhenLeftClick = THISBACK(Item); + label.NoHeader().NoGrid(); + label.AddColumn(); + label.WhenLeftClick = THISBACK(Label); +} + +bool ParseLink(const String& link, DocKey& key, String& label) +{ + if(memcmp(link, "dpp://", 6)) return false; + Vector p = Split(~link + 6, '/', false); + if(p.GetCount() != 3) return false; + key.nameing = p[0]; + key.nesting = p[1]; + key.item = p[2]; + int q = key.item.Find('#'); + label = Null; + if(q < 0) return true; + label = key.item.Mid(q + 1); + key.item = key.item.Mid(0, q); + return true; +} diff --git a/uppsrc/Docedit/Docbase.cpp b/archive/uppsrc/Docedit/Docbase.cpp similarity index 95% rename from uppsrc/Docedit/Docbase.cpp rename to archive/uppsrc/Docedit/Docbase.cpp index 97a509ebb..67f9edb32 100644 --- a/uppsrc/Docedit/Docbase.cpp +++ b/archive/uppsrc/Docedit/Docbase.cpp @@ -1,66 +1,66 @@ -#include "Docedit.h" - -String PackageDirectory(const String& name) -{ - return AppendFileName("F:/uppsrc", name); -} - -String SourcePath(const String& package, const String& name) -{ - return AppendFileName(PackageDirectory(package), name); -} - -String CommonPath(const String& filename) -{ - return AppendFileName("f:/theide", filename); -} - -DocBase doc_base; - -void DocBase::RemoveFile(const String& file) -{ - CppBase base; - CppBase& doc_base = *this; - for(int i = 0; i < doc_base.GetCount(); i++) { - String m = doc_base.GetKey(i); - CppNamespace& mm = doc_base[i]; - for(int i = 0; i < mm.GetCount(); i++) { - String n = mm.GetKey(i); - CppNest& nn = mm[i]; - for(int i = 0; i < nn.GetCount(); i++) { - CppItem& q = nn[i]; - if(q.file != file) - base.GetAdd(m).GetAdd(n).GetAdd(nn.GetKey(i)) = q; - } - } - } - doc_base = base; -} - -void DocBase::ParseFile(const String& file, const String& package) throw(CParser::Error) -{ - Parse(FileIn(file), ignore, doc_base, package, file); -} - -void DocBase::RefreshFile(const String& file, const String& package) throw(CParser::Error) -{ - RemoveFile(file); - ParseFile(file, package); -} - -Vector DocBase::GetHeaders() -{ - Index h; - for(int i = 0; i < doc_base.GetCount(); i++) { - String m = doc_base.GetKey(i); - CppNamespace& mm = doc_base[i]; - for(int i = 0; i < mm.GetCount(); i++) { - String n = mm.GetKey(i); - CppNest& nn = mm[i]; - for(int i = 0; i < nn.GetCount(); i++) { - h.FindAdd(nn[i].file); - } - } - } - return h.PickKeys(); -} +#include "Docedit.h" + +String PackageDirectory(const String& name) +{ + return AppendFileName("F:/uppsrc", name); +} + +String SourcePath(const String& package, const String& name) +{ + return AppendFileName(PackageDirectory(package), name); +} + +String CommonPath(const String& filename) +{ + return AppendFileName("f:/theide", filename); +} + +DocBase doc_base; + +void DocBase::RemoveFile(const String& file) +{ + CppBase base; + CppBase& doc_base = *this; + for(int i = 0; i < doc_base.GetCount(); i++) { + String m = doc_base.GetKey(i); + CppNamespace& mm = doc_base[i]; + for(int i = 0; i < mm.GetCount(); i++) { + String n = mm.GetKey(i); + CppNest& nn = mm[i]; + for(int i = 0; i < nn.GetCount(); i++) { + CppItem& q = nn[i]; + if(q.file != file) + base.GetAdd(m).GetAdd(n).GetAdd(nn.GetKey(i)) = q; + } + } + } + doc_base = base; +} + +void DocBase::ParseFile(const String& file, const String& package) throw(CParser::Error) +{ + Parse(FileIn(file), ignore, doc_base, package, file); +} + +void DocBase::RefreshFile(const String& file, const String& package) throw(CParser::Error) +{ + RemoveFile(file); + ParseFile(file, package); +} + +Vector DocBase::GetHeaders() +{ + Index h; + for(int i = 0; i < doc_base.GetCount(); i++) { + String m = doc_base.GetKey(i); + CppNamespace& mm = doc_base[i]; + for(int i = 0; i < mm.GetCount(); i++) { + String n = mm.GetKey(i); + CppNest& nn = mm[i]; + for(int i = 0; i < nn.GetCount(); i++) { + h.FindAdd(nn[i].file); + } + } + } + return h.PickKeys(); +} diff --git a/uppsrc/Docedit/Docdir.cpp b/archive/uppsrc/Docedit/Docdir.cpp similarity index 95% rename from uppsrc/Docedit/Docdir.cpp rename to archive/uppsrc/Docedit/Docdir.cpp index 590fb2749..391afff99 100644 --- a/uppsrc/Docedit/Docdir.cpp +++ b/archive/uppsrc/Docedit/Docdir.cpp @@ -1,511 +1,511 @@ -#include "Docedit.h" - -bool DocKey::operator==(const DocKey& b) const -{ - return nameing == b.nameing && nesting == b.nesting && item == b.item && lang == b.lang; -} - -dword GetHashValue(const DocKey& k) -{ - return CombineHash(GetHashValue(k.nameing), GetHashValue(k.nesting), - GetHashValue(k.item)) << k.lang; -} - -int CharFilterNameing(int c) -{ - return c == ':' ? '_' : c; -} - -String DocFile(const String& package, const String& name) -{ - return AppendFileName(SourcePath(package, "doc.dpp"), name); -} - -Time GetFileTime(const char *path) -{ - FindFile ff(path); - return ff ? Time(ff.GetLastWriteTime()) : Null; -} - -void CreateDocDir(const String& package) -{ - ::CreateDirectory(SourcePath(package, "doc.dpp"), 0); -} - -String AsCode(const DocKey& k) -{ - return AsCString(k.nameing) + ", " + AsCString(k.nesting) + ", " + - AsCString(k.item) + ", " + AsCString(LNGAsText(k.lang)); -} - -bool ReadCode(CParser& p, DocKey& key) -{ - if(!p.IsString()) return false; - key.nameing = p.ReadString(); - if(!p.Char(',') || !p.IsString()) return false; - key.nesting = p.ReadString(); - if(!p.Char(',') || !p.IsString()) return false; - key.item = p.ReadString(); - if(!p.Char(',') || !p.IsString()) return false; - key.lang = LNGFromText(p.ReadString()); - return true; -} - -void DocDir::SaveLinks(const String& package) const -{ - CreateDocDir(package); - FileOut out(DocFile(package, "links")); - int q = dir.Find(package); - if(q >= 0) { - const ArrayMap& p = dir[q]; - for(int i = 0; i < p.GetCount(); i++) { - const Entry& w = p[i]; - const DocKey& k = p.GetKey(i); - if(w.type == LINK) - out << "LINK(" << AsCode(k) << ", " << AsCString(w.text) << ")\r\n"; - if(w.type == IGNORED) - out << "IGNORED(" << AsCode(k) << ")\r\n"; - } - } -} - -void DocDir::SaveDir(const String& package) const -{ - CreateDocDir(package); - FileOut out(DocFile(package, "dir.h")); - int q = dir.Find(package); - if(q >= 0) { - const ArrayMap& p = dir[q]; - for(int i = 0; i < p.GetCount(); i++) { - const Entry& w = p[i]; - if(w.type == NORMAL || w.type == EXTERNAL) { - const DocKey& k = p.GetKey(i); - out << "#ifdef INCLUDE_NAMESPACE_" << - Filter(k.nameing, CharFilterNameing) << "\r\n"; - out << "//" << k.item << "\r\n"; - out << "//" << k.nesting << "\r\n"; - out << "//" << k.nameing << "\r\n"; - out << "#include \"doc.dpp/"; - out << w.text; - out << "\" //"; - if(w.type == EXTERNAL) - out << "*"; - out << LNGAsText(k.lang) << "\r\n"; - out << "#endif\r\n\r\n"; - } - } - } - SaveLinks(package); -} - -bool DocDir::LoadLinks(const String& package) -{ - String f = LoadFile(DocFile(package, "links")); - CParser p(f); - ArrayMap& pk = dir.GetAdd(package); - try { - while(!p.IsEof()) { - if(p.Id("LINK")) { - DocKey key; - p.PassChar('('); - if(!ReadCode(p, key)) return false; - p.PassChar(','); - String link = p.ReadString(); - p.PassChar(')'); - Entry& e = pk.GetAdd(key); - e.text = link; - e.type = LINK; - } - if(p.Id("IGNORED")) { - DocKey key; - p.PassChar('('); - if(!ReadCode(p, key)) return false; - p.PassChar(')'); - Entry& e = pk.GetAdd(key); - e.text.Clear(); - e.type = IGNORED; - } - } - return true; - } - catch(CParser::Error) { - return false; - } -} - -bool DocDir::LoadDir(const String& package) -{ - ArrayMap& p = dir.GetAdd(package); - p.Clear(); - LoadLinks(package); - FileIn in(DocFile(package, "dir.h")); - int q = 0; - String d[3]; - while(!in.IsEof()) { - String l = in.GetLine(); - if(memcmp(l, "#include ", 9) == 0) { - const char *b = strchr(l, '/'); - if(!b) return false; - const char *e = strchr(b + 1, '\"'); - if(!e) return false; - String fn = String(b + 1, e); - e = strchr(e, '/'); - if(!e || e[1] != '/') return false; - e += 2; - int type = NORMAL; - if(*e == '*') { - type = EXTERNAL; - e++; - } - Entry& w = p.GetAdd(DocKey(d[2], d[1], d[0], LNGFromText(e))); - w.text = fn; - w.type = type; - q = 0; - } - if(l[0] == '/' && l[1] == '/') { - if(q >= 3) return false; - d[q] = l.Mid(2); - q++; - } - } - return true; -} - -int DocDir::ReadDocHeader(const char *filename, DocKey& key) -{ - FileIn in(filename); - if(!in) return -1; - String l = in.GetLine(); - CParser p(l); - if(!p.Id("ITEM") || !p.Char('(') || !ReadCode(p, key)) return -1; - p.Char(')'); - if(p.Id("EXTERNAL")) - return EXTERNAL; - return NORMAL; -} - -void DocDir::RebuildDir(const String& package) -{ - FindFile ff(DocFile(package, "*.dpp")); - Progress pi("Rebuilding " + package + " doc directory %d"); - ArrayMap& p = dir.GetAdd(package); - p.Clear(); - LoadLinks(package); - while(ff) { - DocKey key; - pi.Step(); - int q = ReadDocHeader(DocFile(package, ff.GetName()), key); - if(q >= 0) { - Entry& w = p.GetAdd(key); - w.text = ff.GetName(); - w.type = q; - } - ff.Next(); - } - SaveDir(package); -} - -void DocDir::Refresh(const String& package) -{ - FindFile ff(DocFile(package, "dir.h")); - if(!ff) { - RebuildDir(package); - return; - } - FileTime dirtime = ff.GetLastWriteTime(); - ff.Search(DocFile(package, "links")); - if(ff && ff.GetLastWriteTime() > dirtime) { - RebuildDir(package); - return; - } - const ArrayMap& p = dir.GetAdd(package); - Index dfn; - for(int i = 0; i < p.GetCount(); i++) - if(p[i].type == NORMAL || p[i].type == EXTERNAL) - dfn.Add(p[i].text); - ff.Search(DocFile(package, "*.dpp")); - int count = 0; - while(ff) { - DocKey key; - if(dfn.Find(ff.GetName()) >= 0) - if(ff.GetLastWriteTime() > dirtime) { - RebuildDir(package); - return; - } - else - count++; - else - if(ReadDocHeader(DocFile(package, ff.GetName()), key) >= 0) { - RebuildDir(package); - return; - } - ff.Next(); - } - if(count != dfn.GetCount()) - RebuildDir(package); -} - -int CharFilterLNG_(int c) -{ - return c == '-' ? '_' : c; -} - -String DocDir::GetAddFileName(const String& package, const DocKey& key, int type) -{ - Entry& w = dir.GetAdd(package).GetAdd(key); - String& fn = w.text; - w.type = type; - if(!IsEmpty(fn)) return fn; - String nm = key.nameing + '_' + key.nesting + '_' + key.item; - String n; - const char *s = nm; - while(*s && n.GetLength() < 30) - if(iscid(*s)) - n.Cat(*s++); - else { - n.Cat('_'); - while(*s && !iscid(*s)) - s++; - } - n << '_' << LNGAsText(key.lang); - int i = 0; - for(;;) { - fn = n + FormatIntAlpha(i) + ".dpp"; - if(!FindFile(DocFile(package, fn))) - return fn; - i++; - } -} - -bool DocDir::GetFileName(const DocKey& key, String& fn, String& package) -{ - dword hv = GetHashValue(key); - for(int i = 0; i < dir.GetCount(); i++) { - const ArrayMap& p = dir[i]; - int q = p.Find(key, hv); - if(q >= 0) { - fn = p[q].text; - package = dir.GetKey(i); - return true; - } - } - return false; -} - -void DocDir::RemoveOtherKey(const DocKey& key, int t1, int t2) -{ - dword hv = GetHashValue(key); - for(int i = 0; i < dir.GetCount(); i++) { - int q = dir[i].Find(key, hv); - if(q >= 0) { - Entry& e = dir[i][q]; - if(e.type != t1 && e.type != t2) { - if(e.type == NORMAL || e.type == EXTERNAL) - DeleteFile(DocFile(dir.GetKey(i), dir[i][q].text)); - dir[i].Remove(q); - } - SaveDir(dir.GetKey(i)); - SaveLinks(dir.GetKey(i)); - } - } -} - -void DocDir::Remove(const DocKey& k) -{ - RemoveOtherKey(k, UNDOCUMENTED, UNDOCUMENTED); -} - -void DocDir::SaveText(const String& package, const DocKey& k, const String& text, bool external) -{ - RemoveOtherKey(k, NORMAL, EXTERNAL); - CreateDocDir(package); - String fn = DocFile(package, GetAddFileName(package, k, external ? EXTERNAL : NORMAL)); - FileOut out(fn); - out << "ITEM(" << AsCode(k) << ")"; - if(external) - out << " EXTERNAL"; - out << "\r\n"; - int n = 0; - for(;;) { - int m = min(text.GetLength() - n, 2048); - if(m == 0) break; - out << "TEXT(\r\n\t"; - out << AsCString(~text + n, ~text + n + m, 64, "\t") << "\r\n"; - out << ")\r\n"; - n += m; - } - out << "END_ITEM\r\n"; - SaveDir(package); - SaveLinks(package); -} - -void DocDir::SaveLink(const String& package, const DocKey& key, const String& text) -{ - RemoveOtherKey(key, LINK); - Entry& w = dir.GetAdd(package).GetAdd(key); - w.text = text; - w.type = LINK; - SaveLinks(package); -} - -void DocDir::Ignore(const String& package, const DocKey& key) -{ - RemoveOtherKey(key, IGNORED); - Entry& w = dir.GetAdd(package).GetAdd(key); - w.type = IGNORED; - SaveLinks(package); -} - -DocDir::Entry *DocDir::Find(const DocKey& key, String& package) const -{ - dword hv = GetHashValue(key); - for(int i = 0; i < dir.GetCount(); i++) { - int q = dir[i].Find(key, hv); - if(q >= 0) { - package = dir.GetKey(i); - return const_cast(&dir[i][q]); - } - } - return NULL; -} - -DocDir::Entry *DocDir::Find(const DocKey& key) const -{ - String dm; - return Find(key, dm); -} - -int DocDir::GetStatus(const DocKey& key) -{ - DocDir::Entry *e = Find(key); - return e ? e->type : UNDOCUMENTED; -} - -int DocDir::GetStatus(const String& nameing, const String& nesting, const String& item, - int lang) -{ - return GetStatus(DocKey(nameing, nesting, item, lang)); -} - -String DocDir::GetFilePath(const DocKey& key) const -{ - String package; - Entry *e = Find(key, package); - if(!e || e->type != NORMAL && e->type != EXTERNAL) return Null; - return DocFile(package, e->text); -} - -String DocDir::GetPackage(const DocKey& key) const -{ - String package; - Entry *e = Find(key, package); - return e ? package : Null; -} - -String DocDir::GetText(const DocKey& key) const -{ - String s = LoadFile(GetFilePath(key)); - if(s.IsEmpty()) return Null; - CParser p(s); - DocKey dummy; - if(!p.Id("ITEM") || !p.Char('(') || !ReadCode(p, dummy)) return "Invalid file"; - p.Char(')'); - p.Id("EXTERNAL"); - String text; - while(p.Id("TEXT")) { - p.Char('('); - if(p.IsString()) - text.Cat(p.ReadString()); - else - return "Invalid file"; - p.Char(')'); - } - return p.Id("END_ITEM") ? text : "Invalid file"; -} - -String DocDir::GetLink(const DocKey& key) const -{ - DocDir::Entry *e = Find(key); - if(!e) return Null; - return e->type == LINK ? e->text : Null; -} - -bool Contains(const DocSet& r, const DocKey& key) -{ - int q = r.Find(key.nameing); - if(q < 0) return false; - int w = r[q].Find(key.nesting); - if(w < 0) return false; - return r[q][w].Find(key.item) >= 0; -} - -bool Contains(const String& big, const String& part) -{ - if(part.GetLength() > big.GetLength()) return false; - const char *s = big; - const char *e = s + big.GetLength() - part.GetLength(); - int l = part.GetLength(); - while(s <= e) { - if(memcmp(s, part, l) == 0) - return true; - s++; - } - return false; -} - -DocSet DocDir::Select(const DocQuery& query) -{ - DocSet r; - CppBase base; - int i; - for(i = 0; i < doc_base.GetCount(); i++) { - String nameing = doc_base.GetKey(i); - CppNamespace& mm = doc_base[i]; - for(int i = 0; i < mm.GetCount(); i++) { - String nesting = mm.GetKey(i); - CppNest& nn = mm[i]; - for(int i = 0; i < nn.GetCount(); i++) { - CppItem& q = nn[i]; - String item = nn.GetKey(i); - if((query.name.IsEmpty() || query.name == q.name) && - (query.text.IsEmpty() || Contains(item, query.text)) && - (query.package.IsEmpty() || q.package.CompareNoCase(query.package) == 0) && - (query.header.IsEmpty() || q.file.CompareNoCase(query.header) == 0)) { - String pk; - const Entry *e = Find(DocKey(nameing, nesting, item, query.lang), pk); - int st = e ? e->type : UNDOCUMENTED; - if((query.undocumented || e) && (st != IGNORED || query.ignored)) { - DocItem& a = r.GetAdd(nameing).GetAdd(nesting).GetAdd(item); - a.cppitem = &q; - a.item = item; - a.status = st; - a.package = e ? pk : q.package; - } - } - } - } - } - for(i = 0; i < dir.GetCount(); i++) { - ArrayMap& pk = dir[i]; - String package = dir.GetKey(i); - for(int j = 0; j < pk.GetCount(); j++) { - const DocKey& k = pk.GetKey(j); - if(k.lang == query.lang && - query.name.IsEmpty() && - (query.text.IsEmpty() || Contains(k.item, query.text)) && - (query.package.IsEmpty() || package.CompareNoCase(query.package) == 0) && - query.header.IsEmpty() && - !Contains(r, k)) { - DocItem& a = r.GetAdd(k.nameing).GetAdd(k.nesting).GetAdd(k.item); - a.cppitem = NULL; - a.item = k.item; - int st = pk[j].type; - a.status = st == NORMAL ? OBSOLETE : st == LINK ? OBSOLETELINK : st; - a.package = package; - } - } - } - return r; -} - -DocDir doc_dir; +#include "Docedit.h" + +bool DocKey::operator==(const DocKey& b) const +{ + return nameing == b.nameing && nesting == b.nesting && item == b.item && lang == b.lang; +} + +dword GetHashValue(const DocKey& k) +{ + return CombineHash(GetHashValue(k.nameing), GetHashValue(k.nesting), + GetHashValue(k.item)) << k.lang; +} + +int CharFilterNameing(int c) +{ + return c == ':' ? '_' : c; +} + +String DocFile(const String& package, const String& name) +{ + return AppendFileName(SourcePath(package, "doc.dpp"), name); +} + +Time GetFileTime(const char *path) +{ + FindFile ff(path); + return ff ? Time(ff.GetLastWriteTime()) : Null; +} + +void CreateDocDir(const String& package) +{ + ::CreateDirectory(SourcePath(package, "doc.dpp"), 0); +} + +String AsCode(const DocKey& k) +{ + return AsCString(k.nameing) + ", " + AsCString(k.nesting) + ", " + + AsCString(k.item) + ", " + AsCString(LNGAsText(k.lang)); +} + +bool ReadCode(CParser& p, DocKey& key) +{ + if(!p.IsString()) return false; + key.nameing = p.ReadString(); + if(!p.Char(',') || !p.IsString()) return false; + key.nesting = p.ReadString(); + if(!p.Char(',') || !p.IsString()) return false; + key.item = p.ReadString(); + if(!p.Char(',') || !p.IsString()) return false; + key.lang = LNGFromText(p.ReadString()); + return true; +} + +void DocDir::SaveLinks(const String& package) const +{ + CreateDocDir(package); + FileOut out(DocFile(package, "links")); + int q = dir.Find(package); + if(q >= 0) { + const ArrayMap& p = dir[q]; + for(int i = 0; i < p.GetCount(); i++) { + const Entry& w = p[i]; + const DocKey& k = p.GetKey(i); + if(w.type == LINK) + out << "LINK(" << AsCode(k) << ", " << AsCString(w.text) << ")\r\n"; + if(w.type == IGNORED) + out << "IGNORED(" << AsCode(k) << ")\r\n"; + } + } +} + +void DocDir::SaveDir(const String& package) const +{ + CreateDocDir(package); + FileOut out(DocFile(package, "dir.h")); + int q = dir.Find(package); + if(q >= 0) { + const ArrayMap& p = dir[q]; + for(int i = 0; i < p.GetCount(); i++) { + const Entry& w = p[i]; + if(w.type == NORMAL || w.type == EXTERNAL) { + const DocKey& k = p.GetKey(i); + out << "#ifdef INCLUDE_NAMESPACE_" << + Filter(k.nameing, CharFilterNameing) << "\r\n"; + out << "//" << k.item << "\r\n"; + out << "//" << k.nesting << "\r\n"; + out << "//" << k.nameing << "\r\n"; + out << "#include \"doc.dpp/"; + out << w.text; + out << "\" //"; + if(w.type == EXTERNAL) + out << "*"; + out << LNGAsText(k.lang) << "\r\n"; + out << "#endif\r\n\r\n"; + } + } + } + SaveLinks(package); +} + +bool DocDir::LoadLinks(const String& package) +{ + String f = LoadFile(DocFile(package, "links")); + CParser p(f); + ArrayMap& pk = dir.GetAdd(package); + try { + while(!p.IsEof()) { + if(p.Id("LINK")) { + DocKey key; + p.PassChar('('); + if(!ReadCode(p, key)) return false; + p.PassChar(','); + String link = p.ReadString(); + p.PassChar(')'); + Entry& e = pk.GetAdd(key); + e.text = link; + e.type = LINK; + } + if(p.Id("IGNORED")) { + DocKey key; + p.PassChar('('); + if(!ReadCode(p, key)) return false; + p.PassChar(')'); + Entry& e = pk.GetAdd(key); + e.text.Clear(); + e.type = IGNORED; + } + } + return true; + } + catch(CParser::Error) { + return false; + } +} + +bool DocDir::LoadDir(const String& package) +{ + ArrayMap& p = dir.GetAdd(package); + p.Clear(); + LoadLinks(package); + FileIn in(DocFile(package, "dir.h")); + int q = 0; + String d[3]; + while(!in.IsEof()) { + String l = in.GetLine(); + if(memcmp(l, "#include ", 9) == 0) { + const char *b = strchr(l, '/'); + if(!b) return false; + const char *e = strchr(b + 1, '\"'); + if(!e) return false; + String fn = String(b + 1, e); + e = strchr(e, '/'); + if(!e || e[1] != '/') return false; + e += 2; + int type = NORMAL; + if(*e == '*') { + type = EXTERNAL; + e++; + } + Entry& w = p.GetAdd(DocKey(d[2], d[1], d[0], LNGFromText(e))); + w.text = fn; + w.type = type; + q = 0; + } + if(l[0] == '/' && l[1] == '/') { + if(q >= 3) return false; + d[q] = l.Mid(2); + q++; + } + } + return true; +} + +int DocDir::ReadDocHeader(const char *filename, DocKey& key) +{ + FileIn in(filename); + if(!in) return -1; + String l = in.GetLine(); + CParser p(l); + if(!p.Id("ITEM") || !p.Char('(') || !ReadCode(p, key)) return -1; + p.Char(')'); + if(p.Id("EXTERNAL")) + return EXTERNAL; + return NORMAL; +} + +void DocDir::RebuildDir(const String& package) +{ + FindFile ff(DocFile(package, "*.dpp")); + Progress pi("Rebuilding " + package + " doc directory %d"); + ArrayMap& p = dir.GetAdd(package); + p.Clear(); + LoadLinks(package); + while(ff) { + DocKey key; + pi.Step(); + int q = ReadDocHeader(DocFile(package, ff.GetName()), key); + if(q >= 0) { + Entry& w = p.GetAdd(key); + w.text = ff.GetName(); + w.type = q; + } + ff.Next(); + } + SaveDir(package); +} + +void DocDir::Refresh(const String& package) +{ + FindFile ff(DocFile(package, "dir.h")); + if(!ff) { + RebuildDir(package); + return; + } + FileTime dirtime = ff.GetLastWriteTime(); + ff.Search(DocFile(package, "links")); + if(ff && ff.GetLastWriteTime() > dirtime) { + RebuildDir(package); + return; + } + const ArrayMap& p = dir.GetAdd(package); + Index dfn; + for(int i = 0; i < p.GetCount(); i++) + if(p[i].type == NORMAL || p[i].type == EXTERNAL) + dfn.Add(p[i].text); + ff.Search(DocFile(package, "*.dpp")); + int count = 0; + while(ff) { + DocKey key; + if(dfn.Find(ff.GetName()) >= 0) + if(ff.GetLastWriteTime() > dirtime) { + RebuildDir(package); + return; + } + else + count++; + else + if(ReadDocHeader(DocFile(package, ff.GetName()), key) >= 0) { + RebuildDir(package); + return; + } + ff.Next(); + } + if(count != dfn.GetCount()) + RebuildDir(package); +} + +int CharFilterLNG_(int c) +{ + return c == '-' ? '_' : c; +} + +String DocDir::GetAddFileName(const String& package, const DocKey& key, int type) +{ + Entry& w = dir.GetAdd(package).GetAdd(key); + String& fn = w.text; + w.type = type; + if(!IsEmpty(fn)) return fn; + String nm = key.nameing + '_' + key.nesting + '_' + key.item; + String n; + const char *s = nm; + while(*s && n.GetLength() < 30) + if(iscid(*s)) + n.Cat(*s++); + else { + n.Cat('_'); + while(*s && !iscid(*s)) + s++; + } + n << '_' << LNGAsText(key.lang); + int i = 0; + for(;;) { + fn = n + FormatIntAlpha(i) + ".dpp"; + if(!FindFile(DocFile(package, fn))) + return fn; + i++; + } +} + +bool DocDir::GetFileName(const DocKey& key, String& fn, String& package) +{ + dword hv = GetHashValue(key); + for(int i = 0; i < dir.GetCount(); i++) { + const ArrayMap& p = dir[i]; + int q = p.Find(key, hv); + if(q >= 0) { + fn = p[q].text; + package = dir.GetKey(i); + return true; + } + } + return false; +} + +void DocDir::RemoveOtherKey(const DocKey& key, int t1, int t2) +{ + dword hv = GetHashValue(key); + for(int i = 0; i < dir.GetCount(); i++) { + int q = dir[i].Find(key, hv); + if(q >= 0) { + Entry& e = dir[i][q]; + if(e.type != t1 && e.type != t2) { + if(e.type == NORMAL || e.type == EXTERNAL) + DeleteFile(DocFile(dir.GetKey(i), dir[i][q].text)); + dir[i].Remove(q); + } + SaveDir(dir.GetKey(i)); + SaveLinks(dir.GetKey(i)); + } + } +} + +void DocDir::Remove(const DocKey& k) +{ + RemoveOtherKey(k, UNDOCUMENTED, UNDOCUMENTED); +} + +void DocDir::SaveText(const String& package, const DocKey& k, const String& text, bool external) +{ + RemoveOtherKey(k, NORMAL, EXTERNAL); + CreateDocDir(package); + String fn = DocFile(package, GetAddFileName(package, k, external ? EXTERNAL : NORMAL)); + FileOut out(fn); + out << "ITEM(" << AsCode(k) << ")"; + if(external) + out << " EXTERNAL"; + out << "\r\n"; + int n = 0; + for(;;) { + int m = min(text.GetLength() - n, 2048); + if(m == 0) break; + out << "TEXT(\r\n\t"; + out << AsCString(~text + n, ~text + n + m, 64, "\t") << "\r\n"; + out << ")\r\n"; + n += m; + } + out << "END_ITEM\r\n"; + SaveDir(package); + SaveLinks(package); +} + +void DocDir::SaveLink(const String& package, const DocKey& key, const String& text) +{ + RemoveOtherKey(key, LINK); + Entry& w = dir.GetAdd(package).GetAdd(key); + w.text = text; + w.type = LINK; + SaveLinks(package); +} + +void DocDir::Ignore(const String& package, const DocKey& key) +{ + RemoveOtherKey(key, IGNORED); + Entry& w = dir.GetAdd(package).GetAdd(key); + w.type = IGNORED; + SaveLinks(package); +} + +DocDir::Entry *DocDir::Find(const DocKey& key, String& package) const +{ + dword hv = GetHashValue(key); + for(int i = 0; i < dir.GetCount(); i++) { + int q = dir[i].Find(key, hv); + if(q >= 0) { + package = dir.GetKey(i); + return const_cast(&dir[i][q]); + } + } + return NULL; +} + +DocDir::Entry *DocDir::Find(const DocKey& key) const +{ + String dm; + return Find(key, dm); +} + +int DocDir::GetStatus(const DocKey& key) +{ + DocDir::Entry *e = Find(key); + return e ? e->type : UNDOCUMENTED; +} + +int DocDir::GetStatus(const String& nameing, const String& nesting, const String& item, + int lang) +{ + return GetStatus(DocKey(nameing, nesting, item, lang)); +} + +String DocDir::GetFilePath(const DocKey& key) const +{ + String package; + Entry *e = Find(key, package); + if(!e || e->type != NORMAL && e->type != EXTERNAL) return Null; + return DocFile(package, e->text); +} + +String DocDir::GetPackage(const DocKey& key) const +{ + String package; + Entry *e = Find(key, package); + return e ? package : Null; +} + +String DocDir::GetText(const DocKey& key) const +{ + String s = LoadFile(GetFilePath(key)); + if(s.IsEmpty()) return Null; + CParser p(s); + DocKey dummy; + if(!p.Id("ITEM") || !p.Char('(') || !ReadCode(p, dummy)) return "Invalid file"; + p.Char(')'); + p.Id("EXTERNAL"); + String text; + while(p.Id("TEXT")) { + p.Char('('); + if(p.IsString()) + text.Cat(p.ReadString()); + else + return "Invalid file"; + p.Char(')'); + } + return p.Id("END_ITEM") ? text : "Invalid file"; +} + +String DocDir::GetLink(const DocKey& key) const +{ + DocDir::Entry *e = Find(key); + if(!e) return Null; + return e->type == LINK ? e->text : Null; +} + +bool Contains(const DocSet& r, const DocKey& key) +{ + int q = r.Find(key.nameing); + if(q < 0) return false; + int w = r[q].Find(key.nesting); + if(w < 0) return false; + return r[q][w].Find(key.item) >= 0; +} + +bool Contains(const String& big, const String& part) +{ + if(part.GetLength() > big.GetLength()) return false; + const char *s = big; + const char *e = s + big.GetLength() - part.GetLength(); + int l = part.GetLength(); + while(s <= e) { + if(memcmp(s, part, l) == 0) + return true; + s++; + } + return false; +} + +DocSet DocDir::Select(const DocQuery& query) +{ + DocSet r; + CppBase base; + int i; + for(i = 0; i < doc_base.GetCount(); i++) { + String nameing = doc_base.GetKey(i); + CppNamespace& mm = doc_base[i]; + for(int i = 0; i < mm.GetCount(); i++) { + String nesting = mm.GetKey(i); + CppNest& nn = mm[i]; + for(int i = 0; i < nn.GetCount(); i++) { + CppItem& q = nn[i]; + String item = nn.GetKey(i); + if((query.name.IsEmpty() || query.name == q.name) && + (query.text.IsEmpty() || Contains(item, query.text)) && + (query.package.IsEmpty() || q.package.CompareNoCase(query.package) == 0) && + (query.header.IsEmpty() || q.file.CompareNoCase(query.header) == 0)) { + String pk; + const Entry *e = Find(DocKey(nameing, nesting, item, query.lang), pk); + int st = e ? e->type : UNDOCUMENTED; + if((query.undocumented || e) && (st != IGNORED || query.ignored)) { + DocItem& a = r.GetAdd(nameing).GetAdd(nesting).GetAdd(item); + a.cppitem = &q; + a.item = item; + a.status = st; + a.package = e ? pk : q.package; + } + } + } + } + } + for(i = 0; i < dir.GetCount(); i++) { + ArrayMap& pk = dir[i]; + String package = dir.GetKey(i); + for(int j = 0; j < pk.GetCount(); j++) { + const DocKey& k = pk.GetKey(j); + if(k.lang == query.lang && + query.name.IsEmpty() && + (query.text.IsEmpty() || Contains(k.item, query.text)) && + (query.package.IsEmpty() || package.CompareNoCase(query.package) == 0) && + query.header.IsEmpty() && + !Contains(r, k)) { + DocItem& a = r.GetAdd(k.nameing).GetAdd(k.nesting).GetAdd(k.item); + a.cppitem = NULL; + a.item = k.item; + int st = pk[j].type; + a.status = st == NORMAL ? OBSOLETE : st == LINK ? OBSOLETELINK : st; + a.package = package; + } + } + } + return r; +} + +DocDir doc_dir; diff --git a/uppsrc/Docedit/Docedit.cpp b/archive/uppsrc/Docedit/Docedit.cpp similarity index 95% rename from uppsrc/Docedit/Docedit.cpp rename to archive/uppsrc/Docedit/Docedit.cpp index 91bdd618d..a8cc8ada5 100644 --- a/uppsrc/Docedit/Docedit.cpp +++ b/archive/uppsrc/Docedit/Docedit.cpp @@ -1,539 +1,539 @@ -#include - -int PosOf(const String& str, const String& sub) -{ - if(sub.GetLength() > str.GetLength()) return -1; - const char *s = str; - const char *e = s + str.GetLength() - sub.GetLength(); - while(s <= e) { - if(memcmp(s, sub, sub.GetLength()) == 0) - return s - ~str; - s++; - } - return -1; -} - -void DocBrowser::Nameing() -{ - nesting.Clear(); - if(IsNull(nameing)) { - Nesting(); - return; - } - const VectorMap >& ns = set.Get(~nameing); - nesting.Clear(); - for(int i = 0; i < ns.GetCount(); i++) - nesting.Add(ns.GetKey(i)); - nesting.Sort(0, CompareNests); - nesting.GoBegin(); - Nesting(); -} - -void DocBrowser::Nesting() -{ - item.Clear(); - if(!nesting.IsCursor()) { - Item(); - return; - } - LoadItems(set, ~nameing, nesting.GetKey(), item); - if(sort) - item.Sort(CompareItems); - item.GoBegin(); - edit.Enable(item.IsCursor()); -} - -void DocBrowser::Item() -{ - Flush(); - EnterItem(); -} - -void DocBrowser::EnterItem() -{ - String lbl; - target = current = DocKey(~nameing, nesting.GetKey(), item.GetKey(), (int)~lang); - if(doc_dir.GetStatus(current) == DocDir::LINK) - if(!ParseLink(doc_dir.GetLink(current), target, lbl)) { - View(); - view.SetQTF("[R9&&&=@3* Invalid link"); - return; - } - String txt = LoadFile(CommonPath("dppstyles.qtf")) + doc_dir.GetText(target); - package <<= doc_dir.GetPackage(target); - if(edit.IsShown()) { - edit.SetPage(Size(3968, INT_MAX)); - edit.SetQTF(txt); - edit.SetFocus(); - String p = doc_dir.GetFilePath(target); - if(!IsNull(p)) { - int q = editstate.Find(p); - if(q >= 0) { - FileInfo& fi = editstate[q]; - if(fi.time == GetFileTime(p)) { - edit.SetPickUndoInfo(fi.info); - fi.time = Time(1, 1, 1); - } - } - } - int q = posinfo.Find(current); - if(q >= 0) - edit.SetPosInfo(posinfo[q]); - else - if(!lbl.IsEmpty()) - edit.GotoLabel(lbl); - edit.ClearModify(); - } - else { - view.SetQTF(txt); - if(!lbl.IsEmpty()) - view.GotoLabel(lbl); - } - trect.Color(SLtBlue); - title.SetInk(SWhite); - String s = " dpp://" + current.nameing + "/" + current.nesting + "/" + current.item; - switch(GetCurrentStatus()) { - case DocDir::UNDOCUMENTED: - trect.Color(SGray); - break; - case DocDir::LINK: - s << " -> " << target.nameing + "/" + target.nesting + "/" + target.item; - trect.Color(SCyan); - break; - case DocDir::OBSOLETE: - trect.Color(SRed); - break; - case DocDir::EXTERNAL: - trect.Color(SGreen); - break; - } - title = s; - int status = item.Get(4); - int kind = item.Get(2); - String name = item.Get(1); - String text = item.Get(0); - String post; - if(status == DocDir::EXTERNAL) - post = " (external)"; - if(!name.IsEmpty() && status != DocDir::EXTERNAL) { - int q = PosOf(text, name); - if(q >= 0) { - if(current.nesting.IsEmpty() || kind == STRUCT || kind == STRUCTTEMPLATE) - Title(text.Mid(0, q) + current.nameing + text.Mid(q) + post); - else - Title(text.Mid(0, q) + current.nameing + current.nesting + "::" + text.Mid(q) - + post); - return; - } - } - Title(current.nameing + "::" + current.nesting + "::" + text + post); -} - -void DocBrowser::Flush() -{ - if(edit.IsShown() && target && item.IsCursor()) { - posinfo.GetAdd(current) = edit.GetPosInfo(); - if(edit.IsModified()) { - DocItem& im = set.Get(target.nameing).Get(target.nesting).Get(target.item); - const RichText& txt = edit.Get(); - SaveFile(CommonPath("dppstyles.qtf"), StylesAsQTF(txt)); - if(edit.GetLength()) { - doc_dir.SaveText(GetItemPackage(), target, BodyAsQTF(txt), - doc_dir.GetStatus(target) == DocDir::EXTERNAL); - im.status = DocDir::NORMAL; - } - else { - doc_dir.Remove(target); - im.status = DocDir::UNDOCUMENTED; - } - String p = doc_dir.GetFilePath(target); - FileInfo& fi = editstate.GetAdd(p); - fi.time = GetFileTime(p); - fi.info = edit.PickUndoInfo(); - } - target.Clear(); - if(edit.IsModified()) - ReloadItems(); - edit.ClearModify(); - } -} - -void DocBrowser::Query() -{ - DocQuery q; - q.lang = (int)~lang; - q.undocumented = q.normal = q.external = q.obsolete = q.ignored = false; - switch(query.status) { - case 4: - q.ignored = true; - case 0: - q.undocumented = q.normal = q.external = q.obsolete = true; - break; - case 1: - q.undocumented = true; - break; - case 2: - q.obsolete = true; - break; - case 3: - q.ignored = true; - break; - } - q.name = query.name; - q.text = query.text; - q.header = ~query.header; - set = doc_dir.Select(q); - nameing.ClearList(); - for(int i = 0; i < set.GetCount(); i++) - nameing.Add(set.GetKey(i)); - if(nameing.GetCount()) - nameing.SetIndex(0); - Nameing(); -} - -void DocBrowser::Select() -{ - int c; - query.header.ClearList(); - Vector h = doc_base.GetHeaders(); - for(int i = 0; i < h.GetCount(); i++) - query.header.Add(h[i], GetFileName(h[i])); - query.header.Add(Null, ""); - for(;;) { - c = query.Run(); - if(c == IDCANCEL) - break;; - if(c == IDYES) { - query.status = 0; - query.name <<= Null; - query.text <<= Null; - } - if(c == IDOK) - break; - } - query.Close(); - query.name.AddHistory(); - query.text.AddHistory(); - if(c == IDOK) - Query(); -} - -bool DocBrowser::Key(dword key, int) -{ - switch(key) { - case K_F6: - Select(); - break; - default: - return false; - } - return true; -} - -void DocBrowser::Edit() -{ - Flush(); - edit.Show(); - view.Hide(); - EnterItem(); -} - -void DocBrowser::View() -{ - view.Show(); - edit.Hide(); - Item(); -} - -void DocBrowser::Sort() -{ - sort = !sort; - Nesting(); -} - -int DocBrowser::GetCurrentStatus() -{ - return item.IsCursor() ? doc_dir.GetStatus(current) : Null; -} - -void DocBrowser::ReloadItems() -{ - int c = item.GetCursor(); - int a = item.GetCursorSc(); - Nesting(); - if(c >= 0) - item.SetCursor(c); - item.ScCursor(a); -} - -void DocBrowser::SetCurrentStatus(int status) -{ - set.GetAdd(current.nameing).GetAdd(current.nesting).GetAdd(current.item).status = status; - ReloadItems(); -} - -void DocBrowser::Link() -{ - int q = GetCurrentStatus(); - if(q != DocDir::UNDOCUMENTED && q != DocDir::LINK || !item.IsCursor()) - return; - String pk = GetItemPackage(); - String h; - if(GetCurrentStatus() == DocDir::LINK) - h = doc_dir.GetLink(current); - if(linkdlg.Perform(set, sort, h, (int)~lang, ~nameing, nesting.GetKey())) { - int c = item.GetCursor(); - item.KillCursor(); - doc_dir.SaveLink(pk, current, h); - item.SetCursor(c); - SetCurrentStatus(DocDir::LINK); - } -} - -void DocBrowser::Ignore() -{ - int q = GetCurrentStatus(); - if(q != DocDir::UNDOCUMENTED || !item.IsCursor()) return; - int c = item.GetCursor(); - String pk = GetItemPackage(); - item.KillCursor(); - doc_dir.Ignore(pk, current); - item.SetCursor(c); - SetCurrentStatus(DocDir::IGNORED); -} - -void DocBrowser::Delete() -{ - int q = GetCurrentStatus(); - if(q == DocDir::UNDOCUMENTED || !item.IsCursor()) return; - int c = item.GetCursor(); - item.KillCursor(); - switch(q) { - case DocDir::OBSOLETE: - case DocDir::OBSOLETELINK: - break; - default: - if(!PromptYesNo("Remove current current ?")) return; - } - doc_dir.Remove(current); - item.SetCursor(c); - SetCurrentStatus(DocDir::UNDOCUMENTED); -} - -void DocBrowser::New() -{ - - external.package.Add("Core"); //!!! - external.package <<= doc_dir.GetPackage(current); - external.nameing <<= ~nameing; - external.nesting <<= nesting.GetKey(); -again: - if(external.Execute() != IDOK) return; - if(IsNull(external.nameing)) { - Exclamation("Missing namespace !"); - goto again; - } - if(IsNull(external.item)) { - Exclamation("Missing item !"); - goto again; - } - external.nameing.AddHistory(); - external.nesting.AddHistory(); - DocKey k = DocKey(~external.nameing, ~external.nesting, ~external.item, (int)~lang); - doc_dir.SaveText(~external.package, k, "", true); - Query(); - nameing <<= k.nameing; - Nameing(); - if(nesting.FindSetCursor(k.nesting)) - item.FindSetCursor(k.item); -} - -void DocBrowser::EditLink(String& s) -{ - linkdlg.Perform(set, sort, s, (int)~lang, ~nameing, nesting.GetKey()); -} - -void DocBrowser::FollowLink(const String& s) -{ - if(memcmp(s, "dpp://", 6)) { - Exclamation("Not a dpp link !"); - return; - } - Vector l = Split(~s + 6, '/', false); - if(l.GetCount() != 3) { - Exclamation("Invalid link !"); - return; - } - if(nameing.HasKey(l[0])) { - nameing.SetData(l[0]); - Nameing(); - if(nesting.FindSetCursor(l[1])) { - String n = l[2]; - String l; - int q = n.Find('#'); - if(q >= 0) { - l = n.Mid(q + 1); - n = n.Mid(0, q); - } - if(item.FindSetCursor(n)) - return; - } - } - Exclamation("Link not found"); -} - -void DocBrowser::BrowseMenu(Bar& bar) -{ - bar.Add("Select..", THISBACK(Select)) - .Key(K_F6); - bar.Separator(); - bar.Add("Edit", THISBACK(Edit)) - .Radio(edit.IsShown()) - .Key(K_CTRL_O); - bar.Add("View", THISBACK(View)) - .Radio(view.IsShown()) - .Key(edit.IsShown() ? K_ESCAPE : 0); - bar.Separator(); - bar.Add("Sort by types and names", THISBACK(Sort)) - .Check(sort); - bar.Separator(); -} - -void DocBrowser::ItemMenu(Bar& bar) -{ - int q = GetCurrentStatus(); - bar.Add(q == DocDir::UNDOCUMENTED || q == DocDir::LINK, - "Link..", THISBACK(Link)) - .Key(K_CTRL_L); - bar.Add(q == DocDir::UNDOCUMENTED, "Ignore", THISBACK(Ignore)) - .Key(K_CTRL_I); - bar.Add(q != DocDir::UNDOCUMENTED, "Delete", THISBACK(Delete)) - .Key(K_CTRL_DELETE); - bar.Add("New..", THISBACK(New)); -} - -void DocBrowser::MainMenu(Bar& bar) -{ - bar.Add("Browse", THISBACK(BrowseMenu)); - bar.Add("Item", THISBACK(ItemMenu)); -} - -void DocBrowser::EditBar(Bar& bar) -{ - edit.StyleTool(bar); - bar.Gap(); - edit.FontTools(bar); - bar.Gap(); - edit.InkTool(bar); - edit.PaperTool(bar); - bar.Gap(); - edit.LanguageTool(bar); - edit.SpellCheckTool(bar); - bar.Break(); - - edit.HyperlinkTool(bar, 300); - bar.Gap(); - edit.LabelTool(bar); - bar.Gap(); - edit.IndexEntryTool(bar); - bar.Break(); - - edit.ParaTools(bar); - bar.Gap(); - edit.EditTools(bar); - bar.Gap(); - edit.PrintTool(bar); -} - -void DocBrowser::SetEditBar() -{ - editbar.Set(THISBACK(EditBar)); -} - -void DocBrowser::SetMainBar() -{ - menu.Set(THISBACK(MainMenu)); -} - -void DocBrowser::Close() -{ - Flush(); - TopWindow::Close(); -} - -DocBrowser::DocBrowser() -{ - Zoomable().Sizeable().Icon(DppImg::SmallIcon); - ni_split.Vert(nesting, item); - ni_split.SetPos(3000); - int q = nameing.GetMinSize().cy; - larea.Add(nameing.HSizePos().TopPos(0, q)); - larea.Add(ni_split.HSizePos().VSizePos(q + 4, 0)); - rarea.AddFrame(trect.Height(q + 4)); - trect.SetFrame(ThinInsetFrame()); - trect.Add(title.SizePos()); - trect.Add(package.RightPos(0, 100).VSizePos()); - rarea.Add(view.SizePos()); - rarea.Add(edit.SizePos()); - vi_split.Horz(larea, rarea); - vi_split.SetPos(3000); - Add(vi_split); - nesting.AddColumn().SetDisplay(Single()); - nesting.NoHeader().NoGrid(); - nameing <<= THISBACK(Nameing); - nesting.WhenEnterRow = THISBACK(Nesting); - InitItemArray(item); - item.WhenEnterRow = THISBACK(Item); - item.WhenKillCursor = THISBACK(Flush); - item.WhenBar = THISBACK(ItemMenu); - item.WhenLeftDouble = THISBACK(Edit); - - view.Show(); - edit.Hide(); - edit.SetPage(Size(3968, INT_MAX)); - - CtrlLayoutOKCancel(query, "Select"); - query.clear <<= query.Breaker(IDYES); - query.status = 0; - - AddFrame(menu); - SetMainBar(); - menu.Ctrl::Add(lang.RightPos(10, 70).TopPos(0, EditField::GetStdHeight())); - lang.Add((int)LNG_ENGLISH, "EN-US"); - lang.Add((int)LNGFromText("EN-GB"), "EN-GB"); - lang.Add((int)LNGFromText("DE-DE"), "DE-DE"); - lang.Add((int)LNG_CZECH, "CS-CZ"); - lang <<= (int)LNGFromText("EN-US"); - lang <<= THISBACK(Query); - - edit.InsertFrame(1, editbar); - edit.WhenRefreshBar = THISBACK(SetEditBar); - edit.WhenHyperlink = THISBACK(EditLink); - - view.WhenLink = THISBACK(FollowLink); - - sort = false; - - CtrlLayoutOKCancel(external, "New external item"); - external.ActiveFocus(external.item); -} - -void AppMain() -{ - doc_base.ignore.Add("pick_"); - FindFile ff("f:/uppsrc/Core/*.h"); - while(ff) { - String fn = String("f:/uppsrc/Core/") + ff.GetName(); - try { - doc_base.ParseFile(fn, "Core"); - } - catch(Parser::Error e) { - LOG(e); - } - ff.Next(); - } - doc_dir.Refresh("Core"); - DocBrowser d; - d.Query(); - d.Run(); -} +#include + +int PosOf(const String& str, const String& sub) +{ + if(sub.GetLength() > str.GetLength()) return -1; + const char *s = str; + const char *e = s + str.GetLength() - sub.GetLength(); + while(s <= e) { + if(memcmp(s, sub, sub.GetLength()) == 0) + return s - ~str; + s++; + } + return -1; +} + +void DocBrowser::Nameing() +{ + nesting.Clear(); + if(IsNull(nameing)) { + Nesting(); + return; + } + const VectorMap >& ns = set.Get(~nameing); + nesting.Clear(); + for(int i = 0; i < ns.GetCount(); i++) + nesting.Add(ns.GetKey(i)); + nesting.Sort(0, CompareNests); + nesting.GoBegin(); + Nesting(); +} + +void DocBrowser::Nesting() +{ + item.Clear(); + if(!nesting.IsCursor()) { + Item(); + return; + } + LoadItems(set, ~nameing, nesting.GetKey(), item); + if(sort) + item.Sort(CompareItems); + item.GoBegin(); + edit.Enable(item.IsCursor()); +} + +void DocBrowser::Item() +{ + Flush(); + EnterItem(); +} + +void DocBrowser::EnterItem() +{ + String lbl; + target = current = DocKey(~nameing, nesting.GetKey(), item.GetKey(), (int)~lang); + if(doc_dir.GetStatus(current) == DocDir::LINK) + if(!ParseLink(doc_dir.GetLink(current), target, lbl)) { + View(); + view.SetQTF("[R9&&&=@3* Invalid link"); + return; + } + String txt = LoadFile(CommonPath("dppstyles.qtf")) + doc_dir.GetText(target); + package <<= doc_dir.GetPackage(target); + if(edit.IsShown()) { + edit.SetPage(Size(3968, INT_MAX)); + edit.SetQTF(txt); + edit.SetFocus(); + String p = doc_dir.GetFilePath(target); + if(!IsNull(p)) { + int q = editstate.Find(p); + if(q >= 0) { + FileInfo& fi = editstate[q]; + if(fi.time == GetFileTime(p)) { + edit.SetPickUndoInfo(fi.info); + fi.time = Time(1, 1, 1); + } + } + } + int q = posinfo.Find(current); + if(q >= 0) + edit.SetPosInfo(posinfo[q]); + else + if(!lbl.IsEmpty()) + edit.GotoLabel(lbl); + edit.ClearModify(); + } + else { + view.SetQTF(txt); + if(!lbl.IsEmpty()) + view.GotoLabel(lbl); + } + trect.Color(SLtBlue); + title.SetInk(SWhite); + String s = " dpp://" + current.nameing + "/" + current.nesting + "/" + current.item; + switch(GetCurrentStatus()) { + case DocDir::UNDOCUMENTED: + trect.Color(SGray); + break; + case DocDir::LINK: + s << " -> " << target.nameing + "/" + target.nesting + "/" + target.item; + trect.Color(SCyan); + break; + case DocDir::OBSOLETE: + trect.Color(SRed); + break; + case DocDir::EXTERNAL: + trect.Color(SGreen); + break; + } + title = s; + int status = item.Get(4); + int kind = item.Get(2); + String name = item.Get(1); + String text = item.Get(0); + String post; + if(status == DocDir::EXTERNAL) + post = " (external)"; + if(!name.IsEmpty() && status != DocDir::EXTERNAL) { + int q = PosOf(text, name); + if(q >= 0) { + if(current.nesting.IsEmpty() || kind == STRUCT || kind == STRUCTTEMPLATE) + Title(text.Mid(0, q) + current.nameing + text.Mid(q) + post); + else + Title(text.Mid(0, q) + current.nameing + current.nesting + "::" + text.Mid(q) + + post); + return; + } + } + Title(current.nameing + "::" + current.nesting + "::" + text + post); +} + +void DocBrowser::Flush() +{ + if(edit.IsShown() && target && item.IsCursor()) { + posinfo.GetAdd(current) = edit.GetPosInfo(); + if(edit.IsModified()) { + DocItem& im = set.Get(target.nameing).Get(target.nesting).Get(target.item); + const RichText& txt = edit.Get(); + SaveFile(CommonPath("dppstyles.qtf"), StylesAsQTF(txt)); + if(edit.GetLength()) { + doc_dir.SaveText(GetItemPackage(), target, BodyAsQTF(txt), + doc_dir.GetStatus(target) == DocDir::EXTERNAL); + im.status = DocDir::NORMAL; + } + else { + doc_dir.Remove(target); + im.status = DocDir::UNDOCUMENTED; + } + String p = doc_dir.GetFilePath(target); + FileInfo& fi = editstate.GetAdd(p); + fi.time = GetFileTime(p); + fi.info = edit.PickUndoInfo(); + } + target.Clear(); + if(edit.IsModified()) + ReloadItems(); + edit.ClearModify(); + } +} + +void DocBrowser::Query() +{ + DocQuery q; + q.lang = (int)~lang; + q.undocumented = q.normal = q.external = q.obsolete = q.ignored = false; + switch(query.status) { + case 4: + q.ignored = true; + case 0: + q.undocumented = q.normal = q.external = q.obsolete = true; + break; + case 1: + q.undocumented = true; + break; + case 2: + q.obsolete = true; + break; + case 3: + q.ignored = true; + break; + } + q.name = query.name; + q.text = query.text; + q.header = ~query.header; + set = doc_dir.Select(q); + nameing.ClearList(); + for(int i = 0; i < set.GetCount(); i++) + nameing.Add(set.GetKey(i)); + if(nameing.GetCount()) + nameing.SetIndex(0); + Nameing(); +} + +void DocBrowser::Select() +{ + int c; + query.header.ClearList(); + Vector h = doc_base.GetHeaders(); + for(int i = 0; i < h.GetCount(); i++) + query.header.Add(h[i], GetFileName(h[i])); + query.header.Add(Null, ""); + for(;;) { + c = query.Run(); + if(c == IDCANCEL) + break;; + if(c == IDYES) { + query.status = 0; + query.name <<= Null; + query.text <<= Null; + } + if(c == IDOK) + break; + } + query.Close(); + query.name.AddHistory(); + query.text.AddHistory(); + if(c == IDOK) + Query(); +} + +bool DocBrowser::Key(dword key, int) +{ + switch(key) { + case K_F6: + Select(); + break; + default: + return false; + } + return true; +} + +void DocBrowser::Edit() +{ + Flush(); + edit.Show(); + view.Hide(); + EnterItem(); +} + +void DocBrowser::View() +{ + view.Show(); + edit.Hide(); + Item(); +} + +void DocBrowser::Sort() +{ + sort = !sort; + Nesting(); +} + +int DocBrowser::GetCurrentStatus() +{ + return item.IsCursor() ? doc_dir.GetStatus(current) : Null; +} + +void DocBrowser::ReloadItems() +{ + int c = item.GetCursor(); + int a = item.GetCursorSc(); + Nesting(); + if(c >= 0) + item.SetCursor(c); + item.ScCursor(a); +} + +void DocBrowser::SetCurrentStatus(int status) +{ + set.GetAdd(current.nameing).GetAdd(current.nesting).GetAdd(current.item).status = status; + ReloadItems(); +} + +void DocBrowser::Link() +{ + int q = GetCurrentStatus(); + if(q != DocDir::UNDOCUMENTED && q != DocDir::LINK || !item.IsCursor()) + return; + String pk = GetItemPackage(); + String h; + if(GetCurrentStatus() == DocDir::LINK) + h = doc_dir.GetLink(current); + if(linkdlg.Perform(set, sort, h, (int)~lang, ~nameing, nesting.GetKey())) { + int c = item.GetCursor(); + item.KillCursor(); + doc_dir.SaveLink(pk, current, h); + item.SetCursor(c); + SetCurrentStatus(DocDir::LINK); + } +} + +void DocBrowser::Ignore() +{ + int q = GetCurrentStatus(); + if(q != DocDir::UNDOCUMENTED || !item.IsCursor()) return; + int c = item.GetCursor(); + String pk = GetItemPackage(); + item.KillCursor(); + doc_dir.Ignore(pk, current); + item.SetCursor(c); + SetCurrentStatus(DocDir::IGNORED); +} + +void DocBrowser::Delete() +{ + int q = GetCurrentStatus(); + if(q == DocDir::UNDOCUMENTED || !item.IsCursor()) return; + int c = item.GetCursor(); + item.KillCursor(); + switch(q) { + case DocDir::OBSOLETE: + case DocDir::OBSOLETELINK: + break; + default: + if(!PromptYesNo("Remove current current ?")) return; + } + doc_dir.Remove(current); + item.SetCursor(c); + SetCurrentStatus(DocDir::UNDOCUMENTED); +} + +void DocBrowser::New() +{ + + external.package.Add("Core"); //!!! + external.package <<= doc_dir.GetPackage(current); + external.nameing <<= ~nameing; + external.nesting <<= nesting.GetKey(); +again: + if(external.Execute() != IDOK) return; + if(IsNull(external.nameing)) { + Exclamation("Missing namespace !"); + goto again; + } + if(IsNull(external.item)) { + Exclamation("Missing item !"); + goto again; + } + external.nameing.AddHistory(); + external.nesting.AddHistory(); + DocKey k = DocKey(~external.nameing, ~external.nesting, ~external.item, (int)~lang); + doc_dir.SaveText(~external.package, k, "", true); + Query(); + nameing <<= k.nameing; + Nameing(); + if(nesting.FindSetCursor(k.nesting)) + item.FindSetCursor(k.item); +} + +void DocBrowser::EditLink(String& s) +{ + linkdlg.Perform(set, sort, s, (int)~lang, ~nameing, nesting.GetKey()); +} + +void DocBrowser::FollowLink(const String& s) +{ + if(memcmp(s, "dpp://", 6)) { + Exclamation("Not a dpp link !"); + return; + } + Vector l = Split(~s + 6, '/', false); + if(l.GetCount() != 3) { + Exclamation("Invalid link !"); + return; + } + if(nameing.HasKey(l[0])) { + nameing.SetData(l[0]); + Nameing(); + if(nesting.FindSetCursor(l[1])) { + String n = l[2]; + String l; + int q = n.Find('#'); + if(q >= 0) { + l = n.Mid(q + 1); + n = n.Mid(0, q); + } + if(item.FindSetCursor(n)) + return; + } + } + Exclamation("Link not found"); +} + +void DocBrowser::BrowseMenu(Bar& bar) +{ + bar.Add("Select..", THISBACK(Select)) + .Key(K_F6); + bar.Separator(); + bar.Add("Edit", THISBACK(Edit)) + .Radio(edit.IsShown()) + .Key(K_CTRL_O); + bar.Add("View", THISBACK(View)) + .Radio(view.IsShown()) + .Key(edit.IsShown() ? K_ESCAPE : 0); + bar.Separator(); + bar.Add("Sort by types and names", THISBACK(Sort)) + .Check(sort); + bar.Separator(); +} + +void DocBrowser::ItemMenu(Bar& bar) +{ + int q = GetCurrentStatus(); + bar.Add(q == DocDir::UNDOCUMENTED || q == DocDir::LINK, + "Link..", THISBACK(Link)) + .Key(K_CTRL_L); + bar.Add(q == DocDir::UNDOCUMENTED, "Ignore", THISBACK(Ignore)) + .Key(K_CTRL_I); + bar.Add(q != DocDir::UNDOCUMENTED, "Delete", THISBACK(Delete)) + .Key(K_CTRL_DELETE); + bar.Add("New..", THISBACK(New)); +} + +void DocBrowser::MainMenu(Bar& bar) +{ + bar.Add("Browse", THISBACK(BrowseMenu)); + bar.Add("Item", THISBACK(ItemMenu)); +} + +void DocBrowser::EditBar(Bar& bar) +{ + edit.StyleTool(bar); + bar.Gap(); + edit.FontTools(bar); + bar.Gap(); + edit.InkTool(bar); + edit.PaperTool(bar); + bar.Gap(); + edit.LanguageTool(bar); + edit.SpellCheckTool(bar); + bar.Break(); + + edit.HyperlinkTool(bar, 300); + bar.Gap(); + edit.LabelTool(bar); + bar.Gap(); + edit.IndexEntryTool(bar); + bar.Break(); + + edit.ParaTools(bar); + bar.Gap(); + edit.EditTools(bar); + bar.Gap(); + edit.PrintTool(bar); +} + +void DocBrowser::SetEditBar() +{ + editbar.Set(THISBACK(EditBar)); +} + +void DocBrowser::SetMainBar() +{ + menu.Set(THISBACK(MainMenu)); +} + +void DocBrowser::Close() +{ + Flush(); + TopWindow::Close(); +} + +DocBrowser::DocBrowser() +{ + Zoomable().Sizeable().Icon(DppImg::SmallIcon); + ni_split.Vert(nesting, item); + ni_split.SetPos(3000); + int q = nameing.GetMinSize().cy; + larea.Add(nameing.HSizePos().TopPos(0, q)); + larea.Add(ni_split.HSizePos().VSizePos(q + 4, 0)); + rarea.AddFrame(trect.Height(q + 4)); + trect.SetFrame(ThinInsetFrame()); + trect.Add(title.SizePos()); + trect.Add(package.RightPos(0, 100).VSizePos()); + rarea.Add(view.SizePos()); + rarea.Add(edit.SizePos()); + vi_split.Horz(larea, rarea); + vi_split.SetPos(3000); + Add(vi_split); + nesting.AddColumn().SetDisplay(Single()); + nesting.NoHeader().NoGrid(); + nameing <<= THISBACK(Nameing); + nesting.WhenEnterRow = THISBACK(Nesting); + InitItemArray(item); + item.WhenEnterRow = THISBACK(Item); + item.WhenKillCursor = THISBACK(Flush); + item.WhenBar = THISBACK(ItemMenu); + item.WhenLeftDouble = THISBACK(Edit); + + view.Show(); + edit.Hide(); + edit.SetPage(Size(3968, INT_MAX)); + + CtrlLayoutOKCancel(query, "Select"); + query.clear <<= query.Breaker(IDYES); + query.status = 0; + + AddFrame(menu); + SetMainBar(); + menu.Ctrl::Add(lang.RightPos(10, 70).TopPos(0, EditField::GetStdHeight())); + lang.Add((int)LNG_ENGLISH, "EN-US"); + lang.Add((int)LNGFromText("EN-GB"), "EN-GB"); + lang.Add((int)LNGFromText("DE-DE"), "DE-DE"); + lang.Add((int)LNG_CZECH, "CS-CZ"); + lang <<= (int)LNGFromText("EN-US"); + lang <<= THISBACK(Query); + + edit.InsertFrame(1, editbar); + edit.WhenRefreshBar = THISBACK(SetEditBar); + edit.WhenHyperlink = THISBACK(EditLink); + + view.WhenLink = THISBACK(FollowLink); + + sort = false; + + CtrlLayoutOKCancel(external, "New external item"); + external.ActiveFocus(external.item); +} + +void AppMain() +{ + doc_base.ignore.Add("pick_"); + FindFile ff("f:/uppsrc/Core/*.h"); + while(ff) { + String fn = String("f:/uppsrc/Core/") + ff.GetName(); + try { + doc_base.ParseFile(fn, "Core"); + } + catch(Parser::Error e) { + LOG(e); + } + ff.Next(); + } + doc_dir.Refresh("Core"); + DocBrowser d; + d.Query(); + d.Run(); +} diff --git a/uppsrc/Docedit/Docedit.h b/archive/uppsrc/Docedit/Docedit.h similarity index 96% rename from uppsrc/Docedit/Docedit.h rename to archive/uppsrc/Docedit/Docedit.h index 650f15e89..4dcd2341e 100644 --- a/uppsrc/Docedit/Docedit.h +++ b/archive/uppsrc/Docedit/Docedit.h @@ -1,241 +1,241 @@ -#include -#include - -#define IMAGECLASS DppImg -#define IMAGEFILE -#include - -// before placed to IDE... - -String SourcePath(const String& package, const String& name); -String PackageDirectory(const String& name); -String CommonPath(const String& filename); - -// ------ - -struct DocBase : public CppBase { - Vector DocBase::ignore; - Vector package; - - void RemoveFile(const String& file); - void ParseFile(const String& file, const String& package) throw(Parser::Error); - void RefreshFile(const String& file, const String& package) throw(Parser::Error); - Vector GetHeaders(); - Vector GetPackages(); -}; - -extern DocBase doc_base; - -Time GetFileTime(const char *path); -String DocFile(const String& package, const String& name); - -struct DocKey { - String nameing; - String nesting; - String item; - dword lang; - - bool operator==(const DocKey& b) const; - dword GetHashValue(const DocKey& k); - operator bool() const { return item.GetLength(); } - void Clear() { item.Clear(); nesting.Clear(); nameing.Clear(); lang = 0; } - - DocKey() {} - DocKey(const String& m, const String& n, const String& s, dword l) - : nameing(m), nesting(n), item(s), lang(l) {} -}; - -dword GetHashValue(const DocKey& k); - -struct DocQuery { - String name, text, package, header; - bool undocumented, normal, external, obsolete, ignored; - dword lang; -}; - -struct DocItem { - CppItem *cppitem; - String item; - int status; - String package; -}; - -typedef VectorMap > > DocSet; - -class DocDir { - struct Entry { - int type; - String text; - }; - VectorMap > dir; - - int ReadDocHeader(const char *filename, DocKey& key); - String GetAddFileName(const String& package, const DocKey& key, int type); - bool GetFileName(const DocKey& key, String& fn, String& package); - - bool LoadLinks(const String& package); - void SaveLinks(const String& package) const; - - void RemoveOtherKey(const DocKey& k, int t1, int t2 = UNDOCUMENTED); - Entry *Find(const DocKey& key, String& package) const; - Entry *Find(const DocKey& key) const; - -public: - enum { - NORMAL, EXTERNAL, LINK, IGNORED, - UNDOCUMENTED = -1, OBSOLETE = -2, OBSOLETELINK = -3 - }; - - bool LoadDir(const String& package); - void SaveDir(const String& package) const; - - void RebuildDir(const String& package); - - void Refresh(const String& package); - - int GetStatus(const DocKey& key); - int GetStatus(const String& nameing, const String& nesting, const String& item, int lang); - - String GetFilePath(const DocKey& key) const; - String GetPackage(const DocKey& key) const; - String GetText(const DocKey& key) const; - String GetLink(const DocKey& key) const; - - void Remove(const DocKey& key); - void SaveText(const String& package, const DocKey& key, const String& text, bool external); - void SaveLink(const String& package, const DocKey& key, const String& text); - void Ignore(const String& package, const DocKey& key); - - DocSet Select(const DocQuery& query); -}; - -bool ParseLink(const String& link, DocKey& key, String& label); - -extern DocDir doc_dir; - -#define LAYOUTFILE "DocEdit.lay" -#include - -struct DocItemDisplay : public Display -{ - virtual void Paint(Draw& w, const Rect& r, const Value& q, - Color _ink, Color paper, dword style) const; -}; - -struct DocNestDisplay : public Display -{ - virtual void Paint(Draw& w, const Rect& r, const Value& q, - Color _ink, Color paper, dword style) const; -}; - -void InitItemArray(ArrayCtrl& item); -void LoadItems(const DocSet& set, const String& nameing, const String& nesting, ArrayCtrl& item); -int PosOf(const String& s, const String& subs); -bool IsCppKeyword(const String& id); -int CompareNests(const Value& v1, const Value& v2); -int CompareItems(const Vector& row1, const Vector& row2); - -struct DocLinkDlg : public WithLinkLayout { - const DocSet *set; - bool sort; - dword lang; - - void Nameing(); - void Nesting(); - void Item(); - bool Perform(const DocSet& set, bool sort, String& link, int lang, - const String& nameing = Null, const String& nesting = Null); - void Label(); - String Get(); - - typedef DocLinkDlg CLASSNAME; - - DocLinkDlg(); -}; - -class DocBrowser : public TopWindow { -public: - virtual bool Key(dword key, int count); - virtual void Close(); - -private: - struct FileInfo { - Time time; - RichEdit::UndoInfo info; - }; - - ArrayMap editstate; - ArrayMap posinfo; - - DropList nameing; - StaticRect larea, rarea; - ArrayCtrl nesting; - ArrayCtrl item; - Splitter ni_split; - Splitter vi_split; - - FrameTop trect; - Label title; - DataPusher package; - RichTextView view; - RichEdit edit; - - DropList lang; - - MenuBar menu; - ToolBar tool; - - ToolBar editbar; - - WithQueryLayout query; - DocSet set; - DocKey current, target; - - DocLinkDlg linkdlg; - - bool sort; - - WithExternalLayout external; - - void Nameing(); - void Nesting(); - void Item(); - void EnterItem(); - - void ReloadItems(); - - DocKey Key(); - void Flush(); - int GetCurrentStatus(); - void SetCurrentStatus(int status); - String GetItemPackage() { return item.Get(7); } - - void EditLink(String& s); - - void Edit(); - void View(); - void Sort(); - void Select(); - void Link(); - void Ignore(); - void Delete(); - void New(); - - void FollowLink(const String& s); - - void SetMainBar(); - - void MainMenu(Bar& bar); - void ItemMenu(Bar& bar); - void BrowseMenu(Bar& bar); - - void EditBar(Bar& bar); - void SetEditBar(); - -public: - typedef DocBrowser CLASSNAME; - - void Query(); - - DocBrowser(); -}; +#include +#include + +#define IMAGECLASS DppImg +#define IMAGEFILE +#include + +// before placed to IDE... + +String SourcePath(const String& package, const String& name); +String PackageDirectory(const String& name); +String CommonPath(const String& filename); + +// ------ + +struct DocBase : public CppBase { + Vector DocBase::ignore; + Vector package; + + void RemoveFile(const String& file); + void ParseFile(const String& file, const String& package) throw(Parser::Error); + void RefreshFile(const String& file, const String& package) throw(Parser::Error); + Vector GetHeaders(); + Vector GetPackages(); +}; + +extern DocBase doc_base; + +Time GetFileTime(const char *path); +String DocFile(const String& package, const String& name); + +struct DocKey { + String nameing; + String nesting; + String item; + dword lang; + + bool operator==(const DocKey& b) const; + dword GetHashValue(const DocKey& k); + operator bool() const { return item.GetLength(); } + void Clear() { item.Clear(); nesting.Clear(); nameing.Clear(); lang = 0; } + + DocKey() {} + DocKey(const String& m, const String& n, const String& s, dword l) + : nameing(m), nesting(n), item(s), lang(l) {} +}; + +dword GetHashValue(const DocKey& k); + +struct DocQuery { + String name, text, package, header; + bool undocumented, normal, external, obsolete, ignored; + dword lang; +}; + +struct DocItem { + CppItem *cppitem; + String item; + int status; + String package; +}; + +typedef VectorMap > > DocSet; + +class DocDir { + struct Entry { + int type; + String text; + }; + VectorMap > dir; + + int ReadDocHeader(const char *filename, DocKey& key); + String GetAddFileName(const String& package, const DocKey& key, int type); + bool GetFileName(const DocKey& key, String& fn, String& package); + + bool LoadLinks(const String& package); + void SaveLinks(const String& package) const; + + void RemoveOtherKey(const DocKey& k, int t1, int t2 = UNDOCUMENTED); + Entry *Find(const DocKey& key, String& package) const; + Entry *Find(const DocKey& key) const; + +public: + enum { + NORMAL, EXTERNAL, LINK, IGNORED, + UNDOCUMENTED = -1, OBSOLETE = -2, OBSOLETELINK = -3 + }; + + bool LoadDir(const String& package); + void SaveDir(const String& package) const; + + void RebuildDir(const String& package); + + void Refresh(const String& package); + + int GetStatus(const DocKey& key); + int GetStatus(const String& nameing, const String& nesting, const String& item, int lang); + + String GetFilePath(const DocKey& key) const; + String GetPackage(const DocKey& key) const; + String GetText(const DocKey& key) const; + String GetLink(const DocKey& key) const; + + void Remove(const DocKey& key); + void SaveText(const String& package, const DocKey& key, const String& text, bool external); + void SaveLink(const String& package, const DocKey& key, const String& text); + void Ignore(const String& package, const DocKey& key); + + DocSet Select(const DocQuery& query); +}; + +bool ParseLink(const String& link, DocKey& key, String& label); + +extern DocDir doc_dir; + +#define LAYOUTFILE "DocEdit.lay" +#include + +struct DocItemDisplay : public Display +{ + virtual void Paint(Draw& w, const Rect& r, const Value& q, + Color _ink, Color paper, dword style) const; +}; + +struct DocNestDisplay : public Display +{ + virtual void Paint(Draw& w, const Rect& r, const Value& q, + Color _ink, Color paper, dword style) const; +}; + +void InitItemArray(ArrayCtrl& item); +void LoadItems(const DocSet& set, const String& nameing, const String& nesting, ArrayCtrl& item); +int PosOf(const String& s, const String& subs); +bool IsCppKeyword(const String& id); +int CompareNests(const Value& v1, const Value& v2); +int CompareItems(const Vector& row1, const Vector& row2); + +struct DocLinkDlg : public WithLinkLayout { + const DocSet *set; + bool sort; + dword lang; + + void Nameing(); + void Nesting(); + void Item(); + bool Perform(const DocSet& set, bool sort, String& link, int lang, + const String& nameing = Null, const String& nesting = Null); + void Label(); + String Get(); + + typedef DocLinkDlg CLASSNAME; + + DocLinkDlg(); +}; + +class DocBrowser : public TopWindow { +public: + virtual bool Key(dword key, int count); + virtual void Close(); + +private: + struct FileInfo { + Time time; + RichEdit::UndoInfo info; + }; + + ArrayMap editstate; + ArrayMap posinfo; + + DropList nameing; + StaticRect larea, rarea; + ArrayCtrl nesting; + ArrayCtrl item; + Splitter ni_split; + Splitter vi_split; + + FrameTop trect; + Label title; + DataPusher package; + RichTextView view; + RichEdit edit; + + DropList lang; + + MenuBar menu; + ToolBar tool; + + ToolBar editbar; + + WithQueryLayout query; + DocSet set; + DocKey current, target; + + DocLinkDlg linkdlg; + + bool sort; + + WithExternalLayout external; + + void Nameing(); + void Nesting(); + void Item(); + void EnterItem(); + + void ReloadItems(); + + DocKey Key(); + void Flush(); + int GetCurrentStatus(); + void SetCurrentStatus(int status); + String GetItemPackage() { return item.Get(7); } + + void EditLink(String& s); + + void Edit(); + void View(); + void Sort(); + void Select(); + void Link(); + void Ignore(); + void Delete(); + void New(); + + void FollowLink(const String& s); + + void SetMainBar(); + + void MainMenu(Bar& bar); + void ItemMenu(Bar& bar); + void BrowseMenu(Bar& bar); + + void EditBar(Bar& bar); + void SetEditBar(); + +public: + typedef DocBrowser CLASSNAME; + + void Query(); + + DocBrowser(); +}; diff --git a/uppsrc/Docedit/Docedit.iml b/archive/uppsrc/Docedit/Docedit.iml similarity index 98% rename from uppsrc/Docedit/Docedit.iml rename to archive/uppsrc/Docedit/Docedit.iml index d0449c13d..c3f98a271 100644 --- a/uppsrc/Docedit/Docedit.iml +++ b/archive/uppsrc/Docedit/Docedit.iml @@ -1,53 +1,53 @@ -PREMULTIPLIED -IMAGE_ID(Variable) -IMAGE_ID(SmallIcon) -IMAGE_ID(InstanceVariable) -IMAGE_ID(ClassVariable) -IMAGE_ID(Function) -IMAGE_ID(InstanceFunction) -IMAGE_ID(InlineFriend) -IMAGE_ID(ClassFunction) -IMAGE_ID(FunctionTemplate) -IMAGE_ID(InstanceFunctionTemplate) -IMAGE_ID(ClassFunctionTemplate) -IMAGE_ID(Enum) -IMAGE_ID(Protected) -IMAGE_ID(Struct) -IMAGE_ID(StructTemplate) -IMAGE_ID(Other) -IMAGE_ID(Typedef) -IMAGE_ID(Constructor) -IMAGE_ID(Destructor) -IMAGE_ID(Macro) - -IMAGE_BEGIN_DATA -IMAGE_DATA(120,156,237,152,11,146,131,32,12,134,115,132,30,185,71,243,102,217,105,187,190,32,228,137,21,107,226,48,221,110,249,18) -IMAGE_DATA(192,248,19,129,7,60,0,0,17,86,67,69,147,236,211,175,117,89,252,112,215,119,124,212,227,246,142,225,181,208,136,30) -IMAGE_DATA(31,103,242,209,249,71,214,223,203,70,242,175,71,254,95,211,8,49,104,153,117,17,202,254,210,119,142,71,152,147,88,199) -IMAGE_DATA(151,201,82,242,136,80,249,235,197,215,137,135,184,182,127,118,110,132,143,8,223,78,126,157,143,40,127,246,252,123,220,191) -IMAGE_DATA(30,60,144,243,226,191,247,230,237,118,64,101,64,239,32,58,101,174,110,60,123,145,137,84,240,54,31,60,175,219,25,169) -IMAGE_DATA(249,45,125,179,50,112,198,182,177,89,25,120,44,95,19,12,201,236,123,24,86,31,223,121,152,35,98,132,65,49,228,121) -IMAGE_DATA(121,253,107,222,126,239,34,155,81,185,126,183,23,3,141,69,22,36,178,160,33,22,245,15,111,119,214,201,111,31,13,107) -IMAGE_DATA(114,238,88,170,113,108,171,5,230,178,140,233,4,22,224,188,188,155,249,241,173,33,6,26,245,108,25,181,59,80,190,61) -IMAGE_DATA(188,114,23,37,121,75,50,149,243,79,49,72,49,184,173,24,72,118,187,202,96,154,166,16,235,21,131,153,221,196,87,139) -IMAGE_DATA(193,150,165,62,57,182,213,12,115,169,229,199,42,200,126,182,246,225,207,157,8,187,245,49,190,165,24,124,135,205,202,96) -IMAGE_DATA(29,211,134,181,60,104,53,203,87,160,21,95,244,177,240,212,239,86,158,243,59,134,88,12,46,6,229,98,181,18,73,149) -IMAGE_DATA(76,198,221,125,23,171,96,45,177,223,172,179,178,88,88,111,101,192,53,142,109,181,192,92,150,49,41,88,106,126,220,61) -IMAGE_DATA(80,197,86,246,37,99,7,226,206,204,248,118,128,24,136,73,202,254,70,157,70,235,197,128,61,111,80,36,98,243,188,193) -IMAGE_DATA(32,6,100,18,167,24,172,99,82,176,41,6,103,88,86,6,170,113,102,101,160,23,3,110,92,50,75,111,6,20,75,197) -IMAGE_DATA(57,236,240,89,136,187,247,65,141,235,10,230,20,131,163,141,75,124,233,97,144,94,149,171,86,248,40,255,159,241,239,21) -IMAGE_DATA(31,12,113,61,2,63,174,213,98,240,124,125,193,167,123,146,31,254,253,151,203,71,198,207,248,87,142,127,97,99,42,131) -IMAGE_DATA(136,42,234,133,153,82,101,155,176,215,37,89,242,119,230,163,249,183,250,184,83,85,240,178,163,196,64,122,95,101,222,61) -IMAGE_DATA(165,190,187,70,248,96,251,42,198,144,241,175,29,159,245,209,227,220,164,104,191,99,131,158,25,80,102,175,78,54,173,101) -IMAGE_DATA(28,175,49,137,111,37,97,198,63,63,62,195,138,241,5,22,224,130,34,242,7,126,154,4,137,0,0,0,0,0,0,0) -IMAGE_END_DATA(608, 16) - -IMAGE_BEGIN_DATA -IMAGE_DATA(120,156,237,150,137,13,195,48,8,69,25,33,35,103,52,111,70,213,86,74,28,204,241,125,201,74,90,34,164,28,188,143) -IMAGE_DATA(141,45,28,218,104,35,34,102,26,111,108,56,206,107,23,174,161,243,184,134,205,99,26,62,31,107,196,188,175,49,55,127) -IMAGE_DATA(207,252,123,234,95,179,254,125,251,239,247,172,178,25,212,22,51,143,103,46,23,211,221,140,34,62,122,142,52,172,251,112) -IMAGE_DATA(14,239,88,233,0,123,201,101,240,150,142,202,88,110,105,116,228,31,49,255,131,165,182,250,15,89,127,71,79,126,71,236) -IMAGE_DATA(217,205,100,226,159,193,104,107,237,238,95,102,223,79,199,117,174,156,116,164,33,180,243,62,27,107,172,230,87,215,239,212) -IMAGE_DATA(104,95,255,82,231,201,13,193,105,6,218,233,81,117,162,164,148,62,158,243,202,59,51,175,136,53,223,89,121,17,159,193) -IMAGE_DATA(119,142,255,95,191,181,245,43,198,145,243,64,222,219,218,11,170,178,33,106,0,0,0,0,0,0,0,0,0,0,0,0) -IMAGE_END_DATA(224, 4) +PREMULTIPLIED +IMAGE_ID(Variable) +IMAGE_ID(SmallIcon) +IMAGE_ID(InstanceVariable) +IMAGE_ID(ClassVariable) +IMAGE_ID(Function) +IMAGE_ID(InstanceFunction) +IMAGE_ID(InlineFriend) +IMAGE_ID(ClassFunction) +IMAGE_ID(FunctionTemplate) +IMAGE_ID(InstanceFunctionTemplate) +IMAGE_ID(ClassFunctionTemplate) +IMAGE_ID(Enum) +IMAGE_ID(Protected) +IMAGE_ID(Struct) +IMAGE_ID(StructTemplate) +IMAGE_ID(Other) +IMAGE_ID(Typedef) +IMAGE_ID(Constructor) +IMAGE_ID(Destructor) +IMAGE_ID(Macro) + +IMAGE_BEGIN_DATA +IMAGE_DATA(120,156,237,152,11,146,131,32,12,134,115,132,30,185,71,243,102,217,105,187,190,32,228,137,21,107,226,48,221,110,249,18) +IMAGE_DATA(192,248,19,129,7,60,0,0,17,86,67,69,147,236,211,175,117,89,252,112,215,119,124,212,227,246,142,225,181,208,136,30) +IMAGE_DATA(31,103,242,209,249,71,214,223,203,70,242,175,71,254,95,211,8,49,104,153,117,17,202,254,210,119,142,71,152,147,88,199) +IMAGE_DATA(151,201,82,242,136,80,249,235,197,215,137,135,184,182,127,118,110,132,143,8,223,78,126,157,143,40,127,246,252,123,220,191) +IMAGE_DATA(30,60,144,243,226,191,247,230,237,118,64,101,64,239,32,58,101,174,110,60,123,145,137,84,240,54,31,60,175,219,25,169) +IMAGE_DATA(249,45,125,179,50,112,198,182,177,89,25,120,44,95,19,12,201,236,123,24,86,31,223,121,152,35,98,132,65,49,228,121) +IMAGE_DATA(121,253,107,222,126,239,34,155,81,185,126,183,23,3,141,69,22,36,178,160,33,22,245,15,111,119,214,201,111,31,13,107) +IMAGE_DATA(114,238,88,170,113,108,171,5,230,178,140,233,4,22,224,188,188,155,249,241,173,33,6,26,245,108,25,181,59,80,190,61) +IMAGE_DATA(188,114,23,37,121,75,50,149,243,79,49,72,49,184,173,24,72,118,187,202,96,154,166,16,235,21,131,153,221,196,87,139) +IMAGE_DATA(193,150,165,62,57,182,213,12,115,169,229,199,42,200,126,182,246,225,207,157,8,187,245,49,190,165,24,124,135,205,202,96) +IMAGE_DATA(29,211,134,181,60,104,53,203,87,160,21,95,244,177,240,212,239,86,158,243,59,134,88,12,46,6,229,98,181,18,73,149) +IMAGE_DATA(76,198,221,125,23,171,96,45,177,223,172,179,178,88,88,111,101,192,53,142,109,181,192,92,150,49,41,88,106,126,220,61) +IMAGE_DATA(80,197,86,246,37,99,7,226,206,204,248,118,128,24,136,73,202,254,70,157,70,235,197,128,61,111,80,36,98,243,188,193) +IMAGE_DATA(32,6,100,18,167,24,172,99,82,176,41,6,103,88,86,6,170,113,102,101,160,23,3,110,92,50,75,111,6,20,75,197) +IMAGE_DATA(57,236,240,89,136,187,247,65,141,235,10,230,20,131,163,141,75,124,233,97,144,94,149,171,86,248,40,255,159,241,239,21) +IMAGE_DATA(31,12,113,61,2,63,174,213,98,240,124,125,193,167,123,146,31,254,253,151,203,71,198,207,248,87,142,127,97,99,42,131) +IMAGE_DATA(136,42,234,133,153,82,101,155,176,215,37,89,242,119,230,163,249,183,250,184,83,85,240,178,163,196,64,122,95,101,222,61) +IMAGE_DATA(165,190,187,70,248,96,251,42,198,144,241,175,29,159,245,209,227,220,164,104,191,99,131,158,25,80,102,175,78,54,173,101) +IMAGE_DATA(28,175,49,137,111,37,97,198,63,63,62,195,138,241,5,22,224,130,34,242,7,126,154,4,137,0,0,0,0,0,0,0) +IMAGE_END_DATA(608, 16) + +IMAGE_BEGIN_DATA +IMAGE_DATA(120,156,237,150,137,13,195,48,8,69,25,33,35,103,52,111,70,213,86,74,28,204,241,125,201,74,90,34,164,28,188,143) +IMAGE_DATA(141,45,28,218,104,35,34,102,26,111,108,56,206,107,23,174,161,243,184,134,205,99,26,62,31,107,196,188,175,49,55,127) +IMAGE_DATA(207,252,123,234,95,179,254,125,251,239,247,172,178,25,212,22,51,143,103,46,23,211,221,140,34,62,122,142,52,172,251,112) +IMAGE_DATA(14,239,88,233,0,123,201,101,240,150,142,202,88,110,105,116,228,31,49,255,131,165,182,250,15,89,127,71,79,126,71,236) +IMAGE_DATA(217,205,100,226,159,193,104,107,237,238,95,102,223,79,199,117,174,156,116,164,33,180,243,62,27,107,172,230,87,215,239,212) +IMAGE_DATA(104,95,255,82,231,201,13,193,105,6,218,233,81,117,162,164,148,62,158,243,202,59,51,175,136,53,223,89,121,17,159,193) +IMAGE_DATA(119,142,255,95,191,181,245,43,198,145,243,64,222,219,218,11,170,178,33,106,0,0,0,0,0,0,0,0,0,0,0,0) +IMAGE_END_DATA(224, 4) diff --git a/uppsrc/Docedit/Docedit.lay b/archive/uppsrc/Docedit/Docedit.lay similarity index 98% rename from uppsrc/Docedit/Docedit.lay rename to archive/uppsrc/Docedit/Docedit.lay index 4560f8373..5e1f14410 100644 --- a/uppsrc/Docedit/Docedit.lay +++ b/archive/uppsrc/Docedit/Docedit.lay @@ -1,48 +1,48 @@ -#ifdef LAYOUTFILE - -LAYOUT(QueryLayout, 372, 120) - ITEM(LabelBox, dv___0, LeftPosZ(8, 132).TopPosZ(4, 108).SetLabel("Status")) - ITEM(Switch, status, LeftPosZ(16, 117).TopPosZ(20, 85).SetLabel("Any except ignored\nUndocumented\nObsolete\nIgnored\nAny")) - ITEM(Label, dv___2, LeftPosZ(152, 48).TopPosZ(12, 13).SetLabel("Name")) - ITEM(WithDropChoice, name, LeftPosZ(204, 160).TopPosZ(8, 19)) - ITEM(Label, dv___4, LeftPosZ(152, 48).TopPosZ(36, 13).SetLabel("Contains")) - ITEM(WithDropChoice, text, LeftPosZ(204, 160).TopPosZ(32, 19)) - ITEM(Label, dv___6, LeftPosZ(152, 44).TopPosZ(59, 13).SetLabel("Header")) - ITEM(DropList, header, LeftPosZ(204, 160).TopPosZ(56, 19)) - ITEM(Button, ok, LeftPosZ(232, 64).TopPosZ(88, 24).SetLabel("OK")) - ITEM(Button, cancel, LeftPosZ(300, 64).TopPosZ(88, 24).SetLabel("Cancel")) - ITEM(Button, clear, LeftPosZ(152, 64).TopPosZ(88, 24).SetLabel("Clear")) -END_LAYOUT - -LAYOUT(LinkLayout, 632, 500) - ITEM(Label, dv___0, LeftPosZ(8, 28).TopPosZ(12, 13).SetLabel("Link")) - ITEM(WithDropChoice, link, LeftPosZ(44, 580).TopPosZ(8, 19)) - ITEM(DropList, nameing, LeftPosZ(8, 224).TopPosZ(36, 19)) - ITEM(ArrayCtrl, nesting, LeftPosZ(8, 224).TopPosZ(60, 400)) - ITEM(ArrayCtrl, item, LeftPosZ(240, 384).TopPosZ(36, 300)) - ITEM(ArrayCtrl, label, LeftPosZ(240, 384).TopPosZ(340, 120)) - ITEM(Button, ok, LeftPosZ(492, 64).TopPosZ(468, 24).SetLabel("OK")) - ITEM(Button, cancel, LeftPosZ(560, 64).TopPosZ(468, 24).SetLabel("Cancel")) -END_LAYOUT - -LAYOUT(ExternalLayout, 400, 108) - ITEM(Label, dv___0, LeftPosZ(4, 68).TopPosZ(8, 13).SetLabel("Namespace")) - ITEM(WithDropChoice, nameing, LeftPosZ(80, 76).TopPosZ(4, 19)) - ITEM(Label, dv___2, LeftPosZ(176, 43).TopPosZ(8, 13).SetLabel("Nesting")) - ITEM(WithDropChoice, nesting, LeftPosZ(224, 168).TopPosZ(4, 19)) - ITEM(Label, dv___4, LeftPosZ(4, 28).TopPosZ(31, 13).SetLabel("Item")) - ITEM(EditString, item, LeftPosZ(80, 312).TopPosZ(28, 19)) - ITEM(Label, dv___6, LeftPosZ(4, 72).TopPosZ(56, 13).SetLabel("Host package")) - ITEM(DropList, package, LeftPosZ(80, 100).TopPosZ(52, 19)) - ITEM(Button, ok, LeftPosZ(260, 64).TopPosZ(76, 24).SetLabel("OK")) - ITEM(Button, cancel, LeftPosZ(328, 64).TopPosZ(76, 24).SetLabel("Cancel")) -END_LAYOUT - -LAYOUT(TemplateLayout, 672, 568) - ITEM(Button, ok, LeftPosZ(532, 64).TopPosZ(536, 24).SetLabel("OK")) - ITEM(Button, cancel, LeftPosZ(600, 64).TopPosZ(536, 24).SetLabel("Cancel")) - ITEM(DocEdit, code, LeftPosZ(164, 500).TopPosZ(8, 160)) - ITEM(RichTextView, view, LeftPosZ(164, 500).TopPosZ(172, 352)) -END_LAYOUT - -#endif +#ifdef LAYOUTFILE + +LAYOUT(QueryLayout, 372, 120) + ITEM(LabelBox, dv___0, LeftPosZ(8, 132).TopPosZ(4, 108).SetLabel("Status")) + ITEM(Switch, status, LeftPosZ(16, 117).TopPosZ(20, 85).SetLabel("Any except ignored\nUndocumented\nObsolete\nIgnored\nAny")) + ITEM(Label, dv___2, LeftPosZ(152, 48).TopPosZ(12, 13).SetLabel("Name")) + ITEM(WithDropChoice, name, LeftPosZ(204, 160).TopPosZ(8, 19)) + ITEM(Label, dv___4, LeftPosZ(152, 48).TopPosZ(36, 13).SetLabel("Contains")) + ITEM(WithDropChoice, text, LeftPosZ(204, 160).TopPosZ(32, 19)) + ITEM(Label, dv___6, LeftPosZ(152, 44).TopPosZ(59, 13).SetLabel("Header")) + ITEM(DropList, header, LeftPosZ(204, 160).TopPosZ(56, 19)) + ITEM(Button, ok, LeftPosZ(232, 64).TopPosZ(88, 24).SetLabel("OK")) + ITEM(Button, cancel, LeftPosZ(300, 64).TopPosZ(88, 24).SetLabel("Cancel")) + ITEM(Button, clear, LeftPosZ(152, 64).TopPosZ(88, 24).SetLabel("Clear")) +END_LAYOUT + +LAYOUT(LinkLayout, 632, 500) + ITEM(Label, dv___0, LeftPosZ(8, 28).TopPosZ(12, 13).SetLabel("Link")) + ITEM(WithDropChoice, link, LeftPosZ(44, 580).TopPosZ(8, 19)) + ITEM(DropList, nameing, LeftPosZ(8, 224).TopPosZ(36, 19)) + ITEM(ArrayCtrl, nesting, LeftPosZ(8, 224).TopPosZ(60, 400)) + ITEM(ArrayCtrl, item, LeftPosZ(240, 384).TopPosZ(36, 300)) + ITEM(ArrayCtrl, label, LeftPosZ(240, 384).TopPosZ(340, 120)) + ITEM(Button, ok, LeftPosZ(492, 64).TopPosZ(468, 24).SetLabel("OK")) + ITEM(Button, cancel, LeftPosZ(560, 64).TopPosZ(468, 24).SetLabel("Cancel")) +END_LAYOUT + +LAYOUT(ExternalLayout, 400, 108) + ITEM(Label, dv___0, LeftPosZ(4, 68).TopPosZ(8, 13).SetLabel("Namespace")) + ITEM(WithDropChoice, nameing, LeftPosZ(80, 76).TopPosZ(4, 19)) + ITEM(Label, dv___2, LeftPosZ(176, 43).TopPosZ(8, 13).SetLabel("Nesting")) + ITEM(WithDropChoice, nesting, LeftPosZ(224, 168).TopPosZ(4, 19)) + ITEM(Label, dv___4, LeftPosZ(4, 28).TopPosZ(31, 13).SetLabel("Item")) + ITEM(EditString, item, LeftPosZ(80, 312).TopPosZ(28, 19)) + ITEM(Label, dv___6, LeftPosZ(4, 72).TopPosZ(56, 13).SetLabel("Host package")) + ITEM(DropList, package, LeftPosZ(80, 100).TopPosZ(52, 19)) + ITEM(Button, ok, LeftPosZ(260, 64).TopPosZ(76, 24).SetLabel("OK")) + ITEM(Button, cancel, LeftPosZ(328, 64).TopPosZ(76, 24).SetLabel("Cancel")) +END_LAYOUT + +LAYOUT(TemplateLayout, 672, 568) + ITEM(Button, ok, LeftPosZ(532, 64).TopPosZ(536, 24).SetLabel("OK")) + ITEM(Button, cancel, LeftPosZ(600, 64).TopPosZ(536, 24).SetLabel("Cancel")) + ITEM(DocEdit, code, LeftPosZ(164, 500).TopPosZ(8, 160)) + ITEM(RichTextView, view, LeftPosZ(164, 500).TopPosZ(172, 352)) +END_LAYOUT + +#endif diff --git a/uppsrc/Docedit/Docedit.upp b/archive/uppsrc/Docedit/Docedit.upp similarity index 91% rename from uppsrc/Docedit/Docedit.upp rename to archive/uppsrc/Docedit/Docedit.upp index 6ce06d047..40b910b8e 100644 --- a/uppsrc/Docedit/Docedit.upp +++ b/archive/uppsrc/Docedit/Docedit.upp @@ -1,15 +1,15 @@ -uses - docpp, - RichEdit; - -file - Docedit.h, - Docbase.cpp, - Docdir.cpp, - DocItem.cpp, - DocLink.cpp, - Docedit.cpp, - Docedit.iml, - Info readonly separator, - Copying; - +uses + docpp, + RichEdit; + +file + Docedit.h, + Docbase.cpp, + Docdir.cpp, + DocItem.cpp, + DocLink.cpp, + Docedit.cpp, + Docedit.iml, + Info readonly separator, + Copying; + diff --git a/archive/uppsrc/TCore/Copying b/archive/uppsrc/TCore/Copying index 9159e0082..27fc52607 100644 --- a/archive/uppsrc/TCore/Copying +++ b/archive/uppsrc/TCore/Copying @@ -1,4 +1,4 @@ -Copyright (c) 1998, 2019, The U++ Project +Copyright (c) 1998, 2020, The U++ Project All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted diff --git a/archive/uppsrc/TCtrlLib/Copying b/archive/uppsrc/TCtrlLib/Copying index 9159e0082..27fc52607 100644 --- a/archive/uppsrc/TCtrlLib/Copying +++ b/archive/uppsrc/TCtrlLib/Copying @@ -1,4 +1,4 @@ -Copyright (c) 1998, 2019, The U++ Project +Copyright (c) 1998, 2020, The U++ Project All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted diff --git a/archive/uppsrc/TDraw/Copying b/archive/uppsrc/TDraw/Copying index 9159e0082..27fc52607 100644 --- a/archive/uppsrc/TDraw/Copying +++ b/archive/uppsrc/TDraw/Copying @@ -1,4 +1,4 @@ -Copyright (c) 1998, 2019, The U++ Project +Copyright (c) 1998, 2020, The U++ Project All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted diff --git a/archive/uppsrc/TSql/Copying b/archive/uppsrc/TSql/Copying index 9159e0082..27fc52607 100644 --- a/archive/uppsrc/TSql/Copying +++ b/archive/uppsrc/TSql/Copying @@ -1,4 +1,4 @@ -Copyright (c) 1998, 2019, The U++ Project +Copyright (c) 1998, 2020, The U++ Project All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted diff --git a/archive/uppsrc/Web/Copying b/archive/uppsrc/Web/Copying index 9159e0082..27fc52607 100644 --- a/archive/uppsrc/Web/Copying +++ b/archive/uppsrc/Web/Copying @@ -1,4 +1,4 @@ -Copyright (c) 1998, 2019, The U++ Project +Copyright (c) 1998, 2020, The U++ Project All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted diff --git a/archive/uppsrc/Web/SSL/Copying b/archive/uppsrc/Web/SSL/Copying index 9159e0082..27fc52607 100644 --- a/archive/uppsrc/Web/SSL/Copying +++ b/archive/uppsrc/Web/SSL/Copying @@ -1,4 +1,4 @@ -Copyright (c) 1998, 2019, The U++ Project +Copyright (c) 1998, 2020, The U++ Project All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted diff --git a/archive/uppsrc/Web/ctrl/Copying b/archive/uppsrc/Web/ctrl/Copying index 9159e0082..27fc52607 100644 --- a/archive/uppsrc/Web/ctrl/Copying +++ b/archive/uppsrc/Web/ctrl/Copying @@ -1,4 +1,4 @@ -Copyright (c) 1998, 2019, The U++ Project +Copyright (c) 1998, 2020, The U++ Project All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted diff --git a/archive/uppsrc/Web/wisapi/Copying b/archive/uppsrc/Web/wisapi/Copying index 9159e0082..27fc52607 100644 --- a/archive/uppsrc/Web/wisapi/Copying +++ b/archive/uppsrc/Web/wisapi/Copying @@ -1,4 +1,4 @@ -Copyright (c) 1998, 2019, The U++ Project +Copyright (c) 1998, 2020, The U++ Project All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted diff --git a/uppsrc/docpp/Copying b/archive/uppsrc/docpp/Copying similarity index 100% rename from uppsrc/docpp/Copying rename to archive/uppsrc/docpp/Copying diff --git a/uppsrc/docpp/Parser.cpp b/archive/uppsrc/docpp/Parser.cpp similarity index 95% rename from uppsrc/docpp/Parser.cpp rename to archive/uppsrc/docpp/Parser.cpp index 9a4ed5286..a87884312 100644 --- a/uppsrc/docpp/Parser.cpp +++ b/archive/uppsrc/docpp/Parser.cpp @@ -1,825 +1,825 @@ -#include "docpp.h" - -String Purify(const char *s) { - String res; - while(*s) { - if(*s >= 'a' && *s <= 'z') { - String q; - while(*s >= 'a' && *s <= 'z') - q.Cat(*s++); - if(q != "virtual" && q != "inline") - res.Cat(q); - else - while((byte)*s <= ' ' && *s) s++; - } - else - if((byte)*s <= ' ') { - res.Cat(' '); - while(*s <= ' ' && *s) - s++; - } - else - res.Cat(*s++); - } - return res; -} - -void ScAdd(String& s, const String& a) -{ - if(a.IsEmpty()) return; - if(!s.IsEmpty()) - s << ';'; - s << a; -} - -String Parser::Context::Dump() const -{ - return "Namespace: " + nameing + " Struct: " + nesting; -} - -void Parser::Context::operator<<=(const Context& t) -{ - nameing = t.nameing; - nesting = t.nesting; - typenames <<= t.typenames; - access = t.access; -} - - -Parser::Decla::Decla() -{ - function = type_def = false; - s_static = s_auto = s_register = s_extern = s_mutable = s_explicit = s_virtual = false; - isfriend = istemplate = istructor = isptr = nofn = false; -} - -bool Parser::Key(int code) -{ - if(lex == code) { - ++lex; - return true; - } - return false; -} - -int Parser::GetLine(const char *p) -{ - int pos = p - ~file.text; - int l = 0; - int h = file.linepos.GetCount(); - while(l < h) { - int q = (l + h) / 2; - if(file.linepos[q] < pos) - l = q + 1; - else - h = q; - } - return l; -} - -void Parser::Line() -{ - int pos = lex.Pos() - ~file.text; - while(line + 1 < file.linepos.GetCount() && file.linepos[line + 1] <= pos) - line++; -} - -void Parser::ThrowError(const String& e) -{ - throw Error(Format("(%d) : %s", GetLine(lex.Pos()), ~e)); -} - -void Parser::Check(bool b, const char *err) -{ - if(!b) ThrowError(err); -} - -void Parser::CheckKey(int c) -{ - if(!Key(c)) ThrowError(Format("Missing %c", c)); -} - -String Parser::TemplateParams(String& param) -{ - const char *pos = lex.Pos(); - CheckKey('<'); - int level = 1; - String id; - bool gp = true; - for(;;) { - if(lex.IsId() && gp) - id = lex.GetId(); - else - if(Key(',')) { - ScAdd(param, id); - id.Clear(); - gp = true; - } - else - if(Key('=')) { - if(!id.IsEmpty()) { - ScAdd(param, id); - id.Clear(); - } - gp = false; - } - else - if(Key('>')) { - level--; - if(level <= 0) { - ScAdd(param, id); - break; - } - } - else - if(Key('<')) - level++; - else - ++lex; - } - return String(pos, lex.Pos()); -} - -String Parser::TemplateParams() -{ - String dummy; - return TemplateParams(dummy); -} - -String Parser::TemplatePnames() -{ - String pnames; - TemplateParams(pnames); - return pnames; -} - -String Parser::Name() -{ - String s; - if(Key(t_dblcolon)) - s << "::"; - Check(lex.IsId(), "Name expected"); - while(lex.IsId()) { - s << lex.GetId(); - if(lex == '<') - s << TemplateParams(); - if(Key(t_dblcolon)) { - s << "::"; - if(Key('~')) - s << "~"; - } - else - break; - } - return s; -} - -String Parser::Constant() -{ - const char *p = lex.Pos(); - const char *p1 = p; - int level = 0; - for(;;) { - p1 = lex.Pos(); - if(lex == t_eof) break; - if(level <= 0 && (lex == ',' || lex == ';' || lex == ')' || lex == '}' || lex == ']')) - break; - if(Key('(') || Key('[') || Key('{')) level++; - else - if(Key(')') || Key(']') || Key('}')) level--; - else - ++lex; - } - return String(p, p1); -} - -String Parser::SimpleType() -{ - if(Key(tk_struct) || Key(tk_class) || Key(tk_union) || Key(tk_enum) || Key(tk_typename)) { - if(lex.IsId() || lex == t_dblcolon) Name(); - if(lex == '{') EatBody(); - return Null; - } - if(Key(tk_bool) || Key(tk_float) || Key(tk_double) || Key(tk_void)) - return Null; - bool sgn = Key(tk_signed) || Key(tk_unsigned); - if(Key(tk_long)) { - Key(tk_int); - return Null; - } - if(Key(tk_short)) { - Key(tk_int); - return Null; - } - if(Key(tk_int) || Key(tk_char) || - Key(tk___int8) || Key(tk___int16) || Key(tk___int32) || Key(tk___int64)) return Null; - if(sgn) return Null; - const char *p = lex.Pos(); - int cs = 0; - Index cix; - Key(t_dblcolon); - Check(lex.IsId(), "Name expected"); - while(lex.IsId()) { - if(cix.Find(lex) >= 0) - cs++; - else - cix.Add(lex); - ++lex; - if(lex == '<') - TemplateParams(); - if(Key(t_dblcolon)) - Key('~'); - else - break; - } - return cs ? String(p, lex.Pos()) : String(); -} - -void Parser::Qualifier() -{ - Key(tk_const); - Key(tk_volatile); - if(Key(tk_throw)) { - while(lex != t_eof && !Key(')')) - ++lex; - } -} - -void Parser::Elipsis(Decl& d) -{ - Decl& q = d.param.Add(); - q.name = "..."; - CheckKey(')'); -} - -void Parser::ParamList(Decl& d) { - if(!Key(')')) - for(;;) { - if(Key(t_elipsis)) { - Elipsis(d); - break; - } - else - d.param.Add() = Declaration().Top(); - if(Key(t_elipsis)) { - Elipsis(d); - break; - } - if(Key(')')) break; - CheckKey(','); - } -} - -int Parser::RPtr() -{ - int n = 0; - int q = 0; - int tlevel = 0; - for(;;) { - int t = lex[n]; - if(t == '*') return n + 1; - if(t == '<') { - tlevel++; - n++; - } - else - if(t == '>') { - tlevel--; - n++; - } - else - if(t == t_dblcolon || lex.IsId(n) || t == ',' && tlevel > 0) - n++; - else - return 0; - } -} - -void Parser::EatInitializers() -{ - if(Key(':')) { - while(lex != '{' && lex != t_eof) ++lex; - } -} - -String Parser::ReadOper() { - const char *p = lex.Pos(); - const char *p1 = p; - Key(tk_operator); - int level = 0; - if(Key('(')) - level++; - for(;;) { - p1 = lex.Pos(); - if(lex == t_eof) break; - if(level <= 0 && lex == '(') break; - if(Key('(') || Key('[')) level++; - else - if(Key(')') || Key(']')) level--; - else - ++lex; - } - return TrimRight(Purify(String(p, p1))); -} - -void Parser::Declarator(Decl& d, const char *p) -{ - int n = RPtr(); - if(n) { - while(n--) lex.Get(); - Declarator(d, p); - d.isptr = true; - return; - } - if(Key('&')) { - Declarator(d, p); - return; - } - if(Key(tk_const)) { - Declarator(d, p); - return; - } - if(Key('(')) { - Declarator(d, p); - if(d.isptr) - d.nofn = true; - CheckKey(')'); - } - if(lex == tk_operator) - d.name = ReadOper(); - else - if(lex.IsId() || lex == t_dblcolon) { - d.name = Name(); - if(Key(':')) - if(!Key(t_integer)) - Name(); - } - if(Key('(')) { - if((lex < 256 || lex == tk_true || lex == tk_false) && lex != ')') { - int level = 0; - for(;;) { - if(lex == t_eof) break; - if(Key('(')) level++; - else - if(Key(')')) { - if(--level < 0) break; - } - else - ++lex; - } - return; - } - else { - d.header = String(p, lex.Pos() - 1); - d.function = !d.nofn; - ParamList(d); - p = lex.Pos(); - Qualifier(); - d.ender = String(p, lex.Pos()); - } - } - EatInitializers(); - while(Key('[')) { - const char *p = lex.Pos(); - int level = 1; - while(level && lex != t_eof) { - if(Key('[')) level++; - else - if(Key(']')) level--; - else - ++lex; - } - } - if(Key('=')) { - Constant(); - } -} - -Parser::Decl& Parser::Finish(Decl& d, const char *s) -{ - d.natural = String(s, lex.Pos()); - return d; -} - -Parser::Decl Parser::Type() { - Decl d; - const char *p = lex.Pos(); - Qualifier(); - SimpleType(); - Declarator(d, p); - return Finish(d, p); -} - -Array Parser::Declaration(bool l0, bool more) -{ - Array r; - Decla d; - const char *p = lex.Pos(); - if(Key(tk_typedef)) { - r = Declaration(); - r.Top().type_def = true; - r.Top().natural = String(p, lex.Pos()); - return r; - } - if(Key(tk_friend)) - d.isfriend = true; -// if(Key(tk_template)) { -// d.istemplate = true; -// d.template_params = TemplateParams(d.tnames); -// } - for(;;) { - if(Key(tk_static)) - d.s_static = true; - else - if(Key(tk_extern)) - d.s_extern = true; - else - if(Key(tk_auto)) - d.s_auto = true; - else - if(Key(tk_register)) - d.s_register = true; - else - if(Key(tk_mutable)) - d.s_mutable = true; - else - if(Key(tk_explicit)) - d.s_explicit = true; - else - if(Key(tk_virtual)) - d.s_virtual = true; - else - if(!Key(tk_inline)) - break; - } - Qualifier(); - bool isdestructor = Key('~'); - if(l0 && context.typenames.Find(lex) >= 0 && lex[1] == '(') { - Decl& a = r.Add(); - a.name = lex.GetId(); - a.isdestructor = isdestructor; - a.function = true; - a.istructor = true; - a.header = String(p, lex.Pos()); - ++lex; - ParamList(a); - const char *p1 = lex.Pos(); - Qualifier(); - a.ender = String(p1, lex.Pos()); - a.natural = String(p, lex.Pos()); - EatInitializers(); - return r; - } - if(lex == tk_operator) { - Decl& a = r.Add(); - (Decla&)a = d; - a.name = ReadOper(); - a.header = String(p, lex.Pos()); - Key('('); - ParamList(a); - const char *p1 = lex.Pos(); - Qualifier(); - a.ender = String(p1, lex.Pos()); - a.function = true; - a.natural = String(p, lex.Pos()); - return r; - } - String st = SimpleType(); - if(!st.IsEmpty()) { - Decl& a = r.Add(); - a.name = st; - a.isdestructor = st.Find('~') > 0; - a.function = true; - a.istructor = true; - a.header = String(p, lex.Pos()); - if(Key('(')) - ParamList(a); - const char *p1 = lex.Pos(); - Qualifier(); - a.ender = String(p1, lex.Pos()); - a.natural = String(p, lex.Pos()); - EatInitializers(); - return r; - } - String natural1 = String(p, lex.Pos()); - do { - const char *p1 = lex.Pos(); - Decl& a = r.Add(); - (Decla&)a = d; - Declarator(a, p); - a.natural = natural1 + String(p1, lex.Pos()); - p = lex.Pos(); - } - while(more && Key(',')); - return r; -} - -bool Parser::EatBody() -{ - if(!Key('{')) return false; - int level = 1; - while(level && lex != t_eof) { - if(Key('{')) level++; - else - if(Key('}')) level--; - else - ++lex; - } - return true; -} - -String CleanTp(const String& tp) -{ - int q = tp.Find('<'); - int w = tp.ReverseFind('>'); - if(q < 0 || w < 0) return tp; - String a = TrimLeft(TrimRight(tp.Mid(q + 1, w - q - 1))); - const char *s = a; - String r; - while(*s) { - if(*s == ',') { - r.Cat(';'); - s++; - while(*s == ' ') - s++; - } - else - r.Cat(*s++); - } - return r; -} - -bool Parser::Nest(const String& tp, const String& tn) { - if(Key(tk_namespace)) { - Check(lex.IsId(), "Expected name of namespace"); - String name = lex.GetId(); - if(Key('{')) { - Context cc; - cc <<= context; - context.nameing << name << "::"; - Do(); - context <<= cc; - Key('}'); - } - Key(';'); - return true; - } - if((lex == tk_class || lex == tk_struct || lex == tk_union) && - lex.IsId(1) && - (lex[2] == ':' || lex[2] == ';' || lex[2] == '{')) { - int t = lex.GetCode(); - context.typenames.FindAdd(lex); - String name = lex.GetId(); - Context cc; - cc <<= context; - if(context.nesting.IsEmpty()) - context.nesting = name + TrimRight(tp); - else - context.nesting = context.nesting + "::" + name + TrimRight(tp); - context.access = t == tk_class ? PRIVATE : PUBLIC; - String nn; - if(!tp.IsEmpty()) - nn = "template " + tp + " "; - nn << (t == tk_class ? "class " : t == tk_union ? "union " : "struct ") + name; - CppItem& im = Item(context.nameing, context.nesting, nn); - im.kind = tp.IsEmpty() ? STRUCT : STRUCTTEMPLATE; - im.name = name; - im.access = cc.access; - im.tname = tn; - im.tparam = CleanTp(tp); - if(Key(':')) { - do { - String access = t == tk_class ? "private" : "public"; - if(Key(tk_public)) access = "public"; - else - if(Key(tk_protected)) access = "protected"; - else - if(Key(tk_private)) access = "private"; - if(Key(tk_virtual)) access << " virtual"; - String n = Name(); - ScAdd(im.pname, n); - ScAdd(im.param, access + ' ' + n); - } - while(Key(',')); - } - if(Key('{')) { - Do(); - CheckKey('}'); - } - CheckKey(';'); - context = cc; - return true; - } - return false; -} - -CppItem& Parser::Item(const String& nameing, const String& nesting, const String& item) -{ - CppItem& im = base->GetAdd(nameing).GetAdd(nesting).GetAdd(TrimRight(Purify(item))); - im.pname.Clear(); - im.param.Clear(); - im.package = package; - im.file = filename; - im.line = line + 1; - im.name.Clear(); - return im; -} - -void Parser::Do() -{ - while(lex != t_eof && lex != '}') { - Line(); - if(Key(tk_using)) { - while(!Key(';')) - ++lex; - } - else - if(Key(tk_extern) && lex == t_string) { - ++lex; - ++lex; - if(Key('{')) { - Do(); - Key('}'); - } - Key(';'); - } - else - if(Key(tk_template)) { - if(lex.IsId() || lex == tk_class && lex.IsId(1)) { - Key(tk_class); - for(;;) { - if(lex.IsId()) - lex.GetId(); - else - if(!Key(t_dblcolon)) - break; - } - TemplateParams(); - Key(';'); - } - else { - String tnames; - String tparam = TemplateParams(tnames); - if(!Nest(tparam, tnames)) { - Array r = Declaration(true, true); - for(int i = 0; i < r.GetCount(); i++) { - Decl& d = r[i]; - d.natural = "template" + tparam + ' ' + d.natural; - if(context.access != PRIVATE && !d.isfriend && d.function) { - CppItem& im = Item(context.nameing, context.nesting, d.natural); - im.name = d.name; - im.access = context.access; - im.header = Purify(d.header); - im.ender = Purify(d.ender); - im.kind = context.nesting.IsEmpty() ? FUNCTIONTEMPLATE : - d.s_static ? CLASSFUNCTIONTEMPLATE - : INSTANCEFUNCTIONTEMPLATE; - for(int i = 0; i < d.param.GetCount(); i++) { - ScAdd(im.param, d.param[i].natural); - ScAdd(im.pname, d.param[i].name); - } - im.tname = tnames; - im.tparam = CleanTp(tparam); - } - } - EatBody(); - Key(';'); - } - } - } - else - if(lex == tk_enum && (lex[1] == '{' || lex[2] == '{')) { - ++lex; - String name; - if(lex.IsId()) - name = lex.GetId(); - String param; - String pname; - String n = "enum " + name + " { "; - Key('{'); - for(;;) { - String val; - Check(lex.IsId(), "Expected identifier"); - String nm = lex.GetId(); - if(Key('=')) - val = Constant(); - if(!param.IsEmpty()) - n << ", "; - n << nm; - ScAdd(param, nm + " = " + val); - ScAdd(pname, nm); - Key(','); - if(Key('}')) break; - } - n << " }"; - CppItem& im = Item(context.nameing, context.nesting, n); - im.kind = ENUM; - im.name = name; - im.access = context.access; - im.param = param; - im.pname = pname; - if(lex.IsId()) - im.name = lex.GetId(); - CheckKey(';'); - } - else - if(Key('#')) { - String n = lex.GetText(); - CppItem& im = Item(context.nameing, context.nesting, n); - im.kind = MACRO; - im.name.Clear(); - const char *s = n; - while(*s && iscid(*s)) - im.name.Cat(*s++); - s = strchr(n, '('); - if(s) { - s++; - String p; - for(;;) { - if(iscid(*s)) - p.Cat(*s++); - else { - ScAdd(im.pname, p); - p.Clear(); - if(*s == ')' || *s == '\0') break; - s++; - } - } - } - im.access = context.access; - } - else - if(!Nest(String(), String())) { - if(Key(tk_public)) { - context.access = PUBLIC; - Key(':'); - } - else - if(Key(tk_private)) { - context.access = PRIVATE; - Key(':'); - } - else - if(Key(tk_protected)) { - context.access = PROTECTED; - Key(':'); - } - else { - const char *p = lex.Pos(); - Array r = Declaration(true, true); - bool body = EatBody(); - for(int i = 0; i < r.GetCount(); i++) { - Decl& d = r[i]; - if(context.access != PRIVATE && !d.isfriend || d.isfriend && body) { - CppItem& im = Item(context.nameing, context.nesting, d.natural); - im.name = d.name; - im.header = Purify(d.header); - im.ender = Purify(d.ender); - im.access = context.access; - if(d.function) { - im.kind = d.istructor ? (d.isdestructor ? DESTRUCTOR : CONSTRUCTOR) : - d.isfriend ? INLINEFRIEND : - context.nesting.IsEmpty() ? FUNCTION : - d.s_static ? CLASSFUNCTION : INSTANCEFUNCTION; - for(int i = 0; i < d.param.GetCount(); i++) { - ScAdd(im.param, d.param[i].natural); - ScAdd(im.pname, d.param[i].name); - } - } - else - im.kind = d.type_def ? TYPEDEF : - context.nesting.IsEmpty() ? VARIABLE : - d.s_static ? CLASSVARIABLE : INSTANCEVARIABLE; - } - } - EatBody(); - Key(';'); - } - } - } -} - -void Parser::Do(Stream& in, const Vector& ignore, CppBase& _base, - const String& p, const String& f) throw(Parser::Error) -{ - base = &_base; - file = PreProcess(in); - lex = ~file.text; - lex.Ignore(ignore); - context.nesting.Clear(); - context.nameing = "::"; - context.access = PUBLIC; - context.typenames.Clear(); - package = p; - filename = f; - lpos = 0; - line = 0; - Do(); -} - -void Parse(Stream& s, const Vector& ignore, CppBase& base, - const String& package, const String& file) throw(Parser::Error) -{ - Parser p; - p.Do(s, ignore, base, package, file); -} +#include "docpp.h" + +String Purify(const char *s) { + String res; + while(*s) { + if(*s >= 'a' && *s <= 'z') { + String q; + while(*s >= 'a' && *s <= 'z') + q.Cat(*s++); + if(q != "virtual" && q != "inline") + res.Cat(q); + else + while((byte)*s <= ' ' && *s) s++; + } + else + if((byte)*s <= ' ') { + res.Cat(' '); + while(*s <= ' ' && *s) + s++; + } + else + res.Cat(*s++); + } + return res; +} + +void ScAdd(String& s, const String& a) +{ + if(a.IsEmpty()) return; + if(!s.IsEmpty()) + s << ';'; + s << a; +} + +String Parser::Context::Dump() const +{ + return "Namespace: " + nameing + " Struct: " + nesting; +} + +void Parser::Context::operator<<=(const Context& t) +{ + nameing = t.nameing; + nesting = t.nesting; + typenames <<= t.typenames; + access = t.access; +} + + +Parser::Decla::Decla() +{ + function = type_def = false; + s_static = s_auto = s_register = s_extern = s_mutable = s_explicit = s_virtual = false; + isfriend = istemplate = istructor = isptr = nofn = false; +} + +bool Parser::Key(int code) +{ + if(lex == code) { + ++lex; + return true; + } + return false; +} + +int Parser::GetLine(const char *p) +{ + int pos = p - ~file.text; + int l = 0; + int h = file.linepos.GetCount(); + while(l < h) { + int q = (l + h) / 2; + if(file.linepos[q] < pos) + l = q + 1; + else + h = q; + } + return l; +} + +void Parser::Line() +{ + int pos = lex.Pos() - ~file.text; + while(line + 1 < file.linepos.GetCount() && file.linepos[line + 1] <= pos) + line++; +} + +void Parser::ThrowError(const String& e) +{ + throw Error(Format("(%d) : %s", GetLine(lex.Pos()), ~e)); +} + +void Parser::Check(bool b, const char *err) +{ + if(!b) ThrowError(err); +} + +void Parser::CheckKey(int c) +{ + if(!Key(c)) ThrowError(Format("Missing %c", c)); +} + +String Parser::TemplateParams(String& param) +{ + const char *pos = lex.Pos(); + CheckKey('<'); + int level = 1; + String id; + bool gp = true; + for(;;) { + if(lex.IsId() && gp) + id = lex.GetId(); + else + if(Key(',')) { + ScAdd(param, id); + id.Clear(); + gp = true; + } + else + if(Key('=')) { + if(!id.IsEmpty()) { + ScAdd(param, id); + id.Clear(); + } + gp = false; + } + else + if(Key('>')) { + level--; + if(level <= 0) { + ScAdd(param, id); + break; + } + } + else + if(Key('<')) + level++; + else + ++lex; + } + return String(pos, lex.Pos()); +} + +String Parser::TemplateParams() +{ + String dummy; + return TemplateParams(dummy); +} + +String Parser::TemplatePnames() +{ + String pnames; + TemplateParams(pnames); + return pnames; +} + +String Parser::Name() +{ + String s; + if(Key(t_dblcolon)) + s << "::"; + Check(lex.IsId(), "Name expected"); + while(lex.IsId()) { + s << lex.GetId(); + if(lex == '<') + s << TemplateParams(); + if(Key(t_dblcolon)) { + s << "::"; + if(Key('~')) + s << "~"; + } + else + break; + } + return s; +} + +String Parser::Constant() +{ + const char *p = lex.Pos(); + const char *p1 = p; + int level = 0; + for(;;) { + p1 = lex.Pos(); + if(lex == t_eof) break; + if(level <= 0 && (lex == ',' || lex == ';' || lex == ')' || lex == '}' || lex == ']')) + break; + if(Key('(') || Key('[') || Key('{')) level++; + else + if(Key(')') || Key(']') || Key('}')) level--; + else + ++lex; + } + return String(p, p1); +} + +String Parser::SimpleType() +{ + if(Key(tk_struct) || Key(tk_class) || Key(tk_union) || Key(tk_enum) || Key(tk_typename)) { + if(lex.IsId() || lex == t_dblcolon) Name(); + if(lex == '{') EatBody(); + return Null; + } + if(Key(tk_bool) || Key(tk_float) || Key(tk_double) || Key(tk_void)) + return Null; + bool sgn = Key(tk_signed) || Key(tk_unsigned); + if(Key(tk_long)) { + Key(tk_int); + return Null; + } + if(Key(tk_short)) { + Key(tk_int); + return Null; + } + if(Key(tk_int) || Key(tk_char) || + Key(tk___int8) || Key(tk___int16) || Key(tk___int32) || Key(tk___int64)) return Null; + if(sgn) return Null; + const char *p = lex.Pos(); + int cs = 0; + Index cix; + Key(t_dblcolon); + Check(lex.IsId(), "Name expected"); + while(lex.IsId()) { + if(cix.Find(lex) >= 0) + cs++; + else + cix.Add(lex); + ++lex; + if(lex == '<') + TemplateParams(); + if(Key(t_dblcolon)) + Key('~'); + else + break; + } + return cs ? String(p, lex.Pos()) : String(); +} + +void Parser::Qualifier() +{ + Key(tk_const); + Key(tk_volatile); + if(Key(tk_throw)) { + while(lex != t_eof && !Key(')')) + ++lex; + } +} + +void Parser::Elipsis(Decl& d) +{ + Decl& q = d.param.Add(); + q.name = "..."; + CheckKey(')'); +} + +void Parser::ParamList(Decl& d) { + if(!Key(')')) + for(;;) { + if(Key(t_elipsis)) { + Elipsis(d); + break; + } + else + d.param.Add() = Declaration().Top(); + if(Key(t_elipsis)) { + Elipsis(d); + break; + } + if(Key(')')) break; + CheckKey(','); + } +} + +int Parser::RPtr() +{ + int n = 0; + int q = 0; + int tlevel = 0; + for(;;) { + int t = lex[n]; + if(t == '*') return n + 1; + if(t == '<') { + tlevel++; + n++; + } + else + if(t == '>') { + tlevel--; + n++; + } + else + if(t == t_dblcolon || lex.IsId(n) || t == ',' && tlevel > 0) + n++; + else + return 0; + } +} + +void Parser::EatInitializers() +{ + if(Key(':')) { + while(lex != '{' && lex != t_eof) ++lex; + } +} + +String Parser::ReadOper() { + const char *p = lex.Pos(); + const char *p1 = p; + Key(tk_operator); + int level = 0; + if(Key('(')) + level++; + for(;;) { + p1 = lex.Pos(); + if(lex == t_eof) break; + if(level <= 0 && lex == '(') break; + if(Key('(') || Key('[')) level++; + else + if(Key(')') || Key(']')) level--; + else + ++lex; + } + return TrimRight(Purify(String(p, p1))); +} + +void Parser::Declarator(Decl& d, const char *p) +{ + int n = RPtr(); + if(n) { + while(n--) lex.Get(); + Declarator(d, p); + d.isptr = true; + return; + } + if(Key('&')) { + Declarator(d, p); + return; + } + if(Key(tk_const)) { + Declarator(d, p); + return; + } + if(Key('(')) { + Declarator(d, p); + if(d.isptr) + d.nofn = true; + CheckKey(')'); + } + if(lex == tk_operator) + d.name = ReadOper(); + else + if(lex.IsId() || lex == t_dblcolon) { + d.name = Name(); + if(Key(':')) + if(!Key(t_integer)) + Name(); + } + if(Key('(')) { + if((lex < 256 || lex == tk_true || lex == tk_false) && lex != ')') { + int level = 0; + for(;;) { + if(lex == t_eof) break; + if(Key('(')) level++; + else + if(Key(')')) { + if(--level < 0) break; + } + else + ++lex; + } + return; + } + else { + d.header = String(p, lex.Pos() - 1); + d.function = !d.nofn; + ParamList(d); + p = lex.Pos(); + Qualifier(); + d.ender = String(p, lex.Pos()); + } + } + EatInitializers(); + while(Key('[')) { + const char *p = lex.Pos(); + int level = 1; + while(level && lex != t_eof) { + if(Key('[')) level++; + else + if(Key(']')) level--; + else + ++lex; + } + } + if(Key('=')) { + Constant(); + } +} + +Parser::Decl& Parser::Finish(Decl& d, const char *s) +{ + d.natural = String(s, lex.Pos()); + return d; +} + +Parser::Decl Parser::Type() { + Decl d; + const char *p = lex.Pos(); + Qualifier(); + SimpleType(); + Declarator(d, p); + return Finish(d, p); +} + +Array Parser::Declaration(bool l0, bool more) +{ + Array r; + Decla d; + const char *p = lex.Pos(); + if(Key(tk_typedef)) { + r = Declaration(); + r.Top().type_def = true; + r.Top().natural = String(p, lex.Pos()); + return r; + } + if(Key(tk_friend)) + d.isfriend = true; +// if(Key(tk_template)) { +// d.istemplate = true; +// d.template_params = TemplateParams(d.tnames); +// } + for(;;) { + if(Key(tk_static)) + d.s_static = true; + else + if(Key(tk_extern)) + d.s_extern = true; + else + if(Key(tk_auto)) + d.s_auto = true; + else + if(Key(tk_register)) + d.s_register = true; + else + if(Key(tk_mutable)) + d.s_mutable = true; + else + if(Key(tk_explicit)) + d.s_explicit = true; + else + if(Key(tk_virtual)) + d.s_virtual = true; + else + if(!Key(tk_inline)) + break; + } + Qualifier(); + bool isdestructor = Key('~'); + if(l0 && context.typenames.Find(lex) >= 0 && lex[1] == '(') { + Decl& a = r.Add(); + a.name = lex.GetId(); + a.isdestructor = isdestructor; + a.function = true; + a.istructor = true; + a.header = String(p, lex.Pos()); + ++lex; + ParamList(a); + const char *p1 = lex.Pos(); + Qualifier(); + a.ender = String(p1, lex.Pos()); + a.natural = String(p, lex.Pos()); + EatInitializers(); + return r; + } + if(lex == tk_operator) { + Decl& a = r.Add(); + (Decla&)a = d; + a.name = ReadOper(); + a.header = String(p, lex.Pos()); + Key('('); + ParamList(a); + const char *p1 = lex.Pos(); + Qualifier(); + a.ender = String(p1, lex.Pos()); + a.function = true; + a.natural = String(p, lex.Pos()); + return r; + } + String st = SimpleType(); + if(!st.IsEmpty()) { + Decl& a = r.Add(); + a.name = st; + a.isdestructor = st.Find('~') > 0; + a.function = true; + a.istructor = true; + a.header = String(p, lex.Pos()); + if(Key('(')) + ParamList(a); + const char *p1 = lex.Pos(); + Qualifier(); + a.ender = String(p1, lex.Pos()); + a.natural = String(p, lex.Pos()); + EatInitializers(); + return r; + } + String natural1 = String(p, lex.Pos()); + do { + const char *p1 = lex.Pos(); + Decl& a = r.Add(); + (Decla&)a = d; + Declarator(a, p); + a.natural = natural1 + String(p1, lex.Pos()); + p = lex.Pos(); + } + while(more && Key(',')); + return r; +} + +bool Parser::EatBody() +{ + if(!Key('{')) return false; + int level = 1; + while(level && lex != t_eof) { + if(Key('{')) level++; + else + if(Key('}')) level--; + else + ++lex; + } + return true; +} + +String CleanTp(const String& tp) +{ + int q = tp.Find('<'); + int w = tp.ReverseFind('>'); + if(q < 0 || w < 0) return tp; + String a = TrimLeft(TrimRight(tp.Mid(q + 1, w - q - 1))); + const char *s = a; + String r; + while(*s) { + if(*s == ',') { + r.Cat(';'); + s++; + while(*s == ' ') + s++; + } + else + r.Cat(*s++); + } + return r; +} + +bool Parser::Nest(const String& tp, const String& tn) { + if(Key(tk_namespace)) { + Check(lex.IsId(), "Expected name of namespace"); + String name = lex.GetId(); + if(Key('{')) { + Context cc; + cc <<= context; + context.nameing << name << "::"; + Do(); + context <<= cc; + Key('}'); + } + Key(';'); + return true; + } + if((lex == tk_class || lex == tk_struct || lex == tk_union) && + lex.IsId(1) && + (lex[2] == ':' || lex[2] == ';' || lex[2] == '{')) { + int t = lex.GetCode(); + context.typenames.FindAdd(lex); + String name = lex.GetId(); + Context cc; + cc <<= context; + if(context.nesting.IsEmpty()) + context.nesting = name + TrimRight(tp); + else + context.nesting = context.nesting + "::" + name + TrimRight(tp); + context.access = t == tk_class ? PRIVATE : PUBLIC; + String nn; + if(!tp.IsEmpty()) + nn = "template " + tp + " "; + nn << (t == tk_class ? "class " : t == tk_union ? "union " : "struct ") + name; + CppItem& im = Item(context.nameing, context.nesting, nn); + im.kind = tp.IsEmpty() ? STRUCT : STRUCTTEMPLATE; + im.name = name; + im.access = cc.access; + im.tname = tn; + im.tparam = CleanTp(tp); + if(Key(':')) { + do { + String access = t == tk_class ? "private" : "public"; + if(Key(tk_public)) access = "public"; + else + if(Key(tk_protected)) access = "protected"; + else + if(Key(tk_private)) access = "private"; + if(Key(tk_virtual)) access << " virtual"; + String n = Name(); + ScAdd(im.pname, n); + ScAdd(im.param, access + ' ' + n); + } + while(Key(',')); + } + if(Key('{')) { + Do(); + CheckKey('}'); + } + CheckKey(';'); + context = cc; + return true; + } + return false; +} + +CppItem& Parser::Item(const String& nameing, const String& nesting, const String& item) +{ + CppItem& im = base->GetAdd(nameing).GetAdd(nesting).GetAdd(TrimRight(Purify(item))); + im.pname.Clear(); + im.param.Clear(); + im.package = package; + im.file = filename; + im.line = line + 1; + im.name.Clear(); + return im; +} + +void Parser::Do() +{ + while(lex != t_eof && lex != '}') { + Line(); + if(Key(tk_using)) { + while(!Key(';')) + ++lex; + } + else + if(Key(tk_extern) && lex == t_string) { + ++lex; + ++lex; + if(Key('{')) { + Do(); + Key('}'); + } + Key(';'); + } + else + if(Key(tk_template)) { + if(lex.IsId() || lex == tk_class && lex.IsId(1)) { + Key(tk_class); + for(;;) { + if(lex.IsId()) + lex.GetId(); + else + if(!Key(t_dblcolon)) + break; + } + TemplateParams(); + Key(';'); + } + else { + String tnames; + String tparam = TemplateParams(tnames); + if(!Nest(tparam, tnames)) { + Array r = Declaration(true, true); + for(int i = 0; i < r.GetCount(); i++) { + Decl& d = r[i]; + d.natural = "template" + tparam + ' ' + d.natural; + if(context.access != PRIVATE && !d.isfriend && d.function) { + CppItem& im = Item(context.nameing, context.nesting, d.natural); + im.name = d.name; + im.access = context.access; + im.header = Purify(d.header); + im.ender = Purify(d.ender); + im.kind = context.nesting.IsEmpty() ? FUNCTIONTEMPLATE : + d.s_static ? CLASSFUNCTIONTEMPLATE + : INSTANCEFUNCTIONTEMPLATE; + for(int i = 0; i < d.param.GetCount(); i++) { + ScAdd(im.param, d.param[i].natural); + ScAdd(im.pname, d.param[i].name); + } + im.tname = tnames; + im.tparam = CleanTp(tparam); + } + } + EatBody(); + Key(';'); + } + } + } + else + if(lex == tk_enum && (lex[1] == '{' || lex[2] == '{')) { + ++lex; + String name; + if(lex.IsId()) + name = lex.GetId(); + String param; + String pname; + String n = "enum " + name + " { "; + Key('{'); + for(;;) { + String val; + Check(lex.IsId(), "Expected identifier"); + String nm = lex.GetId(); + if(Key('=')) + val = Constant(); + if(!param.IsEmpty()) + n << ", "; + n << nm; + ScAdd(param, nm + " = " + val); + ScAdd(pname, nm); + Key(','); + if(Key('}')) break; + } + n << " }"; + CppItem& im = Item(context.nameing, context.nesting, n); + im.kind = ENUM; + im.name = name; + im.access = context.access; + im.param = param; + im.pname = pname; + if(lex.IsId()) + im.name = lex.GetId(); + CheckKey(';'); + } + else + if(Key('#')) { + String n = lex.GetText(); + CppItem& im = Item(context.nameing, context.nesting, n); + im.kind = MACRO; + im.name.Clear(); + const char *s = n; + while(*s && iscid(*s)) + im.name.Cat(*s++); + s = strchr(n, '('); + if(s) { + s++; + String p; + for(;;) { + if(iscid(*s)) + p.Cat(*s++); + else { + ScAdd(im.pname, p); + p.Clear(); + if(*s == ')' || *s == '\0') break; + s++; + } + } + } + im.access = context.access; + } + else + if(!Nest(String(), String())) { + if(Key(tk_public)) { + context.access = PUBLIC; + Key(':'); + } + else + if(Key(tk_private)) { + context.access = PRIVATE; + Key(':'); + } + else + if(Key(tk_protected)) { + context.access = PROTECTED; + Key(':'); + } + else { + const char *p = lex.Pos(); + Array r = Declaration(true, true); + bool body = EatBody(); + for(int i = 0; i < r.GetCount(); i++) { + Decl& d = r[i]; + if(context.access != PRIVATE && !d.isfriend || d.isfriend && body) { + CppItem& im = Item(context.nameing, context.nesting, d.natural); + im.name = d.name; + im.header = Purify(d.header); + im.ender = Purify(d.ender); + im.access = context.access; + if(d.function) { + im.kind = d.istructor ? (d.isdestructor ? DESTRUCTOR : CONSTRUCTOR) : + d.isfriend ? INLINEFRIEND : + context.nesting.IsEmpty() ? FUNCTION : + d.s_static ? CLASSFUNCTION : INSTANCEFUNCTION; + for(int i = 0; i < d.param.GetCount(); i++) { + ScAdd(im.param, d.param[i].natural); + ScAdd(im.pname, d.param[i].name); + } + } + else + im.kind = d.type_def ? TYPEDEF : + context.nesting.IsEmpty() ? VARIABLE : + d.s_static ? CLASSVARIABLE : INSTANCEVARIABLE; + } + } + EatBody(); + Key(';'); + } + } + } +} + +void Parser::Do(Stream& in, const Vector& ignore, CppBase& _base, + const String& p, const String& f) throw(Parser::Error) +{ + base = &_base; + file = PreProcess(in); + lex = ~file.text; + lex.Ignore(ignore); + context.nesting.Clear(); + context.nameing = "::"; + context.access = PUBLIC; + context.typenames.Clear(); + package = p; + filename = f; + lpos = 0; + line = 0; + Do(); +} + +void Parse(Stream& s, const Vector& ignore, CppBase& base, + const String& package, const String& file) throw(Parser::Error) +{ + Parser p; + p.Do(s, ignore, base, package, file); +} diff --git a/uppsrc/docpp/Pre.cpp b/archive/uppsrc/docpp/Pre.cpp similarity index 94% rename from uppsrc/docpp/Pre.cpp rename to archive/uppsrc/docpp/Pre.cpp index f253179cb..e0ca652fe 100644 --- a/uppsrc/docpp/Pre.cpp +++ b/archive/uppsrc/docpp/Pre.cpp @@ -1,95 +1,95 @@ -#include "docpp.h" - -String SSpaces(const char *txt) -{ - String r; - while(*txt) - if(*txt == ' ') { - while((byte)*txt <= ' ' && *txt) txt++; - r.Cat(' '); - } - else - r.Cat(*txt++); - return r; -} - -void SLPos(SrcFile& res) -{ - res.linepos.Add(res.text.GetLength()); -} - -SrcFile PreProcess(Stream& in) -{ - SrcFile res; - bool include = true; - while(!in.IsEof()) { - String ln = in.GetLine(); - SLPos(res); - while(*ln.Last() == '\\') { - ln.Trim(ln.GetLength() - 1); - ln.Cat(in.GetLine()); - SLPos(res); - } - const char *rm = ln; - while(*rm == ' ' || *rm == '\t') rm++; - if(*rm == '#') { - if(rm[1] == 'd' && rm[2] == 'e' && rm[3] == 'f' && - rm[4] == 'i' && rm[5] == 'n' && rm[6] == 'e' && !iscid(rm[7])) { - const char *s = rm + 8; - while(*s == ' ') s++; - String macro; - while(iscid(*s)) - macro.Cat(*s++); - if(*s == '(') { - while(*s != ')' && *s) - macro.Cat(*s++); - macro << ')'; - } - res.text << '#' << AsCString(SSpaces(macro)); - } - } - else { - String cmd; - while(*rm) { - if(rm[0] == '/' && rm[1] == '/') { - cmd = rm + 2; - break; - } - if(rm[0] == '/' && rm[1] == '*') { - rm += 2; - for(;;) { - if(*rm == '\0') { - if(in.IsEof()) break; - SLPos(res); - ln = in.GetLine(); - rm = ~ln; - } - if(rm[0] == '*' && rm[1] == '/') { - rm += 2; - break; - } - rm++; - } - if(include) - res.text.Cat(' '); - } - else { - if(include) - res.text.Cat(*rm); - rm++; - } - } - if(include) - res.text << ' '; - if(cmd[0] == '$') { - if(cmd[1] == '-') include = false; - if(cmd[1] == '+') include = true; - if(cmd[1]) { - res.text.Cat(~cmd + 2); - res.text.Cat(' '); - } - } - } - } - return res; -} +#include "docpp.h" + +String SSpaces(const char *txt) +{ + String r; + while(*txt) + if(*txt == ' ') { + while((byte)*txt <= ' ' && *txt) txt++; + r.Cat(' '); + } + else + r.Cat(*txt++); + return r; +} + +void SLPos(SrcFile& res) +{ + res.linepos.Add(res.text.GetLength()); +} + +SrcFile PreProcess(Stream& in) +{ + SrcFile res; + bool include = true; + while(!in.IsEof()) { + String ln = in.GetLine(); + SLPos(res); + while(*ln.Last() == '\\') { + ln.Trim(ln.GetLength() - 1); + ln.Cat(in.GetLine()); + SLPos(res); + } + const char *rm = ln; + while(*rm == ' ' || *rm == '\t') rm++; + if(*rm == '#') { + if(rm[1] == 'd' && rm[2] == 'e' && rm[3] == 'f' && + rm[4] == 'i' && rm[5] == 'n' && rm[6] == 'e' && !iscid(rm[7])) { + const char *s = rm + 8; + while(*s == ' ') s++; + String macro; + while(iscid(*s)) + macro.Cat(*s++); + if(*s == '(') { + while(*s != ')' && *s) + macro.Cat(*s++); + macro << ')'; + } + res.text << '#' << AsCString(SSpaces(macro)); + } + } + else { + String cmd; + while(*rm) { + if(rm[0] == '/' && rm[1] == '/') { + cmd = rm + 2; + break; + } + if(rm[0] == '/' && rm[1] == '*') { + rm += 2; + for(;;) { + if(*rm == '\0') { + if(in.IsEof()) break; + SLPos(res); + ln = in.GetLine(); + rm = ~ln; + } + if(rm[0] == '*' && rm[1] == '/') { + rm += 2; + break; + } + rm++; + } + if(include) + res.text.Cat(' '); + } + else { + if(include) + res.text.Cat(*rm); + rm++; + } + } + if(include) + res.text << ' '; + if(cmd[0] == '$') { + if(cmd[1] == '-') include = false; + if(cmd[1] == '+') include = true; + if(cmd[1]) { + res.text.Cat(~cmd + 2); + res.text.Cat(' '); + } + } + } + } + return res; +} diff --git a/uppsrc/docpp/cpplex.cpp b/archive/uppsrc/docpp/cpplex.cpp similarity index 95% rename from uppsrc/docpp/cpplex.cpp rename to archive/uppsrc/docpp/cpplex.cpp index 089bee890..cdcac4864 100644 --- a/uppsrc/docpp/cpplex.cpp +++ b/archive/uppsrc/docpp/cpplex.cpp @@ -1,324 +1,324 @@ -#include "docpp.h" - -#define case_id \ - case '_':case 'a':case 'b':case 'c':case 'd':case 'e':case 'f':case 'g':case 'h': \ - case 'i':case 'j':case 'k':case 'l':case 'm':case 'n':case 'o':case 'p':case 'q': \ - case 'r':case 's':case 't':case 'u':case 'v':case 'w':case 'x':case 'y':case 'z': \ - case 'A':case 'B':case 'C':case 'D':case 'E':case 'F':case 'G':case 'H':case 'I': \ - case 'J':case 'K':case 'L':case 'M':case 'N':case 'O':case 'P':case 'Q':case 'R': \ - case 'S':case 'T':case 'U':case 'V':case 'W':case 'X':case 'Y':case 'Z' - -#define case_nonzero_digit \ - case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8':case '9' - - -const char *_CppKeyword[] = { -#define CPPID(x) #x, -#include "keyword.i" -#undef CPPID - NULL -}; - -const char **CppKeyword() { return _CppKeyword; } - -Lex::Lex() -{ - const char **cppk = CppKeyword(); - for(int i = 0; cppk[i]; i++) - id.Add(cppk[i]); - endkey = id.GetCount(); -} - -void Lex::Ignore(const Vector& ig) -{ - for(int i = 0; i < ig.GetCount(); i++) - ignore.Add(id.FindAdd(ig[i])); -} - -int Lex::GetCharacter() -{ - if(*ptr == '\0') return t_eof; - int c = *ptr++; - if(c == '\\') { - c = *ptr++; - switch(c) { - case 'a': return '\a'; - case 'b': return '\b'; - case 't': return '\t'; - case 'v': return '\v'; - case 'n': return '\n'; - case 'r': return '\r'; - case 'f': return '\f'; - case 'x': - c = 0; - if(isxdigit(*ptr)) { - c = (*ptr >= 'A' ? ToUpper(*ptr) - 'A' + 10 : *ptr - '0'); - ptr++; - if(isxdigit(*ptr)) { - c = 16 * c + (*ptr >= 'A' ? ToUpper(*ptr) - 'A' + 10 : *ptr - '0'); - ptr++; - } - } - break; - default: - if(c >= '0' && c <= '7') { - c -= '0'; - if(*ptr >= '0' && *ptr <= '7') - c = 8 * c + *ptr++ - '0'; - if(*ptr >= '0' && *ptr <= '7') - c = 8 * c + *ptr++ - '0'; - } - } - } - return (byte)c; -} - -#pragma optimize("t", on) - -void Lex::Next() -{ - while((byte)*ptr <= ' ') { - if(*ptr == '\0') return; - ptr++; - } - pos = ptr; - int c = (byte)*ptr++; - if(c == '\0') return; - switch(c) { - case_id: { - String x; - x.Reserve(12); - x.Cat(c); - while(iscid(*ptr)) - x.Cat(*ptr++); - int q = id.FindAdd(x); - if(ignore.Find(q) < 0) - AddCode(q + 256); - break; - } - case ':': AddCode(Char(':') ? t_dblcolon : ':'); break; - case '*': AssOp('*', t_mulass); break; - case '/': AssOp('/', t_divass); break; - case '%': AssOp('%', t_modass); break; - case '^': AssOp('^', t_xorass); break; - case '!': AssOp('!', t_neq); break; - case '.': - if(Char('*')) AddCode(t_dot_asteriks); - else - if(*ptr == '.' && ptr[1] == '.') { - AddCode(t_elipsis); - ptr += 2; - } - else - AddCode('.'); - break; - case '+': - if(Char('+')) AddCode(t_inc); - else - AssOp('+', t_addass); - return; - case '-': - if(Char('-')) AddCode(t_dec); - else - if(Char('>')) - AddCode(Char('*') ? t_arrow_asteriks : t_arrow); - else - AssOp('-', t_subass); - break; - case '&': - if(Char('&')) - AddCode(t_and); - else - AssOp('&', t_andass); - break; - case '|': - if(Char('|')) - AddCode(t_or); - else - AssOp('|', t_orass); - break; - case '=': - AssOp('=', t_eq); - break; - case '<': - if(Char('<')) - AssOp(t_shl, t_shlass); - else - AssOp('<', t_le); - break; - case '>': - if(Char('>')) - AssOp(t_shr, t_shrass); - else - AssOp('>', t_ge); - break; - case '0': { - dword w = 0; - if(Char('x') || Char('X')) { - for(;;) { - int d; - if(*ptr >= '0' && *ptr <= '9') - d = *ptr - '0'; - else - if(*ptr >= 'A' && *ptr <= 'F') - d = *ptr - 'A' + 10; - else - if(*ptr >= 'a' && *ptr <= 'f') - d = *ptr - 'a' + 10; - else - break; - if(w >= 0x8000000u - d) { - AddCode(te_integeroverflow); - return; - } - w = w * 16 + d - '0'; - ptr++; - } - } - else - while(*ptr >= '0' && *ptr <= '7') { - int d = *ptr++ - '0'; - if(w >= 0x1000000u - d) { - AddCode(te_integeroverflow); - return; - } - w = w * 8 + d - '0'; - } - Term& tm = term.AddTail(); - tm.code = t_integer; - tm.ptr = pos; - tm.number = w; - } - break; - case_nonzero_digit: { - double w = c - '0'; - bool fp = false; - while(*ptr >= '0' && *ptr <= '9') - w = w * 10 + *ptr++ - '0'; - if(*ptr == '.') { // TO BE Completed !!! - fp = true; - ptr++; - double x = 0.1; - while(*ptr >= '0' && *ptr <= '9') { - w += x * (*ptr++ - '0'); - x /= 10; - } - } - Term& tm = term.AddTail(); - if(fp || w < INT_MIN || w > INT_MAX) - tm.code = t_double; - else - tm.code = t_integer; - tm.ptr = pos; - tm.number = w; - } - break; - case '\'': { - Term& tm = term.AddTail(); - tm.code = t_character; - tm.ptr = pos; - tm.text = String(GetCharacter(), 1); - if(*ptr == '\'') - ptr++; - else - tm.code = te_badcharacter; - } - break; - case '\"': { - Term& tm = term.AddTail(); - tm.code = t_string; - tm.ptr = pos; - for(;;) { - while(*ptr != '\"') { - if((byte)*ptr < ' ') { - tm.code = te_badstring; - return; - } - tm.text.Cat(GetCharacter()); - } - ptr++; - while(*ptr && (byte)*ptr <= ' ') ptr++; - if(*ptr != '\"') break; - ptr++; - } - } - break; - default: - AddCode(c); - return; - } -} - -#pragma optimize("t", off) - -bool Lex::Prepare(int pos) { - while(term.GetCount() <= pos) { - if(*ptr == '\0') return false; - Next(); - } -#ifdef _DEBUG - pp = term[0].ptr; -#endif - return true; -} - -int Lex::Code(int pos) -{ - if(!Prepare(pos)) return t_eof; - return term[pos].code; -} - -bool Lex::IsId(int pos) -{ - return Code(pos) >= endkey + 256; -} - -String Lex::Id(int pos) -{ - ASSERT(IsId(pos)); - return id[Code(pos) - 256]; -} - -void Lex::Get(int n) -{ - while(n--) { - if(term.GetCount()) - term.DropHead(); - if(term.GetCount() == 0) - Next(); - } -} - -int Lex::Int(int pos) -{ - Prepare(pos); - ASSERT(term[pos].code == t_integer); - return (int)term[pos].number; -} - -double Lex::Double(int pos) -{ - Prepare(pos); - ASSERT(term[pos].code == t_double); - return term[pos].number; -} - -String Lex::Text(int pos) -{ - Prepare(pos); - ASSERT(term[pos].code == t_string); - return term[pos].text; -} - -int Lex::Chr(int pos) -{ - Prepare(pos); - ASSERT(term[pos].code == t_character); - return (byte)*term[pos].text; -} - -const char *Lex::Pos(int pos) -{ - Prepare(pos); - return pos < term.GetCount() ? term[pos].ptr : ptr; -} +#include "docpp.h" + +#define case_id \ + case '_':case 'a':case 'b':case 'c':case 'd':case 'e':case 'f':case 'g':case 'h': \ + case 'i':case 'j':case 'k':case 'l':case 'm':case 'n':case 'o':case 'p':case 'q': \ + case 'r':case 's':case 't':case 'u':case 'v':case 'w':case 'x':case 'y':case 'z': \ + case 'A':case 'B':case 'C':case 'D':case 'E':case 'F':case 'G':case 'H':case 'I': \ + case 'J':case 'K':case 'L':case 'M':case 'N':case 'O':case 'P':case 'Q':case 'R': \ + case 'S':case 'T':case 'U':case 'V':case 'W':case 'X':case 'Y':case 'Z' + +#define case_nonzero_digit \ + case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8':case '9' + + +const char *_CppKeyword[] = { +#define CPPID(x) #x, +#include "keyword.i" +#undef CPPID + NULL +}; + +const char **CppKeyword() { return _CppKeyword; } + +Lex::Lex() +{ + const char **cppk = CppKeyword(); + for(int i = 0; cppk[i]; i++) + id.Add(cppk[i]); + endkey = id.GetCount(); +} + +void Lex::Ignore(const Vector& ig) +{ + for(int i = 0; i < ig.GetCount(); i++) + ignore.Add(id.FindAdd(ig[i])); +} + +int Lex::GetCharacter() +{ + if(*ptr == '\0') return t_eof; + int c = *ptr++; + if(c == '\\') { + c = *ptr++; + switch(c) { + case 'a': return '\a'; + case 'b': return '\b'; + case 't': return '\t'; + case 'v': return '\v'; + case 'n': return '\n'; + case 'r': return '\r'; + case 'f': return '\f'; + case 'x': + c = 0; + if(isxdigit(*ptr)) { + c = (*ptr >= 'A' ? ToUpper(*ptr) - 'A' + 10 : *ptr - '0'); + ptr++; + if(isxdigit(*ptr)) { + c = 16 * c + (*ptr >= 'A' ? ToUpper(*ptr) - 'A' + 10 : *ptr - '0'); + ptr++; + } + } + break; + default: + if(c >= '0' && c <= '7') { + c -= '0'; + if(*ptr >= '0' && *ptr <= '7') + c = 8 * c + *ptr++ - '0'; + if(*ptr >= '0' && *ptr <= '7') + c = 8 * c + *ptr++ - '0'; + } + } + } + return (byte)c; +} + +#pragma optimize("t", on) + +void Lex::Next() +{ + while((byte)*ptr <= ' ') { + if(*ptr == '\0') return; + ptr++; + } + pos = ptr; + int c = (byte)*ptr++; + if(c == '\0') return; + switch(c) { + case_id: { + String x; + x.Reserve(12); + x.Cat(c); + while(iscid(*ptr)) + x.Cat(*ptr++); + int q = id.FindAdd(x); + if(ignore.Find(q) < 0) + AddCode(q + 256); + break; + } + case ':': AddCode(Char(':') ? t_dblcolon : ':'); break; + case '*': AssOp('*', t_mulass); break; + case '/': AssOp('/', t_divass); break; + case '%': AssOp('%', t_modass); break; + case '^': AssOp('^', t_xorass); break; + case '!': AssOp('!', t_neq); break; + case '.': + if(Char('*')) AddCode(t_dot_asteriks); + else + if(*ptr == '.' && ptr[1] == '.') { + AddCode(t_elipsis); + ptr += 2; + } + else + AddCode('.'); + break; + case '+': + if(Char('+')) AddCode(t_inc); + else + AssOp('+', t_addass); + return; + case '-': + if(Char('-')) AddCode(t_dec); + else + if(Char('>')) + AddCode(Char('*') ? t_arrow_asteriks : t_arrow); + else + AssOp('-', t_subass); + break; + case '&': + if(Char('&')) + AddCode(t_and); + else + AssOp('&', t_andass); + break; + case '|': + if(Char('|')) + AddCode(t_or); + else + AssOp('|', t_orass); + break; + case '=': + AssOp('=', t_eq); + break; + case '<': + if(Char('<')) + AssOp(t_shl, t_shlass); + else + AssOp('<', t_le); + break; + case '>': + if(Char('>')) + AssOp(t_shr, t_shrass); + else + AssOp('>', t_ge); + break; + case '0': { + dword w = 0; + if(Char('x') || Char('X')) { + for(;;) { + int d; + if(*ptr >= '0' && *ptr <= '9') + d = *ptr - '0'; + else + if(*ptr >= 'A' && *ptr <= 'F') + d = *ptr - 'A' + 10; + else + if(*ptr >= 'a' && *ptr <= 'f') + d = *ptr - 'a' + 10; + else + break; + if(w >= 0x8000000u - d) { + AddCode(te_integeroverflow); + return; + } + w = w * 16 + d - '0'; + ptr++; + } + } + else + while(*ptr >= '0' && *ptr <= '7') { + int d = *ptr++ - '0'; + if(w >= 0x1000000u - d) { + AddCode(te_integeroverflow); + return; + } + w = w * 8 + d - '0'; + } + Term& tm = term.AddTail(); + tm.code = t_integer; + tm.ptr = pos; + tm.number = w; + } + break; + case_nonzero_digit: { + double w = c - '0'; + bool fp = false; + while(*ptr >= '0' && *ptr <= '9') + w = w * 10 + *ptr++ - '0'; + if(*ptr == '.') { // TO BE Completed !!! + fp = true; + ptr++; + double x = 0.1; + while(*ptr >= '0' && *ptr <= '9') { + w += x * (*ptr++ - '0'); + x /= 10; + } + } + Term& tm = term.AddTail(); + if(fp || w < INT_MIN || w > INT_MAX) + tm.code = t_double; + else + tm.code = t_integer; + tm.ptr = pos; + tm.number = w; + } + break; + case '\'': { + Term& tm = term.AddTail(); + tm.code = t_character; + tm.ptr = pos; + tm.text = String(GetCharacter(), 1); + if(*ptr == '\'') + ptr++; + else + tm.code = te_badcharacter; + } + break; + case '\"': { + Term& tm = term.AddTail(); + tm.code = t_string; + tm.ptr = pos; + for(;;) { + while(*ptr != '\"') { + if((byte)*ptr < ' ') { + tm.code = te_badstring; + return; + } + tm.text.Cat(GetCharacter()); + } + ptr++; + while(*ptr && (byte)*ptr <= ' ') ptr++; + if(*ptr != '\"') break; + ptr++; + } + } + break; + default: + AddCode(c); + return; + } +} + +#pragma optimize("t", off) + +bool Lex::Prepare(int pos) { + while(term.GetCount() <= pos) { + if(*ptr == '\0') return false; + Next(); + } +#ifdef _DEBUG + pp = term[0].ptr; +#endif + return true; +} + +int Lex::Code(int pos) +{ + if(!Prepare(pos)) return t_eof; + return term[pos].code; +} + +bool Lex::IsId(int pos) +{ + return Code(pos) >= endkey + 256; +} + +String Lex::Id(int pos) +{ + ASSERT(IsId(pos)); + return id[Code(pos) - 256]; +} + +void Lex::Get(int n) +{ + while(n--) { + if(term.GetCount()) + term.DropHead(); + if(term.GetCount() == 0) + Next(); + } +} + +int Lex::Int(int pos) +{ + Prepare(pos); + ASSERT(term[pos].code == t_integer); + return (int)term[pos].number; +} + +double Lex::Double(int pos) +{ + Prepare(pos); + ASSERT(term[pos].code == t_double); + return term[pos].number; +} + +String Lex::Text(int pos) +{ + Prepare(pos); + ASSERT(term[pos].code == t_string); + return term[pos].text; +} + +int Lex::Chr(int pos) +{ + Prepare(pos); + ASSERT(term[pos].code == t_character); + return (byte)*term[pos].text; +} + +const char *Lex::Pos(int pos) +{ + Prepare(pos); + return pos < term.GetCount() ? term[pos].ptr : ptr; +} diff --git a/uppsrc/docpp/docpp.h b/archive/uppsrc/docpp/docpp.h similarity index 95% rename from uppsrc/docpp/docpp.h rename to archive/uppsrc/docpp/docpp.h index c27a72845..1d8c9811b 100644 --- a/uppsrc/docpp/docpp.h +++ b/archive/uppsrc/docpp/docpp.h @@ -1,250 +1,250 @@ -#ifndef DOCPP_H -#define DOCPP_H - -#include - -enum { - Tmarker_before_first = 255, -#define CPPID(x) tk_##x, -#include "keyword.i" -#undef CPPID -}; - -enum { - t_eof, - t_string = -200, - t_integer, - t_double, - t_character, - t_dblcolon, - t_mulass, - t_divass, - t_modass, - t_xorass, - t_neq, - t_dot_asteriks, - t_elipsis, - t_inc, - t_addass, - t_dec, - t_arrow_asteriks, - t_arrow, - t_subass, - t_and, - t_andass, - t_or, - t_orass, - t_eq, - t_shl, - t_shlass, - t_le, - t_shr, - t_shrass, - t_ge, - te_integeroverflow, - te_badcharacter, - te_badstring, -}; - -const char **CppKeyword(); - -class Lex { -#ifdef _DEBUG - const char *pp; -#endif - const char *ptr; - const char *pos; - - Index id; - Index ignore; - int endkey; - - struct Term : Moveable{ - const char *ptr; - int code; - String text; - double number; - }; - - BiVector term; - - bool Char(int c) { if(*ptr == c) { ptr++; return true; } else return false; } - void AddCode(int code) { Term& tm = term.AddTail(); tm.code = code; tm.ptr = pos; } - void AssOp(int noass, int ass) { AddCode(Char('=') ? ass : noass); } - void Next(); - bool Prepare(int pos); - int GetCharacter(); - -public: - int Code(int pos = 0); - bool IsId(int pos = 0); - String Id(int pos = 0); - int Int(int pos = 0); - double Double(int pos = 0); - int Chr(int pos = 0); - String Text(int pos = 0); - - void Get(int n = 1); - int GetCode() { int q = Code(); Get(); return q; } - String GetId() { String q = Id(); Get(); return q; } - int GetInt() { int q = Int(); Get(); return q; } - double GetDouble() { double q = Double(); Get(); return q; } - int GetChr() { int q = Chr(); Get(); return q; } - String GetText() { String q = Text(); Get(); return q; } - - const char *Pos(int pos = 0); - int operator[](int pos) { return Code(pos); } - operator int() { return Code(0); } - void operator++() { Get(); } - - void operator=(const char *s) { ptr = s; term.Clear(); } - void Ignore(const Vector& ignore); - - Lex(); -}; - -struct SrcFile { - String text; - Vector linepos; -}; - -SrcFile PreProcess(Stream& in); - - -enum Kind { - MACRO, ENUM, TYPEDEF, VARIABLE, - STRUCT, FUNCTION, - INSTANCEFUNCTION, INSTANCEVARIABLE, - CLASSFUNCTION, CLASSVARIABLE, - CONSTRUCTOR, DESTRUCTOR, - STRUCTTEMPLATE, FUNCTIONTEMPLATE, - INSTANCEFUNCTIONTEMPLATE, CLASSFUNCTIONTEMPLATE, - INLINEFRIEND, - OTHER -}; - -enum { - PRIVATE, PROTECTED, PUBLIC -}; - -struct CppItem { - String package; - - int kind; - String name; - int access; - String tparam; - String header; - String param; - String ender; - String pname; - String tname; - - String file; - int line; - - CppItem() { line = 0; } -}; - -typedef ArrayMap CppNest; -typedef ArrayMap CppNamespace; -typedef ArrayMap CppBase; - -class Parser { - struct Context { - String nameing; - String nesting; - Index typenames; - int access; - - void operator<<=(const Context& t); - - String Dump() const; - }; - - struct Decla { - bool s_static:1; - bool s_extern:1; - bool s_register:1; - bool s_auto:1; - bool s_mutable:1; - bool s_explicit:1; - bool s_virtual:1; - String name; - bool function:1; - bool type_def:1; - bool isfriend:1; - bool istemplate:1; - bool istructor:1; - bool isdestructor:1; - bool isptr:1; - bool nofn:1; - - String header; - String ender; - String template_params; - String tnames; - String natural; - - Decla(); - }; - - struct Decl : Decla { - Array param; - }; - - SrcFile file; - Lex lex; - String package, filename; - Context context; - - int lpos, line; - - CppBase *base; - - int RPtr(); - - bool Key(int code); - bool EatBody(); - - void Cv(); - String SimpleType(); - void Qualifier(); - void ParamList(Decl& d); - void Declarator(Decl& d, const char *p); - void EatInitializers(); - Decl Type(); - Array Declaration(bool l0 = false, bool more = false); - void Do(); - void Elipsis(Decl& d); - Decl& Finish(Decl& d, const char *p); - bool Nest(const String& tp, const String& tn); - - String TemplateParams(String& pnames); - String TemplateParams(); - String TemplatePnames(); - String Name(); - String Constant(); - String ReadOper(); - - int GetLine(const char *pos); - void Line(); - void Check(bool b, const char *err); - void CheckKey(int c); - - CppItem& Item(const String& nameing, const String& nesting, const String& item); - -public: - struct Error : public String { Error() {}; Error(const char *s) : String(s) {} }; - - void ThrowError(const String& e); - - void Do(Stream& s, const Vector& ignore, CppBase& base, - const String& package, const String& file) - throw(Parser::Error); -}; - -void Parse(Stream& s, const Vector& ignore, CppBase& base, - const String& package, const String& file) throw(Parser::Error); - -#endif +#ifndef DOCPP_H +#define DOCPP_H + +#include + +enum { + Tmarker_before_first = 255, +#define CPPID(x) tk_##x, +#include "keyword.i" +#undef CPPID +}; + +enum { + t_eof, + t_string = -200, + t_integer, + t_double, + t_character, + t_dblcolon, + t_mulass, + t_divass, + t_modass, + t_xorass, + t_neq, + t_dot_asteriks, + t_elipsis, + t_inc, + t_addass, + t_dec, + t_arrow_asteriks, + t_arrow, + t_subass, + t_and, + t_andass, + t_or, + t_orass, + t_eq, + t_shl, + t_shlass, + t_le, + t_shr, + t_shrass, + t_ge, + te_integeroverflow, + te_badcharacter, + te_badstring, +}; + +const char **CppKeyword(); + +class Lex { +#ifdef _DEBUG + const char *pp; +#endif + const char *ptr; + const char *pos; + + Index id; + Index ignore; + int endkey; + + struct Term : Moveable{ + const char *ptr; + int code; + String text; + double number; + }; + + BiVector term; + + bool Char(int c) { if(*ptr == c) { ptr++; return true; } else return false; } + void AddCode(int code) { Term& tm = term.AddTail(); tm.code = code; tm.ptr = pos; } + void AssOp(int noass, int ass) { AddCode(Char('=') ? ass : noass); } + void Next(); + bool Prepare(int pos); + int GetCharacter(); + +public: + int Code(int pos = 0); + bool IsId(int pos = 0); + String Id(int pos = 0); + int Int(int pos = 0); + double Double(int pos = 0); + int Chr(int pos = 0); + String Text(int pos = 0); + + void Get(int n = 1); + int GetCode() { int q = Code(); Get(); return q; } + String GetId() { String q = Id(); Get(); return q; } + int GetInt() { int q = Int(); Get(); return q; } + double GetDouble() { double q = Double(); Get(); return q; } + int GetChr() { int q = Chr(); Get(); return q; } + String GetText() { String q = Text(); Get(); return q; } + + const char *Pos(int pos = 0); + int operator[](int pos) { return Code(pos); } + operator int() { return Code(0); } + void operator++() { Get(); } + + void operator=(const char *s) { ptr = s; term.Clear(); } + void Ignore(const Vector& ignore); + + Lex(); +}; + +struct SrcFile { + String text; + Vector linepos; +}; + +SrcFile PreProcess(Stream& in); + + +enum Kind { + MACRO, ENUM, TYPEDEF, VARIABLE, + STRUCT, FUNCTION, + INSTANCEFUNCTION, INSTANCEVARIABLE, + CLASSFUNCTION, CLASSVARIABLE, + CONSTRUCTOR, DESTRUCTOR, + STRUCTTEMPLATE, FUNCTIONTEMPLATE, + INSTANCEFUNCTIONTEMPLATE, CLASSFUNCTIONTEMPLATE, + INLINEFRIEND, + OTHER +}; + +enum { + PRIVATE, PROTECTED, PUBLIC +}; + +struct CppItem { + String package; + + int kind; + String name; + int access; + String tparam; + String header; + String param; + String ender; + String pname; + String tname; + + String file; + int line; + + CppItem() { line = 0; } +}; + +typedef ArrayMap CppNest; +typedef ArrayMap CppNamespace; +typedef ArrayMap CppBase; + +class Parser { + struct Context { + String nameing; + String nesting; + Index typenames; + int access; + + void operator<<=(const Context& t); + + String Dump() const; + }; + + struct Decla { + bool s_static:1; + bool s_extern:1; + bool s_register:1; + bool s_auto:1; + bool s_mutable:1; + bool s_explicit:1; + bool s_virtual:1; + String name; + bool function:1; + bool type_def:1; + bool isfriend:1; + bool istemplate:1; + bool istructor:1; + bool isdestructor:1; + bool isptr:1; + bool nofn:1; + + String header; + String ender; + String template_params; + String tnames; + String natural; + + Decla(); + }; + + struct Decl : Decla { + Array param; + }; + + SrcFile file; + Lex lex; + String package, filename; + Context context; + + int lpos, line; + + CppBase *base; + + int RPtr(); + + bool Key(int code); + bool EatBody(); + + void Cv(); + String SimpleType(); + void Qualifier(); + void ParamList(Decl& d); + void Declarator(Decl& d, const char *p); + void EatInitializers(); + Decl Type(); + Array Declaration(bool l0 = false, bool more = false); + void Do(); + void Elipsis(Decl& d); + Decl& Finish(Decl& d, const char *p); + bool Nest(const String& tp, const String& tn); + + String TemplateParams(String& pnames); + String TemplateParams(); + String TemplatePnames(); + String Name(); + String Constant(); + String ReadOper(); + + int GetLine(const char *pos); + void Line(); + void Check(bool b, const char *err); + void CheckKey(int c); + + CppItem& Item(const String& nameing, const String& nesting, const String& item); + +public: + struct Error : public String { Error() {}; Error(const char *s) : String(s) {} }; + + void ThrowError(const String& e); + + void Do(Stream& s, const Vector& ignore, CppBase& base, + const String& package, const String& file) + throw(Parser::Error); +}; + +void Parse(Stream& s, const Vector& ignore, CppBase& base, + const String& package, const String& file) throw(Parser::Error); + +#endif diff --git a/uppsrc/docpp/docpp.upp b/archive/uppsrc/docpp/docpp.upp similarity index 90% rename from uppsrc/docpp/docpp.upp rename to archive/uppsrc/docpp/docpp.upp index f172a5de7..c98d5bbec 100644 --- a/uppsrc/docpp/docpp.upp +++ b/archive/uppsrc/docpp/docpp.upp @@ -1,12 +1,12 @@ -uses - RichEdit; - -file - docpp.h, - keyword.i, - Pre.cpp, - cpplex.cpp, - Parser.cpp, - Info readonly separator, - Copying; - +uses + RichEdit; + +file + docpp.h, + keyword.i, + Pre.cpp, + cpplex.cpp, + Parser.cpp, + Info readonly separator, + Copying; + diff --git a/uppsrc/docpp/keyword.i b/archive/uppsrc/docpp/keyword.i similarity index 93% rename from uppsrc/docpp/keyword.i rename to archive/uppsrc/docpp/keyword.i index 2baa815a5..cc9d72bff 100644 --- a/uppsrc/docpp/keyword.i +++ b/archive/uppsrc/docpp/keyword.i @@ -1,80 +1,80 @@ -#pragma BLITZ_APPROVE - -CPPID(__asm) -CPPID(else) -CPPID(struct) -CPPID(enum) -CPPID(switch) -CPPID(auto) -CPPID(__except) -CPPID(template) -CPPID(explicit) -CPPID(this) -CPPID(bool) -CPPID(extern) -CPPID(mutable) -CPPID(thread) -CPPID(break) -CPPID(false) -CPPID(throw) -CPPID(case) -CPPID(__fastcall) -CPPID(namespace) -CPPID(true) -CPPID(catch) -CPPID(__finally) -CPPID(new) -CPPID(try) -CPPID(__cdecl) -CPPID(float) -CPPID(__try) -CPPID(char) -CPPID(for) -CPPID(operator) -CPPID(typedef) -CPPID(class) -CPPID(friend) -CPPID(private) -CPPID(typeid) -CPPID(const) -CPPID(goto) -CPPID(protected) -CPPID(typename) -CPPID(const_cast) -CPPID(if) -CPPID(public) -CPPID(union) -CPPID(continue) -CPPID(inline) -CPPID(register) -CPPID(unsigned) -CPPID(__declspec) -CPPID(__inline) -CPPID(reinterpret_cast) -CPPID(using) -CPPID(default) -CPPID(int) -CPPID(return) -CPPID(delete) -CPPID(__int8) -CPPID(short) -CPPID(__uuidof) -CPPID(dllexport) -CPPID(__int16) -CPPID(signed) -CPPID(virtual) -CPPID(dllimport) -CPPID(__int32) -CPPID(sizeof) -CPPID(void) -CPPID(do) -CPPID(__int64) -CPPID(static) -CPPID(volatile) -CPPID(double) -CPPID(__leave) -CPPID(static_cast) -CPPID(dynamic_cast) -CPPID(long) -CPPID(__stdcall) -CPPID(while) +#pragma BLITZ_APPROVE + +CPPID(__asm) +CPPID(else) +CPPID(struct) +CPPID(enum) +CPPID(switch) +CPPID(auto) +CPPID(__except) +CPPID(template) +CPPID(explicit) +CPPID(this) +CPPID(bool) +CPPID(extern) +CPPID(mutable) +CPPID(thread) +CPPID(break) +CPPID(false) +CPPID(throw) +CPPID(case) +CPPID(__fastcall) +CPPID(namespace) +CPPID(true) +CPPID(catch) +CPPID(__finally) +CPPID(new) +CPPID(try) +CPPID(__cdecl) +CPPID(float) +CPPID(__try) +CPPID(char) +CPPID(for) +CPPID(operator) +CPPID(typedef) +CPPID(class) +CPPID(friend) +CPPID(private) +CPPID(typeid) +CPPID(const) +CPPID(goto) +CPPID(protected) +CPPID(typename) +CPPID(const_cast) +CPPID(if) +CPPID(public) +CPPID(union) +CPPID(continue) +CPPID(inline) +CPPID(register) +CPPID(unsigned) +CPPID(__declspec) +CPPID(__inline) +CPPID(reinterpret_cast) +CPPID(using) +CPPID(default) +CPPID(int) +CPPID(return) +CPPID(delete) +CPPID(__int8) +CPPID(short) +CPPID(__uuidof) +CPPID(dllexport) +CPPID(__int16) +CPPID(signed) +CPPID(virtual) +CPPID(dllimport) +CPPID(__int32) +CPPID(sizeof) +CPPID(void) +CPPID(do) +CPPID(__int64) +CPPID(static) +CPPID(volatile) +CPPID(double) +CPPID(__leave) +CPPID(static_cast) +CPPID(dynamic_cast) +CPPID(long) +CPPID(__stdcall) +CPPID(while) diff --git a/benchmarks/Sort/Sort.cpp b/benchmarks/Sort/Sort.cpp index 4af52ca5f..ec19c808c 100644 --- a/benchmarks/Sort/Sort.cpp +++ b/benchmarks/Sort/Sort.cpp @@ -8,9 +8,10 @@ using namespace Upp; CONSOLE_APP_MAIN { -// StdLogSetup(LOG_COUT|LOG_FILE); - for(int i = 0; i < 1000; i++) { - Vector w = AliceWords(); + StdLogSetup(LOG_COUT|LOG_FILE); + RDUMP(AliceWords().GetCount()); + for(int i = 0; i < 300; i++) { + Vector w = AliceWords(); { std::vector x; for(auto s : w) @@ -22,8 +23,30 @@ CONSOLE_APP_MAIN RTIMING("Sort Vector"); Sort(w); } + #if 0 ONCELOCK { RDUMPC(w); } + #endif + } + + for(int i = 0; i < 300; i++) { + Vector w; + for(int i = 0; i < 40000; i++) + w.Add(Random()); + { + std::vector x(w.begin(), w.end()); + RTIMING("std::sort std::vector"); + std::sort(x.begin(), x.end()); + } + { + RTIMING("Sort Vector"); + Sort(w); + } + #if 0 + ONCELOCK { + RDUMPC(w); + } + #endif } } diff --git a/configure_makefile b/configure_makefile index e4b2a8257..118148b8b 100755 --- a/configure_makefile +++ b/configure_makefile @@ -31,7 +31,23 @@ fi if [[ "$uname" == 'OpenBSD' ]]; then echo Configuring $1 for OpenBSD - sed -i.bak 's/-DflagPOSIX -DflagLINUX/-DflagPOSIX -DflagBSD -DflagFREEBSD/' $1 + sed -i.bak 's/-DflagPOSIX -DflagLINUX/-DflagPOSIX -DflagBSD -DflagOPENBSD/' $1 + sed -i.bak 's/-Wl,--gc-sections $(LINKOPTIONS)/$(LINKOPTIONS)/' $1 + sed -i.bak 's#LIBPATH =#LIBPATH = -L"/usr/local/lib"#' $1 + sed -i.bak 's#-I./ -I$(UPPOUT)#-I/usr/local/include -I./ -I$(UPPOUT)#' $1 + sed -i.bak 's/GCC-Gcc-Gui-Linux-Main-Posix-Shared/GCC-Bsd-Gcc-Gui-Main-Openbsd-Posix-Shared/' $1 + sed -i.bak 's/GCC-Gcc-Gui-Linux-Posix-Shared/GCC-Bsd-Gcc-Gui-Openbsd-Posix-Shared/' $1 + sed -i.bak 's/GCC-Gcc-Linux-Main-Posix-Shared/GCC-Bsd-Gcc-Main-Openbsd-Posix-Shared/' $1 + sed -i.bak 's/GCC-Gcc-Linux-Posix-Shared/GCC-Bsd-Gcc-Openbsd-Posix-Shared/' $1 + sed -i.bak 's/$(LIBPATH) -Wl,-O,2 $(LDFLAGS)/$(LIBPATH) $(LDFLAGS)/' $1 + sed -i.bak 's/-ldl /-lexecinfo /' $1 + sed -i.bak 's/-lrt / /' $1 + rm $1.bak +fi + +if [[ "$uname" == 'NetBSD' ]]; then + echo Configuring $1 for OpenBSD + sed -i.bak 's/-DflagPOSIX -DflagLINUX/-DflagPOSIX -DflagBSD -DflagNETBSD/' $1 sed -i.bak 's/-Wl,--gc-sections $(LINKOPTIONS)/$(LINKOPTIONS)/' $1 sed -i.bak 's#LIBPATH =#LIBPATH = -L"/usr/local/lib"#' $1 sed -i.bak 's#-I./ -I$(UPPOUT)#-I/usr/local/include -I./ -I$(UPPOUT)#' $1 diff --git a/uppbox/uppweb/Resources/Images/TheIDE.png b/uppbox/uppweb/Resources/Images/TheIDE.png new file mode 100644 index 000000000..b3ec8ae5c Binary files /dev/null and b/uppbox/uppweb/Resources/Images/TheIDE.png differ diff --git a/uppsrc/DocTypes/DocTypes.upp b/uppsrc/DocTypes/DocTypes.upp index 920e3c893..bfd8857d3 100644 --- a/uppsrc/DocTypes/DocTypes.upp +++ b/uppsrc/DocTypes/DocTypes.upp @@ -1,3 +1,5 @@ +description "Legacy reports. Do not use in the new code.\377"; + uses Draw, RichText, diff --git a/uppsrc/GLCtrl/GLCtrl.upp b/uppsrc/GLCtrl/GLCtrl.upp index d18da7447..e2b6336b3 100644 --- a/uppsrc/GLCtrl/GLCtrl.upp +++ b/uppsrc/GLCtrl/GLCtrl.upp @@ -1,3 +1,5 @@ +description "OpenGL widget base class\377"; + uses CtrlCore, plugin/glew; diff --git a/uppsrc/GLDraw/GLDraw.upp b/uppsrc/GLDraw/GLDraw.upp index 592a5d2d5..dcba30965 100644 --- a/uppsrc/GLDraw/GLDraw.upp +++ b/uppsrc/GLDraw/GLDraw.upp @@ -1,3 +1,5 @@ +description "OpenGL Draw implementation\377"; + uses Draw, Painter, diff --git a/uppsrc/Geom/Coords/Coords.upp b/uppsrc/Geom/Coords/Coords.upp index 8eac56533..43308690b 100644 --- a/uppsrc/Geom/Coords/Coords.upp +++ b/uppsrc/Geom/Coords/Coords.upp @@ -1,3 +1,5 @@ +description "Geographical coordinates. Somewhat obsolete.\377"; + uses Geom; diff --git a/uppsrc/Geom/Ctrl/Ctrl.upp b/uppsrc/Geom/Ctrl/Ctrl.upp index 1bb6834c4..6bc00a3ac 100644 --- a/uppsrc/Geom/Ctrl/Ctrl.upp +++ b/uppsrc/Geom/Ctrl/Ctrl.upp @@ -1,3 +1,5 @@ +description "Geometry related GUI code. Do not use in the new code.\377"; + uses Geom\Draw, TCtrlLib; diff --git a/uppsrc/Geom/Draw/Draw.upp b/uppsrc/Geom/Draw/Draw.upp index 3e40773fe..612504b7c 100644 --- a/uppsrc/Geom/Draw/Draw.upp +++ b/uppsrc/Geom/Draw/Draw.upp @@ -1,3 +1,5 @@ +description "Geometry related GUI code. Do not use in the new code.\377"; + acceptflags NOHRRPNG; diff --git a/uppsrc/Geom/Geom.upp b/uppsrc/Geom/Geom.upp index 4bccc8e1c..44c778ced 100644 --- a/uppsrc/Geom/Geom.upp +++ b/uppsrc/Geom/Geom.upp @@ -1,3 +1,5 @@ +description "2D and 3D geometry mathematics. Somewhat obsolete\377"; + uses Core; diff --git a/uppsrc/Ole/Ctrl/Ctrl.upp b/uppsrc/Ole/Ctrl/Ctrl.upp index 7b3214f3c..59351f438 100644 --- a/uppsrc/Ole/Ctrl/Ctrl.upp +++ b/uppsrc/Ole/Ctrl/Ctrl.upp @@ -1,3 +1,5 @@ +description "Windows GUI OLE encapsulation\377"; + uses Ole, CtrlCore; diff --git a/uppsrc/Ole/Ole.upp b/uppsrc/Ole/Ole.upp index 5a565b34c..58b20d0ec 100644 --- a/uppsrc/Ole/Ole.upp +++ b/uppsrc/Ole/Ole.upp @@ -1,3 +1,5 @@ +description "Windows OLE encapsulation\377"; + uses Core; diff --git a/uppsrc/PostgreSQL/PostgreSQL.upp b/uppsrc/PostgreSQL/PostgreSQL.upp index 0170ebdb9..1351d040c 100644 --- a/uppsrc/PostgreSQL/PostgreSQL.upp +++ b/uppsrc/PostgreSQL/PostgreSQL.upp @@ -1,3 +1,5 @@ +description "PostgreSQL SQl database support\377"; + acceptflags NOPOSTGRESQL; diff --git a/uppsrc/Skylark/Iml/Iml.upp b/uppsrc/Skylark/Iml/Iml.upp index 5e2aa651d..3bb2c591b 100644 --- a/uppsrc/Skylark/Iml/Iml.upp +++ b/uppsrc/Skylark/Iml/Iml.upp @@ -1,4 +1,4 @@ -description "\377128,0,0"; +description "Using .iml files in Skylark\377128,0,0"; uses Draw, diff --git a/uppsrc/TextDiffCtrl/TextDiffCtrl.upp b/uppsrc/TextDiffCtrl/TextDiffCtrl.upp index d2806d314..2b90cbfa1 100644 --- a/uppsrc/TextDiffCtrl/TextDiffCtrl.upp +++ b/uppsrc/TextDiffCtrl/TextDiffCtrl.upp @@ -1,3 +1,5 @@ +description "Widgets to show differences between two texts\377"; + uses CtrlLib; diff --git a/uppsrc/VirtualGui/SDL2GL/SDL2GL.upp b/uppsrc/VirtualGui/SDL2GL/SDL2GL.upp index 28a0f3426..5c1e7d5fc 100644 --- a/uppsrc/VirtualGui/SDL2GL/SDL2GL.upp +++ b/uppsrc/VirtualGui/SDL2GL/SDL2GL.upp @@ -1,3 +1,5 @@ +description "VirtualGui implementation for SDL2/OpenGL\377"; + uses VirtualGui, GLDraw; diff --git a/uppsrc/VirtualGui/VirtualGui.upp b/uppsrc/VirtualGui/VirtualGui.upp index 545f9c0af..1da748302 100644 --- a/uppsrc/VirtualGui/VirtualGui.upp +++ b/uppsrc/VirtualGui/VirtualGui.upp @@ -1,4 +1,4 @@ -description "SlaveGui backend\377"; +description "Abstract GUI implementation, with window manager, with minimal implemenation requirements\377"; uses Painter, diff --git a/uppsrc/plugin/astyle/astyle.upp b/uppsrc/plugin/astyle/astyle.upp index 617350248..c53e99a54 100644 --- a/uppsrc/plugin/astyle/astyle.upp +++ b/uppsrc/plugin/astyle/astyle.upp @@ -1,4 +1,4 @@ -description "\3770,128,128"; +description "astyle C++ formatting utility\3770,128,128"; uses Core; diff --git a/uppsrc/plugin/lz4/lz4.upp b/uppsrc/plugin/lz4/lz4.upp index 33b48ba5c..438fd50d1 100644 --- a/uppsrc/plugin/lz4/lz4.upp +++ b/uppsrc/plugin/lz4/lz4.upp @@ -1,4 +1,4 @@ -description "\3770,128,128"; +description "LZ4 compressor (lower compression but very fast)\3770,128,128"; uses Core; diff --git a/uppsrc/plugin/lzma/lzma.upp b/uppsrc/plugin/lzma/lzma.upp index 1c822ba7b..8cc4344b2 100644 --- a/uppsrc/plugin/lzma/lzma.upp +++ b/uppsrc/plugin/lzma/lzma.upp @@ -1,4 +1,4 @@ -description "\3770,128,128"; +description "LZMA compressor (slow, but very good ratio)\3770,128,128"; uses Core; diff --git a/uppsrc/plugin/zstd/zstd.upp b/uppsrc/plugin/zstd/zstd.upp index 559bfcd1a..51a567701 100644 --- a/uppsrc/plugin/zstd/zstd.upp +++ b/uppsrc/plugin/zstd/zstd.upp @@ -1,4 +1,4 @@ -description "\3770,128,128"; +description "zstd compressor (good ratio, very good speed)\3770,128,128"; uses Core; diff --git a/uppsrc/plugin/zstd_legacy/zstd_legacy.upp b/uppsrc/plugin/zstd_legacy/zstd_legacy.upp index 52a0db9ab..d91a11c86 100644 --- a/uppsrc/plugin/zstd_legacy/zstd_legacy.upp +++ b/uppsrc/plugin/zstd_legacy/zstd_legacy.upp @@ -1,4 +1,4 @@ -description "\3770,128,128"; +description "Support for older zstd format. Do not use with new applications.\3770,128,128"; file zstd.h,