Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=fvbe.git;a=commitdiff;h=624565b1e1a94e0ce08e4fe69230a475181e5221
commit 624565b1e1a94e0ce08e4fe69230a475181e5221 Author: James Buren <[email protected]> Date: Wed Oct 22 15:15:07 2014 -0500 fvbe: remove source code for c++ draft diff --git a/src-new/SConstruct b/src-new/SConstruct deleted file mode 100644 index ecaf9d1..0000000 --- a/src-new/SConstruct +++ /dev/null @@ -1,39 +0,0 @@ -from os import environ - -env = Environment() - -# Set default optimizations if environment doesn't specify any. -if not 'CXXFLAGS' in environ: - env.Append(CXXFLAGS = [ '-O2' ]) -else: - env.Append(CXXFLAGS = environ['CXXFLAGS']) - -# Inherit linker flags from environment. -if 'LDFLAGS' in environ: - env.Append(LINKFLAGS = environ['LDFLAGS']) - -# Enable most warnings -env.Append(CXXFLAGS = [ '-Wall', '-Wextra' ]) - -# Enable debug symbols or disable debugging code. -debug = int(ARGUMENTS.get('debug', 1)) -if debug: - env.Append(CXXFLAGS = [ '-g' ]) -else: - env.Append(CXXFLAGS = [ '-DNDEBUG' ]) - -# Disable the prefix / suffix for shared libraries. -env['SHLIBPREFIX'] = '' -env['SHLIBSUFFIX'] = '' - -# libfvbe build instructions -ui_o = env.SharedObject('ui.o', 'ui.cpp') -libfvbe = env.SharedLibrary('libfvbe.so', [ ui_o ]) - -# ui_newt build instructions -ui_newt_o = env.SharedObject('ui_newt.o', 'ui_newt.cpp') -ui_newt = env.SharedLibrary('ui_newt.so', [ ui_newt_o, libfvbe ], LIBS = '-lnewt') - -# main build instructions -main_o = env.Object('main.o', 'main.cpp') -main = env.Program('main', [ main_o, libfvbe ], LIBS = '-ldl') diff --git a/src-new/main.cpp b/src-new/main.cpp deleted file mode 100644 index 14353b2..0000000 --- a/src-new/main.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include <iostream> -#include <dlfcn.h> -#include "main.hpp" - -static void *ui_handle = NULL; -static ui_new_t ui_new = NULL; -static ui_delete_t ui_delete = NULL; -UI *ui = NULL; - -static bool ui_load(const std::string &filename) -{ - if( - (ui_handle = dlopen(filename.c_str(), RTLD_NOW)) == NULL || - (ui_new = (ui_new_t) dlsym(ui_handle, "ui_new")) == NULL || - (ui_delete = (ui_delete_t) dlsym(ui_handle, "ui_delete")) == NULL - ) - { - std::cerr << "Failed to open UI: " << dlerror() << std::endl; - return false; - } - - return true; -} - -int main(int argc, char **argv) -{ - if(!ui_load("./ui_newt.so")) - { - return 1; - } - - ui = ui_new(); - - ui->main(argc, argv); - - ui_delete(ui); - - dlclose(ui_handle); - - return 0; -} diff --git a/src-new/main.hpp b/src-new/main.hpp deleted file mode 100644 index d055c1b..0000000 --- a/src-new/main.hpp +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include "ui.hpp" - -typedef UI *(*ui_new_t) (); - -typedef void (*ui_delete_t) (UI *); - -extern UI *ui; diff --git a/src-new/ui.cpp b/src-new/ui.cpp deleted file mode 100644 index 26020ed..0000000 --- a/src-new/ui.cpp +++ /dev/null @@ -1,132 +0,0 @@ -#include <iostream> -#include <csignal> -#include <cstring> -#include <cstdlib> -#include <unistd.h> -#include "ui.hpp" - -// Widget Class Start -const unsigned char Widget::ALIGN_LEFT = (1 << 0); -const unsigned char Widget::ALIGN_RIGHT = (1 << 1); -const unsigned char Widget::ALIGN_TOP = (1 << 2); -const unsigned char Widget::ALIGN_BOTTOM = (1 << 3); - -const unsigned char Widget::EXPAND_HORIZONTAL = (1 << 0); -const unsigned char Widget::EXPAND_VERTICAL = (1 << 1); - -Widget::~Widget() -{ -} -// Widget Class End - -// Label Class Start -Label::~Label() -{ -} -// Label Class End - -// TextBox Class Start -TextBox::~TextBox() -{ -} -// TextBox Class End - -// EntryBox Class Start -EntryBox::~EntryBox() -{ -} -// EntryBox Class End - -// CheckBox Class Start -CheckBox::~CheckBox() -{ -} -// CheckBox Class End - -// Button Class Start -Button::~Button() -{ -} -// Button Class End - -// ProgressBar Class Start -ProgressBar::~ProgressBar() -{ -} -// ProgressBar Class End - -// UI Class Start -UI::~UI() -{ -} - -void UI::printError(const std::string &line) -{ - std::cerr << line << std::endl; -} - -bool UI::checkTTY(int fd) -{ - std::string fd_name; - - switch(fd) - { - case STDIN_FILENO: - fd_name = "stdin"; - break; - - case STDOUT_FILENO: - fd_name = "stdout"; - break; - - case STDERR_FILENO: - fd_name = "stderr"; - break; - } - - if(!isatty(fd)) - { - printError(fd_name + " is not a tty."); - return false; - } - - return true; -} - -bool UI::setSignalInterrupt(int sig, bool interrupt) -{ - struct sigaction sig_handler; - - memset(&sig_handler, 0, sizeof(struct sigaction)); - - // Get the old signal handler. - if(sigaction(sig, NULL, &sig_handler) == -1) - { - printError("Failed to get old signal handler."); - return false; - } - - if(interrupt && (sig_handler.sa_flags & SA_RESTART)) - { - sig_handler.sa_flags ^= SA_RESTART; - } - else if(!interrupt && !(sig_handler.sa_flags & SA_RESTART)) - { - sig_handler.sa_flags |= SA_RESTART; - } - - // Set the new signal handler. - if(sigaction(sig, &sig_handler, NULL) == -1) - { - printError("Failed to set new signal handler."); - return false; - } - - return true; -} - -int UI::main(int /*argc*/, char ** /*argv*/) -{ - return EXIT_SUCCESS; -} -// UI Class End diff --git a/src-new/ui.hpp b/src-new/ui.hpp deleted file mode 100644 index 73f0f8b..0000000 --- a/src-new/ui.hpp +++ /dev/null @@ -1,63 +0,0 @@ -#pragma once - -#include <string> - -class Widget -{ - public: - static const unsigned char ALIGN_LEFT; - static const unsigned char ALIGN_RIGHT; - static const unsigned char ALIGN_TOP; - static const unsigned char ALIGN_BOTTOM; - - static const unsigned char EXPAND_HORIZONTAL; - static const unsigned char EXPAND_VERTICAL; - - virtual ~Widget(); -}; - -class Label : public Widget -{ - public: - virtual ~Label(); -}; - -class TextBox : public Widget -{ - public: - virtual ~TextBox(); -}; - -class EntryBox : public Widget -{ - public: - virtual ~EntryBox(); -}; - -class CheckBox : public Widget -{ - public: - virtual ~CheckBox(); -}; - -class Button : public Widget -{ - public: - virtual ~Button(); -}; - -class ProgressBar : public Widget -{ - public: - virtual ~ProgressBar(); -}; - -class UI -{ - public: - virtual ~UI(); - void printError(const std::string &line); - bool checkTTY(int fd); - bool setSignalInterrupt(int sig, bool interrupt); - virtual int main(int argc, char **argv); -}; diff --git a/src-new/ui_newt.cpp b/src-new/ui_newt.cpp deleted file mode 100644 index 7b31858..0000000 --- a/src-new/ui_newt.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include <iostream> -#include <cstdlib> -#include <csignal> -#include <unistd.h> -#include "main.hpp" -#include "ui_newt.hpp" - -int UINewt::main(int /*argc*/, char ** /*argv*/) -{ - int code = EXIT_FAILURE; - - // Check that the standard file streams are connected to a TTY. - if(!checkTTY(STDIN_FILENO) || !checkTTY(STDOUT_FILENO) || !checkTTY(STDERR_FILENO)) - { - return code; - } - - if(newtInit() != 0) - { - printError("Could not initialize the NEWT user interface."); - return code; - } - - if(!setSignalInterrupt(SIGWINCH, false)) - { - printError("Failed to stop SIGWINCH from interrupting system calls."); - newtFinished(); - return code; - } - - newtCls(); - - newtFinished(); - - return code; -} - -extern "C" UI *ui_new() -{ - UINewt *ui = new UINewt(); - - return dynamic_cast <UI *> (ui); -} - -extern "C" void ui_delete(UI *p) -{ - UINewt *ui = dynamic_cast <UINewt *> (p); - - delete ui; -} - -#ifndef NDEBUG -static void test_shared_exports() __attribute__((unused)); - -static void test_shared_exports() -{ - // Force compiler to validate the exported C functions. - __attribute__((unused)) ui_new_t a = ui_new; - __attribute__((unused)) ui_delete_t b = ui_delete; -} -#endif diff --git a/src-new/ui_newt.hpp b/src-new/ui_newt.hpp deleted file mode 100644 index c3240bb..0000000 --- a/src-new/ui_newt.hpp +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -#include <newt.h> -#include "ui.hpp" - -class UINewt : public UI -{ - public: - int main(int argc, char **argv); -}; _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
