aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/libparser
diff options
context:
space:
mode:
Diffstat (limited to 'src/libparser')
-rw-r--r--src/libparser/CMakeLists.txt16
-rw-r--r--src/libparser/diceroller.cpp27
-rw-r--r--src/libparser/include/diceparser_qobject/diceroller.h1
-rw-r--r--src/libparser/node/explodedicenode.cpp7
4 files changed, 21 insertions, 30 deletions
diff --git a/src/libparser/CMakeLists.txt b/src/libparser/CMakeLists.txt
index 05faa19..91fb550 100644
--- a/src/libparser/CMakeLists.txt
+++ b/src/libparser/CMakeLists.txt
@@ -71,9 +71,7 @@ IF(STATIC_BUILD)
add_library(diceparser_static STATIC ${dice_sources} )
target_include_directories(diceparser_static PRIVATE include)
target_link_libraries(diceparser_static PUBLIC Qt6::Core Qt6::Gui Qt6::Svg)
- # install(TARGETS diceparser_static
- # ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
- rinstallLib(diceparser_static rolisteam)
+ rinstallLib(diceparser_static libraries)
endif()
@@ -99,10 +97,7 @@ include(GNUInstallDirs)
configure_file(diceparser.pc.in diceparser.pc @ONLY)
-#install(TARGETS diceparser_shared
-# LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
-# PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
-rinstallLib(diceparser_shared rolisteam)
+rinstallLib(diceparser_shared libraries)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/diceparser.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)
if(Qt${QT_VERSION_MAJOR}Qml_FOUND)
@@ -116,18 +111,13 @@ if(Qt${QT_VERSION_MAJOR}Qml_FOUND)
set_target_properties(diceparser_qobject PROPERTIES PUBLIC_HEADER "${dice_header_qobject}")
target_compile_definitions(diceparser_qobject PRIVATE DICEPARSER_QOBJECT_LIBRARY)
target_link_libraries(diceparser_qobject PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Svg Qt${QT_VERSION_MAJOR}::Qml Qt${QT_VERSION_MAJOR}::Concurrent PRIVATE diceparser_shared)
- message("Messages diceparser ${CMAKE_CURRENT_SOURCE_DIR}/include")
target_include_directories(diceparser_qobject PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
-
- #install(TARGETS diceparser_qobject
- #LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- # PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
- rinstallLib(diceparser_qobject rolisteam)
+ rinstallLib(diceparser_qobject libraries)
endif()
diff --git a/src/libparser/diceroller.cpp b/src/libparser/diceroller.cpp
index e1c8ded..3c315f6 100644
--- a/src/libparser/diceroller.cpp
+++ b/src/libparser/diceroller.cpp
@@ -24,6 +24,8 @@
DiceRoller::DiceRoller(QObject* parent) : QObject(parent) {}
+DiceRoller::~DiceRoller()= default;
+
QString DiceRoller::diceList() const
{
return m_diceList;
@@ -61,21 +63,18 @@ void DiceRoller::readErrorAndWarning()
void DiceRoller::start()
{
- auto future= QtConcurrent::run(
- [this]()
+ auto future= QtConcurrent::run([this]() {
+ if(m_diceparser.parseLine(m_command))
{
- if(m_diceparser.parseLine(m_command))
- {
- m_diceparser.start();
- readErrorAndWarning();
- auto jsonstr
- = m_diceparser.resultAsJSon([](const QString& value, const QString&, bool) { return value; });
- QJsonDocument doc= QJsonDocument::fromJson(jsonstr.toLocal8Bit());
- auto json= doc.object();
- m_result= json["scalar"].toString().toDouble();
- emit resultChanged();
- }
- });
+ m_diceparser.start();
+ readErrorAndWarning();
+ auto jsonstr= m_diceparser.resultAsJSon([](const QString& value, const QString&, bool) { return value; });
+ QJsonDocument doc= QJsonDocument::fromJson(jsonstr.toLocal8Bit());
+ auto json= doc.object();
+ m_result= json["scalar"].toString().toDouble();
+ emit resultChanged();
+ }
+ });
}
QString DiceRoller::error() const
diff --git a/src/libparser/include/diceparser_qobject/diceroller.h b/src/libparser/include/diceparser_qobject/diceroller.h
index 72c4e10..f389323 100644
--- a/src/libparser/include/diceparser_qobject/diceroller.h
+++ b/src/libparser/include/diceparser_qobject/diceroller.h
@@ -36,6 +36,7 @@ class DICEPARSER_QOBJECT_EXPORT DiceRoller : public QObject
public:
DiceRoller(QObject* parent= nullptr);
+ virtual ~DiceRoller();
QString diceList() const;
QString resultStr() const;
diff --git a/src/libparser/node/explodedicenode.cpp b/src/libparser/node/explodedicenode.cpp
index 7c9708b..5f51f95 100644
--- a/src/libparser/node/explodedicenode.cpp
+++ b/src/libparser/node/explodedicenode.cpp
@@ -28,7 +28,7 @@ void ExplodeDiceNode::run(ExecutionNode* previous)
die->displayed();
}
- quint64 limit= -1;
+ qint64 limit= -1;
if(m_limit)
{
m_limit->run(this);
@@ -39,8 +39,9 @@ void ExplodeDiceNode::run(ExecutionNode* previous)
}
bool hasExploded= false;
- std::function<void(Die*, qint64)> f= [&hasExploded, this, limit](Die* die, qint64) {
- static QHash<Die*, quint64> explodePerDice;
+ std::function<void(Die*, qint64)> f= [&hasExploded, this, limit](Die* die, qint64)
+ {
+ static QHash<Die*, qint64> explodePerDice;
if(Dice::CONDITION_STATE::ALWAYSTRUE
== m_validatorList->isValidRangeSize(std::make_pair<qint64, qint64>(die->getBase(), die->getMaxValue())))
{