unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Re: reprise: scm_c_eval_string_from_file_line
       [not found]       ` <87sjvdl6ce.fsf@gnu.org>
@ 2011-02-24 22:58         ` Bruce Korb
  2011-02-25 11:13           ` Andy Wingo
  2011-03-08 22:28           ` Andy Wingo
  0 siblings, 2 replies; 9+ messages in thread
From: Bruce Korb @ 2011-02-24 22:58 UTC (permalink / raw)
  To: guile-devel Development; +Cc: Ludovic Courtès

On 02/24/11 08:56, Ludovic Courtès wrote:
> It compiles fine up to here:
> 
> --8<---------------cut here---------------start------------->8---
> make[4]: Entering directory `/home/ludo/tmp/autogen-5.11.7pre1/getdefs'
> exec > gd.c ; \
> echo '#include "config.h"' ; \
> echo '#undef   PKGDATADIR' ; \
> echo '#define  PKGDATADIR "/home/ludo/soft/share/autogen"' ; \
> for f in opts.c getdefs.h proto.h getdefs.c gdemit.c gdinit.c ; \
> do echo "#include \"$f\"" ; done
> top_builddir=.. top_srcdir=.. PATH=`cd ../columns >/dev/null && pwd`:$PATH ; export top_builddir to
> p_srcdir PATH ; /home/ludo/tmp/autogen-5.11.7pre1/agen5/autogen -L../autoopts/tpl -L../autoopts/tpl
>  -MF.deps/opts-dep -MTstamp-opts ./opts.def
> module/ice-9/psyntax.scm:896:30: In procedure dobody:
> module/ice-9/psyntax.scm:896:30: Syntax error:
> ../autoopts/tpl/optlib.tlib:167:22: definition in expression context in subform UP-prefix of (string-append (string-upcase! (get "prefix")) "_")
> Scheme evaluation error.  AutoGen ABEND-ing in template
>         ../autoopts/tpl/optlib.tlib on line 66
[...]
> The failing code is:
> 
> --8<---------------cut here---------------start------------->8---
> (if (exist? "prefix")
>  (begin
>    (define UP-prefix  (string-append (string-upcase! (get "prefix")) "_"))
> --8<---------------cut here---------------end--------------->8---
> 
> ‘define’ is no longer allowed here (search ‘NEWS’ for ‘prohibiting
> definitions in expression’.)

This is an example of why it is important to be able to specify
the source file and line number where the scheme expression gets
extracted from.  This "../autoopts/tpl/optlib.tlib:167:22" thing
led Ludovic directly to the problematic code.  (He sees the problem,
I do not.)  But in order to get the Guile library to understand
where the code comes from, I have to go through what I consider
to be somersaults.

Anyway, picking up threads from 2003 and 2008:
http://osdir.com/ml/lisp.guile.devel/2003-05/msg00202.html
http://www.mail-archive.com/guile-devel@gnu.org/msg02825.html
http://www.mail-archive.com/guile-devel@gnu.org/msg02826.html

I would really, _really_ appreciate being able to yank it out of
my code.  Below is an example of what I go through to do it.
It is simplified somewhat since I no longer support Guile 1.4.

It simply doesn't feel like a straight forward interface.
It feels like I am starting a "process this string" function,
then inject some information, then call a function to scan
a bit then process a bit.  How would it ever get compiled?
It'd be nice to be able to say, "here's some text, from this
file and this line number, give me back the compiled form"
and then call the "run it" function.  But I can't.  I have to
insert the file and line information.  It's icky code.

Thank you.  Regards, Bruce

SCM
ag_scm_c_eval_string_from_file_line(
    char const * pzExpr, char const * pzFile, int line)
{
    SCM port = scm_open_input_string(AG_SCM_STR02SCM(pzExpr));

    if (OPT_VALUE_TRACE >= TRACE_EVERYTHING)
        fprintf(pfTrace, "eval from file %s line %d:\n%s\n", pzFile, line,
                pzExpr);

    {
        static SCM    file      = SCM_UNDEFINED;
        static char * pzOldFile = NULL;

        if ((pzOldFile == NULL) || (strcmp(pzOldFile, pzFile) != 0)) {
            if (pzOldFile != NULL)
                AGFREE(pzOldFile);
            AGDUPSTR(pzOldFile, pzFile, "scheme file source");
            file = AG_SCM_STR02SCM(pzFile);
        }

        {
#if GUILE_VERSION < 107000
            scm_t_port * pt = SCM_PTAB_ENTRY(port);
            pt->line_number = line - 1;
            pt->file_name   = file;
#else
            SCM ln = scm_from_int(line);
            scm_set_port_filename_x(port, file);
            scm_set_port_line_x(port, ln);
#endif
        }
    }

    {
        SCM ans = SCM_UNSPECIFIED;

        /* Read expressions from that port; ignore the values.  */
        for (;;) {
            SCM form = scm_read(port);
            if (SCM_EOF_OBJECT_P(form))
                break;
            ans = scm_primitive_eval_x(form);
        }

        return ans;
    }
}



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: reprise: scm_c_eval_string_from_file_line
  2011-02-24 22:58         ` reprise: scm_c_eval_string_from_file_line Bruce Korb
@ 2011-02-25 11:13           ` Andy Wingo
  2011-03-08 22:28           ` Andy Wingo
  1 sibling, 0 replies; 9+ messages in thread
From: Andy Wingo @ 2011-02-25 11:13 UTC (permalink / raw)
  To: Bruce Korb; +Cc: tès, guile-devel Development

Hi Bruce,

On Thu 24 Feb 2011 23:58, Bruce Korb <bkorb@gnu.org> writes:

> It simply doesn't feel like a straight forward interface.
> It feels like I am starting a "process this string" function,
> then inject some information, then call a function to scan
> a bit then process a bit.  How would it ever get compiled?
> It'd be nice to be able to say, "here's some text, from this
> file and this line number, give me back the compiled form"
> and then call the "run it" function.  But I can't.  I have to
> insert the file and line information.  It's icky code.

Agreed.  I'll see about getting something in for 2.0.1.

Regards,

Andy
-- 
http://wingolog.org/



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: reprise: scm_c_eval_string_from_file_line
  2011-02-24 22:58         ` reprise: scm_c_eval_string_from_file_line Bruce Korb
  2011-02-25 11:13           ` Andy Wingo
@ 2011-03-08 22:28           ` Andy Wingo
  2011-03-08 22:45             ` Bruce Korb
  1 sibling, 1 reply; 9+ messages in thread
From: Andy Wingo @ 2011-03-08 22:28 UTC (permalink / raw)
  To: Bruce Korb; +Cc: tès, guile-devel Development

Hi Bruce,

On Thu 24 Feb 2011 23:58, Bruce Korb <bkorb@gnu.org> writes:

> Anyway, picking up threads from 2003 and 2008:
> http://osdir.com/ml/lisp.guile.devel/2003-05/msg00202.html
> http://www.mail-archive.com/guile-devel@gnu.org/msg02825.html
> http://www.mail-archive.com/guile-devel@gnu.org/msg02826.html
>
> I would really, _really_ appreciate being able to yank it out of
> my code.  Below is an example of what I go through to do it.
> It is simplified somewhat since I no longer support Guile 1.4.
>
> It simply doesn't feel like a straight forward interface.
> It feels like I am starting a "process this string" function,
> then inject some information, then call a function to scan
> a bit then process a bit.  How would it ever get compiled?
> It'd be nice to be able to say, "here's some text, from this
> file and this line number, give me back the compiled form"
> and then call the "run it" function.  But I can't.  I have to
> insert the file and line information.  It's icky code.

> SCM
> ag_scm_c_eval_string_from_file_line(
>     char const * pzExpr, char const * pzFile, int line)

So!  I implemented something, but it's not quite what you asked for.

You can change your implementation to this:

  {
    static SCM eval_string_var = SCM_BOOL_F;

    if (scm_is_false (eval_string_var))
      eval_string_var = scm_c_public_lookup ("ice-9 eval-string",
                                             "eval-string");

    return scm_call_5 (scm_variable_ref (eval_string_var),
                       string,
                       scm_from_locale_keyword ("file"),
                       pzFile ? scm_from_locale_string (pzFile) : SCM_BOOL_F,
                       scm_from_locale_keyword ("line"),
                       scm_from_int (line));
  }

If you want to compile the expression, add #:compile? #t to the keyword
arguments.  If you want to use a different language, use #:lang.  See
the manual in git for more.

Regards,

Andy
-- 
http://wingolog.org/



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: reprise: scm_c_eval_string_from_file_line
  2011-03-08 22:28           ` Andy Wingo
@ 2011-03-08 22:45             ` Bruce Korb
  2011-03-08 22:52               ` Andy Wingo
  2011-03-09 10:07               ` Ludovic Courtès
  0 siblings, 2 replies; 9+ messages in thread
From: Bruce Korb @ 2011-03-08 22:45 UTC (permalink / raw)
  To: Andy Wingo; +Cc: tès, Ludovic, guile-devel Development

Hi Andy!

On 03/08/11 14:28, Andy Wingo wrote:
>> SCM
>> ag_scm_c_eval_string_from_file_line(
>>     char const * pzExpr, char const * pzFile, int line)
> 
> So!  I implemented something, but it's not quite what you asked for.

Sufficiently close that the resulting code isn't "icky". :)
It no longer has the feel of tendrils stuck into the
workings of Guile code.  It isn't as trivial to me, but then
maybe there aren't a lot of folks pulling text from various
files and feeding it to "eval-string".

So, this should go under:
#if GUILE_VERSION > 200000 // anything after 2.0, e.g. 2.0.1 ??

> You can change your implementation to this:
> 
>   {
>     static SCM eval_string_var = SCM_BOOL_F;
> 
>     if (scm_is_false (eval_string_var))
>       eval_string_var = scm_c_public_lookup ("ice-9 eval-string",
>                                              "eval-string");
> 
>     return scm_call_5 (scm_variable_ref (eval_string_var),
>                        string,

Wouldn't this arg need to be SCM-ized?  viz. scm_from_locale_string (string)

>                        scm_from_locale_keyword ("file"),
>                        pzFile ? scm_from_locale_string (pzFile) : SCM_BOOL_F,
>                        scm_from_locale_keyword ("line"),
>                        scm_from_int (line));
>   }
> 
> If you want to compile the expression, add #:compile? #t to the keyword
> arguments.

I guess I'll need to read docs.  From this sentence, I'd be guessing
that I'd need to use "scm_call_7" and add:
   scm_from_locale_keyword("#:compile?"), scm_from_locale_keyword("#t"),
to the arg list.  I think you just added scm_call_5 for this purpose.

Anyway, thank you !  I do appreciate.  Regards, Bruce



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: reprise: scm_c_eval_string_from_file_line
  2011-03-08 22:45             ` Bruce Korb
@ 2011-03-08 22:52               ` Andy Wingo
  2011-03-09  6:30                 ` Mark H Weaver
  2011-03-09 10:07               ` Ludovic Courtès
  1 sibling, 1 reply; 9+ messages in thread
From: Andy Wingo @ 2011-03-08 22:52 UTC (permalink / raw)
  To: Bruce Korb; +Cc: tès, Ludovic, guile-devel Development

On Tue 08 Mar 2011 23:45, Bruce Korb <bkorb@gnu.org> writes:

> So, this should go under:
> #if GUILE_VERSION > 200000 // anything after 2.0, e.g. 2.0.1 ??

Yes, I think that's right.

>>     return scm_call_5 (scm_variable_ref (eval_string_var),
>>                        string,
>
> Wouldn't this arg need to be SCM-ized?  viz. scm_from_locale_string
> (string)

Indeed; though you should think about encodings here.  There is also
scm_from_utf8_string and scm_from_latin1_string, and there will soon be
scm_from_latin1_keyword which is likely preferable to
scm_from_locale_keyword in this case.

> I guess I'll need to read docs.  From this sentence, I'd be guessing
> that I'd need to use "scm_call_7" and add:
>    scm_from_locale_keyword("#:compile?"), scm_from_locale_keyword("#t"),

                                            ^ SCM_BOOL_T, of course.

> to the arg list.  I think you just added scm_call_5 for this purpose.

Indeed, though there is not a scm_call_7 yet :P  You can always use the
scm_apply family, or build up an array and use scm_call_n.

Cheers,

Andy
-- 
http://wingolog.org/



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: reprise: scm_c_eval_string_from_file_line
  2011-03-08 22:52               ` Andy Wingo
@ 2011-03-09  6:30                 ` Mark H Weaver
  0 siblings, 0 replies; 9+ messages in thread
From: Mark H Weaver @ 2011-03-09  6:30 UTC (permalink / raw)
  To: Andy Wingo; +Cc: tès, Ludovic, Bruce Korb, guile-devel Development

Andy Wingo <wingo@pobox.com> writes:
>>>     return scm_call_5 (scm_variable_ref (eval_string_var),
>>>                        string,
>>
>> Wouldn't this arg need to be SCM-ized?  viz. scm_from_locale_string
>> (string)
>
> Indeed; though you should think about encodings here.  There is also
> scm_from_utf8_string and scm_from_latin1_string, and there will soon be
> scm_from_latin1_keyword which is likely preferable to
> scm_from_locale_keyword in this case.

FYI, I just pushed scm_from_latin1_keyword to git.  It will be in 2.0.1.

>
>> I guess I'll need to read docs.  From this sentence, I'd be guessing
>> that I'd need to use "scm_call_7" and add:
>>    scm_from_locale_keyword("#:compile?"), scm_from_locale_keyword("#t"),
>
>                                             ^ SCM_BOOL_T, of course.

Also, the argument to scm_from_locale_keyword (or better yet,
scm_from_latin1_keyword) should be "compile?", not "#:compile?".

     Best,
      Mark



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: reprise: scm_c_eval_string_from_file_line
  2011-03-08 22:45             ` Bruce Korb
  2011-03-08 22:52               ` Andy Wingo
@ 2011-03-09 10:07               ` Ludovic Courtès
  2011-03-09 20:15                 ` Andy Wingo
  1 sibling, 1 reply; 9+ messages in thread
From: Ludovic Courtès @ 2011-03-09 10:07 UTC (permalink / raw)
  To: Bruce Korb; +Cc: Andy Wingo, Ludovic, guile-devel Development

Hi,

Bruce Korb <bkorb@gnu.org> writes:

> So, this should go under:
> #if GUILE_VERSION > 200000 // anything after 2.0, e.g. 2.0.1 ??

Rather use AC_CHECK_FUNC.

Thanks,
Ludo’.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: reprise: scm_c_eval_string_from_file_line
  2011-03-09 10:07               ` Ludovic Courtès
@ 2011-03-09 20:15                 ` Andy Wingo
  2011-03-10  9:35                   ` Bruce Korb
  0 siblings, 1 reply; 9+ messages in thread
From: Andy Wingo @ 2011-03-09 20:15 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: Ludovic, Bruce Korb, guile-devel Development

Greets,

On Wed 09 Mar 2011 11:07, ludo@gnu.org (Ludovic Courtès) writes:

> Bruce Korb <bkorb@gnu.org> writes:
>
>> So, this should go under:
>> #if GUILE_VERSION > 200000 // anything after 2.0, e.g. 2.0.1 ??
>
> Rather use AC_CHECK_FUNC.

You'd have to check for (ice-9 eval-string) as well, added at the same
time.

Andy
-- 
http://wingolog.org/



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: reprise: scm_c_eval_string_from_file_line
  2011-03-09 20:15                 ` Andy Wingo
@ 2011-03-10  9:35                   ` Bruce Korb
  0 siblings, 0 replies; 9+ messages in thread
From: Bruce Korb @ 2011-03-10  9:35 UTC (permalink / raw)
  To: Andy Wingo; +Cc: Ludovic Courtès, Ludovic, guile-devel Development

[-- Attachment #1: Type: text/plain, Size: 1245 bytes --]

Hi Andy,

On 03/09/11 12:15, Andy Wingo wrote:
>>> So, this should go under:
>>> #if GUILE_VERSION > 200000 // anything after 2.0, e.g. 2.0.1 ??
>>
>> Rather use AC_CHECK_FUNC.
> 
> You'd have to check for (ice-9 eval-string) as well, added at the same
> time.

Then scm_call_5 implies (ice-9 eval-string), and vice versa.

AC_CHECK_FUNC is the correct approach for testing platform features
coming from different vendors.  It is not the right approach for
dealing with one platform (the Guile library) that has well understood
features and feature (interface) changes.  I've actually developed
an entire glue layer.  My "ag" interface layers on top of the
gh/scm/whatever and is provided by a header and a little code.
The header is enclosed for your amusement.  I don't think 30 feature
tests is appropriate.  autoconf takes long enough as it is,
hence my little "libposix" project.  To elaborate here a bit, it
basically installs fixed or missing POSIX stuff on a platform.
By testing for the existence and version (note: "VERSION") of that
library, you can safely presume all the POSIX bits are present
and working, and eliminate all the "is this POSIX feature present"
feature tests.  The bulk of my build time is autoconf feature testing.

[-- Attachment #2: guile-iface.h --]
[-- Type: text/x-chdr, Size: 7641 bytes --]

#if   GUILE_VERSION < 107000
# define AG_SCM_APPLY2(_op, _f, _tst) gh_call2(_op, _f, _tst)
# define AG_SCM_BOOL_P(_b)            SCM_BOOLP(_b)
# define AG_SCM_BOOT_GUILE(_ac, _av, _im) \
    gh_enter((_ac), (_av), (_im))
# define AG_SCM_CHAR(_c)              gh_scm2char(_c)
# define AG_SCM_CHARS(_s)             SCM_CHARS(_s)
# define AG_SCM_CHAR_P(_c)            SCM_CHARP(_c)
# define AG_SCM_DISPLAY(_s)           gh_display(_s)
# define AG_SCM_FALSEP(_r)            SCM_FALSEP(_r)
# define AG_SCM_FROM_LONG(_l)         gh_long2scm(_l)
# define AG_SCM_INT2SCM(_i)           gh_int2scm(_i)
# define AG_SCM_IS_PROC(_p)           SCM_NFALSEP( scm_procedure_p(_p))
# define AG_SCM_LIST_P(_l)            SCM_NFALSEP( scm_list_p(_l))
# define AG_SCM_LISTOFNULL()          scm_listofnull
# define AG_SCM_LONG2SCM(_i)          gh_long2scm(_i)
# define AG_SCM_NFALSEP(_r)           SCM_NFALSEP(_r)
# define AG_SCM_NULLP(_m)             scm_is_null(_m)
# define AG_SCM_NUM_P(_n)             SCM_NUMBERP(_n)
# define AG_SCM_PAIR_P(_p)            SCM_NFALSEP( scm_pair_p(_p))
# define AG_SCM_STR02SCM(_s)          scm_makfrom0str(_s)
# define AG_SCM_STR2SCM(_st,_sz)      scm_mem2string(_st,_sz)
# define AG_SCM_STRING_P(_s)          SCM_STRINGP(_s)
# define AG_SCM_STRLEN(_s)            SCM_STRING_LENGTH(_s)
# define AG_SCM_SYM_P(_s)             SCM_SYMBOLP(_s)
# define AG_SCM_TO_INT(_i)            gh_scm2int(_i)
# define AG_SCM_TO_LONG(_v)           gh_scm2long(_v)
# define AG_SCM_TO_NEWSTR(_s)         gh_scm2newstr(_s, NULL)
# define AG_SCM_TO_ULONG(_v)          gh_scm2ulong(_v)
# define AG_SCM_VEC_P(_v)             SCM_VECTORP(_v)

#elif GUILE_VERSION < 108000
# define AG_SCM_APPLY2(_op, _f, _tst) gh_call2(_op, _f, _tst)
# define AG_SCM_BOOL_P(_b)            SCM_BOOLP(_b)
# define AG_SCM_BOOT_GUILE(_ac, _av, _im) \
    gh_enter((_ac), (_av), (_im))
# define AG_SCM_CHAR(_c)              gh_scm2char(_c)
# define AG_SCM_CHARS(_s)             SCM_STRING_CHARS(_s)
# define AG_SCM_CHAR_P(_c)            SCM_CHARP(_c)
# define AG_SCM_DISPLAY(_s)           gh_display(_s)
# define AG_SCM_FALSEP(_r)            scm_is_false(_r)
# define AG_SCM_FROM_LONG(_l)         gh_long2scm(_l)
# define AG_SCM_INT2SCM(_i)           gh_int2scm(_i)
# define AG_SCM_IS_PROC(_p)           scm_is_true( scm_procedure_p(_p))
# define AG_SCM_LIST_P(_l)            scm_is_true( scm_list_p(_l))
# define AG_SCM_LISTOFNULL()          scm_listofnull
# define AG_SCM_LONG2SCM(_i)          gh_long2scm(_i)
# define AG_SCM_NFALSEP(_r)           scm_is_true(_r)
# define AG_SCM_NULLP(_m)             scm_is_null(_m)
# define AG_SCM_NUM_P(_n)             scm_is_number(_n)
# define AG_SCM_PAIR_P(_p)            scm_is_true( scm_pair_p(_p))
# define AG_SCM_STR02SCM(_s)          scm_from_locale_string(_s)
# define AG_SCM_STR2SCM(_st,_sz)      scm_from_locale_stringn(_st,_sz)
# define AG_SCM_STRING_P(_s)          scm_is_string(_s)
# define AG_SCM_STRLEN(_s)            SCM_STRING_LENGTH(_s)
# define AG_SCM_SYM_P(_s)             SCM_SYMBOLP(_s)
# define AG_SCM_TO_INT(_i)            gh_scm2int(_i)
# define AG_SCM_TO_LONG(_v)           gh_scm2long(_v)
# define AG_SCM_TO_NEWSTR(_s)         scm_to_locale_string(_s)
# define AG_SCM_TO_ULONG(_v)          gh_scm2ulong(_v)
# define AG_SCM_VEC_P(_v)             SCM_VECTORP(_v)

#elif GUILE_VERSION < 109000
# define AG_SCM_APPLY2(_op, _f, _tst) \
    scm_apply(_op, _f, scm_cons(_tst, AG_SCM_LISTOFNULL()))
# define AG_SCM_BOOL_P(_b)            scm_is_bool(_b)
# define AG_SCM_BOOT_GUILE(_ac, _av, _im) \
    scm_boot_guile((_ac), (_av), (_im), NULL)
# define AG_SCM_CHAR(_c)              SCM_CHAR(_c)
# define AG_SCM_CHARS(_s)             scm_i_string_chars(_s)
# define AG_SCM_CHAR_P(_c)            SCM_CHARP(_c)
# define AG_SCM_DISPLAY(_s)           \
    scm_display(_s, scm_current_output_port())
# define AG_SCM_FALSEP(_r)            scm_is_false(_r)
# define AG_SCM_FROM_LONG(_l)         scm_from_long(_l)
# define AG_SCM_INT2SCM(_i)           scm_from_int(_i)
# define AG_SCM_IS_PROC(_p)           scm_is_true( scm_procedure_p(_p))
# define AG_SCM_LIST_P(_l)            scm_is_true( scm_list_p(_l))
# define AG_SCM_LISTOFNULL()          scm_listofnull
# define AG_SCM_LONG2SCM(_i)          scm_from_long(_i)
# define AG_SCM_NFALSEP(_r)           scm_is_true(_r)
# define AG_SCM_NULLP(_m)             scm_is_null(_m)
# define AG_SCM_NUM_P(_n)             scm_is_number(_n)
# define AG_SCM_PAIR_P(_p)            scm_is_true( scm_pair_p(_p))
# define AG_SCM_STR02SCM(_s)          scm_from_locale_string(_s)
# define AG_SCM_STR2SCM(_st,_sz)      scm_from_locale_stringn(_st,_sz)
# define AG_SCM_STRING_P(_s)          scm_is_string(_s)
# define AG_SCM_STRLEN(_s)            scm_c_string_length(_s)
# define AG_SCM_SYM_P(_s)             scm_is_symbol(_s)
# define AG_SCM_TO_INT(_i)            scm_to_int(_i)
# define AG_SCM_TO_LONG(_v)           scm_to_long(_v)
# define AG_SCM_TO_NEWSTR(_s)         scm_to_locale_string(_s)
# define AG_SCM_TO_ULONG(_v)          scm_to_ulong(_v)
# define AG_SCM_VEC_P(_v)             scm_is_vector(_v)

#elif GUILE_VERSION < 201000
# define AG_SCM_APPLY2(_op, _f, _tst) \
    scm_apply(_op, _f, scm_cons(_tst, AG_SCM_LISTOFNULL()))
# define AG_SCM_BOOL_P(_b)            scm_is_bool(_b)
# define AG_SCM_BOOT_GUILE(_ac, _av, _im) \
    scm_boot_guile((_ac), (_av), (_im), NULL)
# define AG_SCM_CHAR(_c)              SCM_CHAR(_c)
# define AG_SCM_CHARS(_s)             scm_i_string_chars(_s)
# define AG_SCM_CHAR_P(_c)            SCM_CHARP(_c)
# define AG_SCM_DISPLAY(_s)           \
    scm_display(_s, scm_current_output_port())
# define AG_SCM_FALSEP(_r)            scm_is_false(_r)
# define AG_SCM_FROM_LONG(_l)         scm_from_long(_l)
# define AG_SCM_INT2SCM(_i)           scm_from_int(_i)
# define AG_SCM_IS_PROC(_p)           scm_is_true( scm_procedure_p(_p))
# define AG_SCM_LIST_P(_l)            scm_is_true( scm_list_p(_l))
# define AG_SCM_LISTOFNULL()          scm_list_1(SCM_EOL)
# define AG_SCM_LONG2SCM(_i)          scm_from_long(_i)
# define AG_SCM_NFALSEP(_r)           scm_is_true(_r)
# define AG_SCM_NULLP(_m)             scm_is_null(_m)
# define AG_SCM_NUM_P(_n)             scm_is_number(_n)
# define AG_SCM_PAIR_P(_p)            scm_is_true( scm_pair_p(_p))
# define AG_SCM_STR02SCM(_s)          scm_from_locale_string(_s)
# define AG_SCM_STR2SCM(_st,_sz)      scm_from_locale_stringn(_st,_sz)
# define AG_SCM_STRING_P(_s)          scm_is_string(_s)
# define AG_SCM_STRLEN(_s)            scm_c_string_length(_s)
# define AG_SCM_SYM_P(_s)             scm_is_symbol(_s)
# define AG_SCM_TO_INT(_i)            scm_to_int(_i)
# define AG_SCM_TO_LONG(_v)           scm_to_long(_v)
# define AG_SCM_TO_NEWSTR(_s)         scm_to_locale_string(_s)
# define AG_SCM_TO_ULONG(_v)          scm_to_ulong(_v)
# define AG_SCM_VEC_P(_v)             scm_is_vector(_v)

# define scm_sizet                    size_t

#else
#error unknown GUILE_VERSION
#endif

#if GUILE_VERSION < 107000  /* pre-Guile 1.7.x */

  static inline char * ag_scm2zchars(SCM s, char const * type)
  {
    if (! AG_SCM_STRING_P(s))
        AG_ABEND(aprf(zNotStr, type));

    if (SCM_SUBSTRP(s))
        s = scm_makfromstr(SCM_CHARS(s), SCM_LENGTH(s), 0);
    return SCM_CHARS(s);
  }

#else /* Guile 1.7 and following */

  extern char * ag_scm2zchars(SCM s, char const * type);

#endif

static inline SCM ag_eval(char const * pzStr)
{
    SCM res;
    char const * pzSaveScheme = pzLastScheme; /* Watch for nested calls */
    pzLastScheme = pzStr;

    res = ag_scm_c_eval_string_from_file_line(
        pzStr, pCurTemplate->pzTplFile, pCurMacro->lineNo);

    pzLastScheme = pzSaveScheme;
    return res;
}

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-03-10  9:35 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.4.1298297717.17321.info-gnu@gnu.org>
     [not found] ` <87vd0cqjvx.fsf@gnu.org>
     [not found]   ` <4D643043.6080406@gnu.org>
     [not found]     ` <4D658101.7030307@gnu.org>
     [not found]       ` <87sjvdl6ce.fsf@gnu.org>
2011-02-24 22:58         ` reprise: scm_c_eval_string_from_file_line Bruce Korb
2011-02-25 11:13           ` Andy Wingo
2011-03-08 22:28           ` Andy Wingo
2011-03-08 22:45             ` Bruce Korb
2011-03-08 22:52               ` Andy Wingo
2011-03-09  6:30                 ` Mark H Weaver
2011-03-09 10:07               ` Ludovic Courtès
2011-03-09 20:15                 ` Andy Wingo
2011-03-10  9:35                   ` Bruce Korb

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).