]> git.donarmstrong.com Git - lilypond.git/commitdiff
replace SCM_ASSERT_TYPE with LY_ASSERT_TYPE and friends
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 27 Jan 2007 01:55:22 +0000 (02:55 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 27 Jan 2007 01:55:22 +0000 (02:55 +0100)
51 files changed:
lily/book-scheme.cc
lily/engraver.cc
lily/font-config-scheme.cc
lily/font-metric-scheme.cc
lily/function-documentation.cc
lily/general-scheme.cc
lily/global-context-scheme.cc
lily/global-context.cc
lily/grob-array-scheme.cc
lily/grob-interface-scheme.cc
lily/grob-property.cc
lily/grob-scheme.cc
lily/include/font-metric.hh
lily/include/global-context.hh
lily/include/lily-guile-macros.hh
lily/include/music-output.hh
lily/input-scheme.cc
lily/item-scheme.cc
lily/lily-guile.cc
lily/lily-lexer-scheme.cc
lily/lily-parser-scheme.cc
lily/moment-scheme.cc
lily/music-function-scheme.cc
lily/music-scheme.cc
lily/note-head-scheme.cc
lily/open-type-font-scheme.cc
lily/output-def-scheme.cc
lily/pango-select-scheme.cc
lily/paper-book-scheme.cc
lily/paper-outputter-scheme.cc
lily/paper-score-scheme.cc
lily/paper-score.cc
lily/performance-scheme.cc
lily/performance.cc
lily/pfb-scheme.cc [new file with mode: 0644]
lily/pfb.cc
lily/pitch-scheme.cc
lily/prob-scheme.cc
lily/program-option-scheme.cc [new file with mode: 0644]
lily/program-option.cc
lily/scale.cc
lily/scheme-listener-scheme.cc
lily/score-scheme.cc
lily/simple-spacer-scheme.cc
lily/spanner-scheme.cc
lily/staff-symbol-referencer-scheme.cc
lily/stencil-scheme.cc
lily/stream-event-scheme.cc
lily/text-interface.cc
lily/translator-scheme.cc
lily/ttf.cc

index 5a975041608ca85178fe3302e8ae48021deef014..1bf602907a68f7a31c520f8411756d31258f0555 100644 (file)
@@ -73,11 +73,10 @@ LY_DEFINE (ly_book_process_to_systems, "ly:book-process-to-systems",
           "a string (for file based outputs) or a socket (for network based "
           "output).")
 {
-  Book *book = unsmob_book (book_smob);
+  LY_ASSERT_FIRST_SMOB (Book, book_smob);
+
+  Book *book = unsmob_book (book_smob); 
 
-  LY_FUNC_NOTE_FIRST_ARG(book_smob);
-  
-  LY_ASSERT_SMOB(Book,1);
   LY_ASSERT_SMOB(Output_def, 2);
   LY_ASSERT_SMOB(Output_def, 3);
 
index ac74d5e93064f9c808dccf6358fc95fae9465cc3..29f4b2f198be88d1ede0408fc7ee47f512281c4b 100644 (file)
@@ -96,8 +96,7 @@ LY_DEFINE (ly_set_grob_creation_callback, "ly:set-grob-creation-callback",
           "the grob to be created and the corresponding line number in the "
           "C++ source file.")
 {
-  SCM_ASSERT_TYPE(ly_is_procedure (cb), cb, SCM_ARG1, __FUNCTION__,
-                 "procedure");
+  LY_ASSERT_FIRST_TYPE (ly_is_procedure, cb);
 
   creation_callback = cb;
 
index 5d734899b2b8a3cf95ba7a91d4a7ec19dc0c0bd2..ddcbd201978bf54c0c439438584090086624b206 100644 (file)
@@ -89,9 +89,7 @@ LY_DEFINE (ly_font_config_get_font_file, "ly:font-config-get-font-file", 1, 0, 0
           (SCM name),
           "Get the file for font @var{name}")
 {
-  SCM_ASSERT_TYPE (scm_is_string (name), name,
-                  SCM_ARG1, __FUNCTION__, "string");
-
+  LY_ASSERT_FIRST_TYPE(scm_is_string, name);
   
   FcPattern*pat = FcPatternCreate ();
   FcValue val;
index db231fd11d50f4554c5c8a36aba43ac6ad27da84..96b79def6d75438cdef58878cbb0d6ddf6fbdd3b 100644 (file)
@@ -20,8 +20,8 @@ LY_DEFINE (ly_font_get_glyph, "ly:font-get-glyph",
           "is not available, return @code{#f}.")
 {
   Font_metric *fm = unsmob_metrics (font);
-  SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
-  SCM_ASSERT_TYPE (scm_is_string (name), name, SCM_ARG2, __FUNCTION__, "string");
+  LY_ASSERT_FIRST_SMOB (Font_metric, font);
+  LY_ASSERT_TYPE(scm_is_string, 2);
 
   Stencil m = fm->find_by_name (ly_scm2string (name));
 
@@ -36,8 +36,8 @@ LY_DEFINE (ly_get_glyph, "ly:get-glyph",
           "in @var{font}.")
 {
   Font_metric *fm = unsmob_metrics (font);
-  SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
-  SCM_ASSERT_TYPE (scm_is_number (index), index, SCM_ARG2, __FUNCTION__, "number");
+  LY_ASSERT_FIRST_SMOB (Font_metric, font);
+  LY_ASSERT_TYPE(scm_is_number, 2);
 
   return fm->get_ascii_char_stencil (scm_to_int (index)).smobbed_copy ();
 }
@@ -48,8 +48,8 @@ LY_DEFINE (ly_font_glyph_name_to_index, "ly:font-glyph-name-to-index",
           "Return the index for @var{name} in @var{font}.")
 {
   Font_metric *fm = unsmob_metrics (font);
-  SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
-  SCM_ASSERT_TYPE (scm_is_string (name), name, SCM_ARG2, __FUNCTION__, "string");
+  LY_ASSERT_FIRST_SMOB (Font_metric, font);
+  LY_ASSERT_TYPE(scm_is_string, 2);
 
   return scm_from_int (fm->name_to_index (ly_scm2string (name)));
 }
@@ -60,8 +60,8 @@ LY_DEFINE (ly_font_index_to_charcode, "ly:font-index-to-charcode",
           "Return the character code for @var{index} @var{font}.")
 {
   Font_metric *fm = unsmob_metrics (font);
-  SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
-  SCM_ASSERT_TYPE (scm_is_integer (index), index, SCM_ARG2, __FUNCTION__, "index");
+  LY_ASSERT_FIRST_SMOB (Font_metric, font);
+  LY_ASSERT_TYPE(scm_is_integer, 2);
 
   return scm_from_unsigned_integer (fm->index_to_charcode (scm_to_int (index)));
 }
@@ -72,8 +72,8 @@ LY_DEFINE (ly_font_glyph_name_to_charcode, "ly:font-glyph-name-to-charcode",
           "Return the character code for glyph @var{name} in @var{font}.")
 {
   Font_metric *fm = unsmob_metrics (font);
-  SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
-  SCM_ASSERT_TYPE (scm_is_string (name), name, SCM_ARG2, __FUNCTION__, "string");
+  LY_ASSERT_FIRST_SMOB (Font_metric, font);
+  LY_ASSERT_TYPE(scm_is_string, 2);
 
   return scm_from_unsigned_integer (fm->index_to_charcode (fm->name_to_index (ly_scm2string (name))));
 }
@@ -89,8 +89,8 @@ LY_DEFINE (ly_text_dimension, "ly:text-dimension",
   Modified_font_metric *fm = dynamic_cast<Modified_font_metric *>
     (unsmob_metrics (font));
 
-  SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "modified font metric");
-  SCM_ASSERT_TYPE (scm_is_string (text), text, SCM_ARG2, __FUNCTION__, "string");
+  LY_ASSERT_FIRST_SMOB (Font_metric, font);
+  LY_ASSERT_TYPE(scm_is_string, 2);
   Stencil stc (fm->text_stencil (ly_scm2string (text)));
   return scm_cons (ly_interval2scm (stc.extent (X_AXIS)),
                   ly_interval2scm (stc.extent (Y_AXIS)));
@@ -106,8 +106,9 @@ LY_DEFINE (ly_font_file_name, "ly:font-file-name",
           "Given the font metric @var{font}, "
           "return the corresponding file name.")
 {
+  LY_ASSERT_FIRST_SMOB (Font_metric, font);
+
   Font_metric *fm = unsmob_metrics (font);
-  SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
   SCM name = fm->font_file_name ();
 
   return name;
@@ -119,9 +120,9 @@ LY_DEFINE (ly_font_name, "ly:font-name",
           "Given the font metric @var{font}, "
           "return the corresponding name.")
 {
+  LY_ASSERT_FIRST_SMOB (Font_metric, font);
   Font_metric *fm = unsmob_metrics (font);
 
-  SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
   return ly_string2scm (fm->font_name ());
 }
 
@@ -130,8 +131,9 @@ LY_DEFINE (ly_font_magnification, "ly:font-magnification", 1, 0, 0,
           "Given the font metric @var{font}, return the "
           "magnification, relative to the current output-scale.")
 {
+  LY_ASSERT_FIRST_SMOB (Font_metric, font);
+
   Font_metric *fm = unsmob_metrics (font);
-  SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
   return scm_cdr (fm->description_);
 }
 
@@ -140,8 +142,9 @@ LY_DEFINE (ly_font_design_size, "ly:font-design-size", 1, 0, 0,
           "Given the font metric @var{font}, return the "
           "design size, relative to the current output-scale.")
 {
+  LY_ASSERT_FIRST_SMOB (Font_metric, font);
+
   Font_metric *fm = unsmob_metrics (font);
-  SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
   return scm_from_double (fm->design_size ());
 }
 
index 867911967fefadc2ec121fb313a6c422b39691f9..38e85837c0f6397b894c3f14b29cf67b59e6c5bc 100644 (file)
@@ -13,6 +13,11 @@ using namespace std;
 #include "lily-guile.hh"
 #include "warn.hh"
 
+/* type predicates. */
+#include "spanner.hh"
+#include "item.hh"
+
+
 static SCM doc_hash_table;
 
 void
@@ -100,6 +105,8 @@ init_func_doc ()
   ly_add_type_predicate ((void*) &ly_is_symbol, "symbol");
   ly_add_type_predicate ((void*) &scm_is_vector, "vector");
   ly_add_type_predicate ((void*) &is_axis, "axis");
+  ly_add_type_predicate ((void*) &unsmob_spanner, "spanner");
+  ly_add_type_predicate ((void*) &unsmob_item, "item");
 }
 
 ADD_SCM_INIT_FUNC(func_doc, init_func_doc);
index 868d2d11fb1f2620aaad23fa5f0117b76d70b5e0..b12e2664e649cd0338349757fe49e7c785ce9c4c 100644 (file)
@@ -32,7 +32,7 @@ LY_DEFINE (ly_find_file, "ly:find-file",
           "Return the absolute file name of @var{name}, "
           "or @code{#f} if not found.")
 {
-  SCM_ASSERT_TYPE (scm_is_string (name), name, SCM_ARG1, __FUNCTION__, "string");
+  LY_ASSERT_FIRST_TYPE(scm_is_string, name);
 
   string nm = ly_scm2string (name);
   string file_name = global_path.find (nm);
@@ -51,11 +51,11 @@ LY_DEFINE (ly_gulp_file, "ly:gulp-file",
           "Read the file @var{name}, and return its contents in a string.  "
           "The file is looked up using the search path. ")
 {
-  SCM_ASSERT_TYPE (scm_is_string (name), name, SCM_ARG1, __FUNCTION__, "string");
+  LY_ASSERT_FIRST_TYPE(scm_is_string, name);
   int sz = INT_MAX;
   if (size != SCM_UNDEFINED)
     {
-      SCM_ASSERT_TYPE (scm_is_number (size), size, SCM_ARG2, __FUNCTION__, "number");
+      LY_ASSERT_TYPE(scm_is_number, 2);
       sz = scm_to_int (size);
     }
   
@@ -68,7 +68,7 @@ LY_DEFINE (ly_error, "ly:error",
           "Scheme callable function to issue the error @code{msg}. "
           "The error is formatted with @code{format} and @code{rest}.")
 {
-  SCM_ASSERT_TYPE (scm_is_string (str), str, SCM_ARG1, __FUNCTION__, "string");
+  LY_ASSERT_FIRST_TYPE(scm_is_string, str);
   str = scm_simple_format (SCM_BOOL_F, str, rest);
   error (ly_scm2string (str));
   return SCM_UNSPECIFIED;
@@ -79,7 +79,7 @@ LY_DEFINE (ly_message, "ly:message",
           "Scheme callable function to issue the message @code{msg}. "
           "The message is formatted with @code{format} and @code{rest}.")
 {
-  SCM_ASSERT_TYPE (scm_is_string (str), str, SCM_ARG1, __FUNCTION__, "string");
+  LY_ASSERT_FIRST_TYPE(scm_is_string, str);
   str = scm_simple_format (SCM_BOOL_F, str, rest);
   message (ly_scm2string (str));
   return SCM_UNSPECIFIED;
@@ -90,7 +90,7 @@ LY_DEFINE (ly_progress, "ly:progress",
           "Scheme callable function to print progress @code{str}. "
           "The message is formatted with @code{format} and @code{rest}.")
 {
-  SCM_ASSERT_TYPE (scm_is_string (str), str, SCM_ARG1, __FUNCTION__, "string");
+  LY_ASSERT_FIRST_TYPE(scm_is_string, str);
   str = scm_simple_format (SCM_BOOL_F, str, rest);
   progress_indication (ly_scm2string (str));
   return SCM_UNSPECIFIED;
@@ -101,7 +101,7 @@ LY_DEFINE (ly_programming_error, "ly:programming-error",
           "Scheme callable function to issue the warning @code{msg}. "
           "The message is formatted with @code{format} and @code{rest}.")
 {
-  SCM_ASSERT_TYPE (scm_is_string (str), str, SCM_ARG1, __FUNCTION__, "string");
+  LY_ASSERT_FIRST_TYPE(scm_is_string, str);
   str = scm_simple_format (SCM_BOOL_F, str, rest);
   programming_error (ly_scm2string (str));
   return SCM_UNSPECIFIED;
@@ -112,7 +112,7 @@ LY_DEFINE (ly_warning, "ly:warning",
           "Scheme callable function to issue the warning @code{str}. "
           "The message is formatted with @code{format} and @code{rest}.")
 {
-  SCM_ASSERT_TYPE (scm_is_string (str), str, SCM_ARG1, __FUNCTION__, "string");
+  LY_ASSERT_FIRST_TYPE(scm_is_string, str);
   str = scm_simple_format (SCM_BOOL_F, str, rest);
   warning (ly_scm2string (str));
   return SCM_UNSPECIFIED;
@@ -152,9 +152,9 @@ LY_DEFINE (ly_string_substitute, "ly:string-substitute",
           3, 0, 0, (SCM a, SCM b, SCM s),
           "Replace @var{a} by @var{b} in @var{s}.")
 {
-  SCM_ASSERT_TYPE (scm_is_string (a), s, SCM_ARG1, __FUNCTION__, "string");
-  SCM_ASSERT_TYPE (scm_is_string (b), s, SCM_ARG2, __FUNCTION__, "string");
-  SCM_ASSERT_TYPE (scm_is_string (s), s, SCM_ARG3, __FUNCTION__, "string");
+  LY_ASSERT_FIRST_TYPE(scm_is_string, s);
+  LY_ASSERT_TYPE(scm_is_string, 2);
+  LY_ASSERT_TYPE(scm_is_string, 3);
 
   string ss = ly_scm2string (s);
   replace_all (ss, string (scm_i_string_chars (a)),
@@ -166,7 +166,7 @@ LY_DEFINE (ly_number_2_string, "ly:number->string",
           1, 0, 0, (SCM s),
           "Convert @var{num} to a string without generating many decimals.")
 {
-  SCM_ASSERT_TYPE (scm_is_number (s), s, SCM_ARG1, __FUNCTION__, "number");
+  LY_ASSERT_FIRST_TYPE(scm_is_number, s);
 
   char str[400];                       // ugh.
 
@@ -224,8 +224,7 @@ LY_DEFINE (ly_gettext, "ly:gettext",
           1, 0, 0, (SCM string),
           "Gettext wrapper.")
 {
-  SCM_ASSERT_TYPE (scm_is_string (string), string, SCM_ARG1,
-                  __FUNCTION__, "string");
+  LY_ASSERT_FIRST_TYPE(scm_is_string, string);
   return ly_string2scm (_ (scm_i_string_chars (string)));
 }
 
@@ -257,7 +256,7 @@ LY_DEFINE (ly_wide_char_2_utf_8, "ly:wide-char->utf-8",
 {
   char buf[5];
 
-  SCM_ASSERT_TYPE (scm_is_integer (wc), wc, SCM_ARG1, __FUNCTION__, "integer");
+  LY_ASSERT_FIRST_TYPE(scm_is_integer, wc);
   unsigned wide_char = (unsigned) scm_to_int (wc);
   char *p = buf;
 
@@ -315,8 +314,7 @@ LY_DEFINE (ly_stderr_redirect, "ly:stderr-redirect",
           1, 1, 0, (SCM file_name, SCM mode),
           "Redirect stderr to FILE-NAME, opened with MODE.")
 {
-  SCM_ASSERT_TYPE (scm_is_string (file_name), file_name, SCM_ARG1,
-                  __FUNCTION__, "file_name");
+  LY_ASSERT_FIRST_TYPE(scm_is_string, file_name);
 
   string m = "w";
   if (mode != SCM_UNDEFINED && scm_string_p (mode))
@@ -348,8 +346,7 @@ LY_DEFINE (ly_camel_case_2_lisp_identifier, "ly:camel-case->lisp-identifier",
           1, 0, 0, (SCM name_sym),
           "Convert FooBar_Bla to foo-bar-bla style symbol.")
 {
-  SCM_ASSERT_TYPE(scm_is_symbol (name_sym), name_sym,
-                 SCM_ARG1, __FUNCTION__, "symbol");
+  LY_ASSERT_FIRST_TYPE(ly_is_symbol, name_sym);
   
   /*
     TODO: should use strings instead?
@@ -365,8 +362,7 @@ LY_DEFINE (ly_expand_environment, "ly:expand-environment",
           1, 0, 0, (SCM str),
           "Expand $VAR and $@{VAR@} in @var{str}.")
 {
-  SCM_ASSERT_TYPE(scm_is_string (str), str,
-                 SCM_ARG1, __FUNCTION__, "string");
+  LY_ASSERT_FIRST_TYPE(scm_is_string, str);
 
   return ly_string2scm (expand_environment_variables (ly_scm2string (str)));
 }
@@ -376,8 +372,7 @@ LY_DEFINE (ly_truncate_list_x, "ly:truncate-list!",
           2, 0, 0, (SCM lst, SCM i),
           "Take at most the first @var{i} of list @var{lst}")
 {
-  SCM_ASSERT_TYPE(scm_is_integer (i), i,
-                 SCM_ARG1, __FUNCTION__, "integer");
+  LY_ASSERT_FIRST_TYPE(scm_is_integer, i);
 
   int k = scm_to_int (i);
   if (k == 0)
@@ -432,7 +427,7 @@ LY_DEFINE (ly_format, "ly:format",
           1, 0, 1, (SCM str, SCM rest),
           "LilyPond specific format, supporting ~a ~[0-9]f.")
 {
-  SCM_ASSERT_TYPE (scm_is_string (str), str, SCM_ARG1, __FUNCTION__, "string");
+  LY_ASSERT_FIRST_TYPE(scm_is_string, str);
 
   string format = ly_scm2string (str);
   vector<string> results;
index c5f4d561f9966487c647527f8d189809ef0a8d6b..72693421253114368a4a7cc87c23d3793370004a 100644 (file)
@@ -5,6 +5,7 @@
 
   (c) 2005--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
+
 #include "cpu-timer.hh"
 #include "global-context.hh"
 #include "international.hh"
@@ -22,7 +23,8 @@ LY_DEFINE (ly_format_output, "ly:format-output",
           "process it and return the @code{Music_output} object in its final state.")
 {
   Global_context *g = dynamic_cast<Global_context *> (unsmob_context (context));
-  SCM_ASSERT_TYPE (g, context, SCM_ARG1, __FUNCTION__, "Global context");
+  
+  LY_ASSERT_FIRST_TYPE (unsmob_global_context, context)
 
   SCM output = g->get_output ();
   progress_indication ("\n");
@@ -39,7 +41,7 @@ LY_DEFINE (ly_make_global_translator, "ly:make-global-translator",
           "@var{global}. The translator group is returned.")
 {
   Global_context *g = dynamic_cast<Global_context *> (unsmob_context (global));
-  SCM_ASSERT_TYPE (g, global, SCM_ARG1, __FUNCTION__, "Global context");
+  LY_ASSERT_FIRST_TYPE (unsmob_global_context, global)
 
   Translator_group *tg = new Translator_group ();
   tg->connect_to_context (g);
@@ -55,10 +57,8 @@ LY_DEFINE (ly_make_global_context, "ly:make-global-context",
           "The context is returned.\n"
           )
 {
-  Output_def *odef = unsmob_output_def (output_def);
-
-  SCM_ASSERT_TYPE (odef, output_def, SCM_ARG1, __FUNCTION__,
-                  "Output definition");
+  LY_ASSERT_FIRST_SMOB (Output_def, output_def);
+  Output_def *odef = unsmob_output_def (output_def); 
 
   Global_context *glob = new Global_context (odef);
 
@@ -77,11 +77,10 @@ LY_DEFINE (ly_interpret_music_expression, "ly:interpret-music-expression",
           "global context @var{ctx}. The context is returned in its\n"
           "final state.\n")
 {
-  Music *music = unsmob_music (mus);
-  Global_context *g = dynamic_cast<Global_context *> (unsmob_context (ctx));
-  SCM_ASSERT_TYPE (music, mus, SCM_ARG1, __FUNCTION__, "Music");
-  SCM_ASSERT_TYPE (g, ctx, SCM_ARG2, __FUNCTION__, "Global context");
+  LY_ASSERT_FIRST_SMOB (Music, mus);
+  LY_ASSERT_TYPE (unsmob_global_context, 2);
 
+  Music *music = unsmob_music (mus);
   if (!music
       || !music->get_length ().to_bool ())
     {
@@ -89,6 +88,8 @@ LY_DEFINE (ly_interpret_music_expression, "ly:interpret-music-expression",
       return SCM_BOOL_F;
     }
 
+  Global_context *g = dynamic_cast<Global_context *> (unsmob_context (ctx));
+
   Cpu_timer timer;
 
   message (_ ("Interpreting music... "));
@@ -129,6 +130,9 @@ LY_DEFINE (ly_run_translator, "ly:run-translator",
           "Optionally, this routine takes an Object-key to\n"
           "to uniquely identify the Score block containing it.\n")
 {
+  LY_ASSERT_FIRST_SMOB (Music, mus);
+  LY_ASSERT_SMOB (Output_def, 2);
+
   SCM glob = ly_make_global_context (output_def);
   ly_make_global_translator (glob);
   ly_interpret_music_expression (mus, glob);
index f4aff0398eeaa977015b2142e212c88985aa7fa8..f31a1283afa7fe1e4862736bf07630d503ff4172 100644 (file)
@@ -196,3 +196,9 @@ Global_context::get_default_interpreter ()
   else
     return Context::get_default_interpreter ();
 }
+
+Global_context *
+unsmob_global_context (SCM x)
+{
+  return dynamic_cast<Global_context *> (unsmob_context (x));
+}
index b242addf9b82ff162260eea895f2dff8f921a998..4a521a9958943eaf197781eee478b9308b573946 100644 (file)
@@ -15,8 +15,9 @@ LY_DEFINE (ly_grob_array_length, "ly:grob-array-length",
           (SCM grob_arr),
           "Return the grob_array length.")
 {
+  LY_ASSERT_FIRST_SMOB (Grob_array, grob_arr);
+
   Grob_array *me = unsmob_grob_array (grob_arr);
-  SCM_ASSERT_TYPE (me, grob_arr, SCM_ARG1, __FUNCTION__, "Grob_array");
   return  scm_from_int (me->size ());
 }
 
@@ -27,8 +28,8 @@ LY_DEFINE (ly_grob_array_ref, "ly:grob-array-ref",
           "Retrieve the @code{index} element of @code{grob-arr}.")
 {
   Grob_array *me = unsmob_grob_array (grob_arr);
-  SCM_ASSERT_TYPE (me, grob_arr, SCM_ARG1, __FUNCTION__, "Grob_array");
-  SCM_ASSERT_TYPE (scm_is_integer (index), index, SCM_ARG2, __FUNCTION__, "integer");
+  LY_ASSERT_FIRST_SMOB (Grob_array, grob_arr);
+  LY_ASSERT_TYPE(scm_is_integer, 2);
 
   vsize i = scm_to_unsigned (index);
   if (i == VPOS || i >= me->size ())
index 5d5947cbb7a88faac1028dc0f52a6a08249a319c..504087d59b8b5157a25aa23bfa773724cc9e6294 100644 (file)
@@ -15,9 +15,9 @@ LY_DEFINE (ly_add_interface, "ly:add-interface",
           3, 0, 0, (SCM a, SCM b, SCM c),
           "Add an interface description.")
 {
-  SCM_ASSERT_TYPE (scm_is_symbol (a), a, SCM_ARG1, __FUNCTION__, "symbol");
-  SCM_ASSERT_TYPE (scm_is_string (b), b, SCM_ARG2, __FUNCTION__, "string");
-  SCM_ASSERT_TYPE (ly_is_list (c), c, SCM_ARG3, __FUNCTION__, "list of syms");
+  LY_ASSERT_FIRST_TYPE (ly_is_symbol, a);
+  LY_ASSERT_TYPE(scm_is_string, 2);
+  LY_ASSERT_TYPE(ly_is_list, 3);
   if (!all_ifaces)
     {
       SCM tab = scm_c_make_hash_table (59);
index 0a4e1a669f6686f414e53f304ee4fbac2a83b0d6..c3596fb0efb4fa70b1fd9986b8ee171f426f043d 100644 (file)
@@ -32,9 +32,7 @@ LY_DEFINE (ly_set_grob_modification_callback, "ly:set-grob-modification-callback
           "which the modification was requested, the property to be changed and "
           "the new value for the property.")
 {
-
-  SCM_ASSERT_TYPE(ly_is_procedure (cb), cb, SCM_ARG1, __FUNCTION__,
-                 "procedure");
+  LY_ASSERT_FIRST_TYPE(ly_is_procedure, cb);
 
   modification_callback = cb;
   return SCM_UNSPECIFIED;
index b9ca2d8aa2fcb0ee6b7ecc32df5ae4ec01f5105e..e9720ea986f0b1c69c363f265e22bd2bd935f657 100644 (file)
@@ -21,10 +21,8 @@ LY_DEFINE (ly_grob_property_data, "ly:grob-property-data",
 {
   Grob *sc = unsmob_grob (grob);
 
-  LY_FUNC_NOTE_FIRST_ARG(grob);
-  LY_ASSERT_SMOB(Grob, 1);
-
-  SCM_ASSERT_TYPE (scm_is_symbol (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
+  LY_ASSERT_FIRST_SMOB(Grob, grob);
+  LY_ASSERT_TYPE (ly_is_symbol, 2);
 
   return sc->get_property_data (sym);
 }
@@ -34,8 +32,9 @@ LY_DEFINE (ly_grob_set_property_x, "ly:grob-set-property!",
           "Set @var{sym} in grob @var{grob} to value @var{val}")
 {
   Grob *sc = unsmob_grob (grob);
-  SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob");
-  SCM_ASSERT_TYPE (scm_is_symbol (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
+  LY_ASSERT_FIRST_SMOB(Grob, grob);
+  LY_ASSERT_TYPE (ly_is_symbol, 2);
 
   if (!ly_is_procedure (val)
       && !type_check_assignment (sym, val, ly_symbol2scm ("backend-type?")))
@@ -53,8 +52,9 @@ LY_DEFINE (ly_grob_property, "ly:grob-property",
           "\n\n")
 {
   Grob *sc = unsmob_grob (grob);
-  SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob");
-  SCM_ASSERT_TYPE (scm_is_symbol (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
+   
+  LY_ASSERT_FIRST_SMOB(Grob, grob);
+  LY_ASSERT_TYPE (ly_is_symbol, 2);
   if (deflt == SCM_UNDEFINED)
     deflt = SCM_EOL;
 
@@ -71,7 +71,8 @@ LY_DEFINE (ly_grob_interfaces, "ly:grob-interfaces",
           "Return the interfaces list of grob @var{grob}.")
 {
   Grob *sc = unsmob_grob (grob);
-  SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob");
+   
+  LY_ASSERT_FIRST_SMOB(Grob, grob);
 
   return sc->interfaces ();
 }
@@ -84,8 +85,9 @@ LY_DEFINE (ly_grob_object, "ly:grob-object",
           "\n\n")
 {
   Grob *sc = unsmob_grob (grob);
-  SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob");
-  SCM_ASSERT_TYPE (scm_is_symbol (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
+   
+  LY_ASSERT_FIRST_SMOB(Grob, grob);
+  LY_ASSERT_TYPE (ly_is_symbol, 2);
 
   return sc->internal_get_object (sym);
 }
@@ -95,11 +97,12 @@ LY_DEFINE (ly_grob_object, "ly:grob-object",
 /* TODO: make difference between scaled and unscalead variable in
    calling (i.e different funcs.) */
 LY_DEFINE (ly_grob_layout, "ly:grob-layout",
-          1, 0, 0, (SCM g),
-          "Get @code{\\layout} definition from grob @var{g}.")
+          1, 0, 0, (SCM grob),
+          "Get @code{\\layout} definition from grob @var{grob}.")
 {
-  Grob *sc = unsmob_grob (g);
-  SCM_ASSERT_TYPE (sc, g, SCM_ARG1, __FUNCTION__, "grob");
+  Grob *sc = unsmob_grob (grob);
+   
+  LY_ASSERT_FIRST_SMOB(Grob, grob);
 
   return sc->layout ()->self_scm ();
 }
@@ -111,7 +114,8 @@ LY_DEFINE (ly_grob_alist_chain, "ly:grob-alist-chain",
           "from the layout block is taken. ")
 {
   Grob *sc = unsmob_grob (grob);
-  SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob");
+   
+  LY_ASSERT_FIRST_SMOB(Grob, grob);
 
   if (global == SCM_UNDEFINED)
     {
@@ -131,9 +135,10 @@ LY_DEFINE (ly_grob_extent, "ly:grob-extent",
   Grob *sc = unsmob_grob (grob);
   Grob *ref = unsmob_grob (refp);
   
-  SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob");
-  SCM_ASSERT_TYPE (ref, refp, SCM_ARG2, __FUNCTION__, "grob");
-  SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG3, __FUNCTION__, "axis");
+   
+  LY_ASSERT_FIRST_SMOB(Grob, grob);
+  LY_ASSERT_SMOB(Grob, 2);
+  LY_ASSERT_TYPE(is_axis, 3);
 
   Axis a = Axis (scm_to_int (axis));
 
@@ -154,9 +159,10 @@ LY_DEFINE (ly_grob_robust_relative_extent, "ly:grob-robust-relative-extent",
   Grob *sc = unsmob_grob (grob);
   Grob *ref = unsmob_grob (refp);
   
-  SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob");
-  SCM_ASSERT_TYPE (ref, refp, SCM_ARG2, __FUNCTION__, "grob");
-  SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG3, __FUNCTION__, "axis");
+   
+  LY_ASSERT_FIRST_SMOB(Grob, grob);
+  LY_ASSERT_SMOB(Grob, 2);
+  LY_ASSERT_TYPE(is_axis, 3);
 
   Axis a = Axis (scm_to_int (axis));
     
@@ -177,9 +183,10 @@ LY_DEFINE (ly_grob_relative_coordinate, "ly:grob-relative-coordinate",
   Grob *sc = unsmob_grob (grob);
   Grob *ref = unsmob_grob (refp);
   
-  SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob");
-  SCM_ASSERT_TYPE (ref, refp, SCM_ARG2, __FUNCTION__, "grob");
-  SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG3, __FUNCTION__, "axis");
+   
+  LY_ASSERT_FIRST_SMOB(Grob, grob);
+  LY_ASSERT_SMOB(Grob, 2);
+  LY_ASSERT_TYPE(is_axis, 3);
 
   Axis a = Axis (scm_to_int (axis));
 
@@ -200,8 +207,9 @@ LY_DEFINE (ly_grob_parent, "ly:grob-parent",
           "1 for the Y-axis.")
 {
   Grob *sc = unsmob_grob (grob);
-  SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob");
-  SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG2, __FUNCTION__, "axis");
+   
+  LY_ASSERT_FIRST_SMOB(Grob, grob);
+  LY_ASSERT_TYPE(is_axis, 2);
 
   Grob *par = sc->get_parent (Axis (scm_to_int (axis)));
   return par ? par->self_scm () : SCM_EOL;
@@ -212,7 +220,8 @@ LY_DEFINE (ly_grob_properties, "ly:grob-properties",
           "Get the mutable proprerties of @var{grob}.")
 {
   Grob *g = unsmob_grob (grob);
-  SCM_ASSERT_TYPE (g, grob, SCM_ARG1, __FUNCTION__, "grob");
+   
+  LY_ASSERT_FIRST_SMOB(Grob, grob);
 
   /* FIXME: uhg? copy/read only? */
   return g->mutable_property_alist_;
@@ -223,18 +232,20 @@ LY_DEFINE (ly_grob_basic_properties, "ly:grob-basic-properties",
           "Get the immutable properties of @var{grob}.")
 {
   Grob *g = unsmob_grob (grob);
-  SCM_ASSERT_TYPE (g, grob, SCM_ARG1, __FUNCTION__, "grob");
+   
+  LY_ASSERT_FIRST_SMOB(Grob, grob);
 
   /* FIXME: uhg? copy/read only? */
   return g->immutable_property_alist_;
 }
 
 LY_DEFINE (ly_grob_system, "ly:grob-system",
-          1, 0, 0, (SCM g),
-          "Return the System Grob of @var{g}.")
+          1, 0, 0, (SCM grob),
+          "Return the System Grob of @var{grob}.")
 {
-  Grob *me = unsmob_grob (g);
-  SCM_ASSERT_TYPE (me, g, SCM_ARG1, __FUNCTION__, "grob");
+  Grob *me = unsmob_grob (grob);
+   
+  LY_ASSERT_FIRST_SMOB(Grob, grob);
 
   if (System *g = me->get_system ())
     return g->self_scm ();
@@ -247,30 +258,33 @@ LY_DEFINE (ly_grob_original, "ly:grob-original",
           "Return the unbroken original Grob of @var{grob}.")
 {
   Grob *me = unsmob_grob (grob);
-  SCM_ASSERT_TYPE (me, grob, SCM_ARG1, __FUNCTION__, "grob");
+   
+  LY_ASSERT_FIRST_SMOB(Grob, grob);
   return me->original () ? me->original ()->self_scm () : me->self_scm ();
 }
 
 
 LY_DEFINE (ly_grob_suicide_x, "ly:grob-suicide!",
-          1, 0, 0, (SCM g),
-          "Kill @var{g}.")
+          1, 0, 0, (SCM grob),
+          "Kill @var{grob}.")
 {
-  Grob *me = unsmob_grob (g);
-  SCM_ASSERT_TYPE (me, g, SCM_ARG1, __FUNCTION__, "grob");
+  Grob *me = unsmob_grob (grob);
+   
+  LY_ASSERT_FIRST_SMOB(Grob, grob);
 
   me->suicide ();
   return SCM_UNSPECIFIED;
 }
 
 LY_DEFINE (ly_grob_translate_axis_x, "ly:grob-translate-axis!",
-          3, 0, 0, (SCM g, SCM d, SCM a),
+          3, 0, 0, (SCM grob, SCM d, SCM a),
           "Translate @var{g} on axis @var{a} over distance @var{d}.")
 {
-  Grob *me = unsmob_grob (g);
-  SCM_ASSERT_TYPE (me, g, SCM_ARG1, __FUNCTION__, "grob");
-  SCM_ASSERT_TYPE (scm_is_number (d), d, SCM_ARG2, __FUNCTION__, "dimension");
-  SCM_ASSERT_TYPE (is_axis (a), a, SCM_ARG3, __FUNCTION__, "axis");
+  Grob *me = unsmob_grob (grob);
+   
+  LY_ASSERT_FIRST_SMOB(Grob, grob);
+  LY_ASSERT_TYPE(scm_is_number, 2);
+  LY_ASSERT_TYPE(is_axis, 3);
 
   me->translate_axis (scm_to_double (d), Axis (scm_to_int (a)));
   return SCM_UNSPECIFIED;
@@ -281,7 +295,8 @@ LY_DEFINE (ly_grob_default_font, "ly:grob-default-font",
           "Return the default font for grob @var{gr}.")
 {
   Grob *gr = unsmob_grob (grob);
-  SCM_ASSERT_TYPE (gr, grob, SCM_ARG1, __FUNCTION__, "grob");
+   
+  LY_ASSERT_FIRST_SMOB(Grob, grob);
 
   return Font_interface::get_default_font (gr)->self_scm ();
 }
@@ -299,12 +314,13 @@ LY_DEFINE (ly_grob_common_refpoint, "ly:grob-common-refpoint",
 {
   
   Grob *gr = unsmob_grob (grob);
-  SCM_ASSERT_TYPE (gr, grob, SCM_ARG1, __FUNCTION__, "grob");
+   
+  LY_ASSERT_FIRST_SMOB(Grob, grob);
+  LY_ASSERT_SMOB(Grob, 2);
 
   Grob *o = unsmob_grob (other);
-  SCM_ASSERT_TYPE (o, other, SCM_ARG2, __FUNCTION__, "grob");
 
-  SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG3, __FUNCTION__, "axis");
+  LY_ASSERT_TYPE(is_axis, 3);
 
   Grob *refp = gr->common_refpoint (o,  Axis (scm_to_int (axis)));
   return refp ? refp->self_scm () : SCM_BOOL_F;
@@ -317,11 +333,12 @@ LY_DEFINE (ly_grob_common_refpoint_of_array, "ly:grob-common-refpoint-of-array",
           )
 {
   Grob *gr = unsmob_grob (grob);
-  SCM_ASSERT_TYPE (gr, grob, SCM_ARG1, __FUNCTION__, "grob");
+   
+  LY_ASSERT_FIRST_SMOB(Grob, grob);
+  LY_ASSERT_SMOB(Grob_array, 2);
 
   Grob_array *ga = unsmob_grob_array (others);
-  SCM_ASSERT_TYPE (ga, others, SCM_ARG2, __FUNCTION__, "grob array");
-  SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG3, __FUNCTION__, "axis");
+  LY_ASSERT_TYPE(is_axis, 3);
 
   Grob *refp = common_refpoint_of_array (ga->array (), gr, Axis (scm_to_int (axis)));
   return refp ? refp->self_scm () : SCM_BOOL_F;
index f77d394599cb09b06cee3d5c3dbbd4c5134ee4b1..793c0e14a9e065ecb9cd543c05c41585b5fc5baf 100644 (file)
@@ -79,4 +79,6 @@ DECLARE_UNSMOB (Font_metric, metrics);
 
 Box lookup_tex_text_dimension (Font_metric *font, SCM text);
 
+char *pfb2pfa (Byte const *pfb, int length);
+
 #endif /* FONT_METRIC_HH */
index 540d96654bb9296e3d9f2bdf934bd271d9afd998..2fcbfca2982cc7ff770d9a862dd36fe43efa122a 100644 (file)
@@ -44,5 +44,6 @@ protected:
 };
 
 SCM ly_format_output (SCM);
+Global_context *unsmob_global_context (SCM x);
 
 #endif // GLOBAL_CONTEXT_HH
index 0144523ffa1adf6289068e7b1c66acdf7626196d..aaa883ed15665e496f38900e9e06a6bd9345097a 100644 (file)
@@ -204,16 +204,14 @@ void ly_check_name (string cxx, string fname);
 extern int function_argument_direction;
 
 #define LY_FUNC_NOTE_FIRST_ARG(a)  \
-  SCM *first_arg_ptr = &a; \
-  int stack_grow_dir = 0;  \
-  stack_grow_dir = ((void*) &first_arg_ptr < (void*) &stack_grow_dir) ? -1 : 1;
+  SCM *first_arg_ptr = &a;
 
 #define LY_ASSERT_TYPE(pred, number) \
   {                                                                    \
-    if (!pred (first_arg_ptr[(number-1)*stack_grow_dir]))              \
+    if (!pred (first_arg_ptr[(number-1)*function_argument_direction]))         \
       {                                                                        \
        scm_wrong_type_arg_msg(mangle_cxx_identifier (__FUNCTION__).c_str(), \
-                              number, first_arg_ptr[(number-1)*stack_grow_dir], \
+                              number, first_arg_ptr[(number-1)*function_argument_direction], \
                               predicate_to_typename ((void*) &pred).c_str()); \
       }                                                                        \
   }
index c7c3b82bd5af0d97bff020245de61aca16d91422..eafb6ec8d023126d4882d7304beb8be60aabba7e 100644 (file)
@@ -28,5 +28,6 @@ public:
 };
 
 DECLARE_UNSMOB (Music_output, music_output);
-
+Paper_score *unsmob_paper_score (SCM);
+Performance *unsmob_performance (SCM);
 #endif /* MUSIC_OUTPUT_HH */
index b2d5d84b9208b62ff19949bea2b5b8aeffd2f4ee..4f27b57e50a127e406f5fa6f6cd4bfbf1df6ea4e 100644 (file)
@@ -23,8 +23,9 @@ LY_DEFINE (ly_input_message, "ly:input-message", 2, 0, 1, (SCM sip, SCM msg, SCM
           "location in @var{sip}. @var{msg} is interpreted similar to @code{format}'s argument\n")
 {
   Input *ip = unsmob_input (sip);
-  
-  SCM_ASSERT_TYPE (scm_is_string (msg), msg, SCM_ARG2, __FUNCTION__, "string");
+
+  LY_ASSERT_FIRST_TYPE (unsmob_input, sip);
+  LY_ASSERT_TYPE(scm_is_string, 2);
 
   msg = scm_simple_format (SCM_BOOL_F, msg, rest);
 
@@ -40,8 +41,8 @@ LY_DEFINE (ly_input_file_line_char_column,
           1, 0, 0, (SCM sip),
           "Return input location in @var{sip} as (file-name line char column).")
 {
+  LY_ASSERT_FIRST_TYPE (unsmob_input, sip);
   Input *ip = unsmob_input (sip);
-  SCM_ASSERT_TYPE (ip, sip, SCM_ARG1, __FUNCTION__, "input location");
 
   int l = 0;
   int ch = 0;
@@ -59,8 +60,10 @@ LY_DEFINE (ly_input_both_locations,
           "Return input location in @var{sip} as "
           "(file-name first-line first-column last-line last-column).")
 {
+  
+  LY_ASSERT_FIRST_TYPE (unsmob_input, sip);
   Input *ip = unsmob_input (sip);
-  SCM_ASSERT_TYPE (ip, sip, SCM_ARG1, __FUNCTION__, "input location");
+  
   return scm_list_5 (ly_string2scm (ip->file_string ()),
                     scm_from_int (ip->line_number ()),
                     scm_from_int (ip->column_number ()),
index 0ebbc2832de9a65663a665e7e39a847a23c3c317..bbb595d10e889f41b00295b3ee4a2a0cb6aa4b22 100644 (file)
@@ -24,7 +24,7 @@ LY_DEFINE (ly_item_break_dir, "ly:item-break-dir",
           "The break status dir of item @var{it}. @code{-1} is end of "
           "line, @code{0} unbroken, and @code{1} begin of line.")
 {
-  Item *me = dynamic_cast<Item *> (unsmob_grob (it));
-  SCM_ASSERT_TYPE (me, it, SCM_ARG1, __FUNCTION__, "Item");
+  LY_ASSERT_FIRST_TYPE (unsmob_item, it);
+  Item *me = unsmob_item (it);
   return scm_from_int (me->break_status_dir ());
 }
index bdfcae16486aac79287377dec4e3fac0794f3e48..1f67c0043310d32c2d0abe57e42ece5b7a53e119 100644 (file)
@@ -126,7 +126,7 @@ ly_string2scm (string const &str)
 char *
 ly_scm2newstr (SCM str, size_t *lenp)
 {
-  SCM_ASSERT_TYPE (scm_is_string (str), str, SCM_ARG1, __FUNCTION__, "string");
+  LY_ASSERT_FIRST_TYPE(scm_is_string, str);
 
   size_t len = scm_i_string_length (str);
   if (char *new_str = (char *) malloc ((len + 1) * sizeof (char)))
index 4bf001ea0a3941eb1e6002ad54889a55f9e38264..62c2959791ddb1c77c943c0bf9384b0637eca22d 100644 (file)
@@ -13,7 +13,8 @@ LY_DEFINE(ly_lexer_keywords, "ly:lexer-keywords",
          1, 0, 0, (SCM lexer),
          "Return a list of (KEY . CODE) pairs, signifying the lilypond reserved words list.")
 {
+  LY_ASSERT_FIRST_SMOB(Lily_lexer, lexer);
+
   Lily_lexer * lex = Lily_lexer::unsmob (lexer);
-  SCM_ASSERT_TYPE(lex, lexer, SCM_ARG1, __FUNCTION__, "lily lexer");
   return lex->keyword_list ();
 }
index cb84471b9cc535cb77e5f2a971768ea5b61f5adf..45c61898f23277fd453d3cfcca69c2107823a951 100644 (file)
@@ -36,7 +36,7 @@ LY_DEFINE (ly_parse_file, "ly:parse-file",
           "Parse a single @code{.ly} file.  "
           "Upon failure, throw @code{ly-file-failed} key.")
 {
-  SCM_ASSERT_TYPE (scm_is_string (name), name, SCM_ARG1, __FUNCTION__, "string");
+  LY_ASSERT_FIRST_TYPE(scm_is_string, name);
   string file = ly_scm2string (name);
   char const *extensions[] = {"ly", "", 0};
 
@@ -138,7 +138,7 @@ LY_DEFINE (ly_parse_file, "ly:parse-file",
 
   /*
     outside the if-else to ensure cleanup fo Sources object, 
-   */
+  */
   if (error)
     /* TODO: pass renamed input file too.  */
     scm_throw (ly_symbol2scm ("ly-file-failed"),
@@ -160,6 +160,7 @@ LY_DEFINE (ly_parser_clone, "ly:parser-clone",
           1, 0, 0, (SCM parser_smob),
           "Return a clone of @var{parser-smob}.")
 {
+  LY_ASSERT_FIRST_SMOB (Lily_parser, parser_smob);
   Lily_parser *parser = unsmob_lily_parser (parser_smob);
   Lily_parser *clone = new Lily_parser (*parser);
 
@@ -170,10 +171,12 @@ LY_DEFINE (ly_parser_define_x, "ly:parser-define!",
           3, 0, 0, (SCM parser_smob, SCM symbol, SCM val),
           "Bind @var{symbol} to @var{val} in @var{parser-smob}'s module.")
 {
+  
+  LY_ASSERT_FIRST_SMOB (Lily_parser, parser_smob);
   Lily_parser *parser = unsmob_lily_parser (parser_smob);
-  SCM_ASSERT_TYPE (scm_is_symbol (symbol), symbol, SCM_ARG2, __FUNCTION__, "symbol");
-  SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG2, __FUNCTION__, "parser");
 
+  LY_ASSERT_TYPE (ly_is_symbol, 2);
+    
   parser->lexer_->set_identifier (scm_symbol_to_string (symbol), val);
   return SCM_UNSPECIFIED;
 }
@@ -183,10 +186,11 @@ LY_DEFINE (ly_parser_lookup, "ly:parser-lookup",
           "Lookup @var{symbol} in @var{parser-smob}'s module.  "
           "Undefined is '().")
 {
-  Lily_parser *parser = unsmob_lily_parser (parser_smob);
+  LY_ASSERT_FIRST_SMOB (Lily_parser, parser_smob);
 
-  SCM_ASSERT_TYPE (scm_is_symbol (symbol), symbol, SCM_ARG2, __FUNCTION__, "symbol");
-  SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG2, __FUNCTION__, "parser");
+  Lily_parser *parser = unsmob_lily_parser (parser_smob);
+  LY_ASSERT_TYPE (ly_is_symbol, 2);
 
   SCM val = parser->lexer_->lookup_identifier (ly_scm2string (scm_symbol_to_string (symbol)));
   if (val != SCM_UNDEFINED)
@@ -200,10 +204,9 @@ LY_DEFINE (ly_parser_parse_string, "ly:parser-parse-string",
           "Parse the string @code{ly-code} with @code{parser-smob}."
           "Upon failure, throw @code{ly-file-failed} key.")
 {
-  Lily_parser *parser = unsmob_lily_parser (parser_smob);
-
-  SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG1, __FUNCTION__, "parser");
-  SCM_ASSERT_TYPE (scm_is_string (ly_code), ly_code, SCM_ARG2, __FUNCTION__, "string");
+  LY_ASSERT_FIRST_SMOB (Lily_parser, parser_smob);
+  Lily_parser *parser = unsmob_lily_parser (parser_smob); 
+  LY_ASSERT_TYPE(scm_is_string, 2);
 
   parser->parse_string (ly_scm2string (ly_code));
 
@@ -216,8 +219,8 @@ LY_DEFINE (ly_parser_set_note_names, "ly:parser-set-note-names",
           "@var{names} is an alist of symbols.  "
           "This only has effect if the current mode is notes.")
 {
+  LY_ASSERT_FIRST_SMOB (Lily_parser, parser);
   Lily_parser *p = unsmob_lily_parser (parser);
-  SCM_ASSERT_TYPE (p, parser, SCM_ARG1, __FUNCTION__, "Lilypond parser");
 
   if (p->lexer_->is_note_state ())
     {
@@ -232,8 +235,8 @@ LY_DEFINE (ly_parser_output_name, "ly:parser-output-name",
           1, 0, 0, (SCM parser),
           "Return the base name of the output file.")
 {
+  LY_ASSERT_FIRST_SMOB (Lily_parser, parser);
   Lily_parser *p = unsmob_lily_parser (parser);
-  SCM_ASSERT_TYPE (p, parser, SCM_ARG1, __FUNCTION__, "Lilypond parser");
 
   return ly_string2scm (p->output_basename_);
 }
@@ -242,9 +245,10 @@ LY_DEFINE (ly_parser_error, "ly:parser-error",
           2, 1, 0, (SCM parser, SCM msg, SCM input),
           "Display an error message, and make the parser fail")
 {
+  LY_ASSERT_FIRST_SMOB (Lily_parser, parser);
   Lily_parser *p = unsmob_lily_parser (parser);
-  SCM_ASSERT_TYPE (p, parser, SCM_ARG1, __FUNCTION__, "Lilypond parser");
-  SCM_ASSERT_TYPE (scm_is_string (msg), msg, SCM_ARG2, __FUNCTION__, "string");
+  
+  LY_ASSERT_TYPE(scm_is_string, 2);
   string s = ly_scm2string (msg);
   
   Input *i = unsmob_input (input);
@@ -260,8 +264,9 @@ LY_DEFINE (ly_parser_clear_error, "ly:parser-clear-error",
           1, 0, 0, (SCM parser),
           "Clear the error flag for the parser.")
 {
+  LY_ASSERT_FIRST_SMOB (Lily_parser, parser);
   Lily_parser *p = unsmob_lily_parser (parser);
-  SCM_ASSERT_TYPE (p, parser, SCM_ARG1, __FUNCTION__, "Lilypond parser");
+  
 
   p->error_level_ = 0;
   p->lexer_->error_level_ = 0;
@@ -273,8 +278,8 @@ LY_DEFINE (ly_parser_has_error_p, "ly:parser-has-error?",
           1, 0, 0, (SCM parser),
           "Does @var{parser} have an error flag?")
 {
+  LY_ASSERT_FIRST_SMOB (Lily_parser, parser);
   Lily_parser *p = unsmob_lily_parser (parser);
-  SCM_ASSERT_TYPE (p, parser, SCM_ARG1, __FUNCTION__, "Lilypond parser");
 
   return scm_from_bool (p->error_level_ || p->lexer_->error_level_);
 }
index 9bad172300cac7651ff78666587f1d57d6e137fe..20253ae2025f2f5e4a9de76fe99972e6787338ce 100644 (file)
@@ -21,20 +21,20 @@ LY_DEFINE (ly_make_moment, "ly:make-moment",
           "notes, and @var{g} the timing for grace notes.  "
           "In absence of grace notes, @var{g} is zero.\n")
 {
-  SCM_ASSERT_TYPE (scm_is_integer (n), n, SCM_ARG1, __FUNCTION__, "integer");
-  SCM_ASSERT_TYPE (scm_is_integer (d), d, SCM_ARG2, __FUNCTION__, "integer");
+  LY_ASSERT_FIRST_TYPE(scm_is_integer, n);
+  LY_ASSERT_TYPE(scm_is_integer, 2);
 
   int grace_num = 0;
   if (gn != SCM_UNDEFINED)
     {
-      SCM_ASSERT_TYPE (scm_is_integer (gn), gn, SCM_ARG3, __FUNCTION__, "integer");
+      LY_ASSERT_TYPE(scm_is_integer, 3);
       grace_num = scm_to_int (gn);
     }
 
   int grace_den = 1;
   if (gd != SCM_UNDEFINED)
     {
-      SCM_ASSERT_TYPE (scm_is_integer (gd), gd, SCM_ARG4, __FUNCTION__, "integer");
+      LY_ASSERT_TYPE(scm_is_integer, 4);
       grace_den = scm_to_int (gd);
     }
 
@@ -46,10 +46,12 @@ LY_DEFINE (ly_moment_sub, "ly:moment-sub",
           2, 0, 0, (SCM a, SCM b),
           "Subtract two moments.")
 {
+  LY_ASSERT_FIRST_SMOB (Moment, a); 
+  LY_ASSERT_SMOB (Moment, 2);
+  
   Moment *ma = unsmob_moment (a);
   Moment *mb = unsmob_moment (b);
-  SCM_ASSERT_TYPE (ma, a, SCM_ARG1, __FUNCTION__, "moment");
-  SCM_ASSERT_TYPE (mb, b, SCM_ARG2, __FUNCTION__, "moment");
+
   return (*ma - *mb).smobbed_copy ();
 }
 
@@ -57,10 +59,12 @@ LY_DEFINE (ly_moment_add, "ly:moment-add",
           2, 0, 0, (SCM a, SCM b),
           "Add two moments.")
 {
+  LY_ASSERT_FIRST_SMOB(Moment, a); 
+  LY_ASSERT_SMOB(Moment, 2); 
+
   Moment *ma = unsmob_moment (a);
   Moment *mb = unsmob_moment (b);
-  SCM_ASSERT_TYPE (ma, a, SCM_ARG1, __FUNCTION__, "moment");
-  SCM_ASSERT_TYPE (mb, b, SCM_ARG2, __FUNCTION__, "moment");
+
   return (*ma + *mb).smobbed_copy ();
 }
 
@@ -68,10 +72,11 @@ LY_DEFINE (ly_moment_mul, "ly:moment-mul",
           2, 0, 0, (SCM a, SCM b),
           "Multiply two moments.")
 {
+  LY_ASSERT_FIRST_SMOB(Moment, a); 
+  LY_ASSERT_SMOB(Moment, 2); 
+
   Moment *ma = unsmob_moment (a);
   Moment *mb = unsmob_moment (b);
-  SCM_ASSERT_TYPE (ma, a, SCM_ARG1, __FUNCTION__, "moment");
-  SCM_ASSERT_TYPE (mb, b, SCM_ARG2, __FUNCTION__, "moment");
   return (*ma * * mb).smobbed_copy ();
 }
 
@@ -79,10 +84,12 @@ LY_DEFINE (ly_moment_div, "ly:moment-div",
           2, 0, 0, (SCM a, SCM b),
           "Divide two moments.")
 {
+  LY_ASSERT_FIRST_SMOB(Moment, a); 
+  LY_ASSERT_SMOB(Moment, 2); 
+
   Moment *ma = unsmob_moment (a);
   Moment *mb = unsmob_moment (b);
-  SCM_ASSERT_TYPE (ma, a, SCM_ARG1, __FUNCTION__, "moment");
-  SCM_ASSERT_TYPE (mb, b, SCM_ARG2, __FUNCTION__, "moment");
+  
   return (*ma / * mb).smobbed_copy ();
 }
 
@@ -90,10 +97,11 @@ LY_DEFINE (ly_moment_mod, "ly:moment-mod",
           2, 0, 0, (SCM a, SCM b),
           "Modulo of two moments.")
 {
+  LY_ASSERT_FIRST_SMOB(Moment, a); 
+  LY_ASSERT_SMOB(Moment, 2); 
+  
   Moment *ma = unsmob_moment (a);
   Moment *mb = unsmob_moment (b);
-  SCM_ASSERT_TYPE (ma, a, SCM_ARG1, __FUNCTION__, "moment");
-  SCM_ASSERT_TYPE (mb, b, SCM_ARG2, __FUNCTION__, "moment");
   return (*ma % * mb).smobbed_copy ();
 }
 
@@ -101,8 +109,9 @@ LY_DEFINE (ly_moment_grace_numerator, "ly:moment-grace-numerator",
           1, 0, 0, (SCM mom),
           "Extract numerator from grace timing.")
 {
+  LY_ASSERT_FIRST_SMOB (Moment, mom);
+
   Moment *ma = unsmob_moment (mom);
-  SCM_ASSERT_TYPE (ma, mom, SCM_ARG1, __FUNCTION__, "moment");
 
   return scm_from_int (ma->grace_part_.numerator ());
 }
@@ -111,8 +120,8 @@ LY_DEFINE (ly_moment_grace_denominator, "ly:moment-grace-denominator",
           1, 0, 0, (SCM mom),
           "Extract denominator from grace timing.")
 {
+  LY_ASSERT_FIRST_SMOB (Moment, mom);
   Moment *ma = unsmob_moment (mom);
-  SCM_ASSERT_TYPE (ma, mom, SCM_ARG1, __FUNCTION__, "moment");
 
   return scm_from_int (ma->grace_part_.denominator ());
 }
@@ -120,8 +129,8 @@ LY_DEFINE (ly_moment_main_numerator, "ly:moment-main-numerator",
           1, 0, 0, (SCM mom),
           "Extract numerator from main timing.")
 {
+  LY_ASSERT_FIRST_SMOB (Moment, mom);
   Moment *ma = unsmob_moment (mom);
-  SCM_ASSERT_TYPE (ma, mom, SCM_ARG1, __FUNCTION__, "moment");
 
   return scm_from_int (ma->main_part_.numerator ());
 }
@@ -130,8 +139,8 @@ LY_DEFINE (ly_moment_main_denominator, "ly:moment-main-denominator",
           1, 0, 0, (SCM mom),
           "Extract denominator from main timing.")
 {
+  LY_ASSERT_FIRST_SMOB (Moment, mom);
   Moment *ma = unsmob_moment (mom);
-  SCM_ASSERT_TYPE (ma, mom, SCM_ARG1, __FUNCTION__, "moment");
 
   return scm_from_int (ma->main_part_.denominator ());
 }
@@ -140,10 +149,12 @@ LY_DEFINE (ly_moment_less_p, "ly:moment<?",
           2, 0, 0, (SCM a, SCM b),
           "Compare two moments.")
 {
+  LY_ASSERT_FIRST_SMOB(Moment, a); 
+  LY_ASSERT_SMOB (Moment, 2); 
+  
   Moment *ma = unsmob_moment (a);
   Moment *mb = unsmob_moment (b);
-  SCM_ASSERT_TYPE (ma, a, SCM_ARG1, __FUNCTION__, "moment");
-  SCM_ASSERT_TYPE (mb, b, SCM_ARG2, __FUNCTION__, "moment");
+
   return ly_bool2scm (*ma < *mb);
 }
 
index 06e57f083b7f51326a7248bdd2b589d4e51a3d54..e18a233d4b9835d7c0a21575d50c78811d6d366b 100644 (file)
@@ -11,8 +11,7 @@ LY_DEFINE (ly_music_function_extract, "ly:music-function-extract", 1, 0, 0,
           (SCM x),
           "Return the Scheme function inside @var{x}")
 {
-  SCM_ASSERT_TYPE(is_music_function (x), x, SCM_ARG1, __FUNCTION__,
-                 "music function");
+  LY_ASSERT_FIRST_TYPE(is_music_function, x);
   
   return SCM_CELL_OBJECT_1(x);
 }
@@ -24,7 +23,7 @@ LY_DEFINE (ly_make_music_function, "ly:make-music-function", 2, 0, 0,
           "Its arguments. @code{signature} is a list containing either "
           "@code{ly:music?} predicates or other type predicates.")
 {
-  SCM_ASSERT_TYPE(ly_is_procedure (func), func, SCM_ARG1, __FUNCTION__, "function");
+  LY_ASSERT_FIRST_TYPE(ly_is_procedure, func);
   return  make_music_function (signature, func);
 }
 
index ce4268d9c8b9ea0e47c53e19dc79a9e5bd525664..ca152ef812d03c388ae74390e3103869bf4bcd5f 100644 (file)
@@ -15,8 +15,8 @@ LY_DEFINE (ly_music_length, "ly:music-length",
           1, 0, 0, (SCM mus),
           "Get the length of music expression @var{mus}, and return as a @code{Moment} object.")
 {
+  LY_ASSERT_FIRST_TYPE (unsmob_music, mus);
   Music *sc = unsmob_music (mus);
-  SCM_ASSERT_TYPE (sc, mus, SCM_ARG1, __FUNCTION__, "music");
   return sc->get_length ().smobbed_copy ();
 }
 
@@ -25,8 +25,7 @@ LY_DEFINE (ly_music_property,
           "Get the property @var{sym} of music expression @var{mus}.\n"
           "If @var{sym} is undefined, return @code{'()}.\n")
 {
-  Music *sc = unsmob_music (mus);
-  SCM_ASSERT_TYPE (sc, mus, SCM_ARG1, __FUNCTION__, "music");
+  LY_ASSERT_FIRST_TYPE (unsmob_music, mus);
   return ly_prob_property (mus,sym,dfault);
 }
 
@@ -34,8 +33,8 @@ LY_DEFINE (ly_music_set_property_x, "ly:music-set-property!",
           3, 0, 0, (SCM mus, SCM sym, SCM val),
           "Set property @var{sym} in music expression @var{mus} to @var{val}.")
 {
-  Music *sc = unsmob_music (mus);
-  SCM_ASSERT_TYPE (sc, mus, SCM_ARG1, __FUNCTION__, "music");
+  LY_ASSERT_FIRST_TYPE (unsmob_music, mus);
+
   return ly_prob_set_property_x (mus, sym, val);
 }
 
@@ -69,8 +68,8 @@ LY_DEFINE (ly_music_mutable_properties, "ly:music-mutable-properties",
           "they are constant and initialized by the "
           "@code{make-music} function.\n")
 {
+  LY_ASSERT_FIRST_TYPE (unsmob_music, mus);
   Music *m = unsmob_music (mus);
-  SCM_ASSERT_TYPE (m, mus, SCM_ARG1, __FUNCTION__, "music");
   return m->get_property_alist (true);
 }
 
@@ -111,10 +110,11 @@ LY_DEFINE (ly_music_transpose, "ly:music-transpose",
           "Transpose @var{m} such that central C is mapped to @var{p}. "
           "Return @var{m}.")
 {
+  LY_ASSERT_FIRST_TYPE (unsmob_music, m);
+  LY_ASSERT_SMOB (Pitch, 2);
+
   Music *sc = unsmob_music (m);
   Pitch *sp = unsmob_pitch (p);
-  SCM_ASSERT_TYPE (sc, m, SCM_ARG1, __FUNCTION__, "music");
-  SCM_ASSERT_TYPE (sp, p, SCM_ARG2, __FUNCTION__, "pitch");
 
   sc->transpose (*sp);
   // SCM_UNDEFINED ?
@@ -128,11 +128,10 @@ LY_DEFINE (ly_music_compress, "ly:music-compress",
           2, 0, 0, (SCM m, SCM factor),
           "Compress music object @var{m} by moment @var{factor}.")
 {
-  Music *sc = unsmob_music (m);
-
-  SCM_ASSERT_TYPE (sc, m, SCM_ARG1, __FUNCTION__, "music");
-  SCM_ASSERT_TYPE (unsmob_moment (factor), factor, SCM_ARG2, __FUNCTION__, "moment");
+  LY_ASSERT_FIRST_TYPE (unsmob_music, m);
+  LY_ASSERT_TYPE(unsmob_moment, 2);
 
+  Music *sc = unsmob_music (m);
   sc->compress (*unsmob_moment (factor));
   return sc->self_scm ();
 }
@@ -141,8 +140,8 @@ LY_DEFINE (ly_music_duration_length, "ly:music-duration-length", 1, 0, 0,
           (SCM mus),
           "Extract the duration field from @var{mus}, and return the length.")
 {
+  LY_ASSERT_FIRST_TYPE (unsmob_music, mus);
   Music *m = unsmob_music (mus);
-  SCM_ASSERT_TYPE (m, mus, SCM_ARG1, __FUNCTION__, "Music");
 
   Duration *d = unsmob_duration (m->get_property ("duration"));
   Moment len;
@@ -158,10 +157,11 @@ LY_DEFINE (ly_music_duration_compress, "ly:music-duration-compress", 2, 0, 0,
           (SCM mus, SCM fact),
           "Compress @var{mus} by factor @var{fact}, which is a @code{Moment}.")
 {
+  LY_ASSERT_FIRST_TYPE (unsmob_music, mus);
+  LY_ASSERT_SMOB (Moment, 2);
+  
   Music *m = unsmob_music (mus);
   Moment *f = unsmob_moment (fact);
-  SCM_ASSERT_TYPE (m, mus, SCM_ARG1, __FUNCTION__, "Music");
-  SCM_ASSERT_TYPE (f, fact, SCM_ARG2, __FUNCTION__, "Moment");
 
   Duration *d = unsmob_duration (m->get_property ("duration"));
   if (d)
index 621e5311b98f034a671c833fcfc5919889be1f5c..afd814705dd1fd3aa5ffe6d423bd79b0eeef1926 100644 (file)
@@ -16,9 +16,9 @@ LY_DEFINE(ly_note_head__stem_attachment, "ly:note-head::stem-attachment",
          "Get attachment in @var{font-metric} for attaching a stem to notehead "
          "@var{glyph-name}.")
 {
+  LY_ASSERT_FIRST_SMOB (Font_metric, font_metric);
   Font_metric *fm = unsmob_metrics (font_metric);
-  SCM_ASSERT_TYPE(fm, font_metric, SCM_ARG1, __FUNCTION__, "font metric");
-  SCM_ASSERT_TYPE(scm_is_string (glyph_name), glyph_name, SCM_ARG2, __FUNCTION__, "string");
+  LY_ASSERT_TYPE(scm_is_string, 2);
   
   return ly_offset2scm (Note_head::get_stem_attachment (fm, ly_scm2string (glyph_name)));
 }
index c6561b48cb111c9540d1b2b26e34c38e55527562..139150a7ccbf4230d0c84154c8975193d7d9b259 100644 (file)
@@ -14,8 +14,8 @@ LY_DEFINE (ly_font_sub_fonts, "ly:font-sub-fonts", 1, 0, 0,
           "Given the font metric @var{font} of an OpenType font, return the "
           "names of the subfonts within @var{font}.")
 {
+  LY_ASSERT_FIRST_SMOB (Font_metric, font);
   Font_metric *fm = unsmob_metrics (font);
-  SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
   return fm->sub_fonts ();
 }
 
@@ -27,9 +27,10 @@ LY_DEFINE (ly_otf_font_glyph_info, "ly:otf-font-glyph-info", 2, 0, 0,
   Modified_font_metric *fm
     = dynamic_cast<Modified_font_metric *> (unsmob_metrics (font));
   Open_type_font *otf = dynamic_cast<Open_type_font *> (fm->original_font ());
+
+  LY_FUNC_NOTE_FIRST_ARG (font);
   SCM_ASSERT_TYPE (otf, font, SCM_ARG1, __FUNCTION__, "OTF font-metric");
-  SCM_ASSERT_TYPE (scm_is_string (glyph), glyph, SCM_ARG1,
-                  __FUNCTION__, "string");
+  LY_ASSERT_TYPE(scm_is_string, 2);
 
   SCM sym = scm_string_to_symbol (glyph);
   return scm_hashq_ref (otf->get_char_table (), sym, SCM_EOL);
@@ -47,7 +48,8 @@ LY_DEFINE (ly_otf_font_table_data, "ly:otf-font-table-data", 2, 0, 0,
     : dynamic_cast<Open_type_font *> (unsmob_metrics (font));
 
   SCM_ASSERT_TYPE (otf, font, SCM_ARG1, __FUNCTION__, "Open type font");
-  SCM_ASSERT_TYPE (scm_is_string (tag), tag, SCM_ARG1, __FUNCTION__, "Open type font");
+  LY_FUNC_NOTE_FIRST_ARG (font);
+  LY_ASSERT_TYPE (scm_is_string, 2);
 
   char ctag [5] = "    ";
 
@@ -83,7 +85,7 @@ LY_DEFINE (ly_otf_glyph_list, "ly:otf-glyph-list",
     : dynamic_cast<Open_type_font *> (unsmob_metrics (font));
 
 
-  SCM_ASSERT_TYPE (otf,font, SCM_ARG1, __FUNCTION__, "OTF font");
+  SCM_ASSERT_TYPE (otf, font, SCM_ARG1, __FUNCTION__, "OTF font");
   return otf->glyph_list ();
 
 }
index 13c4d7456fdc69ae98b3b94979022e09d86892b4..7e2c1cc4f47e9a9a296bd19b4641418b4b2ee46a 100644 (file)
@@ -19,9 +19,9 @@ LY_DEFINE (ly_output_def_lookup, "ly:output-def-lookup",
           "Lookup @var{sym} in the Output_def @var{pap}. "
           "Return the value or @var{def} (which defaults to  @code{'()}) if undefined.")
 {
+  LY_ASSERT_FIRST_SMOB (Output_def, pap);
   Output_def *op = unsmob_output_def (pap);
-  SCM_ASSERT_TYPE (op, pap, SCM_ARG1, __FUNCTION__, "Output_def");
-  SCM_ASSERT_TYPE (scm_is_symbol (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
+  LY_ASSERT_TYPE (ly_is_symbol, 2);
 
   SCM answer = op->lookup_variable (sym);
   if (answer == SCM_UNDEFINED)
@@ -39,8 +39,8 @@ LY_DEFINE (ly_output_def_scope, "ly:output-def-scope",
           1, 0, 0, (SCM def),
           "Get the variable scope inside @var{def}.")
 {
+  LY_ASSERT_FIRST_SMOB (Output_def, def);
   Output_def *op = unsmob_output_def (def);
-  SCM_ASSERT_TYPE (op, def, SCM_ARG1, __FUNCTION__, "Output definition");
   return op->scope_;
 }
 
@@ -48,8 +48,8 @@ LY_DEFINE (ly_output_def_parent, "ly:output-def-parent",
           1, 0, 0, (SCM def),
           "Get the parent output-def of @var{def}.")
 {
+  LY_ASSERT_FIRST_SMOB (Output_def, def);
   Output_def *op = unsmob_output_def (def);
-  SCM_ASSERT_TYPE (op, def, SCM_ARG1, __FUNCTION__, "Output definition");
   return op->parent_ ? op->parent_->self_scm () : SCM_EOL;
 }
 
@@ -57,8 +57,8 @@ LY_DEFINE (ly_output_def_clone, "ly:output-def-clone",
           1, 0, 0, (SCM def),
           "Clone @var{def}.")
 {
+  LY_ASSERT_FIRST_SMOB (Output_def, def);
   Output_def *op = unsmob_output_def (def);
-  SCM_ASSERT_TYPE (op, def, SCM_ARG1, __FUNCTION__, "Output definition");
 
   Output_def *clone = op->clone ();
   return clone->unprotect ();
@@ -93,8 +93,8 @@ LY_DEFINE (ly_paper_outputscale, "ly:paper-outputscale",
           1, 0, 0, (SCM bp),
           "Get output-scale for BP.")
 {
+  LY_ASSERT_FIRST_SMOB (Output_def, bp);
   Output_def *b = unsmob_output_def (bp);
-  SCM_ASSERT_TYPE (b, bp, SCM_ARG1, __FUNCTION__, "paper");
   return scm_from_double (output_scale (b));
 }
 
@@ -114,10 +114,9 @@ LY_DEFINE (ly_paper_get_font, "ly:paper-get-font", 2, 0, 0,
           "(An alist chain is a list of alists, "
           "containing grob properties).\n")
 {
-  Output_def *paper = unsmob_output_def (paper_smob);
-  SCM_ASSERT_TYPE (paper, paper_smob, SCM_ARG1,
-                  __FUNCTION__, "paper definition");
+  LY_ASSERT_FIRST_SMOB (Output_def, paper_smob);
 
+  Output_def *paper = unsmob_output_def (paper_smob);
   Font_metric *fm = select_font (paper, chain);
   return fm->self_scm ();
 }
@@ -126,9 +125,9 @@ LY_DEFINE (ly_paper_get_number, "ly:paper-get-number", 2, 0, 0,
           (SCM layout_smob, SCM name),
           "Return the layout variable @var{name}.")
 {
+  LY_ASSERT_FIRST_SMOB (Output_def, layout_smob);
   Output_def *layout = unsmob_output_def (layout_smob);
-  SCM_ASSERT_TYPE (layout, layout_smob, SCM_ARG1,
-                  __FUNCTION__, "layout definition");
   return scm_from_double (layout->get_dimension (name));
 }
 
@@ -137,10 +136,9 @@ LY_DEFINE (ly_paper_fonts, "ly:paper-fonts",
           (SCM bp),
           "Return fonts from the @code{\\paper} block @var{bp}.")
 {
+  LY_ASSERT_FIRST_SMOB (Output_def, bp);
   Output_def *b = unsmob_output_def (bp);
 
-  SCM_ASSERT_TYPE (b, bp, SCM_ARG1, __FUNCTION__, "paper");
-
   SCM tab1 = b->lookup_variable (ly_symbol2scm ("scaled-fonts"));
   SCM tab2 = b->lookup_variable (ly_symbol2scm ("pango-fonts"));
 
index b1edd941c5e1c5f9004fd0d738269bc841ff8fb2..6889ab0f0eb3115ad8c28b8d28264685de80bdb3 100644 (file)
@@ -15,7 +15,7 @@ LY_DEFINE (ly_make_pango_description_string, "ly:make-pango-description-string",
           2, 0, 0, (SCM chain, SCM size),
           "Make a PangoFontDescription string for the property alist @var{chain} at size @var{size}.")
 {
-  SCM_ASSERT_TYPE (scm_is_number (size), size, SCM_ARG1, __FUNCTION__, "number");
+  LY_ASSERT_FIRST_TYPE(scm_is_number, size);
   PangoFontDescription *pfd = properties_to_pango_description (chain, scm_to_double (size));
   char *str = pango_font_description_to_string (pfd);
 
index 01e777220b24655c19c0a860bcd32849a9392082..f78c022502855ebd0c9aa80c17e28614a0a274d0 100644 (file)
@@ -14,6 +14,7 @@ LY_DEFINE (ly_paper_book_pages, "ly:paper-book-pages",
           1, 0, 0, (SCM pb),
           "Return pages in book PB.")
 {
+  LY_ASSERT_FIRST_SMOB (Paper_book, pb);
   return unsmob_paper_book (pb)->pages ();
 }
 
@@ -21,8 +22,8 @@ LY_DEFINE (ly_paper_book_scopes, "ly:paper-book-scopes",
           1, 0, 0, (SCM book),
           "Return pages in layout book @var{book}.")
 {
+  LY_ASSERT_FIRST_SMOB (Paper_book, book);
   Paper_book *pb = unsmob_paper_book (book);
-  SCM_ASSERT_TYPE (pb, book, SCM_ARG1, __FUNCTION__, "Paper_book");
 
   SCM scopes = SCM_EOL;
   if (ly_is_module (pb->header_))
@@ -35,6 +36,7 @@ LY_DEFINE (ly_paper_book_performances, "ly:paper-book-performances",
           1, 0, 0, (SCM paper_book),
           "Return performances in book @var{paper-book}.")
 {
+  LY_ASSERT_FIRST_SMOB (Paper_book, paper_book);
   return unsmob_paper_book (paper_book)->performances ();
 }
 
@@ -42,6 +44,7 @@ LY_DEFINE (ly_paper_book_systems, "ly:paper-book-systems",
           1, 0, 0, (SCM pb),
           "Return systems in book PB.")
 {
+  LY_ASSERT_FIRST_SMOB (Paper_book, pb);
   return unsmob_paper_book (pb)->systems ();
 }
 
@@ -49,7 +52,7 @@ LY_DEFINE (ly_paper_book_paper, "ly:paper-book-paper",
           1, 0, 0, (SCM pb),
           "Return pages in book PB.")
 {
+  LY_ASSERT_FIRST_SMOB (Paper_book, pb);
   Paper_book *pbook = unsmob_paper_book (pb);
-  SCM_ASSERT_TYPE(pbook, pb, SCM_ARG1, __FUNCTION__, "Paper_book");
   return pbook->paper_->self_scm ();
 }
index e4906f4a9bda4fb34eda3c90f85cfef9482723fd..36c77a43f266ffa0942276ac1a34e580122b9cee 100644 (file)
@@ -17,10 +17,8 @@ LY_DEFINE (ly_make_paper_outputter, "ly:make-paper-outputter",
           "Create an outputter that evaluates within "
           "@code{output-}@var{format}, writing to  @var{port}.")
 {
-  SCM_ASSERT_TYPE (ly_is_port (port), port, SCM_ARG1, __FUNCTION__,
-                  "port");
-  SCM_ASSERT_TYPE (scm_is_string (format), format, SCM_ARG2, __FUNCTION__,
-                  "String");
+  LY_ASSERT_FIRST_TYPE(ly_is_port, port);
+  LY_ASSERT_TYPE (scm_is_string, 2);
 
   string f = ly_scm2string (format);
 
@@ -45,10 +43,13 @@ LY_DEFINE (ly_outputter_dump_stencil, "ly:outputter-dump-stencil",
           2, 0, 0, (SCM outputter, SCM stencil),
           "Dump stencil @var{expr} onto @var{outputter}.")
 {
+  
+  LY_ASSERT_FIRST_SMOB (Paper_outputter, outputter);
+  LY_ASSERT_SMOB(Stencil, 2);
+
   Paper_outputter *po = unsmob_outputter (outputter);
   Stencil *st = unsmob_stencil (stencil);
-  SCM_ASSERT_TYPE (po, outputter, SCM_ARG1, __FUNCTION__, "Paper_outputter");
-  SCM_ASSERT_TYPE (st, stencil, SCM_ARG1, __FUNCTION__, "Paper_outputter");
+
   po->output_stencil (*st);
   return SCM_UNSPECIFIED;
 }
@@ -57,9 +58,10 @@ LY_DEFINE (ly_outputter_dump_string, "ly:outputter-dump-string",
           2, 0, 0, (SCM outputter, SCM str),
           "Dump @var{str} onto @var{outputter}.")
 {
+  LY_ASSERT_FIRST_SMOB (Paper_outputter, outputter);
+  LY_ASSERT_TYPE(scm_is_string, 2);
+
   Paper_outputter *po = unsmob_outputter (outputter);
-  SCM_ASSERT_TYPE (po, outputter, SCM_ARG1, __FUNCTION__, "Paper_outputter");
-  SCM_ASSERT_TYPE (scm_is_string (str), str, SCM_ARG1, __FUNCTION__, "Paper_outputter");
 
   return po->dump_string (str);
 }
@@ -68,8 +70,8 @@ LY_DEFINE (ly_outputter_port, "ly:outputter-port",
           1, 0, 0, (SCM outputter),
           "Return output port for @var{outputter}.")
 {
+  LY_ASSERT_FIRST_SMOB (Paper_outputter, outputter);
   Paper_outputter *po = unsmob_outputter (outputter);
-  SCM_ASSERT_TYPE (po, outputter, SCM_ARG1, __FUNCTION__, "Paper_outputter");
 
   return po->file ();
 }
@@ -78,8 +80,8 @@ LY_DEFINE (ly_outputter_close, "ly:outputter-close",
           1, 0, 0, (SCM outputter),
           "Close port of @var{outputter}.")
 {
+  LY_ASSERT_FIRST_SMOB (Paper_outputter, outputter);
   Paper_outputter *po = unsmob_outputter (outputter);
-  SCM_ASSERT_TYPE (po, outputter, SCM_ARG1, __FUNCTION__, "Paper_outputter");
 
   po->close ();
   return SCM_UNSPECIFIED;
@@ -89,8 +91,8 @@ LY_DEFINE (ly_outputter_output_scheme, "ly:outputter-output-scheme",
           2, 0, 0, (SCM outputter, SCM expr),
           "Eval @var{expr} in module of @var{outputter}.")
 {
+  LY_ASSERT_FIRST_SMOB (Paper_outputter, outputter);
   Paper_outputter *po = unsmob_outputter (outputter);
-  SCM_ASSERT_TYPE (po, outputter, SCM_ARG1, __FUNCTION__, "Paper_outputter");
 
   po->output_scheme (expr);
 
index 0c6a16c21c60de057d1da33f1760aa2860c7b08a..a19a1e39f710aee6437fde2e0a0b9b06fcf9f9d0 100644 (file)
@@ -13,8 +13,8 @@ LY_DEFINE (ly_paper_score_paper_systems, "ly:paper-score-paper-systems",
           (SCM paper_score),
           "Return vector of paper_system objects from @var{paper-score}.")
 {
-  Paper_score *pscore = dynamic_cast<Paper_score *> (unsmob_music_output (paper_score));
-  SCM_ASSERT_TYPE (pscore, paper_score, SCM_ARG1, __FUNCTION__, "Paper score (Music output)");
+  LY_ASSERT_FIRST_TYPE (unsmob_paper_score, paper_score);
 
+  Paper_score *pscore = dynamic_cast<Paper_score *> (unsmob_music_output (paper_score));
   return pscore->get_paper_systems ();
 }
index bd6d3a6ede9976aeec333e0a5bca38c51f3e41f7..4a2eceef12e8e6462da1474efe5f798a537bfdd5 100644 (file)
@@ -157,3 +157,9 @@ Paper_score::get_paper_systems ()
   return paper_systems_;
 }
 
+
+Paper_score *
+unsmob_paper_score (SCM x)
+{
+  return dynamic_cast<Paper_score*> (unsmob_music_output (x));
+}
index 3f45829882b8b174e73f99bb077973333800850e..a09904e1e7649af84c58d9b7dfcc7e5ef0a3d983 100644 (file)
@@ -12,12 +12,10 @@ LY_DEFINE (ly_performance_write, "ly:performance-write",
           2, 0, 0, (SCM performance, SCM filename),
           "Write @var{performance} to @var{filename}")
 {
-  Performance *perf = dynamic_cast<Performance *> (unsmob_music_output (performance));
+  LY_ASSERT_FIRST_TYPE (unsmob_performance, performance);
+  LY_ASSERT_TYPE(scm_is_string, 2);
 
-  SCM_ASSERT_TYPE (perf, performance, SCM_ARG1, __FUNCTION__, "Performance");
-  SCM_ASSERT_TYPE (scm_is_string (filename), filename, SCM_ARG2, __FUNCTION__, "file name");
-
-  perf->write_output (ly_scm2string (filename));
+  unsmob_performance (performance)->write_output (ly_scm2string (filename));
   return SCM_UNSPECIFIED;
 }
 
index e536622f06f550336876ea29f4e3b421df787bce..70d5348a9b1d6f0513e7cc8b983538ec79b77cfe 100644 (file)
@@ -109,3 +109,9 @@ void
 Performance::process ()
 {
 }
+
+Performance *
+unsmob_performance (SCM x)
+{
+  return dynamic_cast<Performance*> (unsmob_music_output (x));
+}
diff --git a/lily/pfb-scheme.cc b/lily/pfb-scheme.cc
new file mode 100644 (file)
index 0000000..29cbe15
--- /dev/null
@@ -0,0 +1,53 @@
+
+#include "program-option.hh"
+#include "source-file.hh"
+#include "memory-stream.hh"
+#include "open-type-font.hh"
+#include "main.hh"
+#include "warn.hh"
+
+LY_DEFINE (ly_pfb_2_pfa, "ly:pfb->pfa",
+          1, 0, 0, (SCM pfb_file_name),
+          "Convert the contents of a PFB file to PFA.")
+{
+  LY_ASSERT_FIRST_TYPE(scm_is_string, pfb_file_name);
+
+  string file_name = ly_scm2string (pfb_file_name);
+
+  if (be_verbose_global)
+    progress_indication ("[" + file_name);
+  
+  vector<char> pfb_string = gulp_file (file_name, 0);
+  char *pfa = pfb2pfa ((Byte *) &pfb_string[0], pfb_string.size ());
+  
+  SCM pfa_scm = scm_from_locale_string (pfa);
+  free (pfa);
+
+  if (be_verbose_global)
+    progress_indication ("]");
+
+  return pfa_scm;
+}
+
+LY_DEFINE (ly_otf_2_cff, "ly:otf->cff",
+          1, 0, 0, (SCM otf_file_name),
+          "Convert the contents of a OTF file to CFF file, returning it as "
+          " a string.")
+{
+  LY_ASSERT_FIRST_TYPE(scm_is_string, otf_file_name);
+
+  string file_name = ly_scm2string (otf_file_name);
+  if (be_verbose_global)
+    progress_indication ("[" + file_name);
+
+  FT_Face face = open_ft_face (file_name);
+  string table = get_otf_table (face, "CFF ");
+
+  SCM asscm = scm_from_locale_stringn ((char *) table.data (),
+                                      table.length ());
+
+  if (be_verbose_global)
+    progress_indication ("]");
+
+  return asscm;
+}
index 8eee6647a7b1a04cc290ae8f76a6371587d0c0eb..3cee20618921fe8870ca7c2c3437476159be2f29 100644 (file)
@@ -70,51 +70,3 @@ pfb2pfa (Byte const *pfb, int length)
   return out;
 }
 
-LY_DEFINE (ly_pfb_2_pfa, "ly:pfb->pfa",
-          1, 0, 0, (SCM pfb_file_name),
-          "Convert the contents of a PFB file to PFA.")
-{
-  SCM_ASSERT_TYPE (scm_is_string (pfb_file_name), pfb_file_name,
-                  SCM_ARG1, __FUNCTION__, "string");
-
-  string file_name = ly_scm2string (pfb_file_name);
-
-  if (be_verbose_global)
-    progress_indication ("[" + file_name);
-  
-  vector<char> pfb_string = gulp_file (file_name, 0);
-  char *pfa = pfb2pfa ((Byte *) &pfb_string[0], pfb_string.size ());
-  
-  SCM pfa_scm = scm_from_locale_string (pfa);
-  free (pfa);
-
-  if (be_verbose_global)
-    progress_indication ("]");
-
-  return pfa_scm;
-}
-
-LY_DEFINE (ly_otf_2_cff, "ly:otf->cff",
-          1, 0, 0, (SCM otf_file_name),
-          "Convert the contents of a OTF file to CFF file, returning it as "
-          " a string.")
-{
-  SCM_ASSERT_TYPE (scm_is_string (otf_file_name), otf_file_name,
-                  SCM_ARG1, __FUNCTION__, "string");
-
-  string file_name = ly_scm2string (otf_file_name);
-  if (be_verbose_global)
-    progress_indication ("[" + file_name);
-
-  FT_Face face = open_ft_face (file_name);
-  string table = get_otf_table (face, "CFF ");
-
-  SCM asscm = scm_from_locale_stringn ((char *) table.data (),
-                                      table.length ());
-
-  if (be_verbose_global)
-    progress_indication ("]");
-
-  return asscm;
-}
-
index 440df366ebe68a7175b412bbfc09a010426e0326..6dcf79796c9511110b56d0a72ea95aaffaf1f8cd 100644 (file)
@@ -13,10 +13,11 @@ LY_DEFINE (ly_pitch_transpose, "ly:pitch-transpose",
           "Transpose @var{p} by the amount @var{delta}, "
           "where @var{delta} is relative to middle C.")
 {
+  LY_ASSERT_FIRST_SMOB (Pitch, p);
+  LY_ASSERT_SMOB (Pitch, 2);
+
   Pitch *t = unsmob_pitch (p);
   Pitch *d = unsmob_pitch (delta);
-  SCM_ASSERT_TYPE (t, p, SCM_ARG1, __FUNCTION__, "pitch");
-  SCM_ASSERT_TYPE (d, delta, SCM_ARG1, __FUNCTION__, "pitch");
   return t->transposed (*d).smobbed_copy ();
 }
 
@@ -29,10 +30,9 @@ LY_DEFINE (ly_make_pitch, "ly:make-pitch",
           "with 0 corresponding to C and 6 corresponding to B.  "
           "The @var{alter} is a rational number of whole tones for alteration.")
 {
-  SCM_ASSERT_TYPE (scm_is_integer (octave), octave, SCM_ARG1, __FUNCTION__, "integer");
-  SCM_ASSERT_TYPE (scm_is_integer (note), note, SCM_ARG2, __FUNCTION__, "integer");
-  SCM_ASSERT_TYPE (scm_is_rational (alter),
-                  alter, SCM_ARG3, __FUNCTION__, "rational");
+  LY_ASSERT_FIRST_TYPE(scm_is_integer, octave);
+  LY_ASSERT_TYPE(scm_is_integer, 2);
+  LY_ASSERT_TYPE(scm_is_rational, 3);
   
   Pitch p (scm_to_int (octave), scm_to_int (note),
           ly_scm2rational (alter));
@@ -44,8 +44,8 @@ LY_DEFINE (ly_pitch_negate, "ly:pitch-negate", 1, 0, 0,
           (SCM p),
           "Negate @var{p}.")
 {
+  LY_ASSERT_FIRST_SMOB (Pitch, p);
   Pitch *pp = unsmob_pitch (p);
-  SCM_ASSERT_TYPE (pp, p, SCM_ARG1, __FUNCTION__, "Pitch");
   return pp->negated ().smobbed_copy ();
 }
 
@@ -53,8 +53,8 @@ LY_DEFINE (ly_pitch_steps, "ly:pitch-steps", 1, 0, 0,
           (SCM p),
           "Number of steps counted from middle C of the pitch @var{p}.")
 {
+  LY_ASSERT_FIRST_SMOB (Pitch, p);
   Pitch *pp = unsmob_pitch (p);
-  SCM_ASSERT_TYPE (pp, p, SCM_ARG1, __FUNCTION__, "Pitch");
   return scm_from_int (pp->steps ());
 }
 
@@ -62,8 +62,8 @@ LY_DEFINE (ly_pitch_octave, "ly:pitch-octave",
           1, 0, 0, (SCM pp),
           "Extract the octave from pitch @var{p}.")
 {
+  LY_ASSERT_FIRST_SMOB (Pitch, pp);
   Pitch *p = unsmob_pitch (pp);
-  SCM_ASSERT_TYPE (p, pp, SCM_ARG1, __FUNCTION__, "Pitch");
   int q = p->get_octave ();
   return scm_from_int (q);
 }
@@ -72,8 +72,8 @@ LY_DEFINE (ly_pitch_alteration, "ly:pitch-alteration",
           1, 0, 0, (SCM pp),
           "Extract the alteration from pitch  @var{p}.")
 {
+  LY_ASSERT_FIRST_SMOB (Pitch, pp);
   Pitch *p = unsmob_pitch (pp);
-  SCM_ASSERT_TYPE (p, pp, SCM_ARG1, __FUNCTION__, "Pitch");
   Rational q = p->get_alteration ();
 
   return ly_rational2scm (q);
@@ -83,8 +83,8 @@ LY_DEFINE (pitch_notename, "ly:pitch-notename",
           1, 0, 0, (SCM pp),
           "Extract the note name from pitch  @var{pp}.")
 {
+  LY_ASSERT_FIRST_SMOB (Pitch, pp);
   Pitch *p = unsmob_pitch (pp);
-  SCM_ASSERT_TYPE (p, pp, SCM_ARG1, __FUNCTION__, "Pitch");
   int q = p->get_notename ();
   return scm_from_int (q);
 }
@@ -93,8 +93,8 @@ LY_DEFINE (ly_pitch_quartertones, "ly:pitch-quartertones",
           1, 0, 0, (SCM pp),
           "Calculate the number of quarter tones of @var{p} from middle C.")
 {
+  LY_ASSERT_FIRST_SMOB (Pitch, pp);
   Pitch *p = unsmob_pitch (pp);
-  SCM_ASSERT_TYPE (p, pp, SCM_ARG1, __FUNCTION__, "Pitch");
   int q = p->rounded_quartertone_pitch ();
   return scm_from_int (q);
 }
@@ -103,8 +103,8 @@ LY_DEFINE (ly_pitch_semitones, "ly:pitch-semitones",
           1, 0, 0, (SCM pp),
           "calculate the number of semitones of @var{p} from middle C.")
 {
+  LY_ASSERT_FIRST_SMOB (Pitch, pp);
   Pitch *p = unsmob_pitch (pp);
-  SCM_ASSERT_TYPE (p, pp, SCM_ARG1, __FUNCTION__, "Pitch");
   int q = p->rounded_semitone_pitch ();
   return scm_from_int (q);
 }
@@ -113,12 +113,12 @@ LY_DEFINE (ly_pitch_less_p, "ly:pitch<?",
           2, 0, 0, (SCM p1, SCM p2),
           "Is @var{p1} lexicographically smaller than @var{p2}?")
 {
+  LY_ASSERT_FIRST_SMOB (Pitch, p1);
+  LY_ASSERT_SMOB (Pitch, 2);
+
   Pitch *a = unsmob_pitch (p1);
   Pitch *b = unsmob_pitch (p2);
 
-  SCM_ASSERT_TYPE (a, p1, SCM_ARG1, __FUNCTION__, "Pitch");
-  SCM_ASSERT_TYPE (b, p2, SCM_ARG2, __FUNCTION__, "Pitch");
-
   if (Pitch::compare (*a, *b) < 0)
     return SCM_BOOL_T;
   else
@@ -130,10 +130,12 @@ LY_DEFINE (ly_pitch_diff, "ly:pitch-diff",
           "Return pitch @var{delta} such that @code{pitch} transposed by "
           "@var{delta} equals @var{root}")
 {
+  LY_ASSERT_FIRST_SMOB (Pitch, pitch);
+  LY_ASSERT_SMOB (Pitch, 2);
+
   Pitch *p = unsmob_pitch (pitch);
   Pitch *r = unsmob_pitch (root);
-  SCM_ASSERT_TYPE (p, pitch, SCM_ARG1, __FUNCTION__, "Pitch");
-  SCM_ASSERT_TYPE (r, root, SCM_ARG2, __FUNCTION__, "Pitch");
 
   return pitch_interval (*r, *p).smobbed_copy ();
 }
index f1e917966176d69698d71d436244c4d3c0a46f5f..acaf22a53692de10508ae804c9ef390b1db02e0a 100644 (file)
@@ -12,9 +12,9 @@ LY_DEFINE (ly_prob_set_property_x, "ly:prob-set-property!",
           2, 1, 0, (SCM obj, SCM sym, SCM value),
           "Set property @var{sym} of @var{obj} to @var{value}")
 {
+  LY_ASSERT_FIRST_SMOB (Prob, obj);
   Prob *ps = unsmob_prob (obj);
-  SCM_ASSERT_TYPE (ps, obj, SCM_ARG1, __FUNCTION__, "Prob");
-  SCM_ASSERT_TYPE (scm_is_symbol (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
+  LY_ASSERT_TYPE (ly_is_symbol, 2);
 
   ps->set_property (sym, value);
   return SCM_UNSPECIFIED;
@@ -22,7 +22,7 @@ LY_DEFINE (ly_prob_set_property_x, "ly:prob-set-property!",
 
 /*
   Hmm, this is not orthogonal.
- */
+*/
 LY_DEFINE (ly_prob_property_p, "ly:prob-property?",
           2, 1, 0, (SCM obj, SCM sym),
           "Is boolean prop @var{sym} set?")
@@ -34,9 +34,9 @@ LY_DEFINE (ly_prob_property, "ly:prob-property",
           2, 1, 0, (SCM obj, SCM sym, SCM dfault),
           "Return the value for @var{sym}.")
 {
+  LY_ASSERT_FIRST_SMOB (Prob, obj);
   Prob *ps = unsmob_prob (obj);
-  SCM_ASSERT_TYPE (ps, obj, SCM_ARG1, __FUNCTION__, "Prob");
-  SCM_ASSERT_TYPE (scm_is_symbol (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
+  LY_ASSERT_TYPE (ly_is_symbol, 2);
 
   if (dfault == SCM_UNDEFINED)
     dfault = SCM_EOL;
diff --git a/lily/program-option-scheme.cc b/lily/program-option-scheme.cc
new file mode 100644 (file)
index 0000000..4b47d9b
--- /dev/null
@@ -0,0 +1,244 @@
+/*
+  program-option-scheme.cc -- implement option setting from Scheme
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 2001--2007  Han-Wen Nienhuys <hanwen@xs4all.nl>
+*/
+
+#include "program-option.hh"
+
+#include <cstdio>
+#include <cstring>
+using namespace std;
+
+#include "profile.hh"
+#include "international.hh"
+#include "main.hh"
+#include "parse-scm.hh"
+#include "string-convert.hh"
+#include "warn.hh"
+
+bool debug_skylines;
+
+/*
+  Backwards compatibility.
+*/
+bool lily_1_8_relative = false;
+bool lily_1_8_compatibility_used = false;
+bool profile_property_accesses = false;
+/*
+  crash if internally the wrong type is used for a grob property.
+*/
+bool do_internal_type_checking_global;
+bool strict_infinity_checking = false; 
+
+static SCM option_hash;
+
+void internal_set_option (SCM var, SCM val)
+{
+  scm_hashq_set_x (option_hash, var, val);
+
+  if (0)
+    ;
+  else if (var == ly_symbol2scm ("profile-property-accesses"))
+    {
+      profile_property_accesses = to_boolean (val);
+      val = scm_from_bool (to_boolean (val));
+    }
+  else if (var == ly_symbol2scm ("point-and-click"))
+    {
+      point_and_click_global = to_boolean (val);
+      val = scm_from_bool (to_boolean (val));
+    }
+  else if (var == ly_symbol2scm ("protected-scheme-parsing"))
+    {
+      parse_protect_global = to_boolean (val);
+      val = scm_from_bool (to_boolean (val));
+    }
+  else if (var == ly_symbol2scm ("check-internal-types"))
+    {
+      do_internal_type_checking_global = to_boolean (val);
+      val = scm_from_bool (to_boolean (val));
+    }
+  else if (var == ly_symbol2scm ("debug-gc-assert-parsed-dead"))
+    {
+      parsed_objects_should_be_dead = to_boolean (val);
+      val = scm_from_bool (parsed_objects_should_be_dead);
+    }
+  else if (var == ly_symbol2scm ("safe"))
+    {
+      be_safe_global = to_boolean (val);
+      val = scm_from_bool (be_safe_global);
+    }
+  else if (var == ly_symbol2scm ("old-relative"))
+    {
+      lily_1_8_relative = to_boolean (val);
+      /*  Needs to be reset for each file that uses this option.  */
+      lily_1_8_compatibility_used = to_boolean (val);
+      val = scm_from_bool (to_boolean (val));
+    }
+  else if (var == ly_symbol2scm ("strict-infinity-checking"))
+    {
+      strict_infinity_checking = to_boolean (val);
+      val = scm_from_bool (to_boolean (val));
+    }
+  else if (var == ly_symbol2scm ("debug-skylines"))
+    {
+      debug_skylines = to_boolean (val);
+      val = scm_from_bool (to_boolean (val));
+    }
+}
+
+
+
+
+bool
+get_program_option (const char *s)
+{
+  SCM sym = ly_symbol2scm (s);
+
+  return to_boolean (ly_get_option (sym));
+}
+
+
+ssize const HELP_INDENT = 30;
+ssize const INDENT = 2;
+ssize const SEPARATION = 5;
+
+/*
+  Hmmm. should do in SCM / C++  ?
+*/
+static string
+get_help_string ()
+{
+  SCM alist = ly_hash2alist (option_hash);
+  SCM convertor = ly_lily_module_constant ("scm->string");
+
+  vector<string> opts;
+
+  for (SCM s = alist; scm_is_pair (s); s = scm_cdr (s))
+    {
+      SCM sym = scm_caar (s);
+      SCM val = scm_cdar (s);
+      string opt_spec
+       = String_convert::char_string (' ', INDENT)
+       + ly_symbol2string (sym)
+       + " ("
+       + ly_scm2string (scm_call_1 (convertor, val))
+       + ")";
+
+      if (opt_spec.length () + SEPARATION > HELP_INDENT)
+       {
+         opt_spec += "\n"
+           + String_convert::char_string (' ', HELP_INDENT);
+       }
+      else
+       opt_spec += String_convert::char_string (' ', HELP_INDENT - opt_spec.length ());
+
+      SCM opt_help_scm
+       = scm_object_property (sym, ly_symbol2scm ("program-option-documentation"));
+      string opt_help = ly_scm2string (opt_help_scm);
+      replace_all (opt_help,
+                  string ("\n"),
+                  string ("\n")
+                  + String_convert::char_string (' ', HELP_INDENT));
+
+      opts.push_back (opt_spec + opt_help + "\n");
+    }
+
+  string help ("Options supported by ly:set-option\n\n");
+  vector_sort (opts, less<string> ());
+  for (vsize i = 0; i < opts.size (); i++)
+    help += opts[i];
+
+  help += string ("\n");
+  return help;
+}
+
+
+LY_DEFINE (ly_option_usage, "ly:option-usage", 0, 0, 0, (),
+          "Print @code{ly:set-option} usage")
+{
+  string help = get_help_string ();
+  progress_indication (help);
+
+  return SCM_UNSPECIFIED;
+}
+
+LY_DEFINE (ly_add_option, "ly:add-option", 3, 0, 0,
+          (SCM sym, SCM val, SCM description),
+          "Add a program option @var{sym} with default @var{val}.")
+{
+  if (!option_hash)
+    {
+      option_hash = scm_permanent_object (scm_c_make_hash_table (11));
+    }
+  LY_ASSERT_FIRST_TYPE (ly_is_symbol, sym);
+  LY_ASSERT_TYPE (scm_is_string, 3);
+
+  internal_set_option (sym, val);
+
+  scm_set_object_property_x (sym, ly_symbol2scm ("program-option-documentation"),
+                            description);
+
+  return SCM_UNSPECIFIED;
+}
+
+LY_DEFINE (ly_set_option, "ly:set-option", 1, 1, 0, (SCM var, SCM val),
+          "Set a program option.")
+{
+  LY_ASSERT_FIRST_TYPE(ly_is_symbol, var);
+
+  if (val == SCM_UNDEFINED)
+    val = SCM_BOOL_T;
+
+  string varstr = ly_scm2string (scm_symbol_to_string (var));
+  if (varstr.substr (0, 3) == string ("no-"))
+    {
+      var = ly_symbol2scm (varstr.substr (3, varstr.length () -3).c_str ());
+      val = scm_from_bool (!to_boolean (val));
+    }
+
+  SCM handle = scm_hashq_get_handle (option_hash, var);
+  if (handle == SCM_BOOL_F)
+    warning (_f ("no such internal option: %s", varstr.c_str ()));
+
+  internal_set_option (var, val);
+  return SCM_UNSPECIFIED;
+}
+
+LY_DEFINE (ly_command_line_options, "ly:command-line-options", 0, 0, 0, (),
+          "The Scheme specified on command-line with @samp{-d}.")
+{
+  return ly_string2scm (init_scheme_variables_global); 
+}
+
+LY_DEFINE (ly_command_line_code, "ly:command-line-code", 0, 0, 0, (),
+          "The Scheme specified on command-line with @samp{-e}.")
+{
+  return ly_string2scm (init_scheme_code_global); 
+}
+
+LY_DEFINE (ly_command_line_verbose_p, "ly:command-line-verbose?", 0, 0, 0, (),
+          "Was be_verbose_global set?")
+{
+  return scm_from_bool (be_verbose_global);
+}
+
+
+
+LY_DEFINE (ly_all_options, "ly:all-options",
+          0, 0, 0, (),
+          "Get all option settings in an alist.")
+{
+  return ly_hash2alist (option_hash);
+}
+
+
+LY_DEFINE (ly_get_option, "ly:get-option", 1, 0, 0, (SCM var),
+          "Get a global option setting.")
+{
+  LY_ASSERT_FIRST_TYPE(ly_is_symbol, var);
+  return scm_hashq_ref (option_hash, var, SCM_BOOL_F);
+}
index 139a47f304b361d990de7248f2518ad4ec387821..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,244 +0,0 @@
-/*
-  scm-option.cc -- implement option setting from Scheme
-
-  source file of the GNU LilyPond music typesetter
-
-  (c) 2001--2007  Han-Wen Nienhuys <hanwen@xs4all.nl>
-*/
-
-#include "program-option.hh"
-
-#include <cstdio>
-#include <cstring>
-using namespace std;
-
-#include "profile.hh"
-#include "international.hh"
-#include "main.hh"
-#include "parse-scm.hh"
-#include "string-convert.hh"
-#include "warn.hh"
-
-bool debug_skylines;
-
-/*
-  Backwards compatibility.
-*/
-bool lily_1_8_relative = false;
-bool lily_1_8_compatibility_used = false;
-bool profile_property_accesses = false;
-/*
-  crash if internally the wrong type is used for a grob property.
-*/
-bool do_internal_type_checking_global;
-bool strict_infinity_checking = false; 
-
-static SCM option_hash;
-
-void internal_set_option (SCM var, SCM val)
-{
-  scm_hashq_set_x (option_hash, var, val);
-
-  if (0)
-    ;
-  else if (var == ly_symbol2scm ("profile-property-accesses"))
-    {
-      profile_property_accesses = to_boolean (val);
-      val = scm_from_bool (to_boolean (val));
-    }
-  else if (var == ly_symbol2scm ("point-and-click"))
-    {
-      point_and_click_global = to_boolean (val);
-      val = scm_from_bool (to_boolean (val));
-    }
-  else if (var == ly_symbol2scm ("protected-scheme-parsing"))
-    {
-      parse_protect_global = to_boolean (val);
-      val = scm_from_bool (to_boolean (val));
-    }
-  else if (var == ly_symbol2scm ("check-internal-types"))
-    {
-      do_internal_type_checking_global = to_boolean (val);
-      val = scm_from_bool (to_boolean (val));
-    }
-  else if (var == ly_symbol2scm ("debug-gc-assert-parsed-dead"))
-    {
-      parsed_objects_should_be_dead = to_boolean (val);
-      val = scm_from_bool (parsed_objects_should_be_dead);
-    }
-  else if (var == ly_symbol2scm ("safe"))
-    {
-      be_safe_global = to_boolean (val);
-      val = scm_from_bool (be_safe_global);
-    }
-  else if (var == ly_symbol2scm ("old-relative"))
-    {
-      lily_1_8_relative = to_boolean (val);
-      /*  Needs to be reset for each file that uses this option.  */
-      lily_1_8_compatibility_used = to_boolean (val);
-      val = scm_from_bool (to_boolean (val));
-    }
-  else if (var == ly_symbol2scm ("strict-infinity-checking"))
-    {
-      strict_infinity_checking = to_boolean (val);
-      val = scm_from_bool (to_boolean (val));
-    }
-  else if (var == ly_symbol2scm ("debug-skylines"))
-    {
-      debug_skylines = to_boolean (val);
-      val = scm_from_bool (to_boolean (val));
-    }
-}
-
-ssize const HELP_INDENT = 30;
-ssize const INDENT = 2;
-ssize const SEPARATION = 5;
-
-/*
-  Hmmm. should do in SCM / C++  ?
-*/
-static string
-get_help_string ()
-{
-  SCM alist = ly_hash2alist (option_hash);
-  SCM convertor = ly_lily_module_constant ("scm->string");
-
-  vector<string> opts;
-
-  for (SCM s = alist; scm_is_pair (s); s = scm_cdr (s))
-    {
-      SCM sym = scm_caar (s);
-      SCM val = scm_cdar (s);
-      string opt_spec
-       = String_convert::char_string (' ', INDENT)
-       + ly_symbol2string (sym)
-       + " ("
-       + ly_scm2string (scm_call_1 (convertor, val))
-       + ")";
-
-      if (opt_spec.length () + SEPARATION > HELP_INDENT)
-       {
-         opt_spec += "\n"
-           + String_convert::char_string (' ', HELP_INDENT);
-       }
-      else
-       opt_spec += String_convert::char_string (' ', HELP_INDENT - opt_spec.length ());
-
-      SCM opt_help_scm
-       = scm_object_property (sym, ly_symbol2scm ("program-option-documentation"));
-      string opt_help = ly_scm2string (opt_help_scm);
-      replace_all (opt_help,
-                  string ("\n"),
-                  string ("\n")
-                  + String_convert::char_string (' ', HELP_INDENT));
-
-      opts.push_back (opt_spec + opt_help + "\n");
-    }
-
-  string help ("Options supported by ly:set-option\n\n");
-  vector_sort (opts, less<string> ());
-  for (vsize i = 0; i < opts.size (); i++)
-    help += opts[i];
-
-  help += string ("\n");
-  return help;
-}
-
-LY_DEFINE (ly_option_usage, "ly:option-usage", 0, 0, 0, (),
-          "Print @code{ly:set-option} usage")
-{
-  string help = get_help_string ();
-  progress_indication (help);
-
-  return SCM_UNSPECIFIED;
-}
-
-LY_DEFINE (ly_add_option, "ly:add-option", 3, 0, 0,
-          (SCM sym, SCM val, SCM description),
-          "Add a program option @var{sym} with default @var{val}.")
-{
-  if (!option_hash)
-    {
-      option_hash = scm_permanent_object (scm_c_make_hash_table (11));
-    }
-  SCM_ASSERT_TYPE (scm_is_symbol (sym), sym, SCM_ARG1, __FUNCTION__, "symbol");
-  SCM_ASSERT_TYPE (scm_is_string (description), description,
-                  SCM_ARG3, __FUNCTION__, "string");
-
-  internal_set_option (sym, val);
-
-  scm_set_object_property_x (sym, ly_symbol2scm ("program-option-documentation"),
-                            description);
-
-  return SCM_UNSPECIFIED;
-}
-
-LY_DEFINE (ly_set_option, "ly:set-option", 1, 1, 0, (SCM var, SCM val),
-          "Set a program option. Try setting 'help for a help string.")
-{
-  SCM_ASSERT_TYPE (scm_is_symbol (var), var, SCM_ARG1,
-                  __FUNCTION__, "symbol");
-
-  if (val == SCM_UNDEFINED)
-    val = SCM_BOOL_T;
-
-  string varstr = ly_scm2string (scm_symbol_to_string (var));
-  if (varstr.substr (0, 3) == string ("no-"))
-    {
-      var = ly_symbol2scm (varstr.substr (3, varstr.length () -3).c_str ());
-      val = scm_from_bool (!to_boolean (val));
-    }
-
-  SCM handle = scm_hashq_get_handle (option_hash, var);
-  if (handle == SCM_BOOL_F)
-    warning (_f ("no such internal option: %s", varstr.c_str ()));
-
-  internal_set_option (var, val);
-  return SCM_UNSPECIFIED;
-}
-
-LY_DEFINE (ly_command_line_options, "ly:command-line-options", 0, 0, 0, (),
-          "The Scheme specified on command-line with @samp{-d}.")
-{
-  return ly_string2scm (init_scheme_variables_global); 
-}
-
-LY_DEFINE (ly_command_line_code, "ly:command-line-code", 0, 0, 0, (),
-          "The Scheme specified on command-line with @samp{-e}.")
-{
-  return ly_string2scm (init_scheme_code_global); 
-}
-
-LY_DEFINE (ly_command_line_verbose_p, "ly:command-line-verbose?", 0, 0, 0, (),
-          "Was be_verbose_global set?")
-{
-  return scm_from_bool (be_verbose_global);
-}
-
-
-
-LY_DEFINE (ly_all_options, "ly:all-options",
-          0, 0, 0, (),
-          "Get all option settings in an alist.")
-{
-  return ly_hash2alist (option_hash);
-}
-
-
-LY_DEFINE (ly_get_option, "ly:get-option", 1, 0, 0, (SCM var),
-          "Get a global option setting.")
-{
-  SCM_ASSERT_TYPE (scm_is_symbol (var), var,
-                  SCM_ARG1, __FUNCTION__, "symbol");
-  return scm_hashq_ref (option_hash, var, SCM_BOOL_F);
-}
-
-
-
-bool
-get_program_option (const char *s)
-{
-  SCM sym = ly_symbol2scm (s);
-
-  return to_boolean (ly_get_option (sym));
-}
index c9fa8b7f22afc7499a1782a0f956122eb3e804d4..4ba1a5bc2c5f11ab7ea5aa9dd05dca56488060e8 100644 (file)
@@ -66,9 +66,9 @@ LY_DEFINE (ly_set_default_scale, "ly:set-default-scale",
           1, 0, 0, (SCM scale),
           "Set the global default scale.")
 {
-  Scale *s = Scale::unsmob (scale);
-  SCM_ASSERT_TYPE (s, scale, SCM_ARG1, __FUNCTION__, "scale");
+  LY_ASSERT_FIRST_SMOB (Scale, scale);
 
+  Scale *s = Scale::unsmob (scale);
   if (default_global_scale)
     default_global_scale->unprotect ();
   default_global_scale = s;
index 5d46d7fc5b15a9d76f7822113726a8748f2f9dea..326ba2ecdce755d020778036c667927693befac9 100644 (file)
@@ -16,7 +16,7 @@ LY_DEFINE (ly_make_listener, "ly:make-listener",
           "\n"
           " @var{callback} should take exactly one argument." )
 {
-  SCM_ASSERT_TYPE (ly_is_procedure (callback), callback, SCM_ARG1, __FUNCTION__, "procedure");
+  LY_ASSERT_FIRST_TYPE(ly_is_procedure, callback);
   Scheme_listener *l = new Scheme_listener (callback);
   SCM listener = GET_LISTENER (l->call).smobbed_copy ();
   l->unprotect ();
index eebdedbb95c3d8614b043d932a799d1e9896b25e..7cf79abe8f3fdd1a7e46811e40c5283463e6a7c7 100644 (file)
@@ -20,8 +20,8 @@ LY_DEFINE (ly_make_score, "ly:make-score",
           (SCM music),
           "Return score with @var{music} encapsulated in @var{score}.")
 {
+  LY_ASSERT_FIRST_SMOB (Music, music);
   Music *mus = unsmob_music (music);
-  SCM_ASSERT_TYPE (mus, music, SCM_ARG1, __FUNCTION__, "music");
 
   Score *score = new Score;
   score->set_music (music);
@@ -33,8 +33,8 @@ LY_DEFINE (ly_score_output_defs, "ly:score-output-defs",
           1, 0, 0, (SCM score),
           "All output defs in a score.")
 {
+  LY_ASSERT_FIRST_SMOB (Score, score);
   Score *sc = unsmob_score (score);
-  SCM_ASSERT_TYPE (sc, score, SCM_ARG1, __FUNCTION__, "score");
 
   SCM l = SCM_EOL;
   for (vsize i = 0; i < sc->defs_.size (); i++)
@@ -48,8 +48,8 @@ LY_DEFINE (ly_score_header, "ly:score-header",
           1, 0, 0, (SCM score),
           "return score header.")
 {
+  LY_ASSERT_FIRST_SMOB (Score, score);
   Score *sc = unsmob_score (score);
-  SCM_ASSERT_TYPE (sc, score, SCM_ARG1, __FUNCTION__, "score");
   return sc->header_;
 }
 
@@ -58,8 +58,8 @@ LY_DEFINE (ly_score_music, "ly:score-music",
           1, 0, 0, (SCM score),
           "return score music.")
 {
+  LY_ASSERT_FIRST_SMOB (Score, score);
   Score *sc = unsmob_score (score);
-  SCM_ASSERT_TYPE (sc, score, SCM_ARG1, __FUNCTION__, "score");
   return sc->get_music ();
 }
 
@@ -67,8 +67,8 @@ LY_DEFINE (ly_score_error_p, "ly:score-error?",
           1, 0, 0, (SCM score),
           "Was there an error in the score?")
 {
+  LY_ASSERT_FIRST_SMOB (Score, score);
   Score *sc = unsmob_score (score);
-  SCM_ASSERT_TYPE (sc, score, SCM_ARG1, __FUNCTION__, "score");
   return scm_from_bool (sc->error_found_);
 }
 
@@ -79,15 +79,15 @@ LY_DEFINE (ly_score_embedded_format, "ly:score-embedded-format",
           "return a list of layout-lines. "
           "\nTake optional Object_key argument.")
 {
+  LY_ASSERT_FIRST_SMOB (Score, score);
+  LY_ASSERT_SMOB (Output_def, 2);
+
   Score *sc = unsmob_score (score);
   Output_def *od = unsmob_output_def (layout);
 
   if (sc->error_found_)
     return SCM_EOL;
 
-  SCM_ASSERT_TYPE (sc, score, SCM_ARG1, __FUNCTION__, "Score");
-  SCM_ASSERT_TYPE (od, layout, SCM_ARG2, __FUNCTION__, "Output_def");
-
   Output_def *score_def = 0;
 
   /* UGR, FIXME, these are default \layout blocks once again.  They
index 24b6d1c76351f3830d105651c75eb46644332ba8..2d702edcd0d2a30d8d308212d2efdd10a80a8b58 100644 (file)
@@ -23,14 +23,15 @@ LY_DEFINE (ly_solve_spring_rod_problem, "ly:solve-spring-rod-problem",
           "negative for compressing and #f for non-satisfied constraints) "
           "followed by the @var{spring-count}+1 positions of the objects. ")
 {
+  LY_FUNC_NOTE_FIRST_ARG(springs);
+  
   int len = scm_ilength (springs);
   if (len == 0)
     return scm_list_2 (scm_from_double (0.0), scm_from_double (0.0));
 
   SCM_ASSERT_TYPE (len >= 0, springs, SCM_ARG1, __FUNCTION__, "list of springs");
-  SCM_ASSERT_TYPE (scm_ilength (rods) >= 0, rods, SCM_ARG2, __FUNCTION__, "list of rods");
-  SCM_ASSERT_TYPE (scm_is_number (length) || length == SCM_BOOL_F,
-                  length, SCM_ARG3, __FUNCTION__, "number or #f");
+  SCM_ASSERT_TYPE (scm_ilength (rods)  > 0, rods, SCM_ARG1, __FUNCTION__, "list of rods");
+  LY_ASSERT_TYPE(scm_is_number, 3);
 
   bool is_ragged = ragged == SCM_BOOL_T;
   Simple_spacer spacer;
index 728dbd1e4ad94877e744e545697e9b11e83d5761..c9bb9e37ab22d86505b36b4580af8b4a22a6fa1f 100644 (file)
@@ -15,10 +15,10 @@ LY_DEFINE (ly_spanner_bound, "ly:spanner-bound",
           "Get one of the bounds of @var{spanner}. @var{dir} is @code{-1} "
           "for left, and @code{1} for right.")
 {
-  Spanner *sl = dynamic_cast<Spanner *> (unsmob_grob (slur));
-  SCM_ASSERT_TYPE (sl, slur, SCM_ARG1, __FUNCTION__, "spanner grob");
-  SCM_ASSERT_TYPE (is_direction (dir), slur, SCM_ARG2, __FUNCTION__, "dir");
-  return sl->get_bound (to_dir (dir))->self_scm ();
+  LY_ASSERT_FIRST_TYPE (unsmob_spanner, slur);
+  LY_ASSERT_TYPE(is_direction, 2);
+  
+  return unsmob_spanner (slur)->get_bound (to_dir (dir))->self_scm ();
 }
 
 /* TODO: maybe we should return a vector -- random access is more
@@ -27,8 +27,8 @@ LY_DEFINE (ly_spanner_broken_into, "ly:spanner-broken-into",
           1, 0, 0, (SCM spanner),
           "Return broken-into list for @var{spanner}.")
 {
+  SCM_ASSERT_FIRST_TYPE (unsmob_spanner, spanner);
   Spanner *me = dynamic_cast<Spanner *> (unsmob_grob (spanner));
-  SCM_ASSERT_TYPE (me, spanner, SCM_ARG1, __FUNCTION__, "spanner");
 
   SCM s = SCM_EOL;
   for (vsize i = me->broken_intos_.size (); i--;)
index ec12f1639be0d06ea20145d1320b2d7b7f0ad68b..134e6cc18489977eadc610eba15cf07dad0cc44f 100644 (file)
@@ -14,9 +14,8 @@ LY_DEFINE (ly_grob_staff_position, "ly:grob-staff-position",
           1, 0, 0, (SCM sg),
           "Return the Y-position of @var{sg} relative to the staff.")
 {
+  LY_ASSERT_FIRST_SMOB (Grob, sg);
   Grob *g = unsmob_grob (sg);
-
-  SCM_ASSERT_TYPE (g, sg, SCM_ARG1, __FUNCTION__, "grob");
   Real pos = Staff_symbol_referencer::get_position (g);
 
   if (fabs (rint (pos) -pos) < 1e-6) // ugh.
index cef3c8a353ec7b73715e6e59fe7375aae90d1a3c..619d43d3162ecf67df405a3a8b295c669f5dce4f 100644 (file)
@@ -21,8 +21,8 @@ LY_DEFINE (ly_stencil_translate_axis, "ly:stencil-translate-axis",
           "Return a copy of @var{stil} but translated by @var{amount} in @var{axis} direction.")
 {
   Stencil *s = unsmob_stencil (stil);
-  SCM_ASSERT_TYPE (s, stil, SCM_ARG1, __FUNCTION__, "stencil");
-  SCM_ASSERT_TYPE (scm_is_number (amount), amount, SCM_ARG2, __FUNCTION__, "number");
+  LY_ASSERT_FIRST_SMOB(Stencil, stil);
+  LY_ASSERT_TYPE(scm_is_number, 2);
 
   Real real_amount = scm_to_double (amount);
 
@@ -31,7 +31,7 @@ LY_DEFINE (ly_stencil_translate_axis, "ly:stencil-translate-axis",
                   amount, SCM_ARG2, __FUNCTION__, "finite number");
 #endif
 
-  SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG3, __FUNCTION__, "axis");
+  LY_ASSERT_TYPE(is_axis, 3);
 
   SCM new_s = s->smobbed_copy ();
   Stencil *q = unsmob_stencil (new_s);
@@ -45,8 +45,8 @@ LY_DEFINE (ly_stencil_translate, "ly:stencil-translate",
           "but translated by @var{offset} (a pair of numbers).")
 {
   Stencil *s = unsmob_stencil (stil);
-  SCM_ASSERT_TYPE (s, stil, SCM_ARG1, __FUNCTION__, "stencil");
-  SCM_ASSERT_TYPE (is_number_pair (offset), offset, SCM_ARG2, __FUNCTION__, "number pair");
+  LY_ASSERT_FIRST_SMOB(Stencil, stil);
+  LY_ASSERT_TYPE(is_number_pair, 2);
   Offset o = ly_scm2offset (offset);
 
   SCM new_s = s->smobbed_copy ();
@@ -60,7 +60,7 @@ LY_DEFINE (ly_stencil_expr, "ly:stencil-expr",
           "Return the expression of @var{stil}.")
 {
   Stencil *s = unsmob_stencil (stil);
-  SCM_ASSERT_TYPE (s, stil, SCM_ARG1, __FUNCTION__, "stencil");
+  LY_ASSERT_FIRST_SMOB(Stencil, stil);
   return s->expr ();
 }
 
@@ -70,8 +70,8 @@ LY_DEFINE (ly_stencil_extent, "ly:stencil-extent",
           "@var{axis} direction (0 or 1 for x and y axis respectively).")
 {
   Stencil *s = unsmob_stencil (stil);
-  SCM_ASSERT_TYPE (s, stil, SCM_ARG1, __FUNCTION__, "stencil");
-  SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG2, __FUNCTION__, "axis");
+  LY_ASSERT_FIRST_SMOB(Stencil, stil);
+  LY_ASSERT_TYPE(is_axis, 2);
 
   return ly_interval2scm (s->extent (Axis (scm_to_int (axis))));
 }
@@ -81,7 +81,7 @@ LY_DEFINE (ly_stencil_empty_p, "ly:stencil-empty?",
           "Return whether @var{stil} is empty ")
 {
   Stencil *s = unsmob_stencil (stil);
-  SCM_ASSERT_TYPE (s, stil, SCM_ARG1, __FUNCTION__, "stencil");
+  LY_ASSERT_FIRST_SMOB(Stencil, stil);
   return scm_from_bool (s->is_empty ());
 }
 
@@ -102,23 +102,24 @@ LY_DEFINE (ly_stencil_combine_at_edge, "ly:stencil-combine-at-edge",
   Stencil *s2 = unsmob_stencil (second);
   Stencil result;
 
+  LY_FUNC_NOTE_FIRST_ARG(first);
   SCM_ASSERT_TYPE (s1 || first == SCM_BOOL_F || first == SCM_EOL,
                   first, SCM_ARG1, __FUNCTION__, "Stencil, #f or ()");
   SCM_ASSERT_TYPE (s2 || second == SCM_BOOL_F || second == SCM_EOL,
                   second, SCM_ARG4, __FUNCTION__, "Stencil, #f or ()");
-  SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG2, __FUNCTION__, "axis");
-  SCM_ASSERT_TYPE (is_direction (direction), direction, SCM_ARG3, __FUNCTION__, "dir");
+  LY_ASSERT_TYPE(is_axis, 2);
+  LY_ASSERT_TYPE(is_direction, 3);
 
   Real p = 0.0;
   if (padding != SCM_UNDEFINED)
     {
-      SCM_ASSERT_TYPE (scm_is_number (padding), padding, SCM_ARG5, __FUNCTION__, "number");
+      LY_ASSERT_TYPE(scm_is_number, 5);
       p = scm_to_double (padding);
     }
   Real m = 0.0;
   if (minimum != SCM_UNDEFINED)
     {
-      SCM_ASSERT_TYPE (scm_is_number (minimum), minimum, SCM_ARG6, __FUNCTION__, "number");
+      LY_ASSERT_TYPE(scm_is_number, 6);
       m = scm_to_double (minimum);
     }
 
@@ -172,6 +173,7 @@ LY_DEFINE (ly_make_stencil, "ly:make-stencil",
           "If the extents are unspecified, they are taken  to be empty."
           )
 {
+  LY_FUNC_NOTE_FIRST_ARG (expr);
   SCM_ASSERT_TYPE (!scm_is_pair (expr)
                   || is_stencil_head (scm_car (expr)),
                   expr, SCM_ARG1, __FUNCTION__, "registered stencil expression");
@@ -180,14 +182,14 @@ LY_DEFINE (ly_make_stencil, "ly:make-stencil",
   Interval x; 
   if (xext != SCM_UNDEFINED)
     {
-      SCM_ASSERT_TYPE (is_number_pair (xext), xext, SCM_ARG2, __FUNCTION__, "number pair");
+      LY_ASSERT_TYPE(is_number_pair, 2);
       x = ly_scm2interval (xext);
     }
 
   Interval y; 
   if (yext != SCM_UNDEFINED)
     {
-      SCM_ASSERT_TYPE (is_number_pair (yext), yext, SCM_ARG3, __FUNCTION__, "number pair");
+      LY_ASSERT_TYPE(is_number_pair, 3);
       y = ly_scm2interval (yext);
     }
 
@@ -202,9 +204,9 @@ LY_DEFINE (ly_stencil_aligned_to, "ly:stencil-aligned-to",
           "@var{dir} is a number -1, 1 are left and right respectively. "
           "Other values are interpolated (so 0 means the center).")
 {
-  SCM_ASSERT_TYPE (unsmob_stencil (stil), stil, SCM_ARG1, __FUNCTION__, "stencil");
-  SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG2, __FUNCTION__, "axis");
-  SCM_ASSERT_TYPE (scm_is_number (dir), dir, SCM_ARG3, __FUNCTION__, "number");
+  LY_ASSERT_FIRST_SMOB(Stencil, stil);
+  LY_ASSERT_TYPE(is_axis, 2);
+  LY_ASSERT_TYPE(scm_is_number, 3);
 
   Stencil target = *unsmob_stencil (stil);
 
@@ -217,8 +219,8 @@ LY_DEFINE (ly_stencil_fonts, "ly:stencil-fonts",
           1, 0, 0, (SCM s),
           " Analyse @var{s}, and return a list of fonts used in @var{s}.")
 {
+  LY_ASSERT_FIRST_SMOB (Stencil, s);
   Stencil *stil = unsmob_stencil (s);
-  SCM_ASSERT_TYPE (stil, s, SCM_ARG1, __FUNCTION__, "Stencil");
   return find_expression_fonts (stil->expr ());
 }
 
@@ -226,8 +228,8 @@ LY_DEFINE (ly_stencil_in_color, "ly:stencil-in-color",
           4, 0, 0, (SCM stc, SCM r, SCM g, SCM b),
           "Put @var{stc} in a different color.")
 {
+  LY_ASSERT_FIRST_SMOB (Stencil, stc);
   Stencil *stil = unsmob_stencil (stc);
-  SCM_ASSERT_TYPE (stil, stc, SCM_ARG1, __FUNCTION__, "Stencil");
   return Stencil (stil->extent_box (),
                  scm_list_3 (ly_symbol2scm ("color"),
                              scm_list_3 (r, g, b),
@@ -250,8 +252,8 @@ LY_DEFINE (ly_interpret_stencil_expression, "ly:interpret-stencil-expression",
           4, 0, 0, (SCM expr, SCM func, SCM arg1, SCM offset),
           "Parse EXPR, feed bits to FUNC with first arg ARG1")
 {
-  SCM_ASSERT_TYPE (ly_is_procedure (func), func, SCM_ARG1, __FUNCTION__,
-                  "procedure");
+  LY_FUNC_NOTE_FIRST_ARG(expr);
+  LY_ASSERT_TYPE (ly_is_procedure, 2);
 
   Stencil_interpret_arguments a;
   a.func = func;
@@ -270,10 +272,10 @@ LY_DEFINE (ly_bracket, "ly:bracket",
           "given by @var{iv}. The wings protude by an amount of @var{p}, which "
           "may be negative. The thickness is given by @var{t}.")
 {
-  SCM_ASSERT_TYPE (is_axis (a), a, SCM_ARG1, __FUNCTION__, "axis");
-  SCM_ASSERT_TYPE (is_number_pair (iv), iv, SCM_ARG2, __FUNCTION__, "number pair");
-  SCM_ASSERT_TYPE (scm_is_number (t), a, SCM_ARG3, __FUNCTION__, "number");
-  SCM_ASSERT_TYPE (scm_is_number (p), a, SCM_ARG4, __FUNCTION__, "number");
+  LY_ASSERT_FIRST_TYPE(is_axis, a);
+  LY_ASSERT_TYPE(is_number_pair, 2);
+  LY_ASSERT_TYPE(scm_is_number, 3);
+  LY_ASSERT_TYPE(scm_is_number, 4);
 
   return Lookup::bracket ((Axis)scm_to_int (a), ly_scm2interval (iv),
                          scm_to_double (t),
@@ -286,10 +288,10 @@ LY_DEFINE (ly_stencil_rotate, "ly:stencil-rotate",
           "Return a @var{stil} rotated @var{angle} degrees around point (@var{x}, @var{y}).")
 {
   Stencil *s = unsmob_stencil (stil);
-  SCM_ASSERT_TYPE (s, stil, SCM_ARG1, __FUNCTION__, "stencil");
-  SCM_ASSERT_TYPE (scm_is_number (angle), angle, SCM_ARG2, __FUNCTION__, "number");
-  SCM_ASSERT_TYPE (scm_is_number (x), x, SCM_ARG3, __FUNCTION__, "number");
-  SCM_ASSERT_TYPE (scm_is_number (y), y, SCM_ARG4, __FUNCTION__, "number");
+  LY_ASSERT_FIRST_SMOB(Stencil, stil);
+  LY_ASSERT_TYPE(scm_is_number, 2);
+  LY_ASSERT_TYPE(scm_is_number, 3);
+  LY_ASSERT_TYPE(scm_is_number, 4);
   Real a = scm_to_double (angle);
   Real x_off = scm_to_double (x);
   Real y_off = scm_to_double (y);
@@ -307,9 +309,9 @@ LY_DEFINE (ly_round_filled_box, "ly:round-filled-box",
           "that prints a black box of dimensions @var{xext}, "
           "@var{yext} and roundness @var{blot}.")
 {
-  SCM_ASSERT_TYPE (is_number_pair (xext), xext, SCM_ARG1, __FUNCTION__, "number pair");
-  SCM_ASSERT_TYPE (is_number_pair (yext), yext, SCM_ARG2, __FUNCTION__, "number pair");
-  SCM_ASSERT_TYPE (scm_is_number (blot), blot, SCM_ARG3, __FUNCTION__, "number");
+  LY_ASSERT_FIRST_TYPE(is_number_pair, xext);
+  LY_ASSERT_TYPE(is_number_pair, 2);
+  LY_ASSERT_TYPE(scm_is_number, 3);
 
   return Lookup::round_filled_box (Box (ly_scm2interval (xext), ly_scm2interval (yext)),
                                   scm_to_double (blot)).smobbed_copy ();
@@ -320,8 +322,7 @@ LY_DEFINE (ly_register_stencil_expression, "ly:register-stencil-expression",
           (SCM symbol),
           "Add @var{symbol} as head of a stencil expression")
 {
-  SCM_ASSERT_TYPE (scm_is_symbol (symbol), symbol,
-                  SCM_ARG1, __FUNCTION__, "Symbol");
+  LY_ASSERT_FIRST_TYPE(ly_is_symbol, symbol);
   register_stencil_head (symbol);
   return SCM_UNSPECIFIED;
 }
index c44d24a5779a52344d3da65e53ad176d1124655b..0a4dc71522609ae888a06688669154b9dda7badd 100644 (file)
@@ -12,10 +12,10 @@ LY_DEFINE (ly_make_stream_event, "ly:make-stream-event",
           1, 1, 0, (SCM cl, SCM proplist),
           "Creates a stream event of class @var{cl} with the given mutable property list.\n" )
 {
-  SCM_ASSERT_TYPE (scm_is_symbol (cl), cl, SCM_ARG1, __FUNCTION__, "symbol");
+  LY_ASSERT_FIRST_TYPE (ly_is_symbol, cl);
 
   /* should be scm_list_p, but scm_list_p is expensive. */
-  SCM_ASSERT_TYPE (scm_is_pair (proplist), proplist, SCM_ARG2, __FUNCTION__, "association list");
+  LY_ASSERT_TYPE(scm_is_pair, 2);
   
   if (proplist == SCM_UNDEFINED)
     proplist = SCM_EOL;
@@ -29,18 +29,21 @@ LY_DEFINE (ly_event_property, "ly:event-property",
           "Get the property @var{sym} of stream event @var{mus}.\n"
           "If @var{sym} is undefined, return @code{'()}.\n")
 {
+  LY_ASSERT_FIRST_SMOB (Stream_event, sev);
+  LY_ASSERT_TYPE (ly_is_symbol, 2);
+
   Stream_event *e = unsmob_stream_event (sev);
-  SCM_ASSERT_TYPE (e, sev, SCM_ARG1, __FUNCTION__, "stream event");
-  SCM_ASSERT_TYPE (scm_is_symbol (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
 
   return e->internal_get_property (sym);
 }
 
 LY_DEFINE (ly_event_set_property_x, "ly:event-set-property!",
            3, 0, 0, (SCM ev, SCM sym, SCM val),
-           "Set property @var{sym} in event @var{ev} to @var{val}."){
-  Stream_event *sc = unsmob_stream_event (ev);
-  SCM_ASSERT_TYPE (sc, ev, SCM_ARG1, __FUNCTION__, "event");
+           "Set property @var{sym} in event @var{ev} to @var{val}.")
+{
+  LY_ASSERT_FIRST_SMOB (Stream_event, ev);
+  LY_ASSERT_TYPE (ly_is_symbol, 2);
+  
   return ly_prob_set_property_x (ev, sym, val);
 }
 
index 27af0dbdf7f562f59d6dae4d224d71b8c433155f..50843a03218e7bd4fb87341e5f735d474cb5bc5b 100644 (file)
@@ -25,15 +25,11 @@ Text_interface::interpret_string (SCM layout_smob,
                                  SCM props,
                                  SCM markup)
 {
-  Output_def *layout = unsmob_output_def (layout_smob);
-
-  SCM_ASSERT_TYPE (layout, layout_smob, SCM_ARG1,
-                  __FUNCTION__, "Layout definition");
-  SCM_ASSERT_TYPE (scm_is_string (markup), markup, SCM_ARG3,
-                  __FUNCTION__, "string");
+  LY_ASSERT_FIRST_SMOB (Output_def, layout_smob);
+  LY_ASSERT_TYPE (scm_is_string, 3);
 
   string str = ly_scm2string (markup);
-
+  Output_def *layout = unsmob_output_def (layout_smob);
   Font_metric *fm = select_encoded_font (layout, props);
   return fm->word_stencil (str).smobbed_copy ();
 }
index 3b2604fe18846b9e34dc8c2a8d84d49d8a292a98..caafc565488af5b4fcc6d1c62b2e3c98c5099e75 100644 (file)
@@ -15,8 +15,8 @@ LY_DEFINE (ly_translator_name, "ly:translator-name",
           "Return the type name of the translator object @var{trans}. "
           "The name is a symbol.")
 {
+  LY_ASSERT_FIRST_SMOB (Translator, trans);
   Translator *tr = unsmob_translator (trans);
-  SCM_ASSERT_TYPE (tr, trans, SCM_ARG1, __FUNCTION__, "Translator");
   char const *nm = tr->class_name ();
   return ly_symbol2scm (nm);
 }
@@ -25,8 +25,8 @@ LY_DEFINE (ly_translator_description, "ly:translator-description",
           1, 0, 0, (SCM me),
           "Return an alist of properties of  translator @var{me}.")
 {
+  LY_ASSERT_FIRST_SMOB (Translator, me);
   Translator *tr = unsmob_translator (me);
-  SCM_ASSERT_TYPE (tr, me, SCM_ARG1, __FUNCTION__, "Translator");
   return tr->translator_description ();
 }
 
index 092284edba0f6f5fac16726b17c5d215c5323a69..b34b657dac9d98605a27cb6813c59d1ba32a1fa0 100644 (file)
@@ -223,8 +223,7 @@ LY_DEFINE (ly_ttf_ps_name, "ly:ttf-ps-name",
           1, 0, 0, (SCM ttf_file_name),
           "Extract the PostScript name from a TrueType font.")
 {
-  SCM_ASSERT_TYPE (scm_is_string (ttf_file_name), ttf_file_name,
-                  SCM_ARG1, __FUNCTION__, "string");
+  LY_ASSERT_FIRST_TYPE(scm_is_string, ttf_file_name);
   string file_name = ly_scm2string (ttf_file_name);
   if (be_verbose_global)
     progress_indication ("[" + file_name);
@@ -248,8 +247,7 @@ LY_DEFINE (ly_ttf_2_pfa, "ly:ttf->pfa",
           "Convert the contents of a TTF file to Type42 PFA, returning it as "
           " a string.")
 {
-  SCM_ASSERT_TYPE (scm_is_string (ttf_file_name), ttf_file_name,
-                  SCM_ARG1, __FUNCTION__, "string");
+  LY_ASSERT_FIRST_TYPE(scm_is_string, ttf_file_name);
 
   string file_name = ly_scm2string (ttf_file_name);
   if (be_verbose_global)