Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate the build to C++17 and start using it #363

Merged
merged 2 commits into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,10 @@ on:

env:
BUILD_TYPE: Release
BOOST_URL: 'https://boostorg.jfrog.io/artifactory/main/release/1.78.0/source/boost_1_87_0.tar.gz'
BOOST_TGZ: 'boost_1_87_0.tar.gz'
BOOST_PATH: 'D:/boost_1_87_0'

jobs:
build_ubuntu_20:
runs-on: ubuntu-20.04
steps:
- name: Install Dependencies
run: sudo apt-get install -y libboost-dev

- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
Expand All @@ -45,23 +38,6 @@ jobs:
version: "5.12.8"
setup-python: 'false'

- name: Cache Boost
id: cache-boost
uses: actions/cache@v4
with:
path: ${{env.BOOST_PATH}}
key: win64-boost

- name: Install Boost
if: steps.cache-boost.outputs.cache-hit != 'true'
run: |
Invoke-WebRequest `
"${{ env.BOOST_URL }}" `
-OutFile "${{ env.BOOST_TGZ }}" `
-UserAgent "''"
tar xzf ${{ env.BOOST_TGZ }} -C D:/
rm ${{ env.BOOST_TGZ }}

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2

Expand All @@ -73,8 +49,6 @@ jobs:
- name: Configure
run: |
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -G"Visual Studio 17 2022"
env:
BOOST_ROOT: "${{env.BOOST_PATH}}"

- name: Build
run:
Expand Down
32 changes: 0 additions & 32 deletions .travis.yml

This file was deleted.

6 changes: 2 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ set(CPACK_RPM_PACKAGE_LICENSE "GPL-2")
set(CPACK_RPM_PACKAGE_GROUP "Applications/Editors")

# build requirements...
# set(CPACK_RPM_PACKAGE_REQUIRES "qt5-qtbase-devel, qt5-linguist, gcc, gcc-c++, boost-devel, cmake")
# set(CPACK_RPM_PACKAGE_REQUIRES "qt5-qtbase-devel, qt5-linguist, gcc, gcc-c++, cmake")
set(CPACK_RPM_PACKAGE_REQUIRES "qt5-qtbase >= 5.6")
set(CPACK_RPM_FILE_NAME RPM-DEFAULT)

set(CPACK_DEBIAN_PACKAGE_BUILD_DEPENDS "cmake (>= 3.0), qt5-default (>= 5.6), qtbase5-dev-tools (>= 5.6), qttools5-dev-tools (>= 5.6), qttools5-dev (>= 5.6), libboost-dev (>= 1.35), bison (>=3.0)")
set(CPACK_DEBIAN_PACKAGE_BUILD_DEPENDS "cmake (>= 3.0), qt5-default (>= 5.6), qtbase5-dev-tools (>= 5.6), qttools5-dev-tools (>= 5.6), qttools5-dev (>= 5.6), bison (>=3.0)")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt5core5a (>= 5.6), libqt5gui5 (>= 5.6), libqt5network5 (>= 5.6), libqt5printsupport5 (>= 5.6), libqt5widgets5 (>= 5.6), libqt5xml5 (>= 5.6)")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${CMAKE_PROJECT_HOMEPAGE_URL})
set(CPACK_DEBIAN_PACKAGE_SECTION "editors")
Expand All @@ -43,8 +43,6 @@ set(CPACK_STRIP_FILES "bin/nedit-import")
set(CPACK_STRIP_FILES "bin/nedit-ng")
include(CPack)

find_package(Boost 1.35 REQUIRED)

set(NEDIT_PURIFY OFF CACHE BOOL "Fill Unused TextBuffer space")
set(NEDIT_PER_TAB_CLOSE ON CACHE BOOL "Per Tab Close Buttons")
set(NEDIT_VISUAL_CTRL_CHARS ON CACHE BOOL "Visualize ASCII Control Characters")
Expand Down
10 changes: 6 additions & 4 deletions Interpreter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ PUBLIC
Qt5::Core
Util
GSL
PRIVATE
Boost::boost
)

target_add_warnings(Interpreter)

set_property(TARGET Interpreter PROPERTY CXX_STANDARD ${TARGET_COMPILER_HIGHEST_STD_SUPPORTED})
set_property(TARGET Interpreter PROPERTY CXX_EXTENSIONS OFF)
set_target_properties(Interpreter
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
)
36 changes: 18 additions & 18 deletions Interpreter/DataValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

#include <gsl/span>

#include <limits>
#include <map>
#include <memory>
#include <string>
#include <system_error>

#include <boost/variant.hpp>
#include <variant>

#include <QString>

Expand All @@ -33,8 +33,8 @@ struct ArrayIterator {
Array::iterator it;
};

using Data = boost::variant<
boost::blank,
using Data = std::variant<
std::monostate,
int32_t,
std::string,
ArrayPtr,
Expand Down Expand Up @@ -124,55 +124,55 @@ inline DataValue make_value(LibraryRoutine routine) {
}

inline bool is_unset(const DataValue &dv) {
return dv.value.which() == 0;
return dv.value.index() == 0;
}

inline bool is_integer(const DataValue &dv) {
return dv.value.which() == 1;
return dv.value.index() == 1;
}

inline bool is_string(const DataValue &dv) {
return dv.value.which() == 2;
return dv.value.index() == 2;
}

inline bool is_array(const DataValue &dv) {
return dv.value.which() == 3;
return dv.value.index() == 3;
}

inline std::string to_string(const DataValue &dv) {

if (auto n = boost::get<int>(&dv.value)) {
return std::to_string(*n);
if (auto n = std::get<int>(dv.value)) {
return std::to_string(n);
}
return boost::get<std::string>(dv.value);
return std::get<std::string>(dv.value);
}

inline int to_integer(const DataValue &dv) {
return boost::get<int>(dv.value);
return std::get<int>(dv.value);
}

inline Program *to_program(const DataValue &dv) {
return boost::get<Program *>(dv.value);
return std::get<Program *>(dv.value);
}

inline LibraryRoutine to_subroutine(const DataValue &dv) {
return boost::get<LibraryRoutine>(dv.value);
return std::get<LibraryRoutine>(dv.value);
}

inline DataValue *to_data_value(const DataValue &dv) {
return boost::get<DataValue *>(dv.value);
return std::get<DataValue *>(dv.value);
}

inline Inst *to_instruction(const DataValue &dv) {
return boost::get<Inst *>(dv.value);
return std::get<Inst *>(dv.value);
}

inline ArrayPtr to_array(const DataValue &dv) {
return boost::get<ArrayPtr>(dv.value);
return std::get<ArrayPtr>(dv.value);
}

inline ArrayIterator to_iterator(const DataValue &dv) {
return boost::get<ArrayIterator>(dv.value);
return std::get<ArrayIterator>(dv.value);
}

#endif
29 changes: 14 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
[![License](https://img.shields.io/badge/license-GPL2-blue.svg)](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)

nedit-ng is a Qt port of the [Nirvana Editor (NEdit)](https://sourceforge.net/projects/nedit/) version 5.6. It is intended
to be a **drop in replacement** for nedit in every practical way, just as on
to be a **drop in replacement** for nedit in every practical way, just as on
many systems `/usr/bin/vi` is now a symlink to `/usr/bin/vim`.

Because it is a true port of the original code, it (at least for now) inherits
some (but not all) of the limitations of the original. On the other hand, some
Because it is a true port of the original code, it (at least for now) inherits
some (but not all) of the limitations of the original. On the other hand, some
aspects have been improved simply by the fact that it is now a Qt application.

![Nedit-ng](https://eteran.github.io/nedit-ng/latest/img/nedit-ng-find.png)
Expand All @@ -19,7 +19,6 @@ aspects have been improved simply by the fact that it is now a Qt application.
Dependency | Version Required
------------------------------------------- | ----------------
[Qt](http://www.qt.io/) | >= 5.5
[Boost](http://boost.org) (Headers Only) | >= 1.35
[Bison](https://www.gnu.org/software/bison/)| >= 3.0
[CMake](https://cmake.org) | >= 3.0

Expand All @@ -29,42 +28,42 @@ Dependency | Version Required
$ cd build
$ cmake ..
$ make

### Help Documentation

NEdit had extensive help texts, which have been carefully updated and made available online here: https://eteran.github.io/nedit-ng/

### Inherited Limitations:

* Text display is still ASCII only (for now).
* Regex engine is the original nedit proprietary implementation. This was kept
* Regex engine is the original nedit proprietary implementation. This was kept
for a few reasons:
1. NEdit's syntax is **slightly** non-standard, and I wanted to keep
1. NEdit's syntax is **slightly** non-standard, and I wanted to keep
things backwards compatible for now.
2. NEdit's syntax highligher has very carefully created regex's which
result in things being highlighted in a way that I (and I assume other
2. NEdit's syntax highligher has very carefully created regex's which
result in things being highlighted in a way that I (and I assume other
nedit users) have grown to appreciate. A change in regex engine would
likely require a rework on the syntax highlighting algorithm.
3. The original highligher has some insider information of the regex
implementation which it uses in order to be more efficient. I could
implementation which it uses in order to be more efficient. I could
fake this information, but at the cost of efficiency.

### Improvements already available:

* Bug fixes! Yes, NEdit 5.6 unfortunately has some bugs, some of which can
* Bug fixes! Yes, NEdit 5.6 unfortunately has some bugs, some of which can
result in a crash. Where possible, the new code has these fixed.
* Anti-aliased font rendering.
* Modern look and feel.
* Internally, counted strings are used instead of NUL terminated strings. This
removes the need to have code that played games with substituting NUL
removes the need to have code that played games with substituting NUL
characters mid-stream.
* Use of some C++ containers means many internal size limits are no longer
present.
* Code as been reworked using modern C++ techniques using a toolkit with an
* Code as been reworked using modern C++ techniques using a toolkit with an
active developer community, making it significantly easier for contributions
to be made by the open source community.

The goal of the initial release is to be a nearly 1:1 port of the original NEdit.
The goal of the initial release is to be a nearly 1:1 port of the original NEdit.
Now that we have achieved that goal. looking towards the future, some additional
goals are:

Expand All @@ -73,5 +72,5 @@ goals are:
- [ ] Python/LUA scripting support in addition to the built-in macro system
- [ ] An improved preferences system
- [ ] Extensibility though plugins
- [ ] Sessions, meaning that you can save and restore an edit session (such as
- [ ] Sessions, meaning that you can save and restore an edit session (such as
several open tabs)
8 changes: 6 additions & 2 deletions Regex/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ target_link_libraries(Regex PUBLIC

target_add_warnings(Regex)

set_property(TARGET Regex PROPERTY CXX_STANDARD ${TARGET_COMPILER_HIGHEST_STD_SUPPORTED})
set_property(TARGET Regex PROPERTY CXX_EXTENSIONS OFF)
set_target_properties(Regex
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
)

if(NEDIT_BUILD_TESTS)
if(NOT MSVC)
Expand Down
4 changes: 2 additions & 2 deletions Regex/Decompile.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define DECOMPILE_H_

#include "Opcodes.h"
#include <boost/variant.hpp>
#include <variant>
#include <string>
#include <vector>
class Regex;
Expand Down Expand Up @@ -46,7 +46,7 @@ struct Instruction6 {
uint16_t op2;
};

using Instruction = boost::variant<Instruction1, Instruction2, Instruction3, Instruction4, Instruction5, Instruction6>;
using Instruction = std::variant<Instruction1, Instruction2, Instruction3, Instruction4, Instruction5, Instruction6>;

std::vector<Instruction> decompileRegex(const Regex &re);

Expand Down
10 changes: 8 additions & 2 deletions Regex/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@ if(NEDIT_INCLUDE_DECOMPILER)
target_compile_definitions(nedit-regex-test PUBLIC -DNEDIT_INCLUDE_DECOMPILER)
endif()

set_property(TARGET nedit-regex-test PROPERTY RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
set_property(TARGET nedit-regex-test PROPERTY CXX_STANDARD 14)

set_target_properties(nedit-regex-test
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)

add_test(
NAME nedit-regex-test
Expand Down
10 changes: 6 additions & 4 deletions Settings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ PUBLIC

target_add_warnings(Settings)

set_property(TARGET Settings PROPERTY CXX_STANDARD ${TARGET_COMPILER_HIGHEST_STD_SUPPORTED})
set_property(TARGET Settings PROPERTY CXX_EXTENSIONS OFF)


set_target_properties(Settings
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
)
11 changes: 6 additions & 5 deletions Util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,13 @@ PUBLIC
GSL
Qt5::Core
Qt5::Network
Boost::boost
)

target_add_warnings(Util)

set_property(TARGET Util PROPERTY CXX_STANDARD ${TARGET_COMPILER_HIGHEST_STD_SUPPORTED})
set_property(TARGET Util PROPERTY CXX_EXTENSIONS OFF)


set_target_properties(Util
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
)
2 changes: 1 addition & 1 deletion Util/include/Util/FileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "string_view.h"
#include <QString>
#include <QtGlobal>
#include <boost/optional.hpp>
#include <optional>
#include <string>

enum class FileFormats : int;
Expand Down
Loading