X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Finclude%2Flily-guile-macros.hh;h=ba2c9552481bd744557cc1ac1f2f98db13795061;hb=1dbfe58548c0dbea3a09c94eb03113aaaaa73c75;hp=495b86144f24188c20fab8d9f5b46f180da13a98;hpb=7f3f0083f89d87c5ed0422858e9648fc759e98a4;p=lilypond.git diff --git a/lily/include/lily-guile-macros.hh b/lily/include/lily-guile-macros.hh index 495b86144f..ba2c955248 100644 --- a/lily/include/lily-guile-macros.hh +++ b/lily/include/lily-guile-macros.hh @@ -1,14 +1,27 @@ /* - lily-guile-macros.hh -- declare GUILE interaction macros. + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 2005--2011 Han-Wen Nienhuys - (c) 2005--2008 Han-Wen Nienhuys + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ #ifndef LILY_GUILE_MACROS_HH #define LILY_GUILE_MACROS_HH +#include "config.hh" + #ifndef SMOB_FREE_RETURN_VAL #define SMOB_FREE_RETURN_VAL(CL) 0 #endif @@ -21,6 +34,11 @@ #define SCM_UNPACK(x) (x) #endif +/* For backward compatability with Guile 1.8 */ +#if !HAVE_GUILE_SUBR_TYPE +typedef SCM (*scm_t_subr) (GUILE_ELLIPSIS); +#endif + /* Unreliable with gcc-2.x FIXME: should add check for x86 as well? */ #define CACHE_SYMBOLS @@ -30,7 +48,7 @@ /* this lets us "overload" macros such as get_property to take symbols as well as strings */ inline SCM -scm_or_str2symbol (char const *c) { return scm_str2symbol (c); } +scm_or_str2symbol (char const *c) { return scm_from_locale_symbol (c); } inline SCM scm_or_str2symbol (SCM s) { @@ -38,7 +56,7 @@ scm_or_str2symbol (SCM s) { return s; } -/* Using this trick we cache the value of scm_str2symbol ("fooo") where +/* Using this trick we cache the value of scm_from_locale_symbol ("fooo") where "fooo" is a constant string. This is done at the cost of one static variable per ly_symbol2scm() use, and one boolean evaluation for every call. @@ -58,7 +76,7 @@ scm_or_str2symbol (SCM s) { value; \ }) #else -inline SCM ly_symbol2scm (char const *x) { return scm_str2symbol ((x)); } +inline SCM ly_symbol2scm (char const *x) { return scm_from_locale_symbol ((x)); } #endif /* @@ -76,11 +94,11 @@ inline SCM ly_symbol2scm (char const *x) { return scm_str2symbol ((x)); } if (__builtin_constant_p ((x))) \ { \ if (!cached) \ - value = cached = scm_eval (scm_str2symbol (x), \ - global_lily_module); \ + value = cached = scm_eval (scm_from_locale_symbol (x), \ + global_lily_module); \ } \ else \ - value = scm_eval (scm_str2symbol (x), global_lily_module); \ + value = scm_eval (scm_from_locale_symbol (x), global_lily_module); \ value; \ }) @@ -125,7 +143,7 @@ string predicate_to_typename (void *ptr); string id = mangle_cxx_identifier (cxx); \ TYPE ::FUNC ## _proc = scm_c_define_gsubr (id.c_str(), \ (ARGCOUNT-OPTIONAL_COUNT), OPTIONAL_COUNT, 0, \ - (Scheme_function_unknown) TYPE::FUNC); \ + (scm_t_subr) TYPE::FUNC); \ ly_add_function_documentation (TYPE :: FUNC ## _proc, id.c_str(), "", \ DOC); \ scm_c_export (id.c_str (), NULL); \ @@ -163,7 +181,7 @@ void ly_check_name (string cxx, string fname); INITPREFIX ## init () \ { \ FNAME ## _proc = scm_c_define_gsubr (PRIMNAME, REQ, OPT, VAR, \ - (Scheme_function_unknown) FNAME); \ + (scm_t_subr) FNAME); \ ly_check_name (#FNAME, PRIMNAME);\ ly_add_function_documentation (FNAME ## _proc, PRIMNAME, #ARGLIST, \ DOCSTRING); \ @@ -185,6 +203,10 @@ void ly_check_name (string cxx, string fname); VAR, ARGLIST, DOCSTRING) #define get_property(x) internal_get_property (ly_symbol2scm (x)) +#define get_pure_property(x,y,z) \ + internal_get_pure_property (ly_symbol2scm (x), y, z) +#define get_maybe_pure_property(w,x,y,z) \ + internal_get_maybe_pure_property (ly_symbol2scm (w), x, y, z) #define get_property_data(x) internal_get_property_data (ly_symbol2scm (x)) #define get_object(x) internal_get_object (ly_symbol2scm (x)) #define set_object(x, y) internal_set_object (ly_symbol2scm (x), y)