I am far from being the right person to advice you. But what I would do is the 
following:

  1. I would start from a working C example: 
[myblu3.c](https://developer.gimp.org/writing-a-plug-in/3/myblur3.c).
  2. Then you could put the code in an [emit 
pragma](https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-emit-pragma)
  3. Start porting one function at a time, bearing in mind that you need to 
keep the API. For that you will need to use the 
[exportc](https://nim-lang.org/docs/manual.html#foreign-function-interface-exportc-pragma).
 So that, for instance, the function `run` in nim would be something like:


    
    
    proc run(<function_signature)) {.exportc:"$1".} =
      ...
    
    
    Run

4\. You need to get the right function signatures. For that task I use `c2nim`. 
You create a file `deleteme.h`: 
    
    
    static void
    run (const gchar      *name,
         gint              nparams,
         const GimpParam  *param,
         gint             *nreturn_vals,
         GimpParam       **return_vals);
    
    
    Run

and by running `c2nim deleteme.c` you get a `deleteme.nim` file which contains: 
    
    
    proc run*(name: ptr gchar; nparams: gint; param: ptr GimpParam; 
nreturn_vals: p$
             return_vals: ptr ptr GimpParam)
    
    
    Run

So your `run` function will look like: 
    
    
    proc run*(name: ptr gchar; nparams: gint; param: ptr GimpParam;
                         nreturn_vals: ptr gint; return_vals: ptr ptr 
GimpParam) {.exportc:"$1".} =
       ...
    
    
    Run

When you compile the nim code with the `{.emit.}` and the `proc` you will get 
some `c code`. You can specify in which folder you will find it: 
    
    
    nim c --nimcache:./tmp myGimpPLugin.nim
    
    
    Run

will save your c file under `./tmp`.

I hope this helps you to get started. 

Reply via email to