summaryrefslogtreecommitdiffstats
path: root/src/devices/mem24/xml
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 18:42:24 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 18:42:24 +0000
commitf508189682b6fba62e08feeb1596f682bad5fff9 (patch)
tree28aeb0e6c19386c385c1ce5edf8a92c1bca15281 /src/devices/mem24/xml
downloadpiklab-f508189682b6fba62e08feeb1596f682bad5fff9.tar.gz
piklab-f508189682b6fba62e08feeb1596f682bad5fff9.zip
Added KDE3 version of PikLab
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/piklab@1095639 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/devices/mem24/xml')
-rw-r--r--src/devices/mem24/xml/Makefile.am12
-rw-r--r--src/devices/mem24/xml/mem24_xml_to_data.cpp60
-rw-r--r--src/devices/mem24/xml/xml.pro13
3 files changed, 85 insertions, 0 deletions
diff --git a/src/devices/mem24/xml/Makefile.am b/src/devices/mem24/xml/Makefile.am
new file mode 100644
index 0000000..88a4305
--- /dev/null
+++ b/src/devices/mem24/xml/Makefile.am
@@ -0,0 +1,12 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_PROGRAMS = mem24_xml_to_data
+
+mem24_xml_to_data_SOURCES = mem24_xml_to_data.cpp
+mem24_xml_to_data_DEPENDENCIES = $(top_builddir)/src/devices/mem24/base/libmem24base.la \
+ $(top_builddir)/src/xml_to_data/libxmltodata.la $(top_builddir)/src/devices/base/libdevicebase.la \
+ $(top_builddir)/src/common/common/libcommon.la
+mem24_xml_to_data_LDADD = $(top_builddir)/src/devices/mem24/base/libmem24base.la \
+ $(top_builddir)/src/xml_to_data/libxmltodata.la $(top_builddir)/src/devices/base/libdevicebase.la \
+ $(top_builddir)/src/common/common/libcommon.la $(LIB_KDECORE)
diff --git a/src/devices/mem24/xml/mem24_xml_to_data.cpp b/src/devices/mem24/xml/mem24_xml_to_data.cpp
new file mode 100644
index 0000000..734ebca
--- /dev/null
+++ b/src/devices/mem24/xml/mem24_xml_to_data.cpp
@@ -0,0 +1,60 @@
+/***************************************************************************
+ * Copyright (C) 2006-2007 Nicolas Hadacek <hadacek@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#include <qfile.h>
+#include <qtextstream.h>
+
+#include "xml_to_data/device_xml_to_data.h"
+#include "common/common/misc.h"
+#include "devices/mem24/base/mem24.h"
+
+namespace Mem24
+{
+
+class XmlToData : public Device::XmlToData<Data>
+{
+private:
+ virtual uint nbOutputFiles(uint) const { return 1; }
+ virtual bool isIncluded(uint, uint) const { return true; }
+ virtual QString namespaceName() const { return "Mem24"; }
+
+virtual void processDevice(QDomElement device)
+{
+ Device::XmlToDataBase::processDevice(device);
+
+ QDomElement e = findUniqueElement(device, "memory", "name", QString::null);
+ bool ok;
+ data()->_nbBytes = fromHexLabel(e.attribute("size"), &ok);
+ if ( !ok ) qFatal("Missing or invalid size");
+ data()->_nbBlocks = e.attribute("nb_blocks").toUInt(&ok);
+ if ( !ok || data()->_nbBlocks==0 ) qFatal("Missing, zero, or invalid nb_blocks");
+ if ( (data()->_nbBytes % data()->_nbBlocks)!=0 ) qFatal("nb_blocks should divide size");
+ if ( data()->_nbBlocks>8 ) qFatal("nb_blocks is too large (>8)");
+ data()->_nbBytesPage = e.attribute("page_size").toUInt(&ok);
+ if ( !ok || data()->_nbBytesPage==0 ) qFatal("Missing, zero, or invalid page_size");
+ if ( ((data()->_nbBytes/data()->_nbBlocks) % data()->_nbBytesPage)!=0 ) qFatal("page_size should divide size/nb_blocks");
+ QStringList names;
+ names.append(QString::null);
+ checkTagNames(device, "memory", names);
+}
+
+virtual void checkPins(const QMap<QString, uint> &pinLabels) const
+{
+ if ( !pinLabels.contains("VCC") ) qFatal("No VDD pin specified");
+ if ( !pinLabels.contains("VSS") ) qFatal("No VSS pin specified");
+ QMap<QString, uint>::const_iterator it;
+ for (it=pinLabels.begin(); it!=pinLabels.end(); ++it)
+ if ( it.data()!=1 ) qFatal(QString("Duplicated pin %1").arg(it.key()));
+}
+
+}; // class
+
+} // namespace
+
+//-----------------------------------------------------------------------------
+XML_MAIN(Mem24::XmlToData)
diff --git a/src/devices/mem24/xml/xml.pro b/src/devices/mem24/xml/xml.pro
new file mode 100644
index 0000000..9730b29
--- /dev/null
+++ b/src/devices/mem24/xml/xml.pro
@@ -0,0 +1,13 @@
+STOPDIR = ../../../..
+include($${STOPDIR}/app.pro)
+
+TARGET = mem24_xml_to_data
+SOURCES += mem24_xml_to_data.cpp
+LIBS += ../../../devices/mem24/base/libmem24base.a ../../../xml_to_data/libxmltodata.a \
+ ../../../devices/base/libdevicebase.a ../../../common/global/libglobal.a \
+ ../../../common/nokde/libnokde.a ../../../common/common/libcommon.a
+
+unix:QMAKE_POST_LINK = cd ../xml_data && ../xml/mem24_xml_to_data
+unix:QMAKE_CLEAN += ../xml_data/mem24_data.cpp
+win32:QMAKE_POST_LINK = cd ..\xml_data && ..\xml\mem24_xml_to_data.exe
+win32:QMAKE_CLEAN += ..\xml_data\mem24_data.cpp