[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: g-wrap <gw-guile-wct> questions
From: |
Steve Tell |
Subject: |
Re: g-wrap <gw-guile-wct> questions |
Date: |
Fri, 27 Aug 2004 00:26:07 -0400 (EDT) |
On Mon, 16 Aug 2004, Andy Wingo wrote:
> Hey Steve,
>
> On Mon, 16 Aug 2004, Steve Tell wrote:
>
> > (define-method (wrap-value-cg (wct <gw:parport*>)
> > (value <gw-value>)
> > status-var)
> > (let ((wct-var (slot-ref wct 'wct-var-name))
> > (sv (scm-var value))
> > (cv (var value)))
> > (list
> > "if(" cv " == NULL) scm_syserror_msg(\"wrap(gw:parport*)\", \"error
> > ~a\", SCM_EOL, errno);\n"
> > "else " sv " = gw_wcp_assimilate_ptr((void *) " cv ", " wct-var
> > ");\n")))
> >
> >
> > (I'm doing the call to scm_syserror_msg wrong somehow;
>
> Yeah, you should be using gw:error. It's a bizarre construct, e.g.
>
> `(gw:error ,status-var type ,(wrapped-var value))
>
> First the gw:error symbol, then the name of the status var, then a
> symbol indicating which kind of error, then type-specific args:
>
> ;; (list 'gw:error status-var 'misc msg format-args)
> ;; (list 'gw:error status-var 'memory)
> ;; (list 'gw:error status-var 'range scm-item-out-of-range)
> ;; (list 'gw:error status-var 'type scm-bad-type-item)
> ;; (list 'gw:error status-var 'argc)
Thanks for clearing that up; it is a bit tangled.
(I'm curious why GWerror and gw:error are necessary; it can't be for
portability to non-guile targets since the wrap/unwrap methods are
already in the guile-specific side of g-wrap.)
Anyway, I'm back in town and fooling with this again.
A gw:error of flavor 'misc seems to be what I want, but I can't seem to
get the format-args to work. Here's somthing that I think ought to be close:
define-method (wrap-value-cg (wct <gw:parport*>)
(value <gw-value>)
status-var)
(let ((wct-var (slot-ref wct 'wct-var-name))
(sv (scm-var value))
(cv (var value)))
(list
"if(" cv " == NULL)\n"
`(gw:error ,status-var misc "\"syserror ~S\""
"scm_cons(scm_strerror(SCM_MAKINUM(errno)),SCM_EOL)")
"else " sv " = gw_wcp_assimilate_ptr((void *) " cv ", " wct-var ");\n")))
When my testbench causes an error to check all this, I get:
test-guile-dev-parport.scm:73:14: In procedure parport-open-device in
expression (parport-open-device "/dev/barfport0bad"):
test-guile-dev-parport.scm:73:14: syserror ~S
The message string is printed, but not interpreted by format together with the
arguments.
My current workaround is to change the gw:error line to this:
`(gw:error ,status-var misc "strerror(errno)" "scm_cons(SCM_BOOL_F,SCM_EOL)")
which produces an acceptable message:
test-guile-dev-parport.scm:73:14: In procedure parport-open-device in
expression (parport-open-device "/dev/barfport0bad"):
test-guile-dev-parport.scm:73:14: No such file or directory
Following things down into guile-1.6.4/libguile, I think this is safe
- the static message from strerror appears to get copied into a
guile-string soon enough - but I feel like the format-message with
args ought to work. It would be necessary for other more interesting cases.
Steve
- g-wrap? libffi?, Steve Tell, 2004/08/03
- Re: g-wrap? libffi?, Andreas Rottmann, 2004/08/03
- Re: g-wrap? libffi?, Steve Tell, 2004/08/03
- Re: g-wrap? libffi?, Andreas Rottmann, 2004/08/04
- g-wrap <gw-guile-wct> questions, Steve Tell, 2004/08/12
- Re: g-wrap <gw-guile-wct> questions, Andy Wingo, 2004/08/15
- Re: g-wrap <gw-guile-wct> questions, Steve Tell, 2004/08/16
- Re: g-wrap <gw-guile-wct> questions, Andy Wingo, 2004/08/17
- Re: g-wrap <gw-guile-wct> questions,
Steve Tell <=
- Re: g-wrap <gw-guile-wct> questions, Andreas Rottmann, 2004/08/18