Skip to content

Commit

Permalink
refactor(1089): update index types from int to size_t
Browse files Browse the repository at this point in the history
  • Loading branch information
NickUfer committed Dec 4, 2024
1 parent fb29e85 commit dfb31b8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions bindings/c/cross.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
18 changes: 9 additions & 9 deletions bindings/c/include/manifold/manifoldc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
14 changes: 7 additions & 7 deletions bindings/c/manifoldc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

Expand All @@ -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);
}
Expand Down

0 comments on commit dfb31b8

Please sign in to comment.