This patch provides LLVMGetSubtypes & LLVMGetNumContainedTypes + subtypes (for ocaml) functions, which are bindings to llvm::Type::subtypes & llvm::Type::getNumContainedTypes
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Well, it's only for structures (possibly packed), this method extracts type from, for example, pointers
I think i'm not allowed to commit by myself, please commit this patch when everything's good
There is also facilities to do it for pointers and alike, and I assume you need to check what kind of type you are iterating on, because you have no way to know if the index is valid or not when you don't, so I'm not sure what is the use case here. The C++ code seems to use that to do an iterator interface, but there are no iterators in C.
Hmm, should I add getNumContainedTypes too, so one could check if there are any contained types then? (Because i think it's not possible in C API)
On second thought I would prefer the OCaml interface to have a single function returning an array, since this is safer and easier to use.
@whitequark can you explain the use case here ?
@TyanNN what you need to do depends on the use case.
@deadalnix The use case is the same. The current API can assert, the one I suggest can not.
Array is generally safer, but I (personally) use getContainedType just to get contained type of a pointer (it has only 1). We can do both, like in C++ API
@whitequark Hm.. makes sense, i guess. But why are there both in C++ api then...?
Anyway, it seems that there are already all functions provided, they just don't cover whole C++ API..?
I don't think anyone ever had a goal of covering the entire C++ API, the binding is produced demand-side.
bindings/ocaml/llvm/llvm.mli | ||
---|---|---|
665 | This shouldn't be exposed in the public interface, I think. |
@whitequark please commit this patch when you can, because i do not have commit access
This shouldn't be exposed in the public interface, I think.