From 15318cad33835e4e2dc620d033e43cd930676cdd Mon Sep 17 00:00:00 2001 From: kergoth Date: Fri, 25 Jan 2002 22:14:26 +0000 Subject: Initial revision --- (limited to 'noncore/tools/calc2/binary') 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 @@ + +FormBinary + + QWidget + + name + FormBinary + + + geometry + + 0 + 0 + 332 + 114 + + + + caption + Binary + + + + margin + 0 + + + spacing + 0 + + + QPushButton + + name + PB0 + + + maximumSize + + 80 + 80 + + + + text + 0 + + + + QPushButton + + name + PB1 + + + maximumSize + + 80 + 80 + + + + text + 1 + + + + QPushButton + + name + PBAnd + + + maximumSize + + 80 + 80 + + + + text + AND + + + + QPushButton + + name + PBOr + + + maximumSize + + 80 + 80 + + + + text + OR + + + + QPushButton + + name + PBNot + + + maximumSize + + 80 + 80 + + + + text + NOT + + + + QPushButton + + name + PBSHL + + + maximumSize + + 80 + 80 + + + + text + <- + + + + QPushButton + + name + PBXor + + + maximumSize + + 80 + 80 + + + + text + XOR + + + + QPushButton + + name + PBSHR + + + maximumSize + + 80 + 80 + + + + text + -> + + + + + 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 + +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 +#include + +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 + +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 + +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 -- cgit v0.9.0.2