1
0
forked from mirrors/0ad

Rework ScriptInterface EnumeratePropertyNames to support non-enumerable properties.

This lets it support the JSClass syntax, introduced for components in
5fb88172a2/D2492, which required a workaround before.
As cleanup, remove the prefix logic which was too specific to be in
ScriptInterface, and use an upstream-compatible API that also does more
of what we want.

Based on a patch by: elexis
Differential Revision: https://code.wildfiregames.com/D2644
This was SVN commit r23771.
This commit is contained in:
wraitii
2020-06-14 09:49:32 +00:00
parent bea7a65389
commit 4b1a4ef4cf
5 changed files with 58 additions and 76 deletions
+9 -1
View File
@@ -212,7 +212,15 @@ public:
*/
bool HasProperty(JS::HandleValue obj, const char* name) const;
bool EnumeratePropertyNamesWithPrefix(JS::HandleValue objVal, const char* prefix, std::vector<std::string>& out) const;
/**
* Returns all properties of the object, both own properties and inherited.
* This is essentially equivalent to calling Object.getOwnPropertyNames()
* and recursing up the prototype chain.
* NB: this does not return properties with symbol or numeric keys, as that would
* require a variant in the vector, and it's not useful for now.
* @param enumerableOnly - only return enumerable properties.
*/
bool EnumeratePropertyNames(JS::HandleValue objVal, bool enumerableOnly, std::vector<std::string>& out) const;
bool SetPrototype(JS::HandleValue obj, JS::HandleValue proto);