Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upReplaced constant fixed-length u8 vectors with byte strings (fixes #3257) #3324
Conversation
hoppipolla-critic-bot
commented
Sep 13, 2014
|
Critic review: https://critic.hoppipolla.co.uk/r/2586 This is an external review system which you may optionally use for the code review of your pull request. In order to help critic track your changes, please do not make in-place history rewrites (e.g. via |
highfive
commented
Sep 13, 2014
|
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @larsbergstrom (or someone else) soon. |
|
Just saw that the Travis CI build failed. Pushed a new commit to fix this. |
|
Nice to see you taking interest in Servo! :D |
|
I put the parenthesis to fix the Travis CI build error at the wrong place; pushed a new commit to fix this. |
|
With regards to the eventtarget error, you can just change the casts at http://mxr.mozilla.org/servo/source/components/script/dom/eventtarget.rs#182 and http://mxr.mozilla.org/servo/source/components/script/dom/eventtarget.rs#190 to be what you need. |
…string in eventtarget.rs
|
With the help of Ms2ger and huon on IRC, I found a way to make the byte strings in eventtarget.rs work. I also fixed the latest Travis build error. Because the codegen apparently doesn't run automatically (and I have no idea how to run in manually), I could not check whether I still have got more errors, so I'll have to wait for the Travis CI build to see that. |
|
|
||
| decls = ''.join([stringDecl(m) for m in array]) | ||
| return decls + self.generatePrefableArray( | ||
| array, name, | ||
| ' JSFunctionSpec {name: &%s_name as *const u8 as *const libc::c_char, call: JSNativeWrapper {op: Some(%s), info: %s}, nargs: %s, flags: %s as u16, selfHostedName: 0 as *const libc::c_char }', | ||
| ' JSFunctionSpec {name: %s_name.as_ptr() as *const u8 as *const libc::c_char, call: JSNativeWrapper {op: Some(%s), info: %s}, nargs: %s, flags: %s as u16, selfHostedName: 0 as *const libc::c_char }', |
This comment has been minimized.
This comment has been minimized.
jdm
Sep 14, 2014
Member
Ah yes, this won't work since we can't call functions in constants. Maybe &%s_name[0] instead?
This comment has been minimized.
This comment has been minimized.
huonw
Sep 14, 2014
Contributor
(It may hit rust-lang/rust#17233, depending on how s_name is created.)
|
|
||
| decls = ''.join([stringDecl(m) for m in array]) | ||
|
|
||
| return decls + self.generatePrefableArray( | ||
| array, name, | ||
| ' JSPropertySpec { name: &%s_name as *const u8 as *const libc::c_char, tinyid: 0, flags: ((%s) & 0xFF) as u8, getter: %s, setter: %s }', | ||
| ' JSPropertySpec { name: %s_name.as_ptr() as *const u8 as *const libc::c_char, tinyid: 0, flags: ((%s) & 0xFF) as u8, getter: %s, setter: %s }', |
This comment has been minimized.
This comment has been minimized.
| static Class: DOMJSClass = DOMJSClass { | ||
| base: js::Class { | ||
| name: &Class_name as *const u8 as *const libc::c_char, | ||
| name: Class_name.as_ptr() as *const u8 as *const libc::c_char, |
This comment has been minimized.
This comment has been minimized.
| static PrototypeClass: JSClass = JSClass { | ||
| name: &PrototypeClassName__ as *const u8 as *const libc::c_char, | ||
| name: PrototypeClassName__.as_ptr() as *const u8 as *const libc::c_char, |
This comment has been minimized.
This comment has been minimized.
|
@jdm I tried
I also tried to use functions instead of static variables, and creating a local non-static variable inside that function to perform the casting, but that didn't work; it said that function calls are only allowed in constructors, and I had to use it inside a static class. |
|
Yeah, I think the LLVM problem is rust-lang/rust#17233, so we might be stuck until that gets fixed. |
|
Alright, then I'll wait until that's fixed. |
|
Does this work now? |
|
@Manishearth The linked issue is still open, so I'd say it doesn't. (I would test it, but I don't know what exactly to test for -- I did many different things to try to make it work) |
thomas-daniels commentedSep 13, 2014
Replaced constant fixed-length u8 vectors in CodegenRust.py with byte strings (fixes #3257).
@jdm said that there is also an occurrence of a fixed-length vector in eventtarget.rs. I found this one, but when I tried to replace it, it gave errors (because it is not a
u8vector but ac_charvector). When I replaced it withb"...", it said:And when I did the same but with dropping the
b(so, by changing it to"..."), it said:I don't know whether there are other prefixes for the strings to make this work, but if there are, let me know and I'll use it there.