Skip to content

Commit eb08184

Browse files
committed
Add CompilationDetails sizeof test, remove unnecessary casts
1 parent 589a378 commit eb08184

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/binding.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,9 @@ const v8::Module* v8__ScriptCompiler__CompileModule(
580580
return maybe_local_to_ptr(maybe_local);
581581
}
582582

583+
size_t v8__ScriptCompiler__CompilationDetails__SIZEOF() {
584+
return sizeof(v8::ScriptCompiler::CompilationDetails);
585+
}
583586
// Module
584587

585588
v8::Module::Status v8__Module__GetStatus(const v8::Module& self) {
@@ -1714,8 +1717,8 @@ static inline std::string fromStringView(v8::Isolate* isolate, const v8_inspecto
17141717
int length = static_cast<int>(stringView.length());
17151718
v8::Local<v8::String> message = (
17161719
stringView.is8Bit()
1717-
? v8::String::NewFromOneByte(isolate, reinterpret_cast<const uint8_t*>(stringView.characters8()), v8::NewStringType::kNormal, length)
1718-
: v8::String::NewFromTwoByte(isolate, reinterpret_cast<const uint16_t*>(stringView.characters16()), v8::NewStringType::kNormal, length)
1720+
? v8::String::NewFromOneByte(isolate, stringView.characters8(), v8::NewStringType::kNormal, length)
1721+
: v8::String::NewFromTwoByte(isolate, stringView.characters16(), v8::NewStringType::kNormal, length)
17191722
).ToLocalChecked();
17201723
v8::String::Utf8Value result(isolate, message);
17211724
return *result;

src/binding.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,7 @@ void v8__ScriptOrigin__CONSTRUCT2(
953953
const Data* host_defined_options
954954
);
955955

956+
usize v8__ScriptCompiler__CompilationDetails__SIZEOF();
956957
typedef struct CompilationDetails {
957958
// this is an enum, but should get padded to an int64_t
958959
int64_t in_memory_cache_result;

src/v8.zig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,12 @@ pub const ObjectTemplate = struct {
10431043
c.v8__ObjectTemplate__SetNamedHandler(self.handle, &conf);
10441044
}
10451045

1046+
// JS has two types of properties: data and accessors. The data property, what
1047+
// v8 calls a NativeData property is like a field, obj.x. An access properties
1048+
// is one or both of a get and set function.
1049+
// They seem to mostly differ in subtle ways relating to meta programming
1050+
// and how they're resolve in the prototype chain.
1051+
// https://tc39.es/ecma262/multipage/ecmascript-data-types-and-values.html#sec-object-type
10461052
pub fn setNativeGetter(self: Self, key: Name, getter: c.AccessorNameGetterCallback) void {
10471053
c.v8__ObjectTemplate__SetNativeDataProperty__DEFAULT(self.handle, key.handle, getter);
10481054
}
@@ -2656,6 +2662,7 @@ test "Internals." {
26562662
try eq(c.v8__PromiseRejectMessage__SIZEOF(), @sizeOf(c.PromiseRejectMessage));
26572663
try eq(c.v8__ScriptCompiler__Source__SIZEOF(), @sizeOf(c.ScriptCompilerSource));
26582664
try eq(c.v8__ScriptCompiler__CachedData__SIZEOF(), @sizeOf(c.ScriptCompilerCachedData));
2665+
try eq(c.v8__ScriptCompiler__CompilationDetails__SIZEOF(), @sizeOf(c.CompilationDetails));
26592666
try eq(c.v8__HeapStatistics__SIZEOF(), @sizeOf(c.HeapStatistics));
26602667
}
26612668

0 commit comments

Comments
 (0)