Skip to content

[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

Merged
merged 1 commit into from
Aug 2, 2018

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Jul 31, 2018

We will need this to transfer a binary encoded syntax tree in the future

@ahoppen ahoppen requested review from rintaro and nkcsgexi July 31, 2018 23:48
@rintaro
Copy link
Member

rintaro commented Aug 1, 2018

I think @akyrtzi or @benlangmuir should review this.

@rintaro rintaro requested review from akyrtzi and benlangmuir and removed request for rintaro August 1, 2018 00:05
@ahoppen
Copy link
Member Author

ahoppen commented Aug 1, 2018

@swift-ci Please smoke test

@@ -59,6 +59,7 @@ enum class CustomBufferKind {
InheritedTypesArray,
DocStructureElementArray,
AttributesArray,
SyntaxTree
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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,
Copy link
Contributor

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
}};
Copy link
Contributor

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();
Copy link
Contributor

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
@ahoppen ahoppen force-pushed the sourcekit-raw-data branch from 6040a22 to d920a66 Compare August 1, 2018 21:34
@ahoppen
Copy link
Member Author

ahoppen commented Aug 1, 2018

@swift-ci Please smoke test

@ahoppen ahoppen merged commit 38c62cf into swiftlang:master Aug 2, 2018
@ahoppen ahoppen deleted the sourcekit-raw-data branch August 22, 2018 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants