1 /* 2 * This file is part of DGD, https://github.com/dworkin/dgd 3 * Copyright (C) 1993-2010 Dworkin B.V. 4 * Copyright (C) 2010-2012 DGD Authors (see the commit log for details) 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU Affero General Public License as 8 * published by the Free Software Foundation, either version 3 of the 9 * License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU Affero General Public License for more details. 15 * 16 * You should have received a copy of the GNU Affero General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 # include "hash.h" 21 # include "swap.h" 22 23 struct _object_ { 24 hte chain; /* object name hash table */ 25 char flags; /* object status */ 26 eindex etabi; /* index in external table */ 27 uindex cref; /* # clone references (sometimes) */ 28 uindex prev; /* previous in issue list */ 29 uindex index; /* index in object table */ 30 Uint count; /* object creation count */ 31 Uint update; /* object update count */ 32 Uint ref; /* ref count (if master object) */ 33 control *ctrl; /* control block (master object only) */ 34 dataspace *data; /* dataspace block */ 35 sector cfirst; /* first sector of control block */ 36 sector dfirst; /* first sector of dataspace block */ 37 }; 38 # define u_ref ref 39 # define u_master ref 40 41 # define O_MASTER 0x01 42 # define O_AUTO 0x02 43 # define O_DRIVER 0x04 44 # define O_TOUCHED 0x08 45 # define O_USER 0x10 46 # define O_EDITOR 0x20 47 # define O_COMPILED 0x40 48 # define O_LWOBJ 0x80 49 50 # define O_SPECIAL 0x30 51 52 # define OBJ_LAYOUT "xceuuuiiippdd" 53 54 # define OBJ(i) (&otable[i]) 55 # define OBJR(i) ((BTST(ocmap, (i))) ? o_oread((i)) : &otable[i]) 56 # define OBJW(i) ((!obase) ? o_owrite((i)) : &otable[i]) 57 58 # define O_UPGRADING(o) ((o)->cref > (o)->u_ref) 59 # define O_INHERITED(o) ((o)->u_ref - 1 != (o)->cref) 60 # define O_HASDATA(o) ((o)->data != (dataspace *) NULL || \ 61 (o)->dfirst != SW_UNUSED) 62 63 # define OACC_READ 0x00 /* read access */ 64 # define OACC_MODIFY 0x01 /* write access */ 65 66 # define OBJ_NONE UINDEX_MAX 67 68 extern void o_init (unsigned int, Uint); 69 extern object *o_oread (unsigned int); 70 extern object *o_owrite (unsigned int); 71 extern void o_new_plane (void); 72 extern void o_commit_plane (void); 73 extern void o_discard_plane (void); 74 75 extern bool o_space (void); 76 extern object *o_new (char*, control*); 77 extern object *o_clone (object*); 78 extern void o_lwobj (object*); 79 extern void o_upgrade (object*, control*, frame*); 80 extern void o_upgraded (object*, object*); 81 extern void o_del (object*, frame*); 82 83 extern char *o_name (char*, object*); 84 extern char *o_builtin_name (Int); 85 extern object *o_find (char*, int); 86 extern control *o_control (object*); 87 extern dataspace *o_dataspace (object*); 88 89 extern void o_clean (void); 90 extern uindex o_count (void); 91 extern uindex o_dobjects (void); 92 extern bool o_dump (int, bool); 93 extern void o_restore (int, unsigned int, bool); 94 extern bool o_copy (Uint); 95 96 extern void swapout (void); 97 extern void dump_state (bool); 98 extern void finish (bool); 99 100 extern object *otable; 101 extern Uint *ocmap; 102 extern bool obase, swap, dump, incr, stop, boot; 103 extern Uint odcount; 104 105 106 # ifdef CLOSURES 107 # define BUILTIN_FUNCTION 0 108 # endif 109