This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

A small patch



I hope this trivial patch (against current anoncvs sources) can make
it into 1.3, it would help clean up the scwm source code in a couple
of places.

Basically, it adds support for SCM_VCELL_INIT and
SCM_GLOBAL_VCELL_INIT macros to guile-snarf; these do the same thing
as the non-_INIT versions, but take an extra argument specifying an
initial value for the variable. SCM_CONST_LONG is also reimplemented
in terms of SCM_VCELL_INIT, since it is really just a special case.

ChangeLog entry (feel free to edit):

Mon Sep 28 21:37:14 1998  Maciej Stachowiak  <mstachow@mit.edu>

	* snarf.h: Add SCM_VCELL_INIT and SCM_GLOBAL_VCELL_INIT macros;
 	these are analogous to SCM_VCELL and SCM_GLOBAL_VCELL but take a
 	third argument, a C expression that should result in a SCM value,
 	which is used to initialize the variable. Reimplemented
 	SCM_CONST_LONG in terms of SCM_VCELL_INIT.

Patch:

Index: libguile/snarf.h
===================================================================
RCS file: /egcs/carton/cvsfiles/guile/guile-core/libguile/snarf.h,v
retrieving revision 1.6
diff -u -r1.6 snarf.h
--- snarf.h	1997/05/26 22:33:58	1.6
+++ snarf.h	1998/09/29 01:34:30
@@ -1,3 +1,4 @@
+
 /* classes: h_files */
 
 /* Macros for snarfing initialization actions from C source. */
@@ -109,13 +110,30 @@
 %%%	C_NAME = scm_permanent_object (scm_intern0 (SCHEME_NAME)); SCM_SETCDR (C_NAME, SCM_BOOL_F)
 #endif
 
+#ifndef SCM_MAGIC_SNARFER
+#define SCM_GLOBAL_VCELL(c_name, scheme_name) \
+	SCM c_name = SCM_BOOL_F
+#else
+#define SCM_GLOBAL_VCELL(C_NAME, SCHEME_NAME) \
+%%%	C_NAME = scm_permanent_object (scm_intern0 (SCHEME_NAME)); SCM_SETCDR (C_NAME, SCM_BOOL_F)
+#endif
 
 #ifndef SCM_MAGIC_SNARFER
-#define SCM_CONST_LONG(C_NAME, SCHEME_NAME,VALUE) \
-	static SCM C_NAME = SCM_BOOL_F
+#define SCM_VCELL_INIT(c_name, scheme_name, init_val) \
+	static SCM c_name = SCM_BOOL_F
 #else
-#define SCM_CONST_LONG(C_NAME, SCHEME_NAME,VALUE) \
-%%%	C_NAME = scm_permanent_object (scm_intern0 (SCHEME_NAME)); SCM_SETCDR (C_NAME, scm_long2num (VALUE))
+#define SCM_VCELL_INIT(C_NAME, SCHEME_NAME, init_val) \
+%%%	C_NAME = scm_permanent_object (scm_intern0 (SCHEME_NAME)); SCM_SETCDR (C_NAME, init_val)
 #endif
+
+#ifndef SCM_MAGIC_SNARFER
+#define SCM_GLOBAL_VCELL_INIT(c_name, scheme_name, init_val) \
+	SCM c_name = SCM_BOOL_F
+#else
+#define SCM_GLOBAL_VCELL_INIT(C_NAME, SCHEME_NAME, init_val) \
+%%%	C_NAME = scm_permanent_object (scm_intern0 (SCHEME_NAME)); SCM_SETCDR (C_NAME, init_val)
+#endif
+
+#define SCM_CONST_LONG(C_NAME, SCHEME_NAME,VALUE) SCM_VCELL_INIT(C_NAME, SCHEME_NAME, scm_long2num(VALUE));
 
 #endif /* LIBGUILE_SNARF_H */