Commit e93f7d12 authored by John Parent's avatar John Parent
Browse files

Fixup changes based on review

Update readme for stl yaml flag
parent a1368cb1
......@@ -150,6 +150,56 @@ This information follows a certain structure. There are a few reserved keywords
| | Placed Under: `files` |
| | `namespaces` |
+-----------------------------+---------------------------------+
| 'stl' | To directly bind members of |
| | the STL using one of two |
| | conventions. The first, via |
| | a combination of PyBind11's |
| | opaque type macro and a |
| | PyBind11 builtin for binding |
| | STL types, and the second |
| | By specifying the stl type as |
| | opaque and allowing APB and |
| | pygccxml to inspect and bind |
| | what information can be derived|
| | by running pygccxml over the |
| | stl type. |
| | A more elaborated description |
| | and example can be found below.|
+-----------------------------+---------------------------------+
Stl Binders
###########
If the binding of STL types directly as opaque types is desireable
the `stl` entry must be specified at the top level of the yaml file.
An example of this in a usable yaml file can be found in the stl_containers test.
Under the `stl` entry, the stl types for which wrapping is desireable
should be specified without a template instantiation, such as `vector` or `map`.
Under that type entry, the Python side name for the specific template instantiation of that
type should be specified, such as "VecInt". Under that name a set of parameters can be set,
some of which are optional. These options are displayed and decribed below.
.. parsed-literal::
stl:
<type>:
<name>:
type: <template inst type> (can be list or string entry)
buffer_prot: True(optional)
stl_bind: True(optional)
module_local: True(optional)
The `type` argument under the name speicifies the type that the stl type will be instantiated
with.
`buffer_prot` specifies the usage of the pybind11 buffer protocol to expose a python
buffer interface for the type.
`stl_bind` toggles the usage of PyBind11's automatic binding for the STL types. If this flag
is not specified, bindings for the STL type will be generated based of autopybind11's parsing of
the STL files directly. Use this approach with caution, as differing implementations accross systems
and architectures may result in unexpected behavior, particularly between windows and unix.
`module_local` informs autopybind11 as to whether or not the bound stl type should only be exposed to
the current local module scope, or globally defined. Default behavior is global exposure.
An skeleton of a properly formed YAML file can be seen below. To see additional
examples, see the `Tests` directory of this repository.
......
......@@ -29,5 +29,5 @@ class simple2T
public:
simple2T() {}
};
// template class std::vector<double>;
#endif // STL_CONTAINER
......@@ -49,9 +49,12 @@ class TestStlBinders(unittest.TestCase):
def test_Int2Double(self):
i2d = Int2Double()
i2d[1] = 2.2
self.assertEqual(i2d[1], 2.2)
def test_VectoVec(self):
v2v = VectoVec()
v2v[[1, 2, 3]] = [3, 2, 1]
self.assertEqual(v2v[[1, 2, 3]], [3, 2, 1])
if __name__ == "__main__":
......
......@@ -332,8 +332,6 @@ class stl_binder(object):
operator_string = ""
total_operators = set(pygccxml_data.operators())
for operator in sorted(total_operators, key=lambda c: c.name):
# If ostream is first argument, we assume this is a string representation
# function.
operator_string += binding_gen.generate_operator_string(
pygccxml_data, operator, is_stream=""
)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment