diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/driver/main.cc | 24 | ||||
-rw-r--r-- | src/gui/debate.cc | 4 | ||||
-rw-r--r-- | src/gui/gui.pro.in | 2 | ||||
-rw-r--r-- | src/include/open-axiom.h | 66 | ||||
-rw-r--r-- | src/lib/cfuns-c.c | 10 | ||||
-rw-r--r-- | src/sman/sman.c | 4 | ||||
-rw-r--r-- | src/utils/command.cc | 101 |
7 files changed, 112 insertions, 99 deletions
diff --git a/src/driver/main.cc b/src/driver/main.cc index b08027a7..686a48f2 100644 --- a/src/driver/main.cc +++ b/src/driver/main.cc @@ -125,27 +125,27 @@ main(int argc, char* argv[]) upgrade_environment(&command); switch (driver) { - case null_driver: + case Driver::null: return 0; /* Bye. */ - case config_driver: + case Driver::config: return print_configuration_info(&command); - case core_driver: - case script_driver: - case compiler_driver: - case translator_driver: - case linker_driver: - case gui_driver: + case Driver::core: + case Driver::script: + case Driver::compiler: + case Driver::translator: + case Driver::linker: + case Driver::gui: oa_setenv("LC_ALL", "C"); setlocale(LC_ALL, ""); return execute_core(&command, driver); - case execute_driver: + case Driver::execute: return oa_spawn(&command.core, - SpawnFlags(spawn_search_path | spawn_replace)); - - case sman_driver: + SpawnFlags::search_path | SpawnFlags::replace); + + case Driver::sman: break; default: diff --git a/src/gui/debate.cc b/src/gui/debate.cc index 68d4ee3f..b09d80a5 100644 --- a/src/gui/debate.cc +++ b/src/gui/debate.cc @@ -43,9 +43,9 @@ namespace OpenAxiom { args << "--" << "--role=server"; for (int i = 1; i < cmd.core.argc; ++i) args << cmd.core.argv[i]; - conv->oracle()->start(make_path_for(cmd.root_dir, core_driver), args); + conv->oracle()->start(make_path_for(cmd.root_dir, Driver::core), args); // When invoked in a --role=server mode, OpenAxiom would - // wait to be pinged before displayed a prompt. This is + // wait to be pinged before displaying a prompt. This is // an unfortunate result of a rather awkward hack. conv->submit_query(""); } diff --git a/src/gui/gui.pro.in b/src/gui/gui.pro.in index cf2cce1e..a87715c2 100644 --- a/src/gui/gui.pro.in +++ b/src/gui/gui.pro.in @@ -38,4 +38,4 @@ LIBS += $$OA_LIB ## C++ compiler #QMAKE_CXX = @CXX@ -#QMAKE_CXXFLAGS += @CXXFLAGS@ +QMAKE_CXXFLAGS += -std=c++11 diff --git a/src/include/open-axiom.h b/src/include/open-axiom.h index 0b581a67..925ddc9a 100644 --- a/src/include/open-axiom.h +++ b/src/include/open-axiom.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2007-2011, Gabriel Dos Reis. + Copyright (C) 2007-2013, Gabriel Dos Reis. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -94,9 +94,13 @@ namespace OpenAxiom { typedef void* Handle; #endif + // Data types for labeling positions and counting items. + using Ordinal = size_t; + using Cardinal = size_t; + // Byte order of machine word data. - enum Byteorder { - unknown_endian, little_endian, big_endian + enum class Byteorder { + unknown, little, big }; // Datatype for packaging information necessary tolaunch a process. @@ -107,10 +111,20 @@ namespace OpenAxiom { }; enum SpawnFlags { - spawn_search_path = 0x01, - spawn_replace = 0x02, + search_path = 0x01, + replace = 0x02, }; + constexpr SpawnFlags + operator&(SpawnFlags x, SpawnFlags y) { + return SpawnFlags(int(x) & int(y)); + } + + constexpr SpawnFlags + operator|(SpawnFlags x, SpawnFlags y) { + return SpawnFlags(int(x) | int(y)); + } + // Return the address of the byte array object representation of `t'. template<typename T> @@ -154,33 +168,33 @@ namespace OpenAxiom { // -- Driver -- // ------------ // A list of drivers for OpenAxiom. - enum Driver { - unknown_driver, // unknown driver - null_driver, // do nothing - config_driver, // print out configuration information - sman_driver, // start Superman as master process - gui_driver, // start the GUI interface - core_driver, // start the core system as master process - script_driver, // start the core system in script mode. - compiler_driver, // start the core system in compiler mode. - execute_driver, // Execute a command. - translator_driver, // Start the core system in translator mode. - linker_driver // start the core system in linking mode. + enum class Driver { + unknown, // unknown driver + null, // do nothing + config, // print out configuration information + sman, // start Superman as master process + gui, // start the GUI interface + core, // start the core system as master process + script, // start the core system in script mode. + compiler, // start the core system in compiler mode. + execute, // Execute a command. + translator, // Start the core system in translator mode. + linker // start the core system in linking mode. }; // ------------- // -- Runtime -- // ------------- // A list of runtime support systems for OpenAxiom. - enum Runtime { - unknown_runtime, - gcl_runtime, // GCL-based runtime - sbcl_runtime, // SBCL-based runtime - clisp_runtime, // CLISP-based runtime - ecl_runtime, // ECL-based runtime - clozure_runtime, // Clozure CL-based runtime - bemol_runtime, // Bemol-based runtime - polyml_runtome // Poly/ML abstract machine-based runtime + enum class Runtime { + unknown, // unknown runtime + gcl, // GCL-based runtime + sbcl, // SBCL-based runtime + clisp, // CLISP-based runtime + ecl, // ECL-based runtime + clozure, // Clozure CL-based runtime + bemol, // Bemol-based runtime + polyml // Poly/ML abstract machine-based runtime }; // --------------- diff --git a/src/lib/cfuns-c.c b/src/lib/cfuns-c.c index 1b75219e..e95abbee 100644 --- a/src/lib/cfuns-c.c +++ b/src/lib/cfuns-c.c @@ -749,9 +749,9 @@ OPENAXIOM_C_EXPORT Byteorder oa_get_host_byteorder(void) { #ifdef WORDS_BIGENDIAN - return big_endian; + return Byteorder::big; #else - return little_endian; + return Byteorder::little; #endif } @@ -816,16 +816,16 @@ oa_spawn(Process* proc, SpawnFlags flags) #else proc->id = 0; - if ((flags & spawn_replace) == 0) + if ((flags & SpawnFlags::replace) == 0) proc->id = fork(); if (proc->id == 0) { - if (flags & spawn_search_path) + if (flags & SpawnFlags::search_path) execvp(proc->argv[0], proc->argv); else execv(proc->argv[0], proc->argv); perror(strerror(errno)); /* Don't keep useless clones around. */ - if ((flags & spawn_replace) == 0) + if ((flags & SpawnFlags::replace) == 0) exit(-1); } return proc->id; diff --git a/src/sman/sman.c b/src/sman/sman.c index 1b2a243a..1efe4c5c 100644 --- a/src/sman/sman.c +++ b/src/sman/sman.c @@ -543,9 +543,9 @@ fork_Axiom(Command* cmd) /* Tell the Core that it is being invoked in server mode. */ oa_allocate_process_argv(&cmd->core, 2); - cmd->core.argv[0] = (char*) make_path_for(cmd->root_dir, core_driver); + cmd->core.argv[0] = (char*) make_path_for(cmd->root_dir, Driver::core); cmd->core.argv[1] = (char*) "--role=server"; - execute_core(cmd, core_driver); + execute_core(cmd, Driver::core); } } diff --git a/src/utils/command.cc b/src/utils/command.cc index c7e4ee47..2a8041bb 100644 --- a/src/utils/command.cc +++ b/src/utils/command.cc @@ -153,17 +153,17 @@ static const char* get_driver_subpath(Driver driver) { switch (driver) { - case sman_driver: + case Driver::sman: return OPENAXIOM_SMAN_PATH; - case gui_driver: + case Driver::gui: return OPENAXIOM_GUI_SUBPATH; - case script_driver: - case compiler_driver: - case core_driver: - case translator_driver: - case linker_driver: + case Driver::script: + case Driver::compiler: + case Driver::core: + case Driver::translator: + case Driver::linker: return OPENAXIOM_CORE_PATH; default: @@ -190,22 +190,20 @@ void build_rts_options(Command* command, Driver driver) { switch (driver) { - case config_driver: - case sman_driver: - case gui_driver: - case execute_driver: - case unknown_driver: + case Driver::config: + case Driver::sman: + case Driver::gui: + case Driver::execute: + case Driver::unknown: + case Driver::core: break; - case core_driver: - break; - - case compiler_driver: - case script_driver: - case translator_driver: - case linker_driver: + case Driver::compiler: + case Driver::script: + case Driver::translator: + case Driver::linker: switch (OPENAXIOM_BASE_RTS) { - case gcl_runtime: + case Runtime::gcl: command->rt_args.allocate(3); command->rt_args[0] = (char*) "-batch"; command->rt_args[1] = (char*) "-eval"; @@ -213,7 +211,7 @@ build_rts_options(Command* command, Driver driver) (char*) ("(" OPENAXIOM_LISP_CORE_ENTRY_POINT ")"); break; - case sbcl_runtime: + case Runtime::sbcl: command->rt_args.allocate(6); command->rt_args[0] = (char*) "--noinform"; command->rt_args[1] = (char*) "--end-runtime-options"; @@ -223,19 +221,19 @@ build_rts_options(Command* command, Driver driver) command->rt_args[5] = (char*) "--end-toplevel-options"; break; - case clozure_runtime: + case Runtime::clozure: command->rt_args.allocate(2); command->rt_args[0] = (char*) "--no-init"; command->rt_args[1] = (char*) "--batch"; break; - case clisp_runtime: + case Runtime::clisp: command->rt_args.allocate(2); command->rt_args[0] = (char*) "--quiet"; command->rt_args[1] = (char*) "-norc"; break; - case ecl_runtime: + case Runtime::ecl: command->rt_args.allocate(2); command->rt_args[0] = (char*) "-q"; command->rt_args[1] = (char*) "-norc"; @@ -254,11 +252,11 @@ build_rts_options(Command* command, Driver driver) // Return a description of the driver to invokve by default. static Driver default_driver(bool explicit_no_gui) { if (OPENAXIOM_USE_SMAN) - return sman_driver; + return Driver::sman; else if (OPENAXIOM_USE_GUI and not explicit_no_gui) - return gui_driver; + return Driver::gui; else - return core_driver; + return Driver::core; } @@ -317,12 +315,12 @@ static void print_usage(void) { }; static const DriverMap driver_table[] = { - { "--script", script_driver }, - { "--compile", compiler_driver }, - { "--translate", compiler_driver }, - { "--build-databases", compiler_driver }, - { "--build-initdb", core_driver }, - { "--make", linker_driver }, + { "--script", Driver::script }, + { "--compile", Driver::compiler }, + { "--translate", Driver::compiler }, + { "--build-databases", Driver::compiler }, + { "--build-initdb", Driver::core }, + { "--make", Driver::linker }, }; // Obtain the driver that implement a specific action requested @@ -332,7 +330,7 @@ static void print_usage(void) { for (int i = 0; i < length(driver_table); ++i) if (strcmp(opt, driver_table[i].action) == 0) return driver_table[i].driver; - return unknown_driver; + return Driver::unknown; } /* Determine driver to be used for executing `command'. */ @@ -342,31 +340,31 @@ preprocess_arguments(Command* command, int argc, char** argv) int i; int other = 1; int files = 0; - Driver driver = unknown_driver; + Driver driver = Driver::unknown; bool explicit_no_gui = false; // True if --no-gui explicitly specified. command->root_dir = get_systemdir(argc, argv); for (i = 1; i < argc; ++i) if(strcmp(argv[i], "--no-server") == 0) - driver = core_driver; + driver = Driver::core; else if (strcmp(argv[i], "--server") == 0) - driver = sman_driver; + driver = Driver::sman; else if (strcmp(argv[i], "--gui") == 0) - driver = gui_driver; + driver = Driver::gui; else if (strcmp(argv[i], "--config") == 0) - driver = config_driver; + driver = Driver::config; else if (strcmp(argv[i], "--execute") == 0) { - driver = execute_driver; + driver = Driver::execute; break; } else if (strcmp(argv[i], "--help") == 0) { print_usage(); - driver = null_driver; + driver = Driver::null; break; } else if (strcmp(argv[i], "--version") == 0) { print_version(); - driver = null_driver; + driver = Driver::null; break; } else if (const char* val = is_prefix("--execpath=", argv[i])) { @@ -375,7 +373,8 @@ preprocess_arguments(Command* command, int argc, char** argv) else { /* Apparently we will invoke the Core system; we need to pass on this option. */ - if (const Driver d = option_driver(argv[i])) + const Driver d = option_driver(argv[i]); + if (d != Driver::unknown) driver = d; else { /* Maybe option for the driver. */ @@ -397,7 +396,7 @@ preprocess_arguments(Command* command, int argc, char** argv) } /* Determine argument vector. */ - if (driver == execute_driver) { + if (driver == Driver::execute) { command->core.argc = argc - i - 1; command->core.argv = argv + i + 1; } @@ -406,14 +405,14 @@ preprocess_arguments(Command* command, int argc, char** argv) command->core.argv = argv; } - if (driver != null_driver) { + if (driver != Driver::null) { /* If we have a file but not instructed to compile, assume we are asked to interpret a script. */ if (files > 0) switch (driver) { - case unknown_driver: - case sman_driver: - case gui_driver: + case Driver::unknown: + case Driver::sman: + case Driver::gui: command->core.argc += 1; command->core.argv = (char**) malloc((other + 2) * sizeof(char*)); @@ -421,13 +420,13 @@ preprocess_arguments(Command* command, int argc, char** argv) command->core.argv[1] = (char*) "--script"; for (i = 0; i < other; ++i) command->core.argv[2 + i] = argv[1 + i]; - driver = script_driver; + driver = Driver::script; break; default: /* Driver specified by user. */ break; } - else if (driver == unknown_driver) + else if (driver == Driver::unknown) driver = default_driver(explicit_no_gui); command->core.argv[command->core.argc] = NULL; @@ -524,7 +523,7 @@ execute_core(const Command* command, Driver driver) Arguments args(command->rt_args.size() + command->core.argc + 2); /* GCL has this oddity that it wants to believe that argv[0] has something to tell about what GCL's own runtime is. Silly. */ - if (OPENAXIOM_BASE_RTS == gcl_runtime) + if (OPENAXIOM_BASE_RTS == Runtime::gcl) args[0] = (char*) ""; /* And CLISP wants to believe that argv[0] is where it hides stuff from the saved image. */ |