Coder Social home page Coder Social logo

Comments (9)

rschwarz avatar rschwarz commented on June 4, 2024 1

Thanks for your review and comments.

Could you elaborate more about what is an empty wrapper?

Some of the header files in SCIP only contain struct definitions, or even typedefs. I found that the actual type definitions were all moved to commons.jl and that Clang.jl created Julia files corresponding to the C headers that only contained comments and empty lines. So, it's just a cosmetic problem.

I think Clang.jl's old generator had an option for this, but Julia's function should be loosely typed. Why do you want to catch the error at the wrapper function instead of ccall?

To be honest, I don't remember the reason for that bullet point. Maybe it was about adding a form of documentation.

If the wrapper-generation is fully automatic (it looks that way in your PR #186) then I would be very happy to merge the changes, even without taking any of the "improvements" into account.

from scip.jl.

rschwarz avatar rschwarz commented on June 4, 2024

Actually, the new Clang.jl seems to be tagged now (at 0.8).

Other potential improvements:

  • Automatically generate the wrapper.jl file (with all the include() statements).
  • Copy documentation strings from SCIP's headers to our Julia functions.
  • Use Ref{Ptr{}} instead of Ptr{Ptr{}}?
  • Use a stricter function signature for our ccall wrappers.

from scip.jl.

bhalonen avatar bhalonen commented on June 4, 2024

consider using https://github.com/analytech-solutions/CBindingGen.jl

from scip.jl.

rschwarz avatar rschwarz commented on June 4, 2024

This is also based on Clang.jl, so it would be mostly for convenience of configuration?

from scip.jl.

bhalonen avatar bhalonen commented on June 4, 2024

yeah, my friend (the writer of the package) tried it on your package and (using the PR JuliaLang/julia#32658, I think) and auto wrapped everything but 3 inline functions. So it would add functionality by wrapping the varadic stuff you have as well.

from scip.jl.

rschwarz avatar rschwarz commented on June 4, 2024

OK, good to know.

Well, the variadic functions that are used do actually work now, there is just a risk of segfault or other unexpected behavior when targeting a new platform (or C compiler?).

I would have a look in the future, in case a re-generation of the wrapper becomes necessary after a release of a new SCIP version or similar. Right now, it works well enough for me not to bother, but PRs are welcome!

from scip.jl.

rschwarz avatar rschwarz commented on June 4, 2024

Another topic that has come up on Discourse. The auto-generated ccall wrappers all use Ptr{X} for some SCIP struct X. This is fine in most cases, as we will actually pass C pointers (for SCIP-owned objects) to these calls.

However, there are also cases where we have Julia-owned Julia objects, that we want to pass to SCIP because they are used as data associated with constraints etc. The correct way of specifying the ccall signature would be to use the Any type. Then, the Julia object would be automatically cconverted into a pointer and GC-safe (for the duration of the ccall).

I'm not sure how to handle that in the wrapper generator, since there might not be a simple pattern to distinguish these two cases. In fact, some SCIP functions might be useful to call both ways (passing C data, or passing Julia data).

from scip.jl.

Gnimuc avatar Gnimuc commented on June 4, 2024

This may be fixed by #186, but I need more info.

rename Ptr{SCIP} to Ptr{SCIP_}, to avoid name conflict with module.

#186 generates a new module LibSCIP, so one can use LibSCIP.SCIP for distinguishing.

delete empty wrappers for type_*.h; the type definitions all went to commons.jl

Could you elaborate more about what is an empty wrapper?

add some missing (type/enum) definitions to manual_commons.jl (why did Clang.jl not add them?)

Clang.jl's new generator now works in a strict mode, if some symbols are missing, it just errors out and complains about which symbol is not found. Then, one needs to either add the missing header(if it's a dependent header but not living in the source tree) or use the new @add_def sym(if it's a symbol defined in std headers or system headers). As long as the generation runs successfully, there shouldn't be missing definitions except in the case of macro definitions.

Copy documentation strings from SCIP's headers to our Julia functions.

This can be easily supported in the new generator by adding a documenter pass.

Use Ref{Ptr{}} instead of Ptr{Ptr{}}?

As discussed in JuliaInterop/Clang.jl#120, there is really no much difference between these two versions, but I can add a new option to let users make the decision.

Use a stricter function signature for our ccall wrappers.

I think Clang.jl's old generator had an option for this, but Julia's function should be loosely typed. Why do you want to catch the error at the wrapper function instead of ccall? If you're concerned about mistakenly passing opaque pointers, which may crash Julia, you could generate mutable struct opaque_type end instead of const opaque_type = Cvoid by setting opaque_as_mutable_struct = true in the generator config toml file.

from scip.jl.

matbesancon avatar matbesancon commented on June 4, 2024

closed by #186

from scip.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.