[rdnzl-devel] Problem with invoking static member

Jim Sokoloff jim at sokoloff.com
Thu Feb 9 19:20:59 UTC 2006


It turns out that I don't have the freedom to
co-locate my .net assembly with clisp.exe
(because I have to have different versions of
the assembly loaded on a single machine in
different processes for dev, test, load-test,
and prod).


I'll propose the following patch (attached) to invoke:

Currently it takes an object (for an instance method)
or a type name (for a static method).

After this patch, object can also a cons of a loaded
assembly and a type name, and it will call a static
method on the type from that assembly.

So, in the previous transcript, the call which failed:
(invoke "LispSample1.Parrot" "StaticSayHello" "Bob" 15)

becomes:
(invoke (cons lisp-sample-assembly "LispSample1.Parrot")
         "StaticSayHello" "Bob" 15)

which now works.

Hopefully this patch (or a variant form) will be acceptable.

Thanks for RDNZL! :)
---Jim


diff -u c:\temp\rdNZL-0.9.1\container.lisp 
c:\vp\devenv\lib\clisp\rdNZL-0.9.1\container.lisp
--- c:\temp\rdNZL-0.9.1\container.lisp	2006-01-31 15:02:56.000000000 
-0500
+++ c:\vp\devenv\lib\clisp\rdNZL-0.9.1\container.lisp	2006-02-09 
13:59:03.984125000 -0500
@@ -163,6 +163,13 @@
     (ffi-call-with-foreign-string* %make-type-from-name
                                    name)))

+(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)))
+
  (defun get-object-as-string (container)
    "Get a string representation of the object denoted by CONTAINER.
  Uses 'ToString' internally."
@@ -320,6 +327,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



More information about the rdnzl-devel mailing list