-
Notifications
You must be signed in to change notification settings - Fork 69
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
C++ support meta-issue #20
Comments
Oh my---this is amazing. Clang's impact on the Julia ecosystem is huge and growing! |
I haven't announced anything yet because I'm still not entirely convinced that this is sane :) |
Single inheritance by dispatching on the type of this* is now working: https://github.com/ihnorton/VTK.jl/blob/5fd3b91/src/vtkRenderer.jl#L1-L9 |
Automatic base class resolution has been implemented - imports superclasses automatically and constructs abstract type tree: |
I want to try using this. Can someone guide me as to how I can use it. I checked out the wrap_cpp branch. But when I run the code,it still says: ERROR: @Scall not defined This is my code: using Clang.cindex t = ccall( (:clock, "libc"), Int32, ()) a = @Scall((:main, "/home/shagun/Acads/learning_julia/libshared"), Uint8, ()) |
This is still very rough right now, so be warned. A couple notes:
I will try to clean this up soon and write some basic documentation so other people can hack on it. |
@ihnorton What's the current status? |
I've kept it up to date with Julia but otherwise haven't changed it very much in a while. The JIT'd vcalls still work. But I am giving up on the idea of doing this without any code generation, because I don't think it is reasonable to expect people to recompile a bunch of libraries they could get from apt-get, with weird (and hard-to-use) compiler options just to keep inline functions. So I'm working on generation of C-callable stubs. |
…request/fc0866d6 Change the return types of functions that returned nothing from None …
The wip_cpp branch is now sufficiently developed to enable this proof-of-concept demo:
https://github.com/ihnorton/VTK.jl
C++ method calls are supported as follows:
static methods: normal ccall, using mangled name, with signature like:
@Scall Ptr{Void} New () _ZN11vtkPolyData3NewEv "libvtkFiltering"
macro: https://github.com/ihnorton/Clang.jl/blob/wip_cpp/src/wrap_cpp.jl#L37-L48
member methods: called by mangled name using thiscall, passing this* first. Sig:
@mCall None SetPolys (Ptr{Void},) _ZN11vtkPolyData8SetPolysEP12vtkCellArray "libvtkFiltering"
macro: https://github.com/ihnorton/Clang.jl/blob/wip_cpp/src/wrap_cpp.jl#L50-L61
virtual methods: the vtable index of the function is annotated during generation (probably only supports single-inheritance for now). In each function call, the appropriate function pointer is retrieved by de-referencing the this* object to get the vtable, then de-referencing again at the appropriate offset (= index * sizeof(Ptr))
sig:
@Vcall 90 None GetCellNeighbors (vtkIdType, Ptr{Void}, Ptr{Void})
macro:
https://github.com/ihnorton/Clang.jl/blob/wip_cpp/src/wrap_cpp.jl#L63-L74
There are a lot of things to consider in developing this to the point where it is usable, so this issue and the c++ tag will be used to capture and discuss.
The text was updated successfully, but these errors were encountered: