More work on moving engine into dlmalloc heap
This commit is contained in:
@@ -1,30 +1,32 @@
|
||||
#include "wrap-string.hpp"
|
||||
#include "wrap-vector.hpp"
|
||||
#include "wrap-utility.hpp"
|
||||
|
||||
#include <utility>
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
|
||||
#include "drivenengine.hpp"
|
||||
|
||||
static eng::vector<eng::pair<eng::string, DrivenEngineMaker>> makers;
|
||||
DrivenEngineReg *DrivenEngineReg::All;
|
||||
|
||||
void DrivenEngine::register_maker(const char *kind, DrivenEngineMaker maker) {
|
||||
eng::string skind(kind);
|
||||
makers.push_back(std::make_pair(skind, maker));
|
||||
DrivenEngineReg::DrivenEngineReg(const char *n, DrivenEngineMaker fn) {
|
||||
name = n;
|
||||
maker = fn;
|
||||
next = All;
|
||||
All = this;
|
||||
}
|
||||
|
||||
void DrivenEngine::print_usage(eng::ostream &strm, const char *progname) {
|
||||
void DrivenEngine::print_usage(std::ostream &strm, const char *progname) {
|
||||
strm << "Usage: " << progname << " <mode>" << std::endl;
|
||||
for (const auto &mpair : makers) {
|
||||
strm << " Mode can be: " << mpair.first << std::endl;
|
||||
for (auto reg = DrivenEngineReg::All; reg != nullptr; reg=reg->next) {
|
||||
strm << " Mode can be: " << reg->name << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
UniqueDrivenEngine DrivenEngine::make(const char *kind) {
|
||||
for (const auto &mpair : makers) {
|
||||
if (strcmp(mpair.first.c_str(), kind) == 0) {
|
||||
return mpair.second();
|
||||
for (auto reg = DrivenEngineReg::All; reg != nullptr; reg=reg->next) {
|
||||
if (strcmp(reg->name, kind) == 0) {
|
||||
return reg->maker();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
@@ -38,8 +40,8 @@ Channel::Channel(DrivenEngine *de, int chid, int port, const eng::string &target
|
||||
readline_lastc_ = 0;
|
||||
desired_prompt_ = "";
|
||||
stop_driver_ = stop;
|
||||
sb_in_ = std::make_shared<StreamBuffer>();
|
||||
sb_out_ = std::make_shared<StreamBuffer>();
|
||||
sb_in_ = eng::make_shared<StreamBuffer>();
|
||||
sb_out_ = eng::make_shared<StreamBuffer>();
|
||||
sb_drvout_ = sb_out_;
|
||||
}
|
||||
|
||||
@@ -160,7 +162,7 @@ double DrivenEngine::get_clock() {
|
||||
SharedChannel DrivenEngine::new_outgoing_channel(const eng::string &target) {
|
||||
int chid = find_unused_chid();
|
||||
new_outgoing_.push_back(chid);
|
||||
SharedChannel result = std::make_shared<Channel>(this, chid, 0, target, stop_driver_);
|
||||
SharedChannel result = eng::make_shared<Channel>(this, chid, 0, target, stop_driver_);
|
||||
channels_[chid] = result;
|
||||
return result;
|
||||
}
|
||||
@@ -250,7 +252,7 @@ void DrivenEngine::drv_notify_close(int chid, std::string_view err) {
|
||||
|
||||
int DrivenEngine::drv_notify_accept(int port) {
|
||||
int chid = find_unused_chid();
|
||||
channels_[chid] = std::make_shared<Channel>(this, chid, port, "", stop_driver_);
|
||||
channels_[chid] = eng::make_shared<Channel>(this, chid, port, "", stop_driver_);
|
||||
accepted_channels_.push_back(channels_[chid]);
|
||||
return chid;
|
||||
}
|
||||
@@ -288,8 +290,8 @@ bool DrivenEngine::drv_get_stop_driver() const {
|
||||
|
||||
DrivenEngine::DrivenEngine() {
|
||||
next_unused_chid_ = 1;
|
||||
stdio_channel_ = std::make_shared<Channel>(this, 0, 0, "", false);
|
||||
stdio_channel_->sb_drvout_ = std::make_shared<StreamBuffer>();
|
||||
stdio_channel_ = eng::make_shared<Channel>(this, 0, 0, "", false);
|
||||
stdio_channel_->sb_drvout_ = eng::make_shared<StreamBuffer>();
|
||||
channels_[0] = stdio_channel_;
|
||||
rescan_lua_source_ = true;
|
||||
clock_ = 0.0;
|
||||
|
||||
Reference in New Issue
Block a user