Commit 8f76d597 authored by Joe Snyder's avatar Joe Snyder
Browse files

Merge branch 'issue-93-file-spec_2' into 'master'

Restructure YAML file

See merge request autopybind11/autopybind11!103
parents e6ed59ca 3c81ebb2
......@@ -99,39 +99,78 @@ to be wrapped should contain a file named ``wrapper_input.yml``.
This content should describe the classes, "free" functions
(functions that are not a part of a class), and non-typed enumerations.
This information follows a certain structure. This structure has three reserved key
tags: ``classes``, ``functions``, and ``enums``. Any tag not found within one of these
structures, is considered a namespace for the code to be found under::
<namespace>:
classes:
<class_name>:
<class_data>,
<class_2_name>:
<class_2_data>
functions:
<function_name>:
<function_data>
<namespace_2>:
enums:
This information follows a certain structure. There are a few reserved keywords
+-----------------------------+---------------------------------+
| Keyword | Expected Data |
+=============================+=================================+
| `files` | A set of C++ header files |
| | which contains the objects to |
| | be wrapped |
| | |
| | Placed Under: |
+-----------------------------+---------------------------------+
| `namespaces` | A set of strings which are the |
| | namespaces which contains the |
| | objects to be wrapped |
| | |
| | Placed Under: `files` |
| | `namespaces` |
+-----------------------------+---------------------------------+
| `classes` | Descriptive information which |
| | describes the class object to |
| | be wrapped |
| | |
| | Placed Under: `files` |
| | `namespaces` |
+-----------------------------+---------------------------------+
| `functions` | Descriptive information which |
| | describes the function object |
| | to be wrapped |
| | |
| | Placed Under: `files` |
| | `namespaces` |
+-----------------------------+---------------------------------+
| `enums` | Descriptive information which |
| | describes the enumeration |
| | object to be wrapped |
| | |
| | Placed Under: `files` |
| | `namespaces` |
+-----------------------------+---------------------------------+
An skeleton of a properly formed YAML file can be seen below. To see additional
examples, see the `Tests` directory of this repository.
.. parsed-literal::
files:
<file_name>:
namespaces:
<namespace>:
classes:
<class_name>:
<class_data>
<class_2_name>:
<class_2_data>
functions:
<function_name>:
<function_data>
namespaces:
<namespace_2>:
enums:
<enum_name>:
<enum_data>
Each type of object within the reserved tags requires different pieces of information:
+-----------------------------+---------------------------------+
| C++ Object | Required YAML pieces |
+=============================+=================================+
| Class | file: <str> |
| | Path to file with class |
| +---------------------------------+
| | inst: [] |
| Class | inst: [] |
| | List of instantiation types |
| | for class. |
| | Leave blank for non-templated |
+-----------------------------+---------------------------------+
| Function | file: <str> |
| | Path to file with function |
| +---------------------------------+
| | is_template: <bool> |
| Function | is_template: <bool> |
| | "true" if function is template |
| | "false" otherwise |
| +---------------------------------+
......@@ -140,10 +179,19 @@ Each type of object within the reserved tags requires different pieces of inform
| | for function, if is_template |
| | is true |
+-----------------------------+---------------------------------+
| Enumeration | file: <str> |
| | Path to file with enumeration |
| Enumeration | <No additional information> |
+-----------------------------+---------------------------------+
An "empty" object, for example, the `simple` class or the enumeration `test`
in the following example are treated as non-templated objects::
classes:
simple:
namespaces:
first:
enums:
test:
Customize Output
#####################
......
classes:
files:
simple.h:
classes:
simple:
file: simple.h
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt
simple:
classes:
SimpleClass:
file: blacklist.h
customization:
blacklist:
members: [external_int, external_str]
functions: [wrong_one, notFound, im_protected_and_excluded]
files:
blacklist.h:
namespaces:
simple:
classes:
SimpleClass:
customization:
blacklist:
members: [external_int, external_str]
functions: [wrong_one, notFound, im_protected_and_excluded]
......@@ -80,12 +80,11 @@ class SmokeTest(unittest.TestCase):
input_yaml_file = join(tmp_input_dir, "config.yml")
with open(input_yaml_file, "w") as f:
f.write(dedent(f"""\
classes:
A:
file: {source_file}
B:
file: {source_file}
files:
{source_file}:
classes:
A:
B:
"""))
# WARNING: Because of the current ArgParser-dependent API, this
......
classes:
simple:
file: simple.h
simple_base:
file: simple.h
files:
simple.h:
classes:
simple:
simple_base:
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt
nmspc1:
classes:
Base:
file: Base.hpp
inst: []
files:
Base.hpp:
namespaces:
nmspc1:
classes:
Base:
inst: []
customization:
name: base
functions:
free_add:
is_template: false
customization:
name: base
T1:
file: tmplt_derived.hpp
inst: [double, int]
customization:
name: [t1D, t1I]
nmspc2:
classes:
T2:
file: tmplt_derived.hpp
inst:
- [double, int]
- [double, double]
customization:
name: 'lambda c: "T2_"+c[0][0]+c[1][1]'
T3:
file: tmplt_derived.hpp
inst:
- [double, int, float]
- [int, double, double]
- [int, int, int]
customization:
name: 'lambda c: "T3_"+c[0][0]+c[1][1]+c[2][1]'
functions:
overloaded_non_template:
file: tmplt_derived.hpp
is_template: false
customization:
name: ont_cus
functions:
free_add:
file: Base.hpp
is_template: false
customization:
name: free_add
name: free_add
free_add_templ:
file: Base.hpp
is_template: true
inst: [double, int]
customization:
name: free_templ_add
free_add_templ:
is_template: true
inst: [ double, int ]
customization:
name: free_templ_add
enums:
namedType:
file: Base.hpp
customization:
name: enum_nt
custom_enum_vals:
One: Uno
Three: Tres
enums:
namedType:
customization:
name: enum_nt
custom_enum_vals:
One: Uno
Three: Tres
unscopedType:
customization:
name: unscope
tmplt_derived.hpp:
namespaces:
nmspc1:
classes:
T1:
file:
inst: [double, int]
customization:
name: [t1D, t1I]
namespaces:
nmspc2:
classes:
T2:
inst:
- [double, int]
- [double, double]
customization:
name: 'lambda c: "T2_"+c[0][0]+c[1][1]'
unscopedType:
file: Base.hpp
customization:
name: unscope
\ No newline at end of file
T3:
inst:
- [double, int, float]
- [int, double, double]
- [int, int, int]
customization:
name: 'lambda c: "T3_"+c[0][0]+c[1][1]+c[2][1]'
functions:
overloaded_non_template:
is_template: false
customization:
name: ont_cus
\ No newline at end of file
classes:
no_nmspc_class:
file: no_namespace.hpp
customization:
namespace: foo
module_local:
functions:
no_nmspc_func:
file: no_namespace.hpp
customization:
namespace: foo
outer:
inbetween:
files:
no_namespace.hpp:
classes:
inbetweener:
file: nested_names.hpp
no_nmspc_class:
customization:
namespace: foo.bar
namespace: foo
module_local:
functions:
inbetweener_fun:
file: nested_names.hpp
no_nmspc_func:
customization:
namespace: foo.bar
three:
classes:
third_nmspc_class:
file: nested_names.hpp
customization:
namespace: foo.bar.third
module_local:
functions:
third_namespace_fun:
file: nested_names.hpp
outer_but_inner:
classes:
outer_but_inner_class:
file: nested_names.hpp
customization:
module_local:
justafunc:
functions:
getvalue:
file: nested_names.hpp
customization:
namespace: foo.bar
functions:
outer_namespace_fun:
file: nested_names.hpp
customization:
namespace: foo.bar
namespace: foo
nested_names.hpp:
namespaces:
outer:
namespaces:
inbetween:
classes:
inbetweener:
file:
customization:
namespace: foo.bar
module_local:
functions:
inbetweener_fun:
customization:
namespace: foo.bar
namespaces:
three:
classes:
third_nmspc_class:
customization:
namespace: foo.bar.third
module_local:
functions:
third_namespace_fun:
outer_but_inner:
classes:
outer_but_inner_class:
customization:
module_local:
justafunc:
functions:
getvalue:
customization:
namespace: foo.bar
functions:
outer_namespace_fun:
customization:
namespace: foo.bar
\ No newline at end of file
classes:
no_nmspc_class:
file: no_namespace.hpp
customization:
namespace: foo
module_local:
functions:
no_nmspc_func:
file: no_namespace.hpp
customization:
namespace: foo
outer:
inbetween:
files:
no_namespace.hpp:
classes:
inbetweener:
file: nested_names.hpp
no_nmspc_class:
customization:
namespace: foo.bar
namespace: foo
module_local:
functions:
inbetweener_fun:
file: nested_names.hpp
no_nmspc_func:
customization:
namespace: foo.bar
three:
classes:
third_nmspc_class:
file: nested_names.hpp
customization:
namespace: foo.bar.third
module_local:
functions:
third_namespace_fun:
file: nested_names.hpp
customization:
namespace: foo.bar.third
outer_but_inner:
classes:
outer_but_inner_class:
file: nested_names.hpp
customization:
module_local:
justafunc:
functions:
getvalue:
file: nested_names.hpp
customization:
namespace: foo.bar
functions:
outer_namespace_fun:
file: nested_names.hpp
namespace: foo
nested_names.hpp:
namespaces:
outer:
namespaces:
inbetween:
classes:
inbetweener:
file:
customization:
namespace: foo.bar
module_local:
functions:
inbetweener_fun:
customization:
namespace: foo.bar
namespaces:
three:
classes:
third_nmspc_class:
customization:
namespace: foo.bar.third
module_local:
functions:
third_namespace_fun:
customization:
namespace: foo.bar.third
outer_but_inner:
classes:
outer_but_inner_class:
customization:
module_local:
justafunc:
functions:
getvalue:
customization:
namespace: foo.bar
functions:
outer_namespace_fun:
classes:
files:
simple.h:
classes:
FormulaCell:
file: simple.h
classes:
better_printer:
file: mylib.h
\ No newline at end of file
files:
mylib.h:
classes:
better_printer:
\ No newline at end of file
classes:
outer_class:
file: outer.hpp
files:
outer.hpp:
classes:
outer_class:
functions:
outer_fxn:
functions:
outer_fxn:
file: outer.hpp
inner:
classes:
inner_class:
file: inner.hpp
functions:
inner_fxn:
file: inner.hpp
inner.hpp:
namespaces:
inner:
classes:
inner_class:
functions:
inner_fxn:
\ No newline at end of file
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt
nmspc1:
nmspc2:
classes:
Derived2:
file: non_template/derived2.hpp
protectedClass:
file: non_template/derived2.hpp
TD2:
file: template/tmplt_derived2.hpp
inst:
- [float, double]
- [int, double]
files:
non_template/derived2.hpp:
namespaces:
nmspc1:
namespaces:
nmspc2:
classes:
Derived2:
protectedClass:
functions:
call_virt_from_derived2:
template/tmplt_derived2.hpp:
namespaces:
nmspc1:
namespaces:
nmspc2:
classes:
TD2:
inst:
- [float, double]
- [int, double]
functions:
call_virt_from_td2:
inst:
- [ float, double ]
- [ int, double ]
non_template/inherits_all.hpp:
namespaces:
nmspc1:
namespaces:
nmspc2:
classes:
InheritsAll: