diff options
-rw-r--r-- | Makefile.am | 13 | ||||
-rw-r--r-- | Makefile.in | 121 | ||||
-rw-r--r-- | src/amount.h | 39 | ||||
-rw-r--r-- | src/py_amount.cc | 31 | ||||
-rw-r--r-- | src/py_times.cc | 2 | ||||
-rw-r--r-- | src/pyutils.h | 4 | ||||
-rw-r--r-- | tests/python/numerics/BasicAmount.py | 8 | ||||
-rw-r--r-- | tests/python/numerics/CommodityAmount.py | 8 |
8 files changed, 114 insertions, 112 deletions
diff --git a/Makefile.am b/Makefile.am index 28165969..3e22e2a8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -32,12 +32,16 @@ libledger_la_CPPFLAGS = -I$(top_builddir)/gdtoa -I$(srcdir)/gdtoa \ libledger_la_LDFLAGS = -release 3.0 libledger_la_SOURCES = \ - src/session.cc \ - src/journal.cc \ + src/utils.cc \ + src/times.cc \ + src/mask.cc \ + src/commodity.cc \ src/amount.cc \ src/balance.cc \ - src/commodity.cc \ src/value.cc \ + \ + src/session.cc \ + src/journal.cc \ src/binary.cc \ src/qif.cc \ src/textual.cc \ @@ -50,9 +54,6 @@ libledger_la_SOURCES = \ src/register.cc \ src/report.cc \ src/transform.cc \ - src/mask.cc \ - src/times.cc \ - src/utils.cc \ src/xml.cc \ src/xmlparse.cc \ src/xpath.cc diff --git a/Makefile.in b/Makefile.in index 54d0d2ad..a8a30214 100644 --- a/Makefile.in +++ b/Makefile.in @@ -85,32 +85,31 @@ am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \ libLTLIBRARIES_INSTALL = $(INSTALL) LTLIBRARIES = $(lib_LTLIBRARIES) libledger_la_LIBADD = -am__libledger_la_SOURCES_DIST = src/session.cc src/journal.cc \ - src/amount.cc src/balance.cc src/commodity.cc src/value.cc \ - src/binary.cc src/qif.cc src/textual.cc src/quotes.cc \ - src/csv.cc src/derive.cc src/emacs.cc src/format.cc \ - src/reconcile.cc src/register.cc src/report.cc \ - src/transform.cc src/mask.cc src/times.cc src/utils.cc \ - src/xml.cc src/xmlparse.cc src/xpath.cc src/gnucash.cc \ - src/ofx.cc src/pyinterp.cc +am__libledger_la_SOURCES_DIST = src/utils.cc src/times.cc src/mask.cc \ + src/commodity.cc src/amount.cc src/balance.cc src/value.cc \ + src/session.cc src/journal.cc src/binary.cc src/qif.cc \ + src/textual.cc src/quotes.cc src/csv.cc src/derive.cc \ + src/emacs.cc src/format.cc src/reconcile.cc src/register.cc \ + src/report.cc src/transform.cc src/xml.cc src/xmlparse.cc \ + src/xpath.cc src/gnucash.cc src/ofx.cc src/pyinterp.cc @HAVE_EXPAT_TRUE@am__objects_1 = libledger_la-gnucash.lo @HAVE_XMLPARSE_TRUE@am__objects_2 = libledger_la-gnucash.lo @HAVE_LIBOFX_TRUE@am__objects_3 = libledger_la-ofx.lo @HAVE_BOOST_PYTHON_TRUE@am__objects_4 = libledger_la-pyinterp.lo -am_libledger_la_OBJECTS = libledger_la-session.lo \ - libledger_la-journal.lo libledger_la-amount.lo \ - libledger_la-balance.lo libledger_la-commodity.lo \ - libledger_la-value.lo libledger_la-binary.lo \ +am_libledger_la_OBJECTS = libledger_la-utils.lo libledger_la-times.lo \ + libledger_la-mask.lo libledger_la-commodity.lo \ + libledger_la-amount.lo libledger_la-balance.lo \ + libledger_la-value.lo libledger_la-session.lo \ + libledger_la-journal.lo libledger_la-binary.lo \ libledger_la-qif.lo libledger_la-textual.lo \ libledger_la-quotes.lo libledger_la-csv.lo \ libledger_la-derive.lo libledger_la-emacs.lo \ libledger_la-format.lo libledger_la-reconcile.lo \ libledger_la-register.lo libledger_la-report.lo \ - libledger_la-transform.lo libledger_la-mask.lo \ - libledger_la-times.lo libledger_la-utils.lo \ - libledger_la-xml.lo libledger_la-xmlparse.lo \ - libledger_la-xpath.lo $(am__objects_1) $(am__objects_2) \ - $(am__objects_3) $(am__objects_4) + libledger_la-transform.lo libledger_la-xml.lo \ + libledger_la-xmlparse.lo libledger_la-xpath.lo \ + $(am__objects_1) $(am__objects_2) $(am__objects_3) \ + $(am__objects_4) nodist_libledger_la_OBJECTS = libledger_la_OBJECTS = $(am_libledger_la_OBJECTS) \ $(nodist_libledger_la_OBJECTS) @@ -364,12 +363,12 @@ libledger_la_CPPFLAGS = -I$(top_builddir)/gdtoa -I$(srcdir)/gdtoa \ -I$(srcdir)/src $(am__append_2) $(am__append_4) \ $(am__append_6) $(am__append_8) $(am__append_9) libledger_la_LDFLAGS = -release 3.0 -libledger_la_SOURCES = src/session.cc src/journal.cc src/amount.cc \ - src/balance.cc src/commodity.cc src/value.cc src/binary.cc \ - src/qif.cc src/textual.cc src/quotes.cc src/csv.cc \ - src/derive.cc src/emacs.cc src/format.cc src/reconcile.cc \ - src/register.cc src/report.cc src/transform.cc src/mask.cc \ - src/times.cc src/utils.cc src/xml.cc src/xmlparse.cc \ +libledger_la_SOURCES = src/utils.cc src/times.cc src/mask.cc \ + src/commodity.cc src/amount.cc src/balance.cc src/value.cc \ + src/session.cc src/journal.cc src/binary.cc src/qif.cc \ + src/textual.cc src/quotes.cc src/csv.cc src/derive.cc \ + src/emacs.cc src/format.cc src/reconcile.cc src/register.cc \ + src/report.cc src/transform.cc src/xml.cc src/xmlparse.cc \ src/xpath.cc $(am__append_3) $(am__append_5) $(am__append_7) \ $(am__append_10) @USE_PCH_TRUE@libledger_la_CXXFLAGS = $(WARNFLAGS) @@ -663,19 +662,33 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< -libledger_la-session.lo: src/session.cc -@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-session.lo -MD -MP -MF $(DEPDIR)/libledger_la-session.Tpo -c -o libledger_la-session.lo `test -f 'src/session.cc' || echo '$(srcdir)/'`src/session.cc -@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-session.Tpo $(DEPDIR)/libledger_la-session.Plo -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/session.cc' object='libledger_la-session.lo' libtool=yes @AMDEPBACKSLASH@ +libledger_la-utils.lo: src/utils.cc +@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-utils.lo -MD -MP -MF $(DEPDIR)/libledger_la-utils.Tpo -c -o libledger_la-utils.lo `test -f 'src/utils.cc' || echo '$(srcdir)/'`src/utils.cc +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-utils.Tpo $(DEPDIR)/libledger_la-utils.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/utils.cc' object='libledger_la-utils.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-session.lo `test -f 'src/session.cc' || echo '$(srcdir)/'`src/session.cc +@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-utils.lo `test -f 'src/utils.cc' || echo '$(srcdir)/'`src/utils.cc -libledger_la-journal.lo: src/journal.cc -@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-journal.lo -MD -MP -MF $(DEPDIR)/libledger_la-journal.Tpo -c -o libledger_la-journal.lo `test -f 'src/journal.cc' || echo '$(srcdir)/'`src/journal.cc -@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-journal.Tpo $(DEPDIR)/libledger_la-journal.Plo -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/journal.cc' object='libledger_la-journal.lo' libtool=yes @AMDEPBACKSLASH@ +libledger_la-times.lo: src/times.cc +@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-times.lo -MD -MP -MF $(DEPDIR)/libledger_la-times.Tpo -c -o libledger_la-times.lo `test -f 'src/times.cc' || echo '$(srcdir)/'`src/times.cc +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-times.Tpo $(DEPDIR)/libledger_la-times.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/times.cc' object='libledger_la-times.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-journal.lo `test -f 'src/journal.cc' || echo '$(srcdir)/'`src/journal.cc +@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-times.lo `test -f 'src/times.cc' || echo '$(srcdir)/'`src/times.cc + +libledger_la-mask.lo: src/mask.cc +@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-mask.lo -MD -MP -MF $(DEPDIR)/libledger_la-mask.Tpo -c -o libledger_la-mask.lo `test -f 'src/mask.cc' || echo '$(srcdir)/'`src/mask.cc +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-mask.Tpo $(DEPDIR)/libledger_la-mask.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/mask.cc' object='libledger_la-mask.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-mask.lo `test -f 'src/mask.cc' || echo '$(srcdir)/'`src/mask.cc + +libledger_la-commodity.lo: src/commodity.cc +@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-commodity.lo -MD -MP -MF $(DEPDIR)/libledger_la-commodity.Tpo -c -o libledger_la-commodity.lo `test -f 'src/commodity.cc' || echo '$(srcdir)/'`src/commodity.cc +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-commodity.Tpo $(DEPDIR)/libledger_la-commodity.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/commodity.cc' object='libledger_la-commodity.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-commodity.lo `test -f 'src/commodity.cc' || echo '$(srcdir)/'`src/commodity.cc libledger_la-amount.lo: src/amount.cc @am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-amount.lo -MD -MP -MF $(DEPDIR)/libledger_la-amount.Tpo -c -o libledger_la-amount.lo `test -f 'src/amount.cc' || echo '$(srcdir)/'`src/amount.cc @@ -691,13 +704,6 @@ libledger_la-balance.lo: src/balance.cc @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-balance.lo `test -f 'src/balance.cc' || echo '$(srcdir)/'`src/balance.cc -libledger_la-commodity.lo: src/commodity.cc -@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-commodity.lo -MD -MP -MF $(DEPDIR)/libledger_la-commodity.Tpo -c -o libledger_la-commodity.lo `test -f 'src/commodity.cc' || echo '$(srcdir)/'`src/commodity.cc -@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-commodity.Tpo $(DEPDIR)/libledger_la-commodity.Plo -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/commodity.cc' object='libledger_la-commodity.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-commodity.lo `test -f 'src/commodity.cc' || echo '$(srcdir)/'`src/commodity.cc - libledger_la-value.lo: src/value.cc @am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-value.lo -MD -MP -MF $(DEPDIR)/libledger_la-value.Tpo -c -o libledger_la-value.lo `test -f 'src/value.cc' || echo '$(srcdir)/'`src/value.cc @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-value.Tpo $(DEPDIR)/libledger_la-value.Plo @@ -705,6 +711,20 @@ libledger_la-value.lo: src/value.cc @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-value.lo `test -f 'src/value.cc' || echo '$(srcdir)/'`src/value.cc +libledger_la-session.lo: src/session.cc +@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-session.lo -MD -MP -MF $(DEPDIR)/libledger_la-session.Tpo -c -o libledger_la-session.lo `test -f 'src/session.cc' || echo '$(srcdir)/'`src/session.cc +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-session.Tpo $(DEPDIR)/libledger_la-session.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/session.cc' object='libledger_la-session.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-session.lo `test -f 'src/session.cc' || echo '$(srcdir)/'`src/session.cc + +libledger_la-journal.lo: src/journal.cc +@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-journal.lo -MD -MP -MF $(DEPDIR)/libledger_la-journal.Tpo -c -o libledger_la-journal.lo `test -f 'src/journal.cc' || echo '$(srcdir)/'`src/journal.cc +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-journal.Tpo $(DEPDIR)/libledger_la-journal.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/journal.cc' object='libledger_la-journal.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-journal.lo `test -f 'src/journal.cc' || echo '$(srcdir)/'`src/journal.cc + libledger_la-binary.lo: src/binary.cc @am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-binary.lo -MD -MP -MF $(DEPDIR)/libledger_la-binary.Tpo -c -o libledger_la-binary.lo `test -f 'src/binary.cc' || echo '$(srcdir)/'`src/binary.cc @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-binary.Tpo $(DEPDIR)/libledger_la-binary.Plo @@ -789,27 +809,6 @@ libledger_la-transform.lo: src/transform.cc @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-transform.lo `test -f 'src/transform.cc' || echo '$(srcdir)/'`src/transform.cc -libledger_la-mask.lo: src/mask.cc -@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-mask.lo -MD -MP -MF $(DEPDIR)/libledger_la-mask.Tpo -c -o libledger_la-mask.lo `test -f 'src/mask.cc' || echo '$(srcdir)/'`src/mask.cc -@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-mask.Tpo $(DEPDIR)/libledger_la-mask.Plo -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/mask.cc' object='libledger_la-mask.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-mask.lo `test -f 'src/mask.cc' || echo '$(srcdir)/'`src/mask.cc - -libledger_la-times.lo: src/times.cc -@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-times.lo -MD -MP -MF $(DEPDIR)/libledger_la-times.Tpo -c -o libledger_la-times.lo `test -f 'src/times.cc' || echo '$(srcdir)/'`src/times.cc -@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-times.Tpo $(DEPDIR)/libledger_la-times.Plo -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/times.cc' object='libledger_la-times.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-times.lo `test -f 'src/times.cc' || echo '$(srcdir)/'`src/times.cc - -libledger_la-utils.lo: src/utils.cc -@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-utils.lo -MD -MP -MF $(DEPDIR)/libledger_la-utils.Tpo -c -o libledger_la-utils.lo `test -f 'src/utils.cc' || echo '$(srcdir)/'`src/utils.cc -@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-utils.Tpo $(DEPDIR)/libledger_la-utils.Plo -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/utils.cc' object='libledger_la-utils.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -c -o libledger_la-utils.lo `test -f 'src/utils.cc' || echo '$(srcdir)/'`src/utils.cc - libledger_la-xml.lo: src/xml.cc @am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libledger_la_CPPFLAGS) $(CPPFLAGS) $(libledger_la_CXXFLAGS) $(CXXFLAGS) -MT libledger_la-xml.lo -MD -MP -MF $(DEPDIR)/libledger_la-xml.Tpo -c -o libledger_la-xml.lo `test -f 'src/xml.cc' || echo '$(srcdir)/'`src/xml.cc @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/libledger_la-xml.Tpo $(DEPDIR)/libledger_la-xml.Plo diff --git a/src/amount.h b/src/amount.h index f185cf7b..f5253b04 100644 --- a/src/amount.h +++ b/src/amount.h @@ -368,22 +368,24 @@ public: * Truth tests. An amount may be truth test in several ways: * * sign() returns an integer less than, greater than, or equal to - * zero depending on whether an amount is negative, zero, or greater - * than zero. Note that this function tests the actual value of the - * amount -- using its internal precision -- and not the display - * value. To test its display value, use: `round().sign()'. + * zero depending on whether the amount is negative, zero, or + * greater than zero. Note that this function tests the actual + * value of the amount -- using its internal precision -- and not + * the display value. To test its display value, use: + * `round().sign()'. * * is_nonzero(), or operator bool, returns true if an amount's * display value is not zero. * * is_zero() returns true if an amount's display value is zero. - * Thus, $0.0001 is considered zero(). + * Thus, $0.0001 is considered zero if the current display precision + * for dollars is two decimal places. * * is_realzero() returns true if an amount's actual value is zero. - * $0.0001 is not considered is_realzero(). + * Thus, $0.0001 is never considered realzero. * * is_null() returns true if an amount has no value and no - * commodity. This occurs only if an unitialized amount has never + * commodity. This only occurs if an uninitialized amount has never * been assigned a value. */ int sign() const; @@ -401,7 +403,11 @@ public: } bool is_null() const { - return ! quantity && ! has_commodity(); + if (! quantity) { + assert(! has_commodity()); + return true; + } + return false; } /** @@ -440,11 +446,10 @@ public: * Commodity-related methods. The following methods relate to an * amount's commodity: * - * has_commodity() returns true if the amount has a commodity. - * * commodity() returns an amount's commodity. If the amount has no - * commodity, then the value returned will be equal to - * `commodity_t::null_commodity'. + * commodity, the value returned is `current_pool->null_commodity'. + * + * has_commodity() returns true if the amount has a commodity. * * set_commodity(commodity_t) sets an amount's commodity to the * given value. Note that this merely sets the current amount to @@ -458,9 +463,9 @@ public: * number() returns a commodity-less version of an amount. This is * useful for accessing just the numeric portion of an amount. */ - bool has_commodity() const; commodity_t& commodity() const; + bool has_commodity() const; void set_commodity(commodity_t& comm) { commodity_ = &comm; } @@ -683,15 +688,15 @@ inline amount_t amount_t::round() const { return round(commodity().precision()); } -inline bool amount_t::has_commodity() const { - return commodity_ && commodity_ != commodity_->parent().null_commodity; -} - inline commodity_t& amount_t::commodity() const { // jww (2007-05-02): Should be a way to access null_commodity better return has_commodity() ? *commodity_ : *current_pool->null_commodity; } +inline bool amount_t::has_commodity() const { + return commodity_ && commodity_ != commodity_->parent().null_commodity; +} + } // namespace ledger #endif // _AMOUNT_H diff --git a/src/py_amount.cc b/src/py_amount.cc index 2d93067d..8721f879 100644 --- a/src/py_amount.cc +++ b/src/py_amount.cc @@ -51,6 +51,10 @@ void export_amount() .staticmethod("shutdown") #endif + .add_static_property("current_pool", + make_getter(&amount_t::current_pool, + return_value_policy<reference_existing_object>())) + #if 0 .add_static_property("keep_base", &amount_t::keep_base) @@ -58,13 +62,12 @@ void export_amount() .add_static_property("keep_date", &amount_t::keep_date) .add_static_property("keep_tag", &amount_t::keep_tag) - .add_static_property("full_strings", &amount_t::full_strings) + .add_static_property("stream_fullstrings", &amount_t::stream_fullstrings) #endif .def(init<double>()) .def(init<long>()) .def(init<std::string>()) - .def(init<char *>()) .def("exact", &amount_t::exact) .staticmethod("exact") @@ -151,6 +154,8 @@ void export_amount() .def(self / double()) .def(double() / self) + .def("precision", &amount_t::precision) + .def("negate", &amount_t::negate) .def("in_place_negate", &amount_t::in_place_negate, return_value_policy<reference_existing_object>()) @@ -176,9 +181,9 @@ void export_amount() .def("sign", &amount_t::sign) .def("__nonzero__", &amount_t::is_nonzero) - .def("nonzero", &amount_t::is_nonzero) - .def("zero", &amount_t::is_zero) - .def("realzero", &amount_t::is_realzero) + .def("is_nonzero", &amount_t::is_nonzero) + .def("is_zero", &amount_t::is_zero) + .def("is_realzero", &amount_t::is_realzero) .def("is_null", &amount_t::is_null) .def("to_double", &amount_t::to_double) @@ -192,39 +197,31 @@ void export_amount() .def("quantity_string", &amount_t::quantity_string) - .def("has_commodity", &amount_t::has_commodity) - .add_property("commodity", make_function(&amount_t::commodity, return_value_policy<reference_existing_object>()), make_function(&amount_t::set_commodity, with_custodian_and_ward<1, 2>())) + .def("has_commodity", &amount_t::has_commodity) .def("clear_commodity", &amount_t::clear_commodity) .def("number", &amount_t::number) .def("annotate_commodity", &amount_t::annotate_commodity) - .def("strip_annotations", &amount_t::strip_annotations) - -#if 0 - // jww (2007-05-03): This method depends on annotation_t + .def("commodity_annotated", &amount_t::commodity_annotated) .def("annotation_details", &amount_t::annotation_details) -#endif + .def("strip_annotations", &amount_t::strip_annotations) - // jww (2007-05-03): There are four versions of this method now .def("parse", py_parse_1) .def("parse", py_parse_2) -#if 0 - // jww (2007-05-03): This method has two forms .def("parse_conversion", &amount_t::parse_conversion) .staticmethod("parse_conversion") -#endif .def("valid", &amount_t::valid) ; - python_optional<amount_t>(); + register_optional_to_python<amount_t>(); implicitly_convertible<double, amount_t>(); implicitly_convertible<long, amount_t>(); diff --git a/src/py_times.cc b/src/py_times.cc index f509e0d0..861c43c9 100644 --- a/src/py_times.cc +++ b/src/py_times.cc @@ -95,7 +95,7 @@ void export_times() date_python_conversion(); datetime_python_conversion(); - python_optional<moment_t>(); + register_optional_to_python<moment_t>(); } } // namespace ledger diff --git a/src/pyutils.h b/src/pyutils.h index 84a0db7e..42d5f1e0 100644 --- a/src/pyutils.h +++ b/src/pyutils.h @@ -21,7 +21,7 @@ struct register_python_conversion }; template <typename T> -struct python_optional : public boost::noncopyable +struct register_optional_to_python : public boost::noncopyable { struct optional_to_python { @@ -67,7 +67,7 @@ struct python_optional : public boost::noncopyable } }; - explicit python_optional() { + explicit register_optional_to_python() { register_python_conversion<boost::optional<T>, optional_to_python, optional_from_python>(); } diff --git a/tests/python/numerics/BasicAmount.py b/tests/python/numerics/BasicAmount.py index 4dfb3a7a..9e2c1b3e 100644 --- a/tests/python/numerics/BasicAmount.py +++ b/tests/python/numerics/BasicAmount.py @@ -444,10 +444,10 @@ class BasicAmountTestCase(unittest.TestCase): self.assertFalse(x0) self.assertTrue(x1) - self.assertTrue(x0.zero()) - self.assertTrue(x0.realzero()) - self.assertFalse(x1.zero()) - self.assertFalse(x1.realzero()) + self.assertTrue(x0.is_zero()) + self.assertTrue(x0.is_realzero()) + self.assertFalse(x1.is_zero()) + self.assertFalse(x1.is_realzero()) self.assertTrue(x0.valid()) self.assertTrue(x1.valid()) diff --git a/tests/python/numerics/CommodityAmount.py b/tests/python/numerics/CommodityAmount.py index 5c177044..0edd9fad 100644 --- a/tests/python/numerics/CommodityAmount.py +++ b/tests/python/numerics/CommodityAmount.py @@ -178,8 +178,8 @@ class CommodityAmountTestCase(unittest.TestCase): x10 = amount("-123.45€") self.assertTrue(x0.is_null()) - self.assertTrue(x0.zero()) - self.assertTrue(x0.realzero()) + self.assertTrue(x0.is_zero()) + self.assertTrue(x0.is_realzero()) self.assertTrue(x0.sign() == 0) self.assertTrue(x0.compare(x1) < 0) self.assertTrue(x0.compare(x2) > 0) @@ -543,8 +543,8 @@ class CommodityAmountTestCase(unittest.TestCase): x1 = amount(internalAmount("$0.000000000000000000001")) self.assertFalse(x1) - self.assertTrue(x1.zero()) - self.assertFalse(x1.realzero()) + self.assertTrue(x1.is_zero()) + self.assertFalse(x1.is_realzero()) self.assertValid(x1) |