Ruby  3.4.0dev (2024-11-22 revision 37a72b0150ec36b4ea27175039afc28c62207b0c)
short.h
Go to the documentation of this file.
1 #ifndef RBIMPL_ARITHMETIC_SHORT_H /*-*-C++-*-vi:se ft=cpp:*/
2 #define RBIMPL_ARITHMETIC_SHORT_H
26 #include "ruby/internal/value.h"
29 
30 #define RB_NUM2SHORT rb_num2short_inline
31 #define RB_NUM2USHORT rb_num2ushort
32 #define NUM2SHORT RB_NUM2SHORT
33 #define NUM2USHORT RB_NUM2USHORT
34 #define USHORT2NUM RB_INT2FIX
35 #define RB_FIX2SHORT rb_fix2short
36 #define FIX2SHORT RB_FIX2SHORT
39 
40 
48 short rb_num2short(VALUE num);
49 
58 unsigned short rb_num2ushort(VALUE num);
59 
73 short rb_fix2short(VALUE num);
74 
88 unsigned short rb_fix2ushort(VALUE num);
90 
104 static inline short
106 {
107  if (RB_FIXNUM_P(x))
108  return rb_fix2short(x);
109  else
110  return rb_num2short(x);
111 }
112 
113 #endif /* RBIMPL_ARITHMETIC_SHORT_H */
Tweaking visibility of C variables/functions.
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition: dllexport.h:74
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition: dllexport.h:65
#define inline
Old Visual Studio versions do not support the inline keyword, so we need to define it to be __inline.
Definition: defines.h:88
short rb_num2short(VALUE num)
Converts an instance of rb_cNumeric into C's short.
Definition: numeric.c:3400
unsigned short rb_num2ushort(VALUE num)
Converts an instance of rb_cNumeric into C's unsigned short.
Definition: numeric.c:3418
short rb_fix2short(VALUE num)
Identical to rb_num2short().
Definition: numeric.c:3409
unsigned short rb_fix2ushort(VALUE num)
Identical to rb_num2ushort().
Definition: numeric.c:3428
static short rb_num2short_inline(VALUE x)
Identical to rb_num2short().
Definition: short.h:105
Defines enum ruby_special_consts.
static bool RB_FIXNUM_P(VALUE obj)
Checks if the given object is a so-called Fixnum.
Defines VALUE and ID.
uintptr_t VALUE
Type that represents a Ruby object.
Definition: value.h:40