Skip to content

Commit 25602ce

Browse files
committed
add warnings
1 parent bdccaeb commit 25602ce

1 file changed

Lines changed: 26 additions & 31 deletions

File tree

  • crates/processing_ffi/src

crates/processing_ffi/src/lib.rs

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,8 +1012,8 @@ pub extern "C" fn processing_end_contour(graphics_id: u64) {
10121012
/// Load a font file and return a font entity ID.
10131013
/// Returns 0 on error.
10141014
///
1015-
/// SAFETY:
1016-
/// - path_ptr is a valid pointer to a null-terminated UTF-8 string.
1015+
/// # Safety
1016+
/// - path_ptr is a valid pointer to a null-terminated string.
10171017
#[unsafe(no_mangle)]
10181018
pub unsafe extern "C" fn processing_load_font(path_ptr: *const std::ffi::c_char) -> u64 {
10191019
error::clear_error();
@@ -1024,8 +1024,8 @@ pub unsafe extern "C" fn processing_load_font(path_ptr: *const std::ffi::c_char)
10241024
/// Create a font handle from an existing font family name.
10251025
/// Returns 0 on error.
10261026
///
1027-
/// SAFETY:
1028-
/// - name_ptr is a valid pointer to a null-terminated UTF-8 string.
1027+
/// # Safety
1028+
/// - name_ptr is a valid pointer to a null-terminated string.
10291029
#[unsafe(no_mangle)]
10301030
pub unsafe extern "C" fn processing_create_font(name_ptr: *const std::ffi::c_char) -> u64 {
10311031
error::clear_error();
@@ -1045,9 +1045,9 @@ pub extern "C" fn processing_font_variation_count(font_id: u64) -> u32 {
10451045
/// Query variable font axis info.
10461046
/// Writes tag (4 bytes), min, max, default to out buffer at the given index.
10471047
///
1048-
/// SAFETY:
1049-
/// - out_tag is a valid pointer to at least 4 bytes.
1050-
/// - out_min, out_max, out_default are valid pointers.
1048+
/// # Safety
1049+
/// - out_tag is a valid pointer to at least 4 writable bytes.
1050+
/// - out_min, out_max, out_default are valid pointers to writable f32 values.
10511051
#[unsafe(no_mangle)]
10521052
pub unsafe extern "C" fn processing_font_variation(
10531053
font_id: u64,
@@ -1096,9 +1096,8 @@ pub extern "C" fn processing_text_font(graphics_id: u64, font_id: u64) {
10961096

10971097
/// Draw text at a position.
10981098
///
1099-
/// SAFETY:
1100-
/// - graphics_id is a valid ID returned from graphics_create.
1101-
/// - str_ptr is a valid pointer to a null-terminated UTF-8 string.
1099+
/// # Safety
1100+
/// - str_ptr is a valid pointer to a null-terminated string.
11021101
#[unsafe(no_mangle)]
11031102
pub unsafe extern "C" fn processing_text(
11041103
graphics_id: u64,
@@ -1128,9 +1127,8 @@ pub unsafe extern "C" fn processing_text(
11281127

11291128
/// Draw text at a 3D position.
11301129
///
1131-
/// SAFETY:
1132-
/// - graphics_id is a valid ID returned from graphics_create.
1133-
/// - str_ptr is a valid pointer to a null-terminated UTF-8 string.
1130+
/// # Safety
1131+
/// - str_ptr is a valid pointer to a null-terminated string.
11341132
#[unsafe(no_mangle)]
11351133
pub unsafe extern "C" fn processing_text_3d(
11361134
graphics_id: u64,
@@ -1203,9 +1201,8 @@ pub extern "C" fn processing_text_float(graphics_id: u64, value: f32, x: f32, y:
12031201

12041202
/// Draw text within a bounding box (with word wrapping).
12051203
///
1206-
/// SAFETY:
1207-
/// - graphics_id is a valid ID returned from graphics_create.
1208-
/// - str_ptr is a valid pointer to a null-terminated UTF-8 string.
1204+
/// # Safety
1205+
/// - str_ptr is a valid pointer to a null-terminated string.
12091206
#[unsafe(no_mangle)]
12101207
pub unsafe extern "C" fn processing_text_box(
12111208
graphics_id: u64,
@@ -1245,10 +1242,9 @@ pub extern "C" fn processing_text_style(graphics_id: u64, style: u8) {
12451242

12461243
/// Compute the bounding box of text. Writes [x, y, w, h] to out_bounds.
12471244
///
1248-
/// SAFETY:
1249-
/// - graphics_id is a valid ID returned from graphics_create.
1250-
/// - str_ptr is a valid pointer to a null-terminated UTF-8 string.
1251-
/// - out_bounds is a valid pointer to a float array of at least 4 elements.
1245+
/// # Safety
1246+
/// - str_ptr is a valid pointer to a null-terminated string.
1247+
/// - out_bounds is a valid pointer to a writable float array of at least 4 elements.
12521248
#[unsafe(no_mangle)]
12531249
pub unsafe extern "C" fn processing_text_bounds(
12541250
graphics_id: u64,
@@ -1274,8 +1270,8 @@ pub unsafe extern "C" fn processing_text_bounds(
12741270

12751271
/// Set a font variation axis value (e.g. "wdth", 75.0).
12761272
///
1277-
/// SAFETY:
1278-
/// - tag_ptr is a valid pointer to a null-terminated UTF-8 string of exactly 4 characters.
1273+
/// # Safety
1274+
/// - tag_ptr is a valid pointer to a null-terminated string.
12791275
#[unsafe(no_mangle)]
12801276
pub unsafe extern "C" fn processing_text_variation(
12811277
graphics_id: u64,
@@ -1298,8 +1294,8 @@ pub extern "C" fn processing_clear_text_variations(graphics_id: u64) {
12981294

12991295
/// Enable/configure an OpenType font feature (e.g. "smcp", 1).
13001296
///
1301-
/// SAFETY:
1302-
/// - tag_ptr is a valid pointer to a null-terminated UTF-8 string of exactly 4 characters.
1297+
/// # Safety
1298+
/// - tag_ptr is a valid pointer to a null-terminated string.
13031299
#[unsafe(no_mangle)]
13041300
pub unsafe extern "C" fn processing_text_feature(
13051301
graphics_id: u64,
@@ -1314,8 +1310,8 @@ pub unsafe extern "C" fn processing_text_feature(
13141310

13151311
/// Disable an OpenType font feature.
13161312
///
1317-
/// SAFETY:
1318-
/// - tag_ptr is a valid pointer to a null-terminated UTF-8 string of exactly 4 characters.
1313+
/// # Safety
1314+
/// - tag_ptr is a valid pointer to a null-terminated string.
13191315
#[unsafe(no_mangle)]
13201316
pub unsafe extern "C" fn processing_no_text_feature(
13211317
graphics_id: u64,
@@ -1338,8 +1334,8 @@ pub extern "C" fn processing_clear_text_features(graphics_id: u64) {
13381334
/// Set per-glyph colors for the next text() call.
13391335
/// colors_ptr points to an array of (r, g, b, a) float tuples.
13401336
///
1341-
/// SAFETY:
1342-
/// - colors_ptr is a valid pointer to count * 4 floats.
1337+
/// # Safety
1338+
/// - colors_ptr is a valid pointer to count * 4 readable floats.
13431339
#[unsafe(no_mangle)]
13441340
pub unsafe extern "C" fn processing_text_glyph_colors(
13451341
graphics_id: u64,
@@ -1401,9 +1397,8 @@ pub extern "C" fn processing_text_wrap(graphics_id: u64, mode: u8) {
14011397

14021398
/// Measure the width of text.
14031399
///
1404-
/// SAFETY:
1405-
/// - graphics_id is a valid ID returned from graphics_create.
1406-
/// - str_ptr is a valid pointer to a null-terminated UTF-8 string.
1400+
/// # Safety
1401+
/// - str_ptr is a valid pointer to a null-terminated string.
14071402
#[unsafe(no_mangle)]
14081403
pub unsafe extern "C" fn processing_text_width(
14091404
graphics_id: u64,

0 commit comments

Comments
 (0)