My code is crappy, believe me. Nothing to do with `nimterop` or `c2nim`. No 
aspirations here to be a contender.

The results are crappy as well. Let me show some examples: 
    
    
    proc ` new`*(this: var gp_Quaternion, theSize: cint)  {.importcpp: "` 
new`".}
    
    
    Run

or 
    
    
    proc `+`*(this: gp_Mat2d, Other: gp_Mat2d): gp_Mat2d  {.importcpp: "`+`".}
    
    
    Run

or 
    
    
    gp_TrsfNLerp* {.include: "gp_TrsfNLerp.hxx", importcpp: "gp_TrsfNLerp".} = 
NCollection_Lerp<gp_Trsf>
    
    
    Run

or 
    
    
    Handle_gp_VectorWithNullMagnitude* {.include: 
"gp_VectorWithNullMagnitude.hxx", importcpp: 
"Handle_gp_VectorWithNullMagnitude".} = 
opencascade::handle<gp_VectorWithNullMagnitude>
    
    
    Run

It is not managing enums, structs, functions (just methods and constructors) 
either.

I hope this serves to manage the expectations! ;oP

I agree that it would be better to improve nimterop or c2nim.

For a noob like me, with very little C++ knowledge, it is difficult just to 
make a first shot at a library with c2nim (you need to clean the heaader until 
it is able to digest it). I think nimterop is more tolerant, but it is not 
trivial to use. I didn't manage to make it work both together.

This tool is sufficient for the purpose I intent to use it (just a few tests 
with OpenCascade whose API is seem to follow a similar pattern accross many 
headers).

I tried with libtorch. I just downloded `libtorch-shared-with-deps-1.7.0.zip` 
and execute it over the first folder: `ATen`: 
    
    
    python cpp2nim.py "libtorch/include/ATen/*.h" ATen
    
    
    Run

It created only 19 files out of 79 files. I think this is because most of the 
files probably doesn't contain a class (just functions).

For instance, for `CUDAGeneratorImpl.h` it created.: 
    
    
    {.push header: "CUDAGeneratorImpl.h".}
    
    
    # Constructors and methods
    proc constructor_CUDAGeneratorImpl*(device_index: c10::DeviceIndex): 
CUDAGeneratorImpl {.constructor,importcpp: "CUDAGeneratorImpl(@)".}
    
    proc clone*(this: CUDAGeneratorImpl): std::shared_ptr<CUDAGeneratorImpl>  
{.importcpp: "clone".}
    
    proc set_current_seed*(this: var CUDAGeneratorImpl, seed: uint64_t)  
{.importcpp: "set_current_seed".}
    
    proc current_seed*(this: CUDAGeneratorImpl): uint64_t  {.importcpp: 
"current_seed".}
    
    proc seed*(this: var CUDAGeneratorImpl): uint64_t  {.importcpp: "seed".}
    
    proc set_philox_offset_per_thread*(this: var CUDAGeneratorImpl, offset: 
uint64_t)  {.importcpp: "set_philox_offset_per_thread".}
    
    proc philox_offset_per_thread*(this: var CUDAGeneratorImpl): uint64_t  
{.importcpp: "philox_offset_per_thread".}
    
    proc philox_engine_inputs*(this: var CUDAGeneratorImpl, increment: 
uint64_t): std::pair<uint64_t, uint64_t>  {.importcpp: "philox_engine_inputs".}
    
    proc device_type*(this: var CUDAGeneratorImpl): c10::DeviceType  
{.importcpp: "device_type".}
    
    proc clone_impl*(this: CUDAGeneratorImpl): at::CUDAGeneratorImpl *  
{.importcpp: "clone_impl".}
    
    {.pop.} # header: "CUDAGeneratorImpl.h
    
    
    Run

where there are obvious issues (that maybe are not that difficult to fix).

One good thing is that cpp2nim is right now less than 500 lines of actual code, 
so it shouldn't be that hard to fix.

Reply via email to