Commit e10adccc authored by Ariel Rios's avatar Ariel Rios Committed by Ariel Rios

Add prototype. (make_new_smob): Ditto New functions that enables to create

2000-11-06  Ariel Rios  <ariel@arcavia.com>

* smob-value.h (make_new_smob): Add prototype.
(make_new_smob): Ditto
* smob-value.c (make_new_smob): New functions that enables to create a
new value smob from a Value. This function is used in the C world.
(get_value_from_smob): Get the Value member from the smob. Also
used only in the C world.
(scm_value_new_bool): Function to create a new SCM.
(scm_value_new_float): Ditto.
(scm_value_new_string): Ditto.
(init_value_type): Add the value-new* functions into Guile.
parent a602f6a6
2000-11-06 Ariel Rios <ariel@arcavia.com>
* smob-value.h (make_new_smob): Add prototype.
(make_new_smob): Ditto
* smob-value.c (make_new_smob): New functions that enables to create a
new value smob from a Value. This function is used in the C world.
(get_value_from_smob): Get the Value member from the smob. Also
used only in the C world.
(scm_value_new_bool): Function to create a new SCM.
(scm_value_new_float): Ditto.
(scm_value_new_string): Ditto.
(init_value_type): Add the value-new* functions into Guile.
2000-11-06 Ariel Rios <ariel@arcavia.com>
* doc/guile-gnumeric.txt: Update documentation.
......
/* -*- mode: c; c-basic-offset: 8 -*- */
/*
Author: Ariel Rios <ariel@arcavia.com>
Copyright Ariel Rios 2000
*/
*
* Author: Ariel Rios <ariel@arcavia.com>
* Copyright Ariel Rios 2000
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*/
#include <libguile.h>
#include <glib.h>
#include <gtk/gtk.h>
......@@ -22,6 +38,32 @@ typedef struct _SCM_Value
SCM update_func;
} SCM_Value;
SCM
make_new_smob (Value *v)
{
SCM_Value *value;
value = (SCM_Value *) scm_must_malloc (sizeof (SCM_Value), "value");
value->v = v;
value->update_func = SCM_BOOL_F;
SCM_RETURN_NEWSMOB (value_tag, value);
}
Value *
get_value_from_smob (SCM value_smob)
{
Value *value;
SCM_Value *v = (SCM_Value *) SCM_CDR (value_smob);
value = g_new (Value, 1);
value = v->v;
return value;
}
static SCM
make_value (SCM scm)
{
......@@ -92,6 +134,61 @@ equalp_value (SCM value_smob_1, SCM value_smob_2)
return flag;
}
static SCM
scm_value_new_bool (SCM scm)
{
Value *v;
SCM_Value *value;
v = g_new (Value, 1);
if (gh_boolean_p (scm))
v = value_new_bool ((gboolean) gh_scm2bool (scm));
value = (SCM_Value *) scm_must_malloc (sizeof (SCM_Value), "value");
value->v = v;
value->update_func = SCM_BOOL_F;
SCM_RETURN_NEWSMOB (value_tag, value);
}
static SCM
scm_value_new_float (SCM scm)
{
Value *v;
SCM_Value *value;
v = g_new (Value, 1);
if ((SCM_NFALSEP (scm_number_p(scm))))
v = value_new_float ((float_t) scm_num2dbl(scm, 0));
value = (SCM_Value *) scm_must_malloc (sizeof (SCM_Value), "value");
value->v = v;
value->update_func = SCM_BOOL_F;
SCM_RETURN_NEWSMOB (value_tag, value);
}
static SCM
scm_value_new_string (SCM scm)
{
Value *v;
SCM_Value *value;
v = g_new (Value, 1);
if (SCM_NIMP (scm) && SCM_STRINGP (scm))
v = value_new_string (SCM_CHARS (scm));
value = (SCM_Value *) scm_must_malloc (sizeof (SCM_Value), "value");
value->v = v;
value->update_func = SCM_BOOL_F;
SCM_RETURN_NEWSMOB (value_tag, value);
}
static SCM
scm_value_get_as_string (SCM value_smob)
{
......@@ -162,6 +259,9 @@ init_value_type ()
scm_set_smob_equalp (value_tag, equalp_value);
scm_make_gsubr ("make-value", 1, 0, 0, make_value);
scm_make_gsubr ("value-new-bool", 1, 0, 0, scm_value_new_bool);
scm_make_gsubr ("value-new-float", 1, 0, 0, scm_value_new_float);
scm_make_gsubr ("value-new-string", 1, 0, 0, scm_value_new_string);
scm_make_gsubr ("value-get-as-string", 1, 0, 0, scm_value_get_as_string);
scm_make_gsubr ("value-get-as-int", 1, 0, 0, scm_value_get_as_int);
scm_make_gsubr ("value-get-as-float", 1, 0, 0, scm_value_get_as_float);
......
/* -*- mode: c; c-basic-offset: 8 -*- */
/*
Author: Ariel Rios <ariel@arcavia.com>
Copyright Ariel Rios 2000
*/
void init_value_type (void);
*
* Author: Ariel Rios <ariel@arcavia.com>
* Copyright Ariel Rios 2000
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*/
#include <libguile.h>
#include "value.h"
void init_value_type (void);
SCM make_new_smob (Value *);
Value *get_value_from_smob (SCM);
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