/*
This file is part of LilyPond, the GNU music typesetter.
- Copyright (C) 1998--2010 Jan Nieuwenhuizen <janneke@gnu.org>
+ Copyright (C) 1998--2011 Jan Nieuwenhuizen <janneke@gnu.org>
Han-Wen Nienhuys <hanwen@xs4all.nl>
LilyPond is free software: you can redistribute it and/or modify
LY_DEFINE (ly_context_id, "ly:context-id",
1, 0, 0, (SCM context),
"Return the ID string of @var{context},"
- " i.e., for @code{\\context Voice = one @dots{}}"
+ " i.e., for @code{\\context Voice = \"one\" @dots{}}"
" return the string @code{one}.")
{
Context *tr = unsmob_context (context);
LY_DEFINE (ly_context_name, "ly:context-name",
1, 0, 0, (SCM context),
"Return the name of @var{context},"
- " i.e., for @code{\\context Voice = one @dots{}}"
+ " i.e., for @code{\\context Voice = \"one\" @dots{}}"
" return the symbol @code{Voice}.")
{
LY_ASSERT_SMOB (Context, context, 1);
" @var{context} as an alist.")
{
Context *tr = unsmob_context (context);
-
+
LY_ASSERT_SMOB (Context, context, 1);
LY_ASSERT_TYPE (ly_is_symbol, name, 2);
}
LY_DEFINE (ly_context_property, "ly:context-property",
- 2, 0, 0, (SCM context, SCM sym),
- "Return the value for property @var{sym} in @var{context}.")
+ 2, 1, 0, (SCM context, SCM sym, SCM def),
+ "Return the value for property @var{sym} in @var{context}."
+ " If @var{def} is given, and property value is @code{'()},"
+ " return @var{def}.")
{
LY_ASSERT_SMOB (Context, context, 1);
LY_ASSERT_TYPE (ly_is_symbol, sym, 2);
Context *t = unsmob_context (context);
- return t->internal_get_property (sym);
+ SCM result = t->internal_get_property (sym);
+ return def != SCM_UNDEFINED && scm_is_null (result) ? def : result;
}
LY_DEFINE (ly_context_set_property_x, "ly:context-set-property!",
{
LY_ASSERT_SMOB (Context, context, 1);
LY_ASSERT_TYPE (ly_is_symbol, name, 2);
-
+
Context *tr = unsmob_context (context);
SCM val;
LY_ASSERT_SMOB (Context, context, 1);
LY_ASSERT_TYPE (ly_is_symbol, name, 2);
Context *tr = unsmob_context (context);
-
+
tr->unset_property (name);
return SCM_UNSPECIFIED;
}