annotate src/opaque.h @ 387:f892a9d0bb8d

Added tag r21-2-8 for changeset 4af0ddfb7c5b
author cvs
date Mon, 13 Aug 2007 11:08:51 +0200
parents 064ab7fed2e0
children 74fd4e045ea6
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
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 0
diff changeset
29 typedef union {
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 0
diff changeset
30 struct { Lisp_Object obj; } obj;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 0
diff changeset
31 struct { void *p; } p;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 0
diff changeset
32 struct { double d; } d;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 0
diff changeset
33 } max_align_t;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 0
diff changeset
34
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 0
diff changeset
35 typedef struct Lisp_Opaque
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 struct lcrecord_header header;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 Lisp_Object (*markfun) (Lisp_Object obj, void (*markobj) (Lisp_Object));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 /* An integral size for non-freed objects, an opaque or nil for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 freed objects. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 Lisp_Object size_or_chain;
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 0
diff changeset
42 max_align_t data[1];
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 0
diff changeset
43 } Lisp_Opaque;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 0
diff changeset
45 typedef struct Lisp_Opaque_List
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 struct lcrecord_header header;
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 0
diff changeset
48 /* `markfun' allows you to put lisp objects inside of opaque objects
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 0
diff changeset
49 without having to create a new object type. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 Lisp_Object (*markfun) (Lisp_Object obj, void (*markobj) (Lisp_Object));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 Lisp_Object free;
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 0
diff changeset
52 size_t size;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 0
diff changeset
53 } Lisp_Opaque_List;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 0
diff changeset
55 DECLARE_LRECORD (opaque, Lisp_Opaque);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 0
diff changeset
56 #define XOPAQUE(x) XRECORD (x, opaque, Lisp_Opaque)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 #define XSETOPAQUE(x, p) XSETRECORD (x, p, opaque)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 #define OPAQUEP(x) RECORDP (x, opaque)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 #define GC_OPAQUEP(x) GC_RECORDP (x, opaque)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 /* #define CHECK_OPAQUE(x) CHECK_RECORD (x, opaque)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 Opaque pointers should never escape to the Lisp level, so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 functions should not be doing this. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 0
diff changeset
64 DECLARE_LRECORD (opaque_list, Lisp_Opaque_List);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 0
diff changeset
65 #define XOPAQUE_LIST(x) XRECORD (x, opaque_list, Lisp_Opaque_List)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 #define XSETOPAQUE_LIST(x, p) XSETRECORD (x, p, opaque_list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 #define OPAQUE_LISTP(x) RECORDP (x, opaque_list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 #define GC_OPAQUE_LISTP(x) GC_RECORDP (x, opaque_list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 /* #define CHECK_OPAQUE_LIST(x) CHECK_RECORD (x, opaque_list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 Opaque lists should never escape to the Lisp level, so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 functions should not be doing this. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 0
diff changeset
73 /* Alternative DATA arguments to make_opaque */
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 0
diff changeset
74 #define OPAQUE_CLEAR ((CONST void *) 0)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 0
diff changeset
75 #define OPAQUE_UNINIT ((CONST void *) -1)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 0
diff changeset
76
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 0
diff changeset
77 Lisp_Object make_opaque (size_t size, CONST void *data);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 Lisp_Object make_opaque_ptr (CONST void *val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 Lisp_Object make_opaque_long (long val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 void free_opaque_ptr (Lisp_Object ptr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 #define OPAQUE_SIZE(op) XINT ((op)->size_or_chain)
382
064ab7fed2e0 Import from CVS: tag r21-2-6
cvs
parents: 380
diff changeset
83 #define OPAQUE_DATA(op) ((void *) ((op)->data))
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 0
diff changeset
84 #define OPAQUE_MARKFUN(op) ((op)->markfun)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 #define XOPAQUE_SIZE(op) OPAQUE_SIZE (XOPAQUE (op))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 #define XOPAQUE_DATA(op) OPAQUE_DATA (XOPAQUE (op))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 #define XOPAQUE_MARKFUN(op) OPAQUE_MARKFUN (XOPAQUE (op))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 #define get_opaque_ptr(op) (* (void **) XOPAQUE_DATA (op))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 #define set_opaque_ptr(op, ptr) (get_opaque_ptr (op) = (void *) ptr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 #define get_opaque_long(op) (* (long *) XOPAQUE_DATA (op))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 #define set_opaque_long(op, ptr) (get_opaque_long (op) = ptr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 #define set_opaque_markfun(op, fun) (XOPAQUE_MARKFUN (op) = fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 0
diff changeset
95 Lisp_Object make_opaque_list (size_t size,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 Lisp_Object (*markfun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (Lisp_Object obj,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 void (*markobj) (Lisp_Object)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 Lisp_Object allocate_managed_opaque (Lisp_Object opaque_list,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 CONST void *data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 void free_managed_opaque (Lisp_Object opaque_list, Lisp_Object opaque);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 #endif /* _XEMACS_OPAQUE_H_ */