clangformat
This commit is contained in:
parent
bb6e6a15f1
commit
fe398ab983
@ -109,8 +109,8 @@ PYBIND11_MODULE(MODULE_NAME, m)
|
||||
|
||||
py::class_<GraphicElement>(m, "GraphicElement")
|
||||
.def(py::init<GraphicElement::type_t, GraphicElement::style_t, float, float, float, float, float>(),
|
||||
py::arg("type"), py::arg("style"), py::arg("x1"), py::arg("y1"), py::arg("x2"), py::arg("y2"), py::arg("z")
|
||||
)
|
||||
py::arg("type"), py::arg("style"), py::arg("x1"), py::arg("y1"), py::arg("x2"), py::arg("y2"),
|
||||
py::arg("z"))
|
||||
.def_readwrite("type", &GraphicElement::type)
|
||||
.def_readwrite("x1", &GraphicElement::x1)
|
||||
.def_readwrite("y1", &GraphicElement::y1)
|
||||
|
@ -22,10 +22,10 @@
|
||||
#define COMMON_PYBINDINGS_H
|
||||
|
||||
#include <Python.h>
|
||||
#include <iostream>
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
#include <iostream>
|
||||
#include "pycontainers.h"
|
||||
#include "pywrappers.h"
|
||||
|
||||
|
@ -45,7 +45,8 @@ pair<Iterator, Iterator> containing (current, end), wrapped in a ContextualWrapp
|
||||
|
||||
*/
|
||||
|
||||
template <typename T, py::return_value_policy P, typename value_conv = PythonConversion::pass_through<T>> struct iterator_wrapper
|
||||
template <typename T, py::return_value_policy P, typename value_conv = PythonConversion::pass_through<T>>
|
||||
struct iterator_wrapper
|
||||
{
|
||||
typedef decltype(*(std::declval<T>())) value_t;
|
||||
|
||||
@ -73,9 +74,10 @@ template <typename T, py::return_value_policy P, typename value_conv = PythonCon
|
||||
/*
|
||||
A pair that doesn't automatically become a tuple
|
||||
*/
|
||||
template <typename Ta, typename Tb> struct iter_pair {
|
||||
iter_pair() {};
|
||||
iter_pair(const Ta &first, const Tb &second) : first(first), second(second) {};
|
||||
template <typename Ta, typename Tb> struct iter_pair
|
||||
{
|
||||
iter_pair(){};
|
||||
iter_pair(const Ta &first, const Tb &second) : first(first), second(second){};
|
||||
Ta first;
|
||||
Tb second;
|
||||
};
|
||||
@ -117,14 +119,14 @@ struct range_wrapper
|
||||
|
||||
static void wrap(py::module &m, const char *range_name, const char *iter_name)
|
||||
{
|
||||
py::class_<wrapped_range>(m, range_name).def("__iter__", iter).def("__repr__", repr);
|
||||
py::class_<wrapped_range>(m, range_name).def("__iter__", iter).def("__repr__", repr);
|
||||
iterator_wrapper<iterator_t, P, value_conv>().wrap(m, iter_name);
|
||||
}
|
||||
|
||||
typedef iterator_wrapper<iterator_t, P, value_conv> iter_wrap;
|
||||
};
|
||||
|
||||
#define WRAP_RANGE(m, t, conv) \
|
||||
#define WRAP_RANGE(m, t, conv) \
|
||||
range_wrapper<t##Range, py::return_value_policy::copy, conv>().wrap(m, #t "Range", #t "Iterator")
|
||||
|
||||
/*
|
||||
@ -286,12 +288,15 @@ template <typename T1, typename T2, typename value_conv> struct map_pair_wrapper
|
||||
KeyError();
|
||||
return (i == 1) ? py::cast(value_conv()(x.ctx, x.base.second))
|
||||
: py::cast(PythonConversion::string_converter<decltype(x.base.first)>().to_str(x.ctx,
|
||||
x.base.first));
|
||||
x.base.first));
|
||||
}
|
||||
|
||||
static int len(wrapped_pair &x) { return 2; }
|
||||
|
||||
static iter_pair<wrapped_pair &, int> iter(wrapped_pair &x) { return iter_pair<wrapped_pair &, int>(boost::ref(x), 0); };
|
||||
static iter_pair<wrapped_pair &, int> iter(wrapped_pair &x)
|
||||
{
|
||||
return iter_pair<wrapped_pair &, int>(boost::ref(x), 0);
|
||||
};
|
||||
|
||||
static std::string first_getter(wrapped_pair &t)
|
||||
{
|
||||
@ -357,7 +362,8 @@ template <typename T, typename value_conv> struct map_wrapper
|
||||
return x.base.count(k);
|
||||
}
|
||||
|
||||
static void wrap(py::module &m, const char *map_name, const char *kv_name, const char *kv_iter_name, const char *iter_name)
|
||||
static void wrap(py::module &m, const char *map_name, const char *kv_name, const char *kv_iter_name,
|
||||
const char *iter_name)
|
||||
{
|
||||
map_pair_wrapper<typename KV::first_type, typename KV::second_type, value_conv>::wrap(m, kv_name, kv_iter_name);
|
||||
typedef range_wrapper<T &, py::return_value_policy::copy, PythonConversion::wrap_context<KV &>> rw;
|
||||
@ -390,7 +396,8 @@ template <typename T1, typename T2> struct map_pair_wrapper_uptr
|
||||
iter.first.ctx, iter.first.base.first));
|
||||
} else if (iter.second == 1) {
|
||||
iter.second++;
|
||||
return py::cast(PythonConversion::ContextualWrapper<V &>(iter.first.ctx, *iter.first.base.second.get()));
|
||||
return py::cast(
|
||||
PythonConversion::ContextualWrapper<V &>(iter.first.ctx, *iter.first.base.second.get()));
|
||||
} else {
|
||||
PyErr_SetString(PyExc_StopIteration, "End of range reached");
|
||||
throw py::error_already_set();
|
||||
@ -409,12 +416,15 @@ template <typename T1, typename T2> struct map_pair_wrapper_uptr
|
||||
KeyError();
|
||||
return (i == 1) ? py::cast(PythonConversion::ContextualWrapper<V &>(x.ctx, *x.base.second.get()))
|
||||
: py::cast(PythonConversion::string_converter<decltype(x.base.first)>().to_str(x.ctx,
|
||||
x.base.first));
|
||||
x.base.first));
|
||||
}
|
||||
|
||||
static int len(wrapped_pair &x) { return 2; }
|
||||
|
||||
static iter_pair<wrapped_pair &, int> iter(wrapped_pair &x) { return iter_pair<wrapped_pair &, int>(boost::ref(x), 0); };
|
||||
static iter_pair<wrapped_pair &, int> iter(wrapped_pair &x)
|
||||
{
|
||||
return iter_pair<wrapped_pair &, int>(boost::ref(x), 0);
|
||||
};
|
||||
|
||||
static std::string first_getter(wrapped_pair &t)
|
||||
{
|
||||
@ -483,7 +493,8 @@ template <typename T> struct map_wrapper_uptr
|
||||
return x.base.count(k);
|
||||
}
|
||||
|
||||
static void wrap(py::module &m, const char *map_name, const char *kv_name, const char *kv_iter_name, const char *iter_name)
|
||||
static void wrap(py::module &m, const char *map_name, const char *kv_name, const char *kv_iter_name,
|
||||
const char *iter_name)
|
||||
{
|
||||
map_pair_wrapper_uptr<typename KV::first_type, typename KV::second_type>::wrap(m, kv_name, kv_iter_name);
|
||||
typedef range_wrapper<T &, py::return_value_policy::copy, PythonConversion::wrap_context<KV &>> rw;
|
||||
@ -497,9 +508,9 @@ template <typename T> struct map_wrapper_uptr
|
||||
}
|
||||
};
|
||||
|
||||
#define WRAP_MAP(m, t, conv, name) \
|
||||
#define WRAP_MAP(m, t, conv, name) \
|
||||
map_wrapper<t, conv>().wrap(m, #name, #name "KeyValue", #name "KeyValueIter", #name "Iterator")
|
||||
#define WRAP_MAP_UPTR(m, t, name) \
|
||||
#define WRAP_MAP_UPTR(m, t, name) \
|
||||
map_wrapper_uptr<t>().wrap(m, #name, #name "KeyValue", #name "KeyValueIter", #name "Iterator")
|
||||
|
||||
NEXTPNR_NAMESPACE_END
|
||||
|
@ -262,7 +262,8 @@ template <typename Class, typename FuncT, FuncT fn, typename arg1_conv> struct f
|
||||
|
||||
template <typename WrapCls> static void def_wrap(WrapCls cls_, const char *name) { cls_.def(name, wrapped_fn); }
|
||||
|
||||
template <typename WrapCls, typename Ta> static void def_wrap(WrapCls cls_, const char *name, Ta a = py::arg("arg1"))
|
||||
template <typename WrapCls, typename Ta>
|
||||
static void def_wrap(WrapCls cls_, const char *name, Ta a = py::arg("arg1"))
|
||||
{
|
||||
cls_.def(name, wrapped_fn, a);
|
||||
}
|
||||
|
@ -157,29 +157,29 @@ void arch_wrap_python(py::module &m)
|
||||
fn_wrapper_4a_v<Context, decltype(&Context::addWire), &Context::addWire, conv_from_str<IdString>,
|
||||
conv_from_str<IdString>, pass_through<int>, pass_through<int>>::def_wrap(ctx_cls, "addWire",
|
||||
"name"_a, "type"_a, "x"_a,
|
||||
"y"_a);
|
||||
"y"_a);
|
||||
fn_wrapper_6a_v<Context, decltype(&Context::addPip), &Context::addPip, conv_from_str<IdString>,
|
||||
conv_from_str<IdString>, conv_from_str<IdString>, conv_from_str<IdString>, pass_through<DelayInfo>,
|
||||
pass_through<Loc>>::def_wrap(ctx_cls, "addPip",
|
||||
"name"_a, "type"_a, "srcWire"_a, "dstWire"_a, "delay"_a, "loc"_a);
|
||||
pass_through<Loc>>::def_wrap(ctx_cls, "addPip", "name"_a, "type"_a, "srcWire"_a, "dstWire"_a,
|
||||
"delay"_a, "loc"_a);
|
||||
fn_wrapper_5a_v<Context, decltype(&Context::addAlias), &Context::addAlias, conv_from_str<IdString>,
|
||||
conv_from_str<IdString>, conv_from_str<IdString>, conv_from_str<IdString>,
|
||||
pass_through<DelayInfo>>::def_wrap(ctx_cls, "addAlias",
|
||||
"name"_a, "type"_a, "srcWire"_a, "dstWire"_a, "delay"_a);
|
||||
pass_through<DelayInfo>>::def_wrap(ctx_cls, "addAlias", "name"_a, "type"_a, "srcWire"_a,
|
||||
"dstWire"_a, "delay"_a);
|
||||
|
||||
fn_wrapper_4a_v<Context, decltype(&Context::addBel), &Context::addBel, conv_from_str<IdString>,
|
||||
conv_from_str<IdString>, pass_through<Loc>, pass_through<bool>>::def_wrap(ctx_cls, "addBel",
|
||||
"name"_a, "type"_a,
|
||||
"loc"_a, "gb"_a);
|
||||
"loc"_a, "gb"_a);
|
||||
fn_wrapper_3a_v<Context, decltype(&Context::addBelInput), &Context::addBelInput, conv_from_str<IdString>,
|
||||
conv_from_str<IdString>, conv_from_str<IdString>>::def_wrap(ctx_cls, "addBelInput",
|
||||
"bel"_a, "name"_a, "wire"_a);
|
||||
conv_from_str<IdString>, conv_from_str<IdString>>::def_wrap(ctx_cls, "addBelInput", "bel"_a,
|
||||
"name"_a, "wire"_a);
|
||||
fn_wrapper_3a_v<Context, decltype(&Context::addBelOutput), &Context::addBelOutput, conv_from_str<IdString>,
|
||||
conv_from_str<IdString>, conv_from_str<IdString>>::def_wrap(ctx_cls, "addBelOutput",
|
||||
"bel"_a, "name"_a, "wire"_a);
|
||||
conv_from_str<IdString>, conv_from_str<IdString>>::def_wrap(ctx_cls, "addBelOutput", "bel"_a,
|
||||
"name"_a, "wire"_a);
|
||||
fn_wrapper_3a_v<Context, decltype(&Context::addBelInout), &Context::addBelInout, conv_from_str<IdString>,
|
||||
conv_from_str<IdString>, conv_from_str<IdString>>::def_wrap(ctx_cls, "addBelInout",
|
||||
"bel"_a, "name"_a, "wire"_a);
|
||||
conv_from_str<IdString>, conv_from_str<IdString>>::def_wrap(ctx_cls, "addBelInout", "bel"_a,
|
||||
"name"_a, "wire"_a);
|
||||
|
||||
fn_wrapper_2a_v<Context, decltype(&Context::addGroupBel), &Context::addGroupBel, conv_from_str<IdString>,
|
||||
conv_from_str<IdString>>::def_wrap(ctx_cls, "addGroupBel", "group"_a, "bel"_a);
|
||||
@ -202,14 +202,14 @@ void arch_wrap_python(py::module &m)
|
||||
unwrap_context<DecalXY>>::def_wrap(ctx_cls, "setGroupDecal", "group"_a, "decalxy"_a);
|
||||
|
||||
fn_wrapper_3a_v<Context, decltype(&Context::setWireAttr), &Context::setWireAttr, conv_from_str<DecalId>,
|
||||
conv_from_str<IdString>, pass_through<std::string>>::def_wrap(ctx_cls, "setWireAttr",
|
||||
"wire"_a, "key"_a, "value"_a);
|
||||
conv_from_str<IdString>, pass_through<std::string>>::def_wrap(ctx_cls, "setWireAttr", "wire"_a,
|
||||
"key"_a, "value"_a);
|
||||
fn_wrapper_3a_v<Context, decltype(&Context::setBelAttr), &Context::setBelAttr, conv_from_str<DecalId>,
|
||||
conv_from_str<IdString>, pass_through<std::string>>::def_wrap(ctx_cls, "setBelAttr",
|
||||
"bel"_a, "key"_a, "value"_a);
|
||||
conv_from_str<IdString>, pass_through<std::string>>::def_wrap(ctx_cls, "setBelAttr", "bel"_a,
|
||||
"key"_a, "value"_a);
|
||||
fn_wrapper_3a_v<Context, decltype(&Context::setPipAttr), &Context::setPipAttr, conv_from_str<DecalId>,
|
||||
conv_from_str<IdString>, pass_through<std::string>>::def_wrap(ctx_cls, "setPipAttr",
|
||||
"pip"_a, "key"_a, "value"_a);
|
||||
conv_from_str<IdString>, pass_through<std::string>>::def_wrap(ctx_cls, "setPipAttr", "pip"_a,
|
||||
"key"_a, "value"_a);
|
||||
|
||||
fn_wrapper_1a_v<Context, decltype(&Context::setLutK), &Context::setLutK, pass_through<int>>::def_wrap(
|
||||
ctx_cls, "setLutK", "K"_a);
|
||||
@ -217,20 +217,20 @@ void arch_wrap_python(py::module &m)
|
||||
pass_through<double>>::def_wrap(ctx_cls, "setDelayScaling", "scale"_a, "offset"_a);
|
||||
|
||||
fn_wrapper_2a_v<Context, decltype(&Context::addCellTimingClock), &Context::addCellTimingClock,
|
||||
conv_from_str<IdString>, conv_from_str<IdString>>::def_wrap(ctx_cls, "addCellTimingClock",
|
||||
"cell"_a, "port"_a);
|
||||
conv_from_str<IdString>, conv_from_str<IdString>>::def_wrap(ctx_cls, "addCellTimingClock", "cell"_a,
|
||||
"port"_a);
|
||||
fn_wrapper_4a_v<Context, decltype(&Context::addCellTimingDelay), &Context::addCellTimingDelay,
|
||||
conv_from_str<IdString>, conv_from_str<IdString>, conv_from_str<IdString>,
|
||||
pass_through<DelayInfo>>::def_wrap(ctx_cls, "addCellTimingDelay",
|
||||
"cell"_a, "fromPort"_a, "toPort"_a, "delay"_a);
|
||||
pass_through<DelayInfo>>::def_wrap(ctx_cls, "addCellTimingDelay", "cell"_a, "fromPort"_a,
|
||||
"toPort"_a, "delay"_a);
|
||||
fn_wrapper_5a_v<Context, decltype(&Context::addCellTimingSetupHold), &Context::addCellTimingSetupHold,
|
||||
conv_from_str<IdString>, conv_from_str<IdString>, conv_from_str<IdString>, pass_through<DelayInfo>,
|
||||
pass_through<DelayInfo>>::def_wrap(ctx_cls, "addCellTimingSetupHold",
|
||||
"cell"_a, "port"_a, "clock"_a, "setup"_a, "hold"_a);
|
||||
pass_through<DelayInfo>>::def_wrap(ctx_cls, "addCellTimingSetupHold", "cell"_a, "port"_a, "clock"_a,
|
||||
"setup"_a, "hold"_a);
|
||||
fn_wrapper_4a_v<Context, decltype(&Context::addCellTimingClockToOut), &Context::addCellTimingClockToOut,
|
||||
conv_from_str<IdString>, conv_from_str<IdString>, conv_from_str<IdString>,
|
||||
pass_through<DelayInfo>>::def_wrap(ctx_cls, "addCellTimingClockToOut",
|
||||
"cell"_a, "port"_a, "clock"_a, "clktoq"_a);
|
||||
pass_through<DelayInfo>>::def_wrap(ctx_cls, "addCellTimingClockToOut", "cell"_a, "port"_a,
|
||||
"clock"_a, "clktoq"_a);
|
||||
|
||||
WRAP_MAP_UPTR(m, CellMap, "IdCellMap");
|
||||
WRAP_MAP_UPTR(m, NetMap, "IdNetMap");
|
||||
|
Loading…
Reference in New Issue
Block a user