]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/context-mod-scheme.cc
Merge remote-tracking branch 'origin/translation' into staging
[lilypond.git] / lily / context-mod-scheme.cc
index b993a7de8f33e6e728b713ae49dbf974828513df..6c04c0baf92461d4a4d39b26d2bbbf7f38340062 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 2010--2011 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
@@ -21,8 +21,7 @@
 #include "context.hh"
 #include "context-mod.hh"
 
-LY_DEFINE (ly_get_context_mods,
-           "ly:get-context-mods",
+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}.")
@@ -32,8 +31,7 @@ LY_DEFINE (ly_get_context_mods,
   return tr->get_mods ();
 }
 
-LY_DEFINE (ly_add_context_mod,
-           "ly:add-context-mod",
+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.")
@@ -44,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;
+}