> -----Original Message-----
> From: Ben Wing [mailto:ben@666.com]
> Sent: Monday, June 05, 2000 7:56 PM
> To: Andrew Begel
> Cc: 'xemacs-beta(a)xemacs.org'
> Subject: Re: Patches for lrecords to support dynamic modules which
> define new types.
>
>
> this looks pretty good, although you should definitely
> eliminate the references
> to pgresult and instead use a dummy enum at the end of the
> table. also, send
> patches to xemacs-patches(a)xemacs.org.
>
Here are updated patches:
Index: ChangeLog
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/ChangeLog,v
retrieving revision 1.154.2.610
diff -u -r1.154.2.610 ChangeLog
--- ChangeLog 2000/06/05 10:35:19 1.154.2.610
+++ ChangeLog 2000/06/06 03:18:08
@@ -1,3 +1,22 @@
+2000-06-05 Andrew Begel (abegel(a)cs.berkeley.edu>
+ * lrecord.h (lrecord_types): Changed lrecord_type_count to an
+ unsigned int and changed the last enum to
+ lrecord_type_last_built_in_type.
+ (lrecord_implementations_table): changed prototype to know how
+ long the array is supposed to be.
+ (lrecord_type_count): new unsigned int to keep track of the
+ current number of lisp lrecord types.
+ (DEFINE_EXTERNAL_LRECORD):
+ (DECLARE_EXTERNAL_LRECORD): Added these two for external
+ dynamic-modules to declare new lisp types. They are the same
+ as the non-EXTERNAL forms, but declare an lrecord_type unsigned
+ int for each new type, and increment lrecord_type_count by 1.
+
+ * alloc.c (lrecord_implementations_table): Changed to reference
+ lrecord_type_last_built_in_type for the size of the array.
+ Moved MODULE_DEFINABLE_TYPE_COUNT to lrecord.h.
+
+
2000-06-05 Yoshiki Hayashi <yoshiki(a)xemacs.org>
* data.c (Faset): Don't cast XCHAR() to unsigned char.
Index: alloc.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/alloc.c,v
retrieving revision 1.42.2.61
diff -u -r1.42.2.61 alloc.c
--- alloc.c 2000/05/01 11:00:02 1.42.2.61
+++ alloc.c 2000/06/06 03:07:25
@@ -2349,8 +2349,9 @@
/* All the built-in lisp object types are enumerated in `enum
lrecord_type'.
Additional ones may be defined by a module (none yet). We leave some
room in `lrecord_implementations_table' for such new lisp object types.
*/
-#define MODULE_DEFINABLE_TYPE_COUNT 32
-const struct lrecord_implementation
*lrecord_implementations_table[lrecord_type_count +
MODULE_DEFINABLE_TYPE_COUNT];
+const struct lrecord_implementation
*lrecord_implementations_table[(unsigned int)lrecord_type_last_built_in_type
+ MODULE_DEFINABLE_TYPE_COUNT];
+
+unsigned int lrecord_type_count = (unsigned
int)lrecord_type_last_built_in_type;
Index: lrecord.h
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/lrecord.h,v
retrieving revision 1.8.2.28
diff -u -r1.8.2.28 lrecord.h
--- lrecord.h 2000/04/14 07:54:42 1.8.2.28
+++ lrecord.h 2000/06/06 03:07:26
@@ -186,9 +186,15 @@
lrecord_type_ldap,
lrecord_type_pgconn,
lrecord_type_pgresult,
- lrecord_type_count /* must be last */
+ lrecord_type_last_built_in_type /* must be last */
};
+extern unsigned int lrecord_type_count;
+
struct lrecord_implementation
{
const char *name;
@@ -258,7 +264,16 @@
unsigned int basic_p :1;
};
-extern const struct lrecord_implementation
*lrecord_implementations_table[];
+/* All the built-in lisp object types are enumerated in `enum
lrecord_type'.
+ Additional ones may be defined by a module (none yet). We leave some
+ room in `lrecord_implementations_table' for such new lisp object types.
*/
+#define MODULE_DEFINABLE_TYPE_COUNT 32
+
+extern const struct lrecord_implementation
*lrecord_implementations_table[(unsigned int)lrecord_type_last_built_in_type
+ MODULE_DEFINABLE_TYPE_COUNT];
#define XRECORD_LHEADER_IMPLEMENTATION(obj) \
LHEADER_IMPLEMENTATION (XRECORD_LHEADER (obj))
@@ -454,7 +469,34 @@
getprop, putprop, remprop, plist, size, sizer, \
lrecord_type_##c_name, basic_p }
+
+
+#define
DEFINE_EXTERNAL_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equa
l,hash,desc,structtype) \
+DEFINE_EXTERNAL_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printe
r,nuker,equal,hash,desc,0,0,0,0,structtype)
+
+#define
DEFINE_EXTERNAL_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer
,nuker,equal,hash,desc,getprop,putprop,remprop,plist,structtype) \
+MAKE_EXTERNAL_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal
,hash,desc,getprop,putprop,remprop,plist,sizeof (structtype),0,0,structtype)
+
+#define
DEFINE_EXTERNAL_LRECORD_SEQUENCE_IMPLEMENTATION(name,c_name,marker,printer,n
uker,equal,hash,desc,sizer,structtype) \
+DEFINE_EXTERNAL_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS(name,c_name,mark
er,printer,nuker,equal,hash,desc,0,0,0,0,sizer,structtype)
+
+#define
DEFINE_EXTERNAL_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS(name,c_name,marke
r,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizer,structty
pe) \
+MAKE_EXTERNAL_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal
,hash,desc,getprop,putprop,remprop,plist,0,sizer,0,structtype) \
+
+#define
MAKE_EXTERNAL_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,
hash,desc,getprop,putprop,remprop,plist,size,sizer,basic_p,structtype) \
+DECLARE_ERROR_CHECK_TYPECHECK(c_name, structtype) \
+unsigned int lrecord_type_##c_name = lrecord_type_count++; \
+const struct lrecord_implementation lrecord_##c_name = \
+ { name, marker, printer, nuker, equal, hash, desc, \
+ getprop, putprop, remprop, plist, size, sizer, \
+ (enum lrecord_type)lrecord_type_##c_name, basic_p }
+
+
extern Lisp_Object (*lrecord_markers[]) (Lisp_Object);
#define INIT_LRECORD_IMPLEMENTATION(type) do { \
lrecord_implementations_table[lrecord_type_##type] = &lrecord_##type;
\
@@ -466,7 +508,7 @@
#define XRECORD_LHEADER(a) ((struct lrecord_header *) XPNTR (a))
#define RECORD_TYPEP(x, ty) \
- (LRECORDP (x) && XRECORD_LHEADER (x)->type == (ty))
+ (LRECORDP (x) && (((unsigned int)(XRECORD_LHEADER (x)->type)) ==
((unsigned int)(ty))))
/* NOTE: the DECLARE_LRECORD() must come before the associated
DEFINE_LRECORD_*() or you will get compile errors.
@@ -491,6 +533,10 @@
} \
extern Lisp_Object Q##c_name##p
+# define DECLARE_EXTERNAL_LRECORD(c_name, structtype) \
+extern unsigned int lrecord_type_##c_name; \
+DECLARE_LRECORD(c_name, structtype)
+
# define DECLARE_NONRECORD(c_name, type_enum, structtype) \
INLINE_HEADER structtype * \
error_check_##c_name (Lisp_Object obj); \
@@ -515,6 +561,10 @@
# define DECLARE_LRECORD(c_name, structtype) \
extern Lisp_Object Q##c_name##p; \
+extern const struct lrecord_implementation lrecord_##c_name
+# define DECLARE_EXTERNAL_LRECORD(c_name, structtype) \
+extern Lisp_Object Q##c_name##p; \
+extern unsigned int lrecord_type_##c_name; \
extern const struct lrecord_implementation lrecord_##c_name
# define DECLARE_NONRECORD(c_name, type_enum, structtype) \
extern Lisp_Object Q##c_name##p