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

RFC: Refactor the package to make it self-generated and more #210

Open
wants to merge 40 commits into
base: master
from

Conversation

Projects
None yet
5 participants
@Gnimuc
Collaborator

Gnimuc commented Oct 11, 2018

I'm investigating how to rebuild the package directly on the auto-generated libclang bindings. Almost done. Please give it a review at your convenience ;)

Change Summary

  • rebuild Clang.jl directly on top of the auto-generated libclang C bindings
    • the new submodule LibClang is one-to-one mapped to the libclang C APIs. it depends on two new files: CEnum.jl and ctypes.jl. CEnum.jl is for better C-compatible enum handling. ctypes.jl contains those C stdlib types that are missing corresponding Julia aliases. when generating wrappers, we should also ship these two files to users.
    • module cindex's base functions are now rebuild on top of LibClang. almost all of the old APIs are renamed, please take a look at index.jl, trans_unit.jl, cursor.jl, type.jl, token.jl and show.jl for details.
    • module cindex's CL-prefixed types are removed, since methods are now directly dynamic-dispatched on Val{CEnum} value types(not sure whether this is a good idea or not).
    • unwind wrap_c.jl and add an AbstractContext type for extensibility
      • this is easier for users who would like to write their own wrap! for certain cursor decls
        and dispatched on their own context.
      • for compatibility's sake, init+run are rebuild on top of DefaultContext. also, old cindex and wrap_c modules can be loaded with Clang.Deprecated.cindex; using Clang.Deprecated.wrap_c;
  • provide an out-of-box installation experience with BB2 on Linux, masOS and Windows, this may attract more users to use this package.
    • the newly released binaries of LLVMBuilder are still not compatible with Julia-1.0, so I built a compatible version with an older version of BinaryBuilder locally and uploaded on the Github releases of this repo.
  • bugfixes and TODO list:
  • handle typedef anonymous structs/enums correctly using visr's method(close #208, fix #190)
  • integrate CEnums(cherrypick Simon's old PR close #162)
  • refactor cindex directly on top of generated wrapper - [x] make wrap_c work again
  • add tests
  • use LLVMBuilder to provide an out-of-box installation experience:
    • fix #211, fix #197, fix #183, fix #65
    • potentially fix #163 and #39 since with BB2 we install those headers in the same place on all platforms
    • close #172(obsolete), close #145(obsolete), close #142(looks like an installation problem), close #75(obsolete), close #49(obsolete)
  • handle opaque struct typealias appropriately(#84)
  • "$" should be "\$"(#196, #206)
  • CEnums doesn't like enums with minus field values
  • sort include headers
  • build docs by Documenter.jl
  • update examples and README(#209)

Gnimuc and others added some commits Sep 30, 2018

combine StructDecl as well
Co-Authored-By: Martijn Visser <mgvisser@gmail.com>
Add generator
let's make Clang.jl self-generated.
Apply Better Enums #162
Co-Authored-By: Simon <sdanisch@gmail.com>
Rewrap libclang on top of auto-generated code
1. remove old cindex wrappers
2. add a new low-level module LibClang that is one-to-one mapped to libclang APIs and exports everything
C tests passed
but it's still buggy:
1. the type of "kind" field is not correct
2. typedef impl* should not be generated
3. size_t is not represented correctly(e.g. getFileContents)
Handle enum correctly
also add a simple test case
@ihnorton

This comment has been minimized.

Owner

ihnorton commented Oct 19, 2018

I'll try to give this a read-through this weekend, very cool!

@codecov-io

This comment has been minimized.

codecov-io commented Oct 21, 2018

Codecov Report

❗️ No coverage uploaded for pull request base (master@1c5f425). Click here to learn what that means.
The diff coverage is 17.49%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #210   +/-   ##
=========================================
  Coverage          ?   12.52%           
=========================================
  Files             ?       21           
  Lines             ?     1429           
  Branches          ?        0           
=========================================
  Hits              ?      179           
  Misses            ?     1250           
  Partials          ?        0
Impacted Files Coverage Δ
src/deprecated/cindex/types.jl 0% <ø> (ø)
src/deprecated/wrap_cpp.jl 0% <ø> (ø)
src/deprecated/cindex/base.jl 0% <ø> (ø)
src/deprecated/util.jl 0% <ø> (ø)
src/deprecated/cindex.jl 0.71% <ø> (ø)
src/Clang.jl 0% <0%> (ø)
src/show.jl 0% <0%> (ø)
src/compat.jl 0% <0%> (ø)
src/deprecated/wrap_c.jl 0% <0%> (ø)
src/LibClang.jl 100% <100%> (ø)
... and 11 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1c5f425...60f2657. Read the comment docs.

@Gnimuc

This comment has been minimized.

Collaborator

Gnimuc commented Oct 21, 2018

the CI failure on Linux might due to the compatibility of the LLVM binaries. I've released two windows binaries and it works well on my VM.

Gnimuc added some commits Oct 22, 2018

Revert "fix-up"
This reverts commit 2267531.

Gnimuc added some commits Oct 28, 2018

Allow loosely typed function signature
let Julia do more convert stuff for us

@Gnimuc Gnimuc requested a review from ihnorton Nov 12, 2018

Gnimuc and others added some commits Nov 12, 2018

@musm

This comment has been minimized.

musm commented Nov 12, 2018

This is great, thanks for the hard work.

@Gnimuc Gnimuc changed the title from WIP: Refactor the package to make it self-generated to RFC: Refactor the package to make it self-generated and more Nov 13, 2018

Gnimuc and others added some commits Nov 13, 2018

Merge pull request #2 from samuelpowell/patch-1
Fix options reference
Yupei Qi
@samuelpowell

This comment has been minimized.

samuelpowell commented Nov 13, 2018

Cross-referencing a brief thread on discourse regarding #213 - this branch has fixed this issue and seems to work very well. (Running on Ubuntu 18.04 with Julia 1.0.2 generic binaries).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment