annotate modules/sample/external/sample.c @ 4792:95b04754ea8c

Make #'equalp more compatible with CL; add a compiler macro, test & doc it. lisp/ChangeLog addition: 2009-11-08 Aidan Kehoe <kehoea@parhasard.net> * cl-extra.el (cl-string-vector-equalp) (cl-bit-vector-vector-equalp, cl-vector-array-equalp) (cl-hash-table-contents-equalp): New functions, to implement equalp treating arrays with identical contents as equivalent, as specified by Common Lisp. (equalp): Revise this function to implement array equivalence, and the hash-table equalp behaviour specified by CL. * cl-macs.el (equalp): Add a compiler macro for this function, used when one of the arguments is constant, and as such, its type is known at compile time. man/ChangeLog addition: 2009-11-08 Aidan Kehoe <kehoea@parhasard.net> * lispref/objects.texi (Equality Predicates): Document #'equalp here, as well as #'equal and #'eq. tests/ChangeLog addition: 2009-12-31 Aidan Kehoe <kehoea@parhasard.net> * automated/lisp-tests.el: Test much of the functionality of equalp; add a pointer to Paul Dietz' ANSI test suite for this function, converted to Emacs Lisp. Not including the tests themselves in XEmacs because who owns the copyright on the files is unclear and the GCL people didn't respond to my queries.
author Aidan Kehoe <kehoea@parhasard.net>
date Thu, 31 Dec 2009 15:09:41 +0000
parents dce479915b74
children dd9541c73e70
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
1 /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
2 * Very simple sample module. Illustrates most of the salient features
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
3 * of Emacs dynamic modules.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
4 * (C) Copyright 1998, 1999 J. Kean Johnston. All rights reserved.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
5 * (C) Copyright 2002 Jerry James.
4737
dce479915b74 Clarify the GPL status of several sample module files. J. Kean Johnston
Jerry James <james@xemacs.org>
parents: 996
diff changeset
6 *
dce479915b74 Clarify the GPL status of several sample module files. J. Kean Johnston
Jerry James <james@xemacs.org>
parents: 996
diff changeset
7 * This sample module code is free software; you can redistribute it and/or
dce479915b74 Clarify the GPL status of several sample module files. J. Kean Johnston
Jerry James <james@xemacs.org>
parents: 996
diff changeset
8 * modify it under the terms of the GNU General Public License as published
dce479915b74 Clarify the GPL status of several sample module files. J. Kean Johnston
Jerry James <james@xemacs.org>
parents: 996
diff changeset
9 * by the Free Software Foundation; either version 2, or (at your option)
dce479915b74 Clarify the GPL status of several sample module files. J. Kean Johnston
Jerry James <james@xemacs.org>
parents: 996
diff changeset
10 * any later version.
996
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
11 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
12
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
13 #include <config.h>
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
14 #include "lisp.h"
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
15
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
16 /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
17 * This sample introduces three new Lisp objects to the Lisp reader.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
18 * The first, a simple boolean value, and the second a string. The
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
19 * Third is a sample function that simply prints a message.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
20 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
21 int sample_bool;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
22 Lisp_Object Vsample_string;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
23
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
24 DEFUN ("sample-function", Fsample_function, 0, 0, "", /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
25 This is a sample function loaded dynamically.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
26
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
27 You will notice in the source code for this module that the
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
28 declaration is identical to internal Emacs functions. This
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
29 makes it possible to use the exact same code in a dumped
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
30 version of Emacs.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
31 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
32 ())
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
33 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
34 message ("Eureka! It worked");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
35 return Qt;
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
36 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
37
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
38 /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
39 * Each dynamically loaded Emacs module is given a name at compile
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
40 * time. This is a short name, and must be a valid part of a C
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
41 * identifier. This name is used to construct the name of several
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
42 * functions which must appear in the module source code.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
43 * The first such function, modules_of_XXXX, should load in any dependent
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
44 * modules. This function is optional, and the module will still load if
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
45 * it is not present in the module.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
46 *
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
47 * The second function, which is NOT optional, is syms_of_XXXX, in which
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
48 * all functions that the module will be provided are declared. This
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
49 * function will contain calls to DEFSUBR().
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
50 *
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
51 * The third function, which is also NOT optional, is vars_of_XXXX, in
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
52 * which you declare all variables that the module provides. This
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
53 * function will contain calls to DEFVAR_LISP(), DEFVAR_BOOL() etc.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
54 *
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
55 * When declaring functions and variables in the syms_of_XXXX and
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
56 * vars_of_XXXX functions, you use the exact same syntax that you
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
57 * would as if this module were being compiled into the pure Emacs.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
58 *
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
59 * The fourth function, which is optional, is unload_XXXX, in which actions
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
60 * that must be taken to unload the module are listed. XEmacs will unbind
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
61 * functions and variables for you. Anything else that must be done should
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
62 * appear in this function.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
63 *
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
64 * All four of these functions are declared as void functions,
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
65 * taking no parameters. Since this sample module is called 'sample',
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
66 * the functions will be named 'modules_of_sample', 'syms_of_sample',
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
67 * 'vars_of_sample', and 'unload_sample'.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
68 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
69
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
70 void
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
71 modules_of_sample()
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
72 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
73 /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
74 * This function isn't actually required as we will not be loading
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
75 * in any dependent modules, but if we were, we would do something like:
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
76 * emodules_load ("dependent.ell", "sample2", "1.0.0");
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
77 */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
78 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
79
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
80 void
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
81 syms_of_sample()
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
82 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
83 DEFSUBR(Fsample_function);
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
84 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
85
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
86 void
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
87 vars_of_sample()
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
88 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
89 DEFVAR_LISP ("sample-string", &Vsample_string /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
90 This is a sample string, declared in a dynamic module.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
91
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
92 The syntax and conventions used for all normal Emacs variables
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
93 apply equally to modules, using an identical syntax.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
94 */ );
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
95
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
96 DEFVAR_BOOL ("sample-boolean", &sample_bool /*
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
97 *Sample boolean value, in a dynamic module.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
98
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
99 This is a user-settable variable, as indicated by the *
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
100 as the first character of the description. Declared in
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
101 a module exactly as it would be internally in Emacs.
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
102 */ );
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
103 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
104
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
105 #ifdef HAVE_SHLIB
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
106 void
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
107 unload_sample()
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
108 {
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
109 /* We don't need to do anything here in the sample case. However, if you
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
110 create any new types with INIT_LRECORD_IMPLEMENTATION (sample_type), then
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
111 UNDEF_LRECORD_IMPLEMENTATION (sample_type) must appear here. Also, any
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
112 symbols declared with DEFSYMBOL (Qsample_var), or one of its variants,
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
113 must have a corresponding unstaticpro_nodump (&Qsample_var) here. */
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
114 }
25e260cb7994 [xemacs-hg @ 2002-09-10 15:27:02 by james]
james
parents:
diff changeset
115 #endif