Debian Codegraph @

include/ruby/internal/intern/compar.h

raw
1 #ifndef RBIMPL_INTERN_COMPAR_H /*-*-C++-*-vi:se ft=cpp:*/
2 #define RBIMPL_INTERN_COMPAR_H
3 /**
4 * @file
5 * @author Ruby developers <[email protected]>
6 * @copyright This file is a part of the programming language Ruby.
7 * Permission is hereby granted, to either redistribute and/or
8 * modify this file, provided that the conditions mentioned in the
9 * file COPYING are met. Consult the file for details.
10 * @warning Symbols prefixed with either `RBIMPL` or `rbimpl` are
11 * implementation details. Don't take them as canon. They could
12 * rapidly appear then vanish. The name (path) of this header file
13 * is also an implementation detail. Do not expect it to persist
14 * at the place it is now. Developers are free to move it anywhere
15 * anytime at will.
16 * @note To ruby-core: remember that this header can be possibly
17 * recursively included from extension libraries written in C++.
18 * Do not expect for instance `__VA_ARGS__` is always available.
19 * We assume C99 for ruby itself but we don't assume languages of
20 * extension libraries. They could be written in C++98.
21 * @brief Public APIs related to ::rb_mComparable.
22 */
23 #include "ruby/internal/attr/cold.h"
24 #include "ruby/internal/attr/noreturn.h"
25 #include "ruby/internal/dllexport.h"
26 #include "ruby/internal/value.h"
27
28 RBIMPL_SYMBOL_EXPORT_BEGIN()
29
30 /* bignum.c */
31
32 /**
33 * Canonicalises the passed `val`, which is the return value of `a <=> b`, into
34 * C's `{-1, 0, 1}`. This can be handy when you implement a callback function
35 * to pass to `qsort(3)` etc.
36 *
37 * @param[in] val Return value of a space ship operator.
38 * @param[in] a Comparison LHS.
39 * @param[in] b Comparison RHS.
40 * @exception rb_eArgError `a` and `b` are not comparable each other.
41 * @retval -1 `val` is less than zero.
42 * @retval 0 `val` is equal to zero.
43 * @retval 1 `val` is greater than zero.
44 */
45 int rb_cmpint(VALUE val, VALUE a, VALUE b);
46
47 /* compar.c */
48
49 RBIMPL_ATTR_COLD()
50 RBIMPL_ATTR_NORETURN()
51 /**
52 * Raises "comparison failed" error.
53 *
54 * @param[in] a Comparison LHS.
55 * @param[in] b Comparison RHS.
56 * @exception rb_eArgError `a` and `b` are not comparable each other.
57 */
58 void rb_cmperr(VALUE a, VALUE b);
59
60 RBIMPL_SYMBOL_EXPORT_END()
61
62 #endif /* RBIMPL_INTERN_COMPAR_H */