changeset 9147:ee9adbda1ad1

(wrong_type_argument, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp, Fvectorp, Fstringp, Farrayp, Fsequencep, Fbufferp, Fmarkerp, Fsubrp, Fbyte_code_function_p, Fchar_or_string_p, Fintegerp, Finteger_or_marker_p, Fnatnump, Fnumber_or_marker_p, Ffloatp, Fcar, Fcar_safe, Fcdr, Fcdr_safe, Fsetcar, Fsetcdr, Fboundp, Ffboundp, store_symval_forwarding, Fset, default_value, Fdefault_boundp, Fdefault_value, Fset_default, Fmake_variable_buffer_local, Fmake_local_variable, Fkill_local_variable, indirect_function, Faref, Faset, Farray_length, arithcompare, Fzerop, Fnumber_to_string, arith_driver, float_arith_driver, Fmod, Fadd1, Fsub1): Use type test macros.
author Karl Heuer <kwzh@gnu.org>
date Tue, 27 Sep 1994 04:00:45 +0000
parents 8f966cc4652b
children e7ab930bb7eb
files src/data.c
diffstat 1 files changed, 74 insertions(+), 82 deletions(-) [+]
line wrap: on
line diff
--- a/src/data.c	Tue Sep 27 03:57:23 1994 +0000
+++ b/src/data.c	Tue Sep 27 04:00:45 1994 +0000
@@ -95,10 +95,10 @@
     {
       if (!EQ (Vmocklisp_arguments, Qt))
 	{
-	 if (XTYPE (value) == Lisp_String &&
+	 if (STRINGP (value) &&
 	     (EQ (predicate, Qintegerp) || EQ (predicate, Qinteger_or_marker_p)))
 	   return Fstring_to_number (value);
-	 if (XTYPE (value) == Lisp_Int && EQ (predicate, Qstringp))
+	 if (INTEGERP (value) && EQ (predicate, Qstringp))
 	   return Fnumber_to_string (value);
 	}
       value = Fsignal (Qwrong_type_argument, Fcons (predicate, Fcons (value, Qnil)));
@@ -180,7 +180,7 @@
   (obj)
      Lisp_Object obj;
 {
-  if (XTYPE (obj) == Lisp_Cons)
+  if (CONSP (obj))
     return Qt;
   return Qnil;
 }
@@ -189,7 +189,7 @@
   (obj)
      Lisp_Object obj;
 {
-  if (XTYPE (obj) == Lisp_Cons)
+  if (CONSP (obj))
     return Qnil;
   return Qt;
 }
@@ -198,7 +198,7 @@
   (obj)
      Lisp_Object obj;
 {
-  if (XTYPE (obj) == Lisp_Cons || NILP (obj))
+  if (CONSP (obj) || NILP (obj))
     return Qt;
   return Qnil;
 }
@@ -207,7 +207,7 @@
   (obj)
      Lisp_Object obj;
 {
-  if (XTYPE (obj) == Lisp_Cons || NILP (obj))
+  if (CONSP (obj) || NILP (obj))
     return Qnil;
   return Qt;
 }
@@ -216,7 +216,7 @@
   (obj)
      Lisp_Object obj;
 {
-  if (XTYPE (obj) == Lisp_Symbol)
+  if (SYMBOLP (obj))
     return Qt;
   return Qnil;
 }
@@ -225,7 +225,7 @@
   (obj)
      Lisp_Object obj;
 {
-  if (XTYPE (obj) == Lisp_Vector)
+  if (VECTORP (obj))
     return Qt;
   return Qnil;
 }
@@ -234,7 +234,7 @@
   (obj)
      Lisp_Object obj;
 {
-  if (XTYPE (obj) == Lisp_String)
+  if (STRINGP (obj))
     return Qt;
   return Qnil;
 }
@@ -243,7 +243,7 @@
   (obj)
      Lisp_Object obj;
 {
-  if (XTYPE (obj) == Lisp_Vector || XTYPE (obj) == Lisp_String)
+  if (VECTORP (obj) || STRINGP (obj))
     return Qt;
   return Qnil;
 }
@@ -253,8 +253,7 @@
   (obj)
      register Lisp_Object obj;
 {
-  if (CONSP (obj) || NILP (obj) ||
-      XTYPE (obj) == Lisp_Vector || XTYPE (obj) == Lisp_String)
+  if (CONSP (obj) || NILP (obj) || VECTORP (obj) || STRINGP (obj))
     return Qt;
   return Qnil;
 }
@@ -263,7 +262,7 @@
   (obj)
      Lisp_Object obj;
 {
-  if (XTYPE (obj) == Lisp_Buffer)
+  if (BUFFERP (obj))
     return Qt;
   return Qnil;
 }
@@ -272,7 +271,7 @@
   (obj)
      Lisp_Object obj;
 {
-  if (XTYPE (obj) == Lisp_Marker)
+  if (MARKERP (obj))
     return Qt;
   return Qnil;
 }
@@ -281,7 +280,7 @@
   (obj)
      Lisp_Object obj;
 {
-  if (XTYPE (obj) == Lisp_Subr)
+  if (SUBRP (obj))
     return Qt;
   return Qnil;
 }
@@ -291,7 +290,7 @@
   (obj)
      Lisp_Object obj;
 {
-  if (XTYPE (obj) == Lisp_Compiled)
+  if (COMPILEDP (obj))
     return Qt;
   return Qnil;
 }
@@ -301,7 +300,7 @@
   (obj)
      register Lisp_Object obj;
 {
-  if (XTYPE (obj) == Lisp_Int || XTYPE (obj) == Lisp_String)
+  if (INTEGERP (obj) || STRINGP (obj))
     return Qt;
   return Qnil;
 }
@@ -310,7 +309,7 @@
   (obj)
      Lisp_Object obj;
 {
-  if (XTYPE (obj) == Lisp_Int)
+  if (INTEGERP (obj))
     return Qt;
   return Qnil;
 }
@@ -320,7 +319,7 @@
   (obj)
      register Lisp_Object obj;
 {
-  if (XTYPE (obj) == Lisp_Marker || XTYPE (obj) == Lisp_Int)
+  if (MARKERP (obj) || INTEGERP (obj))
     return Qt;
   return Qnil;
 }
@@ -330,7 +329,7 @@
   (obj)
      Lisp_Object obj;
 {
-  if (XTYPE (obj) == Lisp_Int && XINT (obj) >= 0)
+  if (INTEGERP (obj) && XINT (obj) >= 0)
     return Qt;
   return Qnil;
 }
@@ -352,8 +351,7 @@
   (obj)
      Lisp_Object obj;
 {
-  if (NUMBERP (obj)
-      || XTYPE (obj) == Lisp_Marker)
+  if (NUMBERP (obj) || MARKERP (obj))
     return Qt;
   return Qnil;
 }
@@ -364,7 +362,7 @@
   (obj)
      Lisp_Object obj;
 {
-  if (XTYPE (obj) == Lisp_Float)
+  if (FLOATP (obj))
     return Qt;
   return Qnil;
 }
@@ -380,7 +378,7 @@
 {
   while (1)
     {
-      if (XTYPE (list) == Lisp_Cons)
+      if (CONSP (list))
 	return XCONS (list)->car;
       else if (EQ (list, Qnil))
 	return Qnil;
@@ -394,7 +392,7 @@
   (object)
      Lisp_Object object;
 {
-  if (XTYPE (object) == Lisp_Cons)
+  if (CONSP (object))
     return XCONS (object)->car;
   else
     return Qnil;
@@ -409,7 +407,7 @@
 {
   while (1)
     {
-      if (XTYPE (list) == Lisp_Cons)
+      if (CONSP (list))
 	return XCONS (list)->cdr;
       else if (EQ (list, Qnil))
 	return Qnil;
@@ -423,7 +421,7 @@
   (object)
      Lisp_Object object;
 {
-  if (XTYPE (object) == Lisp_Cons)
+  if (CONSP (object))
     return XCONS (object)->cdr;
   else
     return Qnil;
@@ -434,7 +432,7 @@
   (cell, newcar)
      register Lisp_Object cell, newcar;
 {
-  if (XTYPE (cell) != Lisp_Cons)
+  if (!CONSP (cell))
     cell = wrong_type_argument (Qconsp, cell);
 
   CHECK_IMPURE (cell);
@@ -447,7 +445,7 @@
   (cell, newcdr)
      register Lisp_Object cell, newcdr;
 {
-  if (XTYPE (cell) != Lisp_Cons)
+  if (!CONSP (cell))
     cell = wrong_type_argument (Qconsp, cell);
 
   CHECK_IMPURE (cell);
@@ -477,7 +475,7 @@
       valcontents = swap_in_symval_forwarding (sym, valcontents);
     }
 
-  return (XTYPE (valcontents) == Lisp_Void || EQ (valcontents, Qunbound)
+  return (VOIDP (valcontents) || EQ (valcontents, Qunbound)
 	  ? Qnil : Qt);
 }
 
@@ -486,9 +484,9 @@
      register Lisp_Object sym;
 {
   CHECK_SYMBOL (sym, 0);
-  return (XTYPE (XSYMBOL (sym)->function) == Lisp_Void
-	  || EQ (XSYMBOL (sym)->function, Qunbound))
-	 ? Qnil : Qt;
+  return ((VOIDP (XSYMBOL (sym)->function)
+	   || EQ (XSYMBOL (sym)->function, Qunbound))
+	  ? Qnil : Qt);
 }
 
 DEFUN ("makunbound", Fmakunbound, Smakunbound, 1, 1, 0, "Make SYMBOL's value be void.")
@@ -701,8 +699,8 @@
 
     default:
       valcontents = XSYMBOL (sym)->value;
-      if (XTYPE (valcontents) == Lisp_Buffer_Local_Value
-	  || XTYPE (valcontents) == Lisp_Some_Buffer_Local_Value)
+      if (BUFFER_LOCAL_VALUEP (valcontents)
+	  || SOME_BUFFER_LOCAL_VALUEP (valcontents))
 	XCONS (XSYMBOL (sym)->value)->car = newval;
       else
 	XSYMBOL (sym)->value = newval;
@@ -819,7 +817,7 @@
   (sym, newval)
      register Lisp_Object sym, newval;
 {
-  int voide = (XTYPE (newval) == Lisp_Void || EQ (newval, Qunbound));
+  int voide = (VOIDP (newval) || EQ (newval, Qunbound));
 
   register Lisp_Object valcontents, tem1, current_alist_element;
 
@@ -828,7 +826,7 @@
     return Fsignal (Qsetting_constant, Fcons (sym, Qnil));
   valcontents = XSYMBOL (sym)->value;
 
-  if (XTYPE (valcontents) == Lisp_Buffer_Objfwd)
+  if (BUFFER_OBJFWDP (valcontents))
     {
       register int idx = XUINT (valcontents);
       register int mask = *(int *)(idx + (char *) &buffer_local_flags);
@@ -836,8 +834,8 @@
 	current_buffer->local_var_flags |= mask;
     }
 
-  else if (XTYPE (valcontents) == Lisp_Buffer_Local_Value
-	   || XTYPE (valcontents) == Lisp_Some_Buffer_Local_Value)
+  else if (BUFFER_LOCAL_VALUEP (valcontents)
+	   || SOME_BUFFER_LOCAL_VALUEP (valcontents))
     {
       /* valcontents is actually a pointer to a cons heading something like:
 	 (REALVALUE BUFFER CURRENT-ALIST-ELEMENT . DEFAULT-VALUE).
@@ -876,7 +874,7 @@
 	 need to write it out, and find the new CURRENT-ALIST-ELEMENT.  */
       if ((current_buffer
 	   != XBUFFER (XCONS (XCONS (valcontents)->cdr)->car))
-	  || (XTYPE (valcontents) == Lisp_Buffer_Local_Value
+	  || (BUFFER_LOCAL_VALUEP (valcontents)
 	      && EQ (XCONS (current_alist_element)->car,
 		     current_alist_element)))
 	{
@@ -895,7 +893,7 @@
 	      /* If the variable is a Lisp_Some_Buffer_Local_Value,
 		 make CURRENT-ALIST-ELEMENT point to itself,
 		 indicating that we're seeing the default value.  */
-	      if (XTYPE (valcontents) == Lisp_Some_Buffer_Local_Value)
+	      if (SOME_BUFFER_LOCAL_VALUEP (valcontents))
 		tem1 = XCONS (XCONS (valcontents)->cdr)->cdr;
 
 	      /* If it's a Lisp_Buffer_Local_Value, give this buffer a
@@ -944,7 +942,7 @@
 
   /* For a built-in buffer-local variable, get the default value
      rather than letting do_symval_forwarding get the current value.  */
-  if (XTYPE (valcontents) == Lisp_Buffer_Objfwd)
+  if (BUFFER_OBJFWDP (valcontents))
     {
       register int idx = XUINT (valcontents);
 
@@ -953,8 +951,8 @@
     }
 
   /* Handle user-created local variables.  */
-  if (XTYPE (valcontents) == Lisp_Buffer_Local_Value
-      || XTYPE (valcontents) == Lisp_Some_Buffer_Local_Value)
+  if (BUFFER_LOCAL_VALUEP (valcontents)
+      || SOME_BUFFER_LOCAL_VALUEP (valcontents))
     {
       /* If var is set up for a buffer that lacks a local value for it,
 	 the current value is nominally the default value.
@@ -983,7 +981,7 @@
   register Lisp_Object value;
 
   value = default_value (sym);
-  return (XTYPE (value) == Lisp_Void || EQ (value, Qunbound)
+  return (VOIDP (value) || EQ (value, Qunbound)
 	  ? Qnil : Qt);
 }
 
@@ -998,7 +996,7 @@
   register Lisp_Object value;
 
   value = default_value (sym);
-  if (XTYPE (value) == Lisp_Void || EQ (value, Qunbound))
+  if (VOIDP (value) || EQ (value, Qunbound))
     return Fsignal (Qvoid_variable, Fcons (sym, Qnil));
   return value;
 }
@@ -1018,7 +1016,7 @@
   /* Handle variables like case-fold-search that have special slots
      in the buffer.  Make them work apparently like Lisp_Buffer_Local_Value
      variables.  */
-  if (XTYPE (valcontents) == Lisp_Buffer_Objfwd)
+  if (BUFFER_OBJFWDP (valcontents))
     {
       register int idx = XUINT (valcontents);
       register struct buffer *b;
@@ -1034,8 +1032,8 @@
       return value;
     }
 
-  if (XTYPE (valcontents) != Lisp_Buffer_Local_Value &&
-      XTYPE (valcontents) != Lisp_Some_Buffer_Local_Value)
+  if (!BUFFER_LOCAL_VALUEP (valcontents)
+      && !SOME_BUFFER_LOCAL_VALUEP (valcontents))
     return Fset (sym, value);
 
   /* Store new value into the DEFAULT-VALUE slot */
@@ -1110,10 +1108,9 @@
     error ("Symbol %s may not be buffer-local", XSYMBOL (sym)->name->data);
 
   valcontents = XSYMBOL (sym)->value;
-  if ((XTYPE (valcontents) == Lisp_Buffer_Local_Value) ||
-      (XTYPE (valcontents) == Lisp_Buffer_Objfwd))
+  if (BUFFER_LOCAL_VALUEP (valcontents) || BUFFER_OBJFWDP (valcontents))
     return sym;
-  if (XTYPE (valcontents) == Lisp_Some_Buffer_Local_Value)
+  if (SOME_BUFFER_LOCAL_VALUEP (valcontents))
     {
       XSETTYPE (XSYMBOL (sym)->value, Lisp_Buffer_Local_Value);
       return sym;
@@ -1148,8 +1145,7 @@
     error ("Symbol %s may not be buffer-local", XSYMBOL (sym)->name->data);
 
   valcontents = XSYMBOL (sym)->value;
-  if (XTYPE (valcontents) == Lisp_Buffer_Local_Value
-      || XTYPE (valcontents) == Lisp_Buffer_Objfwd)
+  if (BUFFER_LOCAL_VALUEP (valcontents) || BUFFER_OBJFWDP (valcontents))
     {
       tem = Fboundp (sym);
       
@@ -1159,7 +1155,7 @@
       return sym;
     }
   /* Make sure sym is set up to hold per-buffer values */
-  if (XTYPE (valcontents) != Lisp_Some_Buffer_Local_Value)
+  if (!SOME_BUFFER_LOCAL_VALUEP (valcontents))
     {
       tem = Fcons (Qnil, do_symval_forwarding (valcontents));
       XCONS (tem)->car = tem;
@@ -1191,9 +1187,7 @@
      variable before we swap in, then that new value will clobber the
      default value the next time we swap.  */
   valcontents = XCONS (XSYMBOL (sym)->value)->car;
-  if (XTYPE (valcontents) == Lisp_Intfwd
-      || XTYPE (valcontents) == Lisp_Boolfwd
-      || XTYPE (valcontents) == Lisp_Objfwd)
+  if (INTFWDP (valcontents) || BOOLFWDP (valcontents) || OBJFWDP (valcontents))
     swap_in_symval_forwarding (sym, XSYMBOL (sym)->value);
 
   return sym;
@@ -1212,7 +1206,7 @@
 
   valcontents = XSYMBOL (sym)->value;
 
-  if (XTYPE (valcontents) == Lisp_Buffer_Objfwd)
+  if (BUFFER_OBJFWDP (valcontents))
     {
       register int idx = XUINT (valcontents);
       register int mask = *(int *) (idx + (char *) &buffer_local_flags);
@@ -1226,8 +1220,8 @@
       return sym;
     }
 
-  if (XTYPE (valcontents) != Lisp_Buffer_Local_Value &&
-      XTYPE (valcontents) != Lisp_Some_Buffer_Local_Value)
+  if (!BUFFER_LOCAL_VALUEP (valcontents)
+      && !SOME_BUFFER_LOCAL_VALUEP (valcontents))
     return sym;
 
   /* Get rid of this buffer's alist element, if any */
@@ -1267,10 +1261,10 @@
 
   for (;;)
     {
-      if (XTYPE (hare) != Lisp_Symbol || EQ (hare, Qunbound))
+      if (!SYMBOLP (hare) || EQ (hare, Qunbound))
 	break;
       hare = XSYMBOL (hare)->function;
-      if (XTYPE (hare) != Lisp_Symbol || EQ (hare, Qunbound))
+      if (!SYMBOLP (hare) || EQ (hare, Qunbound))
 	break;
       hare = XSYMBOL (hare)->function;
 
@@ -1316,12 +1310,11 @@
 
   CHECK_NUMBER (idx, 1);
   idxval = XINT (idx);
-  if (XTYPE (array) != Lisp_Vector && XTYPE (array) != Lisp_String
-      && XTYPE (array) != Lisp_Compiled)
+  if (!VECTORP (array) && !STRINGP (array) && !COMPILEDP (array))
     array = wrong_type_argument (Qarrayp, array);
   if (idxval < 0 || idxval >= XVECTOR (array)->size)
     args_out_of_range (array, idx);
-  if (XTYPE (array) == Lisp_String)
+  if (STRINGP (array))
     {
       Lisp_Object val;
       XFASTINT (val) = (unsigned char) XSTRING (array)->data[idxval];
@@ -1342,13 +1335,13 @@
 
   CHECK_NUMBER (idx, 1);
   idxval = XINT (idx);
-  if (XTYPE (array) != Lisp_Vector && XTYPE (array) != Lisp_String)
+  if (!VECTORP (array) && !STRINGP (array))
     array = wrong_type_argument (Qarrayp, array);
   if (idxval < 0 || idxval >= XVECTOR (array)->size)
     args_out_of_range (array, idx);
   CHECK_IMPURE (array);
 
-  if (XTYPE (array) == Lisp_Vector)
+  if (VECTORP (array))
     XVECTOR (array)->contents[idxval] = newelt;
   else
     {
@@ -1364,8 +1357,7 @@
      register Lisp_Object array;
 {
   register Lisp_Object size;
-  if (XTYPE (array) != Lisp_Vector && XTYPE (array) != Lisp_String
-      && XTYPE (array) != Lisp_Compiled)
+  if (!VECTORP (array) && !STRINGP (array) && !COMPILEDP (array))
     array = wrong_type_argument (Qarrayp, array);
   XFASTINT (size) = XVECTOR (array)->size;
   return size;
@@ -1387,11 +1379,11 @@
   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num1, 0);
   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num2, 0);
 
-  if (XTYPE (num1) == Lisp_Float || XTYPE (num2) == Lisp_Float)
+  if (FLOATP (num1) || FLOATP (num2))
     {
       floatp = 1;
-      f1 = (XTYPE (num1) == Lisp_Float) ? XFLOAT (num1)->data : XINT (num1);
-      f2 = (XTYPE (num2) == Lisp_Float) ? XFLOAT (num2)->data : XINT (num2);
+      f1 = (FLOATP (num1)) ? XFLOAT (num1)->data : XINT (num1);
+      f2 = (FLOATP (num2)) ? XFLOAT (num2)->data : XINT (num2);
     }
 #else
   CHECK_NUMBER_COERCE_MARKER (num1, 0);
@@ -1492,7 +1484,7 @@
 #ifdef LISP_FLOAT_TYPE
   CHECK_NUMBER_OR_FLOAT (num, 0);
 
-  if (XTYPE(num) == Lisp_Float)
+  if (FLOATP (num))
     {
       if (XFLOAT(num)->data == 0.0)
 	return Qt;
@@ -1550,7 +1542,7 @@
 #else
   CHECK_NUMBER_OR_FLOAT (num, 0);
 
-  if (XTYPE(num) == Lisp_Float)
+  if (FLOATP (num))
     {
       char pigbuf[350];	/* see comments in float_to_string */
 
@@ -1628,7 +1620,7 @@
 #ifdef LISP_FLOAT_TYPE
       CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (val, argnum);
 
-      if (XTYPE (val) == Lisp_Float) /* time to do serious math */
+      if (FLOATP (val)) /* time to do serious math */
 	return (float_arith_driver ((double) accum, argnum, code,
 				    nargs, args));
 #else
@@ -1691,7 +1683,7 @@
       val = args[argnum];    /* using args[argnum] as argument to CHECK_NUMBER_... */
       CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (val, argnum);
 
-      if (XTYPE (val) == Lisp_Float)
+      if (FLOATP (val))
 	{
 	  next = XFLOAT (val)->data;
 	}
@@ -1830,12 +1822,12 @@
   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num1, 0);
   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num2, 1);
 
-  if (XTYPE (num1) == Lisp_Float || XTYPE (num2) == Lisp_Float)
+  if (FLOATP (num1) || FLOATP (num2))
     {
       double f1, f2;
 
-      f1 = XTYPE (num1) == Lisp_Float ? XFLOAT (num1)->data : XINT (num1);
-      f2 = XTYPE (num2) == Lisp_Float ? XFLOAT (num2)->data : XINT (num2);
+      f1 = FLOATP (num1) ? XFLOAT (num1)->data : XINT (num1);
+      f2 = FLOATP (num2) ? XFLOAT (num2)->data : XINT (num2);
       if (f2 == 0)
 	Fsignal (Qarith_error, Qnil);
 
@@ -1963,7 +1955,7 @@
 #ifdef LISP_FLOAT_TYPE
   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num, 0);
 
-  if (XTYPE (num) == Lisp_Float)
+  if (FLOATP (num))
     return (make_float (1.0 + XFLOAT (num)->data));
 #else
   CHECK_NUMBER_COERCE_MARKER (num, 0);
@@ -1982,7 +1974,7 @@
 #ifdef LISP_FLOAT_TYPE
   CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (num, 0);
 
-  if (XTYPE (num) == Lisp_Float)
+  if (FLOATP (num))
     return (make_float (-1.0 + XFLOAT (num)->data));
 #else
   CHECK_NUMBER_COERCE_MARKER (num, 0);