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

Support for JS getters and setters #358

Merged
merged 3 commits into from
Feb 10, 2024

Conversation

Sharktheone
Copy link
Member

This PR adds support for Javascript's getters and setters. This is needed to pass structs with fields to JS, see test.rs

Next Steps

@Sharktheone Sharktheone added the javascript Any issues related to JavaScript label Feb 3, 2024
@Sharktheone Sharktheone self-assigned this Feb 3, 2024
@Sharktheone Sharktheone requested a review from jaytaph February 5, 2024 21:26
Comment on lines 110 to 127
#[test]
fn v8_bindings_test() {
// let platform = v8::new_default_platform(0, false).make_shared();
// v8::V8::initialize_platform(platform);
// v8::V8::initialize();
// The engine is already initialized in the previous test

let isolate = &mut v8::Isolate::new(Default::default());
let hs = &mut v8::HandleScope::new(isolate);
let c = v8::Context::new(hs);
let s = &mut v8::ContextScope::new(hs, c);

let code = v8::String::new(s, "console.log(\"Hello World!\"); 1234").unwrap();

let value = v8::Script::compile(s, code, None).unwrap().run(s).unwrap();

println!("{}", value.to_rust_string_lossy(s));
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, interesting, looks like this Test causes some errors.
I guess, that's because V8 crashes somehow while initializing and it still holds the "init-lock", I probably should limit this.

@Sharktheone Sharktheone force-pushed the js-getter-setter branch 2 times, most recently from 136f8a7 to f44565d Compare February 6, 2024 08:21
fix tests

fix fmt
@Sharktheone Sharktheone merged commit cb176d3 into gosub-io:main Feb 10, 2024
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
javascript Any issues related to JavaScript
Projects
Status: 🎯 Done
Development

Successfully merging this pull request may close these issues.

2 participants