| 1 |
#ifndef RBIMPL_RFILE_H /*-*-C++-*-vi:se ft=cpp:*/ |
| 2 |
#define RBIMPL_RFILE_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 Defines struct ::RFile. |
| 22 |
*/ |
| 23 |
#include "ruby/internal/core/rbasic.h" |
| 24 |
#include "ruby/internal/cast.h" |
| 25 |
|
| 26 |
/* rb_io_t is in ruby/io.h. The header file has historically not been included |
| 27 |
* into ruby/ruby.h. We follow that tradition. */ |
| 28 |
struct rb_io; |
| 29 |
|
| 30 |
/** |
| 31 |
* Ruby's File and IO. Ruby's IO are not just file descriptors. They have |
| 32 |
* buffers. They also have encodings. Various information are controlled |
| 33 |
* using this struct. |
| 34 |
*/ |
| 35 |
struct RFile { |
| 36 |
|
| 37 |
/** Basic part, including flags and class. */ |
| 38 |
struct RBasic basic; |
| 39 |
|
| 40 |
/** IO's specific fields. */ |
| 41 |
struct rb_io *fptr; |
| 42 |
}; |
| 43 |
|
| 44 |
/** |
| 45 |
* Convenient casting macro. |
| 46 |
* |
| 47 |
* @param obj An object, which is in fact an ::RFile. |
| 48 |
* @return The passed object casted to ::RFile. |
| 49 |
*/ |
| 50 |
#define RFILE(obj) RBIMPL_CAST((struct RFile *)(obj)) |
| 51 |
#endif /* RBIMPL_RFILE_H */ |