Add QueuingStrategy and UnderlyingSource#32572
Add QueuingStrategy and UnderlyingSource#32572gterzian merged 13 commits intoservo:readablestream-re-implementationfrom
Conversation
|
@gterzian Here's the first PR to |
| cx: SafeJSContext, | ||
| _global: &GlobalScope, | ||
| _proto: Option<SafeHandleObject>, | ||
| underlying_source: Option<*mut JSObject>, |
There was a problem hiding this comment.
Could you please look into using UnderlyingSource here?
There was a problem hiding this comment.
But this is the signature required by the codegen.
And I think the spec also says it will convert to UnderlyingSource in step 2.
https://streams.spec.whatwg.org/#rs-constructor
| let global = self.reflector_.global(); | ||
| let cx = GlobalScope::get_cx(); | ||
| // Return this's relevant global object's count queuing strategy | ||
| // size function. | ||
| if let Some(fun) = global.get_count_queuing_strategy_size() { | ||
| return Ok(fun); | ||
| } | ||
|
|
||
| // Step 1. Let steps be the following steps: | ||
| // Note: See count_queuing_strategy_size instead. | ||
|
|
||
| unsafe { | ||
| // Step 2. Let F be | ||
| // ! CreateBuiltinFunction(steps, 0, "size", « », | ||
| // globalObject’s relevant Realm). | ||
| let raw_fun = JS_NewFunction( | ||
| *cx, | ||
| Some(count_queuing_strategy_size), | ||
| 0, | ||
| 0, | ||
| b"size\0".as_ptr() as *const c_char, | ||
| ); | ||
| assert!(!raw_fun.is_null()); | ||
|
|
||
| // Step 3. Set globalObject’s count queuing strategy size function to | ||
| // a Function that represents a reference to F, | ||
| // with callback context equal to globalObject’s relevant settings object. | ||
| let fun_obj = JS_GetFunctionObject(raw_fun); | ||
| let fun = Function::new(cx, fun_obj); | ||
| global.set_count_queuing_strategy_size(fun.clone()); | ||
| Ok(fun) |
There was a problem hiding this comment.
This is duplicated, but we will take care of it in another PR when we move this unsafe_code to dom/bindings.
There was a problem hiding this comment.
Yeah current Function creation still requires us to write unsafe c function. Maybe we can improve Function later.
gterzian
left a comment
There was a problem hiding this comment.
Great! Let's move the unsafe code do dom/bindings in a subsequent step...
--------- Co-authored-by: Jason Tsai <[email protected]> Signed-off-by: gterzian <[email protected]>
--------- Co-authored-by: Jason Tsai <[email protected]> Signed-off-by: gterzian <[email protected]>
--------- Co-authored-by: Jason Tsai <[email protected]> Signed-off-by: Wu Wayne <[email protected]>
--------- Co-authored-by: Jason Tsai <[email protected]> Signed-off-by: Wu Wayne <[email protected]>
This PR add QueuingStrategy and UnderlyingSource. The related types are also added but with
todo!()implementations../mach build -ddoes not report any errors./mach test-tidydoes not report any errors