]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/include/lily-guile-macros.hh: new file.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 7 Jan 2005 13:22:39 +0000 (13:22 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 7 Jan 2005 13:22:39 +0000 (13:22 +0000)
* lily/font-select.cc (get_font_by_design_size): retrieve
PangoFont for (designsize . "pango-descr") entries.

* lily/output-def-scheme.cc: new file.

ChangeLog
lily/font-select.cc
lily/grob-interface-scheme.cc [new file with mode: 0644]
lily/grob-interface.cc
lily/include/grob-interface.hh
lily/include/lily-guile-macros.hh [new file with mode: 0644]
lily/include/lily-guile.hh
lily/output-def-scheme.cc

index fe1fd35e8e922d9b2abb7ed41a6720047e180f66..b15e4d832140b1e02cce2e10291d3a25d2daef2f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2005-01-07  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+       * lily/include/lily-guile-macros.hh: new file.
+
+       * lily/pango-select-scheme.cc (LY_DEFINE): new file.
+
        * lily/general-scheme.cc: new file. 
 
        * lily/font-select.cc (get_font_by_design_size): retrieve
index 68cdc5e49793c078779aeecf2ed9a5e29615a89c..5f8ca95b2f6ed7739dafa72e7919e3e3eda2042d 100644 (file)
 #include "warn.hh"
 #include "pango-font.hh"
 
-LY_DEFINE (ly_paper_get_font, "ly:paper-get-font", 2, 0, 0,
-          (SCM paper_smob, SCM chain),
-
-          "Return a font metric satisfying the font-qualifiers "
-          "in the alist chain @var{chain}.\n"
-          "(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");
-  
-  Font_metric *fm = select_font (paper, chain);
-  return fm->self_scm ();
-}
-
-LY_DEFINE (ly_paper_get_number, "ly:paper-get-number", 2, 0, 0,
-          (SCM layout_smob, SCM name),
-          "Return the layout variable @var{name}.")
-{
-  Output_def *layout = unsmob_output_def (layout_smob);
-  SCM_ASSERT_TYPE (layout, layout_smob, SCM_ARG1,
-                  __FUNCTION__, "layout definition");
-  return scm_make_real (layout->get_dimension (name));
-}
 
 bool
 wild_compare (SCM field_val, SCM val)
diff --git a/lily/grob-interface-scheme.cc b/lily/grob-interface-scheme.cc
new file mode 100644 (file)
index 0000000..466c4bb
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+  lily/grob-interface-scheme.cc --  implement
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+*/
+
+#include "lily-guile.hh"
+
+Protected_scm all_ifaces;
+
+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_c_list_p (c), c, SCM_ARG3, __FUNCTION__, "list of syms");    
+  if (!ly_c_vector_p (all_ifaces))
+    all_ifaces = scm_make_vector (scm_int2num (40), SCM_EOL);
+
+  SCM entry = scm_list_n (a, b, c, SCM_UNDEFINED);
+
+  scm_hashq_set_x (all_ifaces, a, entry);
+
+  return SCM_UNSPECIFIED;
+}
+
+
+LY_DEFINE (ly_all_grob_interfaces, "ly:all-grob-interfaces",
+         0,0,0, (),
+         "Get a hash table with all interface descriptions.")
+{
+  return all_ifaces;
+}
+
index 8bcf12bdddc83073cc60c84ea78b78b077e7a239..f1d686f9b223922362789fdc95f57a35eae037f3 100644 (file)
@@ -12,8 +12,6 @@
 #include "grob.hh"
 #include "warn.hh"
 
-Protected_scm all_ifaces;
-
 void add_interface (const char * symbol,
                    const char * descr,
                    const char * vars)
@@ -26,30 +24,6 @@ void add_interface (const char * symbol,
 }
 
 
-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_c_list_p (c), c, SCM_ARG3, __FUNCTION__, "list of syms");    
-  if (!ly_c_vector_p (all_ifaces))
-    all_ifaces = scm_make_vector (scm_int2num (40), SCM_EOL);
-
-  SCM entry = scm_list_n (a, b, c, SCM_UNDEFINED);
-
-  scm_hashq_set_x (all_ifaces, a, entry);
-
-  return SCM_UNSPECIFIED;
-}
-
-
-LY_DEFINE (ly_all_grob_interfaces, "ly:all-grob-interfaces",
-         0,0,0, (),
-         "Get a hash table with all interface descriptions.")
-{
-  return all_ifaces;
-}
-
 
 void
 check_interfaces_for_property (Grob const *me, SCM sym)
@@ -64,6 +38,7 @@ check_interfaces_for_property (Grob const *me, SCM sym)
     }
   SCM ifs = me->get_property ("interfaces");
 
+  SCM all_ifaces = ly_all_grob_interfaces ();
   bool found = false;
   for (; !found && scm_is_pair (ifs); ifs = scm_cdr (ifs))
     {
index a3194a9a13790417f84f3d2f7d14337ea4813a30..d764ae4e6eb71bc32b6f7a92625ebf767c18ceb1 100644 (file)
 
 #include <libguile.h> /* SCM */
 
-void add_interface (const char * symbol,
-                   const char * descr,
-                   const char * vars);
 
-SCM ly_add_interface (SCM, SCM, SCM); 
 
 #define ADD_INTERFACE(cl,a,b,c) \
 bool cl::has_interface(Grob*me)\
@@ -29,5 +25,13 @@ void cl ## _init_ifaces() {\
 ADD_SCM_INIT_FUNC(cl ## ifaces, cl ## _init_ifaces);\
 
 
+
+void add_interface (const char * symbol,
+                   const char * descr,
+                   const char * vars);
+
+SCM ly_add_interface (SCM, SCM, SCM); 
+SCM ly_all_grob_interfaces();
+
 #endif /* INTERFACE_HH */
 
diff --git a/lily/include/lily-guile-macros.hh b/lily/include/lily-guile-macros.hh
new file mode 100644 (file)
index 0000000..526d1ec
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+  lily-guile-macros.hh -- declare
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+*/
+
+#ifndef LILY_GUILE_MACROS_HH
+#define LILY_GUILE_MACROS_HH
+
+#ifndef SMOB_FREE_RETURN_VAL
+#define SMOB_FREE_RETURN_VAL(CL) 0
+#endif
+
+#ifndef SCM_PACK
+#define SCM_PACK(x) ((SCM) x)
+#endif
+
+#ifndef SCM_UNPACK
+#define SCM_UNPACK(x) (x)
+#endif
+
+
+#if (__GNUC__ > 2)
+/* Unreliable with gcc-2.x
+   FIXME: should add check for x86 as well?  */
+#define CACHE_SYMBOLS
+#endif
+
+#ifdef CACHE_SYMBOLS
+
+/* Using this trick we cache the value of scm_str2symbol ("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.
+
+  The overall speedup of lily is about 5% on a run of wtk1-fugue2.  */
+#define ly_symbol2scm(x) \
+({ \
+  static SCM cached; \
+  /* We store this one locally, since G++ -O2 fucks up else */ \
+  SCM value = cached; \
+  if ( __builtin_constant_p ((x))) \
+    { \
+      if (!cached) \
+        value = cached =  scm_gc_protect_object (scm_str2symbol ((x))); \
+    } \
+  else \
+    value = scm_str2symbol ((char*) (x)); \
+  value; \
+})
+#else
+inline SCM ly_symbol2scm(char const* x) { return scm_str2symbol ((x)); }
+#endif
+
+
+/*
+  TODO: rename me to ly_c_lily_module_eval
+ */
+#define ly_lily_module_constant(x) \
+({ \
+  static SCM cached; \
+  /* We store this one locally, since G++ -O2 fucks up else */ \
+  SCM value = cached; \
+  if ( __builtin_constant_p ((x))) \
+    { \
+      if (!cached) \
+        value = cached = scm_gc_protect_object (scm_eval (scm_str2symbol (x), \
+                                               global_lily_module)); \
+    } \
+  else \
+    value = scm_eval (scm_str2symbol (x), global_lily_module); \
+  value; \
+})
+
+
+
+/*
+  Adds the NAME as a Scheme function, and a variable to store the SCM
+  version of the function in the static variable NAME_proc
+ */
+#define DECLARE_SCHEME_CALLBACK(NAME, ARGS) \
+       static SCM NAME ARGS; \
+       static SCM NAME ## _proc
+
+/*
+  Make TYPE::FUNC available as a Scheme function.
+ */
+#define MAKE_SCHEME_CALLBACK(TYPE, FUNC, ARGCOUNT) \
+SCM TYPE :: FUNC ## _proc; \
+void \
+TYPE ## _ ## FUNC ## _init_functions () \
+{ \
+  TYPE :: FUNC ## _proc = scm_c_define_gsubr (#TYPE "::" #FUNC, \
+                                             (ARGCOUNT), 0, 0, \
+                         (Scheme_function_unknown)TYPE :: FUNC); \
+  scm_c_export (#TYPE "::" #FUNC, NULL); \
+} \
+ \
+ADD_SCM_INIT_FUNC (TYPE ## _ ## FUNC ## _callback, \
+                  TYPE ## _ ## FUNC ## _init_functions);
+
+
+void
+ly_add_function_documentation (SCM proc, char const *fname,
+                              char const *varlist,
+                              char const *doc);
+
+#define ADD_SCM_INIT_FUNC(name, func) \
+class name ## _scm_initter \
+{ \
+public: \
+  name ## _scm_initter () \
+  { \
+    add_scm_init_func (func); \
+  } \
+} _ ## name ## _scm_initter; \
+/* end define */
+
+#define LY_DEFINE_WITHOUT_DECL(INITPREFIX, FNAME, PRIMNAME, REQ, OPT, VAR, \
+                              ARGLIST, DOCSTRING) \
+SCM FNAME ## _proc; \
+void \
+INITPREFIX ## init () \
+{ \
+  FNAME ## _proc = scm_c_define_gsubr (PRIMNAME,REQ, OPT, VAR, \
+                                       (Scheme_function_unknown) FNAME); \
+  ly_add_function_documentation (FNAME ## _proc, PRIMNAME, #ARGLIST, \
+                                DOCSTRING); \
+  scm_c_export (PRIMNAME, NULL); \
+} \
+ADD_SCM_INIT_FUNC (INITPREFIX ## init_unique_prefix, INITPREFIX ## init); \
+SCM \
+FNAME ARGLIST
+
+
+#define LY_DEFINE(FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) \
+SCM FNAME ARGLIST; \
+LY_DEFINE_WITHOUT_DECL (FNAME, FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, \
+                       DOCSTRING)
+
+#define LY_DEFINE_MEMBER_FUNCTION(CLASS, FNAME, PRIMNAME, REQ, OPT, VAR, \
+                                 ARGLIST, DOCSTRING) \
+SCM FNAME ARGLIST; \
+LY_DEFINE_WITHOUT_DECL (CLASS ## FNAME, CLASS::FNAME, PRIMNAME, REQ, OPT, \
+                       VAR, ARGLIST, DOCSTRING)
+
+#define get_property(x) internal_get_property (ly_symbol2scm (x))
+#define set_property(x, y) internal_set_property (ly_symbol2scm (x), y)
+
+#endif /* LILY_GUILE_MACROS_HH */
index 13d50328fd91cd732f8427b8756157f0bf8a7a7d..f6cb2c1482646f5c1a97070670aa141b0705cbe7 100644 (file)
 
 #include "interval.hh"
 #include "guile-compatibility.hh"
+#include "lily-guile-macros.hh"
 #include "ly-module.hh"
 
-#ifndef SMOB_FREE_RETURN_VAL
-#define SMOB_FREE_RETURN_VAL(CL) 0
-#endif
-
-#ifndef SCM_PACK
-#define SCM_PACK(x) ((SCM) x)
-#endif
-
-#ifndef SCM_UNPACK
-#define SCM_UNPACK(x) (x)
-#endif
 
 /** Conversion functions follow the GUILE naming convention, i.e.
     A ly_B2A (B b);  */
@@ -38,59 +28,8 @@ SCM ly_truncate_list (int k, SCM lst);
 SCM ly_to_string (SCM scm);
 SCM ly_to_symbol (SCM scm);
 
-#if (__GNUC__ > 2)
-/* Unreliable with gcc-2.x
-   FIXME: should add check for x86 as well?  */
-#define CACHE_SYMBOLS
-#endif
-
-#ifdef CACHE_SYMBOLS
-
-/* Using this trick we cache the value of scm_str2symbol ("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.
-
-  The overall speedup of lily is about 5% on a run of wtk1-fugue2.  */
-#define ly_symbol2scm(x) \
-({ \
-  static SCM cached; \
-  /* We store this one locally, since G++ -O2 fucks up else */ \
-  SCM value = cached; \
-  if ( __builtin_constant_p ((x))) \
-    { \
-      if (!cached) \
-        value = cached =  scm_gc_protect_object (scm_str2symbol ((x))); \
-    } \
-  else \
-    value = scm_str2symbol ((char*) (x)); \
-  value; \
-})
-#else
-inline SCM ly_symbol2scm(char const* x) { return scm_str2symbol ((x)); }
-#endif
-
 extern SCM global_lily_module;
 
-/*
-  TODO: rename me to ly_c_lily_module_eval
- */
-#define ly_lily_module_constant(x) \
-({ \
-  static SCM cached; \
-  /* We store this one locally, since G++ -O2 fucks up else */ \
-  SCM value = cached; \
-  if ( __builtin_constant_p ((x))) \
-    { \
-      if (!cached) \
-        value = cached = scm_gc_protect_object (scm_eval (scm_str2symbol (x), \
-                                               global_lily_module)); \
-    } \
-  else \
-    value = scm_eval (scm_str2symbol (x), global_lily_module); \
-  value; \
-})
-
 String gulp_file_to_string (String fn, bool must_exist);
 
 String ly_scm2string (SCM s);
@@ -212,79 +151,4 @@ typedef SCM (*Scheme_function_1) (...);
 typedef SCM (*Scheme_function_2) (...);
 typedef SCM (*Scheme_function_3) (...);
 #endif
-
-
-/*
-  Adds the NAME as a Scheme function, and a variable to store the SCM
-  version of the function in the static variable NAME_proc
- */
-#define DECLARE_SCHEME_CALLBACK(NAME, ARGS) \
-       static SCM NAME ARGS; \
-       static SCM NAME ## _proc
-
-/*
-  Make TYPE::FUNC available as a Scheme function.
- */
-#define MAKE_SCHEME_CALLBACK(TYPE, FUNC, ARGCOUNT) \
-SCM TYPE :: FUNC ## _proc; \
-void \
-TYPE ## _ ## FUNC ## _init_functions () \
-{ \
-  TYPE :: FUNC ## _proc = scm_c_define_gsubr (#TYPE "::" #FUNC, \
-                                             (ARGCOUNT), 0, 0, \
-                         (Scheme_function_unknown)TYPE :: FUNC); \
-  scm_c_export (#TYPE "::" #FUNC, NULL); \
-} \
- \
-ADD_SCM_INIT_FUNC (TYPE ## _ ## FUNC ## _callback, \
-                  TYPE ## _ ## FUNC ## _init_functions);
-
-
-void
-ly_add_function_documentation (SCM proc, char const *fname,
-                              char const *varlist,
-                              char const *doc);
-
-#define ADD_SCM_INIT_FUNC(name, func) \
-class name ## _scm_initter \
-{ \
-public: \
-  name ## _scm_initter () \
-  { \
-    add_scm_init_func (func); \
-  } \
-} _ ## name ## _scm_initter; \
-/* end define */
-
-#define LY_DEFINE_WITHOUT_DECL(INITPREFIX, FNAME, PRIMNAME, REQ, OPT, VAR, \
-                              ARGLIST, DOCSTRING) \
-SCM FNAME ## _proc; \
-void \
-INITPREFIX ## init () \
-{ \
-  FNAME ## _proc = scm_c_define_gsubr (PRIMNAME,REQ, OPT, VAR, \
-                                       (Scheme_function_unknown) FNAME); \
-  ly_add_function_documentation (FNAME ## _proc, PRIMNAME, #ARGLIST, \
-                                DOCSTRING); \
-  scm_c_export (PRIMNAME, NULL); \
-} \
-ADD_SCM_INIT_FUNC (INITPREFIX ## init_unique_prefix, INITPREFIX ## init); \
-SCM \
-FNAME ARGLIST
-
-
-#define LY_DEFINE(FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) \
-SCM FNAME ARGLIST; \
-LY_DEFINE_WITHOUT_DECL (FNAME, FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, \
-                       DOCSTRING)
-
-#define LY_DEFINE_MEMBER_FUNCTION(CLASS, FNAME, PRIMNAME, REQ, OPT, VAR, \
-                                 ARGLIST, DOCSTRING) \
-SCM FNAME ARGLIST; \
-LY_DEFINE_WITHOUT_DECL (CLASS ## FNAME, CLASS::FNAME, PRIMNAME, REQ, OPT, \
-                       VAR, ARGLIST, DOCSTRING)
-
-#define get_property(x) internal_get_property (ly_symbol2scm (x))
-#define set_property(x, y) internal_set_property (ly_symbol2scm (x), y)
-
 #endif /* LILY_GUILE_HH */
index 5465ef4075e9611b46145e025c8f2b7d19fae396..88d6f28c49666e76d8788141171128078f45abcf 100644 (file)
@@ -7,6 +7,7 @@
 
 */
 
+#include "font-metric.hh"
 #include "output-def.hh"
 #include "ly-module.hh"
 #include "context-def.hh"
@@ -94,3 +95,29 @@ LY_DEFINE (ly_make_output_def, "ly:make-output-def",
   Output_def *bp = new Output_def ;
   return scm_gc_unprotect_object (bp->self_scm ());
 }
+
+LY_DEFINE (ly_paper_get_font, "ly:paper-get-font", 2, 0, 0,
+          (SCM paper_smob, SCM chain),
+
+          "Return a font metric satisfying the font-qualifiers "
+          "in the alist chain @var{chain}.\n"
+          "(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");
+  
+  Font_metric *fm = select_font (paper, chain);
+  return fm->self_scm ();
+}
+
+LY_DEFINE (ly_paper_get_number, "ly:paper-get-number", 2, 0, 0,
+          (SCM layout_smob, SCM name),
+          "Return the layout variable @var{name}.")
+{
+  Output_def *layout = unsmob_output_def (layout_smob);
+  SCM_ASSERT_TYPE (layout, layout_smob, SCM_ARG1,
+                  __FUNCTION__, "layout definition");
+  return scm_make_real (layout->get_dimension (name));
+}