]> gcc.gnu.org Git - gcc.git/blame - gcc/objc/typedstream.h
More system.h cutover patches:
[gcc.git] / gcc / objc / typedstream.h
CommitLineData
1df03188 1/* GNU Objective-C Typed Streams interface.
0994488a 2 Copyright (C) 1993, 1995 Free Software Foundation, Inc.
1df03188
KKT
3
4This file is part of GNU CC.
5
6GNU CC is free software; you can redistribute it and/or modify it
7under the terms of the GNU General Public License as published by the
8Free Software Foundation; either version 2, or (at your option) any
9later version.
10
11GNU CC is distributed in the hope that it will be useful, but WITHOUT
12ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU CC; see the file COPYING. If not, write to
0af195cf
RK
18the Free Software Foundation, 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA. */
1df03188
KKT
20
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. */
26
27#ifndef __typedstream_INCLUDE_GNU
28#define __typedstream_INCLUDE_GNU
29
30#include "objc/objc.h"
31#include "objc/hash.h"
32#include <stdio.h>
33
1df03188
KKT
34typedef int (*objc_typed_read_func)(void*, char*, int);
35typedef int (*objc_typed_write_func)(void*, const char*, int);
36typedef int (*objc_typed_flush_func)(void*);
37typedef int (*objc_typed_eof_func)(void*);
38
39#define OBJC_READONLY 0x01
40#define OBJC_WRITEONLY 0x02
41
42#define OBJC_MANAGED_STREAM 0x01
43#define OBJC_FILE_STREAM 0x02
44#define OBJC_MEMORY_STREAM 0x04
45
46#define OBJC_TYPED_STREAM_VERSION 0x01
47
48typedef struct objc_typed_stream {
49 void* physical;
50 cache_ptr object_table; /* read/written objects */
51 cache_ptr stream_table; /* other read/written but shared things.. */
52 cache_ptr class_table; /* class version mapping */
53 cache_ptr object_refs; /* forward references */
54 int mode; /* OBJC_READONLY or OBJC_WRITEONLY */
55 int type; /* MANAGED, FILE, MEMORY etc bit string */
56 int version; /* version used when writing */
57 int writing_root_p;
58 objc_typed_read_func read;
59 objc_typed_write_func write;
60 objc_typed_eof_func eof;
61 objc_typed_flush_func flush;
62} TypedStream;
63
64/* opcode masks */
65#define _B_VALUE 0x1fU
66#define _B_CODE 0xe0U
67#define _B_SIGN 0x10U
68#define _B_NUMBER 0x0fU
69
70/* standard opcodes */
71#define _B_INVALID 0x00U
72#define _B_SINT 0x20U
73#define _B_NINT 0x40U
74#define _B_SSTR 0x60U
75#define _B_NSTR 0x80U
76#define _B_RCOMM 0xa0U
77#define _B_UCOMM 0xc0U
78#define _B_EXT 0xe0U
79
80/* eXtension opcodes */
81#define _BX_OBJECT 0x00U
82#define _BX_CLASS 0x01U
83#define _BX_SEL 0x02U
84#define _BX_OBJREF 0x03U
85#define _BX_OBJROOT 0x04U
86#define _BX_EXT 0x1fU
87
88/*
89** Read and write objects as specified by TYPE. All the `last'
90** arguments are pointers to the objects to read/write.
91*/
92
93int objc_write_type (TypedStream* stream, const char* type, const void* data);
94int objc_read_type (TypedStream* stream, const char* type, void* data);
95
96int objc_write_types (TypedStream* stream, const char* type, ...);
97int objc_read_types (TypedStream* stream, const char* type, ...);
98
99int objc_write_object_reference (TypedStream* stream, id object);
100int objc_write_root_object (TypedStream* stream, id object);
101
0994488a 102long objc_get_stream_class_version (TypedStream* stream, Class class);
1df03188
KKT
103
104
105/*
9faa82d8 106** Convenience functions
1df03188
KKT
107*/
108
109int objc_write_array (TypedStream* stream, const char* type,
110 int count, const void* data);
111int objc_read_array (TypedStream* stream, const char* type,
112 int count, void* data);
113
114int objc_write_object (TypedStream* stream, id object);
3ac2f5d2
KKT
115int objc_read_object (TypedStream* stream, id* object);
116
117
1df03188
KKT
118
119/*
120** Open a typed stream for reading or writing. MODE may be either of
121** OBJC_READONLY or OBJC_WRITEONLY.
122*/
123
124TypedStream* objc_open_typed_stream (FILE* physical, int mode);
125TypedStream* objc_open_typed_stream_for_file (const char* file_name, int mode);
126
127void objc_close_typed_stream (TypedStream* stream);
128
129BOOL objc_end_of_typed_stream (TypedStream* stream);
130void objc_flush_typed_stream (TypedStream* stream);
131
1df03188 132#endif /* not __typedstream_INCLUDE_GNU */
This page took 0.438811 seconds and 5 git commands to generate.