07/25/2006: mutandiz

[allegrocl]
	    more additions to std::string, some tweaks and small bug fixes
	    -nocwrap mode.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9225 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Mikel Bancroft 2006-07-25 22:59:16 +00:00
commit f41560641b
4 changed files with 29 additions and 14 deletions

View file

@ -1,5 +1,10 @@
Version 1.3.30 (in progress)
============================
07/25/2006: mutandiz
[allegrocl]
more additions to std::string, some tweaks and small bug fixes
-nocwrap mode.
07/21/2006: mgossage
Bugfix #1526022 pdated std::string to support strings with '\0' inside them
updated typemaps.i to add support for pointer to pointers

View file

@ -18,11 +18,11 @@
%typemap(lout) void "$body";
%typemap(lout) SWIGTYPE[ANY], SWIGTYPE *,
SWIGTYPE &
%{ (let* ((address $body)
(new-inst (make-instance '$lclass :foreign-address address)))
(when (and $owner (not (zerop address)))
%{ (cl:let* ((address $body)
(new-inst (cl:make-instance '$lclass :foreign-address address)))
(cl:when (cl:and $owner (cl:not (cl:zerop address)))
(excl:schedule-finalization new-inst #'$ldestructor))
(setq ACL_ffresult new-inst)) %}
(cl:setq ACL_ffresult new-inst)) %}
%typemap(lout) SWIGTYPE "(cl::let* ((address $body)\n (new-inst (cl::make-instance '$lclass :foreign-address address)))\n (cl::unless (cl::zerop address)\n (excl:schedule-finalization new-inst #'$ldestructor))\n (cl::setq ACL_ffresult new-inst))";
@ -161,7 +161,7 @@ SWIG_TYPECHECK_STRING_ARRAY 1140
%typecheck(SWIG_TYPECHECK_UNICHAR) wchar_t { $1 = 1; };
%typemap(in) wchar_t "$1 = $input;";
%typemap(lin,numinputs=1) wchar_t "(cl::let (($out (char-code $in)))\n $body)";
%typemap(lin,numinputs=1) wchar_t "(cl::let (($out (cl:char-code $in)))\n $body)";
%typemap(lin,numinputs=1) wchar_t* "(excl:with-native-string ($out $in
:external-format #+little-endian :fat-le #-little-endian :fat)\n
$body)"
@ -296,6 +296,7 @@ $body)"
(:constructor (cl::format nil "new_~A~@[~A~]" id arity))
(:destructor (cl::format nil "delete_~A" id))
(:type (cl::format nil "ff_~A" id))
(:slot id)
(:ff-operator (cl::format nil "ffi_~A" id))
(otherwise (cl::format nil "~@[~A_~]~A~@[~A~]"
class id arity))))
@ -383,7 +384,7 @@ $body)"
&body body)
(cl::let* ((symbol (id-convert-and-export name :type type
:arity arity :class class))
(mangle (excl::if* (cl::eq name mangled-name)
(mangle (excl::if* (cl::string-equal name mangled-name)
then (id-convert-and-export
(cl::cond
((cl::eq type :setter) (cl::format nil "~A-set" name))
@ -497,7 +498,7 @@ $body)"
(cl::defpackage ,string
(:use :swig :ff #+ignore '(:common-lisp :ff :excl)
,@parent-strings ,*swig-module-name*)
(:import-from :cl "*")))))
(:import-from :cl :* :nil :t)))))
(cl::defmacro swig-in-package (namespace)
`(cl::eval-when (compile load eval)

View file

@ -82,6 +82,7 @@ namespace std {
bool operator >= ( const basic_string<charT> &other ) const {
return self->compare( other ) != -1;
}
}
};
@ -94,12 +95,20 @@ namespace std {
typedef basic_string<char> string;
typedef basic_string<wchar_t> wstring;
// automatically convert constant std::strings to cl:strings
%typemap(ctype) string "char *";
%typemap(in) string "$1 = string($input);";
%typemap(out) string "$result = (char *)(&$1)->c_str();";
%typemap(lisptype) string "cl:string";
%typemap(lout) string "(cl::setq ACL_ffresult $body)";
%typemap(ctype) wstring "wchar_t *";
%typemap(in) wstring "$1 = string($input);";
%typemap(out) wstring "$result = (wchar_t *)(&$1)->c_str();";
%typemap(lisptype) wstring "cl:string";
%typemap(lout) wstring "(cl::setq ACL_ffresult (excl:native-to-string $body
:external-format #+little-endian :fat-le #-little-endian :fat))";
/* Overloading check */
// %typemap(in) string {
// if (caml_ptr_check($input))

View file

@ -977,13 +977,7 @@ String * convert_literal(String *literal, String *type, bool try_to_split) {
Delete(num); Delete(trimmed);
return NewStringf("\"%s\"", num_param);
}
else if (allegrocl->validIdentifier(num)) {
/* convert C/C++ identifiers to CL symbols */
res = NewStringf("#.(swig-insert-id \"%s\" %s :type :constant)", num, ns);
Delete(num); Delete(trimmed); Delete(ns);
return res;
}
else if (Len(num) >= 1 && isdigit(s[0])) {
else if (Len(num) >= 1 && (isdigit(s[0]) || s[0] == '+' || s[0] == '-')) {
/* use CL syntax for numbers */
String *oldnum = Copy(num);
int usuffixes = Replaceall(num, "u", "") + Replaceall(num, "U", "");
@ -1006,6 +1000,12 @@ String * convert_literal(String *literal, String *type, bool try_to_split) {
}
Delete(oldnum); Delete(trimmed);
return res;
}
else if (allegrocl->validIdentifier(num)) {
/* convert C/C++ identifiers to CL symbols */
res = NewStringf("#.(swig-insert-id \"%s\" %s :type :constant)", num, ns);
Delete(num); Delete(trimmed); Delete(ns);
return res;
} else {
Delete(trimmed);
return num;