Re: Nim's popularity

2020-06-17 Thread mantielero
I don't think that bearing popularity in mind means disregarding all the other things that Nim is already managing really well. I don't like popularity, I like what it comes with popularity: more brains, more libraries, better maintained packages, ... This thread could be titled: "Nim's

Re: Nim's popularity

2020-06-15 Thread mantielero
Gracias @juancarlospaco. This is exactly what I was looking for. @treeform, nice overview. Given Nim's potential, I am surprised about point 1. I think/hope this is a matter of time.

Nim's popularity

2020-06-15 Thread mantielero
I was wondering (just out of curiosity) about current Nim's popularity. I know every metric is somehow biased, but I would like to get a feeling about how is evolving. I was looking as well, for the biggest projects developped in Nim (apart from Nim itself). I bet there is a way to get that

Re: Standalone Libclang Nim Apps

2020-06-09 Thread mantielero
Hi deech. I am posting here to avoid hijacking the [hackaton thread](https://forum.nim-lang.org/t/6394). I am not sure if I get it. If I understand this correctly, this provides is a way to introspect headers by means of libclang. So this could be used to create a nimterop like tool using

Re: Hackathon as part of NimConf 2020

2020-06-07 Thread mantielero
I am not a contributor so probably not entitled to give an opinion here. In any case, I would suggest improving [nimterop](https://github.com/nimterop/nimterop). Right now it works really well when you try to wrap C libraries. But it could be even better, and it still misses the capability to

Re: Question about type safety and OOP

2020-05-25 Thread mantielero
The thing is that in example1 case there is an implicit conversion from Cat to Animal, while in example2 that conversion has to be explicit. I would expect the implicit conversion happening in both cases. Probably there is a rationale for that no happening.

Re: Inheritance vs composition

2020-05-24 Thread mantielero
Ahhh. I though it would be something more complicated. It is just a matter of adding objects into another object.

Re: Question about type safety and OOP

2020-05-24 Thread mantielero
I understand the rationale of seq[Animal] being a different type than seq[Cat]. But I believe this is counter-intuitive when Cat it is actually an animal. In fact, it looks strange to me the following behaviour: type Animal = ref object of RootObj Cat = ref object of

Inheritance vs composition

2020-05-24 Thread mantielero
With all this experiments with OOP, I have read in several places that Nim encourage composition against inheritance. I have read [this](https://medium.com/humans-create-software/composition-over-inheritance-cb6f88070205) which is very clear, but I don't know how this translates well into Nim.

Re: Question about type safety and OOP

2020-05-24 Thread mantielero
I am still struggling with the type system . For instance: type A = ref object of RootObj B = ref object of A val:int proc example*(x:seq[A]) = for i in x: echo repr i var a:seq[A] = @[B(val:1), B(val:2)] #<--- This fails, but

Re: Question about type safety and OOP

2020-05-24 Thread mantielero
My bad. It was an error somewhere else.

Re: Strange failure

2020-05-24 Thread mantielero
@mratsim, it looks we posted at the same time and I missed your answer. Much better your second solution. Thanks.

Re: Question about type safety and OOP

2020-05-24 Thread mantielero
Thank both. It is clear. In fact I just realised that the problem was cause by something different (that I still don't understand), but probably it has something to do with the stack and the heap. I have something like the following: let points = newPoint( @[ pt(0,0,0),

Question about type safety and OOP

2020-05-24 Thread mantielero
I have a function with the following signature: proc newCurveLoop*( curves:seq[Curve]; tag:int = -1 ):Loop Run On the other hand I have: Curve* = ref object of Tag Line* = ref object of Curve ini*, fin*:Point Run The type safety makes

Re: Strange failure

2020-05-24 Thread mantielero
Thanks Stefan. Understood. I fixed it with: proc pt*[N1,N2,N3:SomeNumber](x:N1, y:N2, z:N3):tuple[x,y,z:float] = Run

Strange failure

2020-05-24 Thread mantielero
Why the following code is failing? proc pt*[N:SomeNumber](x, y, z:N):tuple[x,y,z:float] = return (x: x.float, y: y.float, z: z.float) let t1 = pt(0,0,0) let t2 = pt(0.1, 0, 0) let t3 = pt(0.1, 0.3, 0) let t4 = pt(0, 0.3, 0) #<- Why is this

Re: Playing with objects - object referecing another object

2020-05-23 Thread mantielero
I think I just had to remove the ref in Tmp definition: type Coord = ref object of RootObj x,y,z:float Pt* = ref object of Coord Tmp = ref object of RootObj tag:int point:Pt let a = Pt(x:1.0, y:3.0,z:2.0) let

Playing with objects - object referecing another object

2020-05-23 Thread mantielero
I have not used OOP in Nim so far. I was playing with the following code: type Coord = ref object of RootObj x,y,z:float Pt* = ref object of Coord Tmp = ref object of RootObj tag:int point:ref Pt let a = Pt(x:1.0,

Converting to another's variable type

2020-05-22 Thread mantielero
I have a sequence of distinct types (despite all of them are actually int). I would like to "copy the types" into a new sequence. (Not looking for workarounds, because the problem is a little bit more involved) Something as the following: type A = distinct int B =

llegal capture 'world' because ':anonymous' has the calling convention:

2020-05-13 Thread mantielero
I am trying to define the following callback from Nim: static void nearCallback (void *data, dGeomID o1, dGeomID o2) { int i; //-- Get the body's ID dBodyID b1 = dGeomGetBody(o1); dBodyID b2 = dGeomGetBody(o2); //-- If they are

Re: Nim forum development

2020-05-10 Thread mantielero
Why other languages are not prettified?

Re: gr.nim - floats in FFI

2020-05-06 Thread mantielero
I had that feeling too. Thanks Vindaar.

gr.nim - floats in FFI

2020-05-06 Thread mantielero
or theirs. What I am doing is pretty simple: 1. I create a sequence of floats by calling [linRange](https://github.com/mantielero/gr.nim/blob/master/examples/grm_plot.nim#L4) 2. The function linRange is pretty simple. It is defined [here](https://github.com/mantielero/gr.nim/blob/master/src/gr/

FFI with huge C++ projects

2020-05-03 Thread mantielero
Any experience/advise with this? I was looking forward to create bindings with [Open Cascade](https://www.opencascade.com/doc/occt-7.3.0/overview/html/index.html) after the accumulated experience so far with a couple of projects. But I realized that it is C++ and it is huge, so bad starting

GR.nim - just another plotting library

2020-05-03 Thread mantielero
I have just done the bare minimum to get it working. Hopefully it can be useful for some of you. Here you have some basic [documentation]([https://mantielero.github.io/gr.nim/](https://mantielero.github.io/gr.nim/)) and the [code]([https://github.com/mantielero/gr.nim)](https://github.com

Embedding OpenGL window into some of our gui frameworks

2020-04-28 Thread mantielero
I asked this question yesterday in [nimx issues](https://github.com/yglukhov/nimx/issues/417). But I would like to do it in other frameworks as well. Basically I would like to do somehing like [this](https://gr-framework.org/tutorials/gr3_wx.html). @juancarlospaco, I was wondering if this

Re: ggplotnim - pretty native plots for us

2020-04-27 Thread mantielero
@Vindaar, I am working on doing some bindings to [gr-framework]([https://gr-framework.org/)](https://gr-framework.org/\)). My bindings are not mature, but I believe it could be a better option that using Cairo. I have created both animations, images, ... in both windows and pictures. It could

Re: Number of items in a tuple

2020-04-25 Thread mantielero
Thanks guys.

Number of items in a tuple

2020-04-24 Thread mantielero
Is there a function to know the number of items in a tuple?

ipopt.nim - large scale non-linear optimization

2020-04-15 Thread mantielero
on [hs071_c.c](https://github.com/coin-or/Ipopt/blob/master/examples/hs071_c/hs071_c.c). The second example uses a macro to perform a similar calculation [ex02.nim](https://github.com/mantielero/ipopt.nim/blob/master/examples/ex02.nim) which is a lot shorter and kinder to the eyes. I hope it becomes

Re: Macros - organizing code

2020-04-14 Thread mantielero
Thanks. That was what I was looking for.

Re: Macros - Is this a bug?

2020-04-13 Thread mantielero
For reference: [https://github.com/nim-lang/Nim/issues/13973](https://github.com/nim-lang/Nim/issues/13973)

Re: ipopt - Problem with Macro

2020-04-13 Thread mantielero
, because I am using something similar [here](https://github.com/mantielero/ipopt.nim/blob/9967dc72130a45e8d6a675439f174cf24a01c941/src/ipopt.nim#L419) and it is working. That is what is making me thing that this is an error a not a bug.

ipopt - Problem with Macro

2020-04-13 Thread mantielero
I am having an issue with a macro that I am not managing to solve. The code is messy, but I will try to make clear the issue. I have the source code [here](https://github.com/mantielero/ipopt.nim/tree/master/src). When I compile this code, the last lines displayed (from expandMacro

Macros - Is this a bug?

2020-04-13 Thread mantielero
This weekend playing with a macro I faced the following problem. The following code [fails](https://play.nim-lang.org/#ix=2hQj): import macros proc hello() = echo "hola" macro function() = let f = genSym(nskProc, ident="hello") result = quote do:

Macros - organizing code

2020-04-12 Thread mantielero
I don't have much practise with macros and I normally end-up with big ones. How can I split macros bearing in mind that I might need to reference identifiers from one sub-macro into another submacro? mymacro: submacro1: ... submacro2: ...

Re: FFI - ipopt solver - malloc(): corrupted top size

2020-04-11 Thread mantielero
Thanks a Araq for trying. I manage to find and solve the problem. Regarding the cast, are you referring to [these](https://github.com/mantielero/ipopt.nim/blob/master/src/ex01.nim#L238-L244). I need to think about how to make it easier using the library.

Strange "type mismatch" error

2020-04-11 Thread mantielero
I am getting the following error: /home/jose/src/VapourSynth.nim/test/ex12.nim(24, 6) Error: type mismatch: got but expected one of: proc append(vsmap: ptr VSMap; key: string; data: float) first type mismatch at position: 3 required type for data: float but

Re: FFI - ipopt solver - malloc(): corrupted top size

2020-04-11 Thread mantielero
Just for the record, it was much more informative (at least for me) compiling with: $ nim c --profiler:on --stacktrace:on ex01 and then checking the error messages provided by valgrind: $ valgrind ./ex01

FFI - ipopt solver - malloc(): corrupted top size

2020-04-11 Thread mantielero
://github.com/mantielero/ipopt.nim/tree/master/src). The ex01.nim code compiles fine, but when I run it I get the failure: ** This program contains Ipopt, a library for large-scale nonlinear optimization

Re: UncheckedArray conversion

2020-04-08 Thread mantielero
Well now I am amazed but on the other side of the pic. I need to check if I have done something really wrong, but I have managed to get: 6074fps using float32 (I was expecting 3000fps) and 10700fps using int32, just by taking advance of multithreading.

Re: Nim threading and FFI - locks

2020-04-08 Thread mantielero
I made it work like this: import locks type FrameRequest {.bycopy.} = object numFrames*: int # Total number of frames nthreads*: int # Number of threads available completedFrames*: int # Number of frames already processed

Re: UncheckedArray conversion

2020-04-08 Thread mantielero
zed that, but I don't want to change that (yet) until I get similar performance to the C++ version with similar algorithm. I tried to perform a filter with [ArrayMancer](https://github.com/mantielero/VapourSynth.nim/blob/master/src/filters/Mancer.nim) but I got worst. My short term object

Nim threading and FFI - locks

2020-04-08 Thread mantielero
Disclaimer: I don't have much experience with multithreading (I played with it long ago in python). In a different [forum thread](https://forum.nim-lang.org/t/6169), we were talking about the need of setupForeignThreadGc() on the top of a callback called by C. In the same context, I aiming to

Re: UncheckedArray conversion

2020-04-07 Thread mantielero
**C++ stuff** In order to test the C++ version: 1. The code can be downloaded from [here](https://github.com/IFeelBloated/test_c_filters). 2. I compiled it like: $ g++ -Wall -O3 -shared -fPIC -I. -o libfilter.so GaussBlur.cxx 3\. Create a VapourSynth python filter like

Re: How do I pass Nim functions to C code as callbacks?

2020-04-07 Thread mantielero
I was just looking into this at this very moment and I am not sure if I use it well. I was reading the [Thread coordination](https://nim-lang.org/docs/backends.html#memory-management-thread-coordination) section and this [forum entry](https://forum.nim-lang.org/t/3965#24714). So I was

Re: UncheckedArray conversion

2020-04-07 Thread mantielero
**Nim stuff** I have updated the [repository](https://github.com/mantielero/VapourSynth.nim). I have a local package.json with: [ { "name": "vapoursynth", "url": "https://github.com/mantielero/VapourSynth.nim;,

Re: UncheckedArray conversion

2020-04-07 Thread mantielero
You are probably right. For me is the first time doing this sort of stuff. But the feeling that I have is that even small modifications in the algorithm (avoiding conversions as much as possible, for example) has a significant impact. I think that the reason is that I am interating on 100_000

Re: UncheckedArray conversion

2020-04-07 Thread mantielero
This is part of a convolution filter. The result is in the same order of magnitude (uint8): let value:int32 = r0[col0].int32 + r0[col1].int32 * 2 + r0[col2].int32 + r1[col0].int32 * 2 + r1[col1].int32 * 4 + r1[col2].int32 * 2 +

UncheckedArray conversion

2020-04-06 Thread mantielero
I have something like the following: > let value:int32 = r0[col0].int32 + r0[col1].int32 * 2 + ... where r0 has type ptr UncheckedArray[uint8]. How can I avoid adding .int32 each time I use one item from the unckeckedarray?

Re: Vapoursynth - optimization

2020-04-03 Thread mantielero
It has improved a bit. Regarding the Nim filter: * 308fps by tuning seq[seq[int]], into array[9,int32] * 442fps by changing the bound checks into min( max(val, 0), max_val) Still slow but getting better. import ../vapoursynth import math template clamp(val:int,

Re: Vapoursynth - optimization

2020-04-03 Thread mantielero
**Working with C filters** When I work with C filters (like Convolution) I works fine with refc GC. In that case, I don't know why I get 2640fps vs 3740fps on the python version. They should be roughly the same. When I call a filter within an existing plugin I just call one function:

Re: Vapoursynth - optimization

2020-04-02 Thread mantielero
At this stage I can only recommend NOT to use VapourSynth.nim. It is too slow (not because of nim, but I cannot find out why). Testing the convolution filter in Python: import vapoursynth as vs core = vs.get_core() core.std.SetMaxCPU('none') clip =

Re: Vapoursynth - optimization

2020-03-31 Thread mantielero
Let me try asking less general questions: What is preferred, using UncheckedArray, using [these templates](https://forum.nim-lang.org/t/1188#7366)? I guess all this is better than performing a memcopy into a Nim structure.

Re: libvapoursynth.so: undefined symbol: pthread_create

2020-03-31 Thread mantielero
Solved in Archlinux's R49-2. It was a packaging problem.

Vapoursynth - optimization

2020-03-30 Thread mantielero
My filters are unsurprisingly slow (because of the "My" variable, of course). Now I would like to learn how to avoid that. I have implemented a Gauss filter just to compare it with a C++ version . The results are 80fps (for me) against about 2400fps for a C++ wrapper and 11748fps for a pure C

Re: Vapoursynth - optimization

2020-03-30 Thread mantielero
Just for the record the C++ version is [here](https://github.com/IFeelBloated/vsFilterScript/blob/master/GaussBlur.hxx#L23) using templates. And this is by using the [low level API](https://github.com/IFeelBloated/test_c_filters/blob/master/GaussBlur.cxx#L26).

Re: libvapoursynth.so: undefined symbol: pthread_create

2020-03-30 Thread mantielero
It doesn't gives me much information: $ ./modifyframe ViolaciĆ³n de segmento (`core' generado) I have observed also that this happens when I call a macro, but not when I call a vapoursynth plugin.

Re: libvapoursynth.so: undefined symbol: pthread_create

2020-03-30 Thread mantielero
A different one. I get a Segfault:

Re: libvapoursynth.so: undefined symbol: pthread_create

2020-03-30 Thread mantielero
That fails, but I have checked that the following works: nim c -f --threads:on --gc:none modifyframe Why do I need that now? Is this a change in Nim or in vapoursynth? I keep on using v1.0.6 as far as I know.

libvapoursynth.so: undefined symbol: pthread_create

2020-03-30 Thread mantielero
Tonight I updated my archlinux installation. It updated vapoursynth from R48 to R49. If I compile and run a file I get the message: $ ./modifyframe /home/jose/src/VapourSynth.nim/src/libs/libvapoursynth.so: undefined symbol: pthread_create could not load:

Re: Strange (maybe memory related behaviour)

2020-03-29 Thread mantielero
What I have done is to go for a minimal execution trying to find problems. Something strange that I have observed while doing so is that if I comment the line: echo &"Width: {width} bytesPerSample: {bytesPerSample} " Run I pass from 369 errors in 61 contexts to 0. Why

Re: Strange (maybe memory related behaviour)

2020-03-29 Thread mantielero
Thanks Stefan. So: nim c -r modifyframe fails after 6 frames as explained before. arc fails for me: $ nim c --gc:arc modifyframe Hint: used config file '/home/jose/.choosenim/toolchains/nim-1.0.6/config/nim.cfg' [Conf] command line(1, 2) Error: 'none',

Strange (maybe memory related behaviour)

2020-03-29 Thread mantielero
I am facing some kind of issues that I am having difficulties to solve. I am getting the following error during runtime: Traceback (most recent call last) /home/jose/src/VapourSynth.nim/src/filters/modifyframe.nim(9) modifyframe

Arraymancer - kernel

2020-03-28 Thread mantielero
I was wondering if it is possible to apply a small kernel to a bigger matrix. I have implemented a small blur filter, and I would like to see how it feels to do it with arraymancer.

VapourSynth.nim - video processing

2020-03-28 Thread mantielero
Despite there is lot of work ahead I today I have achieved the two main objectives I aimed with this project: 1. Being able to reuse VapourSynth plugins 2. Being able to create pure Nim filters in an easy way. And [this](https://github.com/mantielero/VapourSynth.nim/blob

Re: template - body issue

2020-03-26 Thread mantielero
One remaning question is how can I see the result from a template execution. I am not talking about invoking the template. For instance in the example above, is there a way to see how: tpl(myname): echo "1" echo "2" Run gets converted into:

template - body issue

2020-03-25 Thread mantielero
I am trying to do something like the following: template tpl(name:string, body:untyped):untyped = proc `name Free`()= body tpl("myname"): echo "1" echo "2" mynameFree() Run What am I missing to make it work? Secondly,

Re: Template - how to prefix a function's name

2020-03-24 Thread mantielero
Brilliant. Thanks a lot.

Template - how to prefix a function's name

2020-03-24 Thread mantielero
How can I create a new function with a template so that the created function has its function name prefixed? Something like: template mytempl(prefix) = proc $prefix & World() = echo "hello world" Run So that: mytempl(hello) Run creates a

Re: VapourSynth - some help from somebody with C knowledge

2020-03-23 Thread mantielero
I fixed this issue. Now we can create filters in pure Nim. Right now, it is only a small improvement when compared with C because it only avoids having the filter within a plugin. Slowly getting there.

Re: SIGSEGV: Illegal storage access.

2020-03-22 Thread mantielero
Thanks @Araq, that helped me fix the bug.

Re: SIGSEGV: Illegal storage access.

2020-03-22 Thread mantielero
(Just for the record; I haven't checked if these are already known issues or if they are actually issues or my misuse) I am playing again with c2nim. I am not sure if this could be a problem: typedef enum VSColorFamily { cmGray = 100, cmRGB= 200 }

SIGSEGV: Illegal storage access.

2020-03-21 Thread mantielero
This is the second time I face this error: SIGSEGV: Illegal storage access. (Attempt to read from nil?) So I am pretty sure this is something that I systematically do wrong. This happens when I wrap some libraries. My question is what is the right strategy to debug this sort of

Re: VapourSynth - some help from somebody with C knowledge

2020-03-19 Thread mantielero
@mratsim, thanks a lot. Right now I am focusing on [simple.nim](https://github.com/mantielero/VapourSynth.nim/blob/master/test/simple.nim). Don't hesitate to participate in this [issue](https://github.com/vapoursynth/vapoursynth/issues/534).

Re: pointer to uint8: changing the underlying value

2020-03-17 Thread mantielero
It looks like the address type wasn't right. The following works (where "tmp" contains the pointer): let address:ptr uint8 = cast[ptr uint8](tmp) address[] = 10.uint8 Run

pointer to uint8: changing the underlying value

2020-03-17 Thread mantielero
I'd like to change the content from an address. I though the following would work. let address = address[] = 10 Run How should I do it?

VapourSynth - some help from somebody with C knowledge

2020-03-17 Thread mantielero
://github.com/mantielero/VapourSynth.nim/blob/master/test/function.nim), but doesn't work (yes, I know there is plenty of rubbish in it). I think it has to do with something related with memory managment or nil pointers of stuff like that (I don't have the expertise). I have reached a point where

Re: Issue with a function signature

2020-03-15 Thread mantielero
I was missing the {.cdecl.} in the function declaration.

Issue with a function signature

2020-03-15 Thread mantielero
I am having a problem with a function call: Error: type mismatch: got .}> but expected 'VSFilterGetFrame = proc (n: cint, activationReason: cint, instanceData: ptr pointer, frameData: ptr pointer, frameCtx: ptr VSFrameContext, core: ptr VSCore, vsapi: ptr VSAPI): ptr

Re: VapourSynth - now we do video ;oP

2020-03-13 Thread mantielero
[Added](https://github.com/mantielero/VapourSynth.nim/blob/master/src/plugins/motionmask.nim) Let me know if it works (or not)

Re: VapourSynth - now we do video ;oP

2020-03-13 Thread mantielero
FFT3D should work (I haven't tried). I think Masktools are not available as a plugin for VapourSynth. If I am wrong, let me know and I will wrap it.

VapourSynth - now we do video ;oP

2020-03-12 Thread mantielero
ost forgot, the link to the code: [VapourSynth.nim](https://github.com/mantielero/VapourSynth.nim). Lot of work ahead.

Re: Casting basics (a few questions)

2020-03-12 Thread mantielero
Thank you both. I got it working.

Casting basics (a few questions)

2020-03-11 Thread mantielero
I am trying to read c-array into a sequence. If somebody could confirm if my understanding is correct. In one hand, I have in C world: an address, the array size and the type. Something like: bufferptr, size and uint8 (it contains an image). In order to load the buffer into the seq, is the

Re: FFI: how to avoid naming arguments in C functions

2020-03-10 Thread mantielero
Thanks for that. I was looking about how that was called (enum offsets).

Re: FFI: how to avoid naming arguments in C functions

2020-03-10 Thread mantielero
Nimterop has other issues (I should file it). For instance: toast -pnrk VapourSynth.h creates the following enums: pfRGB24* = (cmRGB + 10).VSPresetFormat pfRGB27* = 29.VSPresetFormat pfRGB30* = 30.VSPresetFormat pfRGB48* = 31.VSPresetFormat

Re: FFI: how to avoid naming arguments in C functions

2020-03-10 Thread mantielero
@akavel no problem and I understand (I can imagine). @shashlick thanks for that. Very useful. I have left my spaguetty code [here](https://github.com/mantielero/h2nim.py) (I called it **h2nim.py** ). It uses [pyclibrary](https://pyclibrary.readthedocs.io/en/latest/) under the hood. It is far

Re: FFI: how to avoid naming arguments in C functions

2020-03-08 Thread mantielero
I will take a look to ggplotnim. Looks interesting. I have played with both nimterop and c2nim before. Thanks a lot.

Re: FFI: how to avoid naming arguments in C functions

2020-03-08 Thread mantielero
Thanks for the clarification.

Re: FFI: how to avoid naming arguments in C functions

2020-03-08 Thread mantielero
Or alternative, you can point me in the right direction if you actually know what is the problem. I read the documentation, despite neither [here](https://github.com/nim-lang/c2nim) nor [here

Re: FFI: how to avoid naming arguments in C functions

2020-03-08 Thread mantielero
When I try to use c2nim, it tends to fail while parsing stuff (vapoursynth and gr). Por example, with [gr.h](https://github.com/sciapp/gr/blob/master/lib/gr/gr.h): $ c2nim --header gr.h gr.h(27, 25) Error: token expected: ; $ c2nim --dynlib /usr/gr/lib/libGR.so

Re: FFI: how to avoid naming arguments in C functions

2020-03-08 Thread mantielero
By the way, I am just playing with [gr framework](https://gr-framework.org/). #import gr_wrapper const libName = "/usr/gr/lib/libGR.so" proc gr_initgr*(){.importc,dynlib: libName.} proc gr_polyline*(a:cint, b:ptr cdouble, c:ptr cdouble)

FFI: how to avoid naming arguments in C functions

2020-03-08 Thread mantielero
Is it possible to avoid giving names to arguments in the functions? I have the following in the C header: DLLEXPORT void gr_polyline(int, double *, double *); Run and in order to make it work, I have to do: proc gr_polyline*(a:cint, b:ptr cdouble, c:ptr

Re: FFI: from seq[int] to C array

2020-03-07 Thread mantielero
Solved with unsafeAddr(arr[0]) instead of unsafeAddr(arr)

FFI: from seq[int] to C array

2020-03-07 Thread mantielero
I have wrapped a C function with the following signature: type VSAPI* {.bycopy.} = object ... propSetIntArray*: proc(map:ptr VSMap, key:cstring, i:ptr int64, size:cint):cint ... Run I want to make easier to deal with it with something like

Re: Creating functions at runtime

2020-03-07 Thread mantielero
Thanks for the clarifications. I'll try to improve it if I manage to get everything working beforehand.

Re: Creating functions at runtime

2020-03-07 Thread mantielero
I see that this [nimeval - execute](https://forum.nim-lang.org/t/1319#8265) could be useful for my problem. But it looks like it is no longer available. What is the alternative?

Re: Creating functions at runtime

2020-03-07 Thread mantielero
I am trying to make something like the following: macro gen_function(plugin:string, functionName:string) = var source = fmt""" proc {functionName}():ptr VSMap = let plug = getPluginById("{plugin}") let args = createMap() return API.invoke(plug,

Creating functions at runtime

2020-03-07 Thread mantielero
I am wrapping VapourSynth and I facing a problem that I don't how to best face it. I want to make available a number of functions that are available from plugins. The plugins available are known at runtime. For example the following works: macro gen_functions():typed = var

  1   2   >