~peter-pearse/ubuntu/natty/guile-1.8/prop001

« back to all changes in this revision

Viewing changes to libguile/boolean.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Schepler
  • Date: 2006-11-09 03:11:16 UTC
  • Revision ID: james.westby@ubuntu.com-20061109031116-hu0q1jxqg12y6yeg
Tags: upstream-1.8.1+1
ImportĀ upstreamĀ versionĀ 1.8.1+1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*      Copyright (C) 1995, 1996, 2000, 2001, 2006 Free Software Foundation, Inc.
 
2
 * 
 
3
 * This library is free software; you can redistribute it and/or
 
4
 * modify it under the terms of the GNU Lesser General Public
 
5
 * License as published by the Free Software Foundation; either
 
6
 * version 2.1 of the License, or (at your option) any later version.
 
7
 *
 
8
 * This library is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
11
 * Lesser General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public
 
14
 * License along with this library; if not, write to the Free Software
 
15
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
16
 */
 
17
 
 
18
 
 
19
 
 
20
 
 
21
#include "libguile/_scm.h"
 
22
 
 
23
#include "libguile/validate.h"
 
24
#include "libguile/boolean.h"
 
25
#include "libguile/lang.h"
 
26
#include "libguile/tags.h"
 
27
 
 
28
 
 
29
 
 
30
 
 
31
SCM_DEFINE (scm_not, "not", 1, 0, 0, 
 
32
            (SCM x),
 
33
            "Return @code{#t} iff @var{x} is @code{#f}, else return @code{#f}.")
 
34
#define FUNC_NAME s_scm_not
 
35
{
 
36
  return scm_from_bool (scm_is_false (x) || SCM_NILP (x));
 
37
}
 
38
#undef FUNC_NAME
 
39
 
 
40
 
 
41
SCM_DEFINE (scm_boolean_p, "boolean?", 1, 0, 0, 
 
42
           (SCM obj),
 
43
            "Return @code{#t} iff @var{obj} is either @code{#t} or @code{#f}.")
 
44
#define FUNC_NAME s_scm_boolean_p
 
45
{
 
46
  return scm_from_bool (scm_is_bool (obj) || SCM_NILP (obj));
 
47
}
 
48
#undef FUNC_NAME
 
49
 
 
50
int
 
51
scm_is_bool (SCM x)
 
52
{
 
53
  return scm_is_eq (x, SCM_BOOL_F) || scm_is_eq (x, SCM_BOOL_T);
 
54
}
 
55
 
 
56
int
 
57
scm_to_bool (SCM x)
 
58
{
 
59
  if (scm_is_eq (x, SCM_BOOL_F))
 
60
    return 0;
 
61
  else if (scm_is_eq (x, SCM_BOOL_T))
 
62
    return 1;
 
63
  else    
 
64
    scm_wrong_type_arg (NULL, 0, x);
 
65
}
 
66
 
 
67
void
 
68
scm_init_boolean ()
 
69
{
 
70
#include "libguile/boolean.x"
 
71
}
 
72
 
 
73
 
 
74
/*
 
75
  Local Variables:
 
76
  c-file-style: "gnu"
 
77
  End:
 
78
*/