]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/context-mod-scheme.cc
Run grand-replace (issue 3765)
[lilypond.git] / lily / context-mod-scheme.cc
index 245749604af8e65c7d818f83a0c1c5ba836396f6..6c04c0baf92461d4a4d39b26d2bbbf7f38340062 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 2010 Jan Nieuwenhuizen <janneke@gnu.org>
+  Copyright (C) 2010--2014 Jan Nieuwenhuizen <janneke@gnu.org>
   Han-Wen Nienhuys <hanwen@xs4all.nl>
 
   LilyPond is free software: you can redistribute it and/or modify
 #include "context.hh"
 #include "context-mod.hh"
 
-LY_DEFINE (ly_get_context_mods,
-          "ly:get-context-mods",
-          1, 0, 0, (SCM contextmod),
-          "Returns the list of context modifications stored in @var{contextmod}.")
+LY_DEFINE (ly_get_context_mods, "ly:get-context-mods",
+           1, 0, 0, (SCM contextmod),
+           "Returns the list of context modifications stored in"
+           " @var{contextmod}.")
 {
   Context_mod *tr = unsmob_context_mod (contextmod);
   LY_ASSERT_SMOB (Context_mod, contextmod, 1);
   return tr->get_mods ();
 }
 
-LY_DEFINE (ly_add_context_mod,
-          "ly:add-context-mod",
-          2, 0, 0, (SCM contextmods, SCM modification),
-          "Adds the given context @var{modification} to the list @var{contextmods} of context modifications.")
+LY_DEFINE (ly_add_context_mod, "ly:add-context-mod",
+           2, 0, 0, (SCM contextmods, SCM modification),
+           "Adds the given context @var{modification} to the list"
+           " @var{contextmods} of context modifications.")
 {
   Context_mod *ctxmod = unsmob_context_mod (contextmods);
   LY_ASSERT_SMOB (Context_mod, contextmods, 1);
@@ -42,3 +42,29 @@ LY_DEFINE (ly_add_context_mod,
   return SCM_UNSPECIFIED;
 }
 
+LY_DEFINE (ly_make_context_mod, "ly:make-context-mod",
+           0, 1, 0, (SCM mod_list),
+           "Creates a context modification, optionally initialized"
+           " via the list of modifications @var{mod-list}.")
+{
+  if (mod_list != SCM_UNDEFINED)
+    {
+      LY_ASSERT_TYPE (ly_cheap_is_list, mod_list, 1);
+      return Context_mod (mod_list).smobbed_copy ();
+    }
+  else
+    return Context_mod ().smobbed_copy ();
+}
+
+LY_DEFINE (ly_context_mod_apply_x, "ly:context-mod-apply!",
+           2, 0, 0, (SCM context, SCM mod),
+           "Apply the context modification @var{mod} to @var{context}.")
+{
+  LY_ASSERT_SMOB (Context, context, 1);
+  LY_ASSERT_SMOB (Context_mod, mod, 2);
+
+  apply_property_operations (unsmob_context (context),
+                             unsmob_context_mod (mod)->get_mods ());
+  scm_remember_upto_here_1 (context);
+  return SCM_UNSPECIFIED;
+}