simplify macro representation in the wake of module hygiene changes
[bpt/guile.git] / libguile / discouraged.c
index cf395e2..2621428 100644 (file)
    discourage something, move it here when that is feasible.
 */
 
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2004, 2006, 2008 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
  *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * This library 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
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
  */
 
-#include "libguile.h"
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <libguile.h>
+
 
 #if (SCM_ENABLE_DISCOURAGED == 1)
 
-#define DEFFROM(t,f1,f2) SCM f1(t x) { return f2 (x); }
-#define DEFTO(t,f1,f2)   t f1(SCM x, unsigned long pos, const char *s_caller) \
-                           { return f2 (x); }
-
-DEFFROM (short, scm_short2num, scm_from_short);
-DEFFROM (unsigned short, scm_ushort2num, scm_from_ushort);
-DEFFROM (int, scm_int2num, scm_from_int);
-DEFFROM (unsigned int, scm_uint2num, scm_from_uint);
-DEFFROM (long, scm_long2num, scm_from_long);
-DEFFROM (unsigned long, scm_ulong2num, scm_from_ulong);
-DEFFROM (size_t, scm_size2num, scm_from_size_t);
-DEFFROM (ptrdiff_t, scm_ptrdiff2num, scm_from_ssize_t);
-
-DEFTO (short, scm_num2short, scm_to_short);
-DEFTO (unsigned short, scm_num2ushort, scm_to_ushort);
-DEFTO (int, scm_num2int, scm_to_int);
-DEFTO (unsigned int, scm_num2uint, scm_to_uint);
-DEFTO (long, scm_num2long, scm_to_long);
-DEFTO (unsigned long, scm_num2ulong, scm_to_ulong);
-DEFTO (size_t, scm_num2size, scm_to_size_t);
-DEFTO (ptrdiff_t, scm_num2ptrdiff, scm_to_ssize_t);
+SCM
+scm_short2num (short x)
+{
+  return scm_from_short (x);
+}
+
+SCM
+scm_ushort2num (unsigned short x)
+{
+  return scm_from_ushort (x);
+}
+
+SCM
+scm_int2num (int x)
+{
+  return scm_from_int (x);
+}
+
+SCM
+scm_uint2num (unsigned int x)
+{
+  return scm_from_uint (x);
+}
+
+SCM
+scm_long2num (long x)
+{
+  return scm_from_long (x);
+}
+
+SCM
+scm_ulong2num (unsigned long x)
+{
+  return scm_from_ulong (x);
+}
+
+SCM
+scm_size2num (size_t x)
+{
+  return scm_from_size_t (x);
+}
+
+SCM
+scm_ptrdiff2num (ptrdiff_t x)
+{
+  return scm_from_ssize_t (x);
+}
+
+short
+scm_num2short (SCM x, unsigned long pos, const char *s_caller)
+{
+  return scm_to_short (x);
+}
+
+unsigned short
+scm_num2ushort (SCM x, unsigned long pos, const char *s_caller)
+{
+  return scm_to_ushort (x);
+}
+
+int
+scm_num2int (SCM x, unsigned long pos, const char *s_caller)
+{
+  return scm_to_int (x);
+}
+
+unsigned int
+scm_num2uint (SCM x, unsigned long pos, const char *s_caller)
+{
+  return scm_to_uint (x);
+}
+
+long
+scm_num2long (SCM x, unsigned long pos, const char *s_caller)
+{
+  return scm_to_long (x);
+}
+
+unsigned long
+scm_num2ulong (SCM x, unsigned long pos, const char *s_caller)
+{
+  return scm_to_ulong (x);
+}
+
+size_t
+scm_num2size (SCM x, unsigned long pos, const char *s_caller)
+{
+  return scm_to_size_t (x);
+}
+
+ptrdiff_t
+scm_num2ptrdiff (SCM x, unsigned long pos, const char *s_caller)
+{
+  return scm_to_ssize_t (x);
+}
 
 #if SCM_SIZEOF_LONG_LONG != 0
-DEFFROM (long long, scm_long_long2num, scm_from_long_long);
-DEFFROM (unsigned long long, scm_ulong_long2num, scm_from_ulong_long);
-DEFTO   (long long, scm_num2long_long, scm_to_long_long);
-DEFTO   (unsigned long long, scm_num2ulong_long, scm_to_ulong_long);
+
+SCM
+scm_long_long2num (long long x)
+{
+  return scm_from_long_long (x);
+}
+
+SCM
+scm_ulong_long2num (unsigned long long x)
+{
+  return scm_from_ulong_long (x);
+}
+
+long long
+scm_num2long_long (SCM x, unsigned long pos, const char *s_caller)
+{
+  return scm_to_long_long (x);
+}
+
+unsigned long long
+scm_num2ulong_long (SCM x, unsigned long pos, const char *s_caller)
+{
+  return scm_to_ulong_long (x);
+}
+
 #endif
 
 SCM
@@ -164,7 +265,7 @@ SCM_DEFINE (scm_make_keyword_from_dash_symbol, "make-keyword-from-dash-symbol",
   SCM dash_string, non_dash_symbol;
 
   SCM_ASSERT (scm_is_symbol (symbol)
-             && ('-' == scm_i_symbol_chars(symbol)[0]),
+             && (scm_i_symbol_ref (symbol, 0) == '-'),
              symbol, SCM_ARG1, FUNC_NAME);
 
   dash_string = scm_symbol_to_string (symbol);