input_location_ = SCM_EOL;
smobify_self ();
- input_location_ = make_input (Input ());
+ input_location_ = Input ().smobbed_copy ();
}
Book::Book (Book const &s)
paper_->unprotect ();
}
- input_location_ = make_input (*s.origin ());
+ input_location_ = s.origin ()->smobbed_copy ();
header_ = ly_make_module (false);
if (ly_is_module (s.header_))
smobify_self ();
- input_location_ = make_input (Input ());
+ input_location_ = Input ().smobbed_copy ();
context_name_ = ly_symbol2scm ("");
}
smobify_self ();
description_ = s.description_;
- input_location_ = make_input (*s.origin ());
+ input_location_ = s.origin ()->smobbed_copy ();
default_child_ = s.default_child_;
accept_mods_ = s.accept_mods_;
property_ops_ = s.property_ops_;
/**
Base class for anything that records its poisition in the parse file.
*/
-class Input
+class Input : public Simple_smob<Input>
{
char const *start_;
char const *end_;
Source_file *source_file_;
public:
+ static const char type_p_name_[];
+ static int print_smob (SCM, SCM, scm_print_state *);
+ static SCM equal_p (SCM, SCM);
+ static SCM mark_smob (SCM);
Source_file *get_source_file () const;
char const *start () const;
char const *end () const;
- static Input *unsmob (SCM);
-
void set (Source_file *, char const *, char const *);
void error (const string&) const;
void programming_error (const string&) const;
string message_string (const string &msg) const;
};
-SCM make_input (Input spot);
-
extern Input dummy_input_global;
#endif // INPUT_HH
#include "std-string.hh"
#include "input.hh"
-/* We don't use IMPLEMENT_TYPE_P, since the smobification part is
- implemented separately from the class. */
-LY_DEFINE (ly_input_location_p, "ly:input-location?", 1, 0, 0,
- (SCM x),
- "Is @var{x} an @code{input-location}?")
-{
- return Input::unsmob (x) ? SCM_BOOL_T : SCM_BOOL_F;
-}
-
LY_DEFINE (ly_input_warning, "ly:input-warning", 2, 0, 1, (SCM sip, SCM msg, SCM rest),
"Print @var{msg} as a GNU compliant warning message, pointing"
" to the location in @var{sip}. @var{msg} is interpreted"
/* Dummy input location for use if real one is missing. */
Input dummy_input_global;
-static long input_tag;
+const char Input::type_p_name_[] = "ly:input-location?";
-static SCM
-mark_smob (SCM s)
+SCM
+Input::mark_smob (SCM s)
{
- Input *sc = (Input *) SCM_CELL_WORD_1 (s);
+ Input *sc = unsmob (s);
if (Source_file *sf = sc->get_source_file ())
return sf->self_scm ();
return SCM_EOL;
}
-static int
-print_smob (SCM s, SCM port, scm_print_state *)
+int
+Input::print_smob (SCM s, SCM port, scm_print_state *)
{
string str = "#<location " + Input::unsmob (s)->location_string () + ">";
scm_puts (str.c_str (), port);
return 1;
}
-static size_t
-free_smob (SCM s)
-{
- delete Input::unsmob (s);
- return 0;
-}
-
-static SCM
-equal_smob (SCM sa, SCM sb)
+SCM
+Input::equal_p (SCM sa, SCM sb)
{
- Input *a = (Input *) SCM_CELL_WORD_1 (sa);
- Input *b = (Input *) SCM_CELL_WORD_1 (sb);
+ Input *a = unsmob (sa);
+ Input *b = unsmob (sb);
if (a->get_source_file () == b->get_source_file ()
&& a->start () == b->start ()
&& a->end () == b->end ())
else
return SCM_BOOL_F;
}
-
-static void
-start_input_smobs ()
-{
- input_tag = scm_make_smob_type ("input", 0);
- scm_set_smob_mark (input_tag, mark_smob);
- scm_set_smob_free (input_tag, free_smob);
- scm_set_smob_print (input_tag, print_smob);
- scm_set_smob_equalp (input_tag, equal_smob);
-}
-
-SCM
-make_input (Input ip)
-{
- Input *nip = new Input (ip);
- SCM z;
-
- SCM_NEWSMOB (z, input_tag, nip);
- return z;
-}
-
-Input *
-Input::unsmob (SCM s)
-{
- if (SCM_IMP (s))
- return 0;
- if (SCM_CAR (s) == (SCM)input_tag) // ugh.
- return (Input *) SCM_CDR (s);
- else
- return 0;
-}
-
-ADD_SCM_INIT_FUNC (input, start_input_smobs);
void
Lily_lexer::push_extra_token (Input const &where, int token_type, SCM scm)
{
- extra_tokens_ = scm_cons (scm_cons2 (make_input (where),
+ extra_tokens_ = scm_cons (scm_cons2 (where.smobbed_copy (),
scm_from_int (token_type),
scm), extra_tokens_);
}
void
Music::set_spot (Input ip)
{
- set_property ("origin", make_input (ip));
+ set_property ("origin", ip.smobbed_copy ());
}
Input *
scm_apply_0 (proc, args)
/* Syntactic Sugar. */
#define MAKE_SYNTAX(name, location, ...) \
- LOWLEVEL_MAKE_SYNTAX (ly_lily_module_constant (name), scm_list_n (parser->self_scm (), make_input (parser->lexer_->override_input (location)), ##__VA_ARGS__, SCM_UNDEFINED))
+ LOWLEVEL_MAKE_SYNTAX (ly_lily_module_constant (name), scm_list_n (parser->self_scm (), parser->lexer_->override_input (location).smobbed_copy (), ##__VA_ARGS__, SCM_UNDEFINED))
#define START_MAKE_SYNTAX(name, ...) \
scm_list_n (ly_lily_module_constant (name) , ##__VA_ARGS__, SCM_UNDEFINED)
#define FINISH_MAKE_SYNTAX(start, location, ...) \
- LOWLEVEL_MAKE_SYNTAX (scm_car (start), scm_cons2 (parser->self_scm (), make_input (parser->lexer_->override_input (location)), scm_append_x (scm_list_2 (scm_cdr (start), scm_list_n (__VA_ARGS__, SCM_UNDEFINED)))))
+ LOWLEVEL_MAKE_SYNTAX (scm_car (start), scm_cons2 (parser->self_scm (), parser->lexer_->override_input (location).smobbed_copy (), scm_append_x (scm_list_2 (scm_cdr (start), scm_list_n (__VA_ARGS__, SCM_UNDEFINED)))))
SCM get_next_unique_context_id ();
SCM get_next_unique_lyrics_context_id ();
if (SCM_UNBNDP ($1))
$$ = MAKE_SYNTAX ("void-music", @1);
else
- $$ = LOWLEVEL_MAKE_SYNTAX (ly_lily_module_constant ("property-operation"), scm_cons2 (parser->self_scm (), make_input (@$), $1));
+ $$ = LOWLEVEL_MAKE_SYNTAX (ly_lily_module_constant ("property-operation"), scm_cons2 (parser->self_scm (), @$.smobbed_copy (), $1));
}
;
error_found_ = false;
smobify_self ();
- input_location_ = make_input (Input ());
+ input_location_ = Input ().smobbed_copy ();
}
Score::~Score ()
error_found_ = s.error_found_;
smobify_self ();
- input_location_ = make_input (*s.origin ());
+ input_location_ = s.origin ()->smobbed_copy ();
Music *m = Music::unsmob (s.music_);
if (m)
void
Stream_event::set_spot (Input *i)
{
- set_property ("origin", make_input (*i));
+ set_property ("origin", i->smobbed_copy ());
}
bool