+1.3.59.hwn1
+===========
+
+* Use Scheme_hash_table for identifier Scopes. Scheme_hash_table is
+based on STL and should be faster than hash_table.
+
1.3.58.hwn1
===========
MAJOR_VERSION=1
MINOR_VERSION=3
PATCH_LEVEL=59
-MY_PATCH_LEVEL=uu1
+MY_PATCH_LEVEL=uu2
# use the above to send patches: MY_PATCH_LEVEL is always empty for a
# released version.
*/
#include <fstream.h>
-#include "dictionary-iter.hh"
#include "dstream.hh"
-
+#include "dictionary-iter.hh"
+#include "dictionary.hh"
#include "text-db.hh"
#include "string-convert.hh"
#include "rational.hh"
bool
Dstream::silent_b (String s) const
{
+ if (!silent_dict_p_)
+ return 0;
+
if (!silent_dict_p_->elem_b (s))
return false;
return (*silent_dict_p_)[s];
void
Dstream::clear_silence()
{
- for (map<String,bool>::iterator ki(silent_dict_p_->begin ());
- silent_dict_p_->end () != ki; ki++)
- {
- (*ki).second = false;
- }
+ delete silent_dict_p_;
+ silent_dict_p_ = 0;
}
#include <map>
-#include "hash-table.hh"
-
-
unsigned int string_hash (String);
TODO:
make a baseclass for indentable streams.
+
+ JUNKME
*/
class Dstream
{
String current_classname_str_;
void output (String s);
Dictionary<bool> *silent_dict_p_;
-
+
public:
void clear_silence();
bool silent_b (String) const;
#include "debug.hh"
#include "request.hh"
#include "translator-group.hh"
+#include "ly-smobs.icc"
+IMPLEMENT_UNSMOB(Identifier, identifier);
+IMPLEMENT_SMOBS(Identifier);
Identifier::Identifier (int code)
{
+ self_scm_ = SCM_EOL;
token_code_i_ = code;
accessed_b_ = 0;
}
Identifier::Identifier (Identifier const&s)
: Input (s)
{
+ self_scm_ = SCM_EOL;
token_code_i_ = s.token_code_i_;
accessed_b_ = s.accessed_b_;
}
DEFAULT_ACCESSOR(Midi_def);
DEFAULT_ACCESSOR(Paper_def);
+int
+Identifier::print_smob (SCM s, SCM p, scm_print_state*)
+{
+ return 1;
+}
+
+SCM
+Identifier::mark_smob (SCM s)
+{
+ return SCM_EOL;
+}
+
+
+
+void
+Identifier::do_smobify_self ()
+{
+
+}
#define IDENTIFIER_HH
#include "lily-proto.hh"
+#include "lily-guile.hh"
#include "string.hh"
#include "input.hh"
#include "virtual-methods.hh"
+#include "smobs.hh"
#define DECLARE_TYPE_NAME(Class)
TODO: use SMOBS for the union type, and junk all derived classes.
*/
struct Identifier : public Input {
+
+ DECLARE_SMOBS;
bool init_b_;
bool accessed_b_;
int token_code_i_;
Identifier (Identifier const&);
Identifier (int code) ;
virtual ~Identifier() ;
-
+
void print() const;
DECLARE_ID_CLASS(Paper_def);
DECLARE_ID_CLASS(Midi_def);
+Identifier * unsmob_identifier (SCM);
+
#endif // IDENTIFIER_HH
#include <map>
#include "lily-guile.hh"
-#include "hash-table.hh"
#include "smobs.hh"
#include "lily-proto.hh"
#include "lily-guile.hh"
-class Protected_scm;
+class Scheme_hash_table;
class Scope {
- Hash_table<Protected_scm,Identifier*> *id_dict_;
+ Scheme_hash_table *id_dict_;
public:
+ SCM to_alist () const;
bool elem_b (String ) const;
bool elem_b (SCM s) const;
- Identifier *&elem (String);
- Identifier *&elem (SCM s);
+ Identifier *elem (String) const;
+ Identifier *elem (SCM) const;
+ void set (String, Identifier *);
Scope ();
Scope (Scope const &);
~Scope ();
friend class Scope_iter;
};
-
+#if 0
class Scope_iter {
Hash_table_iter<Protected_scm,Identifier*> * iter_;
public:
SCM scm_key () const;
};
+#endif
#endif /* SCOPE_HH */
Translator *get_simple_translator (String) const;
Translator_group *find_existing_translator_l (String n, String id);
Translator_group *find_create_translator_l (String n, String id);
- Link_array<Translator_group> path_to_acceptable_translator (String alias) const;
+ Link_array<Translator_group> path_to_acceptable_translator (String alias, Music_output_def*) const;
Translator_group*get_default_interpreter();
virtual ~Translator_group ();
#include "debug.hh"
#include "music-output-def.hh"
#include "global-translator.hh"
-#include "dictionary-iter.hh"
+
#include "identifier.hh"
#include "main.hh"
#include "lily-guile.hh"
{
scope_p_ = new Scope (*s.scope_p_);
translator_p_dict_p_ = new Scope (*s.translator_p_dict_p_);
- // default_properties_ = s.default_properties_;
-
- for (Scope_iter i (*translator_p_dict_p_); i.ok (); i++)
- {
- Translator * t = i.val ()->access_content_Translator_group (false);
- t-> output_def_l_ = this;
- }
}
void
{
tp->warning (_("Interpretation context with empty type"));
}
- if (translator_p_dict_p_->elem_b (s))
- delete translator_p_dict_p_->elem (s);
-
- translator_p_dict_p_->elem (s) = new Translator_group_identifier (tp, 0);
- tp ->output_def_l_ = this;
+
+ translator_p_dict_p_->set (s, new Translator_group_identifier (tp, 0));
}
Translator*
if (!t)
error (_f ("can't find `%s' context", "Score"));
t = t->clone ();
+ t->output_def_l_ = this;
Global_translator *g = dynamic_cast <Global_translator *> (t);
t->add_processing ();
if (old)
{
- delete old;
+ // delete old;
}
if (lookup_keyword (name_str) >= 0)
{
warning ( _f ("Identifier name is a keyword: `%s'", name_str));
}
- scope_l_arr_.top ()->elem (name_str) = i;
+ scope_l_arr_.top ()->set (name_str, i);
}
My_lily_lexer::~My_lily_lexer()
#include "identifier.hh"
#include "main.hh"
#include "scope.hh"
-#include "dictionary-iter.hh"
#include "file-results.hh" // urg? header_global_p
#include "paper-outputter.hh"
#include "paper-stream.hh"
#include <iostream.h>
#include "dimensions.hh"
-#include "dictionary-iter.hh"
#include "virtual-methods.hh"
#include "paper-outputter.hh"
#include "paper-stream.hh"
void
Paper_outputter::output_scope (Scope *scope, String prefix)
{
- for (Scope_iter i (*scope); i.ok (); i++)
+ SCM al = scope->to_alist ();
+ for (SCM s = al ; gh_pair_p (s); s = gh_cdr (s))
{
- if (dynamic_cast<String_identifier*> (i.val ()))
- {
- String val = *i.val()->access_content_String (false);
+ SCM k = gh_caar (s);
+ SCM v = gh_cdar (s);
+
+ Identifier * id = unsmob_identifier (v);
+ String s = ly_symbol2string (k);
- output_String_def (prefix + i.key (), val);
+ if (dynamic_cast<String_identifier*> (id))
+ {
+ String val = *id->access_content_String (false);
+
+ output_String_def (prefix + s, val);
}
- else if(dynamic_cast<Real_identifier*> (i.val ()))
+ else if(dynamic_cast<Real_identifier*> (id))
{
- Real val = *i.val ()->access_content_Real (false);
+ Real val = *id->access_content_Real (false);
- output_Real_def (prefix + i.key (), val);
+ output_Real_def (prefix + s, val);
}
- else if (dynamic_cast<int_identifier*> (i.val ()))
+ else if (dynamic_cast<int_identifier*> (id))
{
- int val = *i.val ()->access_content_int (false);
+ int val = *id->access_content_int (false);
- output_int_def (prefix + i.key (), val);
+ output_int_def (prefix + s, val);
}
}
}
#include <stdio.h>
#include "scm-hash.hh"
-#include "hash-table-iter.hh"
+
Scheme_hash_table::Scheme_hash_table ()
*/
#include "scope.hh"
-#include "dictionary-iter.hh"
-#include "debug.hh"
#include "identifier.hh"
-#include "dictionary.hh"
-#include "protected-scm.hh"
+#include "scm-hash.hh"
Scope::~Scope ()
{
- for (Scope_iter ai (*this); ai.ok(); ai++)
- delete ai.val ();
delete id_dict_;
}
Scope::Scope (Scope const&s)
+ : id_dict_ (new Scheme_hash_table (*s.id_dict_))
{
+ /*
+ cloning not necessary.
+
id_dict_ = new Hash_table<Protected_scm,Identifier*> (*s.id_dict_);
for (Scope_iter ai (s); ai.ok(); ai++)
{
id_dict_->elem (ai.scm_key ()) = ai.val ()->clone ();
}
+ */
}
-unsigned int ly_pscm_hash (Protected_scm s)
-{
- return ly_scm_hash (s);
-}
-
-
Scope::Scope ()
{
- id_dict_ = new Hash_table<Protected_scm,Identifier*>;
- id_dict_->hash_func_ = ly_pscm_hash;
+ id_dict_ = new Scheme_hash_table;
}
bool
}
-Identifier *&
-Scope::elem (String s)
-{
- return id_dict_->elem (ly_symbol2scm (s.ch_C()));
-}
-
-
-Scope_iter::Scope_iter (Scope const &s)
-{
- iter_ = new Hash_table_iter<Protected_scm,Identifier*>(*s.id_dict_);
-}
-
-String
-Scope_iter::key () const
-{
- SCM s= iter_->key ();
- return ly_symbol2string (s);
-}
-
bool
Scope::elem_b (SCM s) const
{
return id_dict_->elem_b (s);
}
-
-Identifier* &
-Scope::elem (SCM s)
-{
- return id_dict_->elem (s);
-}
-
-SCM
-Scope_iter::scm_key () const
+Identifier*
+Scope::elem (SCM s)const
{
- return iter_->key ();
+ return unsmob_identifier (id_dict_->get (s));
}
-
-bool
-Scope_iter::ok () const
+Identifier*
+Scope::elem (String s)const
{
- return iter_->ok();
+ return elem (ly_symbol2scm (s.ch_C()));
}
void
-Scope_iter::operator ++(int)
+Scope::set (String s, Identifier * id)
{
- (*iter_) ++;
+ return id_dict_->set (ly_symbol2scm (s.ch_C()),
+ id->smobify_self());
}
-Identifier*
-Scope_iter::val ()const
+SCM
+Scope::to_alist () const
{
- return iter_->val ();
+ return id_dict_->to_alist ();
}
#include "translator.hh"
#include "debug.hh"
#include "moment.hh"
-#include "dictionary-iter.hh"
#include "killing-cons.tcc"
Translator_group::add_translator (Translator *trans_p)
{
trans_p_list_.append (new Killing_cons<Translator> (trans_p,0));
-
+
trans_p->daddy_trans_l_ = this;
trans_p->output_def_l_ = output_def_l_;
trans_p->add_processing ();
}
Link_array<Translator_group>
-Translator_group::path_to_acceptable_translator (String type) const
+Translator_group::path_to_acceptable_translator (String type, Music_output_def* odef) const
{
Link_array<Translator_group> accepted_arr;
for (int i=0; i < accepts_str_arr_.size (); i++)
{
- Translator *t = output_def_l ()->find_translator_l (accepts_str_arr_[i]);
+ Translator *t = odef->find_translator_l (accepts_str_arr_[i]);
if (!t || !dynamic_cast <Translator_group *> (t))
continue;
accepted_arr.push (dynamic_cast <Translator_group *> (t));
Translator_group * g = accepted_arr[i];
Link_array<Translator_group> result
- = g->path_to_acceptable_translator (type);
+ = g->path_to_acceptable_translator (type, odef);
if (result.size () && result.size () < best_depth)
{
result.insert (g,0);
if (existing)
return existing;
- Link_array<Translator_group> path = path_to_acceptable_translator (n);
+ Link_array<Translator_group> path
+ = path_to_acceptable_translator (n, output_def_l ());
if (path.size ())
{
for (int i=0; i < path.size (); i++)
{
Translator_group * new_group = dynamic_cast<Translator_group*>(path[i]->clone ());
+
current->add_translator (new_group);
current = new_group;
}
\notes \context PianoStaff <
\context Staff = treble <
- \key c \minor;
+% \key c \minor;
+ \key es;
\dux
{ \comes \bar "|."; }
\time 4/4;
\property Score.timeSignatureStyle = "C"
>
\context Staff = bass <
- \key c \minor;
+ \key es;% \key c \minor;
\bassdux
>
>