Ejemplo n.º 1
0
bool Script::ResultIsElementCollection() {
  if (this->result_.vt == VT_DISPATCH) {
    CComQIPtr<IHTMLElementCollection> is_collection(this->result_.pdispVal);
    if (is_collection) {
      return true;
    }
  }
  return false;
}
Ejemplo n.º 2
0
SharedRefPtr<ParseResult> DataTypeClassNameParser::parse_with_composite(const std::string& type, const NativeDataTypes& native_types) {
  Parser parser(type, 0);

  std::string next;
  parser.get_next_name(&next);

  if (!is_composite(next)) {
    DataType::ConstPtr data_type = parse_one(type, native_types);
    if (!data_type) {
      return SharedRefPtr<ParseResult>();
    }
    return SharedRefPtr<ParseResult>(new ParseResult(data_type, is_reversed(next)));
  }

  TypeParamsVec sub_class_names;

  if (!parser.get_type_params(&sub_class_names)) {
    return SharedRefPtr<ParseResult>();
  }

  if (sub_class_names.empty()) {
    LOG_ERROR("Expected at least one subclass type for a composite type");
    return SharedRefPtr<ParseResult>();
  }

  ParseResult::CollectionMap collections;
  const std::string& last = sub_class_names.back();
  size_t count = sub_class_names.size();
  if (is_collection(last)) {
    count--;

    Parser collection_parser(last, 0);
    collection_parser.get_next_name();
    NameAndTypeParamsVec params;
    if (!collection_parser.get_collection_params(&params)) {
      return SharedRefPtr<ParseResult>();
    }

    for (NameAndTypeParamsVec::const_iterator i = params.begin(),
         end = params.end(); i != end; ++i) {
      DataType::ConstPtr data_type = parse_one(i->second, native_types);
      if (!data_type) {
        return SharedRefPtr<ParseResult>();
      }
      collections[i->first] = data_type;
    }
  }

  DataType::Vec types;
  ParseResult::ReversedVec reversed;
  for (size_t i = 0; i < count; ++i) {
    DataType::ConstPtr data_type = parse_one(sub_class_names[i], native_types);
    if (!data_type) {
      return SharedRefPtr<ParseResult>();
    }
    types.push_back(data_type);
    reversed.push_back(is_reversed(sub_class_names[i]));
  }

  return SharedRefPtr<ParseResult>(new ParseResult(true, types, reversed, collections));
}