view libinterp/corefcn/settings.h @ 25443:2fa7cd178c4a

new class for miscellaneous interpreter settings * libgui/src/editor-settings.h: Rename from octave-settings.h. Change all uses. * libgui/src/module.mk: Update. * settings.h, settings.cc: New files for miscellaneous interpreter settings and access functions. * libinterp/corefcn/module.mk: Update. * lex.h, lex.ll: Move static variables Vdisplay_tokens, Vtoken_count, and lexer_debug_flag to new settings class. Change all uses. (base_lexer::debug_flag, base_lexer::display_tokens, base_lexer::increment_token_count, base_lexer::lexer_debug): New functions. (F__display_tokens__, F__token_count__, F__lexer_debug_flag__): Move to settings.cc. * interpreter.h, interpreter.cc (interpreter::m_settings, interpreter::settings): New data member and access function.
author John W. Eaton <jwe@octave.org>
date Fri, 08 Jun 2018 18:04:18 -0400
parents
children 4877f77d5e1d
line wrap: on
line source

/*

Copyright (C) 2018 John W. Eaton

This file is part of Octave.

Octave is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Octave is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Octave; see the file COPYING.  If not, see
<https://www.gnu.org/licenses/>.

*/

#if ! defined (octave_settings_h)
#define octave_settings_h 1

#include "octave-config.h"

class octave_value_list;

namespace octave
{
  // Most settings for the interpreter are stored in the classes which
  // they affect (intput_system, output_system, load_path, etc.  Some
  // don't really fit anywhere else.  For example, there is no single
  // lexer or parser object, so we store settings for those things
  // here.

  class settings
  {
  public:

    settings (void);

    settings (const settings&) = delete;

    settings& operator = (const settings&) = delete;

    ~settings (void) = default;

    octave_value display_tokens (const octave_value_list& args, int nargout);

    bool display_tokens (void) const { return m_display_tokens; }

    bool display_tokens (bool flag)
    {
      bool val = m_display_tokens;
      m_display_tokens = flag;
      return val;
    }

    // Read only.
    size_t token_count (void) const { return m_token_count; }

    void increment_token_count (void) { ++m_token_count; }

    octave_value lexer_debug_flag (const octave_value_list& args, int nargout);

    bool lexer_debug_flag (void) const { return m_lexer_debug_flag; }

    bool lexer_debug_flag (bool flag)
    {
      bool val = m_lexer_debug_flag;
      m_lexer_debug_flag = flag;
      return val;
    }

  private:

    // Display tokens as they are processed, for debugging.
    bool m_display_tokens = false;

    // Number of tokens processed since interpreter startup.
    size_t m_token_count = 0;

    // Internal variable for lexer debugging state.
    bool m_lexer_debug_flag = false;
  };
}

#endif