From d30ecbab17c89db4cc9428bdf23b87259dffe8ec Mon Sep 17 00:00:00 2001 From: Petr Kubica Date: Thu, 7 Dec 2023 14:26:49 +0100 Subject: [PATCH] move js class initialization to constructor --- main/espFeatures/analogFeature.h | 5 ++++- main/espFeatures/digitalFeature.h | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/main/espFeatures/analogFeature.h b/main/espFeatures/analogFeature.h index 5031f87..48abac3 100644 --- a/main/espFeatures/analogFeature.h +++ b/main/espFeatures/analogFeature.h @@ -91,12 +91,15 @@ class AnalogFeature : public Next { public: using AnalogClass = jac::Class>; + 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())); diff --git a/main/espFeatures/digitalFeature.h b/main/espFeatures/digitalFeature.h index 9e2cc1a..2cd414d 100644 --- a/main/espFeatures/digitalFeature.h +++ b/main/espFeatures/digitalFeature.h @@ -325,6 +325,10 @@ class DigitalFeature : public Next { public: using DigitalClass = jac::Class>; + DigitalFeature() { + DigitalClass::init("Digital"); + } + void initialize() { Next::initialize(); @@ -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()); @@ -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));