|
Proto : |
Subject: Re: [proto] Using Phoenix inside eUML: mixing grammars
From: Christophe Henry (christophe.j.henry_at_[hidden])
Date: 2011-05-02 17:35:13
>> Anyway, I am hoping not to write any cool transform but simply save
>> the type of the phoenix expression so that I can re-create an actor
>> later. If I need to rewrite differently what BuildGuards was doing, I
>> gain little. I would like phoenix to do the grammar parsing and
>> building of actor.
>
> It does ... just pass on proto::_right and it should be good:
>
> struct BuildEventPlusGuard
> : proto::when<
> proto::subscript<
> proto::terminal<event_tag>
> , phoenix::meta_grammar // match the phoenix actor
> >
> , TempRow<
> none
> , proto::_left
> , none
> , none
> , proto::_right // Pass the type along. which is a phoenix actor.
> >(proto::_right) // Pass the object along. Which is the actor (1)
> >
> {};
Great! This is what I unsuccessfully tried (I was missing the second
proto::_right, my bad).
> (1): Here you can work around the thing with the possibly uninitialized stuff.
> Just copy the phoenix actor (should be cheap, if not optimized away completely).
Oh the copy is really not a problem, the transition table is purely a
compile-time construct, there is no call at run-time.
So, for Michael who must be impatient to see some progress, so far this works:
struct some_guard_impl
{
typedef bool result_type;
bool operator()()
{
cout << "calling: some_guard" << endl;
return true;
}
};
boost::phoenix::function<some_guard_impl> some_guard;
struct some_action_impl
{
typedef void result_type;
void operator()()
{
cout << "calling: some_action" << endl;
}
};
boost::phoenix::function<some_action_impl> some_action;
BOOST_MSM_EUML_TRANSITION_TABLE((
Open == Empty + open_close
[some_guard()&&some_guard()] / (some_action(),some_action())
// these standard constructs are also ok
//Open == Empty + open_close / some_action()
//Empty + open_close [some_guard()] / some_action()
//Open == Empty / some_action()
// +------------------------------------------------------------------------------+
),transition_table)
So far it's looking pretty good. I still have stuff to think about but
I like the direction this takes.
Thanks,
Christophe
Proto list run by eric at boostpro.com