| Left: | ||
| Right: | 
| 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 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 496 function createString(str) | 496 function createString(str) | 
| 497 { | 497 { | 
| 498 var length = 0; | 498 var length = 0; | 
| 499 var buffer = 0; | 499 var buffer = 0; | 
| 500 if (str) | 500 if (str) | 
| 501 { | 501 { | 
| 502 buffer = Runtime.stackAlloc(str.length * 2); | 502 buffer = Runtime.stackAlloc(str.length * 2); | 
| 503 length = copyString(str, buffer); | 503 length = copyString(str, buffer); | 
| 504 } | 504 } | 
| 505 | 505 | 
| 506 var result = Module.Runtime.stackAlloc(sizeofString); | 506 var result = Runtime.stackAlloc(sizeofString); | 
| 
 
Wladimir Palant
2017/03/15 11:02:48
We don't need to call this via Module, and above w
 
 | |
| 507 Module._InitString(result, buffer, length); | 507 Module._InitString(result, buffer, length); | 
| 508 return result; | 508 return result; | 
| 509 } | 509 } | 
| 510 | 510 | 
| 511 function readString(str) | 511 function readString(str) | 
| 512 { | 512 { | 
| 513 var length = Module._GetStringLength(str); | 513 var length = Module._GetStringLength(str); | 
| 514 var pointer = Module._GetStringData(str) >> 1; | 514 var pointer = Module._GetStringData(str) >> 1; | 
| 515 return String.fromCharCode.apply(String, HEAP16.slice(pointer, pointer + len gth)); | 515 return String.fromCharCode.apply(String, HEAP16.slice(pointer, pointer + len gth)); | 
| 516 } | 516 } | 
| 517 | 517 | 
| 518 function createClass(superclass, ref_counted_offset) | 518 function createClass(superclass, ref_counted_offset) | 
| 519 { | 519 { | 
| 520 var result = function(pointer) | 520 var result = function(pointer) | 
| 521 { | 521 { | 
| 522 this._pointer = pointer; | 522 this._pointer = pointer; | 
| 523 }; | 523 }; | 
| 524 if (superclass) | 524 if (superclass) | 
| 525 result.prototype = Object.create(superclass.prototype); | 525 result.prototype = Object.create(superclass.prototype); | 
| 526 result.prototype.delete = function() | 526 result.prototype.delete = function() | 
| 527 { | 527 { | 
| 528 Module._ReleaseRef(this._pointer + ref_counted_offset); | 528 Module._ReleaseRef(this._pointer + ref_counted_offset); | 
| 529 }; | 529 }; | 
| 530 return result; | 530 return result; | 
| 531 })"); | 531 } | 
| 532 )"); | |
| 
 
Wladimir Palant
2017/03/15 11:02:48
Surprisingly, this is the only change that was rea
 
sergei
2017/03/20 17:41:49
Should spaces at the beginning of `    )");` be re
 
sergei
2017/03/20 17:41:49
Actually the whole last line is removed. I think i
 
Wladimir Palant
2017/03/21 10:18:59
Luckily, we don't care about the resulting code be
 
 | |
| 532 } | 533 } | 
| 533 | 534 | 
| 534 void printClass(const ClassInfo& cls) | 535 void printClass(const ClassInfo& cls) | 
| 535 { | 536 { | 
| 536 DifferentiatorInfo differentiator = cls.subclass_differentiator; | 537 DifferentiatorInfo differentiator = cls.subclass_differentiator; | 
| 537 if (differentiator.offset != SIZE_MAX) | 538 if (differentiator.offset != SIZE_MAX) | 
| 538 { | 539 { | 
| 539 printf("var %s_mapping = \n", cls.name.c_str()); | 540 printf("var %s_mapping = \n", cls.name.c_str()); | 
| 540 puts("{"); | 541 puts("{"); | 
| 541 for (const auto& item : differentiator.mapping) | 542 for (const auto& item : differentiator.mapping) | 
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 717 | 718 | 
| 718 std::vector<std::pair<int, std::string>> mapping; | 719 std::vector<std::pair<int, std::string>> mapping; | 
| 719 for (const auto& item : list) | 720 for (const auto& item : list) | 
| 720 mapping.emplace_back(item.first, item.second); | 721 mapping.emplace_back(item.first, item.second); | 
| 721 | 722 | 
| 722 bindings_internal::register_differentiator( | 723 bindings_internal::register_differentiator( | 
| 723 bindings_internal::TypeInfo<ClassType>(), offset, mapping); | 724 bindings_internal::TypeInfo<ClassType>(), offset, mapping); | 
| 724 return *this; | 725 return *this; | 
| 725 } | 726 } | 
| 726 }; | 727 }; | 
| OLD | NEW |