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.
Andrew Begel wrote:
Here's a list of all the patches I made to the latest sources I
checked out
of the CVS tree.
(There may be some discrepancies in the line numbering since I doctored the
output to get rid of extra changes that aren't relevant to this issue).
Basically, I changed lrecord_type_count from the last enum in lrecord_type
to an unsigned int global variable (which records what the next unused
lrecord type number is). I modified the declaration of
lrecord_implementations_table in lrecord.h to know how big it was supposed
to be statically at compile-time.
There are two new macros for DLLs to define new types:
DEFINE_EXTERNAL_LRECORD and
DECLARE_EXTERNAL_LRECORD
These are exactly the same as the non-EXTERNAL forms, but define the extra
lrecord_type_##c_name unsigned int variable that each new type needs.
andrew
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/05 23:07:01
@@ -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_pgresult + 1 +
MODULE_DEFINABLE_TYPE_COUNT];
+
+unsigned int lrecord_type_count = (unsigned int)lrecord_type_pgresult + 1;
/* Object marker functions are in the lrecord_implementation structure.
But copying them to a parallel array is much more cache-friendly.
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/05 23:07:02
@@ -185,10 +185,15 @@
lrecord_type_tooltalk_pattern,
lrecord_type_ldap,
lrecord_type_pgconn,
- lrecord_type_pgresult,
- lrecord_type_count /* must be last */
+ lrecord_type_pgresult
};
+extern unsigned int lrecord_type_count;
+
struct lrecord_implementation
{
const char *name;
@@ -258,7 +263,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_pgresult + 1 +
MODULE_DEFINABLE_TYPE_COUNT];
#define XRECORD_LHEADER_IMPLEMENTATION(obj) \
LHEADER_IMPLEMENTATION (XRECORD_LHEADER (obj))
@@ -454,7 +468,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 +507,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 +532,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 +560,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
--
Ben
In order to save my hands, I am cutting back on my mail. I also write
as succinctly as possible -- please don't be offended. If you send me
mail, you _will_ get a response, but please be patient, especially for
XEmacs-related mail. If you need an immediate response and it is not
apparent in your message, please say so. Thanks for your understanding.
See also
http://www.666.com/ben/chronic-pain/