2007-01-11 Paolo Bonzini <bonzini@gnu.org>
[official-gcc.git] / libobjc / objc / typedstream.h
blob3a5e0b3b80cfd0427bf8cf2d434b42b439683ca8
1 /* GNU Objective-C Typed Streams interface.
2 Copyright (C) 1993, 1995, 2004 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 2, 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 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING. If not, write to
18 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
21 /* As a special exception, if you link this library with files compiled
22 with GCC to produce an executable, this does not cause the resulting
23 executable to be covered by the GNU General Public License. This
24 exception does not however invalidate any other reasons why the
25 executable file might be covered by the GNU General Public License. */
27 #ifndef __typedstream_INCLUDE_GNU
28 #define __typedstream_INCLUDE_GNU
30 #include "objc.h"
31 #include "hash.h"
33 #include <stdio.h>
35 #ifdef __cplusplus
36 extern "C" {
37 #endif /* __cplusplus */
39 typedef int (*objc_typed_read_func)(void*, char*, int);
40 typedef int (*objc_typed_write_func)(void*, const char*, int);
41 typedef int (*objc_typed_flush_func)(void*);
42 typedef int (*objc_typed_eof_func)(void*);
44 #define OBJC_READONLY 0x01
45 #define OBJC_WRITEONLY 0x02
47 #define OBJC_MANAGED_STREAM 0x01
48 #define OBJC_FILE_STREAM 0x02
49 #define OBJC_MEMORY_STREAM 0x04
51 #define OBJC_TYPED_STREAM_VERSION 0x01
53 typedef struct objc_typed_stream {
54 void* physical;
55 cache_ptr object_table; /* read/written objects */
56 cache_ptr stream_table; /* other read/written but shared things.. */
57 cache_ptr class_table; /* class version mapping */
58 cache_ptr object_refs; /* forward references */
59 int mode; /* OBJC_READONLY or OBJC_WRITEONLY */
60 int type; /* MANAGED, FILE, MEMORY etc bit string */
61 int version; /* version used when writing */
62 int writing_root_p;
63 objc_typed_read_func read;
64 objc_typed_write_func write;
65 objc_typed_eof_func eof;
66 objc_typed_flush_func flush;
67 } TypedStream;
69 /* opcode masks */
70 #define _B_VALUE 0x1fU
71 #define _B_CODE 0xe0U
72 #define _B_SIGN 0x10U
73 #define _B_NUMBER 0x0fU
75 /* standard opcodes */
76 #define _B_INVALID 0x00U
77 #define _B_SINT 0x20U
78 #define _B_NINT 0x40U
79 #define _B_SSTR 0x60U
80 #define _B_NSTR 0x80U
81 #define _B_RCOMM 0xa0U
82 #define _B_UCOMM 0xc0U
83 #define _B_EXT 0xe0U
85 /* eXtension opcodes */
86 #define _BX_OBJECT 0x00U
87 #define _BX_CLASS 0x01U
88 #define _BX_SEL 0x02U
89 #define _BX_OBJREF 0x03U
90 #define _BX_OBJROOT 0x04U
91 #define _BX_EXT 0x1fU
94 ** Read and write objects as specified by TYPE. All the `last'
95 ** arguments are pointers to the objects to read/write.
98 int objc_write_type (TypedStream* stream, const char* type, const void* data);
99 int objc_read_type (TypedStream* stream, const char* type, void* data);
101 int objc_write_types (TypedStream* stream, const char* type, ...);
102 int objc_read_types (TypedStream* stream, const char* type, ...);
104 int objc_write_object_reference (TypedStream* stream, id object);
105 int objc_write_root_object (TypedStream* stream, id object);
107 long objc_get_stream_class_version (TypedStream* stream, Class class_type);
111 ** Convenience functions
114 int objc_write_array (TypedStream* stream, const char* type,
115 int count, const void* data);
116 int objc_read_array (TypedStream* stream, const char* type,
117 int count, void* data);
119 int objc_write_object (TypedStream* stream, id object);
120 int objc_read_object (TypedStream* stream, id* object);
125 ** Open a typed stream for reading or writing. MODE may be either of
126 ** OBJC_READONLY or OBJC_WRITEONLY.
129 TypedStream* objc_open_typed_stream (FILE* physical, int mode);
130 TypedStream* objc_open_typed_stream_for_file (const char* file_name, int mode);
132 void objc_close_typed_stream (TypedStream* stream);
134 BOOL objc_end_of_typed_stream (TypedStream* stream);
135 void objc_flush_typed_stream (TypedStream* stream);
137 #ifdef __cplusplus
139 #endif /* __cplusplus */
141 #endif /* not __typedstream_INCLUDE_GNU */