Back to index

texmacs  1.0.7.15
Classes | Defines | Functions | Variables
guile_tm.cpp File Reference
#include "guile_tm.hpp"
#include "blackbox.hpp"
#include "file.hpp"
#include "../Scheme/glue.hpp"
#include "convert.hpp"

Go to the source code of this file.

Classes

struct  arg_list

Defines

#define SET_SMOB(smob, data, type)
#define SCM_BLACKBOXP(t)   (SCM_NIMP (t) && (((long) SCM_CAR (t)) == blackbox_tag))

Functions

void start_scheme (int argc, char **argv, void(*call_back)(int, char **))
SCM TeXmacs_lazy_catcher (void *data, SCM tag, SCM throw_args)
SCM TeXmacs_catcher (void *data, SCM tag, SCM args)
static SCM TeXmacs_lazy_eval_file (char *file)
static SCM TeXmacs_eval_file (char *file)
SCM eval_scheme_file (string file)
static SCM TeXmacs_lazy_eval_string (char *s)
static SCM TeXmacs_eval_string (char *s)
SCM eval_scheme (string s)
static SCM TeXmacs_call (arg_list *args)
static SCM TeXmacs_lazy_call_scm (arg_list *args)
static SCM TeXmacs_call_scm (arg_list *args)
SCM call_scheme (SCM fun)
SCM call_scheme (SCM fun, SCM a1)
SCM call_scheme (SCM fun, SCM a1, SCM a2)
SCM call_scheme (SCM fun, SCM a1, SCM a2, SCM a3)
SCM call_scheme (SCM fun, SCM a1, SCM a2, SCM a3, SCM a4)
SCM call_scheme (SCM fun, array< SCM > a)
string scheme_dialect ()
SCM bool_to_scm (bool flag)
SCM int_to_scm (int i)
SCM double_to_scm (double i)
tmscm string_to_tmscm (string s)
string tmscm_to_string (tmscm s)
tmscm symbol_to_tmscm (string s)
string tmscm_to_symbol (tmscm s)
bool tmscm_is_blackbox (tmscm t)
tmscm blackbox_to_tmscm (blackbox b)
blackbox tmscm_to_blackbox (tmscm blackbox_smob)
static SCM mark_blackbox (SCM blackbox_smob)
static scm_sizet free_blackbox (SCM blackbox_smob)
int print_blackbox (SCM blackbox_smob, SCM port, scm_print_state *pstate)
static SCM cmp_blackbox (SCM t1, SCM t2)
void initialize_smobs ()
void initialize_scheme ()

Variables

int guile_argc
char ** guile_argv
static long blackbox_tag
scm_smobfuns blackbox_smob_funcs
tmscm object_stack

Class Documentation

struct arg_list

Definition at line 141 of file guile_tm.cpp.

Collaboration diagram for arg_list:
Class Members
SCM * a
scm * a
int n

Define Documentation

#define SCM_BLACKBOXP (   t)    (SCM_NIMP (t) && (((long) SCM_CAR (t)) == blackbox_tag))

Definition at line 374 of file guile_tm.cpp.

#define SET_SMOB (   smob,
  data,
  type 
)
Value:
SCM_NEWCELL (smob);              \
SCM_SETCAR (smob, (SCM) (type)); \
SCM_SETCDR (smob, (SCM) (data));

Definition at line 249 of file guile_tm.cpp.


Function Documentation

Definition at line 383 of file guile_tm.cpp.

                               {
       SCM blackbox_smob;
       SET_SMOB (blackbox_smob, (void*) (tm_new<blackbox> (b)), (SCM) blackbox_tag);
       return blackbox_smob;
}

Here is the caller graph for this function:

SCM bool_to_scm ( bool  flag)

Definition at line 262 of file guile_tm.cpp.

                        {
       return scm_bool2scm (flag);
}

Here is the caller graph for this function:

SCM call_scheme ( SCM  fun)

Definition at line 177 of file guile_tm.cpp.

                      {
       SCM a[]= { fun }; arg_list args= { 0, a };
       return TeXmacs_call_scm (&args);
}

Here is the call graph for this function:

Here is the caller graph for this function:

SCM call_scheme ( SCM  fun,
SCM  a1 
)

Definition at line 183 of file guile_tm.cpp.

                              {
       SCM a[]= { fun, a1 }; arg_list args= { 1, a };
       return TeXmacs_call_scm (&args);
}

Here is the call graph for this function:

SCM call_scheme ( SCM  fun,
SCM  a1,
SCM  a2 
)

Definition at line 189 of file guile_tm.cpp.

                                      {
       SCM a[]= { fun, a1, a2 }; arg_list args= { 2, a };
       return TeXmacs_call_scm (&args);
}

Here is the call graph for this function:

SCM call_scheme ( SCM  fun,
SCM  a1,
SCM  a2,
SCM  a3 
)

Definition at line 195 of file guile_tm.cpp.

                                              {
       SCM a[]= { fun, a1, a2, a3 }; arg_list args= { 3, a };
       return TeXmacs_call_scm (&args);
}

Here is the call graph for this function:

SCM call_scheme ( SCM  fun,
SCM  a1,
SCM  a2,
SCM  a3,
SCM  a4 
)

Definition at line 201 of file guile_tm.cpp.

                                                      {
       SCM a[]= { fun, a1, a2, a3, a4 }; arg_list args= { 4, a };
       return TeXmacs_call_scm (&args);
}

Here is the call graph for this function:

SCM call_scheme ( SCM  fun,
array< SCM >  a 
)

Definition at line 207 of file guile_tm.cpp.

                                    {
       const int n= N(a);
       STACK_NEW_ARRAY(scm, SCM, n+1);
       int i;
       scm[0]= fun;
       for (i=0; i<n; i++) scm[i+1]= a[i];
       arg_list args= { n, scm };
       SCM ret= TeXmacs_call_scm (&args);
       STACK_DELETE_ARRAY(scm);
       return ret;
}

Here is the call graph for this function:

static SCM cmp_blackbox ( SCM  t1,
SCM  t2 
) [static]

Definition at line 439 of file guile_tm.cpp.

                              {
       return scm_bool2scm (tmscm_to_blackbox (t1) == tmscm_to_blackbox (t2));
}

Here is the call graph for this function:

SCM double_to_scm ( double  i)

Definition at line 300 of file guile_tm.cpp.

                         {
       return scm_double2scm (i);
}

Here is the caller graph for this function:

SCM eval_scheme ( string  s)

Definition at line 129 of file guile_tm.cpp.

                       {
       // cout << "Eval] " << s << "\n";
       char* _s= as_charp (s);
       SCM result= TeXmacs_eval_string (_s);
       tm_delete_array (_s);
       return result;
}

Here is the caller graph for this function:

SCM eval_scheme_file ( string  file)

Definition at line 98 of file guile_tm.cpp.

                               {
       //static int cumul= 0;
       //timer tm;
       if (DEBUG_STD) cout << "TeXmacs] Evaluating " << file << "...\n";
       char* _file= as_charp (file);
       SCM result= TeXmacs_eval_file (_file);
       tm_delete_array (_file);
       //int extra= tm->watch (); cumul += extra;
       //cout << extra << "\t" << cumul << "\t" << file << "\n";
       return result;
}

Here is the caller graph for this function:

static scm_sizet free_blackbox ( SCM  blackbox_smob) [static]

Definition at line 401 of file guile_tm.cpp.

                                  {
       blackbox *ptr = (blackbox *) SCM_CDR (blackbox_smob);
       tm_delete (ptr);
       return 0;
}

Here is the call graph for this function:

Definition at line 477 of file guile_tm.cpp.

                     {
       const char* init_prg =
    "(read-set! keywords 'prefix)\n"
    "(read-enable 'positions)\n"
    "(debug-enable 'debug)\n"
    ";(debug-enable 'backtrace)\n"
    "\n"
    "(define (display-to-string obj)\n"
    "  (call-with-output-string\n"
    "    (lambda (port) (display obj port))))\n"
    "(define (object->string obj)\n"
    "  (call-with-output-string\n"
    "    (lambda (port) (write obj port))))\n"
    "\n"
    "(define (texmacs-version) \"" TEXMACS_VERSION "\")\n"
    "(define object-stack '(()))";
       
       scm_c_eval_string (init_prg);
       initialize_smobs ();
       initialize_glue ();
       object_stack= scm_lookup_string ("object-stack");
       
// uncomment to have a guile repl available at startup  
//     gh_repl(guile_argc, guile_argv);
  //scm_shell (guile_argc, guile_argv);
  

}

Here is the caller graph for this function:

void initialize_smobs ( )

Definition at line 468 of file guile_tm.cpp.

                    {
       blackbox_tag= scm_newsmob (&blackbox_smob_funcs);
}

Here is the caller graph for this function:

SCM int_to_scm ( int  i)

Definition at line 279 of file guile_tm.cpp.

                   {
       return scm_long2scm ((long) i);
}

Here is the caller graph for this function:

static SCM mark_blackbox ( SCM  blackbox_smob) [static]

Definition at line 395 of file guile_tm.cpp.

                                  {
       (void) blackbox_smob;
       return SCM_BOOL_F;
}
int print_blackbox ( SCM  blackbox_smob,
SCM  port,
scm_print_state *  pstate 
)

Definition at line 408 of file guile_tm.cpp.

                                                                      {
       (void) pstate;
       string s = "<blackbox>";
       int type_ = type_box (tmscm_to_blackbox(blackbox_smob)) ;
       if (type_ == type_helper<tree>::id)
       {
              tree   t= tmscm_to_tree (blackbox_smob);
              s= "<tree " * tree_to_texmacs (t) * ">";
       } else if (type_ == type_helper<observer>::id)
       {
              s= "<observer>";
       } else if (type_ == type_helper<widget>::id)
       {
              s= "<widget>";
       } else if (type_ == type_helper<promise<widget> >::id)
       {
              s= "<promise-widget>";
       } else if (type_ == type_helper<command>::id) 
       {
              s= "<command>";
       } else if (type_ == type_helper<url>::id)
       {
              url    u= tmscm_to_url (blackbox_smob);
              s= "<url " * as_string (u) * ">";
       }
       
       scm_display (string_to_tmscm (s), port);
       return 1;
}

Here is the call graph for this function:

Definition at line 225 of file guile_tm.cpp.

                  {
#ifdef GUILE_A
       return "guile-a";
#else
#ifdef GUILE_B
       return "guile-b";
#else
#ifdef GUILE_C
       return "guile-c";
#else
#ifdef GUILE_D
       return "guile-d";
#else
       return "unknown";
#endif
#endif
#endif
#endif
}

Here is the caller graph for this function:

void start_scheme ( int  argc,
char **  argv,
void(*)(int, char **)  call_back 
)

Definition at line 43 of file guile_tm.cpp.

                                                                      {
       guile_argc = argc;
       guile_argv = argv;
#if (defined(GUILE_C) || defined(GUILE_D))
       old_call_back= call_back;
       scm_boot_guile (argc, argv, new_call_back, 0);
#else
#ifdef DOTS_OK
       gh_enter (argc, argv, (void (*)(...)) ((void*) call_back));
#else
       gh_enter (argc, argv, call_back);
#endif
#endif
}

Here is the caller graph for this function:

Definition at line 317 of file guile_tm.cpp.

                           {
       char* _s= as_charp (s);
       SCM r= scm_str2scm (_s, N(s));
       tm_delete_array (_s);
       return r;
}

Here is the call graph for this function:

Definition at line 348 of file guile_tm.cpp.

                           {
       char* _s= as_charp (s);
       SCM r= scm_symbol2scm (_s);
       tm_delete_array (_s);
       return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static SCM TeXmacs_call ( arg_list args) [static]

Definition at line 144 of file guile_tm.cpp.

                              {
       switch (args->n) {
              case 0: return scm_call_0 (args->a[0]); break;
              case 1: return scm_call_1 (args->a[0], args->a[1]); break;
              case 2: return scm_call_2 (args->a[0], args->a[1], args->a[2]); break;
              case 3:
                     return scm_call_3 (args->a[0], args->a[1], args->a[2], args->a[3]); break;
              default:
              {
                     int i;
                     SCM l= SCM_NULL;
                     for (i=args->n; i>=1; i--)
                            l= scm_cons (args->a[i], l);
                     return scm_apply_0 (args->a[0], l);
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static SCM TeXmacs_call_scm ( arg_list args) [static]

Definition at line 170 of file guile_tm.cpp.

                                  {
       return scm_internal_catch (SCM_BOOL_T,
                                                    (scm_t_catch_body) TeXmacs_lazy_call_scm, (void*) args,
                                                    (scm_t_catch_handler) TeXmacs_catcher, (void*) args);
}

Here is the call graph for this function:

Here is the caller graph for this function:

SCM TeXmacs_catcher ( void *  data,
SCM  tag,
SCM  args 
)

Definition at line 74 of file guile_tm.cpp.

                                                {
       (void) data;
       return scm_cons (tag, args);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static SCM TeXmacs_eval_file ( char *  file) [static]

Definition at line 91 of file guile_tm.cpp.

                               {
       return scm_internal_catch (SCM_BOOL_T,
                                                    (scm_t_catch_body) TeXmacs_lazy_eval_file, file,
                                                    (scm_t_catch_handler) TeXmacs_catcher, file);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static SCM TeXmacs_eval_string ( char *  s) [static]

Definition at line 122 of file guile_tm.cpp.

                              {
       return scm_internal_catch (SCM_BOOL_T,
                                                    (scm_t_catch_body) TeXmacs_lazy_eval_string, s,
                                                    (scm_t_catch_handler) TeXmacs_catcher, s);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static SCM TeXmacs_lazy_call_scm ( arg_list args) [static]

Definition at line 163 of file guile_tm.cpp.

                                       {
       return scm_internal_lazy_catch (SCM_BOOL_T,
                                                               (scm_t_catch_body) TeXmacs_call, (void*) args,
                                                               (scm_t_catch_handler) TeXmacs_lazy_catcher, (void*) args);
}

Here is the call graph for this function:

Here is the caller graph for this function:

SCM TeXmacs_lazy_catcher ( void *  data,
SCM  tag,
SCM  throw_args 
)

Definition at line 65 of file guile_tm.cpp.

                                                           {
       SCM eport= scm_current_error_port();
       scm_handle_by_message_noexit (data, tag, throw_args);
       scm_force_output (eport);
       scm_ithrow (tag, throw_args, 1);
       return SCM_UNSPECIFIED; /* never returns */
}

Here is the caller graph for this function:

static SCM TeXmacs_lazy_eval_file ( char *  file) [static]

Definition at line 84 of file guile_tm.cpp.

                                    {
       return scm_internal_lazy_catch (SCM_BOOL_T,
                                                               (scm_t_catch_body) scm_c_primitive_load, file,
                                                               (scm_t_catch_handler) TeXmacs_lazy_catcher, file);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static SCM TeXmacs_lazy_eval_string ( char *  s) [static]

Definition at line 115 of file guile_tm.cpp.

                                   {
       return scm_internal_lazy_catch (SCM_BOOL_T,
                                                               (scm_t_catch_body) scm_c_eval_string, s,
                                                               (scm_t_catch_handler) TeXmacs_lazy_catcher, s);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool tmscm_is_blackbox ( tmscm  t)

Definition at line 378 of file guile_tm.cpp.

                            {
       return SCM_BLACKBOXP (t);
}

Here is the caller graph for this function:

blackbox tmscm_to_blackbox ( tmscm  blackbox_smob)

Definition at line 390 of file guile_tm.cpp.

                                        {
       return *((blackbox*) SCM_CDR (blackbox_smob));
}

Here is the caller graph for this function:

Definition at line 325 of file guile_tm.cpp.

                          {
       guile_str_size_t len_r;
       char* _r= scm_scm2str (s, &len_r);
       string r (_r, len_r);
#ifdef OS_WIN32
       scm_must_free(_r);
#else
       free (_r);
#endif
       return r;
}

Definition at line 356 of file guile_tm.cpp.

                          {
       guile_str_size_t len_r;
       char* _r= scm_scm2symbol (s, &len_r);
       string r (_r, len_r);
#ifdef OS_WIN32
       scm_must_free(_r);
#else
       free (_r);
#endif
       return r;
}

Here is the caller graph for this function:


Variable Documentation

scm_smobfuns blackbox_smob_funcs
Initial value:

Definition at line 462 of file guile_tm.cpp.

long blackbox_tag [static]

Definition at line 372 of file guile_tm.cpp.

Definition at line 39 of file guile_tm.cpp.

char** guile_argv

Definition at line 40 of file guile_tm.cpp.

Definition at line 474 of file guile_tm.cpp.