Mercurial > emacs
comparison src/data.c @ 10725:24958130d147
Rename arg OBJ to OBJECT in all type predicates.
(Ftype_of): New function.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 13 Feb 1995 05:28:47 +0000 |
parents | 4eeb2d49d841 |
children | 6a8b6db450dc |
comparison
equal
deleted
inserted
replaced
10724:1bc137a2c4eb | 10725:24958130d147 |
---|---|
71 Lisp_Object Qintegerp, Qnatnump, Qwholenump, Qsymbolp, Qlistp, Qconsp; | 71 Lisp_Object Qintegerp, Qnatnump, Qwholenump, Qsymbolp, Qlistp, Qconsp; |
72 Lisp_Object Qstringp, Qarrayp, Qsequencep, Qbufferp; | 72 Lisp_Object Qstringp, Qarrayp, Qsequencep, Qbufferp; |
73 Lisp_Object Qchar_or_string_p, Qmarkerp, Qinteger_or_marker_p, Qvectorp; | 73 Lisp_Object Qchar_or_string_p, Qmarkerp, Qinteger_or_marker_p, Qvectorp; |
74 Lisp_Object Qbuffer_or_string_p; | 74 Lisp_Object Qbuffer_or_string_p; |
75 Lisp_Object Qboundp, Qfboundp; | 75 Lisp_Object Qboundp, Qfboundp; |
76 | |
76 Lisp_Object Qcdr; | 77 Lisp_Object Qcdr; |
77 Lisp_Object Qad_advice_info, Qad_activate; | 78 Lisp_Object Qad_advice_info, Qad_activate; |
78 | 79 |
79 Lisp_Object Qrange_error, Qdomain_error, Qsingularity_error; | 80 Lisp_Object Qrange_error, Qdomain_error, Qsingularity_error; |
80 Lisp_Object Qoverflow_error, Qunderflow_error; | 81 Lisp_Object Qoverflow_error, Qunderflow_error; |
81 | 82 |
82 #ifdef LISP_FLOAT_TYPE | 83 #ifdef LISP_FLOAT_TYPE |
83 Lisp_Object Qfloatp; | 84 Lisp_Object Qfloatp; |
84 Lisp_Object Qnumberp, Qnumber_or_marker_p; | 85 Lisp_Object Qnumberp, Qnumber_or_marker_p; |
85 #endif | 86 #endif |
87 | |
88 static Lisp_Object Qinteger, Qsymbol, Qstring, Qcons, Qmarker, Qoverlay; | |
89 static Lisp_Object Qfloat, Qwindow_configuration, Qprocess, Qwindow; | |
90 static Lisp_Object Qcompiled_function, Qbuffer, Qframe, Qvector; | |
86 | 91 |
87 static Lisp_Object swap_in_symval_forwarding (); | 92 static Lisp_Object swap_in_symval_forwarding (); |
88 | 93 |
89 Lisp_Object | 94 Lisp_Object |
90 wrong_type_argument (predicate, value) | 95 wrong_type_argument (predicate, value) |
172 return Qt; | 177 return Qt; |
173 return Qnil; | 178 return Qnil; |
174 } | 179 } |
175 | 180 |
176 DEFUN ("null", Fnull, Snull, 1, 1, 0, "T if OBJECT is nil.") | 181 DEFUN ("null", Fnull, Snull, 1, 1, 0, "T if OBJECT is nil.") |
177 (obj) | 182 (object) |
178 Lisp_Object obj; | 183 Lisp_Object object; |
179 { | 184 { |
180 if (NILP (obj)) | 185 if (NILP (object)) |
181 return Qt; | 186 return Qt; |
182 return Qnil; | 187 return Qnil; |
183 } | 188 } |
184 | 189 |
190 DEFUN ("type-of", Ftype_of, Stype_of, 1, 1, 0, | |
191 "Return a symbol representing the type of OBJECT.\n\ | |
192 The symbol returned names the object's basic type;\n\ | |
193 for example, (type-of 1) returns `integer'.") | |
194 (object) | |
195 Lisp_Object object; | |
196 { | |
197 switch (XGCTYPE (object)) | |
198 { | |
199 case Lisp_Int: | |
200 return Qinteger; | |
201 | |
202 case Lisp_Symbol: | |
203 return Qsymbol; | |
204 | |
205 case Lisp_String: | |
206 return Qstring; | |
207 | |
208 case Lisp_Cons: | |
209 return Qcons; | |
210 | |
211 case Lisp_Misc: | |
212 switch (XMISC (object)->type) | |
213 { | |
214 case Lisp_Misc_Marker: | |
215 return Qmarker; | |
216 case Lisp_Misc_Overlay: | |
217 return Qoverlay; | |
218 case Lisp_Misc_Float: | |
219 return Qfloat; | |
220 } | |
221 abort (); | |
222 | |
223 case Lisp_Vectorlike: | |
224 if (GC_WINDOW_CONFIGURATIONP (object)) | |
225 return Qwindow_configuration; | |
226 if (GC_PROCESSP (object)) | |
227 return Qprocess; | |
228 if (GC_WINDOWP (object)) | |
229 return Qwindow; | |
230 if (GC_SUBRP (object)) | |
231 return Qsubr; | |
232 if (GC_COMPILEDP (object)) | |
233 return Qcompiled_function; | |
234 if (GC_BUFFERP (object)) | |
235 return Qbuffer; | |
236 | |
237 #ifdef MULTI_FRAME | |
238 if (GC_FRAMEP (object)) | |
239 return Qframe; | |
240 #endif | |
241 return Qvector; | |
242 | |
243 #ifdef LISP_FLOAT_TYPE | |
244 case Lisp_Float: | |
245 return Qfloat; | |
246 #endif | |
247 | |
248 default: | |
249 abort (); | |
250 } | |
251 } | |
252 | |
185 DEFUN ("consp", Fconsp, Sconsp, 1, 1, 0, "T if OBJECT is a cons cell.") | 253 DEFUN ("consp", Fconsp, Sconsp, 1, 1, 0, "T if OBJECT is a cons cell.") |
186 (obj) | 254 (object) |
187 Lisp_Object obj; | 255 Lisp_Object object; |
188 { | 256 { |
189 if (CONSP (obj)) | 257 if (CONSP (object)) |
190 return Qt; | 258 return Qt; |
191 return Qnil; | 259 return Qnil; |
192 } | 260 } |
193 | 261 |
194 DEFUN ("atom", Fatom, Satom, 1, 1, 0, "T if OBJECT is not a cons cell. This includes nil.") | 262 DEFUN ("atom", Fatom, Satom, 1, 1, 0, "T if OBJECT is not a cons cell. This includes nil.") |
195 (obj) | 263 (object) |
196 Lisp_Object obj; | 264 Lisp_Object object; |
197 { | 265 { |
198 if (CONSP (obj)) | 266 if (CONSP (object)) |
199 return Qnil; | 267 return Qnil; |
200 return Qt; | 268 return Qt; |
201 } | 269 } |
202 | 270 |
203 DEFUN ("listp", Flistp, Slistp, 1, 1, 0, "T if OBJECT is a list. This includes nil.") | 271 DEFUN ("listp", Flistp, Slistp, 1, 1, 0, "T if OBJECT is a list. This includes nil.") |
204 (obj) | 272 (object) |
205 Lisp_Object obj; | 273 Lisp_Object object; |
206 { | 274 { |
207 if (CONSP (obj) || NILP (obj)) | 275 if (CONSP (object) || NILP (object)) |
208 return Qt; | 276 return Qt; |
209 return Qnil; | 277 return Qnil; |
210 } | 278 } |
211 | 279 |
212 DEFUN ("nlistp", Fnlistp, Snlistp, 1, 1, 0, "T if OBJECT is not a list. Lists include nil.") | 280 DEFUN ("nlistp", Fnlistp, Snlistp, 1, 1, 0, "T if OBJECT is not a list. Lists include nil.") |
213 (obj) | 281 (object) |
214 Lisp_Object obj; | 282 Lisp_Object object; |
215 { | 283 { |
216 if (CONSP (obj) || NILP (obj)) | 284 if (CONSP (object) || NILP (object)) |
217 return Qnil; | 285 return Qnil; |
218 return Qt; | 286 return Qt; |
219 } | 287 } |
220 | 288 |
221 DEFUN ("symbolp", Fsymbolp, Ssymbolp, 1, 1, 0, "T if OBJECT is a symbol.") | 289 DEFUN ("symbolp", Fsymbolp, Ssymbolp, 1, 1, 0, "T if OBJECT is a symbol.") |
222 (obj) | 290 (object) |
223 Lisp_Object obj; | 291 Lisp_Object object; |
224 { | 292 { |
225 if (SYMBOLP (obj)) | 293 if (SYMBOLP (object)) |
226 return Qt; | 294 return Qt; |
227 return Qnil; | 295 return Qnil; |
228 } | 296 } |
229 | 297 |
230 DEFUN ("vectorp", Fvectorp, Svectorp, 1, 1, 0, "T if OBJECT is a vector.") | 298 DEFUN ("vectorp", Fvectorp, Svectorp, 1, 1, 0, "T if OBJECT is a vector.") |
231 (obj) | 299 (object) |
232 Lisp_Object obj; | 300 Lisp_Object object; |
233 { | 301 { |
234 if (VECTORP (obj)) | 302 if (VECTORP (object)) |
235 return Qt; | 303 return Qt; |
236 return Qnil; | 304 return Qnil; |
237 } | 305 } |
238 | 306 |
239 DEFUN ("stringp", Fstringp, Sstringp, 1, 1, 0, "T if OBJECT is a string.") | 307 DEFUN ("stringp", Fstringp, Sstringp, 1, 1, 0, "T if OBJECT is a string.") |
240 (obj) | 308 (object) |
241 Lisp_Object obj; | 309 Lisp_Object object; |
242 { | 310 { |
243 if (STRINGP (obj)) | 311 if (STRINGP (object)) |
244 return Qt; | 312 return Qt; |
245 return Qnil; | 313 return Qnil; |
246 } | 314 } |
247 | 315 |
248 DEFUN ("arrayp", Farrayp, Sarrayp, 1, 1, 0, "T if OBJECT is an array (string or vector).") | 316 DEFUN ("arrayp", Farrayp, Sarrayp, 1, 1, 0, "T if OBJECT is an array (string or vector).") |
249 (obj) | 317 (object) |
250 Lisp_Object obj; | 318 Lisp_Object object; |
251 { | 319 { |
252 if (VECTORP (obj) || STRINGP (obj)) | 320 if (VECTORP (object) || STRINGP (object)) |
253 return Qt; | 321 return Qt; |
254 return Qnil; | 322 return Qnil; |
255 } | 323 } |
256 | 324 |
257 DEFUN ("sequencep", Fsequencep, Ssequencep, 1, 1, 0, | 325 DEFUN ("sequencep", Fsequencep, Ssequencep, 1, 1, 0, |
258 "T if OBJECT is a sequence (list or array).") | 326 "T if OBJECT is a sequence (list or array).") |
259 (obj) | 327 (object) |
260 register Lisp_Object obj; | 328 register Lisp_Object object; |
261 { | 329 { |
262 if (CONSP (obj) || NILP (obj) || VECTORP (obj) || STRINGP (obj)) | 330 if (CONSP (object) || NILP (object) || VECTORP (object) || STRINGP (object)) |
263 return Qt; | 331 return Qt; |
264 return Qnil; | 332 return Qnil; |
265 } | 333 } |
266 | 334 |
267 DEFUN ("bufferp", Fbufferp, Sbufferp, 1, 1, 0, "T if OBJECT is an editor buffer.") | 335 DEFUN ("bufferp", Fbufferp, Sbufferp, 1, 1, 0, "T if OBJECT is an editor buffer.") |
268 (obj) | 336 (object) |
269 Lisp_Object obj; | 337 Lisp_Object object; |
270 { | 338 { |
271 if (BUFFERP (obj)) | 339 if (BUFFERP (object)) |
272 return Qt; | 340 return Qt; |
273 return Qnil; | 341 return Qnil; |
274 } | 342 } |
275 | 343 |
276 DEFUN ("markerp", Fmarkerp, Smarkerp, 1, 1, 0, "T if OBJECT is a marker (editor pointer).") | 344 DEFUN ("markerp", Fmarkerp, Smarkerp, 1, 1, 0, "T if OBJECT is a marker (editor pointer).") |
277 (obj) | 345 (object) |
278 Lisp_Object obj; | 346 Lisp_Object object; |
279 { | 347 { |
280 if (MARKERP (obj)) | 348 if (MARKERP (object)) |
281 return Qt; | 349 return Qt; |
282 return Qnil; | 350 return Qnil; |
283 } | 351 } |
284 | 352 |
285 DEFUN ("subrp", Fsubrp, Ssubrp, 1, 1, 0, "T if OBJECT is a built-in function.") | 353 DEFUN ("subrp", Fsubrp, Ssubrp, 1, 1, 0, "T if OBJECT is a built-in function.") |
286 (obj) | 354 (object) |
287 Lisp_Object obj; | 355 Lisp_Object object; |
288 { | 356 { |
289 if (SUBRP (obj)) | 357 if (SUBRP (object)) |
290 return Qt; | 358 return Qt; |
291 return Qnil; | 359 return Qnil; |
292 } | 360 } |
293 | 361 |
294 DEFUN ("byte-code-function-p", Fbyte_code_function_p, Sbyte_code_function_p, | 362 DEFUN ("byte-code-function-p", Fbyte_code_function_p, Sbyte_code_function_p, |
295 1, 1, 0, "T if OBJECT is a byte-compiled function object.") | 363 1, 1, 0, "T if OBJECT is a byte-compiled function object.") |
296 (obj) | 364 (object) |
297 Lisp_Object obj; | 365 Lisp_Object object; |
298 { | 366 { |
299 if (COMPILEDP (obj)) | 367 if (COMPILEDP (object)) |
300 return Qt; | 368 return Qt; |
301 return Qnil; | 369 return Qnil; |
302 } | 370 } |
303 | 371 |
304 DEFUN ("char-or-string-p", Fchar_or_string_p, Schar_or_string_p, 1, 1, 0, | 372 DEFUN ("char-or-string-p", Fchar_or_string_p, Schar_or_string_p, 1, 1, 0, |
305 "T if OBJECT is a character (an integer) or a string.") | 373 "T if OBJECT is a character (an integer) or a string.") |
306 (obj) | 374 (object) |
307 register Lisp_Object obj; | 375 register Lisp_Object object; |
308 { | 376 { |
309 if (INTEGERP (obj) || STRINGP (obj)) | 377 if (INTEGERP (object) || STRINGP (object)) |
310 return Qt; | 378 return Qt; |
311 return Qnil; | 379 return Qnil; |
312 } | 380 } |
313 | 381 |
314 DEFUN ("integerp", Fintegerp, Sintegerp, 1, 1, 0, "T if OBJECT is an integer.") | 382 DEFUN ("integerp", Fintegerp, Sintegerp, 1, 1, 0, "T if OBJECT is an integer.") |
315 (obj) | 383 (object) |
316 Lisp_Object obj; | 384 Lisp_Object object; |
317 { | 385 { |
318 if (INTEGERP (obj)) | 386 if (INTEGERP (object)) |
319 return Qt; | 387 return Qt; |
320 return Qnil; | 388 return Qnil; |
321 } | 389 } |
322 | 390 |
323 DEFUN ("integer-or-marker-p", Finteger_or_marker_p, Sinteger_or_marker_p, 1, 1, 0, | 391 DEFUN ("integer-or-marker-p", Finteger_or_marker_p, Sinteger_or_marker_p, 1, 1, 0, |
324 "T if OBJECT is an integer or a marker (editor pointer).") | 392 "T if OBJECT is an integer or a marker (editor pointer).") |
325 (obj) | 393 (object) |
326 register Lisp_Object obj; | 394 register Lisp_Object object; |
327 { | 395 { |
328 if (MARKERP (obj) || INTEGERP (obj)) | 396 if (MARKERP (object) || INTEGERP (object)) |
329 return Qt; | 397 return Qt; |
330 return Qnil; | 398 return Qnil; |
331 } | 399 } |
332 | 400 |
333 DEFUN ("natnump", Fnatnump, Snatnump, 1, 1, 0, | 401 DEFUN ("natnump", Fnatnump, Snatnump, 1, 1, 0, |
334 "T if OBJECT is a nonnegative integer.") | 402 "T if OBJECT is a nonnegative integer.") |
335 (obj) | 403 (object) |
336 Lisp_Object obj; | 404 Lisp_Object object; |
337 { | 405 { |
338 if (NATNUMP (obj)) | 406 if (NATNUMP (object)) |
339 return Qt; | 407 return Qt; |
340 return Qnil; | 408 return Qnil; |
341 } | 409 } |
342 | 410 |
343 DEFUN ("numberp", Fnumberp, Snumberp, 1, 1, 0, | 411 DEFUN ("numberp", Fnumberp, Snumberp, 1, 1, 0, |
344 "T if OBJECT is a number (floating point or integer).") | 412 "T if OBJECT is a number (floating point or integer).") |
345 (obj) | 413 (object) |
346 Lisp_Object obj; | 414 Lisp_Object object; |
347 { | 415 { |
348 if (NUMBERP (obj)) | 416 if (NUMBERP (object)) |
349 return Qt; | 417 return Qt; |
350 else | 418 else |
351 return Qnil; | 419 return Qnil; |
352 } | 420 } |
353 | 421 |
354 DEFUN ("number-or-marker-p", Fnumber_or_marker_p, | 422 DEFUN ("number-or-marker-p", Fnumber_or_marker_p, |
355 Snumber_or_marker_p, 1, 1, 0, | 423 Snumber_or_marker_p, 1, 1, 0, |
356 "T if OBJECT is a number or a marker.") | 424 "T if OBJECT is a number or a marker.") |
357 (obj) | 425 (object) |
358 Lisp_Object obj; | 426 Lisp_Object object; |
359 { | 427 { |
360 if (NUMBERP (obj) || MARKERP (obj)) | 428 if (NUMBERP (object) || MARKERP (object)) |
361 return Qt; | 429 return Qt; |
362 return Qnil; | 430 return Qnil; |
363 } | 431 } |
364 | 432 |
365 #ifdef LISP_FLOAT_TYPE | 433 #ifdef LISP_FLOAT_TYPE |
366 DEFUN ("floatp", Ffloatp, Sfloatp, 1, 1, 0, | 434 DEFUN ("floatp", Ffloatp, Sfloatp, 1, 1, 0, |
367 "T if OBJECT is a floating point number.") | 435 "T if OBJECT is a floating point number.") |
368 (obj) | 436 (object) |
369 Lisp_Object obj; | 437 Lisp_Object object; |
370 { | 438 { |
371 if (FLOATP (obj)) | 439 if (FLOATP (object)) |
372 return Qt; | 440 return Qt; |
373 return Qnil; | 441 return Qnil; |
374 } | 442 } |
375 #endif /* LISP_FLOAT_TYPE */ | 443 #endif /* LISP_FLOAT_TYPE */ |
376 | 444 |
2277 staticpro (&Qfboundp); | 2345 staticpro (&Qfboundp); |
2278 staticpro (&Qcdr); | 2346 staticpro (&Qcdr); |
2279 staticpro (&Qad_advice_info); | 2347 staticpro (&Qad_advice_info); |
2280 staticpro (&Qad_activate); | 2348 staticpro (&Qad_activate); |
2281 | 2349 |
2350 /* Types that type-of returns. */ | |
2351 Qinteger = intern ("integer"); | |
2352 Qsymbol = intern ("symbol"); | |
2353 Qstring = intern ("string"); | |
2354 Qcons = intern ("cons"); | |
2355 Qmarker = intern ("marker"); | |
2356 Qoverlay = intern ("overlay"); | |
2357 Qfloat = intern ("float"); | |
2358 Qwindow_configuration = intern ("window-configuration"); | |
2359 Qprocess = intern ("process"); | |
2360 Qwindow = intern ("window"); | |
2361 /* Qsubr = intern ("subr"); */ | |
2362 Qcompiled_function = intern ("compiled-function"); | |
2363 Qbuffer = intern ("buffer"); | |
2364 Qframe = intern ("frame"); | |
2365 Qvector = intern ("vector"); | |
2366 | |
2367 staticpro (&Qinteger); | |
2368 staticpro (&Qsymbol); | |
2369 staticpro (&Qstring); | |
2370 staticpro (&Qcons); | |
2371 staticpro (&Qmarker); | |
2372 staticpro (&Qoverlay); | |
2373 staticpro (&Qfloat); | |
2374 staticpro (&Qwindow_configuration); | |
2375 staticpro (&Qprocess); | |
2376 staticpro (&Qwindow); | |
2377 /* staticpro (&Qsubr); */ | |
2378 staticpro (&Qcompiled_function); | |
2379 staticpro (&Qbuffer); | |
2380 staticpro (&Qframe); | |
2381 staticpro (&Qvector); | |
2382 | |
2282 defsubr (&Seq); | 2383 defsubr (&Seq); |
2283 defsubr (&Snull); | 2384 defsubr (&Snull); |
2385 defsubr (&Stype_of); | |
2284 defsubr (&Slistp); | 2386 defsubr (&Slistp); |
2285 defsubr (&Snlistp); | 2387 defsubr (&Snlistp); |
2286 defsubr (&Sconsp); | 2388 defsubr (&Sconsp); |
2287 defsubr (&Satom); | 2389 defsubr (&Satom); |
2288 defsubr (&Sintegerp); | 2390 defsubr (&Sintegerp); |