-- -
Abstract
- -RDNZL (pronounced "Redunzl") enables Common Lisp applications to interact with .NET -libraries. It's more or less a foreign function interface for .NET -languages like C# built atop the C foreign function interface. - -- -RDNZL comes with a BSD-style -license so you can basically do with it whatever you want. - -
-Download shortcut: http://weitz.de/files/RDNZL.tar.gz. - -
container-p
- box
- unbox
- new
- cast
- make-null-object
- shutdown-rdnzl
- init-rdnzl
- -CL-USER(1): (load "/home/lisp/RDNZL/load.lisp") -; Loading C:\home\lisp\RDNZL\load.lisp -; Fast loading C:\home\lisp\RDNZL\packages.fasl -; Fast loading C:\home\lisp\RDNZL\specials.fasl -; Fast loading C:\home\lisp\RDNZL\util.fasl -; Fast loading C:\home\lisp\RDNZL\port-acl.fasl -; Fast loading from bundle code\IORDEFS.fasl. -; Fast loading from bundle code\EFMACS.fasl. -; Fast loading C:\home\lisp\RDNZL\ffi.fasl -; Foreign loading RDNZL.dll. -; Fast loading C:\home\lisp\RDNZL\container.fasl -; Fast loading C:\home\lisp\RDNZL\reader.fasl -; Fast loading C:\home\lisp\RDNZL\arrays.fasl -; Fast loading C:\home\lisp\RDNZL\adapter.fasl -; Fast loading C:\home\lisp\RDNZL\import.fasl -T -CL-USER(2): (use-package :rdnzl) -T -CL-USER(3): (enable-rdnzl-syntax) -CL-USER(4): (import-types "System.Windows.Forms" - "MessageBox" "MessageBoxButtons" "DialogResult") -NIL -CL-USER(5): (use-namespace "System.Windows.Forms") -CL-USER(6): (defun message-box (text &optional (caption "RDNZL")) - ;; check if the "OK" button was pressed - [Equals [MessageBox.Show text caption - ;; we want the message box to have "OK" and "Cancel" buttons - [$MessageBoxButtons.OKCancel]] - [$DialogResult.OK]]) -MESSAGE-BOX -CL-USER(7): (message-box "Hello World!") ;; user presses "OK" button -T -CL-USER(8): (message-box "Hello World!") ;; user presses "Cancel" button -NIL -- -(Note: All examples shown here are included in the
examples
folder of the distribution.)
-
-For a more interesting example which interacts with custom .NET code
-and demonstrates callbacks into Lisp consider the .NET library
-AproposGUI.dll
(put it into your Lisp's application folder) created
-with this C# code:
-
-
-// compile this with: -// csc.exe /target:library AproposGui.cs - -using System; -using System.Collections; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Windows.Forms; - -namespace AproposGUI { - public class AproposControl : System.Windows.Forms.UserControl { - public System.Windows.Forms.TextBox textBox; - public System.Windows.Forms.TextBox listBox; - private System.Windows.Forms.Label label; - public System.Windows.Forms.Label title; - private delegate string callback(string input); - - private System.ComponentModel.Container components = null; - - public AproposControl() { - InitializeComponent(); - } - - protected override void Dispose(bool disposing) { - if (disposing) { - if (components != null) - components.Dispose(); - } - base.Dispose(disposing); - } - - private void InitializeComponent() { - this.textBox = new System.Windows.Forms.TextBox(); - this.listBox = new System.Windows.Forms.TextBox(); - this.label = new System.Windows.Forms.Label(); - this.title = new System.Windows.Forms.Label(); - this.SuspendLayout(); - - this.textBox.Location = new System.Drawing.Point(16, 344); - this.textBox.Name = "textBox"; - this.textBox.Size = new System.Drawing.Size(584, 20); - this.textBox.TabIndex = 0; - this.textBox.Text = ""; - - this.listBox.Location = new System.Drawing.Point(16, 56); - this.listBox.Multiline = true; - this.listBox.Name = "listBox"; - this.listBox.ReadOnly = true; - this.listBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.listBox.Size = new System.Drawing.Size(584, 248); - this.listBox.TabIndex = 1; - this.listBox.Text = ""; - - this.label.Location = new System.Drawing.Point(24, 312); - this.label.Name = "label"; - this.label.Size = new System.Drawing.Size(576, 23); - this.label.TabIndex = 2; - this.label.Text = "Enter text below and press RETURN"; - this.label.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - - this.title.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); - this.title.Location = new System.Drawing.Point(24, 16); - this.title.Name = "title"; - this.title.Size = new System.Drawing.Size(568, 24); - this.title.TabIndex = 3; - this.title.Text = "RDNZL Apropos Demo"; - this.title.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - - this.Controls.Add(this.title); - this.Controls.Add(this.label); - this.Controls.Add(this.listBox); - this.Controls.Add(this.textBox); - this.Name = "MainControl"; - this.Size = new System.Drawing.Size(616, 384); - this.ResumeLayout(false); - } - } -} -- -Now load
examples/apropos.lisp
which looks like this:
-
--(in-package :cl-user) - -(use-package :rdnzl) - -(enable-rdnzl-syntax) - -(import-types "System.Windows.Forms" - "Application" "DockStyle" "Form" "MessageBox" "KeyPressEventHandler" "TextBox") - -(import-types "AproposGUI" - "AproposControl") - -(use-namespace "System.Windows.Forms") -(use-namespace "AproposGUI") - -(defun copy-to-clipboard (text-box) - (let ((selection-start [%SelectionStart text-box]) - (selection-length [%SelectionLength text-box]) - (text-length [%Length (box [%Text text-box])])) - (setf [%SelectionStart text-box] 0 - [%SelectionLength text-box] text-length) - [Copy text-box] - (setf [%SelectionStart text-box] selection-start - [%SelectionLength text-box] selection-length))) - -(let (message-shown) - (defun fill-list-box (object event) - (when (char= [%KeyChar event] #\Return) - (cast object "TextBox") - (let* ((input-string [%Text object]) - (input-length (length input-string))) - (when (plusp input-length) - (let ((apropos-text - (with-output-to-string (*standard-output*) - (apropos input-string))) - (list-box [$listBox (cast [%Parent object] "AproposControl")])) - (setf [%Text list-box] apropos-text) - (copy-to-clipboard list-box) - (unless message-shown - [MessageBox.Show "The output of APROPOS has been copied to the clipboard." - "RDNZL"] - (setq message-shown t))) - (setf [%SelectionStart object] 0 - [%SelectionLength object] input-length)))))) - -(defun run-apropos-form () - (let* ((control (new "AproposControl")) - (form (new "Form"))) - (setf [%Dock control] [$DockStyle.Fill] - [%ClientSize form] [%ClientSize control] - [%Text form] "RDNZL Apropos Demo" - [%Text [$title control]] - (format nil "RDNZL Apropos Demo (~A)" - (lisp-implementation-type))) - [+KeyPress [$textBox control] - (new "KeyPressEventHandler" #'fill-list-box)] - [Add [%Controls form] control] - [Application.Run form])) - -(disable-rdnzl-syntax) -- -and evaluate
(RUN-APROPOS-FORM)
. If you want to try this
-several times, start the function in its own thread. In AllegroCL or LispWorks
-that'd be:
-
--(mp:process-run-function "apropos" #+:lispworks nil #'run-apropos-form) -- -The last example shows how easy it is to access web pages using the -.NET standard library: - -
-CL-USER(9): (import-types "System" "Net.WebClient") -NIL -CL-USER(10): (defun download-url (url) - (let ((web-client (new "System.Net.WebClient"))) - [GetString (new "System.Text.ASCIIEncoding") - [DownloadData web-client url]])) -DOWNLOAD-URL -CL-USER(11): (download-url "http://nanook.agharta.de/") -"<HTML> -<HEAD> -<META HTTP-EQUIV=\"refresh\" CONTENT=\"5;URL=http://www.weitz.de/\"> -</HEAD> -<BODY><center> -<table border=3 bordercolor=green cellpadding=5 cellspacing=5><tr><td align=center> -<pre> -Linux nanook 2.6.7 #1 Thu Jul 22 01:01:58 CEST 2004 i686 GNU/Linux - - 01:23:23 up 100 days, 19:43, 0 users, load average: 0.00, 0.00, 0.00 - -</pre> - </td></tr></table></center> - -</BODY> -</HTML> -" -- -A bit more evolved: - -
-CL-USER(12): (import-types "System" "Net.WebException") -NIL -CL-USER(13): (use-namespace "System.Net") -CL-USER(14): (defun download-url (url) - (rdnzl-handler-case - (let ((web-client (new "WebClient"))) - [GetString (new "System.Text.ASCIIEncoding") - [DownloadData web-client url]]) - ("WebException" (e) - (warn "Ooops, probably a typo: ~A" [%Message e]) - nil))) -DOWNLOAD-URL -CL-USER(15): (download-url "http://nanook.aharta.de/") -Warning: Ooops, probably a typo: - The underlying connection was closed: The remote name could not be resolved. -NIL -- -This'll also work with https URLs. - - - -
RDNZL.dll
can be downloaded separately from
-http://weitz.de/files/RDNZL_cpp.tar.gz but you don't need this archive
-to deploy RDNZL - RDNZL.tar.gz
already contains RDNZL.dll
.
-You can also access the current RDNZL source code (Lisp and C++) via CVS.
-
-Before you load RDNZL make sure you have the .NET framework installed.
-Then move the file RDNZL.dll
to a location where your Lisp's FFI will
-find it - the folder where your Lisp executable is located is
-generally a good place for that.
-
-Now, to compile and load RDNZL just LOAD
the file load.lisp
- that's
-all. (Or alternatively use ASDF if you like - RDNZL comes with a
-system definition for ASDF.)
-
-Oh, and - for the moment - don't use SLIME together with
-LispWorks when loading RDNZL - see this message for an explanation.
-
-
-
RDNZL.dll
can be downloaded separately from
http://weitz.de/files/RDNZL_cpp.tar.gz but you don't need this archive
@@ -1073,7 +1073,7 @@
Thanks to Charles A. Cox for the port of RDNZL to AllegroCL. Thanks to Vasilis Margioulas for the CLISP port. Thanks to Roger Corman for his help with the CCL port. Thanks to Franz Inc. (and particularly Jans Aasman) for supporting the development of RDNZL.
-$Header: /project/rdnzl/cvsroot/RDNZL/doc/index.html,v 1.5 2006/02/01 01:00:57 eweitz Exp $ +$Header: /project/rdnzl/cvsroot/RDNZL/doc/index.html,v 1.6 2006/02/01 12:02:22 eweitz Exp $
BACK TO MY HOMEPAGE From eweitz at common-lisp.net Wed Feb 1 12:02:22 2006 From: eweitz at common-lisp.net (eweitz) Date: Wed, 1 Feb 2006 06:02:22 -0600 (CST) Subject: [rdnzl-cvs] CVS RDNZL/examples Message-ID: <20060201120222.D0C392E00B@common-lisp.net> Update of /project/rdnzl/cvsroot/RDNZL/examples In directory common-lisp:/tmp/cvs-serv28943/examples Modified Files: AproposGui.cs apropos.lisp apropos2.lisp deliver-acl.lisp deliver-ccl.lisp deliver-lw.lisp messagebox.lisp url.lisp Log Message: Added WIDE-CHAR support for SBCL (0.9.1) --- /project/rdnzl/cvsroot/RDNZL/examples/AproposGui.cs 2006/02/01 01:00:57 1.2 +++ /project/rdnzl/cvsroot/RDNZL/examples/AproposGui.cs 2006/02/01 12:02:22 1.3 @@ -1,4 +1,4 @@ -// $Header: /project/rdnzl/cvsroot/RDNZL/examples/AproposGui.cs,v 1.2 2006/02/01 01:00:57 eweitz Exp $ +// $Header: /project/rdnzl/cvsroot/RDNZL/examples/AproposGui.cs,v 1.3 2006/02/01 12:02:22 eweitz Exp $ // Copyright (c) 2004-2006, Dr. Edmund Weitz. All rights reserved. --- /project/rdnzl/cvsroot/RDNZL/examples/apropos.lisp 2006/02/01 01:00:57 1.2 +++ /project/rdnzl/cvsroot/RDNZL/examples/apropos.lisp 2006/02/01 12:02:22 1.3 @@ -1,5 +1,5 @@ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: RDNZL; Base: 10 -*- -;;; $Header: /project/rdnzl/cvsroot/RDNZL/examples/apropos.lisp,v 1.2 2006/02/01 01:00:57 eweitz Exp $ +;;; $Header: /project/rdnzl/cvsroot/RDNZL/examples/apropos.lisp,v 1.3 2006/02/01 12:02:22 eweitz Exp $ ;;; Copyright (c) 2004-2006, Dr. Edmund Weitz. All rights reserved. --- /project/rdnzl/cvsroot/RDNZL/examples/apropos2.lisp 2006/02/01 01:00:57 1.2 +++ /project/rdnzl/cvsroot/RDNZL/examples/apropos2.lisp 2006/02/01 12:02:22 1.3 @@ -1,5 +1,5 @@ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: RDNZL; Base: 10 -*- -;;; $Header: /project/rdnzl/cvsroot/RDNZL/examples/apropos2.lisp,v 1.2 2006/02/01 01:00:57 eweitz Exp $ +;;; $Header: /project/rdnzl/cvsroot/RDNZL/examples/apropos2.lisp,v 1.3 2006/02/01 12:02:22 eweitz Exp $ ;;; Copyright (c) 2004-2006, Dr. Edmund Weitz. All rights reserved. --- /project/rdnzl/cvsroot/RDNZL/examples/deliver-acl.lisp 2006/02/01 01:00:57 1.2 +++ /project/rdnzl/cvsroot/RDNZL/examples/deliver-acl.lisp 2006/02/01 12:02:22 1.3 @@ -1,5 +1,5 @@ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: RDNZL; Base: 10 -*- -;;; $Header: /project/rdnzl/cvsroot/RDNZL/examples/deliver-acl.lisp,v 1.2 2006/02/01 01:00:57 eweitz Exp $ +;;; $Header: /project/rdnzl/cvsroot/RDNZL/examples/deliver-acl.lisp,v 1.3 2006/02/01 12:02:22 eweitz Exp $ ;;; Copyright (c) 2004-2006, Charles A. Cox. All rights reserved. --- /project/rdnzl/cvsroot/RDNZL/examples/deliver-ccl.lisp 2006/02/01 01:00:57 1.2 +++ /project/rdnzl/cvsroot/RDNZL/examples/deliver-ccl.lisp 2006/02/01 12:02:22 1.3 @@ -1,5 +1,5 @@ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: RDNZL; Base: 10 -*- -;;; $Header: /project/rdnzl/cvsroot/RDNZL/examples/deliver-ccl.lisp,v 1.2 2006/02/01 01:00:57 eweitz Exp $ +;;; $Header: /project/rdnzl/cvsroot/RDNZL/examples/deliver-ccl.lisp,v 1.3 2006/02/01 12:02:22 eweitz Exp $ ;;; Copyright (c) 2004-2006, Dr. Edmund Weitz. All rights reserved. --- /project/rdnzl/cvsroot/RDNZL/examples/deliver-lw.lisp 2006/02/01 01:00:57 1.3 +++ /project/rdnzl/cvsroot/RDNZL/examples/deliver-lw.lisp 2006/02/01 12:02:22 1.4 @@ -1,5 +1,5 @@ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: RDNZL; Base: 10 -*- -;;; $Header: /project/rdnzl/cvsroot/RDNZL/examples/deliver-lw.lisp,v 1.3 2006/02/01 01:00:57 eweitz Exp $ +;;; $Header: /project/rdnzl/cvsroot/RDNZL/examples/deliver-lw.lisp,v 1.4 2006/02/01 12:02:22 eweitz Exp $ ;;; Copyright (c) 2004-2006, Dr. Edmund Weitz. All rights reserved. --- /project/rdnzl/cvsroot/RDNZL/examples/messagebox.lisp 2006/02/01 01:00:57 1.2 +++ /project/rdnzl/cvsroot/RDNZL/examples/messagebox.lisp 2006/02/01 12:02:22 1.3 @@ -1,5 +1,5 @@ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: RDNZL; Base: 10 -*- -;;; $Header: /project/rdnzl/cvsroot/RDNZL/examples/messagebox.lisp,v 1.2 2006/02/01 01:00:57 eweitz Exp $ +;;; $Header: /project/rdnzl/cvsroot/RDNZL/examples/messagebox.lisp,v 1.3 2006/02/01 12:02:22 eweitz Exp $ ;;; Copyright (c) 2004-2006, Dr. Edmund Weitz. All rights reserved. --- /project/rdnzl/cvsroot/RDNZL/examples/url.lisp 2006/02/01 01:00:57 1.2 +++ /project/rdnzl/cvsroot/RDNZL/examples/url.lisp 2006/02/01 12:02:22 1.3 @@ -1,5 +1,5 @@ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: RDNZL; Base: 10 -*- -;;; $Header: /project/rdnzl/cvsroot/RDNZL/examples/url.lisp,v 1.2 2006/02/01 01:00:57 eweitz Exp $ +;;; $Header: /project/rdnzl/cvsroot/RDNZL/examples/url.lisp,v 1.3 2006/02/01 12:02:22 eweitz Exp $ ;;; Copyright (c) 2004-2006, Dr. Edmund Weitz. All rights reserved. From eweitz at common-lisp.net Sat Feb 18 22:26:13 2006 From: eweitz at common-lisp.net (eweitz) Date: Sat, 18 Feb 2006 16:26:13 -0600 (CST) Subject: [rdnzl-cvs] CVS RDNZL/doc Message-ID: <20060218222613.3F18D4E00F@common-lisp.net> Update of /project/rdnzl/cvsroot/RDNZL/doc In directory common-lisp:/tmp/cvs-serv27157/doc Modified Files: index.html Log Message: sync with 0.9.4 --- /project/rdnzl/cvsroot/RDNZL/doc/index.html 2006/02/01 12:02:22 1.6 +++ /project/rdnzl/cvsroot/RDNZL/doc/index.html 2006/02/18 22:26:13 1.7 @@ -58,6 +58,7 @@
new
cast
make-null-object
+ *coerce-double-floats-to-single*
RDNZL.dll
can be downloaded separately from
http://weitz.de/files/RDNZL_cpp.tar.gz but you don't need this archive
@@ -491,8 +492,8 @@
character
System.Char
string
System.String
pathname
System.String
double-float
System.Double
float
System.Single
DOUBLE-FLOAT
double-float
System.Double
*COERCE-DOUBLE-FLOATS-TO-SINGLE*
.float
System.Single
DOUBLE-FLOAT
.boolean
System.Boolean
[Special variable]
+
*coerce-double-floats-to-single*
+
+
+ +
If the value of this variable is true, +thenBOX
will convert a +LispDOUBLE-FLOAT
+value toSystem.Single
. This is mainly interesting for +LispWorks, where Lisp floats are alwaysDOUBLE-FLOAT
. +
Invokes the public .NET method named by the stringmethod-name
. If -object
is a container, an instance method is invoked. Ifobject
is a -string, the static method of the type named by this string is invoked. +object
is a container, an instance method is +invoked. Ifobject
is a string, the static method +of the type named by this string (which is looked up +usingSystem.Type::GetType
) is invoked. +Otherwise,object
should be a two-element list +where the first element is a container representing an assembly and +the second element is a string denoting a static method (which will be +looked up in that specific assembly).
[Accessor]
@@ -1073,7 +1092,7 @@
Thanks to Charles A. Cox for the port of RDNZL to AllegroCL. Thanks to Vasilis Margioulas for the CLISP port. Thanks to Roger Corman for his help with the CCL port. Thanks to Franz Inc. (and particularly Jans Aasman) for supporting the development of RDNZL.
-$Header: /project/rdnzl/cvsroot/RDNZL/doc/index.html,v 1.6 2006/02/01 12:02:22 eweitz Exp $ +$Header: /project/rdnzl/cvsroot/RDNZL/doc/index.html,v 1.7 2006/02/18 22:26:13 eweitz Exp $
BACK TO MY HOMEPAGE From eweitz at common-lisp.net Sat Feb 18 22:26:12 2006 From: eweitz at common-lisp.net (eweitz) Date: Sat, 18 Feb 2006 16:26:12 -0600 (CST) Subject: [rdnzl-cvs] CVS RDNZL Message-ID: <20060218222612.F392A4E00D@common-lisp.net> Update of /project/rdnzl/cvsroot/RDNZL In directory common-lisp:/tmp/cvs-serv27157 Modified Files: CHANGELOG.txt adapter.lisp arrays.lisp container.lisp direct.lisp ffi.lisp import.lisp load.lisp packages.lisp port-acl.lisp port-ccl.lisp port-clisp.lisp port-lw.lisp port-sbcl.lisp rdnzl.asd reader.lisp specials.lisp util.lisp Log Message: sync with 0.9.4 --- /project/rdnzl/cvsroot/RDNZL/CHANGELOG.txt 2006/02/01 12:02:21 1.6 +++ /project/rdnzl/cvsroot/RDNZL/CHANGELOG.txt 2006/02/18 22:26:12 1.7 @@ -1,3 +1,15 @@ +Version 0.9.4 +2006-02-18 +Fixed LW SINGLE-FLOAT issues (detective work by Dan Muller) + +Version 0.9.3 +2006-02-17 +Added *COERCE-DOUBLE-FLOATS-TO-SINGLE* + +Version 0.9.2 +2006-02-13 +One can now call static methods from specific assemblies (thanks to Jim Sokoloff) + Version 0.9.1 2006-02-01 Added missing WIDE-CHAR support for SBCL/Win32 --- /project/rdnzl/cvsroot/RDNZL/adapter.lisp 2006/02/01 12:02:21 1.4 +++ /project/rdnzl/cvsroot/RDNZL/adapter.lisp 2006/02/18 22:26:12 1.5 @@ -1,5 +1,5 @@ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: RDNZL; Base: 10 -*- -;;; $Header: /project/rdnzl/cvsroot/RDNZL/adapter.lisp,v 1.4 2006/02/01 12:02:21 eweitz Exp $ +;;; $Header: /project/rdnzl/cvsroot/RDNZL/adapter.lisp,v 1.5 2006/02/18 22:26:12 eweitz Exp $ ;;; Copyright (c) 2004-2006, Dr. Edmund Weitz. All rights reserved. --- /project/rdnzl/cvsroot/RDNZL/arrays.lisp 2006/02/01 12:02:21 1.4 +++ /project/rdnzl/cvsroot/RDNZL/arrays.lisp 2006/02/18 22:26:12 1.5 @@ -1,5 +1,5 @@ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: RDNZL; Base: 10 -*- -;;; $Header: /project/rdnzl/cvsroot/RDNZL/arrays.lisp,v 1.4 2006/02/01 12:02:21 eweitz Exp $ +;;; $Header: /project/rdnzl/cvsroot/RDNZL/arrays.lisp,v 1.5 2006/02/18 22:26:12 eweitz Exp $ ;;; Copyright (c) 2004-2006, Dr. Edmund Weitz. All rights reserved. --- /project/rdnzl/cvsroot/RDNZL/container.lisp 2006/02/01 12:02:21 1.4 +++ /project/rdnzl/cvsroot/RDNZL/container.lisp 2006/02/18 22:26:12 1.5 @@ -1,5 +1,5 @@ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: RDNZL; Base: 10 -*- -;;; $Header: /project/rdnzl/cvsroot/RDNZL/container.lisp,v 1.4 2006/02/01 12:02:21 eweitz Exp $ +;;; $Header: /project/rdnzl/cvsroot/RDNZL/container.lisp,v 1.5 2006/02/18 22:26:12 eweitz Exp $ ;;; Copyright (c) 2004-2006, Dr. Edmund Weitz. All rights reserved. @@ -193,7 +193,10 @@ (character (%make-dot-net-container-from-char object)) (double-float - (%make-dot-net-container-from-double object)) + (cond (*coerce-double-floats-to-single* + (%make-dot-net-container-from-float object)) + (t + (%make-dot-net-container-from-double object)))) (float (%make-dot-net-container-from-float object)) (pathname @@ -299,16 +302,26 @@ ,name ,args)))))) +(defun make-type-from-assembly-and-name (assembly name) + "Returns the .NET type with the name NAME from a specific assembly." + (ffi-call-with-args %invoke-instance-member + assembly "GetType" (list name))) + ;; generic functions and TYPECASE are avoided below to make delivered ;; images smaller (defun invoke (object method-name &rest args) - "Invokes the method named METHOD-NAME \(a string). If OBJECT is a -CONTAINER then the method is supposed to be an instance method of this -object. If OBJECT is a string then the method is supposed to be a -static method of the type named OBJECT. ARGS (either CONTAINER -structures or Lisp objects which can be converted) are the arguments -to this method." + "Invokes the method named METHOD-NAME \(a string). If OBJECT +is a CONTAINER then the method is supposed to be an instance +method of this object. If OBJECT is a string then the method is +supposed to be a static method of the type named OBJECT which +will be looked up using System.Type::GetType. Otherwise, OBJECT +should be a two-element list where the first element is a +CONTAINER representing an assembly and the second element is a +string denoting a static method \(which will be looked up in that +specific assembly). ARGS (either CONTAINER structures or Lisp +objects which can be converted) are the arguments to this +method." (let ((result (cond ((container-p object) (ffi-call-with-args %invoke-instance-member @@ -320,6 +333,13 @@ (make-type-from-name (resolve-type-name object)) method-name args)) + ((and (consp object) + (container-p (car object)) + (stringp (cdr object))) + (ffi-call-with-args %invoke-static-member + (make-type-from-assembly-and-name (car object) (cdr object)) + method-name + args)) (t (error "Don't know how to invoke ~A on ~S." method-name object))))) ;; if some of the arguments were pass-by-reference reset them to ;; their underlying types --- /project/rdnzl/cvsroot/RDNZL/direct.lisp 2006/02/01 12:02:21 1.4 +++ /project/rdnzl/cvsroot/RDNZL/direct.lisp 2006/02/18 22:26:12 1.5 @@ -1,5 +1,5 @@ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: RDNZL; Base: 10 -*- -;;; $Header: /project/rdnzl/cvsroot/RDNZL/direct.lisp,v 1.4 2006/02/01 12:02:21 eweitz Exp $ +;;; $Header: /project/rdnzl/cvsroot/RDNZL/direct.lisp,v 1.5 2006/02/18 22:26:12 eweitz Exp $ ;;; Copyright (c) 2004-2006, Dr. Edmund Weitz. All rights reserved. --- /project/rdnzl/cvsroot/RDNZL/ffi.lisp 2006/02/01 12:02:21 1.5 +++ /project/rdnzl/cvsroot/RDNZL/ffi.lisp 2006/02/18 22:26:12 1.6 @@ -1,5 +1,5 @@ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: RDNZL; Base: 10 -*- -;;; $Header: /project/rdnzl/cvsroot/RDNZL/ffi.lisp,v 1.5 2006/02/01 12:02:21 eweitz Exp $ +;;; $Header: /project/rdnzl/cvsroot/RDNZL/ffi.lisp,v 1.6 2006/02/18 22:26:12 eweitz Exp $ ;;; Copyright (c) 2004-2006, Dr. Edmund Weitz. All rights reserved. --- /project/rdnzl/cvsroot/RDNZL/import.lisp 2006/02/01 12:02:21 1.4 +++ /project/rdnzl/cvsroot/RDNZL/import.lisp 2006/02/18 22:26:12 1.5 @@ -1,5 +1,5 @@ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: RDNZL; Base: 10 -*- -;;; $Header: /project/rdnzl/cvsroot/RDNZL/import.lisp,v 1.4 2006/02/01 12:02:21 eweitz Exp $ +;;; $Header: /project/rdnzl/cvsroot/RDNZL/import.lisp,v 1.5 2006/02/18 22:26:12 eweitz Exp $ ;;; Copyright (c) 2004-2006, Dr. Edmund Weitz. All rights reserved. --- /project/rdnzl/cvsroot/RDNZL/load.lisp 2006/02/01 12:02:21 1.4 +++ /project/rdnzl/cvsroot/RDNZL/load.lisp 2006/02/18 22:26:12 1.5 @@ -1,5 +1,5 @@ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-USER; Base: 10 -*- -;;; $Header: /project/rdnzl/cvsroot/RDNZL/load.lisp,v 1.4 2006/02/01 12:02:21 eweitz Exp $ +;;; $Header: /project/rdnzl/cvsroot/RDNZL/load.lisp,v 1.5 2006/02/18 22:26:12 eweitz Exp $ ;;; Copyright (c) 2004-2006, Dr. Edmund Weitz. All rights reserved. --- /project/rdnzl/cvsroot/RDNZL/packages.lisp 2006/02/01 12:02:21 1.4 +++ /project/rdnzl/cvsroot/RDNZL/packages.lisp 2006/02/18 22:26:12 1.5 @@ -1,5 +1,5 @@ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-USER; Base: 10 -*- -;;; $Header: /project/rdnzl/cvsroot/RDNZL/packages.lisp,v 1.4 2006/02/01 12:02:21 eweitz Exp $ +;;; $Header: /project/rdnzl/cvsroot/RDNZL/packages.lisp,v 1.5 2006/02/18 22:26:12 eweitz Exp $ ;;; Copyright (c) 2004-2006, Dr. Edmund Weitz. All rights reserved. @@ -35,7 +35,8 @@ (defpackage :rdnzl (:use :cl) #+:sbcl (:shadow :defconstant) - (:export :aref* + (:export :*coerce-double-floats-to-single* + :aref* :box :cast :container-p --- /project/rdnzl/cvsroot/RDNZL/port-acl.lisp 2006/02/01 12:02:21 1.4 +++ /project/rdnzl/cvsroot/RDNZL/port-acl.lisp 2006/02/18 22:26:12 1.5 @@ -1,5 +1,5 @@ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: RDNZL; Base: 10 -*- -;;; $Header: /project/rdnzl/cvsroot/RDNZL/port-acl.lisp,v 1.4 2006/02/01 12:02:21 eweitz Exp $ +;;; $Header: /project/rdnzl/cvsroot/RDNZL/port-acl.lisp,v 1.5 2006/02/18 22:26:12 eweitz Exp $ ;;; Copyright (c) 2004-2006, Charles A. Cox, Dr. Edmund Weitz. All rights reserved. --- /project/rdnzl/cvsroot/RDNZL/port-ccl.lisp 2006/02/01 12:02:21 1.4 +++ /project/rdnzl/cvsroot/RDNZL/port-ccl.lisp 2006/02/18 22:26:12 1.5 @@ -1,5 +1,5 @@ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: RDNZL; Base: 10 -*- -;;; $Header: /project/rdnzl/cvsroot/RDNZL/port-ccl.lisp,v 1.4 2006/02/01 12:02:21 eweitz Exp $ +;;; $Header: /project/rdnzl/cvsroot/RDNZL/port-ccl.lisp,v 1.5 2006/02/18 22:26:12 eweitz Exp $ ;;; Copyright (c) 2004-2006, Dr. Edmund Weitz. All rights reserved. --- /project/rdnzl/cvsroot/RDNZL/port-clisp.lisp 2006/02/01 12:02:21 1.4 +++ /project/rdnzl/cvsroot/RDNZL/port-clisp.lisp 2006/02/18 22:26:12 1.5 @@ -1,5 +1,5 @@ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: RDNZL; Base: 10 -*- -;;; $Header: /project/rdnzl/cvsroot/RDNZL/port-clisp.lisp,v 1.4 2006/02/01 12:02:21 eweitz Exp $ +;;; $Header: /project/rdnzl/cvsroot/RDNZL/port-clisp.lisp,v 1.5 2006/02/18 22:26:12 eweitz Exp $ ;;; Copyright (c) 2004-2006, Vasilis Margioulas, Dr. Edmund Weitz. All rights reserved. --- /project/rdnzl/cvsroot/RDNZL/port-lw.lisp 2006/02/01 12:02:21 1.4 +++ /project/rdnzl/cvsroot/RDNZL/port-lw.lisp 2006/02/18 22:26:12 1.5 @@ -1,5 +1,5 @@ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: RDNZL; Base: 10 -*- -;;; $Header: /project/rdnzl/cvsroot/RDNZL/port-lw.lisp,v 1.4 2006/02/01 12:02:21 eweitz Exp $ +;;; $Header: /project/rdnzl/cvsroot/RDNZL/port-lw.lisp,v 1.5 2006/02/18 22:26:12 eweitz Exp $ ;;; Copyright (c) 2004-2006, Dr. Edmund Weitz. All rights reserved. @@ -70,7 +70,7 @@ (ffi-integer :int) (ffi-boolean :boolean) (ffi-wide-char :wchar-t) - (ffi-float :float) + (ffi-float :lisp-float) (ffi-double :double))) (defmacro ffi-define-function* ((lisp-name c-name) @@ -88,6 +88,7 @@ arg-list) :result-type ,(ffi-map-type result-type) :calling-convention :cdecl + :language :ansi-c ;; use the last module that was registered ,@(when *module-name* (list :module *module-name*)))) @@ -199,15 +200,13 @@ (defvar *exit-function-registered* nil "Whether LW:DEFINE-ACTION was already called for DllForceTerm.") -(defun register-exit-function (function &optional name) +(defmacro register-exit-function (function &optional name) "Makes sure the function FUNCTION \(with no arguments) is called before the Lisp images exits." - (unless *exit-function-registered* - (lw:define-action "When quitting image" - name - function - :once) - (setq *exit-function-registered* t))) + `(unless *exit-function-registered* + (lw:define-action "When quitting image" + ,name ,function :once) + (setq *exit-function-registered* t))) (defun full-gc () "Invokes a full garbage collection." --- /project/rdnzl/cvsroot/RDNZL/port-sbcl.lisp 2006/02/01 12:02:21 1.2 +++ /project/rdnzl/cvsroot/RDNZL/port-sbcl.lisp 2006/02/18 22:26:12 1.3 @@ -1,5 +1,5 @@ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: RDNZL; Base: 10 -*- -;;; $Header: /project/rdnzl/cvsroot/RDNZL/port-sbcl.lisp,v 1.2 2006/02/01 12:02:21 eweitz Exp $ +;;; $Header: /project/rdnzl/cvsroot/RDNZL/port-sbcl.lisp,v 1.3 2006/02/18 22:26:12 eweitz Exp $ ;;; Copyright (c) 2004-2006, Dr. Edmund Weitz. All rights reserved. --- /project/rdnzl/cvsroot/RDNZL/rdnzl.asd 2006/02/01 12:02:21 1.5 +++ /project/rdnzl/cvsroot/RDNZL/rdnzl.asd 2006/02/18 22:26:12 1.6 @@ -1,5 +1,5 @@ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-USER; Base: 10 -*- -;;; $Header: /project/rdnzl/cvsroot/RDNZL/rdnzl.asd,v 1.5 2006/02/01 12:02:21 eweitz Exp $ +;;; $Header: /project/rdnzl/cvsroot/RDNZL/rdnzl.asd,v 1.6 2006/02/18 22:26:12 eweitz Exp $ ;;; Copyright (c) 2004, Dr. Edmund Weitz. All rights reserved. @@ -39,7 +39,7 @@ (defsystem #:rdnzl :serial t - :version "0.9.1" + :version "0.9.4" :components ((:file "packages") (:file "specials") (:file "util") --- /project/rdnzl/cvsroot/RDNZL/reader.lisp 2006/02/01 12:02:21 1.4 +++ /project/rdnzl/cvsroot/RDNZL/reader.lisp 2006/02/18 22:26:12 1.5 @@ -1,5 +1,5 @@ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: RDNZL; Base: 10 -*- -;;; $Header: /project/rdnzl/cvsroot/RDNZL/reader.lisp,v 1.4 2006/02/01 12:02:21 eweitz Exp $ +;;; $Header: /project/rdnzl/cvsroot/RDNZL/reader.lisp,v 1.5 2006/02/18 22:26:12 eweitz Exp $ ;;; Copyright (c) 2004-2006, Dr. Edmund Weitz. All rights reserved. --- /project/rdnzl/cvsroot/RDNZL/specials.lisp 2006/02/01 12:02:21 1.4 +++ /project/rdnzl/cvsroot/RDNZL/specials.lisp 2006/02/18 22:26:12 1.5 @@ -1,5 +1,5 @@ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: RDNZL; Base: 10 -*- -;;; $Header: /project/rdnzl/cvsroot/RDNZL/specials.lisp,v 1.4 2006/02/01 12:02:21 eweitz Exp $ +;;; $Header: /project/rdnzl/cvsroot/RDNZL/specials.lisp,v 1.5 2006/02/18 22:26:12 eweitz Exp $ ;;; Copyright (c) 2004-2006, Dr. Edmund Weitz. All rights reserved. @@ -85,6 +85,11 @@ "A stack which holds the previous readtables that have been pushed here by ENABLE-RDNZL-SYNTAX.") +(defvar *coerce-double-floats-to-single* nil + "If this is true, then BOX will convert a Lisp DOUBLE-FLOAT +value to System.Single. This is mainly interesting for +LispWorks, where Lisp floats are always DOUBLE-FLOAT.") + (pushnew :rdnzl *features*) ;; stuff for Nikodemus Siivola's HYPERDOC --- /project/rdnzl/cvsroot/RDNZL/util.lisp 2006/02/01 12:02:21 1.4 +++ /project/rdnzl/cvsroot/RDNZL/util.lisp 2006/02/18 22:26:12 1.5 @@ -1,5 +1,5 @@ ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: RDNZL; Base: 10 -*- -;;; $Header: /project/rdnzl/cvsroot/RDNZL/util.lisp,v 1.4 2006/02/01 12:02:21 eweitz Exp $ +;;; $Header: /project/rdnzl/cvsroot/RDNZL/util.lisp,v 1.5 2006/02/18 22:26:12 eweitz Exp $ ;;; Copyright (c) 2004-2006, Dr. Edmund Weitz. All rights reserved.