Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[squash] ABI compatiable, use c++14 deprecation syntax
  • Loading branch information
AndreasMadsen committed Jun 13, 2017
commit 248bc1dd8320cc23189eb08cd078284e04cb4dc0
10 changes: 10 additions & 0 deletions src/async-wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -735,11 +735,21 @@ async_uid AsyncHooksGetExecutionAsyncId(Isolate* isolate) {
return Environment::GetCurrent(isolate)->current_async_id();
}

[[deprecated("Use AsyncHooksGetExecutionAsyncId(isolate)")]]
async_uid AsyncHooksGetCurrentId(v8::Isolate* isolate) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for v8::

return AsyncHooksGetExecutionAsyncId(isolate);
}


async_uid AsyncHooksGetTriggerAsyncId(Isolate* isolate) {
return Environment::GetCurrent(isolate)->get_init_trigger_id();
}

[[deprecated("Use AsyncHooksGetTriggerAsyncId(isolate)")]]
async_uid AsyncHooksGetTriggerId(v8::Isolate* isolate) {
return AsyncHooksGetTriggerAsyncId(isolate);
}


async_uid EmitAsyncInit(Isolate* isolate,
Local<Object> resource,
Expand Down
12 changes: 4 additions & 8 deletions src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -530,18 +530,14 @@ NODE_EXTERN void AddPromiseHook(v8::Isolate* isolate,
* I/O from native code. */
NODE_EXTERN async_uid AsyncHooksGetExecutionAsyncId(v8::Isolate* isolate);
/* legacy alias */
NODE_DEPRECATED("Use AsyncHooksGetExecutionAsyncId(isolate)",
inline async_uid AsyncHooksGetCurrentId(v8::Isolate* isolate) {
return AsyncHooksGetExecutionAsyncId(isolate);
})
[[deprecated("Use AsyncHooksGetExecutionAsyncId(isolate)")]]
NODE_EXTERN async_uid AsyncHooksGetCurrentId(v8::Isolate* isolate);

/* Return same value as async_hooks.triggerAsyncId(); */
NODE_EXTERN async_uid AsyncHooksGetTriggerAsyncId(v8::Isolate* isolate);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just one extra thought, if you want to do this in a ABI/API-compatible way, you could just add

// legacy
#define AsyncHooksGetExecutionAsyncId AsyncHooksGetCurrentId
#define AsyncHooksGetTriggerAsyncId AsyncHooksGetTriggerId

before these definitions

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to do this without a deprecation warning?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do that too, sure (just keep in mind that the deprecated methods would need definitions in our .cc files, we can’t get away with a header-only change in that case). I think this is going to be fine, though.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we start using V8_DEPRECATED in our headers to make note of deprecated native APIs?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndreasMadsen Any thoughts on the above? The way the PR is written right now it’s both breakaging ABI and API, which I guess will be okay because it only came out with 8.1.0, but I wouldn’t see anything wrong with fixing that up by using #defines

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is not an annoyance with using legacy API, there is no incentive to move on. An alias with a deprecation warning sounds good.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just keep in mind that the deprecated methods would need definitions in our .cc files, we can’t get away with a header-only change in that case

That’s still true. If you’re adding the aliases as inline methods in the header, the Node binary will still stop exporting them.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, of course. Then I'm not sure how I can desperate them. Do we allow C++14 deprecation syntax?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I'm not sure how I can desperate them

I think something like NODE_EXTERN NODE_DEPRECATED(…, async_uid AsyncHooksGetCurrentId(v8::Isolate* isolate)); + the alias definition in the .cc file would work?

Do we allow C++14 deprecation syntax?

Not yet, I am afraid.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ABI compatibility: e841a8c

/* legacy alias */
NODE_DEPRECATED("Use AsyncHooksGetTriggerAsyncId(isolate)",
inline async_uid AsyncHooksGetTriggerId(v8::Isolate* isolate) {
return AsyncHooksGetTriggerAsyncId(isolate);
})
[[deprecated("Use AsyncHooksGetTriggerAsyncId(isolate)")]]
NODE_EXTERN async_uid AsyncHooksGetTriggerId(v8::Isolate* isolate);


/* If the native API doesn't inherit from the helper class then the callbacks
Expand Down