#include "paper-score.hh"
#include "page-marker.hh"
+ADD_SMOB_INIT (Book);
Book::Book ()
{
#include "box.hh"
+ADD_SMOB_INIT (Box);
+
void
Box::translate (Offset o)
{
#include "translator.hh"
#include "warn.hh"
+ADD_SMOB_INIT (Context_def);
+
Context_def::Context_def ()
{
context_aliases_ = SCM_EOL;
#include "context-mod.hh"
+ADD_SMOB_INIT (Context_mod);
+
Context_mod::Context_mod ()
{
mods_ = SCM_EOL;
cooked_ (alist), cooked_from_ (alist), nested_ (0) { }
};
+ADD_SMOB_INIT (Grob_properties);
+
const char Grob_properties::type_p_name_[] = "ly:grob-properties?";
SCM
#include "translator-group.hh"
#include "warn.hh"
+ADD_SMOB_INIT (Context);
+
bool
Context::is_removable () const
{
#include "international.hh"
#include "warn.hh"
+ADD_SMOB_INIT (Dispatcher);
+
const char Dispatcher::type_p_name_[] = "ly:dispatcher?";
Dispatcher::~Dispatcher ()
#include "duration.hh"
+ADD_SMOB_INIT (Duration);
+
#include "misc.hh"
#include "lily-proto.hh"
#include "stencil.hh"
#include "warn.hh"
+ADD_SMOB_INIT (Font_metric);
Real
Font_metric::design_size () const
#include "item.hh"
#include "spanner.hh"
+ADD_SMOB_INIT (Grob_array);
Item *
Grob_array::item (vsize i)
#include "unpure-pure-container.hh"
#include "warn.hh"
+ADD_SMOB_INIT (Grob);
Grob *
Grob::clone () const
*/
-// Initialization class. Create a variable or static data member of
-// this type at global scope (or creation will happen too late for
-// Scheme initialization), initialising with a function to be called.
-// Reference somewhere (like in the constructor of the containing
-// class) to make sure the variable is actually instantiated.
-
-class Scm_init {
-public:
- Scm_init () { }
- Scm_init (void (*fun) (void))
- {
- add_scm_init_func (fun);
- }
-};
-
template <class Super>
class Smob_base
{
static scm_t_bits smob_tag_;
- static Scm_init scm_init_;
- static void init (void);
+ static scm_t_bits init_id (void);
static string smob_name_;
static Super *unchecked_unsmob (SCM s)
{
return reinterpret_cast<Super *> (SCM_SMOB_DATA (s));
}
protected:
- // reference scm_init_ in smob_tag which is sure to be called. The
- // constructor, in contrast, may not be called at all in classes
- // like Smob1.
- static scm_t_bits smob_tag () { (void) scm_init_; return smob_tag_; }
+ // This is an initialization with side effect. It is called once,
+ // the first time smob_tag is actually getting called. This
+ // allocates and initializes the type before it is first used for
+ // anything.
+ static scm_t_bits smob_tag ()
+ {
+ static scm_t_bits tag = init_id ();
+ return tag;
+ }
Smob_base () { }
static SCM register_ptr (Super *p);
static Super *unregister_ptr (SCM obj);
static const int smob_proc_signature_ = -1;
public:
+ static void init (void)
+ {
+ // This is stupid, but without forcing initialization at the
+ // Scheme startup hook stage, stuff like ly:undead? will not be
+ // defined when the first Scheme files are loaded.
+ //
+ // So we provide an explicit initialization routine that can be
+ // used with ADD_SCM_INIT_FUNC
+ (void) smob_tag ();
+ }
+#define ADD_SMOB_INIT(type) ADD_SCM_INIT_FUNC (Smob_init_ ## type, Smob_base<type>::init)
static bool is_smob (SCM s)
{
return SCM_SMOB_PREDICATE (smob_tag (), s);
return p;
}
-template <class Super>
-scm_t_bits Smob_base<Super>::smob_tag_ = 0;
-
-template <class Super>
-Scm_init Smob_base<Super>::scm_init_ = init;
-
template <class Super>
string Smob_base<Super>::smob_name_;
template <class Super>
-void Smob_base<Super>::init ()
+scm_t_bits Smob_base<Super>::init_id ()
{
smob_name_ = typeid (Super).name ();
// Primitive demangling, suitable for GCC, should be harmless
// unsuitable for Texinfo documentation. If that proves to be an
// issue, we need some smarter strategy.
smob_name_ = smob_name_.substr (smob_name_.find_first_not_of ("0123456789"));
- assert(!smob_tag_);
- smob_tag_ = scm_make_smob_type (smob_name_.c_str (), 0);
+ scm_t_bits smob_tag = scm_make_smob_type (smob_name_.c_str (), 0);
// The following have trivial private default definitions not
// referring to any aspect of the Super class apart from its name.
// They should be overridden (or rather masked) at Super level: that
// doing it like the rest.
if (&Super::free_smob != &Smob_base<Super>::free_smob)
- scm_set_smob_free (smob_tag_, Super::free_smob);
+ scm_set_smob_free (smob_tag, Super::free_smob);
// Old GCC versions get their type lattice for pointers-to-members
// tangled up to a degree where we need to typecast _both_ covariant
// types in order to be able to compare them. The other comparisons
// pointers which work without those contortions.
if (static_cast<SCM (Super::*)()>(&Super::mark_smob) !=
static_cast<SCM (Super::*)()>(&Smob_base<Super>::mark_smob))
- scm_set_smob_mark (smob_tag_, Super::mark_trampoline);
- scm_set_smob_print (smob_tag_, Super::print_trampoline);
+ scm_set_smob_mark (smob_tag, Super::mark_trampoline);
+ scm_set_smob_print (smob_tag, Super::print_trampoline);
if (&Super::equal_p != &Smob_base<Super>::equal_p)
- scm_set_smob_equalp (smob_tag_, Super::equal_p);
+ scm_set_smob_equalp (smob_tag, Super::equal_p);
if (Super::type_p_name_ != 0)
{
SCM subr = scm_c_define_gsubr (Super::type_p_name_, 1, 0, 0,
}
ly_add_type_predicate ((void *) is_smob, smob_name_.c_str ());
if (Super::smob_proc_signature_ >= 0)
- scm_set_smob_apply (smob_tag_,
+ scm_set_smob_apply (smob_tag,
(scm_t_subr)Super::smob_proc,
Super::smob_proc_signature_ >> 8,
(Super::smob_proc_signature_ >> 4)&0xf,
Super::smob_proc_signature_ & 0xf);
+ return smob_tag;
}
#endif
#include "source-file.hh"
#include "std-string.hh"
+ADD_SMOB_INIT (Input);
+
/* Dummy input location for use if real one is missing. */
Input dummy_input_global;
#include "program-option.hh"
#include "lily-parser.hh"
+ADD_SMOB_INIT (Lily_lexer);
+
static Keyword_ent the_key_tab[]
=
{
#include "warn.hh"
#include "program-option.hh"
+ADD_SMOB_INIT (Lily_parser);
Lily_parser::Lily_parser (Sources *sources)
{
#include "listener.hh"
#include "warn.hh"
+ADD_SMOB_INIT (Listener);
+
Listener::Listener ()
{
target_ = 0;
#include "warn.hh"
+ADD_SMOB_INIT (Moment);
+
Moment::Moment ()
{
}
#include "music-function.hh"
+ADD_SMOB_INIT (Music_function);
+
const char Music_function::type_p_name_[] = "ly:music-function?";
/* Print a textual represenation of the smob to a given port. */
#include "music-wrapper-iterator.hh"
#include "simple-music-iterator.hh"
+ADD_SMOB_INIT (Music_iterator);
Music_iterator::Music_iterator ()
{
#include "music-output.hh"
+ADD_SMOB_INIT (Music_output);
Music_output::Music_output ()
{
#include "string-convert.hh"
+ADD_SMOB_INIT (Output_def);
+
Output_def::Output_def ()
{
scope_ = SCM_EOL;
#include "page-marker.hh"
+ADD_SMOB_INIT (Page_marker);
+
Page_marker::Page_marker ()
{
symbol_ = SCM_EOL;
#include "program-option.hh"
#include "page-marker.hh"
+ADD_SMOB_INIT (Paper_book);
Paper_book::Paper_book ()
{
#include "string-convert.hh"
#include "warn.hh"
+ADD_SMOB_INIT (Paper_outputter);
Paper_outputter::Paper_outputter (SCM port, const string &format)
{
#include <cmath>
+ADD_SMOB_INIT (Pitch);
+
Pitch::Pitch (int o, int n, Rational a)
{
notename_ = n;
#include "input.hh"
#include "profile.hh"
+ADD_SMOB_INIT (Prob);
const char Prob::type_p_name_[] = "ly:prob?";
#include "scale.hh"
+ADD_SMOB_INIT (Scale);
/*
todo: put string <-> pitch here too.
#include "scheme-listener.hh"
+ADD_SMOB_INIT (Scheme_listener);
+
IMPLEMENT_LISTENER (Scheme_listener, call)
void
Scheme_listener::call (SCM ev)
#include <algorithm>
using namespace std;
+ADD_SMOB_INIT (Scheme_hash_table);
+
/*
Return: number of objects.
#include "score.hh"
+ADD_SMOB_INIT (Score);
+
#include <cstdio>
using namespace std;
#include "grob.hh"
+ADD_SMOB_INIT (Simple_closure);
+
SCM
evaluate_args (SCM delayed_argument, SCM args, bool pure, int start, int end)
{
#include "spring.hh"
#include "warn.hh"
+ADD_SMOB_INIT (Simple_spacer);
+
/*
A simple spacing constraint solver. The approach:
#include "international.hh"
+ADD_SMOB_INIT (Skyline_pair);
+
Skyline_pair::Skyline_pair ()
: skylines_ (Skyline (DOWN), Skyline (UP))
{
Alert to these considerations, we now accept buildings of zero-width.
*/
+ADD_SMOB_INIT (Skyline);
+
static void
print_buildings (list<Building> const &b)
{
#include "misc.hh"
#include "warn.hh"
+ADD_SMOB_INIT (Source_file);
+
void
Source_file::load_stdin ()
{
#include "spring.hh"
+ADD_SMOB_INIT (Spring);
+
Spring::Spring ()
{
distance_ = 1.0;
#include "string-convert.hh"
#include "warn.hh"
+ADD_SMOB_INIT (Stencil);
Stencil::Stencil ()
{
#include "translator-dispatch-list.hh"
#include "engraver.hh"
+ADD_SMOB_INIT (Engraver_dispatch_list);
void
Engraver_dispatch_list::apply (Grob_info gi)
#include "scm-hash.hh"
#include "warn.hh"
+ADD_SMOB_INIT (Translator_group);
+
void
translator_each (SCM list, Translator_method method)
{
#include "translator.icc"
+ADD_SMOB_INIT (Translator);
+
Translator::~Translator ()
{
}
Undead (SCM object = SCM_UNDEFINED) : object_ (object) { };
};
+ADD_SMOB_INIT (Undead);
+
SCM
Undead::mark_smob ()
{