]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/context-def.cc
(do_chroot_jail): paranoia security for webserver
[lilypond.git] / lily / context-def.cc
index b9f195eac2a87aef8f6600053f3e13db7c689887..0fc4cdfc2922d74c245e5094aa7f56521db566e8 100644 (file)
@@ -3,15 +3,15 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2000--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 /* TODO: should junk this class an replace by
    a single list of context modifications?  */
 
 #include "context-def.hh"
+
 #include "engraver.hh"
-#include "lily-proto.hh"
 #include "output-def.hh"
 #include "performer.hh"
 #include "score-context.hh"
@@ -92,14 +92,14 @@ Context_def::mark_smob (SCM smob)
 void
 Context_def::add_context_mod (SCM mod)
 {
-  SCM tag = ly_car (mod);
+  SCM tag = scm_car (mod);
   if (ly_symbol2scm ("description") == tag)
     {
-      description_ = ly_cadr (mod);
+      description_ = scm_cadr (mod);
       return;
     }
 
-  SCM sym = ly_cadr (mod);
+  SCM sym = scm_cadr (mod);
   if (scm_is_string (sym))
     sym = scm_string_to_symbol (sym);
   
@@ -143,10 +143,10 @@ Context_def::get_accepted (SCM user_mod) const
 {
   SCM mods = scm_reverse_x (scm_list_copy (accept_mods_), user_mod);
   SCM acc = SCM_EOL;
-  for (SCM s = mods; scm_is_pair (s); s = ly_cdr (s))
+  for (SCM s = mods; scm_is_pair (s); s = scm_cdr (s))
     {
-      SCM tag = ly_caar (s);
-      SCM sym = ly_cadar (s);
+      SCM tag = scm_caar (s);
+      SCM sym = scm_cadar (s);
       if (tag == ly_symbol2scm ("accepts"))
        acc = scm_cons (sym, acc);
       else if (tag == ly_symbol2scm ("denies"))
@@ -163,13 +163,13 @@ Context_def::path_to_acceptable_context (SCM type_sym, Output_def *odef) const
   SCM accepted = get_accepted (SCM_EOL);
 
   Link_array<Context_def> accepteds;
-  for (SCM s = accepted; scm_is_pair (s); s = ly_cdr (s))
+  for (SCM s = accepted; scm_is_pair (s); s = scm_cdr (s))
     if (Context_def *t = unsmob_context_def (find_context_def (odef,
-                                                              ly_car (s))))
+                                                              scm_car (s))))
       accepteds.push (t);
 
   Link_array<Context_def> best_result;
-  for (int i=0; i < accepteds.size (); i++)
+  for (int i = 0; i < accepteds.size (); i++)
     {
       /* do not check aliases, because \context Staff should not
         create RhythmicStaff. */
@@ -180,8 +180,8 @@ Context_def::path_to_acceptable_context (SCM type_sym, Output_def *odef) const
        }
     }
 
-  int best_depth= INT_MAX;
-  for (int i=0; i < accepteds.size (); i++)
+  int best_depth = INT_MAX;
+  for (int i = 0; i < accepteds.size (); i++)
     {
       Context_def * g = accepteds[i];
 
@@ -189,7 +189,7 @@ Context_def::path_to_acceptable_context (SCM type_sym, Output_def *odef) const
        = g->path_to_acceptable_context (type_sym, odef);
       if (result.size () && result.size () < best_depth)
        {
-         result.insert (g,0);
+         result.insert (g, 0);
          best_result = result;
 
          /* this following line was added in 1.9.3, but hsould've been
@@ -208,10 +208,10 @@ Context_def::get_translator_names (SCM user_mod) const
 
   SCM mods = scm_reverse_x (scm_list_copy (translator_mods_), user_mod);
   
-  for (SCM s = mods; scm_is_pair (s); s = ly_cdr (s))
+  for (SCM s = mods; scm_is_pair (s); s = scm_cdr (s))
     {
-      SCM tag = ly_caar (s);
-      SCM arg = ly_cadar (s);
+      SCM tag = scm_caar (s);
+      SCM arg = scm_cadar (s);
 
       if (scm_is_string (arg))
        arg = scm_string_to_symbol (arg);
@@ -232,9 +232,9 @@ filter_performers (SCM ell)
 {
   for (SCM *tail = &ell; scm_is_pair (*tail); tail = SCM_CDRLOC (*tail))
     {
-      if (dynamic_cast<Performer*> (unsmob_translator (ly_car (*tail))))
+      if (dynamic_cast<Performer*> (unsmob_translator (scm_car (*tail))))
        {
-         *tail = ly_cdr (*tail);
+         *tail = scm_cdr (*tail);
          if (!scm_is_pair (*tail))
            break ;
        }
@@ -248,9 +248,9 @@ filter_engravers (SCM ell)
   SCM *tail = &ell;  
   for (; scm_is_pair (*tail) ; tail = SCM_CDRLOC (*tail))
     {
-      if (dynamic_cast<Engraver*> (unsmob_translator (ly_car (*tail))))
+      if (dynamic_cast<Engraver*> (unsmob_translator (scm_car (*tail))))
        {
-         *tail = ly_cdr (*tail);
+         *tail = scm_cdr (*tail);
          if (!scm_is_pair (*tail))
            break ;
        }
@@ -260,14 +260,14 @@ filter_engravers (SCM ell)
 
 
 Context *
-Context_def::instantiate (SCM ops)
+Context_def::instantiate (SCM ops, Object_key const *key)
 {
   Context *tg =  0;
 
   if (context_name_ == ly_symbol2scm ("Score"))
-    tg = new Score_context ();
+    tg = new Score_context (key);
   else
-    tg = new Context ();
+    tg = new Context (key);
 
   tg->definition_ = self_scm ();
 
@@ -279,9 +279,9 @@ Context_def::instantiate (SCM ops)
 
   SCM trans_list = SCM_EOL;
   
-  for (SCM s = trans_names; scm_is_pair (s) ; s = ly_cdr (s))
+  for (SCM s = trans_names; scm_is_pair (s) ; s = scm_cdr (s))
     {
-      Translator *t = get_translator (ly_car (s));
+      Translator *t = get_translator (scm_car (s));
       if (!t)
        warning (_f ("can't find: `%s'", s));
       else
@@ -295,7 +295,7 @@ Context_def::instantiate (SCM ops)
              if (scm_is_pair (trans_list))
                scm_set_cdr_x (scm_last_pair (trans_list), cons);
              else
-               trans_list= cons;
+               trans_list = cons;
            }
          else
            {
@@ -320,15 +320,15 @@ Context_def::instantiate (SCM ops)
   
   scm_gc_unprotect_object (g->self_scm ());
   
-  tg->accepts_list_ = get_accepted  (ops);
-  
+  tg->accepts_list_ = get_accepted (ops);
+
   return tg;
 }
 
 SCM
 Context_def::clone_scm () const
 {
-  Context_def * t = new Context_def (*this);
+  Context_def *t = new Context_def (*this);
   SCM x = t->self_scm ();
   scm_gc_unprotect_object (x);
   return x;
@@ -337,7 +337,7 @@ Context_def::clone_scm () const
 SCM
 Context_def::make_scm ()
 {
-  Context_deft = new Context_def;
+  Context_def *t = new Context_def;
   SCM x = t->self_scm ();
   scm_gc_unprotect_object (x);
   return x;