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

Implemented an initial setup for the console API #76

Merged
merged 9 commits into from
Oct 8, 2023
Merged

Conversation

jaytaph
Copy link
Member

@jaytaph jaytaph commented Oct 2, 2023

This is an initial setup of the console api, since i cannot spend any time on the parser since I cannot access the code (don't ask).

So therefor, I did some reading up on the console API, and found that it's not very hard to implement. Not everything is done yet, but most is.

The idea is that anything that can be displayed (implements fmt::Display), can be added to the console functions. It also contains timers, and groups.

Ultimately, the console will write to a io::Write, which can be stdout(), a file, or a string buffer. Later on, these calls will be connected to javascript methods.

I'm not sure if this is the right way to do it, so i'm hoping from some feedback from others to see if this is the right way to do it.

(i know that the console api is not the highest priority, but it gave me some time to read into more stuff, and practice some rust)

Cargo.toml Outdated Show resolved Hide resolved
src/console/formatter.rs Outdated Show resolved Hide resolved
src/console/formatter.rs Outdated Show resolved Hide resolved
src/console/mod.rs Outdated Show resolved Hide resolved
src/console/mod.rs Outdated Show resolved Hide resolved
src/console/mod.rs Outdated Show resolved Hide resolved
src/console/mod.rs Outdated Show resolved Hide resolved
src/console/mod.rs Outdated Show resolved Hide resolved
src/console/mod.rs Outdated Show resolved Hide resolved
src/console/mod.rs Outdated Show resolved Hide resolved
src/console/text_printer.rs Outdated Show resolved Hide resolved
src/console/text_printer.rs Outdated Show resolved Hide resolved
@jaytaph
Copy link
Member Author

jaytaph commented Oct 4, 2023

@emwalker Thanks for the feedback. I've implemented the suggestions, and will try to implement the rest of the code. I might even check if it would be possible if I could create some node.js bindings, to see if I can use it from node.js, but this depends on my time available (i really want the parser done)

@jaytaph jaytaph marked this pull request as ready for review October 7, 2023 18:55
@jaytaph jaytaph requested a review from emwalker October 7, 2023 18:55
impl Write for Buffer {
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
self.buf.extend(buf);
Ok(buf.len())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you want to fix this return value before merging? If not, perhaps add a // TODO: return correct return value.

@emwalker
Copy link
Collaborator

emwalker commented Oct 7, 2023

LGTM with suggestion.

@jaytaph jaytaph merged commit 3036ec2 into main Oct 8, 2023
4 checks passed
@jaytaph jaytaph deleted the console-api branch October 8, 2023 08:49
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.

2 participants