See CHANGES.recent

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5928 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Ahmon Dancy 2004-05-24 21:22:39 +00:00
commit e465a6ae6a
3 changed files with 93 additions and 49 deletions

View file

@ -1,6 +1,17 @@
Version 1.3.22 (in progress) Version 1.3.22 (in progress)
================================== ==================================
5/24/2004: dancy
* Allegro CL module: Now using some macros (defined in
Lib/allegrocl/allegrocl.swg), swig-defconstant and swig-defun, for
defining constants and foreign functions. This makes the
generated file a bit neater.
Now strips a layer of parenthesis from constants.
Uses (* :void) instead of :foreign-address now.
05/20/2004: wsfulton 05/20/2004: wsfulton
Unnamed enum global variables are now supported in addition Unnamed enum global variables are now supported in addition
to the recently added support for unnamed enum member variables. to the recently added support for unnamed enum member variables.

View file

@ -39,6 +39,19 @@
(setf lastcase :other))) (setf lastcase :other)))
(intern (coerce (nreverse res) 'string)))) (intern (coerce (nreverse res) 'string))))
(defmacro swig-defconstant (string value)
(let ((symbol (funcall *swig-identifier-converter* string :type :constant)))
`(eval-when (compile load eval)
(defconstant ,symbol ,value)
(export (quote ,symbol)))))
(defmacro swig-defun (name &rest rest)
(let ((symbol (funcall *swig-identifier-converter* name :type :operator)))
`(eval-when (compile load eval)
(excl::compiler-let ((*record-xref-info* nil))
(ff:def-foreign-call ,symbol ,@rest)
(export (quote ,symbol))))))
) ;; eval-when ) ;; eval-when

View file

@ -30,30 +30,60 @@ int any_varargs(ParmList *pl) {
} }
/* utilities */ /* utilities */
String *convert_number(String *num, String *type) { /* returns new string w/ parens stripped */
char *s=Char(num); String *strip_parens(String *string) {
char *s=Char(string), *p;
int len=Len(string);
String *res;
/* Make sure doubles use 'd' instead of 'e' */ if (len==0 || s[0] != '(' || s[len-1] != ')') {
if (!Strcmp(type, "double")) { return NewString(string);
String *updated=Copy(num); }
if (Replace(updated, "e", "d", DOH_REPLACE_ANY) > 1) {
Printf(stderr, "Weird!! number %s looks invalid.\n", num);
SWIG_exit(EXIT_FAILURE);
}
return updated;
}
if (Len(num) < 2 || s[0] != '0') { p=(char *)malloc(len-2+1);
return Copy(num); if (!p) {
} Printf(stderr, "Malloc failed\n");
SWIG_exit(EXIT_FAILURE);
}
/* octal or hex */ strncpy(p, s+1, len-1);
p[len-2]=0; /* null terminate */
return NewStringf("#%c%s", res=NewString(p);
s[1] == 'x' ? 'x' : 'o', free(p);
s+2);
return res;
}
String *convert_number(String *num_param, String *type) {
String *num=strip_parens(num_param), *res;
char *s=Char(num);
/* Make sure doubles use 'd' instead of 'e' */
if (!Strcmp(type, "double")) {
String *updated=Copy(num);
if (Replace(updated, "e", "d", DOH_REPLACE_ANY) > 1) {
Printf(stderr, "Weird!! number %s looks invalid.\n", num);
SWIG_exit(EXIT_FAILURE);
}
Delete(num);
return updated;
}
if (Len(num) < 2 || s[0] != '0') {
return num;
}
/* octal or hex */
res=NewStringf("#%c%s",
s[1] == 'x' ? 'x' : 'o',
s+2);
Delete(num);
return res;
} }
typedef struct type_mapping { typedef struct type_mapping {
@ -122,7 +152,11 @@ String *convert_type(SwigType *ty) {
if (SwigType_ispointer(type_reduced) || SwigType_isarray(ty) || if (SwigType_ispointer(type_reduced) || SwigType_isarray(ty) ||
!strncmp(type_reduced, "p.f", 3)) { !strncmp(type_reduced, "p.f", 3)) {
#if 1
return NewString("(* :void)");
#else
return NewString(":foreign-address"); return NewString(":foreign-address");
#endif
} }
for(i=0; type_mappings[i].c_type; i++) { for(i=0; type_mappings[i].c_type; i++) {
@ -158,9 +192,6 @@ void ALLEGROCL :: main(int argc, char *argv[]) {
SWIG_config_file("allegrocl.swg"); SWIG_config_file("allegrocl.swg");
for(i=1; i<argc; i++) { for(i=1; i<argc; i++) {
if (!strcmp(argv[i], "-identifier-converter")) { if (!strcmp(argv[i], "-identifier-converter")) {
char *conv=argv[i+1]; char *conv=argv[i+1];
@ -227,6 +258,7 @@ int ALLEGROCL :: top(Node *n) {
Swig_register_filebyname("wrapper", f_cl); Swig_register_filebyname("wrapper", f_cl);
Printf(f_cl, ";; This is an automatically generated file. Make changes in\n;; the definition file, not here.\n\n(defpackage :%s\n (:use :common-lisp :ff :excl))\n\n(in-package :%s)\n", module, module); Printf(f_cl, ";; This is an automatically generated file. Make changes in\n;; the definition file, not here.\n\n(defpackage :%s\n (:use :common-lisp :ff :excl))\n\n(in-package :%s)\n", module, module);
Printf(f_cl, "(eval-when (compile load eval)\n (defparameter *swig-identifier-converter* '%s))\n", identifier_converter);
Language::top(n); Language::top(n);
@ -246,15 +278,11 @@ int ALLEGROCL :: functionWrapper(Node *n) {
//Language::functionWrapper(n); //Language::functionWrapper(n);
Printf(f_cl, Printf(f_cl, "(swig-defun \"%s\"\n", funcname);
"(excl::compiler-let ((*record-xref-info* nil))\n (ff:def-foreign-call (#.(%s \"%s\" :type :operator) \"%s\")\n (", Printf(f_cl, " (");
identifier_converter,
funcname,
funcname);
/* Special cases */ /* Special cases */
if (ParmList_len(pl) == 0) { if (ParmList_len(pl) == 0) {
Printf(f_cl, ":void"); Printf(f_cl, ":void");
} else if (any_varargs(pl)) { } else if (any_varargs(pl)) {
@ -285,14 +313,10 @@ int ALLEGROCL :: functionWrapper(Node *n) {
} }
} }
Printf(f_cl, ")\n"); /* finish arg list */ Printf(f_cl, ")\n"); /* finish arg list */
Printf(f_cl, " :returning %s\n :strings-convert t\n :call-direct %s\n :optimize-for-space t))\n", Printf(f_cl, " :returning (%s)\n :strings-convert t\n :call-direct %s\n :optimize-for-space t)\n",
convert_type(Getattr(n, "type")), convert_type(Getattr(n, "type")),
varargs ? "nil" : "t"); varargs ? "nil" : "t");
Printf(f_cl,
"(eval-when (compile load eval)\n (export '#.(%s \"%s\" :type :operator)))\n\n",
identifier_converter,
funcname);
return SWIG_OK; return SWIG_OK;
} }
@ -307,15 +331,8 @@ int ALLEGROCL :: constantWrapper(Node *n) {
name, type, converted_value); name, type, converted_value);
#endif #endif
Printf(f_cl, Printf(f_cl, "(swig-defconstant \"%s\" %s)\n",
"(defconstant #.(%s \"%s\" :type :constant) %s)\n", name, converted_value);
identifier_converter,
name,
converted_value);
Printf(f_cl,
"(eval-when (compile load eval)\n (export '#.(%s \"%s\" :type :constant)))\n\n",
identifier_converter,
name);
Delete(converted_value); Delete(converted_value);
@ -354,11 +371,14 @@ int ALLEGROCL :: classDeclaration(Node *n) {
SWIG_exit(EXIT_FAILURE); SWIG_exit(EXIT_FAILURE);
} }
/* Printf(stdout, "Converting %s in %s\n", type, name); */
lisp_type=convert_type(type); lisp_type=convert_type(type);
Printf(f_cl, Printf(f_cl,
" (#.(%s \"%s\" :type :slot) %s)\n", Getattr(c, "sym:name"), " (#.(%s \"%s\" :type :slot) %s)\n",
identifier_converter, identifier_converter,
Getattr(c, "sym:name"),
lisp_type); lisp_type);
Delete(lisp_type); Delete(lisp_type);