-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[sourcekitd] Add support for transferring raw data #18426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I think @akyrtzi or @benlangmuir should review this. |
@swift-ci Please smoke test |
@@ -59,6 +59,7 @@ enum class CustomBufferKind { | |||
InheritedTypesArray, | |||
DocStructureElementArray, | |||
AttributesArray, | |||
SyntaxTree |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a more general buffer kind name, like RawData
.
It could be used for other things, not just SyntaxTree.
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2014 - 2018
@@ -309,7 +309,10 @@ typedef enum { | |||
SOURCEKITD_VARIANT_TYPE_INT64 = 3, | |||
SOURCEKITD_VARIANT_TYPE_STRING = 4, | |||
SOURCEKITD_VARIANT_TYPE_UID = 5, | |||
SOURCEKITD_VARIANT_TYPE_BOOL = 6 | |||
SOURCEKITD_VARIANT_TYPE_BOOL = 6, | |||
// Not implemented in sourcekitd but in SourceKit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not strictly necessary to sync the same integers here, but it's fine to reserve the integer for a future SOURCEKITD_VARIANT_TYPE_DOUBLE
.
I'd recommend to have in the comment Reserved for future addition
.
SOURCEKITD_VARIANT_TYPE_BOOL = 6 | ||
SOURCEKITD_VARIANT_TYPE_BOOL = 6, | ||
// Not implemented in sourcekitd but in SourceKit | ||
// SOURCEKIT_VARIANT_TYPE_DOUBLE = 7, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SOURCEKIT_VARIANT_TYPE_DOUBLE -> SOURCEKITD_VARIANT_TYPE_DOUBLE
return {{ (uintptr_t)getVariantFunctionsForData(), | ||
(uintptr_t)BufStart + sizeof(size_t), | ||
(uintptr_t)BufSize | ||
}}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the buffer for RawData
is supposed to store its size at the beginning. But that seems redundant since xpc_data_get_length
can get us the total size and just remove the size of the kind value.
E.g. below #define CUSTOM_BUF_START
add:
#define CUSTOM_BUF_SIZE(xobj) xpc_data_get_length(xobj)-sizeof(uint64_t)
Then use it as:
case CustomBufferKind::RawData:
return {{ (uintptr_t)getVariantFunctionsForRawData(),
(uintptr_t)CUSTOM_BUF_START(obj), CUSTOM_BUF_SIZE(obj) }};
|
||
namespace sourcekitd { | ||
|
||
VariantFunctions *getVariantFunctionsForData(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getVariantFunctionsForData -> getVariantFunctionsForRawData, is slightly better for clarity.
We will need this to transfer a binary encoded syntax tree in the future
6040a22
to
d920a66
Compare
@swift-ci Please smoke test |
We will need this to transfer a binary encoded syntax tree in the future