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

Unify object creation with empty and from_proto_and_data methods #1567

Merged
merged 2 commits into from
Oct 5, 2021

Conversation

jedel1043
Copy link
Member

@jedel1043 jedel1043 commented Sep 9, 2021

Another step towards #577.

This Pull Request unifies JsObject creation by just having to specify an (optional) prototype and an ObjectData to create a new JsObject.

This refactors patterns like:

let obj = context.construct_object();
obj.set_prototype_instance(prototype);
obj.borrow_mut().data = ObjectData::string("".into());

into a simpler:

let obj = JsObject::from_proto_and_data(Some(prototype), ObjectData::string("".into()));

and the expression:

let obj = JsObject::new(Object::Default());

is replaced with:

let obj = JsObject::empty();

Also made the JsObject::new method private, because we only used it in the latter expression and in a few tests that can perfectly use from_proto_and_data

@github-actions
Copy link

github-actions bot commented Sep 9, 2021

Test262 conformance changes:

Test result master count PR count difference
Total 80,930 80,930 0
Passed 36,864 36,864 0
Ignored 12,690 12,690 0
Failed 31,376 31,376 0
Panics 0 0 0
Conformance 45.55% 45.55% 0.00%

@jedel1043
Copy link
Member Author

Holding the ready for review until #1445 merges

@jedel1043 jedel1043 force-pushed the object_creation branch 2 times, most recently from 9290996 to b4639cb Compare October 4, 2021 09:53
@jedel1043 jedel1043 requested review from RageKnify, raskad and HalidOdat and removed request for RageKnify October 4, 2021 10:02
@jedel1043 jedel1043 marked this pull request as ready for review October 4, 2021 10:02
@jedel1043 jedel1043 requested a review from Razican October 4, 2021 10:02
boa/src/object/gcobject.rs Outdated Show resolved Hide resolved
Copy link
Member

@RageKnify RageKnify left a comment

Choose a reason for hiding this comment

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

LGTM, Razican's proposal sounds like a nice QoL improvement.

@jedel1043 jedel1043 requested a review from Razican October 4, 2021 17:47
Copy link
Member

@Razican Razican left a comment

Choose a reason for hiding this comment

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

Looks good, just needs a rebase :)

@jedel1043 jedel1043 merged commit e1c573a into master Oct 5, 2021
@jedel1043 jedel1043 deleted the object_creation branch October 5, 2021 03:28
@raskad raskad added this to the v0.14.0 milestone Oct 5, 2021
@RageKnify RageKnify added the Internal Category for changelog label Jan 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internal Category for changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants