X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Finclude%2Flily-guile-macros.hh;h=495b86144f24188c20fab8d9f5b46f180da13a98;hb=5b4b0d6e9a197e8f9eb085b7c2ad78b8be3e5cfc;hp=400ead26ea857b299895fc3ee72b69106ddc9870;hpb=11164b5cb08da70748b1e431adbe907f4314e75b;p=lilypond.git diff --git a/lily/include/lily-guile-macros.hh b/lily/include/lily-guile-macros.hh index 400ead26ea..495b86144f 100644 --- a/lily/include/lily-guile-macros.hh +++ b/lily/include/lily-guile-macros.hh @@ -1,9 +1,9 @@ /* - lily-guile-macros.hh -- declare + lily-guile-macros.hh -- declare GUILE interaction macros. source file of the GNU LilyPond music typesetter - (c) 2005--2007 Han-Wen Nienhuys + (c) 2005--2008 Han-Wen Nienhuys */ #ifndef LILY_GUILE_MACROS_HH @@ -25,9 +25,6 @@ FIXME: should add check for x86 as well? */ #define CACHE_SYMBOLS - - - #ifdef CACHE_SYMBOLS /* this lets us "overload" macros such as get_property to take @@ -94,11 +91,31 @@ inline SCM ly_symbol2scm (char const *x) { return scm_str2symbol ((x)); } #define DECLARE_SCHEME_CALLBACK(NAME, ARGS) \ static SCM NAME ARGS; \ static SCM NAME ## _proc - +#define ADD_TYPE_PREDICATE(func, type_name) \ + void \ + func ## _type_adder () \ + {\ + ly_add_type_predicate ((Type_predicate_ptr)func, type_name); \ + }\ + ADD_SCM_INIT_FUNC(func ## _type_adder_ctor, \ + func ## _type_adder); +#define ADD_TYPE_PREDICATE(func, type_name) \ + void \ + func ## _type_adder () \ + {\ + ly_add_type_predicate ((Type_predicate_ptr)func, type_name); \ + }\ + ADD_SCM_INIT_FUNC(func ## _type_adder_ctor, \ + func ## _type_adder); + +string mangle_cxx_identifier (string); + +void ly_add_type_predicate (void *ptr, string name); +string predicate_to_typename (void *ptr); + /* Make TYPE::FUNC available as a Scheme function. */ -string mangle_cxx_identifier (string); #define MAKE_SCHEME_CALLBACK_WITH_OPTARGS(TYPE, FUNC, ARGCOUNT, OPTIONAL_COUNT, DOC) \ SCM TYPE ::FUNC ## _proc; \ void \ @@ -178,9 +195,25 @@ void ly_check_name (string cxx, string fname); TODO: include modification callback support here, perhaps through intermediate Grob::instrumented_set_property( .. __LINE__ ). */ -#define set_property(x, y) internal_set_property (ly_symbol2scm (x), y) +#define set_property(x, y) instrumented_set_property (ly_symbol2scm (x), y, __FILE__, __LINE__, __FUNCTION__) #else #define set_property(x, y) internal_set_property (ly_symbol2scm (x), y) #endif + + +#define LY_ASSERT_TYPE(pred, var, number) \ + { \ + if (!pred (var)) \ + { \ + scm_wrong_type_arg_msg(mangle_cxx_identifier (__FUNCTION__).c_str(), \ + number, var, \ + predicate_to_typename ((void*) &pred).c_str()); \ + } \ + } + +#define LY_ASSERT_SMOB(klass, var, number) LY_ASSERT_TYPE(klass::unsmob, var, number) + + + #endif /* LILY_GUILE_MACROS_HH */