/*
This file is part of LilyPond, the GNU music typesetter.
- Copyright (C) 2002--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ Copyright (C) 2002--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
LilyPond is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#define INTERFACE_HH
#include "lily-guile.hh"
+#include "protected-scm.hh"
-#define DECLARE_GROB_INTERFACE() \
- static SCM interface_symbol_; \
- static bool has_interface (Grob*)
-
-#define ADD_INTERFACE(cl, b, c) \
- SCM cl::interface_symbol_; \
- bool cl::has_interface (Grob *me) \
- { \
- return me->internal_has_interface (interface_symbol_); \
- } \
- void cl ## _init_ifaces () \
- { \
- cl::interface_symbol_ = add_interface (#cl, b, c); \
- } \
- ADD_SCM_INIT_FUNC (cl ## ifaces, cl ## _init_ifaces);
+class Grob;
+
+#define ADD_INTERFACE(cl, b, c) \
+ Grob_interface<cl> cl ## _interface_initializer; \
+ template <> char const *Grob_interface<cl>::cxx_name_ (#cl); \
+ template <> char const *Grob_interface<cl>::description_ (b); \
+ template <> char const *Grob_interface<cl>::variables_ (c);
SCM add_interface (char const *cxx_name,
char const *descr,
void internal_add_interface (SCM, SCM, SCM);
SCM ly_all_grob_interfaces ();
+template <class Interface>
+class Grob_interface
+{
+public:
+ Grob_interface ()
+ {
+ add_scm_init_func (Grob_interface::init);
+ }
+
+private:
+ static void init ()
+ {
+ interface_symbol_ = ::add_interface (cxx_name_, description_, variables_);
+ }
+
+ template <class T>
+ friend bool has_interface(Grob *);
+
+private:
+ static Protected_scm interface_symbol_;
+ static char const *cxx_name_;
+ static char const *description_;
+ static char const *variables_;
+};
+
+template <class Interface>
+Protected_scm Grob_interface<Interface>::interface_symbol_;
+
#endif /* INTERFACE_HH */