From 421dee68819a490be5c8a76f7cb8d75e656f6a0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Mon, 6 Jul 2015 11:54:33 +0100 Subject: [PATCH] register init (again) --- CXX/yapdb.cpp | 83 ------------------------------ console/Qt/untitled/main.cpp | 11 ++++ console/Qt/untitled/mainwindow.cpp | 14 +++++ console/Qt/untitled/mainwindow.h | 22 ++++++++ console/Qt/untitled/mainwindow.ui | 24 +++++++++ console/Qt/untitled/untitled.pro | 20 +++++++ os/x.cpp | 7 +++ os/x.h | 11 ++++ 8 files changed, 109 insertions(+), 83 deletions(-) delete mode 100644 CXX/yapdb.cpp create mode 100644 console/Qt/untitled/main.cpp create mode 100644 console/Qt/untitled/mainwindow.cpp create mode 100644 console/Qt/untitled/mainwindow.h create mode 100644 console/Qt/untitled/mainwindow.ui create mode 100644 console/Qt/untitled/untitled.pro create mode 100644 os/x.cpp create mode 100644 os/x.h diff --git a/CXX/yapdb.cpp b/CXX/yapdb.cpp deleted file mode 100644 index 9f8c56db5..000000000 --- a/CXX/yapdb.cpp +++ /dev/null @@ -1,83 +0,0 @@ - -#define YAP_CPP_INTERFACE 1 - -#include "yapi.hh" -#include "SWI-Stream.h" - - - -YAPPredicate::YAPPredicate(const char *s, Term &tout, yhandle_t &vnames) throw (int) { - CACHE_REGS - BACKUP_MACHINE_REGS(); - yhandle_t yvnames = Yap_InitSlot(); - Term tout = Yap_StringToTerm(s, strlen(s), Yap_DefaultEncoding(), yvnames, 1200); - if (tout == 0L) - throw YAPError::YAP_SYNTAX_ERROR; - ap = getPred( tout ); - RECOVER_MACHINE_REGS(); -} - -YAPPredicate::YAPPredicate(YAPAtom at) { - CACHE_REGS - ap = RepPredProp(PredPropByAtom(at.a,CurrentModule)); -} - -YAPPredicate::YAPPredicate(YAPAtom at, arity_t arity) { - CACHE_REGS - if (arity) { - Functor f = Yap_MkFunctor(at.a, arity); - ap = RepPredProp(PredPropByFunc(f,CurrentModule)); - } else {LogUpdate - ap = RepPredProp(PredPropByAtom(at.a,CurrentModule)); - } -} - -/// auxiliary routine to find a predicate in the current module. -PredEntry *YAPPredicate::getPred( Term t, Term* &outp ) { - CACHE_REGS - Term m = CurrentModule ; - t = Yap_StripModule(t, &m); - if (IsVarTerm(t) || IsNumTerm(t)) { - ap = (PredEntry *)NULL; - outp = (Term *)NULL; - } - if (IsAtomTerm(t)) { - ap = RepPredProp(PredPropByAtom(AtomOfTerm(t), m)); - if (outp) outp = (Term *)NULL; - } else if (IsPairTerm(t)) { - ap = RepPredProp(PredPropByFunc(FunctorCsult, PROLOG_MODULE)); - outp = HR; - HR[0] = RepPair(t)[0]; - HR[1] = m; - HR+=2; - } else { - Functor f = FunctorOfTerm(t); - if (IsExtensionFunctor(f)) { - ap = (PredEntry *)NULL; - outp = (Term *)NULL; - } else { - ap = RepPredProp(PredPropByFunc(f, m)); - outp = RepAppl(t)+1; - } - } - { REGS_LOG( "done H= %p, outp=%p", HR, outp) ; } - return ap; -} - -YAPPredicate::YAPPredicate(YAPFunctor f) { - CACHE_REGS - ap = RepPredProp(PredPropByFunc(f.f,CurrentModule)); -} - -int YAPPredicate::call(YAPTerm t[]) -{ - YAPQuery q = YAPQuery(*this, t); - int ret; - - BACKUP_MACHINE_REGS(); - ret = q.next(); - q.cut(); - q.close(); - RECOVER_MACHINE_REGS(); - return ret; -} diff --git a/console/Qt/untitled/main.cpp b/console/Qt/untitled/main.cpp new file mode 100644 index 000000000..07eec7b81 --- /dev/null +++ b/console/Qt/untitled/main.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/console/Qt/untitled/mainwindow.cpp b/console/Qt/untitled/mainwindow.cpp new file mode 100644 index 000000000..a74816912 --- /dev/null +++ b/console/Qt/untitled/mainwindow.cpp @@ -0,0 +1,14 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} diff --git a/console/Qt/untitled/mainwindow.h b/console/Qt/untitled/mainwindow.h new file mode 100644 index 000000000..a845ec421 --- /dev/null +++ b/console/Qt/untitled/mainwindow.h @@ -0,0 +1,22 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +namespace Ui { + class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/console/Qt/untitled/mainwindow.ui b/console/Qt/untitled/mainwindow.ui new file mode 100644 index 000000000..6050363fa --- /dev/null +++ b/console/Qt/untitled/mainwindow.ui @@ -0,0 +1,24 @@ + + MainWindow + + + + 0 + 0 + 400 + 300 + + + + MainWindow + + + + + + + + + + + diff --git a/console/Qt/untitled/untitled.pro b/console/Qt/untitled/untitled.pro new file mode 100644 index 000000000..48416093a --- /dev/null +++ b/console/Qt/untitled/untitled.pro @@ -0,0 +1,20 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2015-06-27T18:26:00 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = untitled +TEMPLATE = app + + +SOURCES += main.cpp\ + mainwindow.cpp + +HEADERS += mainwindow.h + +FORMS += mainwindow.ui diff --git a/os/x.cpp b/os/x.cpp new file mode 100644 index 000000000..969a38164 --- /dev/null +++ b/os/x.cpp @@ -0,0 +1,7 @@ +#include "x.h" + +x::x() +{ + +} + diff --git a/os/x.h b/os/x.h new file mode 100644 index 000000000..257f344f6 --- /dev/null +++ b/os/x.h @@ -0,0 +1,11 @@ +#ifndef X_H +#define X_H + + +class x +{ +public: + x(); +}; + +#endif // X_H