Ruby  3.4.0dev (2024-11-22 revision 0989400a925cd201defdca9eb28eb87200b30785)
Macros | Functions
short.h File Reference

(0989400a925cd201defdca9eb28eb87200b30785)

Arithmetic conversion between C's short and Ruby's. More...

#include "ruby/internal/value.h"
#include "ruby/internal/dllexport.h"
#include "ruby/internal/special_consts.h"
Include dependency graph for short.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define RB_NUM2SHORT   rb_num2short_inline
 Just another name of rb_num2short_inline. More...
 
#define RB_NUM2USHORT   rb_num2ushort
 Just another name of rb_num2ushort. More...
 
#define NUM2SHORT   RB_NUM2SHORT
 Old name of RB_NUM2SHORT. More...
 
#define NUM2USHORT   RB_NUM2USHORT
 Old name of RB_NUM2USHORT. More...
 
#define USHORT2NUM   RB_INT2FIX
 Old name of RB_INT2FIX. More...
 
#define RB_FIX2SHORT   rb_fix2short
 Just another name of rb_fix2ushort. More...
 
#define FIX2SHORT   RB_FIX2SHORT
 Old name of RB_FIX2SHORT. More...
 

Functions

short rb_num2short (VALUE num)
 Converts an instance of rb_cNumeric into C's short. More...
 
unsigned short rb_num2ushort (VALUE num)
 Converts an instance of rb_cNumeric into C's unsigned short. More...
 
short rb_fix2short (VALUE num)
 Identical to rb_num2short(). More...
 
unsigned short rb_fix2ushort (VALUE num)
 Identical to rb_num2ushort(). More...
 
static short rb_num2short_inline (VALUE x)
 Identical to rb_num2short(). More...
 

Detailed Description

Arithmetic conversion between C's short and Ruby's.

Author
Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org
Warning
Symbols prefixed with either RBIMPL or rbimpl are implementation details. Don't take them as canon. They could rapidly appear then vanish. The name (path) of this header file is also an implementation detail. Do not expect it to persist at the place it is now. Developers are free to move it anywhere anytime at will.
Note
To ruby-core: remember that this header can be possibly recursively included from extension libraries written in C++. Do not expect for instance __VA_ARGS__ is always available. We assume C99 for ruby itself but we don't assume languages of extension libraries. They could be written in C++98.

Shyouhei wonders: why there is no SHORT2NUM, given there are both USHORT2NUM and CHR2FIX?

Definition in file short.h.

Macro Definition Documentation

◆ RB_FIX2SHORT

#define RB_FIX2SHORT   rb_fix2short

Just another name of rb_fix2ushort.

Definition at line 35 of file short.h.

◆ RB_NUM2SHORT

#define RB_NUM2SHORT   rb_num2short_inline

Just another name of rb_num2short_inline.

Definition at line 30 of file short.h.

◆ RB_NUM2USHORT

#define RB_NUM2USHORT   rb_num2ushort

Just another name of rb_num2ushort.

Definition at line 31 of file short.h.

Function Documentation

◆ rb_fix2short()

short rb_fix2short ( VALUE  num)

Identical to rb_num2short().

Parameters
[in]numSomething numeric.
Exceptions
rb_eTypeErrornum is not a numeric.
rb_eRangeErrornum is out of range of short.
Returns
The passed value converted into C's short.

Definition at line 3409 of file numeric.c.

Referenced by rb_num2short_inline().

◆ rb_fix2ushort()

unsigned short rb_fix2ushort ( VALUE  num)

Identical to rb_num2ushort().

Parameters
[in]numSomething numeric.
Exceptions
rb_eTypeErrornum is not a numeric.
rb_eRangeErrornum is out of range of unsigned short.
Returns
The passed value converted into C's unsigned short.

Definition at line 3428 of file numeric.c.

◆ rb_num2short()

short rb_num2short ( VALUE  num)

Converts an instance of rb_cNumeric into C's short.

Parameters
[in]numSomething numeric.
Exceptions
rb_eTypeErrornum is not a numeric.
rb_eRangeErrornum is out of range of short.
Returns
The passed value converted into C's short.

Definition at line 3400 of file numeric.c.

Referenced by rb_num2short_inline().

◆ rb_num2short_inline()

static short rb_num2short_inline ( VALUE  x)
inlinestatic

Identical to rb_num2short().

Parameters
[in]xSomething numeric.
Exceptions
rb_eTypeErrorx is not a numeric.
rb_eRangeErrorx is out of range of short.
Returns
The passed value converted into C's short.

Definition at line 105 of file short.h.

◆ rb_num2ushort()

unsigned short rb_num2ushort ( VALUE  num)

Converts an instance of rb_cNumeric into C's unsigned short.

Parameters
[in]numSomething numeric.
Exceptions
rb_eTypeErrornum is not a numeric.
rb_eRangeErrornum is out of range of unsigned short.
Returns
The passed value converted into C's unsigned short.

Definition at line 3418 of file numeric.c.

Referenced by rb_fix2ushort().