Exemplo n.º 1
0
void ContributionRoot::RegisterVisibilityForChild(const SmartPointer<IContributionItem>& item,
                                const SmartPointer<Expression>& visibleWhen)
{
  if (item.IsNull())
    throw std::invalid_argument("item must not be null");

  Expression::Pointer visibleWhenTmp = visibleWhen;
  if (visibleWhenTmp.IsNull())
    visibleWhenTmp = AlwaysEnabledExpression::INSTANCE;

  menuService->RegisterVisibleWhen(item, visibleWhenTmp, restriction,
                                   CreateIdentifierId(item));
  itemsToExpressions.append(item);
}
Exemplo n.º 2
0
  IIterable::Pointer
  Expressions::GetAsIIterable(Object::Pointer var, Expression::Pointer expression)
  {
    IIterable::Pointer iterable(var.Cast<IIterable>());
    if (!iterable.IsNull())
    {
      return iterable;
    }
    else
    {
      IAdapterManager::Pointer manager= Platform::GetServiceRegistry().GetServiceById<IAdapterManager>("org.blueberry.service.adaptermanager");
      Object::Pointer result;
      Poco::Any any(manager->GetAdapter(var, IIterable::GetStaticClassName()));
      if (!any.empty() && any.type() == typeid(Object::Pointer))
      {
        result = Poco::AnyCast<Object::Pointer>(any);
      }

      if (result)
      {
        iterable = result.Cast<IIterable>();
        return iterable;
      }

      if (manager->QueryAdapter(var->GetClassName(), IIterable::GetStaticClassName()) == IAdapterManager::NOT_LOADED)
        return IIterable::Pointer();

      throw CoreException("The variable is not iterable", expression->ToString());
    }
  }
Exemplo n.º 3
0
 void
 Expressions::CheckCollection(Object::ConstPointer var, Expression::Pointer expression)
 {
   if (var.Cast<const ObjectVector<Object::Pointer> >())
     return;
   throw CoreException("Expression variable is not of type ObjectVector", expression->ToString());
 }
MultiplicationExpression::MultiplicationExpression(const Expression::Pointer&
	operand1, MultiplicationType::Types multiplication_type, const Expression::
	Pointer& operand2)
:
	Expression(ValueType::NUMBER),
	operand1(operand1),
	multiplication_type(multiplication_type),
	operand2(operand2)
{
	if (operand1->getType() != operand2->getType() || operand1->getType() !=
		ValueType::NUMBER)
	{
		throw IllegalMultiplicationOperationException(multiplication_type,
			operand1->getType(), operand2->getType());
	}

	this->operand1 = Expression::Pointer(new ParenthesesExpression(operand1));
	this->operand2 = Expression::Pointer(new ParenthesesExpression(operand2));
}
Exemplo n.º 5
0
SmartPointer<IHandlerActivation> SlaveHandlerService::ActivateHandler(const SmartPointer<IHandlerActivation>& childActivation)
{
  const QString commandId = childActivation->GetCommandId();
  const IHandler::Pointer handler = childActivation->GetHandler();
  const Expression::Pointer childExpression = childActivation->GetExpression();
  Expression::Pointer expression = defaultExpression;
  if (childExpression.IsNotNull() && defaultExpression.IsNotNull())
  {
    const AndExpression::Pointer andExpression(new AndExpression());
    andExpression->Add(childExpression);
    andExpression->Add(defaultExpression);
    expression = andExpression;
  }
  else if (childExpression.IsNotNull())
  {
    expression = childExpression;
  }
  const int depth = childActivation->GetDepth() + 1;
  const IHandlerActivation::Pointer localActivation(
        new HandlerActivation(commandId, handler, expression, depth, this));

  return DoActivation(localActivation);
}
ArrayAccessExpression::ArrayAccessExpression(const Variable::Pointer& variable,
	const Expression::Pointer& index_expression)
:
	Expression(ValueType::NUMBER),
	variable(variable),
	index_expression(index_expression)
{
	ValueType::Types variable_type = ValueType::UNKNOWN_TYPE;
	if (typeid(*variable) == typeid(NumberVariable)) {
		variable_type = ValueType::NUMBER;
	} else if (typeid(*variable) == typeid(ArrayVariable) || typeid(*variable)
		== typeid(StringVariable))
	{
		variable_type = ValueType::ARRAY;
	}

	if (variable_type != ValueType::ARRAY || index_expression->getType() !=
		ValueType::NUMBER)
	{
		throw IllegalArrayAccessOperationException(variable_type,
			index_expression->getType());
	}
}
Exemplo n.º 7
0
std::size_t
Expression::HashCode(Expression::Pointer object)
{
  return object != 0 ? object->HashCode() : 0;
}
Exemplo n.º 8
0
NotExpression::NotExpression(Expression::Pointer expression)
{
  poco_assert(expression.IsNotNull());

  fExpression= expression;
}