| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ea98122 commit e4450a1
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,18 +2,20 @@ | |||
| 2 | 2 | #include <node.h> | |
| 3 | 3 | #include <assert.h> | |
| 4 | 4 | ||
| 5 | - using v8::Isolate; | ||
| 5 | + using v8::Array; | ||
| 6 | + using v8::ArrayBuffer; | ||
| 7 | + using v8::ArrayBufferView; | ||
| 8 | + using v8::BackingStore; | ||
| 6 | 9 | using v8::Context; | |
| 10 | + using v8::FunctionCallbackInfo; | ||
| 11 | + using v8::Isolate; | ||
| 7 | 12 | using v8::Local; | |
| 8 | 13 | using v8::MaybeLocal; | |
| 9 | - using v8::Value; | ||
| 10 | 14 | using v8::Number; | |
| 11 | - using v8::String; | ||
| 12 | 15 | using v8::Object; | |
| 13 | - using v8::Array; | ||
| 14 | - using v8::ArrayBufferView; | ||
| 15 | - using v8::ArrayBuffer; | ||
| 16 | - using v8::FunctionCallbackInfo; | ||
| 16 | + using v8::String; | ||
| 17 | + using v8::Uint32; | ||
| 18 | + using v8::Value; | ||
| 17 | 19 | ||
| 18 | 20 | void CallWithString(const FunctionCallbackInfo<Value>& args) { | |
| 19 | 21 | assert(args.Length() == 1 && args[0]->IsString()); | |
@@ -22,7 +24,7 @@ void CallWithString(const FunctionCallbackInfo<Value>& args) { | |||
| 22 | 24 | const int32_t length = str->Utf8Length(args.GetIsolate()) + 1; | |
| 23 | 25 | char* buf = new char[length]; | |
| 24 | 26 | str->WriteUtf8(args.GetIsolate(), buf, length); | |
| 25 | - delete [] buf; | ||
| 27 | + delete[] buf; | ||
| 26 | 28 | } | |
| 27 | 29 | } | |
| 28 | 30 | ||
@@ -31,7 +33,7 @@ void CallWithArray(const FunctionCallbackInfo<Value>& args) { | |||
| 31 | 33 | if (args.Length() == 1 && args[0]->IsArray()) { | |
| 32 | 34 | const Local<Array> array = args[0].As<Array>(); | |
| 33 | 35 | uint32_t length = array->Length(); | |
| 34 | - for (uint32_t i = 0; i < length; ++ i) { | ||
| 36 | + for (uint32_t i = 0; i < length; i++) { | ||
| 35 | 37 | Local<Value> v; | |
| 36 | 38 | v = array->Get(args.GetIsolate()->GetCurrentContext(), | |
| 37 | 39 | i).ToLocalChecked(); | |
@@ -101,24 +103,22 @@ void CallWithTypedarray(const FunctionCallbackInfo<Value>& args) { | |||
| 101 | 103 | const size_t byte_length = view->ByteLength(); | |
| 102 | 104 | assert(byte_length > 0); | |
| 103 | 105 | assert(view->HasBuffer()); | |
| 104 | - Local<ArrayBuffer> buffer; | ||
| 105 | - buffer = view->Buffer(); | ||
| 106 | - ArrayBuffer::Contents contents; | ||
| 107 | - contents = buffer->GetContents(); | ||
| 106 | + Local<ArrayBuffer> buffer = view->Buffer(); | ||
| 107 | + std::shared_ptr<BackingStore> bs = buffer->GetBackingStore(); | ||
| 108 | 108 | const uint32_t* data = reinterpret_cast<uint32_t*>( | |
| 109 | - static_cast<uint8_t*>(contents.Data()) + byte_offset); | ||
| 109 | + static_cast<uint8_t*>(bs->Data()) + byte_offset); | ||
| 110 | 110 | assert(data); | |
| 111 | 111 | } | |
| 112 | 112 | } | |
| 113 | 113 | ||
| 114 | 114 | void CallWithArguments(const FunctionCallbackInfo<Value>& args) { | |
| 115 | 115 | assert(args.Length() > 1 && args[0]->IsNumber()); | |
| 116 | 116 | if (args.Length() > 1 && args[0]->IsNumber()) { | |
| 117 | - int32_t loop = args[0].As<v8::Uint32>()->Value(); | ||
| 117 | + int32_t loop = args[0].As<Uint32>()->Value(); | ||
| 118 | 118 | for (int32_t i = 1; i < loop; ++i) { | |
| 119 | 119 | assert(i < args.Length()); | |
| 120 | 120 | assert(args[i]->IsUint32()); | |
| 121 | - args[i].As<v8::Uint32>()->Value(); | ||
| 121 | + args[i].As<Uint32>()->Value(); | ||
| 122 | 122 | } | |
| 123 | 123 | } | |
| 124 | 124 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments