Ruby: include/ruby/internal/arithmetic/short.h Source File

Ruby 3.4.1p0 (2024-12-25 revision 48d4efcb85000e1ebae42004e963b5d0cedddcf2)

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"
27#include "ruby/internal/dllexport.h"
28#include "ruby/internal/special_consts.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
37
38 RBIMPL_SYMBOL_EXPORT_BEGIN()
39
40
48short rb_num2short(VALUE num);
49
58unsigned short rb_num2ushort(VALUE num);
59
73short rb_fix2short(VALUE num);
74
88unsigned short rb_fix2ushort(VALUE num);
89 RBIMPL_SYMBOL_EXPORT_END()
90
104static inline short
105rb_num2short_inline(VALUE x)
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 */
dllexport.h
Tweaking visibility of C variables/functions.
RBIMPL_SYMBOL_EXPORT_END
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition dllexport.h:74
RBIMPL_SYMBOL_EXPORT_BEGIN
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition dllexport.h:65
inline
#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
rb_num2short
short rb_num2short(VALUE num)
Converts an instance of rb_cNumeric into C's short.
Definition numeric.c:3400
rb_num2ushort
unsigned short rb_num2ushort(VALUE num)
Converts an instance of rb_cNumeric into C's unsigned short.
Definition numeric.c:3418
rb_fix2short
short rb_fix2short(VALUE num)
Identical to rb_num2short().
Definition numeric.c:3409
rb_fix2ushort
unsigned short rb_fix2ushort(VALUE num)
Identical to rb_num2ushort().
Definition numeric.c:3428
rb_num2short_inline
static short rb_num2short_inline(VALUE x)
Identical to rb_num2short().
Definition short.h:105
special_consts.h
Defines enum ruby_special_consts.
RB_FIXNUM_P
static bool RB_FIXNUM_P(VALUE obj)
Checks if the given object is a so-called Fixnum.
Definition special_consts.h:247
value.h
Defines VALUE and ID.
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40