Import gcc-4.4.1
[dragonfly.git] / contrib / gcc-4.4 / libobjc / objc / typedstream.h
blob0d7643fbbecd6b5e84d6382d89bde9c73814dc1f
1 /* GNU Objective-C Typed Streams interface.
2 Copyright (C) 1993, 1995, 2004, 2009 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 3, or (at your option) any
9 later version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 License for more details.
16 Under Section 7 of GPL version 3, you are granted additional
17 permissions described in the GCC Runtime Library Exception, version
18 3.1, as published by the Free Software Foundation.
20 You should have received a copy of the GNU General Public License and
21 a copy of the GCC Runtime Library Exception along with this program;
22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 <http://www.gnu.org/licenses/>. */
26 #ifndef __typedstream_INCLUDE_GNU
27 #define __typedstream_INCLUDE_GNU
29 #include "objc.h"
30 #include "hash.h"
32 #include <stdio.h>
34 #ifdef __cplusplus
35 extern "C" {
36 #endif /* __cplusplus */
38 typedef int (*objc_typed_read_func)(void*, char*, int);
39 typedef int (*objc_typed_write_func)(void*, const char*, int);
40 typedef int (*objc_typed_flush_func)(void*);
41 typedef int (*objc_typed_eof_func)(void*);
43 #define OBJC_READONLY 0x01
44 #define OBJC_WRITEONLY 0x02
46 #define OBJC_MANAGED_STREAM 0x01
47 #define OBJC_FILE_STREAM 0x02
48 #define OBJC_MEMORY_STREAM 0x04
50 #define OBJC_TYPED_STREAM_VERSION 0x01
52 typedef struct objc_typed_stream {
53 void* physical;
54 cache_ptr object_table; /* read/written objects */
55 cache_ptr stream_table; /* other read/written but shared things.. */
56 cache_ptr class_table; /* class version mapping */
57 cache_ptr object_refs; /* forward references */
58 int mode; /* OBJC_READONLY or OBJC_WRITEONLY */
59 int type; /* MANAGED, FILE, MEMORY etc bit string */
60 int version; /* version used when writing */
61 int writing_root_p;
62 objc_typed_read_func read;
63 objc_typed_write_func write;
64 objc_typed_eof_func eof;
65 objc_typed_flush_func flush;
66 } TypedStream;
68 /* opcode masks */
69 #define _B_VALUE 0x1fU
70 #define _B_CODE 0xe0U
71 #define _B_SIGN 0x10U
72 #define _B_NUMBER 0x0fU
74 /* standard opcodes */
75 #define _B_INVALID 0x00U
76 #define _B_SINT 0x20U
77 #define _B_NINT 0x40U
78 #define _B_SSTR 0x60U
79 #define _B_NSTR 0x80U
80 #define _B_RCOMM 0xa0U
81 #define _B_UCOMM 0xc0U
82 #define _B_EXT 0xe0U
84 /* eXtension opcodes */
85 #define _BX_OBJECT 0x00U
86 #define _BX_CLASS 0x01U
87 #define _BX_SEL 0x02U
88 #define _BX_OBJREF 0x03U
89 #define _BX_OBJROOT 0x04U
90 #define _BX_EXT 0x1fU
93 ** Read and write objects as specified by TYPE. All the `last'
94 ** arguments are pointers to the objects to read/write.
97 int objc_write_type (TypedStream* stream, const char* type, const void* data);
98 int objc_read_type (TypedStream* stream, const char* type, void* data);
100 int objc_write_types (TypedStream* stream, const char* type, ...);
101 int objc_read_types (TypedStream* stream, const char* type, ...);
103 int objc_write_object_reference (TypedStream* stream, id object);
104 int objc_write_root_object (TypedStream* stream, id object);
106 long objc_get_stream_class_version (TypedStream* stream, Class class_type);
110 ** Convenience functions
113 int objc_write_array (TypedStream* stream, const char* type,
114 int count, const void* data);
115 int objc_read_array (TypedStream* stream, const char* type,
116 int count, void* data);
118 int objc_write_object (TypedStream* stream, id object);
119 int objc_read_object (TypedStream* stream, id* object);
124 ** Open a typed stream for reading or writing. MODE may be either of
125 ** OBJC_READONLY or OBJC_WRITEONLY.
128 TypedStream* objc_open_typed_stream (FILE* physical, int mode);
129 TypedStream* objc_open_typed_stream_for_file (const char* file_name, int mode);
131 void objc_close_typed_stream (TypedStream* stream);
133 BOOL objc_end_of_typed_stream (TypedStream* stream);
134 void objc_flush_typed_stream (TypedStream* stream);
136 #ifdef __cplusplus
138 #endif /* __cplusplus */
140 #endif /* not __typedstream_INCLUDE_GNU */