Left: | ||
Right: |
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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
250 case TypeCategory::CLASS_REF: | 250 case TypeCategory::CLASS_REF: |
251 { | 251 { |
252 std::string result; | 252 std::string result; |
253 result += " var result = " + call_str + ";\n"; | 253 result += " var result = " + call_str + ";\n"; |
254 result += " if (result)\n"; | 254 result += " if (result)\n"; |
255 | 255 |
256 const ClassInfo* cls = find_class(call.pointerType); | 256 const ClassInfo* cls = find_class(call.pointerType); |
257 if (!cls) | 257 if (!cls) |
258 throw std::runtime_error("Function " + call.name + " returns pointer t o unknown class"); | 258 throw std::runtime_error("Function " + call.name + " returns pointer t o unknown class"); |
259 | 259 |
260 auto offset = cls->subclass_differentiator.offset; | 260 result += " result = exports." + cls->name + ".fromPointer(result);\n "; |
sergei
2017/09/13 17:09:10
Another option here could be to keep the if and fo
Wladimir Palant
2017/09/19 08:51:48
Trouble is, bindings overhead is very much non-neg
sergei
2017/09/19 09:14:35
I have uploaded the version without fromPointer fo
| |
261 if (offset == SIZE_MAX) | |
262 result += " result = exports." + cls->name + "(result);\n"; | |
263 else | |
264 result += " result = exports." + cls->name + ".fromPointer(result); \n"; | |
265 | 261 |
266 result += " else\n"; | 262 result += " else\n"; |
267 result += " result = null;\n"; | 263 result += " result = null;\n"; |
268 return result; | 264 return result; |
269 } | 265 } |
270 default: | 266 default: |
271 throw std::runtime_error("Unexpected return type for " + call.name); | 267 throw std::runtime_error("Unexpected return type for " + call.name); |
272 } | 268 } |
273 } | 269 } |
274 | 270 |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
483 | 479 |
484 void printBindings() | 480 void printBindings() |
485 { | 481 { |
486 bindings_internal::printHelpers(); | 482 bindings_internal::printHelpers(); |
487 | 483 |
488 for (const auto& cls : classes) | 484 for (const auto& cls : classes) |
489 bindings_internal::printClass(cls); | 485 bindings_internal::printClass(cls); |
490 for (const auto& cls : classes) | 486 for (const auto& cls : classes) |
491 bindings_internal::printClassMapping(cls); | 487 bindings_internal::printClassMapping(cls); |
492 } | 488 } |
OLD | NEW |