Commit 8af29054 authored by Morten Welinder's avatar Morten Welinder

Introspection fixes

parent 115d24d7
......@@ -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)
{
......
......@@ -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 ($_) } @_);
}
......
......@@ -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
......
#!/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
#!/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()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment