-
Notifications
You must be signed in to change notification settings - Fork 11
docs(design):anony fntype as field mapped named fntype and refer #449
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #449 +/- ##
=======================================
Coverage 84.38% 84.38%
=======================================
Files 27 27
Lines 2728 2728
=======================================
Hits 2302 2302
Misses 385 385
Partials 41 41 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
6855c85 to
ff94ed7
Compare
ff94ed7 to
5edc2b9
Compare
doc/en/dev/llcppg.md
Outdated
| LLGo cannot use anonymous function types directly as field types. To preserve type information, llcppg automatically generates named function types and references them in the field and following this naming convention: | ||
| ``` | ||
| LLGO_<namespaces>_<typename>_<nested_field_typename>_<fieldname> | ||
| ``` |
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.
Based on our discussion in the meeting: In C, an anonymous function's type is not accessible from the outside. To follow this same rule in Go, we'll make the auto-generated type unexported, which still allows the field to be assigned correctly.
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.
Done in 545cb07
24e8d8a to
545cb07
Compare
| To work around LLGo's inability to use anonymous function types directly in struct fields, llcppg automatically generates a corresponding named function type. This generated type is intentionally made unexported (private) to mirror C/C++ semantics, where anonymous function types are not externally accessible. Crucially, even though the type itself is private, this does not affect the ability to assign a compatible function to the field during normal use in Go. All such function types follow the specific naming convention: | ||
|
|
||
| ``` | ||
| llgo_<namespaces>_<typename>_<nested_field_typename>_<fieldname> |
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.
Although the design llgo_<namespaces>_<typename>_<nested_field_typename>_<fieldname> improves code readability to some extent, it compromises the original data structure. This is because the original code features a function pointer within a nested struct.
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.
in llgo, when you refer a func type which is comment with llgo:type C,it is actual a pointer in data structure
design for #448
To work around LLGo's inability to use anonymous function types directly in struct fields, llcppg automatically generates a corresponding named function type. This generated type is intentionally made unexported (private) to mirror C/C++ semantics, where anonymous function types are not externally accessible. Crucially, even though the type itself is private, this does not affect the ability to assign a compatible function to the field during normal use in Go. All such function types follow the specific naming convention: