Skip to content

Commit 7f0adcc

Browse files
committed
const allocator
1 parent 497c76f commit 7f0adcc

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

src/binding.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,7 +1555,7 @@ void v8__base__SetDcheckFunction(void (*func)(const char*, int, const char*)) {
15551555
/// @param allocator: A Zig std.mem.Allocator
15561556
/// @param bytes: The number of bytes to allocate
15571557
/// @returns A pointer to the allocated memory, null if allocation failed
1558-
char* zigAlloc(void* allocator, uint64_t bytes);
1558+
char* zigAlloc(const void* allocator, uint64_t bytes);
15591559

15601560
static inline v8_inspector::StringView toStringView(const char *str, size_t length) {
15611561
auto* stringView = reinterpret_cast<const uint8_t*>(str);
@@ -1580,7 +1580,7 @@ static inline std::string fromStringView(v8::Isolate* isolate, const v8_inspecto
15801580
/// @param str: The string to return
15811581
/// @param allocator: A Zig std.mem.Allocator
15821582
/// @returns string pointer with null terminator, null if allocation failed
1583-
const char* toHeapCharPtr(const v8_inspector::String16& str, void* allocator) {
1583+
const char* toHeapCharPtr(const v8_inspector::String16& str, const void* allocator) {
15841584
std::string utf8_str = str.utf8(); // Note the data*'s lifetime is tied to utf8_str and this may hold the string data on the stack as an SSO, so we need to copy it onto the heap.
15851585
char* heap_str = zigAlloc(allocator, utf8_str.length() + 1); // +1 for null terminator, needed to communicate the length to Zig
15861586
if (heap_str == nullptr) {
@@ -1671,7 +1671,7 @@ void v8_inspector__RemoteObject__DELETE(v8_inspector::protocol::Runtime::RemoteO
16711671
}
16721672

16731673
// RemoteObject - Type
1674-
const char* v8_inspector__RemoteObject__getType(v8_inspector::protocol::Runtime::RemoteObject* self, void* allocator) {
1674+
const char* v8_inspector__RemoteObject__getType(v8_inspector::protocol::Runtime::RemoteObject* self, const void* allocator) {
16751675
auto str = self->getType();
16761676
return toHeapCharPtr(str, allocator);
16771677
}
@@ -1683,7 +1683,7 @@ void v8_inspector__RemoteObject__setType(v8_inspector::protocol::Runtime::Remote
16831683
bool v8_inspector__RemoteObject__hasSubtype(v8_inspector::protocol::Runtime::RemoteObject* self) {
16841684
return self->hasSubtype();
16851685
}
1686-
const char* v8_inspector__RemoteObject__getSubtype(v8_inspector::protocol::Runtime::RemoteObject* self, void* allocator) {
1686+
const char* v8_inspector__RemoteObject__getSubtype(v8_inspector::protocol::Runtime::RemoteObject* self, const void* allocator) {
16871687
auto str = self->getSubtype(DEFAULT_STRING);
16881688
return toHeapCharPtr(str, allocator);
16891689
}
@@ -1695,7 +1695,7 @@ void v8_inspector__RemoteObject__setSubtype(v8_inspector::protocol::Runtime::Rem
16951695
bool v8_inspector__RemoteObject__hasClassName(v8_inspector::protocol::Runtime::RemoteObject* self) {
16961696
return self->hasClassName();
16971697
}
1698-
const char* v8_inspector__RemoteObject__getClassName(v8_inspector::protocol::Runtime::RemoteObject* self, void* allocator) {
1698+
const char* v8_inspector__RemoteObject__getClassName(v8_inspector::protocol::Runtime::RemoteObject* self, const void* allocator) {
16991699
auto str = self->getClassName(DEFAULT_STRING);
17001700
return toHeapCharPtr(str, allocator);
17011701
}
@@ -1718,7 +1718,7 @@ void v8_inspector__RemoteObject__setValue(v8_inspector::protocol::Runtime::Remot
17181718
bool v8_inspector__RemoteObject__hasUnserializableValue(v8_inspector::protocol::Runtime::RemoteObject* self) {
17191719
return self->hasUnserializableValue();
17201720
}
1721-
const char* v8_inspector__RemoteObject__getUnserializableValue(v8_inspector::protocol::Runtime::RemoteObject* self, void* allocator) {
1721+
const char* v8_inspector__RemoteObject__getUnserializableValue(v8_inspector::protocol::Runtime::RemoteObject* self, const void* allocator) {
17221722
auto str = self->getUnserializableValue(DEFAULT_STRING);
17231723
return toHeapCharPtr(str, allocator);
17241724
}
@@ -1730,7 +1730,7 @@ void v8_inspector__RemoteObject__setUnserializableValue(v8_inspector::protocol::
17301730
bool v8_inspector__RemoteObject__hasDescription(v8_inspector::protocol::Runtime::RemoteObject* self) {
17311731
return self->hasDescription();
17321732
}
1733-
const char* v8_inspector__RemoteObject__getDescription(v8_inspector::protocol::Runtime::RemoteObject* self, void* allocator) {
1733+
const char* v8_inspector__RemoteObject__getDescription(v8_inspector::protocol::Runtime::RemoteObject* self, const void* allocator) {
17341734
auto str = self->getDescription(DEFAULT_STRING);
17351735
return toHeapCharPtr(str, allocator);
17361736
}
@@ -1754,7 +1754,7 @@ bool v8_inspector__RemoteObject__hasObjectId(v8_inspector::protocol::Runtime::Re
17541754
return self->hasObjectId();
17551755
}
17561756

1757-
const char* v8_inspector__RemoteObject__getObjectId(v8_inspector::protocol::Runtime::RemoteObject* self, void* allocator) {
1757+
const char* v8_inspector__RemoteObject__getObjectId(v8_inspector::protocol::Runtime::RemoteObject* self, const void* allocator) {
17581758
auto str = self->getObjectId(DEFAULT_STRING);
17591759
return toHeapCharPtr(str, allocator);
17601760
}

src/binding.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,17 +1030,17 @@ void v8_inspector__Inspector__ContextCreated(Inspector *self, const char *name,
10301030
void v8_inspector__RemoteObject__DELETE(RemoteObject *self);
10311031

10321032
// RemoteObject - Type
1033-
const char* v8_inspector__RemoteObject__getType(RemoteObject* self, void* allocator);
1033+
const char* v8_inspector__RemoteObject__getType(RemoteObject* self, const void* allocator);
10341034
void v8_inspector__RemoteObject__setType(RemoteObject* self, const char* type, int type_len);
10351035

10361036
// RemoteObject - Subtype
10371037
bool v8_inspector__RemoteObject__hasSubtype(RemoteObject* self);
1038-
const char* v8_inspector__RemoteObject__getSubtype(RemoteObject* self, void* allocator);
1038+
const char* v8_inspector__RemoteObject__getSubtype(RemoteObject* self, const void* allocator);
10391039
void v8_inspector__RemoteObject__setSubtype(RemoteObject* self, const char* subtype, int subtype_len);
10401040

10411041
// RemoteObject - ClassName
10421042
bool v8_inspector__RemoteObject__hasClassName(RemoteObject* self);
1043-
const char* v8_inspector__RemoteObject__getClassName(RemoteObject* self, void* allocator);
1043+
const char* v8_inspector__RemoteObject__getClassName(RemoteObject* self, const void* allocator);
10441044
void v8_inspector__RemoteObject__setClassName(RemoteObject* self, const char* className, int className_len);
10451045

10461046
// RemoteObject - Value
@@ -1051,12 +1051,12 @@ bool v8_inspector__RemoteObject__hasValue(RemoteObject* self);
10511051

10521052
//RemoteObject - UnserializableValue
10531053
bool v8_inspector__RemoteObject__hasUnserializableValue(RemoteObject* self);
1054-
const char* v8_inspector__RemoteObject__getUnserializableValue(RemoteObject* self, void* allocator);
1054+
const char* v8_inspector__RemoteObject__getUnserializableValue(RemoteObject* self, const void* allocator);
10551055
void v8_inspector__RemoteObject__setUnserializableValue(RemoteObject* self, const char* unserializableValue, int unserializableValue_len);
10561056

10571057
// RemoteObject - Description
10581058
bool v8_inspector__RemoteObject__hasDescription(RemoteObject* self);
1059-
const char* v8_inspector__RemoteObject__getDescription(RemoteObject* self, void* allocator);
1059+
const char* v8_inspector__RemoteObject__getDescription(RemoteObject* self, const void* allocator);
10601060
void v8_inspector__RemoteObject__setDescription(RemoteObject* self, const char* description, int description_len);
10611061

10621062
// RemoteObject - WebDriverValue
@@ -1066,7 +1066,7 @@ void v8_inspector__RemoteObject__setWebDriverValue(RemoteObject* self, WebDriver
10661066

10671067
// RemoteObject - ObjectId
10681068
bool v8_inspector__RemoteObject__hasObjectId(RemoteObject* self);
1069-
const char* v8_inspector__RemoteObject__getObjectId(RemoteObject* self, void* allocator);
1069+
const char* v8_inspector__RemoteObject__getObjectId(RemoteObject* self, const void* allocator);
10701070
void v8_inspector__RemoteObject__setObjectId(RemoteObject* self, const char* objectId, int objectId_len);
10711071

10721072
// RemoteObject - Preview

src/v8.zig

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2694,56 +2694,56 @@ pub const RemoteObject = struct {
26942694
c.v8_inspector__RemoteObject__DELETE(self.handle);
26952695
}
26962696

2697-
pub fn getType(self: RemoteObject, allocator: *std.mem.Allocator) ![:0]const u8 {
2698-
const type_ = c.v8_inspector__RemoteObject__getType(self.handle, allocator);
2697+
pub fn getType(self: RemoteObject, allocator: std.mem.Allocator) ![:0]const u8 {
2698+
const type_ = c.v8_inspector__RemoteObject__getType(self.handle, &allocator);
26992699
if (type_ == null) {
27002700
return error.V8AllocFailed;
27012701
}
27022702
const idx = std.mem.indexOfSentinel(u8, 0, type_);
27032703
return type_[0..idx :0];
27042704
}
2705-
pub fn getSubtype(self: RemoteObject, allocator: *std.mem.Allocator) !?[:0]const u8 {
2705+
pub fn getSubtype(self: RemoteObject, allocator: std.mem.Allocator) !?[:0]const u8 {
27062706
if (!c.v8_inspector__RemoteObject__hasSubtype(self.handle)) {
27072707
return null;
27082708
}
27092709

2710-
const subtype = c.v8_inspector__RemoteObject__getSubtype(self.handle, allocator);
2710+
const subtype = c.v8_inspector__RemoteObject__getSubtype(self.handle, &allocator);
27112711
if (subtype == null) {
27122712
return error.V8AllocFailed;
27132713
}
27142714
const idx = std.mem.indexOfSentinel(u8, 0, subtype);
27152715
return subtype[0..idx :0];
27162716
}
2717-
pub fn getClassName(self: RemoteObject, allocator: *std.mem.Allocator) !?[:0]const u8 {
2717+
pub fn getClassName(self: RemoteObject, allocator: std.mem.Allocator) !?[:0]const u8 {
27182718
if (!c.v8_inspector__RemoteObject__hasClassName(self.handle)) {
27192719
return null;
27202720
}
27212721

2722-
const class_name = c.v8_inspector__RemoteObject__getClassName(self.handle, allocator);
2722+
const class_name = c.v8_inspector__RemoteObject__getClassName(self.handle, &allocator);
27232723
if (class_name == null) {
27242724
return error.V8AllocFailed;
27252725
}
27262726
const idx = std.mem.indexOfSentinel(u8, 0, class_name);
27272727
return class_name[0..idx :0];
27282728
}
2729-
pub fn getDescription(self: RemoteObject, allocator: *std.mem.Allocator) !?[:0]const u8 {
2729+
pub fn getDescription(self: RemoteObject, allocator: std.mem.Allocator) !?[:0]const u8 {
27302730
if (!c.v8_inspector__RemoteObject__hasDescription(self.handle)) {
27312731
return null;
27322732
}
27332733

2734-
const description = c.v8_inspector__RemoteObject__getDescription(self.handle, allocator);
2734+
const description = c.v8_inspector__RemoteObject__getDescription(self.handle, &allocator);
27352735
if (description == null) {
27362736
return error.V8AllocFailed;
27372737
}
27382738
const idx = std.mem.indexOfSentinel(u8, 0, description);
27392739
return description[0..idx :0];
27402740
}
2741-
pub fn getObjectId(self: RemoteObject, allocator: *std.mem.Allocator) !?[:0]const u8 {
2741+
pub fn getObjectId(self: RemoteObject, allocator: std.mem.Allocator) !?[:0]const u8 {
27422742
if (!c.v8_inspector__RemoteObject__hasObjectId(self.handle)) {
27432743
return null;
27442744
}
27452745

2746-
const object_id = c.v8_inspector__RemoteObject__getObjectId(self.handle, allocator);
2746+
const object_id = c.v8_inspector__RemoteObject__getObjectId(self.handle, &allocator);
27472747
if (object_id == null) {
27482748
return error.V8AllocFailed;
27492749
}

0 commit comments

Comments
 (0)