2001-12-08 20:40:50 +00:00
|
|
|
/*
|
2002-10-22 14:53:18 +00:00
|
|
|
struct.h
|
2001-12-08 20:40:50 +00:00
|
|
|
|
2002-10-22 14:53:18 +00:00
|
|
|
structure support
|
2001-12-08 20:40:50 +00:00
|
|
|
|
2002-10-22 14:53:18 +00:00
|
|
|
Copyright (C) 2001 Bill Currie <bill@taniwha.org>
|
2001-12-08 20:40:50 +00:00
|
|
|
|
2002-10-22 14:53:18 +00:00
|
|
|
Author: Bill Currie <bill@taniwha.org>
|
|
|
|
Date: 2001/12/08
|
2001-12-08 20:40:50 +00:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __struct_h
|
|
|
|
#define __struct_h
|
|
|
|
|
2011-01-24 06:41:43 +00:00
|
|
|
struct def_s;
|
|
|
|
enum storage_class_e;
|
2011-01-17 13:33:33 +00:00
|
|
|
struct symbol_s;
|
|
|
|
struct symtab_s;
|
|
|
|
struct type_s;
|
2003-07-30 04:11:45 +00:00
|
|
|
|
2011-01-17 13:33:33 +00:00
|
|
|
typedef struct {
|
2002-10-16 02:05:39 +00:00
|
|
|
const char *name;
|
|
|
|
struct type_s *type;
|
2011-01-24 06:41:43 +00:00
|
|
|
void (*emit) (struct def_s *def, void *data, int index);
|
2011-01-17 13:33:33 +00:00
|
|
|
} struct_def_t;
|
|
|
|
|
[qfcc] Add a handle type for engine resources
I never liked the various hacks I had come up with for representing
resource handles in Ruamoko. Structs with an int were awkward to test,
pointers and ints could be modified, etc etc. The new @handle keyword (@
used to keep handle free for use) works just like struct, union and
enum in syntax, but creates an opaque type suitable for a 32-bit handle.
The backing type is a function so v6 progs can use it without (all the
necessary opcodes exist) and no modifications were needed for
type-checking in binary expressions, but only assignment and comparisons
are supported, and (of course) nil. Tested using cbuf_t and QFile: seems
to work as desired.
I had considered 64-bit handles, but really, if more than 4G resource
objects are needed, I'm not sure QF can handle the game. However, that
limit is per resource manager, not total.
2023-05-25 01:41:28 +00:00
|
|
|
struct symbol_s *find_handle (struct symbol_s *tag, struct type_s *type);
|
|
|
|
|
2023-02-08 02:18:42 +00:00
|
|
|
struct symtab_s *start_struct (int *su, struct symbol_s *tag,
|
|
|
|
struct symtab_s *parent);
|
2011-01-17 13:33:33 +00:00
|
|
|
struct symbol_s *find_struct (int su, struct symbol_s *tag,
|
|
|
|
struct type_s *type);
|
|
|
|
struct symbol_s *build_struct (int su, struct symbol_s *tag,
|
2022-07-31 07:56:18 +00:00
|
|
|
struct symtab_s *symtab, struct type_s *type,
|
|
|
|
int base);
|
2011-01-17 13:33:33 +00:00
|
|
|
struct symbol_s *find_enum (struct symbol_s *tag);
|
|
|
|
struct symtab_s *start_enum (struct symbol_s *enm);
|
2013-01-17 11:55:25 +00:00
|
|
|
struct symbol_s *finish_enum (struct symbol_s *sym);
|
2011-01-17 13:33:33 +00:00
|
|
|
void add_enum (struct symbol_s *enm, struct symbol_s *name,
|
|
|
|
struct expr_s *val);
|
2011-03-02 13:46:55 +00:00
|
|
|
int enum_as_bool (struct type_s *enm, struct expr_s **zero,
|
|
|
|
struct expr_s **one);
|
2011-01-17 13:33:33 +00:00
|
|
|
|
|
|
|
struct symbol_s *make_structure (const char *name, int su, struct_def_t *defs,
|
|
|
|
struct type_s *type);
|
2011-01-24 06:41:43 +00:00
|
|
|
struct def_s * emit_structure (const char *name, int su, struct_def_t *defs,
|
|
|
|
struct type_s *type, void *data,
|
2020-04-03 05:16:16 +00:00
|
|
|
struct defspace_s *space,
|
2011-01-24 06:41:43 +00:00
|
|
|
enum storage_class_e storage);
|
2003-07-30 04:11:45 +00:00
|
|
|
|
2001-12-08 20:40:50 +00:00
|
|
|
#endif//__struct_h
|