Re: [patch] extend guile plugin connectivity



On Tue, 2002-07-02 at 16:52, Floris Kraak wrote:

Hi,

This patch allows guile calls to hand gnumeric data other than
type 'string' from within the guile plugin. Diffed against 1.0.8.

As you can see, it is quite small.
(original author: joost helberg <joost snow nl>. Don't credit me ;-)

diff -urN --minimal gnumeric-1.0.8/plugins/guile/smob-value.c gnumeric-1.0.8-snow/plugins/guile/smob-value.c
--- gnumeric-1.0.8/plugins/guile/smob-value.c Sat Apr 13 23:45:59 2002
+++ gnumeric-1.0.8-snow/plugins/guile/smob-value.c    Tue Jul  2 16:24:49 2002
@@ -211,7 +211,14 @@
 {
      SCM_Value *v = (SCM_Value *) SCM_CDR (value_smob);
 
-     if (v->v->type ==  VALUE_STRING)
+     /* JAH: in case we do a get as string on an int, we expect
+        the integer as string, nog EOL! gnumeric fully supports getting
+           stuff in as strings
+        */
+     if (v->v->type == VALUE_STRING ||
+            v->v->type == VALUE_BOOLEAN ||
+            v->v->type == VALUE_INTEGER ||
+            v->v->type == VALUE_FLOAT )
              return scm_makfrom0str (value_get_as_string (v->v));
 
      return SCM_EOL;

I don't see anything wrong with it.

On the other hand - I am probably just revealing my ignorance here - but
what is the point? You turn the value into a Scheme string before
passing it to Guile. You can already pass integers as Scheme numbers
with value-get-as-int, and floats as Scheme bignums with
value-get-as-float.

These have the problem that you're supposed to know the value type. If
you want to improve the Guile plugin, wouldn't it be better to declare
the 'value-get-as-' gang deprecated, and make a 'value-get-value' (lousy
name!) which returns a Scheme value of the type most appropriate to the
Gnumeric value?

(Is anybody actually using the Guile plugin?)

Regards

Jon Kåre 






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