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 source = """
    proc Version():ptr VSMap =
      let plugins = getPlugins()
      for plugin in plugins:
        
        if plugin[0] == "ffms2":
          let plug = getPluginById(plugin[1])
          let args = createMap()
          return API.invoke(plug, "Version".cstring, args)
    """
      result = parseStmt(source)
    
    Run

It works, because I know there is function call "Version" provided by the 
plugin "ffms2", so I provide the information to the compiler.

What I would like to do is moving:
    
    
    let plugins = getPlugins()
    for plugin in plugins:
        ...
    
    Run

outside of the "source" variable. But if I do that, obviously nim complains 
becuase getPlugins requires information only available at runtime.

Can I create functions at runtime? How?

Can you think in a better strategy to create all those functions?

Reply via email to