| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8c8c97d commit b4c75a9
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2452,8 +2452,16 @@ napi_status NAPI_CDECL napi_check_object_type_tag(napi_env env, | |||
| 2452 | 2452 | napi_type_tag tag; | |
| 2453 | 2453 | val.As<v8::BigInt>()->ToWordsArray( | |
| 2454 | 2454 | &sign, &size, reinterpret_cast<uint64_t*>(&tag)); | |
| 2455 | - if (size == 2 && sign == 0) | ||
| 2456 | - *result = (tag.lower == type_tag->lower && tag.upper == type_tag->upper); | ||
| 2455 | + if (sign == 0) { | ||
| 2456 | + if (size == 2) { | ||
| 2457 | + *result = | ||
| 2458 | + (tag.lower == type_tag->lower && tag.upper == type_tag->upper); | ||
| 2459 | + } else if (size == 1) { | ||
| 2460 | + *result = (tag.lower == type_tag->lower && 0 == type_tag->upper); | ||
| 2461 | + } else if (size == 0) { | ||
| 2462 | + *result = (0 == type_tag->lower && 0 == type_tag->upper); | ||
| 2463 | + } | ||
| 2464 | + } | ||
| 2457 | 2465 | } | |
| 2458 | 2466 | ||
| 2459 | 2467 | return GET_RETURN_STATUS(env); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -163,14 +163,23 @@ assert.strictEqual(newObject.test_string, 'test string'); | |||
| 163 | 163 | // Verify that objects can be type-tagged and type-tag-checked. | |
| 164 | 164 | const obj1 = test_object.TypeTaggedInstance(0); | |
| 165 | 165 | const obj2 = test_object.TypeTaggedInstance(1); | |
| 166 | + const obj3 = test_object.TypeTaggedInstance(2); | ||
| 167 | + const obj4 = test_object.TypeTaggedInstance(3); | ||
| 166 | 168 | ||
| 167 | 169 | // Verify that type tags are correctly accepted. | |
| 168 | 170 | assert.strictEqual(test_object.CheckTypeTag(0, obj1), true); | |
| 169 | 171 | assert.strictEqual(test_object.CheckTypeTag(1, obj2), true); | |
| 172 | + assert.strictEqual(test_object.CheckTypeTag(2, obj3), true); | ||
| 173 | + assert.strictEqual(test_object.CheckTypeTag(3, obj4), true); | ||
| 170 | 174 | ||
| 171 | 175 | // Verify that wrongly tagged objects are rejected. | |
| 172 | 176 | assert.strictEqual(test_object.CheckTypeTag(0, obj2), false); | |
| 173 | 177 | assert.strictEqual(test_object.CheckTypeTag(1, obj1), false); | |
| 178 | + assert.strictEqual(test_object.CheckTypeTag(0, obj3), false); | ||
| 179 | + assert.strictEqual(test_object.CheckTypeTag(1, obj4), false); | ||
| 180 | + assert.strictEqual(test_object.CheckTypeTag(2, obj4), false); | ||
| 181 | + assert.strictEqual(test_object.CheckTypeTag(3, obj3), false); | ||
| 182 | + assert.strictEqual(test_object.CheckTypeTag(4, obj3), false); | ||
| 174 | 183 | ||
| 175 | 184 | // Verify that untagged objects are rejected. | |
| 176 | 185 | assert.strictEqual(test_object.CheckTypeTag(0, {}), false); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -605,9 +605,12 @@ static napi_value TestSeal(napi_env env, | |||
| 605 | 605 | } | |
| 606 | 606 | ||
| 607 | 607 | // We create two type tags. They are basically 128-bit UUIDs. | |
| 608 | - static const napi_type_tag type_tags[2] = { | ||
| 608 | + static const napi_type_tag type_tags[5] = { | ||
| 609 | 609 | { 0xdaf987b3cc62481a, 0xb745b0497f299531 }, | |
| 610 | - { 0xbb7936c374084d9b, 0xa9548d0762eeedb9 } | ||
| 610 | + { 0xbb7936c374084d9b, 0xa9548d0762eeedb9 }, | ||
| 611 | + { 0xa5ed9ce2e4c00c38, 0 }, | ||
| 612 | + { 0, 0 }, | ||
| 613 | + { 0xa5ed9ce2e4c00c38, 0xdaf987b3cc62481a }, | ||
| 611 | 614 | }; | |
| 612 | 615 | ||
| 613 | 616 | static napi_value | |
| Back | FazBrowse Home | New Git URL |
0 commit comments