diff options
author | Marius Vollmer <mvo@zagadka.de> | 2004-07-05 17:13:39 +0000 |
---|---|---|
committer | Marius Vollmer <mvo@zagadka.de> | 2004-07-05 17:13:39 +0000 |
commit | 3a684cc6c979b57512af1feb88f1517d506c2088 (patch) | |
tree | affc941931011a4bd221b343945499bfca130d33 | |
parent | e4e249c1b8e5a2dfb619871227ff7ccc8ed000f7 (diff) | |
download | guile-3a684cc6c979b57512af1feb88f1517d506c2088.tar.gz |
(scm_is_true, scm_is_false, scm_from_bool, scm_to_bool): New.
-rw-r--r-- | libguile/boolean.c | 15 | ||||
-rw-r--r-- | libguile/boolean.h | 8 |
2 files changed, 23 insertions, 0 deletions
diff --git a/libguile/boolean.c b/libguile/boolean.c index 97cffe845..1f6b5b037 100644 --- a/libguile/boolean.c +++ b/libguile/boolean.c @@ -45,7 +45,22 @@ SCM_DEFINE (scm_boolean_p, "boolean?", 1, 0, 0, } #undef FUNC_NAME +int +scm_is_bool (SCM x) +{ + return scm_is_eq (x, SCM_BOOL_F) || scm_is_eq (SCM_BOOL_T); +} +int +scm_to_bool (SCM x) +{ + if (scm_is_eq (x, SCM_BOOL_F)) + return 0; + else if (scm_is_eq (x, SCM_BOOL_T)) + return 1; + else + scm_wrong_type_arg (NULL, 0, x); +} void scm_init_boolean () diff --git a/libguile/boolean.h b/libguile/boolean.h index 982c950d6..63cc06006 100644 --- a/libguile/boolean.h +++ b/libguile/boolean.h @@ -47,10 +47,18 @@ ^ (SCM_UNPACK (SCM_BOOL_T) \ ^ SCM_UNPACK (SCM_BOOL_F)))) +#define scm_is_false(x) scm_is_eq ((x), SCM_BOOL_F) +#define scm_is_true(x) !scm_is_false (x) + +SCM_API int scm_is_bool(x); +#define scm_from_bool(x) ((f) ? SCM_BOOL_T : SCM_BOOL_F) +SCM_API int scm_to_bool (SCM x); + SCM_API SCM scm_not (SCM x); SCM_API SCM scm_boolean_p (SCM obj); + SCM_API void scm_init_boolean (void); #endif /* SCM_BOOLEAN_H */ |