-
Notifications
You must be signed in to change notification settings - Fork 28
Fix multiple runtime APIs that were incorrectly using std::string::reserve
#478
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
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
dab9ba7
Try accessing environment variable
vrn-sn 1d4f881
temp: only make this job run
vrn-sn 58b14d2
prints
vrn-sn 602a3db
Incorporate real fix + undo hack
vrn-sn 9cc9163
Fix typo
vrn-sn 801728f
Abstract away buffer management
vrn-sn d194bfe
more debug info
vrn-sn e4cc1f2
Merge branch 'primary' of https://github.com/luau-lang/lute into vrn-…
vrn-sn ac03a64
Remove docs debug prints
vrn-sn 2daf05b
Remove all temp debug additions
vrn-sn e5b37c4
Fix test logic
vrn-sn 5eb5959
Try forcing bash shell to make Windows work
vrn-sn 3fef900
Replace backslashes with forward slashes in bash
vrn-sn d83cc9c
(Revert) undo attempts to fix Windows
vrn-sn ddf1b33
Use Luau::Variant
vrn-sn a73d1ad
Use auto for readability
vrn-sn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #pragma once | ||
|
|
||
| #include "Luau/Variant.h" | ||
|
|
||
| #include <cstddef> | ||
| #include <string> | ||
|
|
||
| namespace uvutils | ||
| { | ||
|
|
||
| struct UvError | ||
| { | ||
| UvError(int code); | ||
| std::string toString() const; | ||
|
|
||
| int code; | ||
| }; | ||
|
|
||
| typedef int (*BufferWriter)(char* buffer, size_t* size); | ||
|
|
||
| // Abstracts away buffer management when getting strings from libuv functions. | ||
| Luau::Variant<std::string, UvError> getStringFromUv(BufferWriter bufferWriter, size_t initialBufferSize = 256); | ||
|
|
||
| } // namespace uvutils | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| #include "lute/uvutils.h" | ||
|
|
||
| #include "uv.h" | ||
|
|
||
| namespace uvutils | ||
| { | ||
|
|
||
| UvError::UvError(int code) | ||
| : code(code) | ||
| { | ||
| } | ||
|
|
||
| std::string UvError::toString() const | ||
| { | ||
| return uv_strerror(code); | ||
| } | ||
|
|
||
| Luau::Variant<std::string, UvError> getStringFromUv(BufferWriter bufferWriter, size_t initialBufferSize) | ||
| { | ||
| std::string buffer; | ||
| size_t size = initialBufferSize; | ||
| buffer.resize(size); | ||
|
|
||
| int writeStatus = bufferWriter(buffer.data(), &size); | ||
| if (writeStatus == UV_ENOBUFS) | ||
| { | ||
| // `size` now contains the required size | ||
| buffer.resize(size); | ||
| writeStatus = bufferWriter(buffer.data(), &size); | ||
| } | ||
|
|
||
| if (writeStatus < 0) | ||
| return UvError{writeStatus}; | ||
|
|
||
| buffer.resize(size); | ||
| return buffer; | ||
| } | ||
|
|
||
| } // namespace uvutils |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.