removed napi in extra utils

This commit is contained in:
Atul R 2019-08-14 08:39:49 +02:00
parent 62362c7fe8
commit fd100b6c54
15 changed files with 16 additions and 22 deletions

View File

@ -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){

View File

@ -1,11 +1,9 @@
#pragma once
#include <napi.h>
#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);
}

View File

@ -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();
}
}

View File

@ -29,7 +29,7 @@ QKeyEventWrap::QKeyEventWrap(const Napi::CallbackInfo& info): Napi::ObjectWrap<Q
Napi::External<QKeyEvent> eventObject = info[0].As<Napi::External<QKeyEvent>>();
this->instance = eventObject.Data();
} else {
extrautils::throwTypeError(env, "Wrong number of arguments");
Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException();
}
}

View File

@ -33,7 +33,7 @@ QPixmapWrap::QPixmapWrap(const Napi::CallbackInfo& info) : Napi::ObjectWrap<QPix
}else if (info.Length() == 0){
this->instance = 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);
}

View File

@ -33,7 +33,7 @@ QCheckBoxWrap::QCheckBoxWrap(const Napi::CallbackInfo& info): Napi::ObjectWrap<Q
}else if (info.Length() == 0){
this->instance = 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);

View File

@ -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();
}
}

View File

@ -36,7 +36,7 @@ QLabelWrap::QLabelWrap(const Napi::CallbackInfo& info): Napi::ObjectWrap<QLabelW
}else if (info.Length() == 0){
this->instance = 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);

View File

@ -36,7 +36,7 @@ QLineEditWrap::QLineEditWrap(const Napi::CallbackInfo& info): Napi::ObjectWrap<Q
}else if (info.Length() == 0){
this->instance = 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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -29,7 +29,7 @@ QWidgetWrap::QWidgetWrap(const Napi::CallbackInfo& info): Napi::ObjectWrap<QWidg
}else if (info.Length() == 0){
this->instance = new NWidget();
}else {
extrautils::throwTypeError(env, "Wrong number of arguments");
Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException();
}
}

View File

@ -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();
}
}