annotate src/opaque.h @ 22:8fc7fe29b841 r19-15b94

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