-
-
Notifications
You must be signed in to change notification settings - Fork 155
capi: Redefine object interfaces to use opaque pointer types #3537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the C API to use opaque pointer types for all Tvg_*
objects, improving encapsulation and clarity.
- Changed all
typedef struct _Tvg_X
declarations to pointer types (typedef struct _Tvg_X* Tvg_X
) - Updated function signatures in headers and implementations to accept handles (
Tvg_X
) instead of pointers-to-pointers - Adjusted example code to declare handles directly and removed unnecessary indirection
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/bindings/capi/tvgCapi.cpp | Updated all C API functions to use opaque pointer types |
src/bindings/capi/thorvg_capi.h | Changed typedefs and function declarations for handles |
examples/Capi.cpp | Refactored example code to use new opaque handle usage |
Comments suppressed due to low confidence (3)
examples/Capi.cpp:99
- The variables
color_stops2_get
andcnt
are not declared in this scope. You likely meant to passcolor_stops2
and the count3
(or a named count variable).
tvg_gradient_set_color_stops(grad_stroke, color_stops2_get, cnt);
examples/Capi.cpp:145
- Typo in comment: "Prapare" should be "Prepare".
//Prapare a dash for the stroke
src/bindings/capi/thorvg_capi.h:444
- The doc comment above this signature still refers to
canvas
as a pointer. Update parameter descriptions (@param canvas
) and return-value notes to reflect thatcanvas
is now an opaque handle, not a pointer-to-pointer.
TVG_API Tvg_Result tvg_swcanvas_set_target(Tvg_Canvas canvas, uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h, Tvg_Colorspace cs);
API breaks, but abstracts & simplifies the interface. Let's carefully confirm. |
bed6696
to
5838334
Compare
dc2d60a
to
8220c78
Compare
9ddde24
to
dac61de
Compare
Redefined Tvg_XXX and related types as pointers e.g., typedef struct _Tvg_Canvas* Tvg_Canvas) to improve encapsulation and clarity in API usage. issue: #3116
what about adding a |
Redefined Tvg_XXX and related types as pointers
e.g., typedef struct _Tvg_Canvas* Tvg_Canvas)
to improve encapsulation and clarity in API usage.
issue: #3116