2 * Copyright (c) 2003 Matthijs Hollemans
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
26 #include <Resources.h>
27 #include <TypeConstants.h>
29 // Handle of file we're currently parsing.
32 // Name of the file we're currently parsing.
33 extern char lexfile
[];
35 // The line we're currently parsing.
40 // Describes a data type.
42 type_code code
; // type code
43 const char* name
; // name of this type
44 int32 count
; // how many fields
45 field_t
* fields
; // field definitions
46 int32 def_id
; // default resource ID
47 const char* def_name
; // default resource name
50 // Used by the lexer and parser to pass around resource data. The rdef
51 // format allows string literals to contain embedded '\0' chars, so we
52 // can't use strlen() to find their length; instead we look at the size
53 // field for that (size includes the final '\0' too).
55 type_t type
; // data type
56 char* name
; // name (only if this is a field)
57 size_t size
; // byte size of data
58 void* ptr
; // the actual data
61 // Describes a data field in a user-defined type.
63 type_t type
; // data type
64 const char* name
; // name of this field
65 size_t resize
; // if not 0, data will be resized
66 data_t data
; // default value
69 // Describes an array of data_t or field_t objects.
72 void* items
; // cast to data_t* or field_t*
75 // Used by the parser to pass around resource IDs.
83 // Describes a symbolic constant.
89 // The output file we add resources to.
90 extern BResources rsrc
;
91 extern const char* rsrc_file
;
97 void clean_up_lexer();
100 void clean_up_parser();
102 void* alloc_mem(size_t size
);
103 void free_mem(void* ptr
);
105 // Returns the data type with the specified name.
106 type_t
get_type(const char* name
);
108 void abort_compile(status_t err
, const char* format
, ...);
109 void abort_compile();