guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PLEASE: debugging embedded guile code


From: Bruce Korb
Subject: Re: PLEASE: debugging embedded guile code
Date: Fri, 16 May 2003 13:27:00 -0700

Neil Jerram wrote:
> 
> >>>>> "Bruce" == Bruce Korb <address@hidden> writes:
> 
>     Bruce> Based on your example, I would need to emit this to libguile:
> 
>     Bruce>   (eval-client-input "...whatever...")
> 
>     Bruce> The problem is that the ``...whatever...'' is likely to
>     Bruce> often include double quotes, backslashes and all kinds of
>     Bruce> interesting stuff.  I don't particularly want to go over
>     Bruce> the string and reformat it so that the reader can
>     Bruce> reconstruct what I already have in hand.
> 
> You don't have to.  You can do something like this:
> 
>    SCM str = gh_str02scm( "...whatever..." );
>    SCM proc = scm_c_lookup( "eval-client-input" );
>    scm_call_1(proc, str);
> 
> Does this make sense?

Except for this:

ERROR: In procedure apply:
ERROR: Wrong type argument in position 1: #<variable 40288450 binding: 
#<procedure eval-client-input (str)>>
ABEND-ing in LOAD_TPL state
Last Guile command:
= = = = =
(setenv "SHELL" "/bin/sh")
= = = = =

Here's da code:

First, this is evaluated:

(define (eval-client-input str)
  (stack-catch #t
    (lambda ()
      (call-with-input-string str
        (lambda (p)
          (set-port-filename! p (tpl-file))
          (set-port-line! p (string->number (tpl-file-line "%2$d")))
          (list (primitive-eval (read p))))))
    (lambda (key . args)
      (apply display-error (fluid-ref the-last-stack)
                           (current-error-port)
                           args)
      (set! stack-saved? #f)
      #f
) ) )

The ``tpl-file'' and ``tpl-file-line'' thingeys are my own pre-registered
callback functions for getting file name and line number.

Then this function is invoked with "pzStr" pointing to the Guile command
noted above:

> static inline SCM ag_eval( tCC* pzStr )
> {
>     static SCM proc = SCM_UNDEFINED;
>     SCM str = gh_str02scm( pzStr );
>     pzLastScheme = pzStr;
> 
>     if (proc == SCM_UNDEFINED)
>         proc = scm_permanent_object( scm_c_lookup( "eval-client-input" ));
>     str = scm_call_1(proc, str);
>     pzLastScheme = NULL;
>     return str;
> }

My "atexit()" proc notices that pzLastScheme is not NULL.
If I replace all that code with just, ``return gh_eval_str( pzStr )''
it all works.  So, it's not quite equivalent yet, but it seems close.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]