| OLD | NEW | 
|    1 /* |    1 /* | 
|    2  * This file is part of Adblock Plus <https://adblockplus.org/>, |    2  * This file is part of Adblock Plus <https://adblockplus.org/>, | 
|    3  * Copyright (C) 2006-2017 eyeo GmbH |    3  * Copyright (C) 2006-2017 eyeo GmbH | 
|    4  * |    4  * | 
|    5  * Adblock Plus is free software: you can redistribute it and/or modify |    5  * Adblock Plus is free software: you can redistribute it and/or modify | 
|    6  * it under the terms of the GNU General Public License version 3 as |    6  * it under the terms of the GNU General Public License version 3 as | 
|    7  * published by the Free Software Foundation. |    7  * published by the Free Software Foundation. | 
|    8  * |    8  * | 
|    9  * Adblock Plus is distributed in the hope that it will be useful, |    9  * Adblock Plus is distributed in the hope that it will be useful, | 
|   10  * but WITHOUT ANY WARRANTY; without even the implied warranty of |   10  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  442  |  442  | 
|  443       result += "  }\n"; |  443       result += "  }\n"; | 
|  444       return result; |  444       return result; | 
|  445     } |  445     } | 
|  446     else |  446     else | 
|  447       throw std::runtime_error("Unexpected return type for " + std::string(call.
     name)); |  447       throw std::runtime_error("Unexpected return type for " + std::string(call.
     name)); | 
|  448   } |  448   } | 
|  449  |  449  | 
|  450   const std::string wrapCall(const FunctionInfo& call) |  450   const std::string wrapCall(const FunctionInfo& call) | 
|  451   { |  451   { | 
|  452     char buffer[20]; |  | 
|  453     bool hasStringArgs = false; |  452     bool hasStringArgs = false; | 
|  454     std::vector<std::string> params; |  453     std::vector<std::string> params; | 
|  455     std::string prefix = "function("; |  454     std::string prefix = "function("; | 
|  456     for (int i = 0; i < call.args.size(); i++) |  455     for (int i = 0; i < call.args.size(); i++) | 
|  457     { |  456     { | 
|  458       sprintf(buffer, "arg%i", i); |  457       std::string argName("arg" + std::to_string(i)); | 
|  459       if (i > 0) |  458       if (i > 0) | 
|  460         prefix += ", "; |  459         prefix += ", "; | 
|  461       prefix += buffer; |  460       prefix += argName; | 
|  462  |  461  | 
|  463       if (call.args[i] == TypeCategory::STRING_REF) |  462       if (call.args[i] == TypeCategory::STRING_REF) | 
|  464       { |  463       { | 
|  465         hasStringArgs = true; |  464         hasStringArgs = true; | 
|  466         params.push_back(std::string("createString(") + buffer + ")"); |  465         params.push_back(std::string("createString(") + argName + ")"); | 
|  467       } |  466       } | 
|  468       else |  467       else | 
|  469         params.push_back(buffer); |  468         params.push_back(argName); | 
|  470     } |  469     } | 
|  471     prefix += ")\n{\n"; |  470     prefix += ")\n{\n"; | 
|  472  |  471  | 
|  473     std::string suffix = "}"; |  472     std::string suffix = "}"; | 
|  474     if (call.returnType != TypeCategory::VOID) |  473     if (call.returnType != TypeCategory::VOID) | 
|  475       suffix = "  return result;\n" + suffix; |  474       suffix = "  return result;\n" + suffix; | 
|  476  |  475  | 
|  477     if (call.returnType == TypeCategory::DEPENDENT_STRING || |  476     if (call.returnType == TypeCategory::DEPENDENT_STRING || | 
|  478         call.returnType == TypeCategory::OWNED_STRING || hasStringArgs) |  477         call.returnType == TypeCategory::OWNED_STRING || hasStringArgs) | 
|  479     { |  478     { | 
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  736  |  735  | 
|  737     std::vector<std::pair<int, std::string>> mapping; |  736     std::vector<std::pair<int, std::string>> mapping; | 
|  738     for (const auto& item : list) |  737     for (const auto& item : list) | 
|  739       mapping.emplace_back(item.first, item.second); |  738       mapping.emplace_back(item.first, item.second); | 
|  740  |  739  | 
|  741     bindings_internal::register_differentiator( |  740     bindings_internal::register_differentiator( | 
|  742         bindings_internal::TypeInfo<ClassType>(), offset, mapping); |  741         bindings_internal::TypeInfo<ClassType>(), offset, mapping); | 
|  743     return *this; |  742     return *this; | 
|  744   } |  743   } | 
|  745 }; |  744 }; | 
| OLD | NEW |