comparison src/opaque.h @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children 8626e4521993
comparison
equal deleted inserted replaced
-1:000000000000 0:376386a54a3c
1 /* Opaque Lisp objects.
2 Copyright (C) 1993 Sun Microsystems, Inc.
3 Copyright (C) 1995, 1996 Ben Wing.
4
5 This file is part of XEmacs.
6
7 XEmacs is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
10 later version.
11
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with XEmacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22 /* Synched up with: Not in FSF. */
23
24 /* Written by Ben Wing, October 1993. */
25
26 #ifndef _XEMACS_OPAQUE_H_
27 #define _XEMACS_OPAQUE_H_
28
29 struct Lisp_Opaque
30 {
31 struct lcrecord_header header;
32 Lisp_Object (*markfun) (Lisp_Object obj, void (*markobj) (Lisp_Object));
33 /* An integral size for non-freed objects, an opaque or nil for
34 freed objects. */
35 Lisp_Object size_or_chain;
36 /* It's actually more space-efficient to declare this as an int
37 rather than a char, because the structure will get rounded up
38 in size by the compiler anyway. */
39 int data[1];
40 };
41
42 struct Lisp_Opaque_List
43 {
44 struct lcrecord_header header;
45 Lisp_Object (*markfun) (Lisp_Object obj, void (*markobj) (Lisp_Object));
46 Lisp_Object free;
47 int size;
48 };
49
50 DECLARE_LRECORD (opaque, struct Lisp_Opaque);
51 #define XOPAQUE(x) XRECORD (x, opaque, struct Lisp_Opaque)
52 #define XSETOPAQUE(x, p) XSETRECORD (x, p, opaque)
53 #define OPAQUEP(x) RECORDP (x, opaque)
54 #define GC_OPAQUEP(x) GC_RECORDP (x, opaque)
55 /* #define CHECK_OPAQUE(x) CHECK_RECORD (x, opaque)
56 Opaque pointers should never escape to the Lisp level, so
57 functions should not be doing this. */
58
59 DECLARE_LRECORD (opaque_list, struct Lisp_Opaque_List);
60 #define XOPAQUE_LIST(x) XRECORD (x, opaque_list, struct Lisp_Opaque_List)
61 #define XSETOPAQUE_LIST(x, p) XSETRECORD (x, p, opaque_list)
62 #define OPAQUE_LISTP(x) RECORDP (x, opaque_list)
63 #define GC_OPAQUE_LISTP(x) GC_RECORDP (x, opaque_list)
64 /* #define CHECK_OPAQUE_LIST(x) CHECK_RECORD (x, opaque_list)
65 Opaque lists should never escape to the Lisp level, so
66 functions should not be doing this. */
67
68 Lisp_Object make_opaque (int size, CONST void *data);
69 Lisp_Object make_opaque_ptr (CONST void *val);
70 Lisp_Object make_opaque_long (long val);
71 void free_opaque_ptr (Lisp_Object ptr);
72
73 #define OPAQUE_SIZE(op) XINT ((op)->size_or_chain)
74 #define OPAQUE_DATA(op) ((op)->data)
75 #define OPAQUE_MARKFUN(op) ((op)->markfun) /* What's the point if this? */
76 #define XOPAQUE_SIZE(op) OPAQUE_SIZE (XOPAQUE (op))
77 #define XOPAQUE_DATA(op) OPAQUE_DATA (XOPAQUE (op))
78 #define XOPAQUE_MARKFUN(op) OPAQUE_MARKFUN (XOPAQUE (op))
79
80 #define get_opaque_ptr(op) (* (void **) XOPAQUE_DATA (op))
81 #define set_opaque_ptr(op, ptr) (get_opaque_ptr (op) = (void *) ptr)
82 #define get_opaque_long(op) (* (long *) XOPAQUE_DATA (op))
83 #define set_opaque_long(op, ptr) (get_opaque_long (op) = ptr)
84 #define set_opaque_markfun(op, fun) (XOPAQUE_MARKFUN (op) = fun)
85
86 Lisp_Object make_opaque_list (int size,
87 Lisp_Object (*markfun)
88 (Lisp_Object obj,
89 void (*markobj) (Lisp_Object)));
90 Lisp_Object allocate_managed_opaque (Lisp_Object opaque_list,
91 CONST void *data);
92 void free_managed_opaque (Lisp_Object opaque_list, Lisp_Object opaque);
93
94 #endif /* _XEMACS_OPAQUE_H_ */