edimetia3d / pybind11_weaver Goto Github PK
View Code? Open in Web Editor NEWA fully customizable pybind11 generator to help generate code for exsiting c/c++ library.
License: MIT License
A fully customizable pybind11 generator to help generate code for exsiting c/c++ library.
License: MIT License
When a function uses T*
(or T &
) as a parameter, this function will usually want to modify the object it pointed to, e.g.
ErrorCode GetValue(int * v);
ErrorCode GetValue(std::vector<int> * vec);
However:
T
is a std container type, any modification to the copied object will not return to python runtime.These cases should be handled automatically, or at least a warning should be printed.
Hi,
This project is still under development, the PyPI package and GitHub repo are both just placeholders.
I do have a full plan to re-implement it in an open-source way, but it may take some time.
whatever, the idea in the readme should be enough, it should be able to help you create your own generator that fits your needs.
Doxygen style C++ document could be injected as docstring for exported entities.
Pybind11 intrinsically supports the binding of overloaded functions.
Nonetheless, several predicaments may arise:
Consequently, when generating an overload solely reliant on the builtin type, potential complications could emerge. For instance:
Should you bind void Foo(int, float)
prior to void Foo(bool, float)
, the Python call mod.foo(False, 8)
would align with void Foo(int, float)
, a situation incongruous with the C++ overloading mechanism.
In the face of such circumstances, it would be prudent to issue appropriate warnings when generating binding code.
The user now could only guess usage from examples, some documents should be added
This issue pertains to another complication involving pointers: The management of heap object lifetimes within pybind11 remains somewhat enigmatic.
By default, pybind11 presupposes that the lifespan of all heap objects will be regulated by the Python Garbage Collection system.
Consequently, pybind11 inherently supports only T*
and std::unique_ptr<T>
. In the case of T*
, it is assumed that each pointer references either a newly created or an existing object. Meanwhile, std::unique_ptr<T>
is permissible solely as a return type, invariably pointing to a newly instantiated object.
Should your API diverge from this paradigm, extensive coding involving Holder and Call Policy becomes imperative.
Currently, Pybind11-Weaver offers no solutions for managing these lifetimes; thus, if your API deviates from the default configuration of pybind11, the resultant code will also fail to serve your needs, necessitating the crafting of bespoke code to integrate these APIs.
I propose two potential enhancements:
/*return_policy=take_ownership*/
, to facilitate accurate call policy determination by pybind11-weaver.There should be some quality assurance:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.