aboutsummaryrefslogtreecommitdiffstats
path: root/src/lisp.h
diff options
context:
space:
mode:
authorAurélien Aptel2015-11-16 00:42:14 +0100
committerTed Zlatanov2015-11-18 14:24:06 -0500
commitf69cd6bfa114ea02f3d10ddb2fe809a26eafb9a4 (patch)
tree05788868cfcc5fda30d37a83e18de6aab8b1735b /src/lisp.h
parent435cf35bcc28ab4220764dff7874f477310d9a48 (diff)
downloademacs-f69cd6bfa114ea02f3d10ddb2fe809a26eafb9a4.tar.gz
emacs-f69cd6bfa114ea02f3d10ddb2fe809a26eafb9a4.zip
Add new User Pointer (User_Ptr) type
* src/lisp.h: Add new Lisp_Misc_User_Ptr type. (XUSER_PTR): New User_Ptr accessor. * src/alloc.c (make_user_ptr): New function. (mark_object, sweep_misc): Handle Lisp_Misc_User_Ptr. * src/data.c (Ftype_of): Return 'user-ptr' for user pointer. (Fuser-ptrp): New user pointer type predicate function. (syms_of_data): New 'user-ptrp', 'user-ptr' symbol. New 'user-ptrp' subr. * src/print.c (print_object): Add printer for User_Ptr type.
Diffstat (limited to 'src/lisp.h')
-rw-r--r--src/lisp.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/lisp.h b/src/lisp.h
index cab912e7401..02c19690adf 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -468,6 +468,9 @@ enum Lisp_Misc_Type
468 Lisp_Misc_Overlay, 468 Lisp_Misc_Overlay,
469 Lisp_Misc_Save_Value, 469 Lisp_Misc_Save_Value,
470 Lisp_Misc_Finalizer, 470 Lisp_Misc_Finalizer,
471#ifdef HAVE_MODULES
472 Lisp_Misc_User_Ptr,
473#endif
471 /* Currently floats are not a misc type, 474 /* Currently floats are not a misc type,
472 but let's define this in case we want to change that. */ 475 but let's define this in case we want to change that. */
473 Lisp_Misc_Float, 476 Lisp_Misc_Float,
@@ -581,6 +584,12 @@ INLINE bool PROCESSP (Lisp_Object);
581INLINE bool PSEUDOVECTORP (Lisp_Object, int); 584INLINE bool PSEUDOVECTORP (Lisp_Object, int);
582INLINE bool SAVE_VALUEP (Lisp_Object); 585INLINE bool SAVE_VALUEP (Lisp_Object);
583INLINE bool FINALIZERP (Lisp_Object); 586INLINE bool FINALIZERP (Lisp_Object);
587
588#ifdef HAVE_MODULES
589INLINE bool USER_PTRP (Lisp_Object);
590INLINE struct Lisp_User_Ptr *(XUSER_PTR) (Lisp_Object);
591#endif
592
584INLINE void set_sub_char_table_contents (Lisp_Object, ptrdiff_t, 593INLINE void set_sub_char_table_contents (Lisp_Object, ptrdiff_t,
585 Lisp_Object); 594 Lisp_Object);
586INLINE bool STRINGP (Lisp_Object); 595INLINE bool STRINGP (Lisp_Object);
@@ -2230,6 +2239,18 @@ XSAVE_OBJECT (Lisp_Object obj, int n)
2230 return XSAVE_VALUE (obj)->data[n].object; 2239 return XSAVE_VALUE (obj)->data[n].object;
2231} 2240}
2232 2241
2242#ifdef HAVE_MODULES
2243struct Lisp_User_Ptr
2244{
2245 ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_User_Ptr */
2246 bool_bf gcmarkbit : 1;
2247 unsigned spacer : 15;
2248
2249 void (*finalizer) (void*);
2250 void *p;
2251};
2252#endif
2253
2233/* A finalizer sentinel. */ 2254/* A finalizer sentinel. */
2234struct Lisp_Finalizer 2255struct Lisp_Finalizer
2235 { 2256 {
@@ -2265,6 +2286,9 @@ union Lisp_Misc
2265 struct Lisp_Overlay u_overlay; 2286 struct Lisp_Overlay u_overlay;
2266 struct Lisp_Save_Value u_save_value; 2287 struct Lisp_Save_Value u_save_value;
2267 struct Lisp_Finalizer u_finalizer; 2288 struct Lisp_Finalizer u_finalizer;
2289#ifdef HAVE_MODULES
2290 struct Lisp_User_Ptr u_user_ptr;
2291#endif
2268 }; 2292 };
2269 2293
2270INLINE union Lisp_Misc * 2294INLINE union Lisp_Misc *
@@ -2314,6 +2338,16 @@ XFINALIZER (Lisp_Object a)
2314 return & XMISC (a)->u_finalizer; 2338 return & XMISC (a)->u_finalizer;
2315} 2339}
2316 2340
2341#ifdef HAVE_MODULES
2342INLINE struct Lisp_User_Ptr *
2343XUSER_PTR (Lisp_Object a)
2344{
2345 eassert (USER_PTRP (a));
2346 return & XMISC (a)->u_user_ptr;
2347}
2348#endif
2349
2350
2317 2351
2318/* Forwarding pointer to an int variable. 2352/* Forwarding pointer to an int variable.
2319 This is allowed only in the value cell of a symbol, 2353 This is allowed only in the value cell of a symbol,
@@ -2598,6 +2632,14 @@ FINALIZERP (Lisp_Object x)
2598 return MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Finalizer; 2632 return MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Finalizer;
2599} 2633}
2600 2634
2635#ifdef HAVE_MODULES
2636INLINE bool
2637USER_PTRP (Lisp_Object x)
2638{
2639 return MISCP (x) && XMISCTYPE (x) == Lisp_Misc_User_Ptr;
2640}
2641#endif
2642
2601INLINE bool 2643INLINE bool
2602AUTOLOADP (Lisp_Object x) 2644AUTOLOADP (Lisp_Object x)
2603{ 2645{
@@ -3870,6 +3912,11 @@ Lisp_Object backtrace_top_function (void);
3870extern bool let_shadows_buffer_binding_p (struct Lisp_Symbol *symbol); 3912extern bool let_shadows_buffer_binding_p (struct Lisp_Symbol *symbol);
3871extern bool let_shadows_global_binding_p (Lisp_Object symbol); 3913extern bool let_shadows_global_binding_p (Lisp_Object symbol);
3872 3914
3915#ifdef HAVE_MODULES
3916/* Defined in alloc.c. */
3917extern Lisp_Object make_user_ptr (void (*finalizer) (void*), void *p);
3918
3919#endif
3873 3920
3874/* Defined in editfns.c. */ 3921/* Defined in editfns.c. */
3875extern void insert1 (Lisp_Object); 3922extern void insert1 (Lisp_Object);