Goal
Drop the C engine API layer and expose a direct C++ API to host applications, eliminating the double-wrap between the C++ Engine class and the C++ Environment internals. The Plugin and Soundfile API interfaces keep their C ABI for DSO stability.
Motivation
The C API exists primarily to support language bindings, which are not a use case for this project. It adds an indirection layer (src/Methcla/API.cpp) that converts C++ exceptions to error codes only for the C++ wrappers to rethrow them, and requires opaque struct wrappers around already-C++ objects.
What changes
Headers removed
include/methcla/engine.h — C engine API (opaque Methcla_Engine*, Methcla_AudioDriver*, Methcla_EngineOptions*)
include/methcla/common.h — C error-handling machinery (Methcla_Error, Methcla_ReturnCode, predicates)
include/methcla/log.h — Methcla_LogHandler (replaced by std::function already in engine.hpp)
include/methcla/types.h — C enums, replaced by C++ enum class in engine/types.hpp
include/methcla/plugin.h — moves and splits (see below)
include/methcla/file.h — moves and splits (see below)
include/methcla/plugin.hpp, file.hpp, log.hpp — moved into plugin/ directory
New header layout
include/methcla/
engine/
engine.hpp ← C++ Engine class; holds EngineImpl via pimpl (no Methcla_Engine* wrapper)
types.hpp ← C++ enum classes: NodePlacement, BusMappingFlags, NodeDoneFlags
log.hpp ← LogStream (was top-level log.hpp)
detail.hpp
detail/result.hpp
plugin/
common.h ← shared C types: AudioSample, Time, OSCPacket, LogLevel
synth.h ← Methcla_World, Host, SynthDef, Library, port types (was plugin.h)
soundfile.h ← Methcla_SoundFile, SoundFileAPI, SoundFileInfo (was file.h)
synth.hpp ← C++ synth plugin authoring helpers (was plugin.hpp)
soundfile.hpp ← C++ soundfile wrapper (was file.hpp)
plugins/ ← plugin registration headers, unchanged
sine.h, disksampler.h, ...
Source removed
src/Methcla/API.cpp — the entire C adapter layer (opaque struct implementations, METHCLA_API_TRY/CATCH, methcla_engine_* exported functions)
Engine class changes
- Drops
Methcla_Engine* member; holds std::unique_ptr<EngineImpl> directly (pimpl)
EngineOptions/AudioDriverOptions hold native C++ types instead of building Methcla_EngineOptions*
- Exceptions propagate directly; no error-code round-tripping
Methcla_LogLevel in LogHandler becomes a C++ enum
What stays unchanged
plugin/synth.h and plugin/soundfile.h — full C ABI preserved (Methcla_Host, Methcla_World, Methcla_SynthDef, Methcla_Library, Methcla_SoundFileAPI)
methcla_api_host_* / methcla_api_world_* functions in Engine.cpp that implement those tables
plugins/*.h registration headers (only their #include path updates from <methcla/plugin.h> to <methcla/plugin/synth.h>)
- CMake target structure;
src/CMakeLists.txt FILE_SET HEADERS list needs updating to new paths
Out of scope
- Changing the OSC command protocol
- Modifying plugin implementations
- Any behaviour change; this is a structural/API-surface refactor only
Goal
Drop the C engine API layer and expose a direct C++ API to host applications, eliminating the double-wrap between the C++
Engineclass and the C++Environmentinternals. The Plugin and Soundfile API interfaces keep their C ABI for DSO stability.Motivation
The C API exists primarily to support language bindings, which are not a use case for this project. It adds an indirection layer (
src/Methcla/API.cpp) that converts C++ exceptions to error codes only for the C++ wrappers to rethrow them, and requires opaque struct wrappers around already-C++ objects.What changes
Headers removed
include/methcla/engine.h— C engine API (opaqueMethcla_Engine*,Methcla_AudioDriver*,Methcla_EngineOptions*)include/methcla/common.h— C error-handling machinery (Methcla_Error,Methcla_ReturnCode, predicates)include/methcla/log.h—Methcla_LogHandler(replaced bystd::functionalready inengine.hpp)include/methcla/types.h— C enums, replaced by C++enum classinengine/types.hppinclude/methcla/plugin.h— moves and splits (see below)include/methcla/file.h— moves and splits (see below)include/methcla/plugin.hpp,file.hpp,log.hpp— moved intoplugin/directoryNew header layout
Source removed
src/Methcla/API.cpp— the entire C adapter layer (opaque struct implementations,METHCLA_API_TRY/CATCH,methcla_engine_*exported functions)Engineclass changesMethcla_Engine*member; holdsstd::unique_ptr<EngineImpl>directly (pimpl)EngineOptions/AudioDriverOptionshold native C++ types instead of buildingMethcla_EngineOptions*Methcla_LogLevelinLogHandlerbecomes a C++ enumWhat stays unchanged
plugin/synth.handplugin/soundfile.h— full C ABI preserved (Methcla_Host,Methcla_World,Methcla_SynthDef,Methcla_Library,Methcla_SoundFileAPI)methcla_api_host_*/methcla_api_world_*functions inEngine.cppthat implement those tablesplugins/*.hregistration headers (only their#includepath updates from<methcla/plugin.h>to<methcla/plugin/synth.h>)src/CMakeLists.txtFILE_SET HEADERS list needs updating to new pathsOut of scope