JFLib

1. Rules of the code base#

  • #![no_std], no foreign crates. Only core and alloc may be extern crated. Every crate and app is a Cargo package of the workspace in the root Cargo.toml; build_rs.py checks the sources (python build_rs.py check --quick runs the lint alone), refuses std or a foreign dependency, and builds through Cargo. Edition 2024, so gen is a keyword.
  • An app of your own is best #![no_std] too: JFLib's runtime brings the entry point, the panic handler and the allocator, and other no_std crates are allowed there. An app that needs a crate with std turns on the feature std of jflib (An app with std): std brings those three then, and every std crate links. Code that makes system calls of its own (std::fs, windows-sys, rustix and the like) passes by plat, so PERMISSIONS does not see it: only the sandbox line confines it, as far as the operating system enforces the manifest (PERMISSIONS.md, "OS sandbox"). The rules below are this repository's; an app of your own may follow them as it likes.
  • unsafe only in rt, simd, plat and gpu. Every other library and style crate has #![forbid(unsafe_code)]; apps have #![deny(unsafe_code)], whose only exception is the ui::main! entry point. The safe interfaces of those four crates are all an app needs.
  • No system libraries beyond kernel32 / user32 / gdi32 on Windows (other DLLs only through GetProcAddress, inside plat), nothing but syscalls on Linux. Fonts, icons and codecs are the library's own.
  • Warnings fail the build (-D warnings).
  • Float code keeps a fixed operation order where results must be reproducible: no FMA, rt::fx for the SSE conversions (cvtt, cvtd, minsd, ...), rt::x87 for the x87 steps. This matters for library code that must stay bit-identical to the assembly reference; app code only needs it when it promises reproducible output.
  • Strings are UTF-8 everywhere; the apps' UI texts are German.
  • Colours in the API are 0xAARRGGBB, straight alpha. Images and layers are premultiplied (gfx::FMT_PARGB); effects work on straight FMT_ARGB.

Source: docs/GUIDE.md in the JFLib repository.