Giter Club home page Giter Club logo

Comments (2)

alaviss avatar alaviss commented on May 24, 2024

Can we also have support for pointer-of-pointer?

I'm wrapping kmod and they have functions like this:

struct kmod_module;
int kmod_module_new_from_name(struct kmod_ctx *ctx, const char *name,
						struct kmod_module **mod);

These can be roughly mapped to

proc kmod_module_new_from_name*(ctx: ptr kmod_ctx; name: cstring; `mod`: var ptr kmod_module): int {.importc, header: headerlibkmod.}

from nimterop.

genotrance avatar genotrance commented on May 24, 2024

This has been implemented in the latest commit.

Considering there's no way to know what the developer meant with char ** - could be array of cstring or pointer to a cstring, I'm just mapping everything to ptr ptr, except ptr ptr cchar which becomes ptr cstring. This was one of Araq's examples of how you cannot always translate 100% automatically.

@alaviss - your case will become ptr ptr kmod_module. This is how c2nim does it right now as well.

type
  kmod_module* {.bycopy.} = object

proc kmod_module_new_from_name*(ctx: ptr kmod_ctx, name: cstring, `mod`: ptr ptr kmod_module): cint {.importc, header: headertest.}

Open to feedback.

from nimterop.

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.