diivm / pcl

Point Cloud Library (PCL)
http://www.pointclouds.org
Other
0 stars 0 forks source link

Anonymous struct/enum/union not parsed into json #11

Closed diivm closed 4 years ago

diivm commented 4 years ago
diivm commented 4 years ago

Solution found:

  1. Package updation:
    • Not use pip package clang for development (was using this). Gives weird behaviour for anonymous structs.
    • Not use apt package python3-libclang10
      • Tried using it after uninstalling the pip package: Doesn't work
      • Something wrong with some file in apt package (not the main cindex, since I had used that successfully after swapping with the pip one). This should be the reason why the docker env was giving issues :exploding_head:
    • Use apt package python3-libclang11: Gives the same result as the current code.
  2. Just remove the starter if spelling != "" condition.
    • Generates a much, much more detailed because removing the spelling check means every symbol gets parsed, not just the declarations.
    • We can do something to handle the special case and keep the if spelling != "", but the extra information can enhance the pybind generation. Needs handling more cursor kinds (a lot), but I feel it will be useful.
    • The current tests pass in this scenario, just updation on the generate.py front required (which would have been done anyway).
kunaltyagi commented 4 years ago

Should have read this before the PR.

We can do something to handle the special case

Maybe the type of node can be used?

the extra information can enhance the pybind generation

In what ways?

Package updation

Clang 11 is not released. That's my opposition against moving to 11. What about clang-9?

diivm commented 4 years ago

Maybe the type of node can be used?

Yeah, was doing just that.

In what ways?

Adds more type info like type of array, etc. Anyway, later if not needed, can just add a skip for those types so that it doesn't go in the json in the first place.

Clang 11 is not released. That's my opposition against moving to 11. What about clang-9?

Yeah, I am aware. On further digging, the problem is with the .so file cindex.py uses. I tried both libclang-10.so and libclang-11.so with both python3-clang-10 and python3-clang-11 (modifying the cindex file). libclang-11.so works in both cases, libclang-10.so doesn't.

clang-9:

Also, now v12 is under development: Screenshot from 2020-07-22 18-30-04

kunaltyagi commented 4 years ago

Sorry for the shoddy research. Didn't expect LLVM's release page to be stale

kunaltyagi commented 4 years ago

python3-clang-9

Nor is python3-clang-11

diivm commented 4 years ago

Nor is python3-clang-11

Yeah, we'll have to use the nightly package:

https://github.com/divmadan/pcl/blob/abc0df1cb4c906cd505f839b6d8634ee07c0aa0b/.github/workflows/pytest.yml#L61-L71

The default version of clang still goes to v6, I'm not sure though. Nightly packages from https://apt.llvm.org/ shows that they have defaulted to v11:

Screenshot from 2020-07-23 11-12-44

aPonza commented 4 years ago

Based on this I'd say this should be the clang-9 package for python3 in bionic. It says "transitional" on the first link. Tried locally on a docker 18.04 and it pulls in python3 stuff but nothing seemingly related to clang though, not 100% on it.

diivm commented 4 years ago

@aPonza, python-clang-9 installs for python2.7

➜  bindings git:(devel/test_parse) ✗ dpkg -L python-clang-9 
/.
/usr
/usr/lib
/usr/lib/python2.7
/usr/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages/clang
/usr/lib/python2.7/dist-packages/clang/__init__.py
/usr/lib/python2.7/dist-packages/clang/cindex.py
/usr/lib/python2.7/dist-packages/clang/enumerations.py
/usr/share
/usr/share/doc
/usr/share/doc/python-clang-9
/usr/share/doc/python-clang-9/NEWS.Debian.gz
/usr/share/doc/python-clang-9/changelog.Debian.gz
/usr/share/doc/python-clang-9/copyright