Route all module interaction through dispatch
A module is addressed by name and command string, and nothing else. Typed API access handed a caller a pointer into the callee's function table, which meant compiling against that module's struct layout — a build-time dependency between modules that the design does not permit. Removing it also removes the manifest, the table magic constant, and the table size field, which existed only to describe and validate those tables. Load validation is now three steps: reserved contract symbols resolve, the minimum-version handshake passes, and the version and description probes return well-formed values. The contract is four reserved symbols, and a module's interface is the command vocabulary it documents. Documentation is brought in line, and artifacts are named exactly: libdpm-core.so for the library, <dpm/core.h> for the header, the dpm binary for the command-line tool.
This commit is contained in:
23
tests/fixtures/src/bad_version.cpp
vendored
23
tests/fixtures/src/bad_version.cpp
vendored
@@ -20,23 +20,6 @@
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <cstdint>
|
||||
|
||||
namespace {
|
||||
|
||||
struct manifest_entry {
|
||||
const char* api_name;
|
||||
int table_version;
|
||||
const char* symbol;
|
||||
};
|
||||
|
||||
struct manifest {
|
||||
uint32_t count;
|
||||
const manifest_entry* entries;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
extern "C" const char* dpm_module_version(void)
|
||||
{
|
||||
return "banana";
|
||||
@@ -52,12 +35,6 @@ extern "C" const char* dpm_module_core_min(void)
|
||||
return "0.1.0";
|
||||
}
|
||||
|
||||
extern "C" const void* dpm_module_manifest(void)
|
||||
{
|
||||
static const manifest m = { 0, nullptr };
|
||||
return &m;
|
||||
}
|
||||
|
||||
extern "C" int dpm_module_execute(void* ctx, const char* command,
|
||||
int argc, char** argv)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user