rdaly525 / coreir

BSD 3-Clause "New" or "Revised" License
100 stars 24 forks source link

Update Python c bindings to correctly find shared library files #26

Closed rdaly525 closed 7 years ago

rdaly525 commented 7 years ago

Use branch 'libreorg' in order to:

The load library call will always have a C++ function signature: Namespace CoreIRLoadLibrary_(Context c);

For example for stdlib: Namespace CoreIRLoadLibrary_stdlib(Context c);

leonardt commented 7 years ago

Task 1 finished in https://github.com/rdaly525/coreir/pull/29

leonardt commented 7 years ago

I imagine the Python interface to look something like

ctx = Context()
stdlib = ctx.load_library("stdlib")

To do this, it could dispatch on the argument to load_library and call the correct function coreir_stdlib.CoreIRLoadLibrary_stdlib(ctx) but either:

rdaly525 commented 7 years ago

@leonardt In regards to #2, how does the library register itself with the C-api? I think it would still necessarily involve writing an extern C function per library. Unless I am misunderstanding something...

That being said, it would be cool to be able to register library functions which would mean no need for a specific function name standard.

rdaly525 commented 7 years ago

@leonardt I just pushed to the clibfix branch (off of libreorg) the addition of the C stdlib api. There are three TODOs (one in lib/libs/stdlib.cpp, two in include/coreir-libs/stdlib.h)

It would be awesome if you could make macros (defined in include/coreir.h) that would macrofy each of the 3 TODOs.

Also now that we have the C api for the libs, you can add them to the python bindings

leonardt commented 7 years ago

README updated -- link @rdaly525 Should I submit a PR for this branch or are there other fixes pending? I'll wait to close this issue until we merge the branch.