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

#274 Remove [[Enumerate]] and associated reflective capabilities #976

Merged
merged 11 commits into from
Aug 26, 2016

Conversation

leirocks
Copy link
Contributor

@leirocks leirocks commented May 12, 2016

#274 Remove [[Enumerate]] and associated reflective capabilities

Fixes #274

@leirocks
Copy link
Contributor Author

@Yongqu can you review?


var proxy = new Proxy({x:1}, {
ownKeys: function() {
return ['a','b'];
Copy link
Contributor

Choose a reason for hiding this comment

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

add a test case with returning symbol?

@Yongqu
Copy link
Contributor

Yongqu commented May 16, 2016

BOOL JavascriptProxy::GetEnumerator(BOOL enumNonEnumerable, Var* enumerator, ScriptContext * requestContext, bool preferSnapshotSemantics, bool enumSymbols)

we need to cleanup all the comments, and basically implements EnumerateObjectProperties, going through prototype etc. Please also cleanup the comments. hmm we shouldn't go through the prototype here as the forin enumerator will go through the prototype chain. but we need to enumerate only enumerable properties. #Closed


Refers to: lib/Runtime/Library/JavascriptProxy.cpp:855 in b74d582. [](commit_id = b74d582, deletion_comment = False)

});

var keys=""
for(var key in proxy){ keys += key;}
Copy link
Contributor

Choose a reason for hiding this comment

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

test case with proxy on the prototype

*enumerator = IteratorObjectEnumerator::Create(scriptContext, trapResult);

JavascriptArray* arrTrapResult = JavascriptArray::FromVar(trapResult);
uint32 len = arrTrapResult->GetLength();
Copy link
Contributor

Choose a reason for hiding this comment

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

check the return is JavascriptArray

Copy link
Contributor Author

@leirocks leirocks May 19, 2016

Choose a reason for hiding this comment

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

checked above: JavascriptOperators::IsArray
do you mean we need to check with JavascriptArray::Is()? #Resolved

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm interesting. JavascriptOperators::IsArray() is true for proxy over array. you can't cast it to JavascriptArray if the trapResult is a proxy.


In reply to: 63961681 [](ancestors = 63961681)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

need a generic method to iterate the array (or array like) elements? do we have such method?


In reply to: 63966947 [](ancestors = 63966947,63961681)

@Yongqu
Copy link
Contributor

Yongqu commented May 25, 2016

    // 1. Assert: Either Type(V) is Object or Type(V) is Null.

I think we should just call JavascriptOperators::GetOwnPropertyNames(this, scriptContext) to get the propertyNames.


Refers to: lib/Runtime/Library/JavascriptProxy.cpp:886 in ceae1ba. [](commit_id = ceae1ba, deletion_comment = False)


Var arrayIterator = JavascriptOperators::GetIterator(RecyclableObject::FromVar(trapResult), scriptContext);
*enumerator = IteratorObjectEnumerator::Create(scriptContext, arrayIterator);

return TRUE;
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of iterators, it's easier to use enumerator. You can see the code in JavascriptObject::CreateKeysHelper, in similar pattern.

@leirocks
Copy link
Contributor Author

leirocks commented Jun 6, 2016

    // 1. Assert: Either Type(V) is Object or Type(V) is Null.

done


In reply to: 221716949 [](ancestors = 221716949)


Refers to: lib/Runtime/Library/JavascriptProxy.cpp:886 in c542fd8. [](commit_id = c542fd8, deletion_comment = False)

// 13.7.5.15EnumerateObjectProperties(O)#
// for (let key of Reflect.ownKeys(obj)) {
Var trapResult = JavascriptOperators::GetOwnPropertyNames(this, scriptContext);
Assert(JavascriptArray::Is(trapResult));
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer a check in runtime then just Assert, at least a defense in depth.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@Yongqu
Copy link
Contributor

Yongqu commented Jun 6, 2016

:shipit:

@dilijev
Copy link
Contributor

dilijev commented Jul 19, 2016

@leirocks any update on this?

check the property descriptor, only enumerable properties should be shown up
add test case for getPrototypeOf, and non-string values in ownKeys trap returning array
@chakrabot chakrabot merged commit 98557fd into chakra-core:master Aug 26, 2016
chakrabot pushed a commit that referenced this pull request Aug 26, 2016
…ctive capabilities

Merge pull request #976 from leirocks:proxyenumerator

#274 Remove [[Enumerate]] and associated reflective capabilities

Fixes #274
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.

6 participants