mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Miscellaneous script splitting preparation changes (#36216)
* script: Move num module to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Make JS reflector creation generic over DOM trait. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Move bindings-specific lock to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Move DOM proto array code to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Move finalizer implementations to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Move some error routines to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Move some DOM interface conversion routines to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Make is_array_like generic over DOM trait. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Use generic interfaces for conditional exposure functions. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Move a bunch of routines used by codegen to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Formatting. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Fix clippy warnings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
2c94110952
commit
c30ad5a30e
28 changed files with 836 additions and 691 deletions
|
@ -155,6 +155,7 @@ impl Callback for PipeTo {
|
|||
/// - the current state.
|
||||
/// - the type of `result`.
|
||||
/// - the state of a stored promise(in some cases).
|
||||
#[allow(unsafe_code)]
|
||||
fn callback(&self, cx: SafeJSContext, result: SafeHandleValue, realm: InRealm, can_gc: CanGc) {
|
||||
let global = self.reader.global();
|
||||
|
||||
|
@ -197,14 +198,16 @@ impl Callback for PipeTo {
|
|||
} else {
|
||||
rooted!(in(*cx) let object = result.to_object());
|
||||
rooted!(in(*cx) let mut done = UndefinedValue());
|
||||
get_dictionary_property(
|
||||
*cx,
|
||||
object.handle(),
|
||||
"done",
|
||||
done.handle_mut(),
|
||||
can_gc,
|
||||
)
|
||||
.unwrap()
|
||||
unsafe {
|
||||
get_dictionary_property(
|
||||
*cx,
|
||||
object.handle(),
|
||||
"done",
|
||||
done.handle_mut(),
|
||||
can_gc,
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
}
|
||||
};
|
||||
// If any chunks have been read but not yet written, write them to dest.
|
||||
|
@ -342,6 +345,7 @@ impl PipeTo {
|
|||
|
||||
/// Try to write a chunk using the jsval, and returns wether it succeeded
|
||||
// It will fail if it is the last `done` chunk, or if it is not a chunk at all.
|
||||
#[allow(unsafe_code)]
|
||||
fn write_chunk(
|
||||
&self,
|
||||
cx: SafeJSContext,
|
||||
|
@ -352,9 +356,10 @@ impl PipeTo {
|
|||
if chunk.is_object() {
|
||||
rooted!(in(*cx) let object = chunk.to_object());
|
||||
rooted!(in(*cx) let mut bytes = UndefinedValue());
|
||||
let has_value =
|
||||
let has_value = unsafe {
|
||||
get_dictionary_property(*cx, object.handle(), "value", bytes.handle_mut(), can_gc)
|
||||
.expect("Chunk should have a value.");
|
||||
.expect("Chunk should have a value.")
|
||||
};
|
||||
if !bytes.is_undefined() && has_value {
|
||||
// Write the chunk.
|
||||
let write_promise = self.writer.write(cx, global, bytes.handle(), can_gc);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue