Split off StructuredClone from ScriptInterface

Follows 34b1920e7b.

This separates StructuredClone & DeepCopy logic into its own header,
reducing the size of the monolithic ScriptInterface header.

Differential Revision: https://code.wildfiregames.com/D3922
This was SVN commit r25419.
This commit is contained in:
wraitii
2021-05-10 11:51:32 +00:00
parent ad62707eef
commit 6fbf036ae4
29 changed files with 266 additions and 180 deletions
-22
View File
@@ -48,8 +48,6 @@ ERROR_TYPE(Scripting_DefineType, CreationFailed);
// but as large as necessary for all wrapped functions)
#define SCRIPT_INTERFACE_MAX_ARGS 8
class JSStructuredCloneData;
class ScriptInterface;
struct ScriptInterface_impl;
@@ -314,26 +312,6 @@ public:
*/
bool MathRandom(double& nbr);
/**
* Structured clones are a way to serialize 'simple' JS::Values into a buffer
* that can safely be passed between compartments and between threads.
* A StructuredClone can be stored and read multiple times if desired.
* We wrap them in shared_ptr so memory management is automatic and
* thread-safe.
*/
using StructuredClone = shared_ptr<JSStructuredCloneData>;
StructuredClone WriteStructuredClone(JS::HandleValue v) const;
void ReadStructuredClone(const StructuredClone& ptr, JS::MutableHandleValue ret) const;
/**
* Construct a new value (usable in this ScriptInterface's compartment) by cloning
* a value from a different compartment.
* Complex values (functions, XML, etc) won't be cloned correctly, but basic
* types and cyclic references should be fine.
*/
JS::Value CloneValueFromOtherCompartment(const ScriptInterface& otherCompartment, JS::HandleValue val) const;
/**
* Retrieve the private data field of a JSObject that is an instance of the given JSClass.
*/