gnucash master: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Sat Nov 7 16:10:38 EST 2015
Updated via https://github.com/Gnucash/gnucash/commit/fdc9a6a1 (commit)
via https://github.com/Gnucash/gnucash/commit/089817a9 (commit)
via https://github.com/Gnucash/gnucash/commit/05f08f33 (commit)
from https://github.com/Gnucash/gnucash/commit/d711b64f (commit)
commit fdc9a6a199489038e60eca81b7566a849e15d401
Author: John Ralls <jralls at ceridwen.us>
Date: Sat Oct 31 16:27:51 2015 -0700
Replace Math128 with GncInt128, add GncRational to Doxygen docs.
diff --git a/src/libqof/qof/gnc-int128.hpp b/src/libqof/qof/gnc-int128.hpp
index 9cd8e93..e7c52d8 100644
--- a/src/libqof/qof/gnc-int128.hpp
+++ b/src/libqof/qof/gnc-int128.hpp
@@ -45,8 +45,9 @@ extern "C"
#include <type_traits>
//using std::string;
-
-/**
+/** @addtogroup GncInt128
+ * @ingroup QOF
+ * @{
* @brief provides a 128-bit int as a base class for GncNumeric.
*
* All the usual operators are provided. Only the explicit integer
@@ -64,9 +65,9 @@ class GncInt128
uint64_t m_lo;
public:
-static const unsigned int numlegs = 2;
-static const unsigned int legbits = 64;
-static const unsigned int maxbits = legbits * numlegs;
+ static const unsigned int numlegs = 2;
+ static const unsigned int legbits = 64;
+ static const unsigned int maxbits = legbits * numlegs;
enum // Values for m_flags
{
@@ -75,14 +76,16 @@ enum // Values for m_flags
overflow = 2,
NaN = 4
};
-/**
- * Construct a GncInt128 from two int64_t.
- *
- * N.B.: If the two parameters are of differing sign, it's taken to
+/** @addtogroup Constructors Constructors
+ * Constructors are templated so that a GncInt128 can be constructed from any
+ * arbitrary integer type or pair of integer types.
+ * @note If the two parameters are of differing sign, it's taken to
* mean that the lower magnitude is *reducing* the magnitude of the
* upper, so the lower magnitude will be subracted from UINT64_MAX to
* obtain the lower limb value.
+* @{
*/
+/** Default constructor. Makes 0. */
GncInt128();
template <typename T>
GncInt128(T lower) : GncInt128 {INT64_C(0), static_cast<int64_t>(lower)}
@@ -119,6 +122,7 @@ enum // Values for m_flags
GncInt128 (int64_t upper, uint64_t lower, unsigned char flags = '\0');
GncInt128 (uint64_t upper, uint64_t lower, unsigned char flags = '\0');
+/** @} */
/**
* Clear the object.
*
diff --git a/src/libqof/qof/gnc-rational.hpp b/src/libqof/qof/gnc-rational.hpp
index 1c4edc6..2e04fd1 100644
--- a/src/libqof/qof/gnc-rational.hpp
+++ b/src/libqof/qof/gnc-rational.hpp
@@ -24,6 +24,10 @@
struct GncDenom;
+/** @ingroup QOF
+ * @brief Rational number class using GncInt128 for the numerator and denominator.
+ */
+
class GncRational
{
public:
diff --git a/src/libqof/qof/qof.h b/src/libqof/qof/qof.h
index 282d690..08baaea 100644
--- a/src/libqof/qof/qof.h
+++ b/src/libqof/qof/qof.h
@@ -39,10 +39,6 @@
@ingroup QOF
*/
/**
- @addtogroup Math128 Math128: 128-bit Integer Math Library
- @ingroup QOF
-*/
-/**
@addtogroup Numeric Numeric: Rational Number Handling w/ Rounding Error Control
@ingroup QOF
*/
commit 089817a9f6d0aeeeeb563933390afda5d3d6fff9
Author: John Ralls <jralls at ceridwen.us>
Date: Sat Oct 31 15:53:32 2015 -0700
Templatize the GncInt128 constructors.
Allows single or pair of arbitrary integral types to construct, without
explicitly creating all of the possibilities.
diff --git a/src/libqof/qof/gnc-int128.cpp b/src/libqof/qof/gnc-int128.cpp
index 4120dc3..2df2008 100644
--- a/src/libqof/qof/gnc-int128.cpp
+++ b/src/libqof/qof/gnc-int128.cpp
@@ -46,17 +46,9 @@ namespace {
GncInt128::GncInt128 () : m_flags {}, m_hi {0}, m_lo {0}{}
-GncInt128::GncInt128 (int64_t lower) :
- m_flags {static_cast<unsigned char>(lower < 0 ? neg : pos)},
- m_hi {0},
- m_lo {static_cast<uint64_t>(lower < 0 ? -lower : lower)} {}
-
-GncInt128::GncInt128 (uint64_t lower) :
- m_flags {}, m_hi {0}, m_lo {lower} {}
-
GncInt128::GncInt128 (int64_t upper, int64_t lower, unsigned char flags) :
m_flags {static_cast<unsigned char>(flags ^ (upper < 0 ? neg :
- upper == 0 && lower < 0 ? neg : pos))},
+ upper == 0 && lower < 0 ? neg : pos))},
m_hi {static_cast<uint64_t>(upper < 0 ? -upper : upper)},
m_lo {static_cast<uint64_t>(lower < 0 ? -lower : lower)}
{
@@ -68,9 +60,12 @@ GncInt128::GncInt128 (int64_t upper, int64_t lower, unsigned char flags) :
m_hi >>= 1;
}
+GncInt128::GncInt128 (int64_t upper, uint64_t lower, unsigned char flags) :
+ m_flags {static_cast<unsigned char>(flags ^ (upper < 0 ? neg : pos))},
+ m_hi {static_cast<uint64_t>(upper < 0 ? -upper : upper)}, m_lo {lower} {}
+
GncInt128::GncInt128 (uint64_t upper, uint64_t lower, unsigned char flags) :
- m_flags {flags}, m_hi {upper},
- m_lo {lower} {}
+ m_flags {flags}, m_hi {upper}, m_lo {lower} {}
GncInt128&
GncInt128::zero () noexcept
@@ -609,7 +604,7 @@ div_single_leg (uint64_t* u, size_t m, uint64_t v, GncInt128& q, GncInt128& r) n
}// namespace
-void
+ void
GncInt128::div (const GncInt128& b, GncInt128& q, GncInt128& r) noexcept
{
if (isOverflow() || b.isOverflow())
diff --git a/src/libqof/qof/gnc-int128.hpp b/src/libqof/qof/gnc-int128.hpp
index 067d395..9cd8e93 100644
--- a/src/libqof/qof/gnc-int128.hpp
+++ b/src/libqof/qof/gnc-int128.hpp
@@ -42,6 +42,7 @@ extern "C"
#include <stdexcept>
#include <string>
#include <ostream>
+#include <type_traits>
//using std::string;
@@ -74,14 +75,6 @@ enum // Values for m_flags
overflow = 2,
NaN = 4
};
-
- GncInt128 ();
- GncInt128 (int16_t lower) : GncInt128{static_cast<int64_t>(lower)} {};
- GncInt128 (uint16_t lower) : GncInt128{static_cast<uint64_t>(lower)} {};
- GncInt128 (int32_t lower) : GncInt128{static_cast<int64_t>(lower)} {};
- GncInt128 (uint32_t lower) : GncInt128{static_cast<uint64_t>(lower)} {};
- GncInt128 (int64_t lower);
- GncInt128 (uint64_t lower);
/**
* Construct a GncInt128 from two int64_t.
*
@@ -90,21 +83,42 @@ enum // Values for m_flags
* upper, so the lower magnitude will be subracted from UINT64_MAX to
* obtain the lower limb value.
*/
- GncInt128 (int16_t upper, int16_t lower, unsigned char flags = '\0') :
- GncInt128{static_cast<int64_t>(upper), static_cast<int64_t>(lower),
- flags} {};
- GncInt128 (uint16_t upper, uint16_t lower, unsigned char flags = '\0') :
- GncInt128{static_cast<int64_t>(upper), static_cast<int64_t>(lower),
- flags} {};
- GncInt128 (int32_t upper, int32_t lower, unsigned char flags = '\0') :
- GncInt128{static_cast<int64_t>(upper), static_cast<int64_t>(lower),
- flags} {};
- GncInt128 (uint32_t upper, uint32_t lower, unsigned char flags = '\0') :
- GncInt128{static_cast<int64_t>(upper), static_cast<int64_t>(lower),
- flags} {};
+ GncInt128();
+ template <typename T>
+ GncInt128(T lower) : GncInt128 {INT64_C(0), static_cast<int64_t>(lower)}
+ {
+ static_assert (std::is_integral<T>(),
+ "GncInt128 can be constructed only with "
+ "integral arguments.");
+ }
+ GncInt128(uint64_t lower) : GncInt128 {UINT64_C(0), lower} {}
+/** Double-integer constructor template.
+ */
+ template <typename T, typename U>
+ GncInt128(T upper, U lower, unsigned char flags = '\0') :
+ GncInt128 {static_cast<int64_t>(upper),
+ static_cast<int64_t>(lower), flags}
+ {
+ static_assert (std::is_integral<T>(),
+ "GncInt128 can be constructed only with "
+ "integral arguments.");
+ static_assert (std::is_integral<U>(),
+ "GncInt128 can be constructed only with "
+ "integral arguments.");
+ }
+
GncInt128 (int64_t upper, int64_t lower, unsigned char flags = '\0');
- GncInt128 (uint64_t upper, uint64_t lower, unsigned char flags = '\0');
+ template <typename T>
+ GncInt128(T upper, uint64_t lower) :
+ GncInt128 {static_cast<int64_t>(upper), lower}
+ {
+ static_assert (std::is_integral<T>(),
+ "GncInt128 can be constructed only with "
+ "integral arguments.");
+ }
+ GncInt128 (int64_t upper, uint64_t lower, unsigned char flags = '\0');
+ GncInt128 (uint64_t upper, uint64_t lower, unsigned char flags = '\0');
/**
* Clear the object.
*
commit 05f08f330d1e731168c35270a66c7be09ce7ccc0
Author: Rob.Gowin <robgowin at gmail.com>
Date: Sat Nov 7 15:01:05 2015 -0600
Clean up bitrot to get CuteCash building again.
1. Use guile-2.0 instead of guile-1.8.
2. Set GNC_PLATFORM_POSIX on Unix (for gnc_timezone.cpp).
3. Pass guile include files when compiling cutecash.
4. Link Boost libraries.
5. Add -std=gnu99 to CMAKE_C_FLAGS.
6. Temporarily put -O2 in CMAKE_C_FLAGS since Fedora requires
optimization for FORTIFY_SOURCE. (Eventually with CMake
we will have separate Debug and Release builds.)
Tested that cutecash builds and launches on OS X, Fedora 23 and Ubuntu 14.04.3.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7198944..6cb37e4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -80,13 +80,13 @@ FIND_PACKAGE (SWIG REQUIRED)
INCLUDE (${SWIG_USE_FILE})
# guile library and include dir
-PKG_CHECK_MODULES (GUILE guile-1.8>=1.8.0)
+PKG_CHECK_MODULES (GUILE guile-2.0>=2.0.9)
ADD_DEFINITIONS (-DHAVE_GUILE18)
# We also need to look up the executable
FIND_PROGRAM (GUILE_EXECUTABLE guile)
IF (NOT GUILE_FOUND)
- MESSAGE (SEND_ERROR "Guile was not found, but is required. Please set PKG_CONFIG_PATH so that guile-1.8.pc is found.")
+ MESSAGE (SEND_ERROR "Guile was not found, but is required. Please set PKG_CONFIG_PATH so that guile-2.0.pc is found.")
ENDIF (NOT GUILE_FOUND)
IF (NOT GUILE_EXECUTABLE)
MESSAGe (SEND_ERROR "The guile executable was not found, but is required. Please set GUILE_EXECUTABLE.")
@@ -148,7 +148,7 @@ ENDIF (WITH_AQBANKING)
# Compiler flags
IF (UNIX)
SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wdeclaration-after-statement -Wno-pointer-sign -D_FORTIFY_SOURCE=2 -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wno-unused")
- SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=deprecated-declarations")
+ SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=deprecated-declarations -std=gnu99 -O2")
ENDIF (UNIX)
IF (MINGW)
SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wdeclaration-after-statement -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wno-unused")
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 007b12d..7267f4a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -73,6 +73,7 @@ IF (UNIX)
SET (HAVE_STRPTIME 1)
SET (HAVE_STRUCT_TM_GMTOFF 1)
SET (HAVE_TIMEGM 1)
+ SET (GNC_PLATFORM_POSIX 1)
ENDIF (UNIX)
ADD_DEFINITIONS (-DHAVE_CONFIG_H)
diff --git a/src/config.h.cmake.in b/src/config.h.cmake.in
index 6b738d3..8876d33 100644
--- a/src/config.h.cmake.in
+++ b/src/config.h.cmake.in
@@ -69,6 +69,8 @@
#cmakedefine HAVE_WCTYPE_H 1
#cmakedefine HAVE_X11_XLIB_H 1
+#cmakedefine GNC_PLATFORM_POSIX 1
+
/* Define to 1 if you have the ANSI C header files. */
#cmakedefine STDC_HEADERS 1
diff --git a/src/gnc/CMakeLists.txt b/src/gnc/CMakeLists.txt
index c8a94c6..87e16ba 100644
--- a/src/gnc/CMakeLists.txt
+++ b/src/gnc/CMakeLists.txt
@@ -78,6 +78,7 @@ QT4_WRAP_UI (gnc_FORMS_HEADERS ${gnc_FORMS})
INCLUDE_DIRECTORIES (${GLIB2_INCLUDE_DIRS})
INCLUDE_DIRECTORIES (${GLIBMM_INCLUDE_DIRS})
+INCLUDE_DIRECTORIES (${GUILE_INCLUDE_DIRS})
INCLUDE_DIRECTORIES (${LIBINTL_INCLUDE_PATH})
INCLUDE_DIRECTORIES (${REGEX_INCLUDE_PATH})
INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/src ) # for config.h
@@ -126,6 +127,7 @@ IF (WIN32)
TARGET_LINK_LIBRARIES (cutecash ${LIBINTL_LIBRARY} ${REGEX_LIBRARY})
ENDIF (WIN32)
+TARGET_LINK_LIBRARIES (cutecash ${Boost_LIBRARIES})
TARGET_LINK_LIBRARIES (cutecash ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
TARGET_LINK_LIBRARIES (cutecash pthread)
Summary of changes:
CMakeLists.txt | 6 ++--
src/CMakeLists.txt | 1 +
src/config.h.cmake.in | 2 ++
src/gnc/CMakeLists.txt | 2 ++
src/libqof/qof/gnc-int128.cpp | 19 ++++------
src/libqof/qof/gnc-int128.hpp | 78 +++++++++++++++++++++++++----------------
src/libqof/qof/gnc-rational.hpp | 4 +++
src/libqof/qof/qof.h | 4 ---
8 files changed, 67 insertions(+), 49 deletions(-)
More information about the gnucash-changes
mailing list