41 #ifdef ORO_PRAGMA_INTERFACE 42 #pragma implementation 48 #include "../types/Operators.hpp" 50 #include "../internal/DataSourceCommand.hpp" 52 #include "../internal/GlobalService.hpp" 56 #include "../TaskContext.hpp" 58 #include "../types/Types.hpp" 61 #include <boost/lambda/lambda.hpp> 63 #include <boost/bind.hpp> 64 #include <boost/ref.hpp> 65 #include "rtt-scripting-config.h" 73 using namespace detail;
77 boost::spirit::classic::assertion<std::string> expect_open(
"Open brace expected.");
78 boost::spirit::classic::assertion<std::string> expect_close(
"Closing brace expected ( or could not find out what this line means ).");
79 boost::spirit::classic::assertion<std::string> expect_type(
"Unknown type. Please specify a type.");
80 boost::spirit::classic::assertion<std::string> expect_expr(
"Expected a valid expression.");
81 boost::spirit::classic::assertion<std::string> expect_ident(
"Expected a valid identifier.");
82 boost::spirit::classic::assertion<std::string> expect_init(
"Expected an initialisation value of the value.");
83 boost::spirit::classic::assertion<std::string> expect_comma(
"Expected the ',' separator after expression.");
84 boost::spirit::classic::assertion<std::string> expect_timespec(
"Expected a time specification (e.g. > 10s or > varname ) after 'time' .");
86 guard<std::string> my_guard;
92 : ret(), mhandle(), mcmdcnd(0), mobject(), mmethod(),
93 mcaller( caller ? caller : c->engine()), mcalltype(DEFAULT_CALLTYPE), commonparser(cp), expressionparser( p ),
94 peerparser( c, cp, false )
99 BOOST_SPIRIT_DEBUG_RULE(
object );
100 BOOST_SPIRIT_DEBUG_RULE(
method );
120 std::string name( begin, end );
121 mobject = name.substr(0, name.length() - 1);
126 std::string name( begin, end );
127 if ( name ==
"send" ) {
131 }
else if (name ==
"cmd" ) {
135 }
else if (name ==
"call" ) {
162 if ( ops == 0 || (
mobject !=
"this" && ops->getName() !=
mobject ) ) {
166 if ( ops->hasMember(
mmethod) == false ) {
174 ops = ops->provides(
"scripting");
212 std::vector<DataSourceBase::shared_ptr> args = argspar->
result();
215 assert(peer &&
"peer may never be null.");
227 if ( (meth ==
"collect" || meth ==
"collectIfDone") && !ops->hasMember(
mmethod) ) {
228 if ( ops->hasAttribute(obj) ) {
233 if (meth ==
"collect")
243 unsigned int arity = ops->getCollectArity(meth);
251 ret = ops->produceSend( meth, args,
mcaller );
257 args.push_back( sendds );
258 for (
unsigned int i =0; i != arity; ++i) {
259 args.push_back( ops->getOperation(meth)->getCollectType( i + 1 )->buildValue() );
283 catch(
const std::exception& e)
328 std::string name( begin, end );
331 throw_(
iter_t(),
"\"" + name +
"\" is an unknown type...");
351 std::vector<DataSourceBase::shared_ptr> args = argspar->
result();
363 static void abort_rule(
const string& reason) {
367 static error_status<> fail_rule(
scanner_t const& scan, parser_error<std::string, iter_t>&e )
369 return error_status<>( error_status<>::fail );
375 datacallparser( *this, cp, pc, caller ),
376 constrparser(*this, cp),
378 valueparser( pc, cp ),
388 BOOST_SPIRIT_DEBUG_RULE(
modexp );
394 BOOST_SPIRIT_DEBUG_RULE(
equalexp );
396 BOOST_SPIRIT_DEBUG_RULE(
orexp );
397 BOOST_SPIRIT_DEBUG_RULE(
andexp );
399 BOOST_SPIRIT_DEBUG_RULE(
groupexp );
400 BOOST_SPIRIT_DEBUG_RULE(
dotexp );
404 BOOST_SPIRIT_DEBUG_RULE(
indexexp );
405 BOOST_SPIRIT_DEBUG_RULE(
comma );
411 comma = expect_comma( ch_p(
',') );
568 case 'm': total =
tsecs / 1000.0;
570 case 'u': total =
tsecs / 1000000.0;
572 case 'n': total =
tsecs / 1000000000.0;
575 std::string arg(begin, end);
650 opreg->applyUnary( op, arg.get() );
653 "\" to " + arg->getType() +
"." );
659 std::string member(s,f);
680 opreg->applyBinary( op, arg2.get(), arg1.get() );
683 " "+arg1->getType() +
"." );
695 if (arg2->getTypeName() ==
"SendHandle" &&
mhandle) {
698 for( ConfigurationInterface::AttributeObjects::iterator it = attrs.begin(); it != attrs.end(); ++it) {
699 if ( (*it)->getDataSource() == arg2 ) {
701 string name = (*it)->getName();
724 act = arg2->updateAction( arg1.get() );
727 " "+arg1->getType() +
"." );
731 " "+arg1->getType() );
733 if (arg2->getTypeInfo()->getTypeName() !=
"unknown_t")
734 ret = arg2->getTypeInfo()->buildActionAlias(act, arg2);
753 +arg1->getType() +
" ]." );
bool setValue(base::AttributeBase *ab)
std::vector< base::DataSourceBase::shared_ptr > result()
ExpressionParser & expressionparser
base::DataSourceBase::shared_ptr ret
virtual result_t get() const =0
ExecutionEngine * mcaller
rule_t tidentifier
recursive template def.
CommonParser & commonparser
DataCallParser(ExpressionParser &p, CommonParser &cp, TaskContext *pc, ExecutionEngine *caller)
ConfigurationInterface * attributes()
ConditionInterface * mcmdcnd
std::stack< base::DataSourceBase::shared_ptr > parsestack
This interface represents the concept of a condition which can be evaluated and return true or false...
void seen_binary(const std::string &op)
void seenmethodname(iter_t begin, iter_t end)
boost::shared_ptr< SendHandleAlias > mhandle
boost::shared_ptr< SendHandleAlias > mhandle
bool skipeol
Saves eol skipping state.
void seen_constructor(void)
types::OperatorRepository::shared_ptr opreg
virtual DataSourceBase::shared_ptr getDataSource() const =0
base::DataSourceBase::shared_ptr getDataSource() const
ConditionInterface * getCmdResult()
base::DataSourceBase * getParseResult()
void removeAttribute(const std::string &name)
This class contains some very common parser definitions.
base::DataSourceBase::shared_ptr ret
boost::shared_ptr< Service > shared_ptr
DataCallParser datacallparser
void seen_type_name(iter_t begin, iter_t end)
void seen_dotmember(iter_t begin, iter_t end)
scanner< iter_t, scanner_pol_t > scanner_t
OperationInterfacePart * getFactory() const
boost::shared_ptr< base::AttributeBase > getHandle()
AttributeObjects const & getValues() const
rule_t type_name
See notassertingidentifier, but in lexeme parsing mode.
Based on the software pattern 'command', this interface allows execution of action objects...
base::DataSourceBase::shared_ptr getResult()
CommonParser & commonparser
ExpressionParser & expressionparser
void seen_unary(const std::string &op)
ConditionInterface * getParseCmdResult()
void seentimeunit(iter_t begin, iter_t end)
TypeInfoRepository::shared_ptr Types()
enum RTT::scripting::DataCallParser::CallType mcalltype
base::DataSourceBase * getParseResult()
virtual base::DataSourceBase::shared_ptr produceCollect(const std::vector< base::DataSourceBase::shared_ptr > &args, internal::DataSource< bool >::shared_ptr blocking) const =0
ExpressionParser(TaskContext *pc, ExecutionEngine *caller, CommonParser &common_parser)
ConditionInterface * mcmdcnd
static shared_ptr Instance()
std::stack< ArgumentsParser * > argparsers
std::stack< ArgumentsParser * > argparsers
std::vector< base::AttributeBase * > AttributeObjects
ConstructorParser(ExpressionParser &p, CommonParser &cp)
Service::shared_ptr object()
rule_t constructor_expression
boost::intrusive_ptr< DataSourceBase > shared_ptr
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
void seenobjectname(iter_t begin, iter_t end)
ConstructorParser constrparser
CommonParser & commonparser
const base::DataSourceBase::shared_ptr lastParsed() const
boost::shared_ptr< SendHandleAlias > getParseHandle()
static RTT_API Service::shared_ptr Instance()
virtual const std::string & getName() const
void setName(std::string const &new_name)