Comments (8)
Yeah, it kinda sucks. It's still 100x easier to use than the raw bindings.
The libclang
API is just really awkward, even as C APIs go.
from clang-rs.
from clang-rs.
Interesting, I hadn't thought about that.
Another idea would be to leave Entity
as a struct but add fields that are specific to only a few EntityKind
s to the EntityKind
variant.
E.g., Entity::get_file
would be removed (because it is only used for inclusion directives) and the EntityKind::InclusionDirective
variant would become EntityKind::InclusionDirective(File<'tu>)
.
I'll have to think about it.
from clang-rs.
I've thought about it, and I'm not sure it's worth the implementation difficulty. There would still be many fields common to most entity kinds.
if let Entity::InclusionDirective(file) = entity {
let name = entity.get_name().unwrap();
}
doesn't seem much better than
if entity.get_kind() == EntityKind::InclusionDirective {
let name = entity.get_name().unwrap();
let file = entity.get_file().unwrap();
}
to me.
There's less unwrap
with the pattern matching, but it wouldn't eliminate it completely. Some entities would still have an optional name and some would still have an optional source range.
from clang-rs.
However, something like
if let EntityKind::InclusionDirective(file) = entity.get_kind() {
let name = entity.get_name().unwrap();
}
might work. I'll start looking into it.
from clang-rs.
Well I tried, but it doesn't seem practical to map libclang
's API into anything other than what it is now.
from clang-rs.
The you crate is not really rust idiomatic ;)
from clang-rs.
This crate will not be used a lot (only crates which manipulates c code), so it's not a big issue.
from clang-rs.
Related Issues (20)
- `parser.arguments(&["-x", "c++"])` works, `.arguments(&["-x c++"])` does not HOT 1
- The function `is_function_like_macro` is wrongly mapped HOT 1
- Location information for Types
- Entity.get_platform_availability() crashing on double free HOT 1
- `struct Clang` should not implement `Send` HOT 1
- New release that uses clang_sys 1.0 HOT 2
- Documentation is down HOT 1
- `Clang` can be constructed without `Clang::new()` HOT 2
- Printing clang error results in infinite recursion and stack overflow HOT 1
- Need help: How to compile C source files HOT 1
- obtain the const type HOT 1
- Crazy token results; either partial or completely missing HOT 7
- libclang is not loaded while having bindgen as dependency HOT 2
- Why was Send and Sync disabled for Clang struct in v2.0.0? HOT 1
- Update EntityKind HOT 1
- clang::source::SourceRange::tokenize can construct a slice with a null pointer, which is UB HOT 1
- A few renaming suggestions
- completion_test fails with clang15.0.3
- How do I call clang::HeaderSearch? HOT 1
- can not visit FriendDecl and CXXAccessSpecifier
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clang-rs.