guile-user
[Top][All Lists]
Advanced

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

Re: Clean Guile code from C program


From: Mike Gran
Subject: Re: Clean Guile code from C program
Date: Fri, 7 Mar 2008 10:30:12 -0800 (PST)

--- Jose Martin <address@hidden> wrote:

> I looked at the program's code and it looks a bit
> difficult to change it, and I must say I'm a
> beginner in C. Could anyone give me the steps of the
> changes I'd need to remove Guile-dependent code from
> C code?

Wow.  The Guile stuff is pretty well entangled.  If
you don't know enough C (and I think I saw some C++ in
there as well) you might be in over your head.

But, FWIW, here's how you'd do it.

1.  For every variable and function declared as type
SCM, figure out what type of information actually goes
in that variable.  Choose an appropriate C type
instead.

1a.  This code creates a special Guile type textmgr
which is, underneath, a C++ class textmgr.  Wherever
the textmgr stuff is used, call the C++ class's
procecures instead.

2.  For every function that begins with scm_, check
the docs for its purpose and recode them in C.  You
can usually ignore the scm_????_p functions because
they check the type of the variable, which won't be
necessary once you convert everything into appropriate
C types.

3.  The scm_shell creates a loop that displays a
prompt, takes user-typed commands, executes them, and
displays the output.  Invent some sort of input scheme
or input language and write a parser for it.  Have it
execute the commands that the user typed in.  (The
"readline" calls invoke a library called readline
which does command history stuff.  Your parser could
use the C API of readline instead.)

4.  Make sure that your C datatypes are freed
appropriately.

5. ???

6. Profit!

Good luck!

--
Mike Gran






reply via email to

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