OLD | NEW |
1 #pragma once | 1 #pragma once |
2 | 2 |
3 #include <cstdint> | 3 #include <cstdint> |
4 #include <cstdio> | 4 #include <cstdio> |
5 #include <cstdlib> | 5 #include <cstdlib> |
6 #include <exception> | 6 #include <exception> |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <type_traits> | 9 #include <type_traits> |
10 #include <utility> | 10 #include <utility> |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 else | 434 else |
435 { | 435 { |
436 result += " var type = HEAP32[result + " + std::to_string(offset)+ "
>> 2];\n"; | 436 result += " var type = HEAP32[result + " + std::to_string(offset)+ "
>> 2];\n"; |
437 result += " if (type in " + cls.name + "_mapping)\n"; | 437 result += " if (type in " + cls.name + "_mapping)\n"; |
438 result += " result = new (exports[" + cls.name + "_mapping[type]])(
result);\n"; | 438 result += " result = new (exports[" + cls.name + "_mapping[type]])(
result);\n"; |
439 result += " else\n"; | 439 result += " else\n"; |
440 result += " throw new Error('Unexpected " + cls.name + " type: ' +
type);\n"; | 440 result += " throw new Error('Unexpected " + cls.name + " type: ' +
type);\n"; |
441 } | 441 } |
442 | 442 |
443 result += " }\n"; | 443 result += " }\n"; |
| 444 result += " else\n"; |
| 445 result += " result = null;\n"; |
444 return result; | 446 return result; |
445 } | 447 } |
446 else | 448 else |
447 throw std::runtime_error("Unexpected return type for " + std::string(call.
name)); | 449 throw std::runtime_error("Unexpected return type for " + std::string(call.
name)); |
448 } | 450 } |
449 | 451 |
450 const std::string wrapCall(const FunctionInfo& call) | 452 const std::string wrapCall(const FunctionInfo& call) |
451 { | 453 { |
452 char buffer[20]; | 454 char buffer[20]; |
453 bool hasStringArgs = false; | 455 bool hasStringArgs = false; |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 | 740 |
739 std::vector<std::pair<int, std::string>> mapping; | 741 std::vector<std::pair<int, std::string>> mapping; |
740 for (const auto& item : list) | 742 for (const auto& item : list) |
741 mapping.emplace_back(item.first, item.second); | 743 mapping.emplace_back(item.first, item.second); |
742 | 744 |
743 bindings_internal::register_differentiator( | 745 bindings_internal::register_differentiator( |
744 bindings_internal::TypeInfo<ClassType>(), offset, mapping); | 746 bindings_internal::TypeInfo<ClassType>(), offset, mapping); |
745 return *this; | 747 return *this; |
746 } | 748 } |
747 }; | 749 }; |
OLD | NEW |