pattern prototype patternwip
authorKonrad Rosenbaum <Konrad.Rosenbaum@peergroup.com>
Mon, 2 Jan 2017 12:14:23 +0000 (13:14 +0100)
committerKonrad Rosenbaum <Konrad.Rosenbaum@peergroup.com>
Mon, 2 Jan 2017 12:14:23 +0000 (13:14 +0100)
26 files changed:
.gitignore
Makefile
tclbase/wobbase.tcl [new file with mode: 0644]
woc/generic/generic.pri [new file with mode: 0644]
woc/generic/genfile.cpp [new file with mode: 0644]
woc/generic/genfile.h [new file with mode: 0644]
woc/generic/genout.cpp [new file with mode: 0644]
woc/generic/genout.h [new file with mode: 0644]
woc/generic/genproc.cpp [new file with mode: 0644]
woc/generic/genproc.h [new file with mode: 0644]
woc/pattern/qt5/client/class-include [new file with mode: 0644]
woc/pattern/qt5/client/export [new file with mode: 0644]
woc/pattern/qt5/client/includeAll [new file with mode: 0644]
woc/pattern/qt5/client/interface-header [new file with mode: 0644]
woc/pattern/qt5/client/interface-include [new file with mode: 0644]
woc/pattern/qt5/client/meta.txt [new file with mode: 0644]
woc/pattern/qt5/client/transaction-include [new file with mode: 0644]
woc/patterns.qrc [new file with mode: 0644]
woc/proc/procclass.cpp
woc/proc/processor.cpp
woc/proc/proctable.cpp
woc/proc/proctrans.cpp
woc/qrcgen/qrcgen.cpp [new file with mode: 0644]
woc/qrcgen/qrcgen.pro [new file with mode: 0644]
woc/woc.cpp
woc/woc.pro

index 512b7db..5c1d289 100644 (file)
@@ -14,6 +14,10 @@ vinfo
 .ptmp
 qtbase/Makefile*
 woc/Makefile*
+woc/tclbase.qrc
+woc/tclbasegen/Makefile
+woc/tclbasegen/tbg
+woc/tclbasegen/tbg.exe
 doc/*base
 doc/woc
 *.tag
@@ -27,3 +31,5 @@ examples/clock/qtc/clock
 examples/clock/qts/clockserv
 examples/clock/qtc/clock.exe
 examples/clock/qts/clockserv.exe
+woc/qrcgen/Makefile
+woc/qrcgen/qrcgen
index f4ab98c..c293ef1 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -23,12 +23,15 @@ all: prewoc woc qtbase doc
 
 .PHONY: prewoc woc qtbase doc clean install install-woc install-qtbase install-phpbase install-doc
 
-vinfo/staticVersion.h prewoc:
+woc/tclbase.qrc woc/patterns.qrc:
+       cd woc/qrcgen && $(QMAKE) && $(MAKE) && $(abspath woc/qrcgen/qrcgen) ../tclbase:tclbase:tclbase.qrc pattern:pattern:patterns.qrc
+
+vinfo/staticVersion.h prewoc: woc/patterns.qrc
        cd woc && $(QMAKE) -o Makefile.prewoc CONFIG+=prewoc
        $(MAKE) -C woc -f Makefile.prewoc
        cd woc && $(abspath woc/prewoc) :/version.wolf
 
-woc: vinfo/staticVersion.h
+woc: vinfo/staticVersion.h woc/tclbase.qrc woc/patterns.qrc
        cd woc && $(QMAKE) CONFIG+=woc
        $(MAKE) -C woc
 
diff --git a/tclbase/wobbase.tcl b/tclbase/wobbase.tcl
new file mode 100644 (file)
index 0000000..b8ae046
--- /dev/null
@@ -0,0 +1 @@
+#!/bin/tclsh
diff --git a/woc/generic/generic.pri b/woc/generic/generic.pri
new file mode 100644 (file)
index 0000000..931e2b1
--- /dev/null
@@ -0,0 +1,11 @@
+SOURCES+= \
+       generic/genproc.cpp \
+       generic/genout.cpp \
+       generic/genfile.cpp 
+
+HEADERS+= \
+       generic/genproc.h \
+       generic/genout.h \
+       generic/genfile.h 
+
+INCLUDEPATH += generic
diff --git a/woc/generic/genfile.cpp b/woc/generic/genfile.cpp
new file mode 100644 (file)
index 0000000..0678131
--- /dev/null
@@ -0,0 +1,76 @@
+// Copyright (C) 2016 by Konrad Rosenbaum <konrad@silmor.de>
+// protected under the GNU GPL version 3 or at your option any newer.
+// See COPYING.GPL file that comes with this distribution.
+//
+
+#include "genfile.h"
+#include "genout.h"
+
+WocGenericVariables::~WocGenericVariables(){}
+
+static const QRegExp validVarName("[a-zA-Z_](([a-zA-Z0-9_:.-]*[a-zA-Z0-9_])?)");
+
+bool WocSimpleVariables::isValidName(QString name)
+{
+       return validVarName.exactMatch(name);
+}
+
+
+
+WocGenericFile::WocGenericFile(WocGenericFile::FileType type, QString pattern, WocGenericVariables*globalvars)
+       : QObject(), mfiletype(type), mfilepattern(pattern), mglobalvars(globalvars)
+{
+}
+
+WocGenericFile::~WocGenericFile()
+{
+       closeFile();
+}
+
+void WocGenericFile::closeFile()
+{
+       if(mcurrentfile){
+               mcurrentfile->close();
+               delete mcurrentfile;
+               mcurrentfile=nullptr;
+       }
+}
+
+void WocGenericFile::setPatternFile(QString patternfilename)
+{
+       QFile fd(patternfilename);
+       //TODO: error handling
+       fd.open(QIODevice::ReadOnly);
+       
+       //get split comment
+       
+       //parse file
+       ...parse
+}
+
+void WocGenericFile::createNewFile(QString basename)
+{
+       closeFile();
+       QString fn=mfilepattern;
+       fn.replace('*',basename);
+       mcurrentfile=new MFile(fn);
+       //TODO: error handling!
+       mcurrentfile->open(QIODevice::WriteOnly|QIODevice::Truncate);
+}
+
+void WocGenericFile::startProject()
+{
+       if(mfiletype!=FileType::Global)return;
+       WocSimpleVariables vars(mglobalvars);
+       createNewFile(QString());
+}
+
+void WocGenericFile::endProject()
+{
+       closeFile();
+}
+
+void WocGenericFile::newClass()
+{
+
+}
diff --git a/woc/generic/genfile.h b/woc/generic/genfile.h
new file mode 100644 (file)
index 0000000..5985099
--- /dev/null
@@ -0,0 +1,90 @@
+// Copyright (C) 2016 by Konrad Rosenbaum <konrad@silmor.de>
+// protected under the GNU GPL version 3 or at your option any newer.
+// See COPYING.GPL file that comes with this distribution.
+//
+
+#ifndef WOC_GENERICFILE_H
+#define WOC_GENERICFILE_H
+
+#include <QObject>
+#include "../mfile.h"
+
+class WocGenericOut;
+class WocGenericVariables
+{
+public:
+       explicit WocGenericVariables(WocGenericVariables*parent=nullptr):mparent(parent){}
+       virtual ~WocGenericVariables();
+       
+       virtual QString getVariable(QString name)=0;
+       virtual bool setVariable(QString name,QString value)
+       {
+               Q_UNUSED(name);Q_UNUSED(value);
+               return false;
+       }
+       
+protected:
+       WocGenericVariables*mparent=nullptr;
+};
+
+class WocGenericFile:public QObject
+{
+       Q_OBJECT
+public:
+       enum class FileType{
+               Global,
+               Class,
+               Transaction,
+               Table
+       };
+       WocGenericFile(FileType type,QString namepattern,WocGenericVariables*globalvars);
+       virtual ~WocGenericFile();
+public slots:
+       void setPatternFile(QString patternfilename);
+       void startProject();
+       void endProject();
+       void newClass();
+private:
+       MFile*mcurrentfile=nullptr;
+       FileType mfiletype;
+       QString mfilepattern;
+       WocGenericVariables*mglobalvars;
+       QMap<QString,QString>msections;
+       
+       void createNewFile(QString basename);
+       void closeFile();
+};
+
+class WocProjectVariables:public WocGenericVariables
+{
+public:
+       explicit WocProjectVariables(WocGenericOut*);
+       
+       QString getVariable(QString)override;
+};
+
+class WocSimpleVariables:public WocGenericVariables
+{
+public:
+       explicit WocSimpleVariables(WocGenericVariables*parent):WocGenericVariables(parent){}
+       
+       QString getVariable(QString name)override
+       {
+               if(mvars.contains(name))return mvars[name];
+               else return mparent->getVariable(name);
+       }
+       
+       bool setVariable(QString name,QString value)override
+       {
+               if(!isValidName(name))return false;
+               mvars.insert(name,value);
+               return true;
+       }
+private:
+       QMap<QString,QString>mvars;
+       
+       static bool isValidName(QString);
+};
+
+
+#endif
diff --git a/woc/generic/genout.cpp b/woc/generic/genout.cpp
new file mode 100644 (file)
index 0000000..c2176e6
--- /dev/null
@@ -0,0 +1,74 @@
+// Copyright (C) 2016 by Konrad Rosenbaum <konrad@silmor.de>
+// protected under the GNU GPL version 3 or at your option any newer.
+// See COPYING.GPL file that comes with this distribution.
+//
+
+#include "genout.h"
+
+#include <QDir>
+#include <QDomElement>
+
+#define QT_OUT_NO_WRAP
+#include "doxyout.h"
+
+WocGenericOut::WocGenericOut(PatternDir pattern, const QDomElement&el)
+{
+       qDebug("Info: creating %s Generator.",el.tagName().toLatin1().data());
+       m_basedir=WocProcessor::instance()->baseDir()+"/"+el.attribute("sourceDir",".");
+       m_subdir=el.attribute("subDir","wob");
+       m_clean=str2bool(el.attribute("clean","0"));
+       m_transbase=el.attribute("transactionBase","::wob::WTransaction");
+       m_namespace=el.attribute("namespace","::");
+       if(!m_namespace.startsWith("::"))m_namespace="::"+m_namespace;
+       //get/create directory
+       QDir d(m_basedir+"/"+m_subdir);
+       if(!d.exists())QDir(".").mkpath(m_basedir+"/"+m_subdir);
+}
+
+WocGenericOut::~WocGenericOut(){}
+
+void WocGenericOut::finalize()
+{
+       //finish sub-classes
+//     if(tclass)tclass->finalize();
+//     if(ttrans)ttrans->finalize();
+       //generate versionInfo
+       initVersion();
+}
+
+void WocGenericOut::newClass(const WocClass&cls)
+{
+//     if(tclass)tclass->newClass(cls);
+}
+
+void WocGenericOut::newTransaction(const WocTransaction&trn)
+{
+//     if(ttrans)ttrans->newTransaction(trn);
+}
+
+void WocGenericOut::addFile(QString fn)
+{
+       QString code=QString("source [file join [file dirname [info script]] %1\n").arg(fn);
+       m_hdr.write(code.toLatin1());
+}
+
+
+
+
+#ifndef NO_PACK_VERSION_H
+#include "../../vinfo/staticVersion.h"
+#endif
+
+static inline QString escapeStr(QString s)
+{
+       return s.replace("\\","\\\\").replace("\"","\\\"").replace("\n","\\n");
+}
+
+void WocGenericOut::initVersion()
+{
+}
+
+void WocGenericOut::addIfaceImpl ( const QString& s )
+{
+}
+
diff --git a/woc/generic/genout.h b/woc/generic/genout.h
new file mode 100644 (file)
index 0000000..db6b109
--- /dev/null
@@ -0,0 +1,79 @@
+// Copyright (C) 2016 by Konrad Rosenbaum <konrad@silmor.de>
+// protected under the GNU GPL version 3 or at your option any newer.
+// See COPYING.GPL file that comes with this distribution.
+//
+
+#ifndef WOC_GENERICOUT_H
+#define WOC_GENERICOUT_H
+
+#include <QObject>
+
+#include "processor.h"
+
+#include "mfile.h"
+
+#include "genproc.h"
+
+class QDomElement;
+
+class WocGenericOut;
+
+///Abstract base class for Generic client and server output.
+///This class controls the main include files and uses helpers to generate
+///transactions, classes and tables.
+///
+///It generates the interface class, a .pri-file and an include-all file.
+class WocGenericOut:public WocOutput
+{
+       public:
+               ///creates a Generic output object from the corresponding XML tag
+               ///that specifies what kind of output is desired.
+               explicit WocGenericOut(PatternDir pattern,const QDomElement&);
+               ///deletes the output object
+               ~WocGenericOut();
+               
+               ///adds code to the implementation file of the interface class
+               void addIfaceImpl(const QString&);
+               
+       protected:
+               ///overloaded slot, called when parsing is finished
+               virtual void finalize()override;
+               ///overloaded slot, called for each new class
+               virtual void newClass(const WocClass&)override;
+               ///overloaded slot, called for each new transaction
+               virtual void newTransaction(const WocTransaction&)override;
+               ///overloaded slot, dummy
+               virtual void newTable(const WocTable&)override{}
+       
+       public:
+               /**helper: adds a file to the project file
+               \param basename the file name to add*/
+               void addFile(QString basename);
+               
+               ///returns the language output spec
+               inline QString languageSpec()const{return m_lang;}
+               ///returns the base directory of the project
+               inline QString baseDir()const{return m_basedir;}
+               ///returns the sub directory relative to the project where to store files
+               inline QString subDir()const{return m_subdir;}
+               ///returns the complete path for files, baseDir()+subDir()
+               inline QString destinationPath()const{return m_basedir+"/"+m_subdir;}
+               ///returns the base class of all transactions
+               inline QString transactionBase()const{return m_transbase;}
+               ///returns the namespace
+               inline QString nameSpace()const{return m_namespace;}
+               
+       private:
+               ///internal: generate the static header for version info
+               void initVersion();
+               
+       private:
+               QString m_basedir,m_subdir,m_transbase,m_postiface,m_scriptcode,m_namespace;
+                mutable QString m_exportsym;
+               bool m_clean;
+               MFile m_iface,m_hdr;
+       protected:
+               QString m_lang;
+};
+
+#endif
diff --git a/woc/generic/genproc.cpp b/woc/generic/genproc.cpp
new file mode 100644 (file)
index 0000000..df6ce1f
--- /dev/null
@@ -0,0 +1,69 @@
+// Copyright (C) 2016 by Konrad Rosenbaum <konrad@silmor.de>
+// protected under the GNU GPL version 3 or at your option any newer.
+// See COPYING.GPL file that comes with this distribution.
+//
+
+#include "genproc.h"
+#include "genout.h"
+
+#include <QMap>
+#include <QDir>
+#include <QDebug>
+
+// pattern map: tag => pattern
+static QMap<QString,PatternDir> genmap;
+
+void WalkPattern(QString dir,QString tname=QString())
+{
+       // recurse into sub-dirs
+       for(auto entry:QDir(dir).entryInfoList(QDir::AllDirs)){
+               if(entry.fileName()=="." || entry.fileName()=="..")continue;
+               if(entry.isDir())
+                       WalkPattern(entry.absoluteFilePath(),tname+"/"+entry.fileName());
+       }
+
+       // check whether this is a pattern dir
+       QFileInfo info(dir+"/meta.txt");
+       if(!info.exists() || !info.isFile() || !info.isReadable())return;
+       PatternDir pat;
+       pat.patterntype=tname;
+       pat.dirname=dir;
+       //parse meta and find tag name
+       QFile fd(info.absoluteFilePath());
+       if(!fd.open(QIODevice::ReadOnly)){
+               qDebug()<<"Error: cannot read pattern meta file"<<info.absoluteFilePath()<<"ignoring it!";
+               return;
+       }
+       while(!fd.atEnd()){
+               QString line=QString::fromUtf8(fd.readLine()).trimmed();
+               if(line.startsWith("tag ")){
+                       pat.tagname=line.mid(4).trimmed();
+                       break;
+               }
+       }
+       fd.close();
+       if(pat.tagname.isEmpty()){
+               qDebug()<<"Warning: pattern in"<<info.absoluteFilePath()<<"has no valid tag name! Ignoring it!";
+               return;
+       }
+       qDebug()<<"Found pattern"<<pat.patterntype<<"with tag"<<pat.tagname<<"in"<<pat.dirname;
+       genmap.insert(pat.tagname,pat);
+}
+
+void InitializeGeneric(QString dir)
+{
+       //go through patterns recursively
+       if(dir.isEmpty())
+               WalkPattern(":/pattern");
+       else
+               WalkPattern(dir);
+}
+
+bool CreateGenericOutput(QString tagname, const QDomElement&element)
+{
+       if(!genmap.contains(tagname))
+               return false;
+       PatternDir pat=genmap[tagname];
+       new WocGenericOut(pat,element);
+       return true;
+}
diff --git a/woc/generic/genproc.h b/woc/generic/genproc.h
new file mode 100644 (file)
index 0000000..dd957cf
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright (C) 2016 by Konrad Rosenbaum <konrad@silmor.de>
+// protected under the GNU GPL version 3 or at your option any newer.
+// See COPYING.GPL file that comes with this distribution.
+//
+
+#ifndef WOC_GENPROC_H
+#define WOC_GENPROC_H
+
+#include "processor.h"
+#include <QString>
+
+class QDomElement;
+
+//pattern descriptions
+struct PatternDir{
+       QString tagname,patterntype,dirname;
+};
+
+
+
+///Scans a directory and looks for valid patterns.
+void InitializeGeneric(QString dirs=QString());
+
+///Creates the generic pattern based output object based on a tag name.
+bool CreateGenericOutput(QString tagname,const QDomElement&);
+
+#endif
diff --git a/woc/pattern/qt5/client/class-include b/woc/pattern/qt5/client/class-include
new file mode 100644 (file)
index 0000000..4dad7c2
--- /dev/null
@@ -0,0 +1,2 @@
+//-- prolog
+#include "src${filename}.h"
diff --git a/woc/pattern/qt5/client/export b/woc/pattern/qt5/client/export
new file mode 100644 (file)
index 0000000..749b084
--- /dev/null
@@ -0,0 +1,25 @@
+//===============================
+//== defines the export Macro
+//===============================
+//-- prolog
+//BEGIN OF AUTOMATICALLY GENERATED FILE
+//DO NOT EDIT THIS FILE DIRECTLY, USE THE XML SOURCE!
+#ifndef ${includeGuard}
+#define ${includeGuard}
+
+//===============================
+//-- epilog
+
+//END OF AUTOMATICALLY GENERATED FILE
+#endif
+//===============================
+//-- post-prolog?enableExport
+
+#ifndef ${exportmacro}
+#define ${exportmacro} Q_DECL_IMPORT
+#endif
+
+//-- post-prolog?!enableExport
+#ifndef ${exportmacro}
+#define ${exportmacro}
+#endif
diff --git a/woc/pattern/qt5/client/includeAll b/woc/pattern/qt5/client/includeAll
new file mode 100644 (file)
index 0000000..9690ee0
--- /dev/null
@@ -0,0 +1,22 @@
+//===============================
+//== general include file
+//===============================
+//-- prolog
+//BEGIN OF AUTOMATICALLY GENERATED FILE
+//DO NOT EDIT THIS FILE DIRECTLY, USE THE XML SOURCE!
+#ifndef ${includeGuard}
+#define ${includeGuard}
+
+#include "src${allClassPrefix}${interfaceName}.h"
+
+//===============================
+//-- epilog
+
+//END OF AUTOMATICALLY GENERATED FILE
+#endif
+//===============================
+//-- class:prolog
+#include "src${classname}.h"
+//===============================
+//-- transaction:prolog
+#include "src${classname}.h"
diff --git a/woc/pattern/qt5/client/interface-header b/woc/pattern/qt5/client/interface-header
new file mode 100644 (file)
index 0000000..dcf7115
--- /dev/null
@@ -0,0 +1,22 @@
+//===============================
+//== 
+//===============================
+//-- prolog
+//BEGIN OF AUTOMATICALLY GENERATED FILE
+//DO NOT EDIT THIS FILE DIRECTLY, USE THE XML SOURCE!
+#ifndef ${includeGuard}
+#define ${includeGuard}
+
+#include "exportdef.h"
+
+class ${exportmacro} ${classname} : public ${interfaceBase}
+{
+
+//===============================
+//-- epilog
+
+};
+
+//END OF AUTOMATICALLY GENERATED FILE
+#endif
+//===============================
diff --git a/woc/pattern/qt5/client/interface-include b/woc/pattern/qt5/client/interface-include
new file mode 100644 (file)
index 0000000..4dad7c2
--- /dev/null
@@ -0,0 +1,2 @@
+//-- prolog
+#include "src${filename}.h"
diff --git a/woc/pattern/qt5/client/meta.txt b/woc/pattern/qt5/client/meta.txt
new file mode 100644 (file)
index 0000000..375c993
--- /dev/null
@@ -0,0 +1,45 @@
+#basic infos
+#inherit qt5/none
+generator qt5/client
+tag Qt5ClientOutput
+
+#syntax
+comment //==
+doc-comment ///
+out-comment //WOC:
+section-start //--
+variable-marker ${ }
+
+#standard features (token, default, configurable)
+feature allClassPrefix C yes
+feature classPrefix Obj yes
+feature transactionPrefix Trn yes
+#feature tablePrefix Tbl
+feature interfaceName Interface yes
+
+#additional configurable features (name, type, default)
+addFeature scriptable boolean no
+addFeature enableExport boolean yes
+
+#standard files (type token pattern) [use * for class name pattern]
+file class include *
+file class header src*.h
+file class source src*.cpp
+file transaction include *
+file transaction header src*.h
+file transaction source src*.cpp
+#file table include *
+#file table header src*.h
+#file table source src*.cpp
+file interface include *
+file interface header src*.h
+file interface source src*.cpp
+file version header staticVersion.h
+
+#additional files (token, pattern, configurable, called-for)
+addFile pri wob.pri yes all
+addFile includeAll {classPrefix}IncludeAll yes all
+addFile export exportdef.h no none
+
+#pre-defined variables (name initial-value|optional-conversion)
+variable exportmacro WOBGEN_{Project:name|toUpper}_EXPORT
diff --git a/woc/pattern/qt5/client/transaction-include b/woc/pattern/qt5/client/transaction-include
new file mode 100644 (file)
index 0000000..4dad7c2
--- /dev/null
@@ -0,0 +1,2 @@
+//-- prolog
+#include "src${filename}.h"
diff --git a/woc/patterns.qrc b/woc/patterns.qrc
new file mode 100644 (file)
index 0000000..182d22d
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE RCC>
+<!-- AUTO GENERATED FILE -->
+<RCC version="1.0">
+<qresource>
+<file alias="pattern/qt5/client/class-include">pattern/qt5/client/class-include</file>
+<file alias="pattern/qt5/client/export">pattern/qt5/client/export</file>
+<file alias="pattern/qt5/client/includeAll">pattern/qt5/client/includeAll</file>
+<file alias="pattern/qt5/client/interface-header">pattern/qt5/client/interface-header</file>
+<file alias="pattern/qt5/client/interface-include">pattern/qt5/client/interface-include</file>
+<file alias="pattern/qt5/client/meta.txt">pattern/qt5/client/meta.txt</file>
+<file alias="pattern/qt5/client/transaction-include">pattern/qt5/client/transaction-include</file>
+</qresource></RCC>
index 22a65e9..60bf515 100644 (file)
@@ -5,9 +5,11 @@
 
 #include "processor.h"
 
-#include "phpout.h"
 #include "qtout.h"
+#ifndef COMPILE_PREWOC
+#include "phpout.h"
 #include "htmlout.h"
+#endif
 
 #include "domquery.h"
 
index f7c6b23..50c50c6 100644 (file)
@@ -5,11 +5,14 @@
 
 #include "processor.h"
 
-#include "phpout.h"
 #include "qtout.h"
+#ifndef COMPILE_PREWOC
+#include "phpout.h"
 #include "htmlout.h"
 #include "schemaout.h"
 #include "soapout.h"
+#include "genproc.h"
+#endif
 
 #include "domquery.h"
 
@@ -178,6 +181,7 @@ bool WocProcessor::processFile(QString fn)
                        new WocQtClientOut(el);
                        if(m_error)return false;
                }else
+#ifndef COMPILE_PREWOC
                if(tn=="QtServerOutput"){
                        new WocQtServerOut(el);
                        if(m_error)return false;
@@ -202,6 +206,7 @@ bool WocProcessor::processFile(QString fn)
                        new WocSoapOut(el);
                        if(m_error)return false;
                }else
+#endif
                if(tn=="Version"){
                        if(el.hasAttribute("system"))
                                m_verSys=el.attribute("system").split(" ",QString::SkipEmptyParts);
@@ -239,8 +244,8 @@ bool WocProcessor::processFile(QString fn)
                if(tn=="Doc"){
                        QString s=el.text().trimmed();
                        if(s!="")m_docstrings<<s;
-               }
-               else{
+               }else
+               if(!CreateGenericOutput(tn,el)){
                        qDebug("Warning: file %s has unknown element '%s' at line %i column %i", fn.toLocal8Bit().data(), tn.toLocal8Bit().data(), el.lineNumber(), el.columnNumber());
                }
        }
index 1555d5f..d6d3f34 100644 (file)
@@ -5,9 +5,11 @@
 
 #include "processor.h"
 
-#include "phpout.h"
 #include "qtout.h"
+#ifndef COMPILE_PREWOC
+#include "phpout.h"
 #include "htmlout.h"
+#endif
 
 #include "domquery.h"
 
index 0a83897..b80f2dd 100644 (file)
@@ -5,9 +5,11 @@
 
 #include "processor.h"
 
-#include "phpout.h"
 #include "qtout.h"
+#ifndef COMPILE_PREWOC
+#include "phpout.h"
 #include "htmlout.h"
+#endif
 
 #include "domquery.h"
 
diff --git a/woc/qrcgen/qrcgen.cpp b/woc/qrcgen/qrcgen.cpp
new file mode 100644 (file)
index 0000000..5398c58
--- /dev/null
@@ -0,0 +1,51 @@
+#include <QCoreApplication>
+#include <QDir>
+#include <QDebug>
+
+#define PROLOG "<!DOCTYPE RCC>\n\
+<!-- AUTO GENERATED FILE -->\n\
+<RCC version=\"1.0\">\n<qresource>\n"
+
+#define EPILOG "</qresource></RCC>\n"
+
+void writeOut(QFile&out,QString source,QString target)
+{
+       QDir dir(source);
+       qDebug()<<"Scanning directory"<<source<<(dir.isReadable()?"(ok)":"(NOT READABLE)")<<"as"<<target<<"into"<<out.fileName();
+       for(QString fn:dir.entryList(QDir::Files|QDir::Dirs)){
+               if(fn=="." || fn=="..")continue;
+               if(QFileInfo(source+"/"+fn).isDir()){
+                       writeOut(out,source+"/"+fn,target.isEmpty()?fn:(target+"/"+fn));
+               }else
+                       out.write(QString("<file alias=\"%3/%1\">%2/%1</file>\n").arg(fn).arg(source).arg(target).toLatin1());
+       }
+}
+
+int main(int ac,char**av)
+{
+       QCoreApplication app(ac,av);
+       QDir::setCurrent(app.applicationDirPath()+"/..");
+       qDebug()<<"Generatin QRCs from"<<QDir::current().absolutePath();
+       for(QString pathspec:app.arguments().mid(1)){
+               qDebug()<<"Working on pathspec"<<pathspec;
+               const QStringList pathes=pathspec.split(':');
+               if(pathes.count()!=3){
+                       qFatal("Pathspec %s is invalid - expecting <sourcePath>:<resourcePath>:<resourceFileName>", pathspec.toLatin1().data());
+                       return 1;
+               }
+               if(!pathes[2].endsWith(".qrc")){
+                       qFatal("Pathspec %s is invalid - resource file name must end in .qrc", pathspec.toLatin1().data());
+                       return 1;
+               }
+               QFile out(app.applicationDirPath()+"/../../woc/"+pathes[2]);
+               if(!out.open(QIODevice::WriteOnly|QIODevice::Truncate)){
+                       qFatal("Unable to create %s - giving up.", pathes[2].toLatin1().data());
+                       return 1;
+               }
+               out.write(PROLOG);
+               writeOut(out,pathes[0],pathes[1]);
+               out.write(EPILOG);
+               out.close();
+       }
+       return 0;
+}
diff --git a/woc/qrcgen/qrcgen.pro b/woc/qrcgen/qrcgen.pro
new file mode 100644 (file)
index 0000000..80f57fd
--- /dev/null
@@ -0,0 +1,7 @@
+TEMPLATE = app
+TARGET = qrcgen
+SOURCES += qrcgen.cpp
+DESTDIR = ../qrcgen
+QT -= gui
+CONFIG += console
+CONFIG -= app_bundle
index 5194b7d..88fdab1 100644 (file)
@@ -17,24 +17,32 @@ The Qt back-end is in the "qt" directory with WocQtOut, WocQtClientOut, and WocQ
 
 The PHP back-end is in the "php" directory with WocPHPOut, WocPHPClientOut, and WocPHPServerOut as the main output classes.
 
+The generic pattern based back-end is in the "generic" directory with default patterns in the "pattern directory.
 */
 
 #include <QCoreApplication>
 #include <QStringList>
+#include <QDebug>
 
 #include "processor.h"
+#include "genproc.h"
 
 int main(int argc,char**argv)
 {
        QCoreApplication app(argc,argv);
+       //Initializations
+       InitializeGeneric();
        //get arguments
        QStringList args=app.arguments();
        args.removeFirst();
        //process files
        WocProcessor proc;
-       for(int i=0;i<args.size();i++)
-               if(!proc.processFile(args[i])){
-                       qDebug("aborting scan.");
+       for(QString arg:args)
+               if(arg.startsWith("-pattern="))
+                       InitializeGeneric(arg.mid(9));
+               else
+               if(!proc.processFile(arg)){
+                       qDebug()<<"Error: invalid argument"<<arg<<"- aborting scan.";
                        return 1;
                }
        //call finalizer
@@ -42,4 +50,4 @@ int main(int argc,char**argv)
        qDebug("done.");
        //return success
        return 0;
-}
\ No newline at end of file
+}
index aac869e..9f08a5f 100644 (file)
@@ -9,10 +9,11 @@ CONFIG+=console
 CONFIG-=app_bundle
 
 CONFIG(prewoc, prewoc|woc){
-       DEFINES += NO_PACK_VERSION_H
+       DEFINES += NO_PACK_VERSION_H COMPILE_PREWOC
        TARGET = ../woc/prewoc
        MYTMPDIR = .ptmp
 }else{
+       DEFINES += COMPILE_WOC
        TARGET = ../woc/woc
        MYTMPDIR = .ctmp
 }
@@ -26,20 +27,25 @@ RCC_DIR = $$MYTMPDIR
 
 SOURCES+= \
        woc.cpp \
-       htmlout.cpp \
        mfile.cpp \
        domquery.cpp
 HEADERS+= \
-       htmlout.h \
        mfile.h \
        domquery.h
 
 include(proc/proc.pri)
-include(php/php.pri)
 include(qt/qt.pri)
-include(soap/soap.pri)
+include(generic/generic.pri)
+CONFIG(prewoc, prewoc|woc){
+}else{
+       SOURCES += htmlout.cpp
+       HEADERS += htmlout.h
+       include(php/php.pri)
+       include(soap/soap.pri)
+       RESOURCES += tclbase.qrc
+}
 
-gcc { QMAKE_CXXFLAGS += -std=c++11 }
+CONFIG += c++11
 
 INCLUDEPATH += . ../vinfo ../qtbase/include