mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Replace null-byte terminated string literals with C-string literals (#32716)
* simple conversion from byte string to c-string Signed-off-by: Bum Kim <bumcrystlbum@gmail.com> * convert byte strings to c-strings to c_char ptr Signed-off-by: Bum Kim <bumcrystlbum@gmail.com> --------- Signed-off-by: Bum Kim <bumcrystlbum@gmail.com>
This commit is contained in:
parent
59d0f1fe1a
commit
141a594e23
6 changed files with 29 additions and 29 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
use std::cell::Cell;
|
||||
use std::collections::VecDeque;
|
||||
use std::ffi::CStr;
|
||||
use std::rc::Rc;
|
||||
use std::{mem, ptr};
|
||||
|
||||
|
@ -143,7 +144,7 @@ impl CustomElementRegistry {
|
|||
if !JS_GetProperty(
|
||||
*GlobalScope::get_cx(),
|
||||
constructor,
|
||||
b"prototype\0".as_ptr() as *const _,
|
||||
c"prototype".as_ptr(),
|
||||
prototype,
|
||||
) {
|
||||
return Err(Error::JSFailed);
|
||||
|
@ -168,10 +169,10 @@ impl CustomElementRegistry {
|
|||
|
||||
// Step 4
|
||||
Ok(LifecycleCallbacks {
|
||||
connected_callback: get_callback(cx, prototype, b"connectedCallback\0")?,
|
||||
disconnected_callback: get_callback(cx, prototype, b"disconnectedCallback\0")?,
|
||||
adopted_callback: get_callback(cx, prototype, b"adoptedCallback\0")?,
|
||||
attribute_changed_callback: get_callback(cx, prototype, b"attributeChangedCallback\0")?,
|
||||
connected_callback: get_callback(cx, prototype, c"connectedCallback")?,
|
||||
disconnected_callback: get_callback(cx, prototype, c"disconnectedCallback")?,
|
||||
adopted_callback: get_callback(cx, prototype, c"adoptedCallback")?,
|
||||
attribute_changed_callback: get_callback(cx, prototype, c"attributeChangedCallback")?,
|
||||
|
||||
form_associated_callback: None,
|
||||
form_disabled_callback: None,
|
||||
|
@ -191,11 +192,11 @@ impl CustomElementRegistry {
|
|||
let cx = self.window.get_cx();
|
||||
|
||||
callbacks.form_associated_callback =
|
||||
get_callback(cx, prototype, b"formAssociatedCallback\0")?;
|
||||
callbacks.form_reset_callback = get_callback(cx, prototype, b"formResetCallback\0")?;
|
||||
callbacks.form_disabled_callback = get_callback(cx, prototype, b"formDisabledCallback\0")?;
|
||||
get_callback(cx, prototype, c"formAssociatedCallback")?;
|
||||
callbacks.form_reset_callback = get_callback(cx, prototype, c"formResetCallback")?;
|
||||
callbacks.form_disabled_callback = get_callback(cx, prototype, c"formDisabledCallback")?;
|
||||
callbacks.form_state_restore_callback =
|
||||
get_callback(cx, prototype, b"formStateRestoreCallback\0")?;
|
||||
get_callback(cx, prototype, c"formStateRestoreCallback")?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -208,7 +209,7 @@ impl CustomElementRegistry {
|
|||
!JS_GetProperty(
|
||||
*cx,
|
||||
constructor,
|
||||
b"observedAttributes\0".as_ptr() as *const _,
|
||||
c"observedAttributes".as_ptr(),
|
||||
observed_attributes.handle_mut(),
|
||||
)
|
||||
} {
|
||||
|
@ -243,7 +244,7 @@ impl CustomElementRegistry {
|
|||
!JS_GetProperty(
|
||||
*cx,
|
||||
constructor,
|
||||
b"formAssociated\0".as_ptr() as *const _,
|
||||
c"formAssociated".as_ptr(),
|
||||
form_associated_value.handle_mut(),
|
||||
)
|
||||
} {
|
||||
|
@ -273,7 +274,7 @@ impl CustomElementRegistry {
|
|||
!JS_GetProperty(
|
||||
*cx,
|
||||
constructor,
|
||||
b"disabledFeatures\0".as_ptr() as *const _,
|
||||
c"disabledFeatures".as_ptr(),
|
||||
disabled_features.handle_mut(),
|
||||
)
|
||||
} {
|
||||
|
@ -305,7 +306,7 @@ impl CustomElementRegistry {
|
|||
fn get_callback(
|
||||
cx: JSContext,
|
||||
prototype: HandleObject,
|
||||
name: &[u8],
|
||||
name: &CStr,
|
||||
) -> Fallible<Option<Rc<Function>>> {
|
||||
rooted!(in(*cx) let mut callback = UndefinedValue());
|
||||
unsafe {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue