Skip to content

Commit

Permalink
maint: Merge default to bytecode-interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
arungiridhar committed Dec 30, 2024
2 parents 5c05f61 + e931407 commit ad38d36
Show file tree
Hide file tree
Showing 27 changed files with 605 additions and 264 deletions.
55 changes: 46 additions & 9 deletions libgui/languages/build_ts/update_ts_files
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,36 @@

# This scripts has to be called from the folder libgui/languages
# where the *.ts files for each provided translation are located
echo "---------------------------------------------"
echo
echo " Updating language file from current sources "
echo
echo " Do NOT interrupt this script by Ctrl-C,"
echo " use 'q' instead."
echo
echo "---------------------------------------------"

# lupdate does not recognize the macro for the octave namespace.
# Therefore, the relevant sources are copied into a temporary
# directory where the macros for begining and edning a namespace
# are replaced by the original syntax.
echo
echo -n "Preparing temporary sources ... "

OCTAVE_TEMP="__octave_temp_gui_sources__"
mkdir $OCTAVE_TEMP
cp -a ../graphics $OCTAVE_TEMP/
cp -a ../qterminal $OCTAVE_TEMP/
cp -a ../src $OCTAVE_TEMP/

find $OCTAVE_TEMP -type f -exec \
sed -i -e 's/OCTAVE_BEGIN_NAMESPACE(\([^)]\+\))/namespace \1 \{/g'\
-e 's/OCTAVE_END_NAMESPACE(\([^)]\+\))/\}/g' {} \;

# The paths with libgui sources to scan for text strings
SEARCH_PATH_COMMON="../graphics ../qterminal ../src"
echo "done"

# Now set the search paths for lupdate to the temporary sources
SEARCH_PATH_COMMON="$OCTAVE_TEMP/graphics $OCTAVE_TEMP/qterminal $OCTAVE_TEMP/src"

# Path to Qt and QScintilla files with strings that should also be
# translated by octave in case that Qt or QScintilla does not provide
Expand All @@ -15,7 +42,7 @@ SEARCH_PATH_QSCI="build_ts/octave-qsci"
# The directory with translations provided by Qt and QScintilla
# FIXME: This constant should not be hardcoded. Probably best if
# it could be picked up from the configuration such as HAVE_QTX in config.h.
QT_VERSION="qt5"
QT_VERSION="qt6"
QT_LANG_DIR=/usr/share/$QT_VERSION/translations

# Now update all ts files
Expand Down Expand Up @@ -52,15 +79,25 @@ do
echo "$xx_yy: Existing translations for Qt: $T_QT, QSci: $T_QSCI"

# Do the update after user's confirmation
echo " => scan for strings in following paths"
echo " => $SEARCH_PATH"
read -p " => Update (y/[n])? " ANS;
ANS=${ANS:-n}
if [ $ANS = "y" ]; then
echo " => scan for strings in following paths"
echo " => $SEARCH_PATH"
read -N 1 -p " => Update (y/[n]/q)? " ANS;

if [[ $ANS = "q" ]]; then
break
fi

if [[ $ANS = "y" ]]; then
echo
lupdate -$QT_VERSION -no-obsolete -locations relative $SEARCH_PATH -ts $file
lupdate -no-obsolete -locations relative $SEARCH_PATH -ts $file
fi

done

# Remove temporary copy of source files
echo
echo
echo -n "Removing temporary sources ... "
rm -rf $OCTAVE_TEMP
echo "done"
echo
468 changes: 327 additions & 141 deletions libgui/src/gui-preferences-sc.cc

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions libgui/src/gui-preferences-sc.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ sc_prevent_rl_conflicts ("shortcuts/prevent_readline_conflicts", QVariant (false
const gui_pref
sc_prevent_rl_conflicts_menu ("shortcuts/prevent_readline_conflicts_menu", QVariant (false));

extern void init_all_shortcuts (void);
extern QString get_shortcut_section (const QString& key);

#endif
2 changes: 1 addition & 1 deletion libgui/src/gui-preferences.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ sc_pref::def_value () const
QString
sc_pref::def_text () const
{
return def_value ().toString ();
return def_value ().toString (QKeySequence::NativeText);
}

all_shortcut_preferences *all_shortcut_preferences::s_instance = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion libgui/src/gui-settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ gui_settings::sc_value (const sc_pref& scpref) const

// Get the value from the settings where the key sequences are stored
// as strings
return value (full_settings_key, key_seq.toString ()).toString ();
return value (full_settings_key, key_seq.toString (QKeySequence::NativeText)).toString ();
}
else
return scpref.def_text ();
Expand Down
3 changes: 3 additions & 0 deletions libgui/src/octave-qobject.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include "documentation-dock-widget.h"
#include "files-dock-widget.h"
#include "gui-settings.h"
#include "gui-preferences-sc.h"
#include "history-dock-widget.h"
#include "interpreter-qobject.h"
#include "main-window.h"
Expand Down Expand Up @@ -403,6 +404,8 @@ base_qobject::config_translators ()
m_qapplication->installTranslator (m_qsci_tr);

m_translators_installed = true;

init_all_shortcuts (); // after translators are loaded
}

void
Expand Down
14 changes: 12 additions & 2 deletions libgui/src/shortcuts-tree-widget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ enter_shortcut::keyPressEvent (QKeyEvent *e)
if (modifiers & Qt::MetaModifier)
key |= Qt::META;

setText (QKeySequence (key).toString ());
setText (QKeySequence (key).toString (QKeySequence::NativeText));
}
}

Expand Down Expand Up @@ -456,7 +456,17 @@ shortcuts_tree_widget::shortcuts_tree_widget (QWidget *parent)

QList<QString> shortcut_settings_keys
= all_shortcut_preferences::keys ();
shortcut_settings_keys.sort ();

// Sort the keys with respect to the desciption, by adding
// descriotions as keys and the settings keys as values to a map.
// Fir this, use QMultiMap since descriptions might not be unique.
QMultiMap <QString, QString> shortcut_settings_map;
for (const auto& settings_key : shortcut_settings_keys)
{
const sc_pref scpref = all_shortcut_preferences::value (settings_key);
shortcut_settings_map.insert (scpref.description (), settings_key);
}
shortcut_settings_keys = shortcut_settings_map.values ();

gui_settings settings;

Expand Down
2 changes: 2 additions & 0 deletions libinterp/octave-value/module.mk
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ OCTAVE_VALUE_SRC = \
%reldir%/cdef-package.cc \
%reldir%/cdef-property.cc \
%reldir%/cdef-utils.cc \
%reldir%/ov-base-diag-inst.cc \
%reldir%/ov-base-int-inst.cc \
%reldir%/ov-base-mat-inst.cc \
%reldir%/ov-base-scalar-inst.cc \
%reldir%/ov-base-sparse-inst.cc \
%reldir%/ov-base.cc \
%reldir%/ov-bool-mat.cc \
%reldir%/ov-bool.cc \
Expand Down
38 changes: 38 additions & 0 deletions libinterp/octave-value/ov-base-diag-inst.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 The Octave Project Developers
//
// See the file COPYRIGHT.md in the top-level directory of this
// distribution or <https://octave.org/copyright/>.
//
// 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 (HAVE_CONFIG_H)
# include "config.h"
#endif

#include "ov-base-diag.cc"

// instantiate template class with types that need to be exported from library

template class OCTINTERP_API octave_base_diag<FloatComplexDiagMatrix, FloatComplexMatrix>;
template class OCTINTERP_API octave_base_diag<FloatDiagMatrix, FloatMatrix>;
template class OCTINTERP_API octave_base_diag<ComplexDiagMatrix, ComplexMatrix>;
template class OCTINTERP_API octave_base_diag<DiagMatrix, Matrix>;

104 changes: 61 additions & 43 deletions libinterp/octave-value/ov-base-diag.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,34 @@
// Real matrix values.

template <typename DMT, typename MT>
class OCTINTERP_API octave_base_diag : public octave_base_value
class OCTINTERP_TEMPLATE_API octave_base_diag : public octave_base_value
{

public:

OCTINTERP_API
octave_base_diag ()
: octave_base_value (), m_matrix (), m_dense_cache () { }

OCTINTERP_API
octave_base_diag (const DMT& m)
: octave_base_value (), m_matrix (m), m_dense_cache ()
{ }

OCTINTERP_API
octave_base_diag (const octave_base_diag& m)
: octave_base_value (), m_matrix (m.m_matrix), m_dense_cache () { }

~octave_base_diag () = default;
OCTINTERP_API ~octave_base_diag () = default;

std::size_t byte_size () const { return m_matrix.byte_size (); }
OCTINTERP_API std::size_t byte_size () const
{ return m_matrix.byte_size (); }

octave_value squeeze () const { return m_matrix; }
OCTINTERP_API octave_value squeeze () const
{ return m_matrix; }

octave_value full_value () const { return to_dense (); }
OCTINTERP_API octave_value full_value () const
{ return to_dense (); }

// We don't need to override all three forms of subsref. The using
// declaration will avoid warnings about partially-overloaded virtual
Expand All @@ -74,8 +80,9 @@ class OCTINTERP_API octave_base_diag : public octave_base_value
OCTINTERP_API octave_value
subsref (const std::string& type, const std::list<octave_value_list>& idx);

octave_value_list subsref (const std::string& type,
const std::list<octave_value_list>& idx, int)
OCTINTERP_API octave_value_list
subsref (const std::string& type, const std::list<octave_value_list>& idx,
int)
{ return subsref (type, idx); }

OCTINTERP_API octave_value
Expand All @@ -85,14 +92,17 @@ class OCTINTERP_API octave_base_diag : public octave_base_value
subsasgn (const std::string& type, const std::list<octave_value_list>& idx,
const octave_value& rhs);

dim_vector dims () const { return m_matrix.dims (); }
OCTINTERP_API dim_vector dims () const
{ return m_matrix.dims (); }

octave_idx_type nnz () const { return diag ().nnz (); }
OCTINTERP_API octave_idx_type nnz () const
{ return diag ().nnz (); }

octave_value reshape (const dim_vector& new_dims) const
OCTINTERP_API octave_value reshape (const dim_vector& new_dims) const
{ return to_dense ().reshape (new_dims); }

octave_value permute (const Array<int>& vec, bool inv = false) const
OCTINTERP_API octave_value
permute (const Array<int>& vec, bool inv = false) const
{
if (vec.numel () == 2
&& ((vec.xelem (0) == 1 && vec.xelem (1) == 0)
Expand All @@ -105,11 +115,15 @@ class OCTINTERP_API octave_base_diag : public octave_base_value
OCTINTERP_API octave_value
resize (const dim_vector& dv, bool fill = false) const;

octave_value all (int dim = 0) const { return MT (m_matrix).all (dim); }
octave_value any (int dim = 0) const { return MT (m_matrix).any (dim); }
OCTINTERP_API octave_value all (int dim = 0) const
{ return MT (m_matrix).all (dim); }

OCTINTERP_API octave_value any (int dim = 0) const
{ return MT (m_matrix).any (dim); }

MatrixType matrix_type () const { return MatrixType::Diagonal; }
MatrixType matrix_type (const MatrixType&) const
OCTINTERP_API MatrixType matrix_type () const
{ return MatrixType::Diagonal; }
OCTINTERP_API MatrixType matrix_type (const MatrixType&) const
{ return matrix_type (); }

// We don't need to override both forms of the diag method. The using
Expand All @@ -119,38 +133,42 @@ class OCTINTERP_API octave_base_diag : public octave_base_value

OCTINTERP_API octave_value diag (octave_idx_type k = 0) const;

octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const
OCTINTERP_API octave_value
sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const
{ return to_dense ().sort (dim, mode); }
octave_value sort (Array<octave_idx_type>& sidx, octave_idx_type dim = 0,
sortmode mode = ASCENDING) const
OCTINTERP_API octave_value
sort (Array<octave_idx_type>& sidx, octave_idx_type dim = 0,
sortmode mode = ASCENDING) const
{ return to_dense ().sort (sidx, dim, mode); }

sortmode issorted (sortmode mode = UNSORTED) const
OCTINTERP_API sortmode issorted (sortmode mode = UNSORTED) const
{ return to_dense ().issorted (mode); }

Array<octave_idx_type> sort_rows_idx (sortmode mode = ASCENDING) const
OCTINTERP_API Array<octave_idx_type>
sort_rows_idx (sortmode mode = ASCENDING) const
{ return to_dense ().sort_rows_idx (mode); }

sortmode is_sorted_rows (sortmode mode = UNSORTED) const
OCTINTERP_API sortmode is_sorted_rows (sortmode mode = UNSORTED) const
{ return to_dense ().is_sorted_rows (mode); }

bool is_matrix_type () const { return true; }
OCTINTERP_API bool is_matrix_type () const { return true; }

bool isnumeric () const { return true; }
OCTINTERP_API bool isnumeric () const { return true; }

bool is_defined () const { return true; }
OCTINTERP_API bool is_defined () const { return true; }

bool is_constant () const { return true; }
OCTINTERP_API bool is_constant () const { return true; }

OCTINTERP_API bool is_true () const;

bool is_diag_matrix () const { return true; }
OCTINTERP_API bool is_diag_matrix () const { return true; }

OCTINTERP_API double double_value (bool = false) const;

OCTINTERP_API float float_value (bool = false) const;

double scalar_value (bool frc_str_conv = false) const
OCTINTERP_API double
scalar_value (bool frc_str_conv = false) const
{ return double_value (frc_str_conv); }

OCTINTERP_API octave::idx_vector
Expand Down Expand Up @@ -187,29 +205,29 @@ class OCTINTERP_API octave_base_diag : public octave_base_value
OCTINTERP_API SparseComplexMatrix
sparse_complex_matrix_value (bool = false) const;

int8NDArray
int8_array_value () const { return to_dense ().int8_array_value (); }
OCTINTERP_API int8NDArray int8_array_value () const
{ return to_dense ().int8_array_value (); }

int16NDArray
int16_array_value () const { return to_dense ().int16_array_value (); }
OCTINTERP_API int16NDArray int16_array_value () const
{ return to_dense ().int16_array_value (); }

int32NDArray
int32_array_value () const { return to_dense ().int32_array_value (); }
OCTINTERP_API int32NDArray int32_array_value () const
{ return to_dense ().int32_array_value (); }

int64NDArray
int64_array_value () const { return to_dense ().int64_array_value (); }
OCTINTERP_API int64NDArray int64_array_value () const
{ return to_dense ().int64_array_value (); }

uint8NDArray
uint8_array_value () const { return to_dense ().uint8_array_value (); }
OCTINTERP_API uint8NDArray uint8_array_value () const
{ return to_dense ().uint8_array_value (); }

uint16NDArray
uint16_array_value () const { return to_dense ().uint16_array_value (); }
OCTINTERP_API uint16NDArray uint16_array_value () const
{ return to_dense ().uint16_array_value (); }

uint32NDArray
uint32_array_value () const { return to_dense ().uint32_array_value (); }
OCTINTERP_API uint32NDArray uint32_array_value () const
{ return to_dense ().uint32_array_value (); }

uint64NDArray
uint64_array_value () const { return to_dense ().uint64_array_value (); }
OCTINTERP_API uint64NDArray uint64_array_value () const
{ return to_dense ().uint64_array_value (); }

OCTINTERP_API octave_value
convert_to_str_internal (bool pad, bool force, char type) const;
Expand Down
Loading

0 comments on commit ad38d36

Please sign in to comment.