shadowm

Untitled

Mar 22nd, 2011
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.50 KB | None | 0 0
  1. else if ((macro = target_.defines_->find(symbol)) != target_.defines_->end())
  2.             {
  3.                 preproc_define const &val = macro->second;
  4.                 size_t nb_arg = strings_.size() - token.stack_pos - 1;
  5.                 if (nb_arg != val.arguments.size())
  6.                 {
  7.                     std::ostringstream error;
  8.                     error << "preprocessor symbol '" << symbol << "' expects "
  9.                           << val.arguments.size() << " arguments, but has "
  10.                           << nb_arg << " arguments";
  11.                     target_.error(error.str(), linenum_);
  12.                 }
  13.                 std::istringstream *buffer = new std::istringstream(val.value);
  14.                 std::map<std::string, std::string> *defines =
  15.                     new std::map<std::string, std::string>;
  16.                 for (size_t i = 0; i < nb_arg; ++i) {
  17.                     (*defines)[val.arguments[i]] = strings_[token.stack_pos + i + 1];
  18.                 }
  19.                 pop_token();
  20.                 std::string const &dir = directory_name(val.location.substr(0, val.location.find(' ')));
  21.                 if (!slowpath_) {
  22.                     DBG_CF << "substituting macro " << symbol << '\n';
  23.                     new preprocessor_data(target_, buffer, val.location, "",
  24.                                           val.linenum, dir, val.textdomain, defines);
  25.                 } else {
  26.                     DBG_CF << "substituting (slow) macro " << symbol << '\n';
  27.                     std::ostringstream res;
  28.                     preprocessor_streambuf *buf =
  29.                         new preprocessor_streambuf(target_);
  30.                     {   std::istream in(buf);
  31.                         new preprocessor_data(*buf, buffer, val.location, "",
  32.                                               val.linenum, dir, val.textdomain, defines);
  33.                         res << in.rdbuf(); }
  34.                     delete buf;
  35.                     put(res.str());
  36.                 }
  37.             }
Advertisement
Add Comment
Please, Sign In to add comment