Skip to content

Commit

Permalink
Merge tag 'dev/16.0.0-dev.315' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
vadzz-dev committed Jun 13, 2024
2 parents 839e290 + 5785c51 commit e00b005
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 4 additions & 3 deletions client/src/bindings/V8Natives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ static void* ToMemoryBuffer(v8::Local<v8::Value> val, v8::Local<v8::Context> ctx
if(val->IsObject())
{
v8::Local<v8::Object> obj = val.As<v8::Object>();
auto cls = V8Helpers::GetObjectClass(obj);

if(obj->InternalFieldCount() == 2)
if(cls == V8Class::ObjectClass::MEMORY_BUFFER)
{
void* memory = obj->GetAlignedPointerFromInternalField(0);
uint32_t size = obj->GetInternalField(0)->Uint32Value(ctx).ToChecked();
void* memory = obj->GetAlignedPointerFromInternalField(1);
uint32_t size = obj->GetInternalField(2)->Uint32Value(ctx).ToChecked();

if(size > 0) return memory;
}
Expand Down
6 changes: 5 additions & 1 deletion shared/V8Helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,12 @@ V8Class::ObjectClass V8Helpers::GetObjectClass(v8::Local<v8::Object> obj)
{
if(obj->InternalFieldCount() <= static_cast<int>(V8Class::InternalFields::OBJECT_CLASS))
return V8Class::ObjectClass::NONE;

auto val = obj->GetInternalField(static_cast<int>(V8Class::InternalFields::OBJECT_CLASS));
if(!val->IsExternal())
return V8Class::ObjectClass::NONE;

void* cls = obj->GetInternalField(static_cast<int>(V8Class::InternalFields::OBJECT_CLASS)).As<v8::External>()->Value();
void* cls = val.As<v8::External>()->Value();
return *reinterpret_cast<V8Class::ObjectClass*>(&cls);
}

Expand Down

0 comments on commit e00b005

Please sign in to comment.