Skip to content

Commit

Permalink
move js class initialization to constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
cubicap committed Dec 7, 2023
1 parent 6a99ed7 commit d30ecba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion main/espFeatures/analogFeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,15 @@ class AnalogFeature : public Next {
public:
using AnalogClass = jac::Class<AnalogProtoBuilder<AnalogFeature>>;

AnalogFeature() {
AnalogClass::init("Analog");
}

void initialize() {
Next::initialize();

auto& module = this->newModule("embedded:io/analog");

AnalogClass::init("Analog");
AnalogClass::initContext(this->context());

module.addExport("Analog", AnalogClass::getConstructor(this->context()));
Expand Down
7 changes: 4 additions & 3 deletions main/espFeatures/digitalFeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@ class DigitalFeature : public Next {
public:
using DigitalClass = jac::Class<DigitalProtoBuilder<DigitalFeature>>;

DigitalFeature() {
DigitalClass::init("Digital");
}

void initialize() {
Next::initialize();

Expand All @@ -339,7 +343,6 @@ class DigitalFeature : public Next {

auto& module = this->newModule("embedded:io/digital");

DigitalClass::init("Digital");
DigitalClass::initContext(this->context());

jac::Object digitalConstructor = DigitalClass::getConstructor(this->context());
Expand All @@ -358,8 +361,6 @@ class DigitalFeature : public Next {
digitalConstructor.set("Falling", DigitalEdge::FALLING);
}

DigitalFeature() {}

~DigitalFeature() {
for (auto pin : PinConfig::INTERRUPT_PINS) {
gpio_intr_disable(Next::getDigitalPin(pin));
Expand Down

0 comments on commit d30ecba

Please sign in to comment.