diff --git a/gen/examples/synth_shed/Makefile b/gen/examples/synth_shed/Makefile index 95f73dc..b456855 100644 --- a/gen/examples/synth_shed/Makefile +++ b/gen/examples/synth_shed/Makefile @@ -1,11 +1,20 @@ -YML2_PATH=$(HOME)/src/pepbase/default/yml2 -YML2_PROC=$(YML2_PATH)/yml2proc $(YML2_OPTS) -YML2_OPTS=--encoding=utf8 +include Makefile.conf +YML2_FILE=py_module.yml2 +CC_FILE=py_module.cc -py_module.cc : gen_pybind.ysl2 cid_grammar.yml2 - $(YML2_PROC) -y $< cid_grammar.yml2 + +.PHONY = yml cc + +all: yml cc + +yml: + $(GEN_CID_DIR)/gen_yml.py $(abspath config.json) + +cc : $(YML2_FILE) + $(YML2_PROC) -y $(GEN_CID_DIR)/gen_cc.ysl2 $(YML2_FILE) clean: - echo -f $(YML2_MARKERS) + rm -f $(YML2_FILE) + rm -f $(CC_FILE) diff --git a/gen/examples/synth_shed/Makefile.conf b/gen/examples/synth_shed/Makefile.conf new file mode 100644 index 0000000..00bfd37 --- /dev/null +++ b/gen/examples/synth_shed/Makefile.conf @@ -0,0 +1,5 @@ +YML2_PATH=$(HOME)/src/pepbase/default/yml2 +YML2_PROC=$(YML2_PATH)/yml2proc $(YML2_OPTS) +YML2_OPTS=--encoding=utf8 + +GEN_CID_DIR=../../gen_cid/ diff --git a/gen/examples/synth_shed/cid_grammar.yml2 b/gen/examples/synth_shed/cid_grammar.yml2 deleted file mode 100644 index de6cd82..0000000 --- a/gen/examples/synth_shed/cid_grammar.yml2 +++ /dev/null @@ -1,65 +0,0 @@ -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; -}; - - -} diff --git a/gen/examples/synth_shed/config.json b/gen/examples/synth_shed/config.json new file mode 100644 index 0000000..0f53e81 --- /dev/null +++ b/gen/examples/synth_shed/config.json @@ -0,0 +1,16 @@ +{ + "module_name": "synth_shed", + "header_filename": "../../src/synth_shed/synth_shed.h", + "libclang_path": "/opt/local/libexec/llvm-9.0/lib/libclang.dylib", + "variables": [ + ], + "functions": [ + "init_synth_shed", + "synth_create", + "synth_set_osc_count", + "tech_to_string", + "update_identity", + "filtertype_to_string", + "play_synth" + ] +} diff --git a/gen/examples/synth_shed/gen_pybind.marker b/gen/examples/synth_shed/gen_pybind.marker deleted file mode 100644 index 3cc762b..0000000 --- a/gen/examples/synth_shed/gen_pybind.marker +++ /dev/null @@ -1 +0,0 @@ -"" \ No newline at end of file diff --git a/gen/examples/synth_shed/py_module.cc b/gen/examples/synth_shed/py_module.cc deleted file mode 100644 index 51bc844..0000000 --- a/gen/examples/synth_shed/py_module.cc +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include -#include -#include -#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, "") - ; - - -} diff --git a/gen/examples/synth_shed/synth_shed.h.cid.yml2 b/gen/examples/synth_shed/synth_shed.h.cid.yml2 deleted file mode 100644 index 3804762..0000000 --- a/gen/examples/synth_shed/synth_shed.h.cid.yml2 +++ /dev/null @@ -1,53 +0,0 @@ -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; -}; - diff --git a/gen/examples/synth_shed/synth_shed.py b/gen/examples/synth_shed/synth_shed.py deleted file mode 100755 index 5782293..0000000 --- a/gen/examples/synth_shed/synth_shed.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -import gen_cid -from gen_cid import utils - -def main(): - vars = [] - funcs = [] - funcs.append("init_synth_shed") - funcs.append("synth_create") - funcs.append("synth_set_osc_count") - funcs.append("tech_to_string") - funcs.append("update_identity") - funcs.append("filtertype_to_string") - funcs.append("play_synth") - - header_filename = "../../src/synth_shed/synth_shed.h" - libclang_path = "/opt/local/libexec/llvm-9.0/lib/libclang.dylib" - - cidtools = gen_cid.CIDTools(libclang_path, header_filename, "synth_shed") - header = cidtools.extract(vars, funcs, debug_ast=True, debug_cid=True, debug_yml=True) - - print(header["yml"]) - utils.write_string(header["yml"], "./" + "/" + header["filename"] + ".cid.yml2", ) - - - -if __name__ == "__main__": - main()