-
Notifications
You must be signed in to change notification settings - Fork 0
Coding standards
We follow the Rust guidelines. Additional Servo-specific conventions follow.
Glob imports are additionally allowed in generated code, since the generator would be much more complex if it had to keep track of this.
Each crate contains its own platform-specific code - we don't have a single platform abstraction layer for all of servo.
some_crate/mod.rs
some_crate/platform/$(port_name)/mod.rs
$(port_name) is generally the same as a #[cfg(target_os = "...")] string.
If not inside platform, you never access platform::$(port_name)::mod, you access platform::mod. Within the platform module, we use conditional compilation, mostly with #[cfg(target_os = "...")] to make symbols appear in the right place. If we find ourselves with multiple ports for a single os we will use the custom port_name
cfg item to identify them and modify the build as appropriate.
Specification name == TypeName
Specification method == TypeName::MethodName
Non-standard method == TypeName::method_name
dom/lowercasespecname.rs => implementation
Except for ones for static methods that are called from generated code (everything that takes a GlobalRef
argument), the rest should following the Rust style guideline.