From dfb31b8aa805d8b35a6f5572ee060d9912f69013 Mon Sep 17 00:00:00 2001 From: Nick Ufer Date: Wed, 4 Dec 2024 20:23:44 +0100 Subject: [PATCH] refactor(1089): update index types from int to size_t --- bindings/c/cross.cpp | 4 ++-- bindings/c/include/manifold/manifoldc.h | 18 +++++++++--------- bindings/c/manifoldc.cpp | 14 +++++++------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/bindings/c/cross.cpp b/bindings/c/cross.cpp index d05e07e46..d91ad78f0 100644 --- a/bindings/c/cross.cpp +++ b/bindings/c/cross.cpp @@ -59,12 +59,12 @@ size_t manifold_cross_section_vec_length(ManifoldCrossSectionVec *csv) { } ManifoldCrossSection *manifold_cross_section_vec_get( - void *mem, ManifoldCrossSectionVec *csv, int idx) { + void *mem, ManifoldCrossSectionVec *csv, size_t idx) { auto cs = (*from_c(csv))[idx]; return to_c(new (mem) CrossSection(cs)); } -void manifold_cross_section_vec_set(ManifoldCrossSectionVec *csv, int idx, +void manifold_cross_section_vec_set(ManifoldCrossSectionVec *csv, size_t idx, ManifoldCrossSection *cs) { (*from_c(csv))[idx] = *from_c(cs); } diff --git a/bindings/c/include/manifold/manifoldc.h b/bindings/c/include/manifold/manifoldc.h index 580b098dc..7d955fff5 100644 --- a/bindings/c/include/manifold/manifoldc.h +++ b/bindings/c/include/manifold/manifoldc.h @@ -30,14 +30,14 @@ ManifoldPolygons *manifold_polygons(void *mem, ManifoldSimplePolygon **ps, size_t length); size_t manifold_simple_polygon_length(ManifoldSimplePolygon *p); size_t manifold_polygons_length(ManifoldPolygons *ps); -size_t manifold_polygons_simple_length(ManifoldPolygons *ps, int idx); +size_t manifold_polygons_simple_length(ManifoldPolygons *ps, size_t idx); ManifoldVec2 manifold_simple_polygon_get_point(ManifoldSimplePolygon *p, - int idx); + size_t idx); ManifoldSimplePolygon *manifold_polygons_get_simple(void *mem, ManifoldPolygons *ps, - int idx); -ManifoldVec2 manifold_polygons_get_point(ManifoldPolygons *ps, int simple_idx, - int pt_idx); + size_t idx); +ManifoldVec2 manifold_polygons_get_point(ManifoldPolygons *ps, + size_t simple_idx, size_t pt_idx); // Mesh Construction @@ -88,8 +88,8 @@ ManifoldManifoldVec *manifold_manifold_vec(void *mem, size_t sz); void manifold_manifold_vec_reserve(ManifoldManifoldVec *ms, size_t sz); size_t manifold_manifold_vec_length(ManifoldManifoldVec *ms); ManifoldManifold *manifold_manifold_vec_get(void *mem, ManifoldManifoldVec *ms, - int idx); -void manifold_manifold_vec_set(ManifoldManifoldVec *ms, int idx, + size_t idx); +void manifold_manifold_vec_set(ManifoldManifoldVec *ms, size_t idx, ManifoldManifold *m); void manifold_manifold_vec_push_back(ManifoldManifoldVec *ms, ManifoldManifold *m); @@ -243,8 +243,8 @@ void manifold_cross_section_vec_reserve(ManifoldCrossSectionVec *csv, size_t sz); size_t manifold_cross_section_vec_length(ManifoldCrossSectionVec *csv); ManifoldCrossSection *manifold_cross_section_vec_get( - void *mem, ManifoldCrossSectionVec *csv, int idx); -void manifold_cross_section_vec_set(ManifoldCrossSectionVec *csv, int idx, + void *mem, ManifoldCrossSectionVec *csv, size_t idx); +void manifold_cross_section_vec_set(ManifoldCrossSectionVec *csv, size_t idx, ManifoldCrossSection *cs); void manifold_cross_section_vec_push_back(ManifoldCrossSectionVec *csv, ManifoldCrossSection *cs); diff --git a/bindings/c/manifoldc.cpp b/bindings/c/manifoldc.cpp index ca40b344b..78795eb1a 100644 --- a/bindings/c/manifoldc.cpp +++ b/bindings/c/manifoldc.cpp @@ -73,24 +73,24 @@ size_t manifold_polygons_length(ManifoldPolygons *ps) { return from_c(ps)->size(); } -size_t manifold_polygons_simple_length(ManifoldPolygons *ps, int idx) { +size_t manifold_polygons_simple_length(ManifoldPolygons *ps, size_t idx) { return (*from_c(ps))[idx].size(); } ManifoldVec2 manifold_simple_polygon_get_point(ManifoldSimplePolygon *p, - int idx) { + size_t idx) { return to_c((*from_c(p))[idx]); } ManifoldSimplePolygon *manifold_polygons_get_simple(void *mem, ManifoldPolygons *ps, - int idx) { + size_t idx) { auto sp = (*from_c(ps))[idx]; return to_c(new (mem) SimplePolygon(sp)); } -ManifoldVec2 manifold_polygons_get_point(ManifoldPolygons *ps, int simple_idx, - int pt_idx) { +ManifoldVec2 manifold_polygons_get_point(ManifoldPolygons *ps, + size_t simple_idx, size_t pt_idx) { return to_c((*from_c(ps))[simple_idx][pt_idx]); } @@ -111,12 +111,12 @@ size_t manifold_manifold_vec_length(ManifoldManifoldVec *ms) { } ManifoldManifold *manifold_manifold_vec_get(void *mem, ManifoldManifoldVec *ms, - int idx) { + size_t idx) { auto m = (*from_c(ms))[idx]; return to_c(new (mem) Manifold(m)); } -void manifold_manifold_vec_set(ManifoldManifoldVec *ms, int idx, +void manifold_manifold_vec_set(ManifoldManifoldVec *ms, size_t idx, ManifoldManifold *m) { (*from_c(ms))[idx] = *from_c(m); }