mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
script: Use the new C string literal in the DOM bindings (#32741)
* simple conversion to cstrings using as_ptr() Signed-off-by: Bum Kim <bumcrystlbum@gmail.com> * replaced byte strings with c strings using new helper functions Signed-off-by: Bum Kim <bumcrystlbum@gmail.com> * changed &[u8] type parameters to &CStr Signed-off-by: Bum Kim <bumcrystlbum@gmail.com> --------- Signed-off-by: Bum Kim <bumcrystlbum@gmail.com>
This commit is contained in:
parent
3e163bfcdb
commit
c6cb7ee981
6 changed files with 60 additions and 63 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
//! Machinery to initialise namespace objects.
|
||||
|
||||
use std::ffi::CStr;
|
||||
use std::ptr;
|
||||
|
||||
use js::jsapi::{JSClass, JSFunctionSpec};
|
||||
|
@ -22,9 +23,9 @@ unsafe impl Sync for NamespaceObjectClass {}
|
|||
|
||||
impl NamespaceObjectClass {
|
||||
/// Create a new `NamespaceObjectClass` structure.
|
||||
pub const unsafe fn new(name: &'static [u8]) -> Self {
|
||||
pub const unsafe fn new(name: &'static CStr) -> Self {
|
||||
NamespaceObjectClass(JSClass {
|
||||
name: name as *const _ as *const libc::c_char,
|
||||
name: name.as_ptr(),
|
||||
flags: 0,
|
||||
cOps: 0 as *mut _,
|
||||
spec: ptr::null(),
|
||||
|
@ -43,7 +44,7 @@ pub fn create_namespace_object(
|
|||
class: &'static NamespaceObjectClass,
|
||||
methods: &[Guard<&'static [JSFunctionSpec]>],
|
||||
constants: &[Guard<&'static [ConstantSpec]>],
|
||||
name: &[u8],
|
||||
name: &CStr,
|
||||
rval: MutableHandleObject,
|
||||
) {
|
||||
create_object(cx, global, proto, &class.0, methods, &[], constants, rval);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue