summaryrefslogtreecommitdiff
path: root/noncore/tools/calc2/binary
Side-by-side diff
Diffstat (limited to 'noncore/tools/calc2/binary') (more/less context) (show whitespace changes)
-rw-r--r--noncore/tools/calc2/binary/Makefile146
-rw-r--r--noncore/tools/calc2/binary/README1
-rw-r--r--noncore/tools/calc2/binary/binary.pro16
-rw-r--r--noncore/tools/calc2/binary/binary.ui177
-rw-r--r--noncore/tools/calc2/binary/binaryfactory.cpp51
-rw-r--r--noncore/tools/calc2/binary/binaryfactory.h46
-rw-r--r--noncore/tools/calc2/binary/binaryimpl.cpp110
-rw-r--r--noncore/tools/calc2/binary/binaryimpl.h50
8 files changed, 597 insertions, 0 deletions
diff --git a/noncore/tools/calc2/binary/Makefile b/noncore/tools/calc2/binary/Makefile
new file mode 100644
index 0000000..93cc0d5
--- a/dev/null
+++ b/noncore/tools/calc2/binary/Makefile
@@ -0,0 +1,146 @@
+#############################################################################
+# Makefile for building libbinary.so.1.0.0
+# Generated by tmake at 12:03, 2001/11/22
+# Project: binary
+# Template: lib
+#############################################################################
+
+####### Compiler, tools and options
+
+CC = gcc
+CXX = g++
+CFLAGS = -pipe -Wall -W -O2 -fPIC -DNO_DEBUG
+CXXFLAGS= -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -fPIC -DNO_DEBUG
+INCPATH = -I$(QPEDIR)/include -I$(QPEDIR)/calc2 -I$(QTDIR)/include
+LINK = gcc
+LFLAGS = -shared -Wl,-soname,libbinary.so.1
+LIBS = $(SUBLIBS) -L$(QTDIR)/lib -lqte
+AR = ar cqs
+RANLIB =
+MOC = $(QTDIR)/bin/moc
+UIC = $(QTDIR)/bin/uic
+
+TAR = tar -cf
+GZIP = gzip -9f
+
+####### Files
+
+HEADERS = binaryimpl.h \
+ binaryfactory.h
+SOURCES = binaryimpl.cpp \
+ binaryfactory.cpp
+OBJECTS = binaryimpl.o \
+ binaryfactory.o \
+ binary.o
+INTERFACES = binary.ui
+UICDECLS = binary.h
+UICIMPLS = binary.cpp
+SRCMOC = moc_binaryimpl.cpp \
+ moc_binary.cpp
+OBJMOC = moc_binaryimpl.o \
+ moc_binary.o
+DIST =
+TARGET = libbinary.so.1.0.0
+TARGETA = $(QPEDIR)/plugins/calculator/libbinary.a
+TARGETD = libbinary.so.1.0.0
+TARGET0 = libbinary.so
+TARGET1 = libbinary.so.1
+TARGET2 = libbinary.so.1.0
+INTERFACE_DECL_PATH = .
+
+####### Implicit rules
+
+.SUFFIXES: .cpp .cxx .cc .C .c
+
+.cpp.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.cxx.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.cc.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.C.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.c.o:
+ $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
+
+####### Build rules
+
+
+all: $(QPEDIR)/plugins/calculator/libbinary.so.1.0.0
+
+$(QPEDIR)/plugins/calculator/libbinary.so.1.0.0: $(OBJECTS) $(OBJMOC) $(SUBLIBS)
+ -rm -f $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2)
+ $(LINK) $(LFLAGS) -o $(TARGETD) $(OBJECTS) $(OBJMOC) $(LIBS)
+ -ln -s $(TARGET) $(TARGET0)
+ -ln -s $(TARGET) $(TARGET1)
+ -ln -s $(TARGET) $(TARGET2)
+ -rm -f $(QPEDIR)/plugins/calculator/$(TARGET)
+ -rm -f $(QPEDIR)/plugins/calculator/$(TARGET0)
+ -rm -f $(QPEDIR)/plugins/calculator/$(TARGET1)
+ -rm -f $(QPEDIR)/plugins/calculator/$(TARGET2)
+ -mv $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) $(QPEDIR)/plugins/calculator/
+
+staticlib: $(TARGETA)
+
+$(TARGETA): $(UICDECLS) $(OBJECTS) $(OBJMOC)
+ -rm -f $(TARGETA)
+ $(AR) $(TARGETA) $(OBJECTS) $(OBJMOC)
+
+moc: $(SRCMOC)
+
+tmake:
+ tmake binary.pro
+
+dist:
+ $(TAR) binary.tar binary.pro $(SOURCES) $(HEADERS) $(INTERFACES) $(DIST)
+ $(GZIP) binary.tar
+
+clean:
+ -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) $(TARGET)
+ -rm -f $(TARGET0) $(TARGET1) $(TARGET2) $(TARGETA)
+ -rm -f *~ core
+
+####### Sub-libraries
+
+
+###### Combined headers
+
+
+####### Compile
+
+binaryimpl.o: binaryimpl.cpp \
+ binaryimpl.h \
+ binary.h
+
+binaryfactory.o: binaryfactory.cpp \
+ binaryfactory.h \
+ binaryimpl.h \
+ binary.h
+
+binary.h: binary.ui
+ $(UIC) binary.ui -o $(INTERFACE_DECL_PATH)/binary.h
+
+binary.cpp: binary.ui
+ $(UIC) binary.ui -i binary.h -o binary.cpp
+
+binary.o: binary.cpp \
+ binary.h \
+ binary.ui
+
+moc_binaryimpl.o: moc_binaryimpl.cpp \
+ binaryimpl.h \
+ binary.h
+
+moc_binary.o: moc_binary.cpp \
+ binary.h
+
+moc_binaryimpl.cpp: binaryimpl.h
+ $(MOC) binaryimpl.h -o moc_binaryimpl.cpp
+
+moc_binary.cpp: binary.h
+ $(MOC) binary.h -o moc_binary.cpp
+
diff --git a/noncore/tools/calc2/binary/README b/noncore/tools/calc2/binary/README
new file mode 100644
index 0000000..4937038
--- a/dev/null
+++ b/noncore/tools/calc2/binary/README
@@ -0,0 +1 @@
+A binary interface with bitwise operations
diff --git a/noncore/tools/calc2/binary/binary.pro b/noncore/tools/calc2/binary/binary.pro
new file mode 100644
index 0000000..01ba6a4
--- a/dev/null
+++ b/noncore/tools/calc2/binary/binary.pro
@@ -0,0 +1,16 @@
+TEMPLATE = lib
+CONFIG -= moc
+CONFIG += qt release
+
+# Input
+INTERFACES += binary.ui
+HEADERS = binaryimpl.h \
+ binaryfactory.h
+SOURCES = binaryimpl.cpp \
+ binaryfactory.cpp
+
+INCLUDEPATH += $(QPEDIR)/include \
+ $(QPEDIR)/calc2
+DEPENDPATH += $(QPEDIR)/include
+
+DESTDIR = $(QPEDIR)/plugins/calculator
diff --git a/noncore/tools/calc2/binary/binary.ui b/noncore/tools/calc2/binary/binary.ui
new file mode 100644
index 0000000..26064d1
--- a/dev/null
+++ b/noncore/tools/calc2/binary/binary.ui
@@ -0,0 +1,177 @@
+<!DOCTYPE UI><UI>
+<class>FormBinary</class>
+<widget>
+ <class>QWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>FormBinary</cstring>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>332</width>
+ <height>114</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>caption</name>
+ <string>Binary</string>
+ </property>
+ <grid>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>0</number>
+ </property>
+ <widget row="1" column="0" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PB0</cstring>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>0</string>
+ </property>
+ </widget>
+ <widget row="1" column="1" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PB1</cstring>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>1</string>
+ </property>
+ </widget>
+ <widget row="0" column="0" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PBAnd</cstring>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>AND</string>
+ </property>
+ </widget>
+ <widget row="0" column="1" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PBOr</cstring>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>OR</string>
+ </property>
+ </widget>
+ <widget row="0" column="2" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PBNot</cstring>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>NOT</string>
+ </property>
+ </widget>
+ <widget row="1" column="2" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PBSHL</cstring>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>&lt;-</string>
+ </property>
+ </widget>
+ <widget row="0" column="3" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PBXor</cstring>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>XOR</string>
+ </property>
+ </widget>
+ <widget row="1" column="3" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PBSHR</cstring>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>-&gt;</string>
+ </property>
+ </widget>
+ </grid>
+</widget>
+</UI>
diff --git a/noncore/tools/calc2/binary/binaryfactory.cpp b/noncore/tools/calc2/binary/binaryfactory.cpp
new file mode 100644
index 0000000..110334f
--- a/dev/null
+++ b/noncore/tools/calc2/binary/binaryfactory.cpp
@@ -0,0 +1,51 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include "binaryfactory.h"
+#include "binaryimpl.h"
+#include <engine.h>
+
+QWidget *BinaryInterface::getPlugin ( Engine *e, QWidget *parent ) {
+ if ( !input )
+ input = new FormBinaryImpl ( e, parent );
+ return input;
+}
+
+#ifndef QT_NO_COMPONENT
+QRESULT BinaryInterface::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
+{
+ *iface = 0;
+ if ( uuid == IID_QUnknown )
+ *iface = this;
+ else if ( uuid == IID_Calc )
+ *iface = this;
+
+ if ( *iface )
+ (*iface)->addRef();
+ return QS_OK;
+}
+
+Q_EXPORT_INTERFACE()
+{
+ Q_CREATE_INSTANCE( BinaryInterface )
+}
+#endif
diff --git a/noncore/tools/calc2/binary/binaryfactory.h b/noncore/tools/calc2/binary/binaryfactory.h
new file mode 100644
index 0000000..e015384
--- a/dev/null
+++ b/noncore/tools/calc2/binary/binaryfactory.h
@@ -0,0 +1,46 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#ifndef BINARYIMPL_H
+#define BINARYIMPL_H
+
+#include "binaryimpl.h"
+#include <plugininterface.h>
+#include <engine.h>
+
+class BinaryInterface : public CalcInterface
+{
+public:
+ BinaryInterface(){input = 0;};
+ virtual ~BinaryInterface(){};
+
+#ifndef QT_NO_COMPONENT
+ QRESULT queryInterface( const QUuid&, QUnknownInterface** );
+ Q_REFCOUNT
+#endif
+
+ QWidget *getPlugin( Engine *, QWidget *parent );
+
+private:
+ FormBinaryImpl *input;
+ ulong ref;
+};
+
+#endif
diff --git a/noncore/tools/calc2/binary/binaryimpl.cpp b/noncore/tools/calc2/binary/binaryimpl.cpp
new file mode 100644
index 0000000..ffc56ad
--- a/dev/null
+++ b/noncore/tools/calc2/binary/binaryimpl.cpp
@@ -0,0 +1,110 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include "binaryimpl.h"
+#include <instruction.h>
+
+class iXOR : public Instruction {
+public:
+ iXOR():Instruction(){};
+ ~iXOR(){};
+ Data eval(Data num) {
+ Data result;
+ result.i = num.i ^ acc.i;
+ return result;
+ };
+};
+class iAND : public Instruction {
+public:
+ iAND():Instruction(){};
+ ~iAND(){};
+ Data eval(Data num) {
+ Data result;
+ result.i = num.i & acc.i;
+ return result;
+ };
+};
+class iNOT : public Instruction {
+public:
+ iNOT():Instruction(){};
+ ~iNOT(){};
+ Data eval(Data num) {
+ Data result;
+ result.i = ~ num.i;
+ return result;
+ };
+};
+class iOR : public Instruction {
+public:
+ iOR():Instruction(){};
+ ~iOR(){};
+ Data eval(Data num) {
+ Data result;
+ result.i = num.i | acc.i;
+ return result;
+ };
+};
+class iLSH : public Instruction {
+public:
+ iLSH():Instruction(){};
+ ~iLSH(){};
+ Data eval(Data num) {
+ Data result;
+ result.i = num.i << 1;
+ return result;
+ };
+};
+class iRSH : public Instruction {
+public:
+ iRSH():Instruction(){};
+ ~iRSH(){};
+ Data eval(Data num) {
+ Data result;
+ result.i = num.i >> 1;
+ return result;
+ };
+};
+
+void FormBinaryImpl::val0Clicked() {
+ engine->pushValue('0');
+}
+
+void FormBinaryImpl::val1Clicked() {
+ engine->pushValue('1');
+}
+
+void FormBinaryImpl::XORClicked() {
+ engine->pushInstruction(new iXOR());
+}
+void FormBinaryImpl::ANDClicked() {
+ engine->pushInstruction(new iAND());
+}
+void FormBinaryImpl::NOTClicked() {
+ engine->immediateInstruction(new iNOT());
+}
+void FormBinaryImpl::ORClicked() {
+ engine->pushInstruction(new iOR());
+}
+void FormBinaryImpl::LSHClicked() {
+ engine->immediateInstruction(new iLSH());
+}
+void FormBinaryImpl::RSHClicked() {
+ engine->immediateInstruction(new iRSH());
+}
diff --git a/noncore/tools/calc2/binary/binaryimpl.h b/noncore/tools/calc2/binary/binaryimpl.h
new file mode 100644
index 0000000..bf9e3a7
--- a/dev/null
+++ b/noncore/tools/calc2/binary/binaryimpl.h
@@ -0,0 +1,50 @@
+/**********************************************************************
+** Copyright (C) 2000 Trolltech AS. All rights reserved.
+**
+** This file is part of Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+#ifndef FORMBINARYINPUTIMPL
+#define FORMBINARYINPUTIMPL
+
+#include "binary.h"
+#include <engine.h>
+
+class FormBinaryImpl : public FormBinary {
+Q_OBJECT
+public:
+ FormBinaryImpl(Engine *e,QWidget *p) : FormBinary (p,"Binary") {
+ engine = e;
+ engine->setRepresentation(rBin);
+ };
+ ~FormBinaryImpl(){};
+private:
+ Engine *engine;
+
+private slots:
+ void val0Clicked();
+ void val1Clicked();
+
+ void XORClicked();
+ void ANDClicked();
+ void NOTClicked();
+ void ORClicked();
+
+ void LSHClicked();
+ void RSHClicked();
+};
+
+#endif