]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/parse-scm.cc
Add \override and \revert music functions usable from Scheme
[lilypond.git] / lily / parse-scm.cc
index a8505fdec617c4d03243c02e42ef10ce9aef37c2..9db184c2ae0f107fcad38f2e13151a95d94a7c2d 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 2004--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 2004--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
   LilyPond is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -92,17 +92,12 @@ internal_ly_eval_scm (Parse_start *ps)
   if (ps->safe_)
     {
       static SCM module = SCM_BOOL_F;
-      if (module == SCM_BOOL_F)
+      if (scm_is_false (module))
         {
           SCM function = ly_lily_module_constant ("make-safe-lilypond-module");
           module = scm_gc_protect_object (scm_call_0 (function));
         }
 
-      // We define the parser so trusted Scheme functions can
-      // access the real namespace underlying the parser.
-      if (ps->parser_)
-        scm_module_define (module, ly_symbol2scm ("parser"),
-                           ps->parser_->self_scm ());
       return scm_eval (ps->form_, module);
     }
   return scm_primitive_eval (ps->form_);
@@ -125,7 +120,8 @@ parse_handler (void *data, SCM /*tag*/, SCM args)
 {
   Parse_start *ps = (Parse_start *) data;
 
-  ps->location_.error (_ ("GUILE signaled an error for the expression beginning here"));
+  ps->location_.non_fatal_error
+    (_ ("GUILE signaled an error for the expression beginning here"));
 
   if (scm_ilength (args) > 2)
     scm_display_error_message (scm_cadr (args), scm_caddr (args), scm_current_error_port ());
@@ -146,15 +142,15 @@ protected_ly_parse_scm (Parse_start *ps)
 }
 
 SCM
-protected_ly_eval_scm (Parse_start *ps)
+protected_ly_eval_scm (void *ps)
 {
   /*
     Catch #t : catch all Scheme level errors.
    */
   return scm_internal_catch (SCM_BOOL_T,
                              catch_protected_eval_body,
-                             (void *) ps,
-                             &parse_handler, (void *) ps);
+                             ps,
+                             &parse_handler, ps);
 }
 
 bool parse_protect_global = true;
@@ -178,8 +174,12 @@ ly_eval_scm (SCM form, Input i, bool safe, Lily_parser *parser)
 {
   Parse_start ps (form, i, safe, parser);
 
-  SCM ans = parse_protect_global ? protected_ly_eval_scm (&ps)
-            : internal_ly_eval_scm (&ps);
+  SCM ans = scm_c_with_fluid
+    (ly_lily_module_constant ("%location"),
+     i.smobbed_copy (),
+     parse_protect_global ? protected_ly_eval_scm
+     : catch_protected_eval_body, (void *) &ps);
+
   scm_remember_upto_here_1 (form);
   return ans;
 }