
8 changed files with 259 additions and 11 deletions
@ -0,0 +1,23 @@ |
|||
YML2_PATH=$(HOME)/src/pepbase/default/yml2 |
|||
YML2_PROC=$(YML2_PATH)/yml2proc $(YML2_OPTS) |
|||
YML2_OPTS=--encoding=utf8 |
|||
|
|||
|
|||
MARKER_DIR=. |
|||
|
|||
YML2_MARKERS= \
|
|||
$(MARKER_DIR)/gen_pybind.marker |
|||
|
|||
.PHONY: all codegen clean |
|||
|
|||
all: codegen |
|||
|
|||
# ------------- YML2 CodeGen --------------
|
|||
codegen: $(YML2_MARKERS) |
|||
|
|||
$(YML2_MARKERS): $(MARKER_DIR)/%.marker : %.ysl2 cid_grammar.yml2 |
|||
$(YML2_PROC) -y $< cid_grammar.yml2 |
|||
|
|||
clean: -dirs |
|||
echo -f $(YML2_MARKERS) |
|||
|
@ -0,0 +1,65 @@ |
|||
decl method @name; |
|||
|
|||
decl struct @name; |
|||
decl field @name; |
|||
|
|||
decl enum @name; |
|||
decl item @name; |
|||
|
|||
namespace pEp { |
|||
|
|||
method init_synth_shed { |
|||
return type="void"; |
|||
}; |
|||
|
|||
method synth_create { |
|||
return type="synth_t *"; |
|||
use name type="const char *"; |
|||
}; |
|||
|
|||
method synth_set_osc_count { |
|||
return type="SYNTH_STATUS"; |
|||
use synth type="synth_t *"; |
|||
use osc_count type="int"; |
|||
}; |
|||
|
|||
method tech_to_string { |
|||
return type="const char *"; |
|||
use tech type="const tech_t *"; |
|||
}; |
|||
|
|||
method filtertype_to_string { |
|||
return type="const char *"; |
|||
use filt type="const filtertype_t *"; |
|||
}; |
|||
|
|||
method play_synth { |
|||
return type="const char *"; |
|||
use synth type="synth_t *"; |
|||
}; |
|||
|
|||
struct _synth { |
|||
field model_name type="const char *"; |
|||
field osc_count type="int"; |
|||
field technolgy type="tech_t"; |
|||
field filter type="filter_t"; |
|||
}; |
|||
|
|||
struct _filter { |
|||
field technology type="tech_t"; |
|||
field type type="filtertype_t"; |
|||
}; |
|||
|
|||
enum _tech { |
|||
item ANALOG value=0; |
|||
item DIGITAL value=1; |
|||
}; |
|||
|
|||
enum _filtertype { |
|||
item HPF value=0; |
|||
item LPF value=1; |
|||
item BPF value=2; |
|||
}; |
|||
|
|||
|
|||
} |
@ -0,0 +1 @@ |
|||
"" |
@ -0,0 +1,65 @@ |
|||
include yslt.yml2 |
|||
|
|||
tstylesheet { |
|||
template "pEp" { |
|||
document("py_module.cc", "text") { |
|||
|| |
|||
#include <string> |
|||
#include <iostream> |
|||
#include <pybind11/pybind11.h> |
|||
#include <pybind11/detail/common.h> |
|||
#include "synth_shed.h" |
|||
|
|||
using namespace std; |
|||
namespace py = pybind11; |
|||
|
|||
PYBIND11_MODULE(synth_shed, m) { |
|||
|
|||
`` apply "method" |
|||
|
|||
`` apply "struct" |
|||
|
|||
`` apply "enum" |
|||
|
|||
} |
|||
|| |
|||
} |
|||
document("gen_pybind.marker", "text") > "" |
|||
} |
|||
|
|||
template "method" { |
|||
|| |
|||
m.def("«@name»", &«@name», ""); |
|||
|| |
|||
} |
|||
|
|||
template "struct" { |
|||
|| |
|||
py::class_<«@name»>(m, "«@name»") |
|||
``apply "field" |
|||
; |
|||
|
|||
|| |
|||
} |
|||
|
|||
template "field" { |
|||
|| |
|||
.def_readwrite("«@name»", &::«../@name»::«@name») |
|||
|| |
|||
} |
|||
|
|||
template "enum" { |
|||
|| |
|||
py::enum_<::«@name»>(m, "«@name»") |
|||
``apply item |
|||
; |
|||
|
|||
|| |
|||
} |
|||
|
|||
template "item" { |
|||
|| |
|||
.value("«@name»", ::«@name», "") |
|||
|| |
|||
} |
|||
} |
@ -0,0 +1,44 @@ |
|||
#include <string> |
|||
#include <iostream> |
|||
#include <pybind11/pybind11.h> |
|||
#include <pybind11/detail/common.h> |
|||
#include "synth_shed.h" |
|||
|
|||
using namespace std; |
|||
namespace py = pybind11; |
|||
|
|||
PYBIND11_MODULE(synth_shed, m) { |
|||
|
|||
m.def("init_synth_shed", &init_synth_shed, ""); |
|||
m.def("synth_create", &synth_create, ""); |
|||
m.def("synth_set_osc_count", &synth_set_osc_count, ""); |
|||
m.def("tech_to_string", &tech_to_string, ""); |
|||
m.def("filtertype_to_string", &filtertype_to_string, ""); |
|||
m.def("play_synth", &play_synth, ""); |
|||
|
|||
py::class_<_synth>(m, "_synth") |
|||
.def_readwrite("model_name", &::_synth::model_name) |
|||
.def_readwrite("osc_count", &::_synth::osc_count) |
|||
.def_readwrite("technolgy", &::_synth::technolgy) |
|||
.def_readwrite("filter", &::_synth::filter) |
|||
; |
|||
|
|||
py::class_<_filter>(m, "_filter") |
|||
.def_readwrite("technology", &::_filter::technology) |
|||
.def_readwrite("type", &::_filter::type) |
|||
; |
|||
|
|||
|
|||
py::enum_<::_tech>(m, "_tech") |
|||
.value("ANALOG", ::ANALOG, "") |
|||
.value("DIGITAL", ::DIGITAL, "") |
|||
; |
|||
|
|||
py::enum_<::_filtertype>(m, "_filtertype") |
|||
.value("HPF", ::HPF, "") |
|||
.value("LPF", ::LPF, "") |
|||
.value("BPF", ::BPF, "") |
|||
; |
|||
|
|||
|
|||
} |
@ -0,0 +1,53 @@ |
|||
method init_synth_shed { |
|||
return type="void"; |
|||
}; |
|||
|
|||
method synth_create { |
|||
return type="synth_t *"; |
|||
use name type="const char *"; |
|||
}; |
|||
|
|||
method synth_set_osc_count { |
|||
return type="SYNTH_STATUS"; |
|||
use synth type="synth_t *"; |
|||
use osc_count type="int"; |
|||
}; |
|||
|
|||
method tech_to_string { |
|||
return type="const char *"; |
|||
use tech type="const tech_t *"; |
|||
}; |
|||
|
|||
method filtertype_to_string { |
|||
return type="const char *"; |
|||
use filt type="const filtertype_t *"; |
|||
}; |
|||
|
|||
method play_synth { |
|||
return type="const char *"; |
|||
use synth type="synth_t *"; |
|||
}; |
|||
|
|||
struct _synth { |
|||
field model_name type="const char *"; |
|||
field osc_count type="int"; |
|||
field technolgy type="tech_t"; |
|||
field filter type="filter_t"; |
|||
}; |
|||
|
|||
struct _filter { |
|||
field technology type="tech_t"; |
|||
field type type="filtertype_t"; |
|||
}; |
|||
|
|||
enum _tech { |
|||
item ANALOG value=0; |
|||
item DIGITAL value=1; |
|||
}; |
|||
|
|||
enum _filtertype { |
|||
item HPF value=0; |
|||
item LPF value=1; |
|||
item BPF value=2; |
|||
}; |
|||
|
Loading…
Reference in new issue