Skip to content
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

src: add AliasedStruct utility #32778

Closed
wants to merge 4 commits into from
Closed

Conversation

jasnell
Copy link
Member

@jasnell jasnell commented Apr 11, 2020

For http2 (and eventually QUIC) we have a struct that is backed
by a v8::BackingStore and exposed to the JavaScript side as an
ArrayBuffer and TypedArray. This is similar to AliasedBuffer
except that it is fronted by a struct on the C++ side.

struct foo {
  uint32_t ex1;
  uint32_t ex2;
};

AliasedStruct<foo> foo_;

foo_->ex1 = 1;
foo_->ex2 = 2;

foo_.GetArrayBuffer();

Signed-off-by: James M Snell [email protected]

/cc @addaleax

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

For http2 (and eventually QUIC) we have a struct that is backed
by a v8::BackingStore and exposed to the JavaScript side as an
ArrayBuffer and TypedArray. This is similar to AliasedBuffer
except that it is fronted by a struct on the C++ side.

```c++
struct foo {
  uint32_t ex1;
  uint32_t ex2;
};

AliasedStruct<foo> foo_;

foo_->ex1 = 1;
foo_->ex2 = 2;

foo_.GetArrayBuffer();
```

Signed-off-by: James M Snell <[email protected]>
@jasnell jasnell added the lib / src Issues and PRs related to general changes in the lib or src directory. label Apr 11, 2020
@jasnell jasnell requested a review from addaleax April 11, 2020 03:21
@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Apr 11, 2020
src/aliased_struct.h Show resolved Hide resolved
src/aliased_struct.h Outdated Show resolved Hide resolved
src/aliased_struct.h Outdated Show resolved Hide resolved
src/aliased_struct.h Outdated Show resolved Hide resolved
src/aliased_struct.h Outdated Show resolved Hide resolved
src/aliased_struct.h Outdated Show resolved Hide resolved
src/aliased_struct.h Outdated Show resolved Hide resolved
@richardlau
Copy link
Member

Add a cctest? (We have test/cctest/test_aliased_buffer.cc for AliasedBuffer.)

@addaleax
Copy link
Member

I don’t think this is the kind of feature that needs to come with a cctest, all of its functionality is basically tested through the existing usage, I’d say.

src/aliased_struct.h Outdated Show resolved Hide resolved
src/aliased_struct.h Outdated Show resolved Hide resolved
@nodejs-github-bot
Copy link
Collaborator

src/node_http2.h Outdated Show resolved Hide resolved
@addaleax addaleax added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 13, 2020
@nodejs-github-bot
Copy link
Collaborator

src/aliased_struct-inl.h Outdated Show resolved Hide resolved
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@addaleax
Copy link
Member

Landed in cecb08f

addaleax pushed a commit that referenced this pull request Apr 14, 2020
For http2 (and eventually QUIC) we have a struct that is backed
by a v8::BackingStore and exposed to the JavaScript side as an
ArrayBuffer and TypedArray. This is similar to AliasedBuffer
except that it is fronted by a struct on the C++ side.

```c++
struct foo {
  uint32_t ex1;
  uint32_t ex2;
};

AliasedStruct<foo> foo_;

foo_->ex1 = 1;
foo_->ex2 = 2;

foo_.GetArrayBuffer();
```

Signed-off-by: James M Snell <[email protected]>

PR-URL: #32778
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
@addaleax addaleax closed this Apr 14, 2020
BethGriggs pushed a commit that referenced this pull request Apr 14, 2020
For http2 (and eventually QUIC) we have a struct that is backed
by a v8::BackingStore and exposed to the JavaScript side as an
ArrayBuffer and TypedArray. This is similar to AliasedBuffer
except that it is fronted by a struct on the C++ side.

```c++
struct foo {
  uint32_t ex1;
  uint32_t ex2;
};

AliasedStruct<foo> foo_;

foo_->ex1 = 1;
foo_->ex2 = 2;

foo_.GetArrayBuffer();
```

Signed-off-by: James M Snell <[email protected]>

PR-URL: #32778
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants