FFIG / ffig

Generate code to call C++ libraries from other languages
MIT License
29 stars 9 forks source link

Provide a method for external APIs #405

Open petr-tik opened 6 years ago

petr-tik commented 6 years ago

As discussed in ffig/rest-api#14, FFIG API should expose few methods to help CLI or web integration.

@ajbennieston suggested defining an output pipeline with options for writing to disk/keeping in memory, running through code formatting.

output_pipeline = [SourceFormatter('py3'), FileWriter()]
generate_bindings(model, template, output_pipeline)

At a higher level, I think we need to agree on a method signature, which ffig-explorer can use without digging into the internals, like it does currently.

I suggest

def API_func_name(fname=None, source_code=None, bindings_to_generate=["py3", "py3"], autoformat_code=False, save_to_disk=False):
"""
Takes fname or source_code as long-string, generates bindings as requested, formats them or not, before either saving to disk or returning as long strings inside a dictionary of binding_name: source_code
"""

Am I missing something?