[gnumeric] Introspection fixes



commit 8af2905493455213325c90b7cff804d76d7128f4
Author: Morten Welinder <terra gnome org>
Date:   Thu Apr 12 09:13:55 2018 -0400

    Introspection fixes

 src/value.c                        |   12 ++++++++----
 test/GnumericTest.pm               |    7 +++++++
 test/Makefile.am                   |    4 +++-
 test/t3001-introspection-simple.pl |   33 +++++++++++++++++++++++++++++++++
 test/t3001-introspection-simple.py |   26 ++++++++++++++++++++++++++
 5 files changed, 77 insertions(+), 5 deletions(-)
---
diff --git a/src/value.c b/src/value.c
index 27299b1..8aec956 100644
--- a/src/value.c
+++ b/src/value.c
@@ -98,7 +98,6 @@ value_new_float (gnm_float f)
                *((GnmValueType *)&(v->type)) = VALUE_FLOAT;
                v->fmt = NULL;
                v->val = f;
-
                return (GnmValue *)v;
        } else {
                /* FIXME: bogus ep sent here.  What to do?  */
@@ -1013,10 +1012,15 @@ value_get_as_string (GnmValue const *v)
        return g_string_free (res, FALSE);
 }
 
-/*
- * Result will stay valid until (a) the value is disposed of, or (b) two
- * further calls to this function are made.
+/**
+ * value_peek_string:
+ * @v: a #GnmValue
+ *
+ * Returns: (transfer none): A string representation of the value.  The
+ * result will stay valid until either (a) the value is disposed of, or
+ * (b) two further calls to this function are made.
  */
+// NOTE: "(transfer none)" papers over an introspection bug
 char const *
 value_peek_string (GnmValue const *v)
 {
diff --git a/test/GnumericTest.pm b/test/GnumericTest.pm
index 18e0f6a..d659ae3 100644
--- a/test/GnumericTest.pm
+++ b/test/GnumericTest.pm
@@ -892,8 +892,15 @@ sub setup_python_environment {
     my $v = 'GI_TYPELIB_PATH';
     my $dir = "$top_builddir/src";
     $ENV{$v} = ($ENV{$v} || '') eq '' ? $dir : $dir . ':' . $ENV{$v};
+
+    # Ditto for shared libraries
+    $v = 'LD_LIBRARY_PATH';
+    $dir = "$top_builddir/src/.libs";
+    $ENV{$v} = ($ENV{$v} || '') eq '' ? $dir : $dir . ':' . $ENV{$v};
 }
 
+# -----------------------------------------------------------------------------
+
 sub quotearg {
     return join (' ', map { &quotearg1 ($_) } @_);
 }
diff --git a/test/Makefile.am b/test/Makefile.am
index 5e046b7..de42601 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -180,7 +180,9 @@ TESTS =     t1000-statfuns.pl                       \
 SUPPS = common.supp gui.supp t8003-valgrind-pdf.supp
 
 INTROSPECTION_TSTS = \
-       t3000-introspection-basic.pl
+       t3000-introspection-basic.pl            \
+       t3001-introspection-simple.pl
+
 INTROSPECTION_SUPPS = \
        $(INTROSPECTION_TSTS:.pl=.py)
 if HAVE_INTROSPECTION
diff --git a/test/t3001-introspection-simple.pl b/test/t3001-introspection-simple.pl
new file mode 100755
index 0000000..269dfff
--- /dev/null
+++ b/test/t3001-introspection-simple.pl
@@ -0,0 +1,33 @@
+#!/usr/bin/perl -w
+# -----------------------------------------------------------------------------
+
+use strict;
+use lib ($0 =~ m|^(.*/)| ? $1 : ".");
+use GnumericTest;
+
+&setup_python_environment ();
+
+my $python_script = $0;
+$python_script =~ s/\.pl$/.py/;
+my $ref = join("",<DATA>);
+&test_command ($PYTHON . ' ' . &GnumericTest::quotearg ($python_script),
+              sub { $_ eq $ref });
+
+__DATA__
+Peek:
+10
+101.25
+111.25
+01
+zzz
+abc
+TRUE
+
+As int:
+10
+101
+111
+1
+0
+0
+1
diff --git a/test/t3001-introspection-simple.py b/test/t3001-introspection-simple.py
new file mode 100755
index 0000000..455bfec
--- /dev/null
+++ b/test/t3001-introspection-simple.py
@@ -0,0 +1,26 @@
+#!/usr/bin/python
+# -----------------------------------------------------------------------------
+
+import gi
+gi.require_version('Gnm', '1.12') 
+from gi.repository import Gnm
+Gnm.init()
+
+wb = Gnm.Workbook.new_with_sheets(1)
+sheet = wb.sheet_by_index(0)
+sheet.cell_set_value(0,0,Gnm.Value.new_int(10))
+sheet.cell_set_value(0,1,Gnm.Value.new_float(101.25))
+sheet.cell_set_text(0,2,"=A1+A2")
+sheet.cell_set_text(0,3,"'01")
+sheet.cell_set_text(0,4,"zzz")
+sheet.cell_set_value(0,5,Gnm.Value.new_string("abc"))
+sheet.cell_set_value(0,6,Gnm.Value.new_bool(1))
+wb.recalc()
+
+print "Peek:"
+for i in range(7):
+    print sheet.cell_get_value(0,i).peek_string()
+
+print "\nAs int:"
+for i in range(7):
+    print sheet.cell_get_value(0,i).get_as_int()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]