Partially sync files.el from XEmacs 21.5 for wildcard support.
[sxemacs] / src / opaque.h
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 SXEmacs
6
7 SXEmacs is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 SXEmacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program.  If not, see <http://www.gnu.org/licenses/>. */
19
20
21 /* Synched up with: Not in FSF. */
22
23 /* Written by Ben Wing, October 1993. */
24
25 #ifndef INCLUDED_opaque_h_
26 #define INCLUDED_opaque_h_
27
28 typedef struct Lisp_Opaque {
29         struct lcrecord_header header;
30         size_t size;
31         max_align_t data[1];
32 } Lisp_Opaque;
33
34 DECLARE_LRECORD(opaque, Lisp_Opaque);
35 #define XOPAQUE(x) XRECORD (x, opaque, Lisp_Opaque)
36 #define XSETOPAQUE(x, p) XSETRECORD (x, p, opaque)
37 #define OPAQUEP(x) RECORDP (x, opaque)
38 /* #define CHECK_OPAQUE(x) CHECK_RECORD (x, opaque)
39    Opaque pointers should never escape to the Lisp level, so
40    functions should not be doing this. */
41
42 /* Alternative DATA arguments to make_opaque() */
43 #define OPAQUE_CLEAR  ((const void *)  0)
44 #define OPAQUE_UNINIT ((const void *) -1)
45
46 #define OPAQUE_SIZE(op) ((op)->size)
47 #define OPAQUE_DATA(op) ((void *) ((op)->data))
48 #define XOPAQUE_SIZE(op) OPAQUE_SIZE (XOPAQUE (op))
49 #define XOPAQUE_DATA(op) OPAQUE_DATA (XOPAQUE (op))
50
51 Lisp_Object make_opaque(const void *data, size_t size);
52
53 typedef struct Lisp_Opaque_Ptr {
54         struct lcrecord_header header;
55         void *ptr;
56 } Lisp_Opaque_Ptr;
57
58 DECLARE_LRECORD(opaque_ptr, Lisp_Opaque_Ptr);
59 #define XOPAQUE_PTR(x) XRECORD (x, opaque_ptr, Lisp_Opaque_Ptr)
60 #define XSETOPAQUE_PTR(x, p) XSETRECORD (x, p, opaque_ptr)
61 #define OPAQUE_PTRP(x) RECORDP (x, opaque_ptr)
62
63 Lisp_Object make_opaque_ptr(void *val);
64 void free_opaque_ptr(Lisp_Object ptr);
65
66 #define get_opaque_ptr(op) (XOPAQUE_PTR (op)->ptr)
67 #define set_opaque_ptr(op, ptr_) (XOPAQUE_PTR (op)->ptr = (ptr_))
68
69 #endif                          /* INCLUDED_opaque_h_ */