Ruby: internal/compar.h File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Data Structures | Macros | Enumerations | Functions
compar.h File Reference

Internal header for Comparable. More...

`#include "internal/vm.h"`

Go to the source code of this file.

## Data Structures
struct | cmp_opt_data

## Macros
#define | STRING_P(s) (RB_TYPE_P((s), T_STRING) && CLASS_OF(s) == rb_cString)
#define | NEW_CMP_OPT_MEMO(type, value) NEW_PARTIAL_MEMO_FOR(type, value, cmp_opt)
#define | CMP_OPTIMIZABLE_BIT(type) (1U << TOKEN_PASTE(cmp_opt_,type))
#define | CMP_OPTIMIZABLE(data, type)
#define | OPTIMIZED_CMP(a, b, data)

## Enumerations
enum | { cmp_opt_Integer , cmp_opt_String , cmp_opt_Float , cmp_optimizable_count }

## Functions
VALUE | rb_invcmp (VALUE, VALUE)

## Detailed Description

Internal header for Comparable.

Author
  Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org

Copyright
  This file is a part of the programming language Ruby. Permission is hereby granted, to either redistribute and/or modify this file, provided that the conditions mentioned in the file COPYING are met. Consult the file for details.

Definition in file compar.h.

## Macro Definition Documentation

## ◆ CMP_OPTIMIZABLE

#define CMP_OPTIMIZABLE | ( |  | data,
|  |  | type
| ) |  |

Value:
(((data).opt_inited & CMP_OPTIMIZABLE_BIT(type)) ? \
((data).opt_methods & CMP_OPTIMIZABLE_BIT(type)) : \
(((data).opt_inited |= CMP_OPTIMIZABLE_BIT(type)), \
rb_method_basic_definition_p(TOKEN_PASTE(rb_c,type), id_cmp) && \
((data).opt_methods |= CMP_OPTIMIZABLE_BIT(type))))
id_cmp
#define id_cmp
Definition: array.c:43
TOKEN_PASTE
#define TOKEN_PASTE(x, y)
Definition: config.h:38
CMP_OPTIMIZABLE_BIT
#define CMP_OPTIMIZABLE_BIT(type)
Definition: compar.h:30
ruby::backward::cxxanyargs::type
VALUE type(ANYARGS)
ANYARGS-ed function type.
Definition: cxxanyargs.hpp:56

Definition at line 31 of file compar.h.

## ◆ CMP_OPTIMIZABLE_BIT

#define CMP_OPTIMIZABLE_BIT | ( |  | type | ) | (1U << TOKEN_PASTE(cmp_opt_,type))

Definition at line 30 of file compar.h.

## ◆ NEW_CMP_OPT_MEMO

#define NEW_CMP_OPT_MEMO | ( |  | type,
|  |  | value
| ) |  | NEW_PARTIAL_MEMO_FOR(type, value, cmp_opt)

Definition at line 28 of file compar.h.

## ◆ OPTIMIZED_CMP

#define OPTIMIZED_CMP | ( |  | a,
|  |  | b,
|  |  | data
| ) |  |

Value:
((FIXNUM_P(a) && FIXNUM_P(b) && CMP_OPTIMIZABLE(data, Integer)) ? \
(((long)a > (long)b) ? 1 : ((long)a < (long)b) ? -1 : 0) : \
(STRING_P(a) && STRING_P(b) && CMP_OPTIMIZABLE(data, String)) ? \
rb_str_cmp(a, b) : \
(RB_FLOAT_TYPE_P(a) && RB_FLOAT_TYPE_P(b) && CMP_OPTIMIZABLE(data, Float)) ? \
rb_float_cmp(a, b) : \
rb_cmpint(rb_funcallv(a, id_cmp, 1, &b), a, b))
rb_str_cmp
int rb_str_cmp(VALUE, VALUE)
Definition: string.c:3378
STRING_P
#define STRING_P(s)
Definition: compar.h:14
CMP_OPTIMIZABLE
#define CMP_OPTIMIZABLE(data, type)
Definition: compar.h:31
rb_float_cmp
int rb_float_cmp(VALUE x, VALUE y)
Definition: numeric.c:1521
rb_funcallv
#define rb_funcallv(...)
Definition: internal.h:77
long
typedef long(ZCALLBACK *tell_file_func) OF((voidpf opaque
FIXNUM_P
#define FIXNUM_P
Definition: special_consts.h:44

Definition at line 38 of file compar.h.

## ◆ STRING_P

#define STRING_P | ( |  | s | ) | (RB_TYPE_P((s), T_STRING) && CLASS_OF(s) == rb_cString)

Definition at line 14 of file compar.h.

## Enumeration Type Documentation

## ◆ anonymous enum

anonymous enum

Enumerator
cmp_opt_Integer |
cmp_opt_String |
cmp_opt_Float |
cmp_optimizable_count |

Definition at line 16 of file compar.h.

## Function Documentation

## ◆ rb_invcmp()

VALUE rb_invcmp | ( | VALUE | x,
|  | VALUE | y
| ) |  |

Definition at line 50 of file compar.c.

References INT2FIX, NIL_P, Qnil, Qundef, rb_cmpint, and rb_exec_recursive().