comparison src/opaque.c @ 442:abe6d1db359e r21-2-36

Import from CVS: tag r21-2-36
author cvs
date Mon, 13 Aug 2007 11:35:02 +0200
parents 8de8e3f6228a
children e7ef97881643
comparison
equal deleted inserted replaced
441:72a7cfa4a488 442:abe6d1db359e
42 42
43 /* Should never, ever be called. (except by an external debugger) */ 43 /* Should never, ever be called. (except by an external debugger) */
44 static void 44 static void
45 print_opaque (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) 45 print_opaque (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
46 { 46 {
47 CONST Lisp_Opaque *p = XOPAQUE (obj); 47 const Lisp_Opaque *p = XOPAQUE (obj);
48 char buf[200]; 48 char buf[200];
49 49
50 sprintf (buf, "#<INTERNAL OBJECT (XEmacs bug?) (opaque, size=%lu) 0x%lx>", 50 sprintf (buf, "#<INTERNAL OBJECT (XEmacs bug?) (opaque, size=%lu) 0x%lx>",
51 (long)(p->size), (unsigned long) p); 51 (long)(p->size), (unsigned long) p);
52 write_c_string (buf, printcharfun); 52 write_c_string (buf, printcharfun);
53 } 53 }
54 54
55 static size_t 55 static size_t
56 sizeof_opaque (CONST void *header) 56 sizeof_opaque (const void *header)
57 { 57 {
58 CONST Lisp_Opaque *p = (CONST Lisp_Opaque *) header; 58 const Lisp_Opaque *p = (const Lisp_Opaque *) header;
59 return offsetof (Lisp_Opaque, data) + p->size; 59 return offsetof (Lisp_Opaque, data) + p->size;
60 } 60 }
61 61
62 /* Return an opaque object of size SIZE. 62 /* Return an opaque object of size SIZE.
63 If DATA is OPAQUE_CLEAR, the object's data is memset to '\0' bytes. 63 If DATA is OPAQUE_CLEAR, the object's data is memset to '\0' bytes.
64 If DATA is OPAQUE_UNINIT, the object's data is uninitialized. 64 If DATA is OPAQUE_UNINIT, the object's data is uninitialized.
65 Else the object's data is initialized by copying from DATA. */ 65 Else the object's data is initialized by copying from DATA. */
66 Lisp_Object 66 Lisp_Object
67 make_opaque (CONST void *data, size_t size) 67 make_opaque (const void *data, size_t size)
68 { 68 {
69 Lisp_Opaque *p = (Lisp_Opaque *) 69 Lisp_Opaque *p = (Lisp_Opaque *)
70 alloc_lcrecord (offsetof (Lisp_Opaque, data) + size, &lrecord_opaque); 70 alloc_lcrecord (offsetof (Lisp_Opaque, data) + size, &lrecord_opaque);
71 p->size = size; 71 p->size = size;
72 72
119 119
120 /* Should never, ever be called. (except by an external debugger) */ 120 /* Should never, ever be called. (except by an external debugger) */
121 static void 121 static void
122 print_opaque_ptr (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) 122 print_opaque_ptr (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
123 { 123 {
124 CONST Lisp_Opaque_Ptr *p = XOPAQUE_PTR (obj); 124 const Lisp_Opaque_Ptr *p = XOPAQUE_PTR (obj);
125 char buf[200]; 125 char buf[200];
126 126
127 sprintf (buf, "#<INTERNAL OBJECT (XEmacs bug?) (opaque_ptr, adr=0x%lx) 0x%lx>", 127 sprintf (buf, "#<INTERNAL OBJECT (XEmacs bug?) (opaque-ptr, adr=0x%lx) 0x%lx>",
128 (long)(p->ptr), (unsigned long) p); 128 (long)(p->ptr), (unsigned long) p);
129 write_c_string (buf, printcharfun); 129 write_c_string (buf, printcharfun);
130 } 130 }
131 131
132 static int 132 static int
139 hash_opaque_ptr (Lisp_Object obj, int depth) 139 hash_opaque_ptr (Lisp_Object obj, int depth)
140 { 140 {
141 return (unsigned long) XOPAQUE_PTR (obj)->ptr; 141 return (unsigned long) XOPAQUE_PTR (obj)->ptr;
142 } 142 }
143 143
144 DEFINE_LRECORD_IMPLEMENTATION ("opaque_ptr", opaque_ptr, 144 DEFINE_LRECORD_IMPLEMENTATION ("opaque-ptr", opaque_ptr,
145 0, print_opaque_ptr, 0, 145 0, print_opaque_ptr, 0,
146 equal_opaque_ptr, hash_opaque_ptr, 0, 146 equal_opaque_ptr, hash_opaque_ptr, 0,
147 Lisp_Opaque_Ptr); 147 Lisp_Opaque_Ptr);
148 148
149 Lisp_Object 149 Lisp_Object
171 } 171 }
172 172
173 void 173 void
174 init_opaque_once_early (void) 174 init_opaque_once_early (void)
175 { 175 {
176 INIT_LRECORD_IMPLEMENTATION (opaque);
177 INIT_LRECORD_IMPLEMENTATION (opaque_ptr);
178
176 reinit_opaque_once_early (); 179 reinit_opaque_once_early ();
177 } 180 }