New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Port init-image-library to rust #1536
base: master
Are you sure you want to change the base?
Conversation
rust_src/src/image.rs
Outdated
use crate::{lisp::LispObject, remacs_sys::valid_image_p}; | ||
use crate::remacs_sys::valid_image_p; | ||
|
||
use crate::{lisp::LispObject, remacs_sys::lookup_image_type}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
group the `remacs_sys items together please.
This should be:
use crate::lisp::LispObject;
use crate::remacs_sys::{valid_image_p, lookup_image_type};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if that means moving the valid_image_p
out from under the #[cfg(feature = "glyph-debug")]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the glyph-debug
remains then import it separately. Maybe that is why the two other imports were grouped together? Was that done by you or by rustformat?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I grouped the imports as they are currently. lisp::LispObject
was needed by both init_image_library
and imagep
but valid_image_p
was only used by imagep
, which is under #[cfg(feature = "glyph-debug")]
. It felt right to only import valid_image_p
in the scenarios where it is needed. Happy to expose everything though if thats the preference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use crate::lisp::LispObject;
use remacs_sys::lookup_image_type;
Then see what rustformat does with it.....
rust_src/src/image.rs
Outdated
/// the library file(s) specified by `dynamic-library-alist'. | ||
#[lisp_fn] | ||
pub fn init_image_library(r#type: LispObject) -> bool { | ||
unsafe { lookup_image_type(r#type) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lookup_image_type
is declared static
in the C code. static
marks the function as only accessible to that C file. The name is not exposed. This is why Rust cannot see it. We often need to remove the static
modifier and then copy the function definition into a header so it will be visible to Rust.
4eb261c
to
7291918
Compare
@shaleh, so I got this branch to build on my local environment, and the smoke test I wrote is passing. TravisCI however is still failing. Any ideas? |
hmm, it appears to be dying because rustfmt is not installed for the linux without X Window System test case. That should be its own PR. Not sure why it is dying now.... Similarly, the Mac build is dying because it needs --without-makeinfo. |
So, neither of this Travis failures are actually related to this PR? Im happy to take a stab at those updates with some guidance. |
@shaleh Just following up on this. Are there any todo's for me on this PR or are there unrelated issues causing the test failures. |
Thanks for the reminder @benreyn. I need to look into this again. The code in the PR looks good. I would typically suggest not using the |
Kicking the PR, let's see what happens. |
I am fairly certain this will need to be rebased to succeed at the unit tests. |
Thanks for circling back on it @shaleh. Ill get it rebased sometime today. |
What was I thinking? Was I?
306fb79
to
a1c7a2a
Compare
@shaleh Just rebased and pushed. Lets see what Ci does 馃 |
Looks like CI is still failing here @shaleh. I havent had a chance to check it out locally and see whats going on. |
c07ff21
to
5e5270c
Compare
This function should not have the |
Thanks for catching that @shaleh. Im still learning the ins and outs of how Remacs is pieced together. |
No worries @benreyn. This is an odd project because of the mix of C and Rust. 'static' means a function is not exported from the C file it is declared in. For variables, they will automatically be set to zero. Not initialized -- zero. There is also a requirement in C that a function be declared before it is used. Which is why the function you were touching had two instances of it. One was a forward declaration on one line and the later the full definition. |
Hello there! 馃憢
Im excited about the opportunity to use remacs to help me get a better lower-level understanding of Rust, C, and Emacs.
My build is still failing due to...
Any pointers on how to expose
lookup_image_type
from C to Rust?Will close #1252