X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Finclude%2Fsmobs.tcc;h=818c0900a56bac154476b49282eae6bf529241b8;hb=dea413b36a5c2ba9b01dcab3fa764fa5ab9f8418;hp=0838a791b247d0f0a03202f096fbde7dc625571a;hpb=8cd6c7945283badb27640b3a0020808ace14a27a;p=lilypond.git diff --git a/lily/include/smobs.tcc b/lily/include/smobs.tcc index 0838a791b2..818c0900a5 100644 --- a/lily/include/smobs.tcc +++ b/lily/include/smobs.tcc @@ -1,7 +1,7 @@ /* -*- C++ -*- This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 2005--2014 Han-Wen Nienhuys + Copyright (C) 2005--2015 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 @@ -24,22 +24,26 @@ // included from smobs.hh, but other template expansion systems might // make it feasible to compile this only a single time. -#include "lily-guile-macros.hh" -#include "smobs.hh" #include template SCM Smob_base::mark_trampoline (SCM arg) { - return (Super::unsmob (arg))->mark_smob (); + Super *ptr = unsmob (arg); + if (ptr) + return ptr->mark_smob (); + return SCM_UNDEFINED; } template int Smob_base::print_trampoline (SCM arg, SCM port, scm_print_state *p) { - return (Super::unsmob (arg))->print_smob (port, p); + Super *ptr = unsmob (arg); + if (ptr) + return ptr->print_smob (port, p); + return 0; } template @@ -59,7 +63,7 @@ Smob_base::register_ptr (Super *p) // Defaults, should not actually get called template SCM -Smob_base::mark_smob () +Smob_base::mark_smob () const { return SCM_UNSPECIFIED; } @@ -82,7 +86,7 @@ Smob_base::equal_p (SCM, SCM) template int -Smob_base::print_smob (SCM p, scm_print_state *) +Smob_base::print_smob (SCM p, scm_print_state *) const { scm_puts ("#<", p); scm_puts (smob_name_.c_str (), p); @@ -96,6 +100,7 @@ Smob_base::unregister_ptr (SCM obj) { Super *p = Super::unchecked_unsmob (obj); scm_gc_unregister_collectable_memory (p, sizeof (*p), smob_name_.c_str ()); + SCM_SET_SMOB_DATA (obj, static_cast (0)); return p; } @@ -103,11 +108,14 @@ template scm_t_bits Smob_base::smob_tag_ = 0; template -Scm_init Smob_base::scm_init_ = init; +Scm_init Smob_base::scm_init_ (init); template string Smob_base::smob_name_; +template +const char * const Smob_base::type_p_name_ = 0; + template void Smob_base::init () { @@ -144,11 +152,6 @@ void Smob_base::init () scm_c_export (Super::type_p_name_, NULL); } ly_add_type_predicate ((void *) is_smob, smob_name_.c_str ()); - if (Super::smob_proc_signature_ >= 0) - 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); + Super::smob_proc_init (smob_tag_); } #endif