04/05/2006: mutandiz

[allegrocl]
	    Fix output typemap of char so it produces a character instead
	    of an integer. Also adds input/output typemaps for 'char *'.

	    add command-line argument -isolate to generate an interface
	    file that won't interfere with other SWIG generated files that
	    may be used in the same application.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9042 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Mikel Bancroft 2006-04-06 06:28:53 +00:00
commit 1b1a48de7b
5 changed files with 43 additions and 13 deletions

View file

@ -1,6 +1,15 @@
Version 1.3.29 (March 21, 2006) Version 1.3.29 (March 21, 2006)
=============================== ===============================
04/05/2006: mutandiz
[allegrocl]
Fix output typemap of char so it produces a character instead
of an integer. Also adds input/output typemaps for 'char *'.
add command-line argument -isolate to generate an interface
file that won't interfere with other SWIG generated files that
may be used in the same application.
03/20/2005: mutandiz 03/20/2005: mutandiz
[allegrocl] [allegrocl]
More tweaks to INPUT/OUTPUT typemaps for bool. More tweaks to INPUT/OUTPUT typemaps for bool.

View file

@ -383,6 +383,11 @@ swig -allegrocl [ options ] filename
for modules with simple interfaces. Can not handle all legal enum for modules with simple interfaces. Can not handle all legal enum
and constant constructs, or take advantage of SWIG customization features. and constant constructs, or take advantage of SWIG customization features.
-isolate - With this command-line argument, all lisp helper functions are defined
in a unique package named <tt>swig.&lt;module-name&gt;</tt> rather than
<tt>swig</tt>. This prevents conflicts when the module is
intended to be used with other swig generated interfaces that may,
for instance, make use of different identifier converters.
</pre> </pre>
</div> </div>

View file

@ -242,7 +242,7 @@ $body)"
%insert("lisphead") %{ %insert("lisphead") %{
;; $Id$ ;; $Id$
(eval-when (compile eval) (eval-when (compile load eval)
;;; You can define your own identifier converter if you want. ;;; You can define your own identifier converter if you want.
;;; Use the -identifier-converter command line argument to ;;; Use the -identifier-converter command line argument to
@ -258,7 +258,7 @@ $body)"
(let* ((info (second form)) (let* ((info (second form))
(id (car info)) (id (car info))
(id-args (cddr info))) (id-args (cddr info)))
(apply swig:*swig-identifier-converter* id id-args))) (apply *swig-identifier-converter* id id-args)))
(defmacro defswig1 (name (&rest args) &body body) (defmacro defswig1 (name (&rest args) &body body)
`(progn (defmacro ,name ,args `(progn (defmacro ,name ,args
@ -268,7 +268,7 @@ $body)"
(defmacro defswig2 (name (&rest args) &body body) (defmacro defswig2 (name (&rest args) &body body)
`(progn (defmacro ,name ,args `(progn (defmacro ,name ,args
,@body) ,@body)
(excl::define-simple-parser ,name second))) b (excl::define-simple-parser ,name second)))
(defun read-symbol-from-string (string) (defun read-symbol-from-string (string)
(multiple-value-bind (result position) (multiple-value-bind (result position)
@ -332,7 +332,7 @@ $body)"
(let ((args (list (if (consp symbol) (cadr symbol) symbol) (let ((args (list (if (consp symbol) (cadr symbol) symbol)
(or package *package*)))) (or package *package*))))
(apply #'export args) (apply #'export args)
(pushnew args swig::*swig-export-list*)) (pushnew args *swig-export-list*))
symbol)) symbol))
(defmacro swig-insert-id (name namespace &key (type :type) class) (defmacro swig-insert-id (name namespace &key (type :type) class)

View file

@ -53,7 +53,8 @@ INOUT_TYPEMAP(unsigned long,
(push (ff:fslot-value-typed (quote $*in_fftype) :c $out) ACL_result), (push (ff:fslot-value-typed (quote $*in_fftype) :c $out) ACL_result),
(setf (ff:fslot-value-typed (quote $*in_fftype) :c $out) $in)); (setf (ff:fslot-value-typed (quote $*in_fftype) :c $out) $in));
INOUT_TYPEMAP(char, INOUT_TYPEMAP(char,
(push (ff:fslot-value-typed (quote $*in_fftype) :c $out) ACL_result), (push (code-char (ff:fslot-value-typed (quote $*in_fftype) :c $out))
ACL_result),
(setf (ff:fslot-value-typed (quote $*in_fftype) :c $out) $in)); (setf (ff:fslot-value-typed (quote $*in_fftype) :c $out) $in));
INOUT_TYPEMAP(float, INOUT_TYPEMAP(float,
(push (ff:fslot-value-typed (quote $*in_fftype) :c $out) ACL_result), (push (ff:fslot-value-typed (quote $*in_fftype) :c $out) ACL_result),
@ -66,6 +67,12 @@ INOUT_TYPEMAP(bool,
ACL_result), ACL_result),
(setf (ff:fslot-value-typed (quote $*in_fftype) :c $out) (if $in 1 0))); (setf (ff:fslot-value-typed (quote $*in_fftype) :c $out) (if $in 1 0)));
INOUT_TYPEMAP(char *,
(push (ff:char*-to-string (ff:fslot-value-typed (quote $*in_fftype) :c $out))
ACL_result),
(setf (ff:fslot-value-typed (quote $*in_fftype) :c $out)
(ff:string-to-char* $in)))
%typemap(lisptype) bool *INPUT, bool &INPUT "boolean"; %typemap(lisptype) bool *INPUT, bool &INPUT "boolean";
// long long support not yet complete // long long support not yet complete

View file

@ -26,10 +26,13 @@ static File *f_cxx_header=0;
static File *f_cxx_wrapper=0; static File *f_cxx_wrapper=0;
static String *module_name=0; static String *module_name=0;
static String *swig_package=0;
const char *identifier_converter="identifier-convert-null"; const char *identifier_converter="identifier-convert-null";
static bool CWrap = true; // generate wrapper file for C code by default. most correct. static bool CWrap = true; // generate wrapper file for C code by default. most correct.
static bool Generate_Wrapper = false; static bool Generate_Wrapper = false;
static bool unique_swig_package = false;
static String *current_namespace=NewString(""); static String *current_namespace=NewString("");
static String *current_package=NewString(""); static String *current_package=NewString("");
@ -1496,6 +1499,9 @@ void ALLEGROCL :: main(int argc, char *argv[]) {
} else if (!strcmp(argv[i], "-nocwrap")) { } else if (!strcmp(argv[i], "-nocwrap")) {
CWrap = false; CWrap = false;
Swig_mark_arg(i); Swig_mark_arg(i);
} else if (!strcmp(argv[i], "-isolate")) {
unique_swig_package = true;
Swig_mark_arg(i);
} }
if (!strcmp(argv[i], "-help")) { if (!strcmp(argv[i], "-help")) {
@ -1524,6 +1530,9 @@ int ALLEGROCL :: top(Node *n) {
String *cxx_filename=Getattr(n, "outfile"); String *cxx_filename=Getattr(n, "outfile");
String *cl_filename=NewString(""); String *cl_filename=NewString("");
swig_package = unique_swig_package ?
NewStringf("swig.%s", module_name) : NewString("swig");
Printf(cl_filename, "%s%s.cl", SWIG_output_directory(), module_name); Printf(cl_filename, "%s%s.cl", SWIG_output_directory(), module_name);
f_cl=NewFile(cl_filename, "w"); f_cl=NewFile(cl_filename, "w");
@ -1556,18 +1565,18 @@ int ALLEGROCL :: top(Node *n) {
Printf(f_cl, ";; This is an automatically generated file. Make changes in\n" Printf(f_cl, ";; This is an automatically generated file. Make changes in\n"
";; the definition file, not here.\n\n" ";; the definition file, not here.\n\n"
"(defpackage :swig\n" "(defpackage :%s\n"
" (:use :common-lisp :ff :excl)\n" " (:use :common-lisp :ff :excl)\n"
" (:export #:*swig-identifier-converter* #:*swig-module-name*\n" " (:export #:*swig-identifier-converter* #:*swig-module-name*\n"
" #:*void*))\n" " #:*void* #:*swig-expoert-list*))\n"
"(in-package :swig)\n\n" "(in-package :%s)\n\n"
"(eval-when (compile load eval)\n" "(eval-when (compile load eval)\n"
" (defparameter *swig-identifier-converter* '%s)\n" " (defparameter *swig-identifier-converter* '%s)\n"
" (defparameter *swig-module-name* :%s))\n\n", " (defparameter *swig-module-name* :%s))\n\n",
identifier_converter, module_name); swig_package, swig_package, identifier_converter, module_name);
Printf(f_cl, "(defpackage :%s\n" Printf(f_cl, "(defpackage :%s\n"
" (:use :common-lisp :swig :ff :excl))\n\n", " (:use :common-lisp :%s :ff :excl))\n\n",
module_name); module_name, swig_package);
Printf(f_clhead, "(in-package :%s)\n", module_name); Printf(f_clhead, "(in-package :%s)\n", module_name);
@ -1583,7 +1592,7 @@ int ALLEGROCL :: top(Node *n) {
#endif #endif
emit_linked_types(); emit_linked_types();
Printf(f_clwrap, "\n(in-package :swig)\n"); Printf(f_clwrap, "\n(in-package :%s)\n", swig_package);
Printf(f_clwrap, "\n(macrolet ((swig-do-export ()\n"); Printf(f_clwrap, "\n(macrolet ((swig-do-export ()\n");
Printf(f_clwrap, " `(dolist (s ',*swig-export-list*)\n"); Printf(f_clwrap, " `(dolist (s ',*swig-export-list*)\n");
Printf(f_clwrap, " (apply #'export s))))\n"); Printf(f_clwrap, " (apply #'export s))))\n");
@ -2329,7 +2338,7 @@ int ALLEGROCL :: emit_defun(Node *n, File *f_cl) {
SwigType *result_type = Swig_cparse_type(Getattr(n,"tmap:ctype")); SwigType *result_type = Swig_cparse_type(Getattr(n,"tmap:ctype"));
// prime the pump, with support for OUTPUT, INOUT typemaps. // prime the pump, with support for OUTPUT, INOUT typemaps.
Printf(wrap->code,"(let ((ACL_ffresult swig:*void*)\n ACL_result)\n $body\n (if (eq ACL_ffresult swig:*void*)\n (values-list ACL_result)\n (values-list (cons ACL_ffresult ACL_result))))"); Printf(wrap->code,"(let ((ACL_ffresult %s:*void*)\n ACL_result)\n $body\n (if (eq ACL_ffresult %s:*void*)\n (values-list ACL_result)\n (values-list (cons ACL_ffresult ACL_result))))", swig_package, swig_package);
Parm *p; Parm *p;
int largnum = 0, argnum=0, first=1; int largnum = 0, argnum=0, first=1;