-
Notifications
You must be signed in to change notification settings - Fork 609
/
io.hpp
95 lines (69 loc) · 1.9 KB
/
io.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#ifndef RBX_BUILTIN_IO_HPP
#define RBX_BUILTIN_IO_HPP
#include "builtin/object.hpp"
#include "type_info.hpp"
namespace rubinius {
class String;
class IO : public Object {
public:
const static size_t fields = 3;
const static object_type type = IOType;
private:
FIXNUM descriptor_; // slot
OBJECT buffer_; // slot
OBJECT mode_; // slot
public:
/* accessors */
attr_accessor(descriptor, Fixnum);
attr_accessor(buffer, Object);
attr_accessor(mode, Object);
/* interface */
native_int to_fd();
static void init(STATE);
static IO* create(STATE, int fd);
void initialize(STATE, int fd, char* mode);
// Ruby.primitive :io_seek
INTEGER seek(STATE, INTEGER amount, FIXNUM whence);
// Ruby.primitive :io_write
OBJECT write(STATE, String* buf);
// Ruby.primitive :io_open
static FIXNUM open(STATE, String* path, FIXNUM mode, FIXNUM perm);
// Ruby.primitive :io_close
OBJECT close(STATE);
// Ruby.primitive :io_blocking_read
OBJECT blocking_read(STATE, FIXNUM count);
// Ruby.primitive :io_query
OBJECT query(STATE, SYMBOL op);
class Info : public TypeInfo {
public:
BASIC_TYPEINFO(TypeInfo)
};
};
class IOBuffer : public Object {
public:
const static size_t fields = 3;
const static object_type type = IOBufferType;
private:
OBJECT storage_; // slot
INTEGER total_; // slot
INTEGER used_; // slot
public:
/* accessors */
attr_accessor(storage, Object);
attr_accessor(total, Integer);
attr_accessor(used, Integer);
/* interface */
static IOBuffer* create(STATE, size_t bytes);
void reset(STATE);
String* drain(STATE);
char* byte_address();
size_t left();
char* at_unused();
void read_bytes(STATE, size_t bytes);
class Info : public TypeInfo {
public:
BASIC_TYPEINFO(TypeInfo)
};
};
};
#endif