From fd100b6c54eef450b1bb936d20c48f85a06b6c7d Mon Sep 17 00:00:00 2001 From: Atul R Date: Wed, 14 Aug 2019 08:39:49 +0200 Subject: [PATCH] removed napi in extra utils --- src/cpp/Extras/Utils/nutils.cpp | 4 ---- src/cpp/Extras/Utils/nutils.h | 6 ++---- src/cpp/QtGui/QApplication/qapplication_wrap.cpp | 2 +- src/cpp/QtGui/QEvent/QKeyEvent/qkeyevent_wrap.cpp | 2 +- src/cpp/QtGui/QPixmap/qpixmap_wrap.cpp | 4 ++-- src/cpp/QtWidgets/QCheckBox/qcheckbox_wrap.cpp | 2 +- src/cpp/QtWidgets/QGridLayout/qgridlayout_wrap.cpp | 2 +- src/cpp/QtWidgets/QLabel/qlabel_wrap.cpp | 2 +- src/cpp/QtWidgets/QLineEdit/qlineedit_wrap.cpp | 2 +- src/cpp/QtWidgets/QMainWindow/qmainwindow_wrap.cpp | 2 +- src/cpp/QtWidgets/QProgressBar/qprogressbar_wrap.cpp | 2 +- src/cpp/QtWidgets/QPushButton/qpushbutton_wrap.cpp | 2 +- src/cpp/QtWidgets/QRadioButton/qradiobutton_wrap.cpp | 2 +- src/cpp/QtWidgets/QWidget/qwidget_wrap.cpp | 2 +- src/cpp/core/FlexLayout/flexlayout_wrap.cpp | 2 +- 15 files changed, 16 insertions(+), 22 deletions(-) diff --git a/src/cpp/Extras/Utils/nutils.cpp b/src/cpp/Extras/Utils/nutils.cpp index f7c28187d..7c595bd56 100644 --- a/src/cpp/Extras/Utils/nutils.cpp +++ b/src/cpp/Extras/Utils/nutils.cpp @@ -5,10 +5,6 @@ void extrautils::noop(){} -void extrautils::throwTypeError(Napi::Env env, std::string errorMessage){ - Napi::TypeError::New(env, errorMessage.c_str()).ThrowAsJavaScriptException(); -} - YGSize extrautils::measureQtWidget (YGNodeRef node, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode){ FlexLayout::NodeContext *ctx = FlexLayout::getNodeContext(node); if(ctx){ diff --git a/src/cpp/Extras/Utils/nutils.h b/src/cpp/Extras/Utils/nutils.h index f11be68be..a14944215 100644 --- a/src/cpp/Extras/Utils/nutils.h +++ b/src/cpp/Extras/Utils/nutils.h @@ -1,11 +1,9 @@ #pragma once -#include #include "src/cpp/core/FlexLayout/flexlayout.h" namespace extrautils { - void noop(); - void throwTypeError(Napi::Env env, std::string errorMessage); - YGSize measureQtWidget (YGNodeRef node, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode); + void noop(); + YGSize measureQtWidget (YGNodeRef node, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode); } diff --git a/src/cpp/QtGui/QApplication/qapplication_wrap.cpp b/src/cpp/QtGui/QApplication/qapplication_wrap.cpp index da3879008..3c2fb6b4a 100644 --- a/src/cpp/QtGui/QApplication/qapplication_wrap.cpp +++ b/src/cpp/QtGui/QApplication/qapplication_wrap.cpp @@ -32,7 +32,7 @@ QApplicationWrap::QApplicationWrap(const Napi::CallbackInfo& info) } else if (info.Length() == 0){ this->instance = new QApplication(this->argc, this->argv); } else { - extrautils::throwTypeError(env, "Wrong number of arguments"); + Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException(); } } diff --git a/src/cpp/QtGui/QEvent/QKeyEvent/qkeyevent_wrap.cpp b/src/cpp/QtGui/QEvent/QKeyEvent/qkeyevent_wrap.cpp index 06fec648b..f6d572406 100644 --- a/src/cpp/QtGui/QEvent/QKeyEvent/qkeyevent_wrap.cpp +++ b/src/cpp/QtGui/QEvent/QKeyEvent/qkeyevent_wrap.cpp @@ -29,7 +29,7 @@ QKeyEventWrap::QKeyEventWrap(const Napi::CallbackInfo& info): Napi::ObjectWrap eventObject = info[0].As>(); this->instance = eventObject.Data(); } else { - extrautils::throwTypeError(env, "Wrong number of arguments"); + Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException(); } } diff --git a/src/cpp/QtGui/QPixmap/qpixmap_wrap.cpp b/src/cpp/QtGui/QPixmap/qpixmap_wrap.cpp index 06069a796..0a51f5090 100644 --- a/src/cpp/QtGui/QPixmap/qpixmap_wrap.cpp +++ b/src/cpp/QtGui/QPixmap/qpixmap_wrap.cpp @@ -33,7 +33,7 @@ QPixmapWrap::QPixmapWrap(const Napi::CallbackInfo& info) : Napi::ObjectWrapinstance = new QPixmap(); }else { - extrautils::throwTypeError(env, "Wrong number of arguments"); + Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException(); } } @@ -57,7 +57,7 @@ Napi::Value QPixmapWrap::load(const Napi::CallbackInfo& info) QString imageUrl = QString::fromUtf8(url.Utf8Value().c_str()); loadSuccess = this->instance->load(imageUrl); }else { - extrautils::throwTypeError(env, "Wrong number of arguments"); + Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException(); } return Napi::Boolean::New(env, loadSuccess); } diff --git a/src/cpp/QtWidgets/QCheckBox/qcheckbox_wrap.cpp b/src/cpp/QtWidgets/QCheckBox/qcheckbox_wrap.cpp index 797e67f86..4b8d89c9d 100644 --- a/src/cpp/QtWidgets/QCheckBox/qcheckbox_wrap.cpp +++ b/src/cpp/QtWidgets/QCheckBox/qcheckbox_wrap.cpp @@ -33,7 +33,7 @@ QCheckBoxWrap::QCheckBoxWrap(const Napi::CallbackInfo& info): Napi::ObjectWrapinstance = new NCheckBox(); }else { - extrautils::throwTypeError(env, "Wrong number of arguments"); + Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException(); } // Adds measure function on yoga node so that widget size is calculated based on its text also. YGNodeSetMeasureFunc(this->instance->getFlexNode(), &extrautils::measureQtWidget); diff --git a/src/cpp/QtWidgets/QGridLayout/qgridlayout_wrap.cpp b/src/cpp/QtWidgets/QGridLayout/qgridlayout_wrap.cpp index dd6607a6f..b50184c68 100644 --- a/src/cpp/QtWidgets/QGridLayout/qgridlayout_wrap.cpp +++ b/src/cpp/QtWidgets/QGridLayout/qgridlayout_wrap.cpp @@ -31,7 +31,7 @@ QGridLayoutWrap::QGridLayoutWrap(const Napi::CallbackInfo& info): Napi::ObjectWr }else if (info.Length() == 0){ this->instance = new QGridLayout(); }else { - extrautils::throwTypeError(env, "Wrong number of arguments"); + Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException(); } } diff --git a/src/cpp/QtWidgets/QLabel/qlabel_wrap.cpp b/src/cpp/QtWidgets/QLabel/qlabel_wrap.cpp index 3f45b3cc5..2b9ae22c4 100644 --- a/src/cpp/QtWidgets/QLabel/qlabel_wrap.cpp +++ b/src/cpp/QtWidgets/QLabel/qlabel_wrap.cpp @@ -36,7 +36,7 @@ QLabelWrap::QLabelWrap(const Napi::CallbackInfo& info): Napi::ObjectWrapinstance = new NLabel(); }else { - extrautils::throwTypeError(env, "Wrong number of arguments"); + Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException(); } // Adds measure function on yoga node so that widget size is calculated based on its text also. YGNodeSetMeasureFunc(this->instance->getFlexNode(), &extrautils::measureQtWidget); diff --git a/src/cpp/QtWidgets/QLineEdit/qlineedit_wrap.cpp b/src/cpp/QtWidgets/QLineEdit/qlineedit_wrap.cpp index 95563d275..c0880e7ee 100644 --- a/src/cpp/QtWidgets/QLineEdit/qlineedit_wrap.cpp +++ b/src/cpp/QtWidgets/QLineEdit/qlineedit_wrap.cpp @@ -36,7 +36,7 @@ QLineEditWrap::QLineEditWrap(const Napi::CallbackInfo& info): Napi::ObjectWrapinstance = new NLineEdit(); }else { - extrautils::throwTypeError(env, "Wrong number of arguments"); + Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException(); } // Adds measure function on yoga node so that widget size is calculated based on its text also. YGNodeSetMeasureFunc(this->instance->getFlexNode(), &extrautils::measureQtWidget); diff --git a/src/cpp/QtWidgets/QMainWindow/qmainwindow_wrap.cpp b/src/cpp/QtWidgets/QMainWindow/qmainwindow_wrap.cpp index 6062d4b75..4909a020a 100644 --- a/src/cpp/QtWidgets/QMainWindow/qmainwindow_wrap.cpp +++ b/src/cpp/QtWidgets/QMainWindow/qmainwindow_wrap.cpp @@ -32,7 +32,7 @@ QMainWindowWrap::QMainWindowWrap(const Napi::CallbackInfo& info): Napi::ObjectWr }else if (info.Length() == 0){ this->instance = new NMainWindow(); }else { - extrautils::throwTypeError(env, "Wrong number of arguments"); + Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException(); } this->instance->setAttribute(Qt::WA_DeleteOnClose); this->instance->installEventFilter(this->instance); diff --git a/src/cpp/QtWidgets/QProgressBar/qprogressbar_wrap.cpp b/src/cpp/QtWidgets/QProgressBar/qprogressbar_wrap.cpp index 4da91aa57..2152f401a 100644 --- a/src/cpp/QtWidgets/QProgressBar/qprogressbar_wrap.cpp +++ b/src/cpp/QtWidgets/QProgressBar/qprogressbar_wrap.cpp @@ -37,7 +37,7 @@ QProgressBarWrap::QProgressBarWrap(const Napi::CallbackInfo& info): Napi::Object }else if (info.Length() == 0){ this->instance = new NProgressBar(); }else { - extrautils::throwTypeError(env, "Wrong number of arguments"); + Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException(); } // Adds measure function on yoga node so that widget size is calculated based on its own size. YGNodeSetMeasureFunc(this->instance->getFlexNode(), &extrautils::measureQtWidget); diff --git a/src/cpp/QtWidgets/QPushButton/qpushbutton_wrap.cpp b/src/cpp/QtWidgets/QPushButton/qpushbutton_wrap.cpp index 6a036d9c4..23c413fa7 100644 --- a/src/cpp/QtWidgets/QPushButton/qpushbutton_wrap.cpp +++ b/src/cpp/QtWidgets/QPushButton/qpushbutton_wrap.cpp @@ -31,7 +31,7 @@ QPushButtonWrap::QPushButtonWrap(const Napi::CallbackInfo& info): Napi::ObjectWr }else if (info.Length() == 0){ this->instance = new NPushButton(); }else { - extrautils::throwTypeError(env, "Wrong number of arguments"); + Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException(); } // Adds measure function on yoga node so that widget size is calculated based on its text also. YGNodeSetMeasureFunc(this->instance->getFlexNode(), &extrautils::measureQtWidget); diff --git a/src/cpp/QtWidgets/QRadioButton/qradiobutton_wrap.cpp b/src/cpp/QtWidgets/QRadioButton/qradiobutton_wrap.cpp index d73ba4b21..d0deab6d1 100644 --- a/src/cpp/QtWidgets/QRadioButton/qradiobutton_wrap.cpp +++ b/src/cpp/QtWidgets/QRadioButton/qradiobutton_wrap.cpp @@ -34,7 +34,7 @@ QRadioButtonWrap::QRadioButtonWrap(const Napi::CallbackInfo& info): Napi::Object }else if (info.Length() == 0){ this->instance = new NRadioButton(); }else { - extrautils::throwTypeError(env, "Wrong number of arguments"); + Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException(); } // Adds measure function on yoga node so that widget size is calculated based on its own size. YGNodeSetMeasureFunc(this->instance->getFlexNode(), &extrautils::measureQtWidget); diff --git a/src/cpp/QtWidgets/QWidget/qwidget_wrap.cpp b/src/cpp/QtWidgets/QWidget/qwidget_wrap.cpp index d61996a13..5c2e07f6c 100644 --- a/src/cpp/QtWidgets/QWidget/qwidget_wrap.cpp +++ b/src/cpp/QtWidgets/QWidget/qwidget_wrap.cpp @@ -29,7 +29,7 @@ QWidgetWrap::QWidgetWrap(const Napi::CallbackInfo& info): Napi::ObjectWrapinstance = new NWidget(); }else { - extrautils::throwTypeError(env, "Wrong number of arguments"); + Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException(); } } diff --git a/src/cpp/core/FlexLayout/flexlayout_wrap.cpp b/src/cpp/core/FlexLayout/flexlayout_wrap.cpp index 7295060e7..5c2919c6b 100644 --- a/src/cpp/core/FlexLayout/flexlayout_wrap.cpp +++ b/src/cpp/core/FlexLayout/flexlayout_wrap.cpp @@ -34,7 +34,7 @@ FlexLayoutWrap::FlexLayoutWrap(const Napi::CallbackInfo& info): Napi::ObjectWrap }else if (info.Length() == 0){ this->instance = new FlexLayout(); }else { - extrautils::throwTypeError(env, "Wrong number of arguments"); + Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException(); } }