Skip to content

Commit 41f1299

Browse files
Add V8 API compatibility shims for node-fibers
Add backward-compatible methods that were removed in V8 12.x: 1. FunctionCallbackInfo::Holder() - returns This() for compatibility (In simple cases without prototype chain lookups, This() == Holder()) 2. Object::SetAccessor() - calls SetNativeDataProperty() internally 3. Template::SetAccessor() - calls SetNativeDataProperty() internally (Inherited by ObjectTemplate) These shims allow node-fibers to compile against Node 24 without modifying the node-fibers source code. Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
1 parent 0a9b007 commit 41f1299

3 files changed

Lines changed: 36 additions & 0 deletions

File tree

deps/v8/include/v8-function-callback.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ class FunctionCallbackInfo {
126126
V8_INLINE Local<Value> operator[](int i) const;
127127
/** Returns the receiver. This corresponds to the "this" value. */
128128
V8_INLINE Local<Object> This() const;
129+
/**
130+
* Compatibility shim for node-fibers: Holder() now returns This().
131+
* In older V8, Holder() returned the object holding the property.
132+
* For simple cases (no prototype chain lookups), This() == Holder().
133+
*/
134+
V8_INLINE Local<Object> Holder() const { return This(); }
129135
/** For construct calls, this returns the "new.target" value. */
130136
V8_INLINE Local<Value> NewTarget() const;
131137
/** Indicates whether this is a regular call or a construct call. */

deps/v8/include/v8-object.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,22 @@ class V8_EXPORT Object : public Value {
364364
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
365365
SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
366366

367+
/**
368+
* Compatibility shim for node-fibers: SetAccessor() now calls
369+
* SetNativeDataProperty() internally.
370+
*/
371+
V8_WARN_UNUSED_RESULT Maybe<bool> SetAccessor(
372+
Local<Context> context, Local<Name> name,
373+
AccessorNameGetterCallback getter,
374+
AccessorNameSetterCallback setter = nullptr,
375+
Local<Value> data = Local<Value>(), PropertyAttribute attributes = None,
376+
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
377+
SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect) {
378+
return SetNativeDataProperty(context, name, getter, setter, data,
379+
attributes, getter_side_effect_type,
380+
setter_side_effect_type);
381+
}
382+
367383
/**
368384
* Attempts to create a property with the given name which behaves like a data
369385
* property, except that the provided getter is invoked (and provided with the

deps/v8/include/v8-template.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,20 @@ class V8_EXPORT Template : public Data {
108108
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
109109
SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
110110

111+
/**
112+
* Compatibility shim for node-fibers: SetAccessor() now calls
113+
* SetNativeDataProperty() internally.
114+
*/
115+
void SetAccessor(
116+
Local<Name> name, AccessorNameGetterCallback getter,
117+
AccessorNameSetterCallback setter = nullptr,
118+
Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
119+
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
120+
SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect) {
121+
SetNativeDataProperty(name, getter, setter, data, attribute,
122+
getter_side_effect_type, setter_side_effect_type);
123+
}
124+
111125
/**
112126
* Like SetNativeDataProperty, but V8 will replace the native data property
113127
* with a real data property on first access.

0 commit comments

Comments
 (0)