Re: Is it possible to call function pointer value?

"Jong-Kyou Kim" <[email protected]> Sun, 27 Jul 2003 13:06:56 +0900
Newsgroups gmane.lisp.corman
Message-ID <001401c353f4$869eb720$0300a8c0@alpha>
Hi Chris,

Thank you very much for your information.

I needed this information because I found that it would be quite interesting if we could wrap corman lisp code with wxWindows based GUI system.

The following is a small code sample what I'm experimenting. Now, the cormanlisp code which computes factorial could display a message box before computing the value using wxWindows API by calling a wrapper function `foo'. Ugly but practical solution for providing GUI interface for corman lisp, I think.

Best regards,

Jong-Kyou

--------- following code --------

int foo()
{
    wxMessageBox("foo");
    return 0;
}

void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
    wxString msg;

    msg.Printf(_("fac(10) = %d"), dll_fac(10, foo));

    wxMessageBox(msg, _T("About Minimal"), wxOK | wxICON_INFORMATION, this);
}

(defun fac (n)
  (if (<= n 0)
      1
    (* n (fac (- n 1)))))

(ct:defun-pointer call-foo ())

(ct:defun-dll-export-c-function (dll_fac "dll_fac") ((n :long) (foo-ptr (:void *)))
   "long dll_fac(long n, void* fooptr)"
   (call-foo foo-ptr)
   (fac n))

  ----- Original Message ----- 
  From: Chris Double 
  To: [email protected] 
  Sent: Sunday, July 27, 2003 7:27 AM
  Subject: Re: [cormanlisp] Is it possible to call function pointer value?


  On Sun, 27 Jul 2003 01:57, Jong-Kyou Kim wrote:
  > Is it possible to pass a function pointer into cormanlisp function and
  > call it within the lisp function?

  Yes, it's definitely possible. Have a look through the archives of the mailing 
  list and you'll find your answer. It was asked a month or two ago I believe 
  but I can't recall the answer unfortunately.

  http://groups.yahoo.com/group/cormanlisp

  Chris.

        Yahoo! Groups Sponsor 
              ADVERTISEMENT
             
       
       

  To unsubscribe from this group, send an email to:
  [email protected]



  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.