1 /*
2 Copyright (C) 2001-2012, Parrot Foundation.
3
4 =head1 NAME
5
6 src/io/userhandle.c - IO_VTABLE and helpers for user-defined types
7
8 =head1 DESCRIPTION
9
10 This file implements the IO_VTABLE for user-defined types. It is not currently
11 used.
12
13 =head2 IO_VTABLE Functions
14
15 =over 4
16
17 =cut
18
19 */
20
21 #include "parrot/parrot.h"
22 #include "io_private.h"
23
24 /* HEADERIZER HFILE: src/io/io_private.h */
25
26 /* HEADERIZER BEGIN: static */
27 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
28
29 static INTVAL io_userhandle_close(PARROT_INTERP, ARGMOD(PMC *handle))
30 __attribute__nonnull__(1)
31 __attribute__nonnull__(2)
32 FUNC_MODIFIES(*handle);
33
34 static INTVAL io_userhandle_flush(PARROT_INTERP, ARGMOD(PMC *handle))
35 __attribute__nonnull__(1)
36 __attribute__nonnull__(2)
37 FUNC_MODIFIES(*handle);
38
39 PARROT_CAN_RETURN_NULL
40 PARROT_WARN_UNUSED_RESULT
41 static const STR_VTABLE * io_userhandle_get_encoding(PARROT_INTERP,
42 ARGIN(PMC *handle))
43 __attribute__nonnull__(1)
44 __attribute__nonnull__(2);
45
46 static INTVAL io_userhandle_get_flags(PARROT_INTERP, ARGIN(PMC *handle))
47 __attribute__nonnull__(1)
48 __attribute__nonnull__(2);
49
50 static PIOHANDLE io_userhandle_get_piohandle(PARROT_INTERP,
51 ARGIN(PMC *handle))
52 __attribute__nonnull__(1)
53 __attribute__nonnull__(2);
54
55 static INTVAL io_userhandle_is_eof(PARROT_INTERP, ARGMOD(PMC *handle))
56 __attribute__nonnull__(1)
57 __attribute__nonnull__(2)
58 FUNC_MODIFIES(*handle);
59
60 static INTVAL io_userhandle_is_open(PARROT_INTERP, ARGMOD(PMC *handle))
61 __attribute__nonnull__(1)
62 __attribute__nonnull__(2)
63 FUNC_MODIFIES(*handle);
64
65 static INTVAL io_userhandle_open(PARROT_INTERP,
66 ARGMOD(PMC *handle),
67 ARGIN(STRING *path),
68 INTVAL flags,
69 ARGIN(STRING *mode))
70 __attribute__nonnull__(1)
71 __attribute__nonnull__(2)
72 __attribute__nonnull__(3)
73 __attribute__nonnull__(5)
74 FUNC_MODIFIES(*handle);
75
76 static INTVAL io_userhandle_read_b(PARROT_INTERP,
77 ARGMOD(PMC *handle),
78 ARGOUT(char *buffer),
79 size_t byte_length)
80 __attribute__nonnull__(1)
81 __attribute__nonnull__(2)
82 __attribute__nonnull__(3)
83 FUNC_MODIFIES(*handle)
84 FUNC_MODIFIES(*buffer);
85
86 static INTVAL io_userhandle_seek(PARROT_INTERP,
87 ARGMOD(PMC *handle),
88 PIOOFF_T offset,
89 INTVAL whence)
90 __attribute__nonnull__(1)
91 __attribute__nonnull__(2)
92 FUNC_MODIFIES(*handle);
93
94 static void io_userhandle_set_flags(PARROT_INTERP,
95 ARGIN(PMC *handle),
96 INTVAL flags)
97 __attribute__nonnull__(1)
98 __attribute__nonnull__(2);
99
100 static PIOOFF_T io_userhandle_tell(PARROT_INTERP, ARGMOD(PMC *handle))
101 __attribute__nonnull__(1)
102 __attribute__nonnull__(2)
103 FUNC_MODIFIES(*handle);
104
105 static size_t io_userhandle_total_size(PARROT_INTERP, ARGIN(PMC *handle))
106 __attribute__nonnull__(1)
107 __attribute__nonnull__(2);
108
109 static INTVAL io_userhandle_write_b(PARROT_INTERP,
110 ARGMOD(PMC *handle),
111 ARGIN(char *buffer),
112 size_t byte_length)
113 __attribute__nonnull__(1)
114 __attribute__nonnull__(2)
115 __attribute__nonnull__(3)
116 FUNC_MODIFIES(*handle);
117
118 #define ASSERT_ARGS_io_userhandle_close __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
119 PARROT_ASSERT_ARG(interp) \
120 , PARROT_ASSERT_ARG(handle))
121 #define ASSERT_ARGS_io_userhandle_flush __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
122 PARROT_ASSERT_ARG(interp) \
123 , PARROT_ASSERT_ARG(handle))
124 #define ASSERT_ARGS_io_userhandle_get_encoding __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
125 PARROT_ASSERT_ARG(interp) \
126 , PARROT_ASSERT_ARG(handle))
127 #define ASSERT_ARGS_io_userhandle_get_flags __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
128 PARROT_ASSERT_ARG(interp) \
129 , PARROT_ASSERT_ARG(handle))
130 #define ASSERT_ARGS_io_userhandle_get_piohandle __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
131 PARROT_ASSERT_ARG(interp) \
132 , PARROT_ASSERT_ARG(handle))
133 #define ASSERT_ARGS_io_userhandle_is_eof __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
134 PARROT_ASSERT_ARG(interp) \
135 , PARROT_ASSERT_ARG(handle))
136 #define ASSERT_ARGS_io_userhandle_is_open __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
137 PARROT_ASSERT_ARG(interp) \
138 , PARROT_ASSERT_ARG(handle))
139 #define ASSERT_ARGS_io_userhandle_open __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
140 PARROT_ASSERT_ARG(interp) \
141 , PARROT_ASSERT_ARG(handle) \
142 , PARROT_ASSERT_ARG(path) \
143 , PARROT_ASSERT_ARG(mode))
144 #define ASSERT_ARGS_io_userhandle_read_b __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
145 PARROT_ASSERT_ARG(interp) \
146 , PARROT_ASSERT_ARG(handle) \
147 , PARROT_ASSERT_ARG(buffer))
148 #define ASSERT_ARGS_io_userhandle_seek __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
149 PARROT_ASSERT_ARG(interp) \
150 , PARROT_ASSERT_ARG(handle))
151 #define ASSERT_ARGS_io_userhandle_set_flags __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
152 PARROT_ASSERT_ARG(interp) \
153 , PARROT_ASSERT_ARG(handle))
154 #define ASSERT_ARGS_io_userhandle_tell __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
155 PARROT_ASSERT_ARG(interp) \
156 , PARROT_ASSERT_ARG(handle))
157 #define ASSERT_ARGS_io_userhandle_total_size __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
158 PARROT_ASSERT_ARG(interp) \
159 , PARROT_ASSERT_ARG(handle))
160 #define ASSERT_ARGS_io_userhandle_write_b __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
161 PARROT_ASSERT_ARG(interp) \
162 , PARROT_ASSERT_ARG(handle) \
163 , PARROT_ASSERT_ARG(buffer))
164 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
165 /* HEADERIZER END: static */
166
167 /*
168
169 =item C<void io_userhandle_setup_vtable(PARROT_INTERP, IO_VTABLE *vtable, INTVAL
170 idx)>
171
172 Setup the IO_VTABLE for custom user-defined types.
173
174 =cut
175
176 */
177
178 void
io_userhandle_setup_vtable(PARROT_INTERP,ARGMOD_NULLOK (IO_VTABLE * vtable),INTVAL idx)179 io_userhandle_setup_vtable(PARROT_INTERP, ARGMOD_NULLOK(IO_VTABLE *vtable), INTVAL idx)
180 {
181 ASSERT_ARGS(io_userhandle_setup_vtable)
182 if (vtable == NULL)
183 vtable = IO_EDITABLE_IO_VTABLE(interp, idx);
184 vtable->number = idx;
185 vtable->name = "User Handle Type";
186 /*
187 vtable->read_b = io_userhandle_read_b;
188 vtable->write_b = io_userhandle_write_b;
189 vtable->flush = io_userhandle_flush;
190 vtable->is_eof = io_userhandle_is_eof;
191 vtable->tell = io_userhandle_tell;
192 vtable->seek = io_userhandle_seek;
193 vtable->open = io_userhandle_open;
194 vtable->is_open = io_userhandle_is_open;
195 vtable->close = io_userhandle_close;
196 vtable->get_encoding = io_userhandle_get_encoding;
197 vtable->set_flags = io_userhandle_set_flags;
198 vtable->get_flags = io_userhandle_get_flags;
199 vtable->total_size = io_userhandle_total_size;
200 vtable->get_piohandle = io_userhandle_get_piohandle;
201 */
202 }
203
204
205 /*
206
207 =back
208
209 =cut
210
211 */
212
213 /*
214 * Local variables:
215 * c-file-style: "parrot"
216 * End:
217 * vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
218 */
219