commit
1b3478e0cb
@ -13,8 +13,7 @@ namespace extrautils {
|
||||
DLL_EXPORT QVariant* convertToQVariant(Napi::Env& env, Napi::Value& value);
|
||||
DLL_EXPORT bool isNapiValueInt(Napi::Env& env, Napi::Value& num);
|
||||
DLL_EXPORT std::string getNapiObjectClassName(Napi::Object& object);
|
||||
DLL_EXPORT void* configureQWidget(QWidget* widget, YGNodeRef node,
|
||||
bool isLeafNode = false);
|
||||
DLL_EXPORT void* configureQWidget(QWidget* widget, bool isLeafNode = false);
|
||||
DLL_EXPORT void* configureQObject(QObject* object);
|
||||
DLL_EXPORT void* configureComponent(void* component);
|
||||
DLL_EXPORT uint64_t hashPointerTo53bit(const void* input);
|
||||
|
||||
@ -35,6 +35,8 @@ class DLL_EXPORT NAbstractItemModel : public QAbstractItemModel,
|
||||
return *newIndex;
|
||||
}
|
||||
|
||||
QObject* parent() const { return nullptr; }
|
||||
|
||||
QModelIndex parent(const QModelIndex& child) const override {
|
||||
Napi::Env env = this->dispatchOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
@ -14,7 +14,6 @@ class DLL_EXPORT QItemSelectionModelWrap
|
||||
|
||||
private:
|
||||
QPointer<QItemSelectionModel> instance;
|
||||
bool disableDeletion;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
|
||||
@ -5,13 +5,13 @@
|
||||
#include <QMimeData>
|
||||
|
||||
#include "Extras/Export/export.h"
|
||||
#include "core/Component/component_macro.h"
|
||||
#include "QtCore/QObject/qobject_macro.h"
|
||||
|
||||
class DLL_EXPORT QMimeDataWrap : public Napi::ObjectWrap<QMimeDataWrap> {
|
||||
COMPONENT_WRAPPED_METHODS_DECLARATION
|
||||
QOBJECT_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
private:
|
||||
std::unique_ptr<QMimeData> instance;
|
||||
QPointer<QMimeData> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
|
||||
@ -5,11 +5,12 @@
|
||||
#include "Extras/Utils/nutils.h"
|
||||
#include "QtCore/QVariant/qvariant_wrap.h"
|
||||
#include "core/Events/eventwidget_macro.h"
|
||||
/*
|
||||
#include "core/WrapperCache/wrappercache.h"
|
||||
|
||||
This macro adds common QObject exported methods
|
||||
The exported methods are taken into this macro to avoid writing them in each
|
||||
and every widget we export.
|
||||
/*
|
||||
This macro adds common QObject exported methods
|
||||
The exported methods are taken into this macro to avoid writing them in each
|
||||
and every widget we export.
|
||||
*/
|
||||
|
||||
#ifndef QOBJECT_WRAPPED_METHODS_DECLARATION_WITH_EVENT_SOURCE
|
||||
@ -20,7 +21,8 @@
|
||||
Napi::Value __id__(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
return Napi::Value::From( \
|
||||
env, extrautils::hashPointerTo53bit(this->instance.data())); \
|
||||
env, extrautils::hashPointerTo53bit( \
|
||||
static_cast<QObject*>(this->instance.data()))); \
|
||||
} \
|
||||
Napi::Value inherits(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
@ -88,6 +90,35 @@
|
||||
int id = info[0].As<Napi::Number>().Int32Value(); \
|
||||
this->instance->killTimer(id); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value parent(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
QObject* parent = this->instance->parent(); \
|
||||
if (parent) { \
|
||||
return WrapperCache::instance.getWrapper(env, parent); \
|
||||
} else { \
|
||||
return env.Null(); \
|
||||
} \
|
||||
} \
|
||||
Napi::Value deleteLater(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
this->instance->deleteLater(); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value deleteObject(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
delete static_cast<QObject*>(this->instance); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value children(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
QObjectList children = this->instance->children(); \
|
||||
Napi::Array resultArrayNapi = Napi::Array::New(env, children.size()); \
|
||||
for (int i = 0; i < children.size(); i++) { \
|
||||
resultArrayNapi[i] = \
|
||||
WrapperCache::instance.getWrapper(env, children[i]); \
|
||||
} \
|
||||
return resultArrayNapi; \
|
||||
}
|
||||
|
||||
// Ideally this macro below should go in
|
||||
@ -131,7 +162,11 @@
|
||||
InstanceMethod("dumpObjectInfo", &ComponentWrapName::dumpObjectInfo), \
|
||||
InstanceMethod("setParent", &ComponentWrapName::setParent), \
|
||||
InstanceMethod("startTimer", &ComponentWrapName::startTimer), \
|
||||
InstanceMethod("killTimer", &ComponentWrapName::killTimer),
|
||||
InstanceMethod("killTimer", &ComponentWrapName::killTimer), \
|
||||
InstanceMethod("parent", &ComponentWrapName::parent), \
|
||||
InstanceMethod("deleteLater", &ComponentWrapName::deleteLater), \
|
||||
InstanceMethod("delete", &ComponentWrapName::deleteObject), \
|
||||
InstanceMethod("children", &ComponentWrapName::children),
|
||||
|
||||
#endif // QOBJECT_WRAPPED_METHODS_EXPORT_DEFINE
|
||||
|
||||
@ -151,4 +186,22 @@
|
||||
#define QOBJECT_SIGNALS QOBJECT_SIGNALS_ON_TARGET(this)
|
||||
#endif // QOBJECT_SIGNALS
|
||||
|
||||
/*
|
||||
Macro to register a function to wrap QObject pointers of a
|
||||
given subclass to wrapper instances. First parameter is the
|
||||
plain name of the QObject subclass (no quotes), seconds is the
|
||||
name of the wrapper class.
|
||||
*/
|
||||
#ifndef QOBJECT_REGISTER_WRAPPER
|
||||
#define QOBJECT_REGISTER_WRAPPER(qobjectType, ComponentWrapName) \
|
||||
WrapperCache::instance.registerWrapper( \
|
||||
QString(#qobjectType), \
|
||||
[](Napi::Env env, QObject* qobject) -> Napi::Object { \
|
||||
qobjectType* exactQObject = dynamic_cast<qobjectType*>(qobject); \
|
||||
Napi::Object wrapper = ComponentWrapName::constructor.New( \
|
||||
{Napi::External<QObject>::New(env, exactQObject)}); \
|
||||
return wrapper; \
|
||||
});
|
||||
#endif // QOBJECT_REGISTER_WRAPPER
|
||||
|
||||
#include "QtCore/QObject/qobject_wrap.h"
|
||||
|
||||
@ -11,14 +11,15 @@
|
||||
class DLL_EXPORT QObjectWrap : public Napi::ObjectWrap<QObjectWrap> {
|
||||
QOBJECT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NObject> instance;
|
||||
QPointer<QObject> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QObjectWrap(const Napi::CallbackInfo& info);
|
||||
~QObjectWrap();
|
||||
NObject* getInternalInstance();
|
||||
QObject* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
static Napi::Object wrapFunc(Napi::Env env, QObject* qobject);
|
||||
// wrapped methods
|
||||
};
|
||||
|
||||
@ -29,8 +29,7 @@ class DLL_EXPORT NApplication : public QApplication, public EventWidget {
|
||||
this, &QGuiApplication::primaryScreenChanged, [=](QScreen* screen) {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
auto instance =
|
||||
WrapperCache::instance.get<QScreen, QScreenWrap>(env, screen);
|
||||
auto instance = WrapperCache::instance.getWrapper(env, screen, true);
|
||||
this->emitOnNode.Call(
|
||||
{Napi::String::New(env, "primaryScreenChanged"), instance});
|
||||
});
|
||||
@ -38,8 +37,7 @@ class DLL_EXPORT NApplication : public QApplication, public EventWidget {
|
||||
QObject::connect(this, &QGuiApplication::screenAdded, [=](QScreen* screen) {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
auto instance =
|
||||
WrapperCache::instance.get<QScreen, QScreenWrap>(env, screen);
|
||||
auto instance = WrapperCache::instance.getWrapper(env, screen, true);
|
||||
this->emitOnNode.Call({Napi::String::New(env, "screenAdded"), instance});
|
||||
});
|
||||
|
||||
@ -47,8 +45,7 @@ class DLL_EXPORT NApplication : public QApplication, public EventWidget {
|
||||
this, &QGuiApplication::screenRemoved, [=](QScreen* screen) {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
auto instance =
|
||||
WrapperCache::instance.get<QScreen, QScreenWrap>(env, screen);
|
||||
auto instance = WrapperCache::instance.getWrapper(env, screen, true);
|
||||
this->emitOnNode.Call(
|
||||
{Napi::String::New(env, "screenRemoved"), instance});
|
||||
});
|
||||
|
||||
@ -22,13 +22,13 @@ class DLL_EXPORT QDragWrap : public Napi::ObjectWrap<QDragWrap> {
|
||||
// except that it is automatically cleared when the referenced object is
|
||||
// destroyed (unlike normal C++ pointers, which become "dangling pointers" in
|
||||
// such cases). T must be a subclass of QObject.
|
||||
QPointer<NDrag> instance;
|
||||
QPointer<QDrag> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QDragWrap(const Napi::CallbackInfo& info);
|
||||
~QDragWrap();
|
||||
NDrag* getInternalInstance();
|
||||
QDrag* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
|
||||
|
||||
@ -145,9 +145,7 @@
|
||||
Napi::Value selectionModel(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
QItemSelectionModel* model = this->instance->selectionModel(); \
|
||||
auto modelExt = Napi::External<QItemSelectionModel>::New(env, model); \
|
||||
auto instance = QItemSelectionModelWrap::constructor.New({modelExt}); \
|
||||
return instance; \
|
||||
return WrapperCache::instance.getWrapper(env, model); \
|
||||
} \
|
||||
Napi::Value isPersistentEditorOpen(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
|
||||
@ -58,9 +58,7 @@
|
||||
Napi::Value viewport(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
QWidget* viewPort = this->instance->viewport(); \
|
||||
NWidget* nviewPort = reinterpret_cast<NWidget*>(viewPort); \
|
||||
auto instance = QWidgetWrap::constructor.New( \
|
||||
{Napi::External<NWidget>::New(env, nviewPort)}); \
|
||||
auto instance = WrapperCache::instance.getWrapper(env, viewPort); \
|
||||
return instance; \
|
||||
}
|
||||
|
||||
|
||||
@ -11,14 +11,13 @@ class DLL_EXPORT QActionWrap : public Napi::ObjectWrap<QActionWrap> {
|
||||
QOBJECT_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
private:
|
||||
QPointer<NAction> instance;
|
||||
bool disableDeletion;
|
||||
QPointer<QAction> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QActionWrap(const Napi::CallbackInfo& info);
|
||||
~QActionWrap();
|
||||
NAction* getInternalInstance();
|
||||
QAction* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -12,13 +12,13 @@
|
||||
class DLL_EXPORT QBoxLayoutWrap : public Napi::ObjectWrap<QBoxLayoutWrap> {
|
||||
QLAYOUT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NBoxLayout> instance;
|
||||
QPointer<QBoxLayout> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QBoxLayoutWrap(const Napi::CallbackInfo& info);
|
||||
~QBoxLayoutWrap();
|
||||
NBoxLayout* getInternalInstance();
|
||||
QBoxLayout* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -9,13 +9,13 @@
|
||||
#include "nbuttongroup.hpp"
|
||||
class DLL_EXPORT QButtonGroupWrap : public Napi::ObjectWrap<QButtonGroupWrap> {
|
||||
private:
|
||||
QPointer<NButtonGroup> instance;
|
||||
QPointer<QButtonGroup> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QButtonGroupWrap(const Napi::CallbackInfo& info);
|
||||
~QButtonGroupWrap();
|
||||
NButtonGroup* getInternalInstance();
|
||||
QButtonGroup* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -11,13 +11,13 @@
|
||||
class DLL_EXPORT QCalendarWidgetWrap
|
||||
: public Napi::ObjectWrap<QCalendarWidgetWrap> {
|
||||
private:
|
||||
QPointer<NCalendarWidget> instance;
|
||||
QPointer<QCalendarWidget> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QCalendarWidgetWrap(const Napi::CallbackInfo &info);
|
||||
~QCalendarWidgetWrap();
|
||||
NCalendarWidget *getInternalInstance();
|
||||
QCalendarWidget *getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -12,14 +12,13 @@
|
||||
class DLL_EXPORT QCheckBoxWrap : public Napi::ObjectWrap<QCheckBoxWrap> {
|
||||
QABSTRACTBUTTON_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NCheckBox> instance;
|
||||
bool disableDeletion;
|
||||
QPointer<QCheckBox> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QCheckBoxWrap(const Napi::CallbackInfo& info);
|
||||
~QCheckBoxWrap();
|
||||
NCheckBox* getInternalInstance();
|
||||
QCheckBox* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -11,13 +11,13 @@
|
||||
class DLL_EXPORT QColorDialogWrap : public Napi::ObjectWrap<QColorDialogWrap> {
|
||||
QDIALOG_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NColorDialog> instance;
|
||||
QPointer<QColorDialog> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QColorDialogWrap(const Napi::CallbackInfo& info);
|
||||
~QColorDialogWrap();
|
||||
NColorDialog* getInternalInstance();
|
||||
QColorDialog* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -11,13 +11,13 @@
|
||||
class DLL_EXPORT QComboBoxWrap : public Napi::ObjectWrap<QComboBoxWrap> {
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NComboBox> instance;
|
||||
QPointer<QComboBox> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QComboBoxWrap(const Napi::CallbackInfo& info);
|
||||
~QComboBoxWrap();
|
||||
NComboBox* getInternalInstance();
|
||||
QComboBox* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -11,13 +11,13 @@
|
||||
class DLL_EXPORT QDateEditWrap : public Napi::ObjectWrap<QDateEditWrap> {
|
||||
QDATETIMEEDIT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NDateEdit> instance;
|
||||
QPointer<QDateEdit> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QDateEditWrap(const Napi::CallbackInfo &info);
|
||||
~QDateEditWrap();
|
||||
NDateEdit *getInternalInstance();
|
||||
QDateEdit *getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -24,14 +24,24 @@
|
||||
this->instance->setCalendarWidget( \
|
||||
calendarWidgetWrap->getInternalInstance()); \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value calendarWidget(const Napi::CallbackInfo &info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
QObject *calendarWidget = this->instance->calendarWidget(); \
|
||||
if (calendarWidget) { \
|
||||
return WrapperCache::instance.getWrapper(env, calendarWidget); \
|
||||
} else { \
|
||||
return env.Null(); \
|
||||
} \
|
||||
}
|
||||
|
||||
#endif // QDATETIMEEDIT_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
#ifndef QDATETIMEEDIT_WRAPPED_METHODS_EXPORT_DEFINE
|
||||
#define QDATETIMEEDIT_WRAPPED_METHODS_EXPORT_DEFINE(WidgetWrapName) \
|
||||
QABSTRACTSPINBOX_WRAPPED_METHODS_EXPORT_DEFINE(WidgetWrapName) \
|
||||
InstanceMethod("setCalendarWidget", &WidgetWrapName::setCalendarWidget),
|
||||
#define QDATETIMEEDIT_WRAPPED_METHODS_EXPORT_DEFINE(WidgetWrapName) \
|
||||
QABSTRACTSPINBOX_WRAPPED_METHODS_EXPORT_DEFINE(WidgetWrapName) \
|
||||
InstanceMethod("setCalendarWidget", &WidgetWrapName::setCalendarWidget), \
|
||||
InstanceMethod("calendarWidget", &WidgetWrapName::calendarWidget),
|
||||
|
||||
#endif // QDATETIMEEDIT_WRAPPED_METHODS_EXPORT_DEFINE
|
||||
|
||||
|
||||
@ -12,13 +12,13 @@ class DLL_EXPORT QDateTimeEditWrap
|
||||
: public Napi::ObjectWrap<QDateTimeEditWrap> {
|
||||
QDATETIMEEDIT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NDateTimeEdit> instance;
|
||||
QPointer<QDateTimeEdit> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QDateTimeEditWrap(const Napi::CallbackInfo &info);
|
||||
~QDateTimeEditWrap();
|
||||
NDateTimeEdit *getInternalInstance();
|
||||
QDateTimeEdit *getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -12,13 +12,13 @@
|
||||
class DLL_EXPORT QDialWrap : public Napi::ObjectWrap<QDialWrap> {
|
||||
QABSTRACTSLIDER_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NDial> instance;
|
||||
QPointer<QDial> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QDialWrap(const Napi::CallbackInfo& info);
|
||||
~QDialWrap();
|
||||
NDial* getInternalInstance();
|
||||
QDial* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -11,13 +11,13 @@
|
||||
class DLL_EXPORT QDialogWrap : public Napi::ObjectWrap<QDialogWrap> {
|
||||
QDIALOG_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NDialog> instance;
|
||||
QPointer<QDialog> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QDialogWrap(const Napi::CallbackInfo& info);
|
||||
~QDialogWrap();
|
||||
NDialog* getInternalInstance();
|
||||
QDialog* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -12,13 +12,13 @@ class DLL_EXPORT QDoubleSpinBoxWrap
|
||||
: public Napi::ObjectWrap<QDoubleSpinBoxWrap> {
|
||||
QABSTRACTSPINBOX_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NDoubleSpinBox> instance;
|
||||
QPointer<QDoubleSpinBox> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QDoubleSpinBoxWrap(const Napi::CallbackInfo& info);
|
||||
~QDoubleSpinBoxWrap();
|
||||
NDoubleSpinBox* getInternalInstance();
|
||||
QDoubleSpinBox* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -12,13 +12,13 @@ class DLL_EXPORT QErrorMessageWrap
|
||||
: public Napi::ObjectWrap<QErrorMessageWrap> {
|
||||
QDIALOG_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NErrorMessage> instance;
|
||||
QPointer<QErrorMessage> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QErrorMessageWrap(const Napi::CallbackInfo& info);
|
||||
~QErrorMessageWrap();
|
||||
NErrorMessage* getInternalInstance();
|
||||
QErrorMessage* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -11,13 +11,13 @@
|
||||
class DLL_EXPORT QFileDialogWrap : public Napi::ObjectWrap<QFileDialogWrap> {
|
||||
QDIALOG_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NFileDialog> instance;
|
||||
QPointer<QFileDialog> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QFileDialogWrap(const Napi::CallbackInfo& info);
|
||||
~QFileDialogWrap();
|
||||
NFileDialog* getInternalInstance();
|
||||
QFileDialog* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -11,13 +11,13 @@
|
||||
class DLL_EXPORT QFontDialogWrap : public Napi::ObjectWrap<QFontDialogWrap> {
|
||||
QDIALOG_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NFontDialog> instance;
|
||||
QPointer<QFontDialog> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QFontDialogWrap(const Napi::CallbackInfo& info);
|
||||
~QFontDialogWrap();
|
||||
NFontDialog* getInternalInstance();
|
||||
QFontDialog* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -11,13 +11,13 @@
|
||||
class DLL_EXPORT QFrameWrap : public Napi::ObjectWrap<QFrameWrap> {
|
||||
QFRAME_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NFrame> instance;
|
||||
QPointer<QFrame> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QFrameWrap(const Napi::CallbackInfo& info);
|
||||
~QFrameWrap();
|
||||
NFrame* getInternalInstance();
|
||||
QFrame* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
#include <QPointer>
|
||||
|
||||
#include "Extras/Export/export.h"
|
||||
#include "Extras/Utils/nutils.h"
|
||||
#include "QtWidgets/QGraphicsEffect/qgraphicseffect_macro.h"
|
||||
#include "ngraphicsblureffect.hpp"
|
||||
|
||||
@ -12,13 +13,13 @@ class DLL_EXPORT QGraphicsBlurEffectWrap
|
||||
: public Napi::ObjectWrap<QGraphicsBlurEffectWrap> {
|
||||
QGRAPHICSEFFECT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NGraphicsBlurEffect> instance;
|
||||
QPointer<QGraphicsBlurEffect> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QGraphicsBlurEffectWrap(const Napi::CallbackInfo& info);
|
||||
~QGraphicsBlurEffectWrap();
|
||||
NGraphicsBlurEffect* getInternalInstance();
|
||||
QGraphicsBlurEffect* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -12,13 +12,13 @@ class DLL_EXPORT QGraphicsDropShadowEffectWrap
|
||||
: public Napi::ObjectWrap<QGraphicsDropShadowEffectWrap> {
|
||||
QGRAPHICSEFFECT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NGraphicsDropShadowEffect> instance;
|
||||
QPointer<QGraphicsDropShadowEffect> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QGraphicsDropShadowEffectWrap(const Napi::CallbackInfo& info);
|
||||
~QGraphicsDropShadowEffectWrap();
|
||||
NGraphicsDropShadowEffect* getInternalInstance();
|
||||
QGraphicsDropShadowEffect* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -12,13 +12,13 @@
|
||||
class DLL_EXPORT QGridLayoutWrap : public Napi::ObjectWrap<QGridLayoutWrap> {
|
||||
QLAYOUT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NGridLayout> instance;
|
||||
QPointer<QGridLayout> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QGridLayoutWrap(const Napi::CallbackInfo& info);
|
||||
~QGridLayoutWrap();
|
||||
NGridLayout* getInternalInstance();
|
||||
QGridLayout* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -11,13 +11,13 @@
|
||||
class DLL_EXPORT QGroupBoxWrap : public Napi::ObjectWrap<QGroupBoxWrap> {
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NGroupBox> instance;
|
||||
QPointer<QGroupBox> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QGroupBoxWrap(const Napi::CallbackInfo& info);
|
||||
~QGroupBoxWrap();
|
||||
NGroupBox* getInternalInstance();
|
||||
QGroupBox* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -45,7 +45,6 @@ class DLL_EXPORT QHeaderViewWrap : public Napi::ObjectWrap<QHeaderViewWrap> {
|
||||
|
||||
private:
|
||||
QPointer<QHeaderView> instance;
|
||||
bool disableDeletion;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
|
||||
@ -11,13 +11,13 @@
|
||||
class DLL_EXPORT QInputDialogWrap : public Napi::ObjectWrap<QInputDialogWrap> {
|
||||
QDIALOG_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NInputDialog> instance;
|
||||
QPointer<QInputDialog> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QInputDialogWrap(const Napi::CallbackInfo& info);
|
||||
~QInputDialogWrap();
|
||||
NInputDialog* getInternalInstance();
|
||||
QInputDialog* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// members
|
||||
|
||||
@ -11,13 +11,13 @@
|
||||
class DLL_EXPORT QLCDNumberWrap : public Napi::ObjectWrap<QLCDNumberWrap> {
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NLCDNumber> instance;
|
||||
QPointer<QLCDNumber> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QLCDNumberWrap(const Napi::CallbackInfo& info);
|
||||
~QLCDNumberWrap();
|
||||
NLCDNumber* getInternalInstance();
|
||||
QLCDNumber* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -12,19 +12,20 @@
|
||||
class DLL_EXPORT QLabelWrap : public Napi::ObjectWrap<QLabelWrap> {
|
||||
QFRAME_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NLabel> instance;
|
||||
QPointer<QLabel> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QLabelWrap(const Napi::CallbackInfo& info);
|
||||
~QLabelWrap();
|
||||
NLabel* getInternalInstance();
|
||||
QLabel* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
Napi::Value setSelection(const Napi::CallbackInfo& info);
|
||||
Napi::Value selectionStart(const Napi::CallbackInfo& info);
|
||||
Napi::Value setBuddy(const Napi::CallbackInfo& info);
|
||||
Napi::Value buddy(const Napi::CallbackInfo& info);
|
||||
Napi::Value clear(const Napi::CallbackInfo& info);
|
||||
Napi::Value setMovie(const Napi::CallbackInfo& info);
|
||||
Napi::Value setNumDouble(const Napi::CallbackInfo& info);
|
||||
|
||||
@ -13,13 +13,13 @@
|
||||
class DLL_EXPORT QLayoutWrap : public Napi::ObjectWrap<QLayoutWrap> {
|
||||
QLAYOUT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NLayout> instance;
|
||||
QPointer<QLayout> instance;
|
||||
|
||||
public:
|
||||
static void init(Napi::Env env);
|
||||
static void init(Napi::Env env, Napi::Object exports);
|
||||
QLayoutWrap(const Napi::CallbackInfo& info);
|
||||
~QLayoutWrap();
|
||||
NLayout* getInternalInstance();
|
||||
QLayout* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -11,13 +11,13 @@
|
||||
class DLL_EXPORT QLineEditWrap : public Napi::ObjectWrap<QLineEditWrap> {
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NLineEdit> instance;
|
||||
QPointer<QLineEdit> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QLineEditWrap(const Napi::CallbackInfo& info);
|
||||
~QLineEditWrap();
|
||||
NLineEdit* getInternalInstance();
|
||||
QLineEdit* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -11,14 +11,13 @@
|
||||
class DLL_EXPORT QListViewWrap : public Napi::ObjectWrap<QListViewWrap> {
|
||||
QLISTVIEW_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NListView> instance;
|
||||
bool disableDeletion;
|
||||
QPointer<QListView> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QListViewWrap(const Napi::CallbackInfo& info);
|
||||
~QListViewWrap();
|
||||
NListView* getInternalInstance();
|
||||
QListView* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -12,13 +12,13 @@
|
||||
class DLL_EXPORT QListWidgetWrap : public Napi::ObjectWrap<QListWidgetWrap> {
|
||||
QLISTVIEW_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NListWidget> instance;
|
||||
QPointer<QListWidget> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QListWidgetWrap(const Napi::CallbackInfo& info);
|
||||
~QListWidgetWrap();
|
||||
NListWidget* getInternalInstance();
|
||||
QListWidget* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -12,16 +12,17 @@ class DLL_EXPORT QMainWindowWrap : public Napi::ObjectWrap<QMainWindowWrap> {
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
private:
|
||||
QPointer<NMainWindow> instance;
|
||||
QPointer<QMainWindow> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QMainWindowWrap(const Napi::CallbackInfo& info);
|
||||
~QMainWindowWrap();
|
||||
NMainWindow* getInternalInstance();
|
||||
QMainWindow* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
Napi::Value centralWidget(const Napi::CallbackInfo& info);
|
||||
Napi::Value setCentralWidget(const Napi::CallbackInfo& info);
|
||||
Napi::Value takeCentralWidget(const Napi::CallbackInfo& info);
|
||||
Napi::Value setMenuBar(const Napi::CallbackInfo& info);
|
||||
|
||||
@ -17,10 +17,8 @@ class DLL_EXPORT NMenu : public QMenu, public NodeWidget {
|
||||
QObject::connect(this, &QMenu::triggered, [=](QAction* action) {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
auto actionInstance = QActionWrap::constructor.New(
|
||||
{Napi::External<QAction>::New(env, action)});
|
||||
this->emitOnNode.Call(
|
||||
{Napi::String::New(env, "triggered"), actionInstance});
|
||||
auto instance = WrapperCache::instance.getWrapper(env, action);
|
||||
this->emitOnNode.Call({Napi::String::New(env, "triggered"), instance});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@ -10,13 +10,13 @@
|
||||
class DLL_EXPORT QMenuWrap : public Napi::ObjectWrap<QMenuWrap> {
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NMenu> instance;
|
||||
QPointer<QMenu> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QMenuWrap(const Napi::CallbackInfo& info);
|
||||
~QMenuWrap();
|
||||
NMenu* getInternalInstance();
|
||||
QMenu* getInternalInstance();
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
Napi::Value clear(const Napi::CallbackInfo& info);
|
||||
|
||||
@ -10,13 +10,13 @@
|
||||
class DLL_EXPORT QMenuBarWrap : public Napi::ObjectWrap<QMenuBarWrap> {
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NMenuBar> instance;
|
||||
QPointer<QMenuBar> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QMenuBarWrap(const Napi::CallbackInfo& info);
|
||||
~QMenuBarWrap();
|
||||
NMenuBar* getInternalInstance();
|
||||
QMenuBar* getInternalInstance();
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
Napi::Value addMenu(const Napi::CallbackInfo& info);
|
||||
|
||||
@ -11,13 +11,13 @@
|
||||
class DLL_EXPORT QMessageBoxWrap : public Napi::ObjectWrap<QMessageBoxWrap> {
|
||||
QDIALOG_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NMessageBox> instance;
|
||||
QPointer<QMessageBox> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QMessageBoxWrap(const Napi::CallbackInfo& info);
|
||||
~QMessageBoxWrap();
|
||||
NMessageBox* getInternalInstance();
|
||||
QMessageBox* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -13,13 +13,13 @@ class DLL_EXPORT QPlainTextEditWrap
|
||||
: public Napi::ObjectWrap<QPlainTextEditWrap> {
|
||||
QABSTRACTSCROLLAREA_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NPlainTextEdit> instance;
|
||||
QPointer<QPlainTextEdit> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QPlainTextEditWrap(const Napi::CallbackInfo &info);
|
||||
~QPlainTextEditWrap();
|
||||
NPlainTextEdit *getInternalInstance();
|
||||
QPlainTextEdit *getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -11,13 +11,13 @@
|
||||
class DLL_EXPORT QProgressBarWrap : public Napi::ObjectWrap<QProgressBarWrap> {
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NProgressBar> instance;
|
||||
QPointer<QProgressBar> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QProgressBarWrap(const Napi::CallbackInfo& info);
|
||||
~QProgressBarWrap();
|
||||
NProgressBar* getInternalInstance();
|
||||
QProgressBar* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -12,13 +12,13 @@ class DLL_EXPORT QProgressDialogWrap
|
||||
: public Napi::ObjectWrap<QProgressDialogWrap> {
|
||||
QDIALOG_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NProgressDialog> instance;
|
||||
QPointer<QProgressDialog> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QProgressDialogWrap(const Napi::CallbackInfo& info);
|
||||
~QProgressDialogWrap();
|
||||
NProgressDialog* getInternalInstance();
|
||||
QProgressDialog* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -12,17 +12,17 @@
|
||||
class DLL_EXPORT QPushButtonWrap : public Napi::ObjectWrap<QPushButtonWrap> {
|
||||
QABSTRACTBUTTON_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NPushButton> instance;
|
||||
bool disableDeletion;
|
||||
QPointer<QPushButton> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QPushButtonWrap(const Napi::CallbackInfo& info);
|
||||
~QPushButtonWrap();
|
||||
NPushButton* getInternalInstance();
|
||||
QPushButton* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
Napi::Value setMenu(const Napi::CallbackInfo& info);
|
||||
Napi::Value menu(const Napi::CallbackInfo& info);
|
||||
Napi::Value showMenu(const Napi::CallbackInfo& info);
|
||||
};
|
||||
|
||||
@ -13,14 +13,13 @@ class DLL_EXPORT QRadioButtonWrap : public Napi::ObjectWrap<QRadioButtonWrap> {
|
||||
QABSTRACTBUTTON_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
private:
|
||||
QPointer<NRadioButton> instance;
|
||||
bool disableDeletion;
|
||||
QPointer<QRadioButton> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QRadioButtonWrap(const Napi::CallbackInfo& info);
|
||||
~QRadioButtonWrap();
|
||||
NRadioButton* getInternalInstance();
|
||||
QRadioButton* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -11,20 +11,20 @@
|
||||
class DLL_EXPORT QScrollAreaWrap : public Napi::ObjectWrap<QScrollAreaWrap> {
|
||||
QABSTRACTSCROLLAREA_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NScrollArea> instance;
|
||||
YGNodeRef scrollNode;
|
||||
QPointer<QScrollArea> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QScrollAreaWrap(const Napi::CallbackInfo& info);
|
||||
~QScrollAreaWrap();
|
||||
NScrollArea* getInternalInstance();
|
||||
QScrollArea* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
Napi::Value ensureVisible(const Napi::CallbackInfo& info);
|
||||
Napi::Value ensureWidgetVisible(const Napi::CallbackInfo& info);
|
||||
Napi::Value setWidget(const Napi::CallbackInfo& info);
|
||||
Napi::Value widget(const Napi::CallbackInfo& info);
|
||||
Napi::Value takeWidget(const Napi::CallbackInfo& info);
|
||||
Napi::Value setViewportMargins(const Napi::CallbackInfo& info);
|
||||
Napi::Value viewportMargins(const Napi::CallbackInfo& info);
|
||||
|
||||
@ -12,13 +12,13 @@
|
||||
class DLL_EXPORT QScrollBarWrap : public Napi::ObjectWrap<QScrollBarWrap> {
|
||||
QABSTRACTSLIDER_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NScrollBar> instance;
|
||||
QPointer<QScrollBar> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QScrollBarWrap(const Napi::CallbackInfo& info);
|
||||
~QScrollBarWrap();
|
||||
NScrollBar* getInternalInstance();
|
||||
QScrollBar* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -11,13 +11,13 @@
|
||||
class DLL_EXPORT QShortcutWrap : public Napi::ObjectWrap<QShortcutWrap> {
|
||||
QOBJECT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NShortcut> instance;
|
||||
QPointer<QShortcut> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QShortcutWrap(const Napi::CallbackInfo& info);
|
||||
~QShortcutWrap();
|
||||
NShortcut* getInternalInstance();
|
||||
QShortcut* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -12,13 +12,13 @@
|
||||
class DLL_EXPORT QSliderWrap : public Napi::ObjectWrap<QSliderWrap> {
|
||||
QABSTRACTSLIDER_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NSlider> instance;
|
||||
QPointer<QSlider> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QSliderWrap(const Napi::CallbackInfo& info);
|
||||
~QSliderWrap();
|
||||
NSlider* getInternalInstance();
|
||||
QSlider* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -11,13 +11,13 @@
|
||||
class DLL_EXPORT QSpinBoxWrap : public Napi::ObjectWrap<QSpinBoxWrap> {
|
||||
QABSTRACTSPINBOX_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NSpinBox> instance;
|
||||
QPointer<QSpinBox> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QSpinBoxWrap(const Napi::CallbackInfo &info);
|
||||
~QSpinBoxWrap();
|
||||
NSpinBox *getInternalInstance();
|
||||
QSpinBox *getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -11,13 +11,13 @@
|
||||
class DLL_EXPORT QSplitterWrap : public Napi::ObjectWrap<QSplitterWrap> {
|
||||
QFRAME_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NSplitter> instance;
|
||||
QPointer<QSplitter> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QSplitterWrap(const Napi::CallbackInfo& info);
|
||||
~QSplitterWrap();
|
||||
NSplitter* getInternalInstance();
|
||||
QSplitter* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -12,13 +12,13 @@ class DLL_EXPORT QStackedWidgetWrap
|
||||
: public Napi::ObjectWrap<QStackedWidgetWrap> {
|
||||
QFRAME_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NStackedWidget> instance;
|
||||
QPointer<QStackedWidget> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QStackedWidgetWrap(const Napi::CallbackInfo &info);
|
||||
~QStackedWidgetWrap();
|
||||
NStackedWidget *getInternalInstance();
|
||||
QStackedWidget *getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -10,13 +10,13 @@
|
||||
class DLL_EXPORT QStandardItemModelWrap
|
||||
: public Napi::ObjectWrap<QStandardItemModelWrap> {
|
||||
private:
|
||||
QPointer<NStandardItemModel> instance;
|
||||
QPointer<QStandardItemModel> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QStandardItemModelWrap(const Napi::CallbackInfo& info);
|
||||
~QStandardItemModelWrap();
|
||||
NStandardItemModel* getInternalInstance();
|
||||
QStandardItemModel* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -12,7 +12,7 @@ class DLL_EXPORT QStatusBarWrap : public Napi::ObjectWrap<QStatusBarWrap> {
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
|
||||
private:
|
||||
QPointer<NStatusBar> instance;
|
||||
QPointer<QStatusBar> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
@ -22,7 +22,7 @@ class DLL_EXPORT QStatusBarWrap : public Napi::ObjectWrap<QStatusBarWrap> {
|
||||
QStatusBarWrap(const Napi::CallbackInfo &info);
|
||||
~QStatusBarWrap();
|
||||
|
||||
NStatusBar *getInternalInstance();
|
||||
QStatusBar *getInternalInstance();
|
||||
|
||||
// Wrapped methods
|
||||
Napi::Value addPermanentWidget(const Napi::CallbackInfo &info);
|
||||
|
||||
@ -11,13 +11,13 @@
|
||||
class DLL_EXPORT QSvgWidgetWrap : public Napi::ObjectWrap<QSvgWidgetWrap> {
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NSvgWidget> instance;
|
||||
QPointer<QSvgWidget> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QSvgWidgetWrap(const Napi::CallbackInfo& info);
|
||||
~QSvgWidgetWrap();
|
||||
NSvgWidget* getInternalInstance();
|
||||
QSvgWidget* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -12,13 +12,13 @@ class DLL_EXPORT QSystemTrayIconWrap
|
||||
: public Napi::ObjectWrap<QSystemTrayIconWrap> {
|
||||
QOBJECT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NSystemTrayIcon> instance;
|
||||
QPointer<QSystemTrayIcon> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QSystemTrayIconWrap(const Napi::CallbackInfo& info);
|
||||
~QSystemTrayIconWrap();
|
||||
NSystemTrayIcon* getInternalInstance();
|
||||
QSystemTrayIcon* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -11,14 +11,13 @@
|
||||
class DLL_EXPORT QTabBarWrap : public Napi::ObjectWrap<QTabBarWrap> {
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NTabBar> instance;
|
||||
bool disableDeletion;
|
||||
QPointer<QTabBar> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QTabBarWrap(const Napi::CallbackInfo& info);
|
||||
~QTabBarWrap();
|
||||
NTabBar* getInternalInstance();
|
||||
QTabBar* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -11,13 +11,13 @@
|
||||
class DLL_EXPORT QTabWidgetWrap : public Napi::ObjectWrap<QTabWidgetWrap> {
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NTabWidget> instance;
|
||||
QPointer<QTabWidget> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QTabWidgetWrap(const Napi::CallbackInfo &info);
|
||||
~QTabWidgetWrap();
|
||||
NTabWidget *getInternalInstance();
|
||||
QTabWidget *getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
@ -31,4 +31,5 @@ class DLL_EXPORT QTabWidgetWrap : public Napi::ObjectWrap<QTabWidgetWrap> {
|
||||
Napi::Value setTabsClosable(const Napi::CallbackInfo &info);
|
||||
Napi::Value setTabText(const Napi::CallbackInfo &info);
|
||||
Napi::Value setTabIcon(const Napi::CallbackInfo &info);
|
||||
Napi::Value widget(const Napi::CallbackInfo &info);
|
||||
};
|
||||
|
||||
@ -181,15 +181,13 @@
|
||||
Napi::Value horizontalHeader(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
auto header = this->instance->horizontalHeader(); \
|
||||
auto instance = QHeaderViewWrap::constructor.New( \
|
||||
{Napi::External<QHeaderView>::New(env, header)}); \
|
||||
auto instance = WrapperCache::instance.getWrapper(env, header); \
|
||||
return instance; \
|
||||
} \
|
||||
Napi::Value verticalHeader(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
auto header = this->instance->verticalHeader(); \
|
||||
auto instance = QHeaderViewWrap::constructor.New( \
|
||||
{Napi::External<QHeaderView>::New(env, header)}); \
|
||||
auto instance = WrapperCache::instance.getWrapper(env, header); \
|
||||
return instance; \
|
||||
}
|
||||
|
||||
|
||||
@ -11,14 +11,13 @@
|
||||
class DLL_EXPORT QTableViewWrap : public Napi::ObjectWrap<QTableViewWrap> {
|
||||
QTABLEVIEW_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NTableView> instance;
|
||||
bool disableDeletion;
|
||||
QPointer<QTableView> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QTableViewWrap(const Napi::CallbackInfo& info);
|
||||
~QTableViewWrap();
|
||||
NTableView* getInternalInstance();
|
||||
QTableView* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -11,13 +11,13 @@
|
||||
class DLL_EXPORT QTableWidgetWrap : public Napi::ObjectWrap<QTableWidgetWrap> {
|
||||
QABSTRACTSCROLLAREA_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NTableWidget> instance;
|
||||
QPointer<QTableWidget> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QTableWidgetWrap(const Napi::CallbackInfo& info);
|
||||
~QTableWidgetWrap();
|
||||
NTableWidget* getInternalInstance();
|
||||
QTableWidget* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -11,13 +11,13 @@
|
||||
class DLL_EXPORT QTextBrowserWrap : public Napi::ObjectWrap<QTextBrowserWrap> {
|
||||
QTEXTEDIT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NTextBrowser> instance;
|
||||
QPointer<QTextBrowser> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QTextBrowserWrap(const Napi::CallbackInfo& info);
|
||||
~QTextBrowserWrap();
|
||||
NTextBrowser* getInternalInstance();
|
||||
QTextBrowser* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -11,13 +11,13 @@
|
||||
class DLL_EXPORT QTextEditWrap : public Napi::ObjectWrap<QTextEditWrap> {
|
||||
QTEXTEDIT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NTextEdit> instance;
|
||||
QPointer<QTextEdit> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QTextEditWrap(const Napi::CallbackInfo& info);
|
||||
~QTextEditWrap();
|
||||
NTextEdit* getInternalInstance();
|
||||
QTextEdit* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -12,13 +12,13 @@
|
||||
class DLL_EXPORT QTimeEditWrap : public Napi::ObjectWrap<QTimeEditWrap> {
|
||||
QDATETIMEEDIT_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NTimeEdit> instance;
|
||||
QPointer<QTimeEdit> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QTimeEditWrap(const Napi::CallbackInfo &info);
|
||||
~QTimeEditWrap();
|
||||
NTimeEdit *getInternalInstance();
|
||||
QTimeEdit *getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -21,11 +21,7 @@ class DLL_EXPORT NToolButton : public QToolButton, public NodeWidget {
|
||||
QObject::connect(this, &QToolButton::triggered, [=](QAction* action) {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
|
||||
// disable deletion of the native instance for these by passing true
|
||||
auto instance = QActionWrap::constructor.New(
|
||||
{Napi::External<QAction>::New(env, action),
|
||||
Napi::Boolean::New(env, true)});
|
||||
auto instance = WrapperCache::instance.getWrapper(env, action);
|
||||
this->emitOnNode.Call({Napi::String::New(env, "triggered"), instance});
|
||||
});
|
||||
}
|
||||
|
||||
@ -12,18 +12,18 @@
|
||||
class DLL_EXPORT QToolButtonWrap : public Napi::ObjectWrap<QToolButtonWrap> {
|
||||
QABSTRACTBUTTON_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NToolButton> instance;
|
||||
bool disableDeletion;
|
||||
QPointer<QToolButton> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QToolButtonWrap(const Napi::CallbackInfo& info);
|
||||
~QToolButtonWrap();
|
||||
NToolButton* getInternalInstance();
|
||||
QToolButton* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
Napi::Value setMenu(const Napi::CallbackInfo& info);
|
||||
Napi::Value setDefaultAction(const Napi::CallbackInfo& info);
|
||||
Napi::Value showMenu(const Napi::CallbackInfo& info);
|
||||
Napi::Value defaultAction(const Napi::CallbackInfo& info);
|
||||
};
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
class DLL_EXPORT QTreeWidgetWrap : public Napi::ObjectWrap<QTreeWidgetWrap> {
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NTreeWidget> instance;
|
||||
QPointer<QTreeWidget> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
@ -20,7 +20,7 @@ class DLL_EXPORT QTreeWidgetWrap : public Napi::ObjectWrap<QTreeWidgetWrap> {
|
||||
|
||||
~QTreeWidgetWrap();
|
||||
|
||||
NTreeWidget *getInternalInstance();
|
||||
QTreeWidget *getInternalInstance();
|
||||
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
|
||||
@ -429,7 +429,7 @@
|
||||
Napi::Env env = info.Env(); \
|
||||
QWindow* window = this->instance->windowHandle(); \
|
||||
if (window) { \
|
||||
return WrapperCache::instance.get<QWindow, QWindowWrap>(env, window); \
|
||||
return WrapperCache::instance.getWrapper(env, window, true); \
|
||||
} else { \
|
||||
return env.Null(); \
|
||||
} \
|
||||
|
||||
@ -27,13 +27,13 @@ class DLL_EXPORT NodeWidgetWrap : public Napi::ObjectWrap<NodeWidgetWrap> {
|
||||
class DLL_EXPORT QWidgetWrap : public Napi::ObjectWrap<QWidgetWrap> {
|
||||
QWIDGET_WRAPPED_METHODS_DECLARATION
|
||||
private:
|
||||
QPointer<NWidget> instance;
|
||||
QPointer<QWidget> instance;
|
||||
|
||||
public:
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports);
|
||||
QWidgetWrap(const Napi::CallbackInfo& info);
|
||||
~QWidgetWrap();
|
||||
NWidget* getInternalInstance();
|
||||
QWidget* getInternalInstance();
|
||||
// class constructor
|
||||
static Napi::FunctionReference constructor;
|
||||
// wrapped methods
|
||||
|
||||
@ -2,17 +2,21 @@
|
||||
|
||||
#include <napi.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QMapIterator>
|
||||
#include <QtCore/QObject>
|
||||
|
||||
#include "Extras/Export/export.h"
|
||||
#include "QtGui/QScreen/qscreen_wrap.h"
|
||||
#include "Extras/Utils/nutils.h"
|
||||
|
||||
struct CachedObject {
|
||||
napi_ref ref;
|
||||
napi_env env;
|
||||
};
|
||||
|
||||
typedef Napi::Object (*WrapFunc)(Napi::Env, QObject*);
|
||||
|
||||
/**
|
||||
* C++ side cache for wrapper objects.
|
||||
*
|
||||
@ -24,7 +28,8 @@ class DLL_EXPORT WrapperCache : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
QMap<const QObject*, CachedObject> cache;
|
||||
QMap<uint64_t, CachedObject> cache;
|
||||
QMap<QString, WrapFunc> wrapperRegistry;
|
||||
|
||||
public:
|
||||
/**
|
||||
@ -33,7 +38,76 @@ class DLL_EXPORT WrapperCache : public QObject {
|
||||
static WrapperCache instance;
|
||||
|
||||
/**
|
||||
* Get a wrapper for a given Qt object.
|
||||
* Register a function to wrap certain instances of a `QObject` subclass.
|
||||
*
|
||||
* @param typeName - The name of the `QObject` subclass this wrapper function
|
||||
* applies to.
|
||||
* @param wrapFunc - Function to wrap `QObject` instances.
|
||||
*/
|
||||
void registerWrapper(QString typeName, WrapFunc wrapFunc) {
|
||||
this->wrapperRegistry[typeName] = wrapFunc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a wrapper for a QObject
|
||||
*
|
||||
* @param env - Napi environment
|
||||
* @param qobject - The QObject or subclass instance to wrap
|
||||
* @param keepAlive - Set this to true if the wrapper object should be kept
|
||||
* alive until the underlying QObject is destroyed regardless of whether
|
||||
* the JS side holding a reference to it or not. (Defaults to false).
|
||||
* @return Napi object wrapping the object
|
||||
*/
|
||||
Napi::Value getWrapper(Napi::Env env, QObject* qobject,
|
||||
bool keepAlive = false) {
|
||||
if (qobject == nullptr) {
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
uint64_t ptrHash = extrautils::hashPointerTo53bit(qobject);
|
||||
if (this->cache.contains(ptrHash)) {
|
||||
napi_value result = nullptr;
|
||||
napi_get_reference_value(env, this->cache[ptrHash].ref, &result);
|
||||
|
||||
napi_valuetype valuetype;
|
||||
napi_typeof(env, result, &valuetype);
|
||||
if (valuetype != napi_null) {
|
||||
return Napi::Object(env, result);
|
||||
}
|
||||
}
|
||||
|
||||
// Might have to climb up the class hierarchy looking for a wrapper type we
|
||||
// support. This makes us immune to internal Qt subclasses, i.e.
|
||||
// `QWidgetWindow` when `QWindow` was expected.
|
||||
const QMetaObject* meta = qobject->metaObject();
|
||||
while (meta != nullptr) {
|
||||
QString className(meta->className());
|
||||
if (this->wrapperRegistry.contains(className)) {
|
||||
Napi::Object wrapper = this->wrapperRegistry[className](env, qobject);
|
||||
store(env, ptrHash, qobject, wrapper, !keepAlive);
|
||||
return wrapper;
|
||||
}
|
||||
meta = meta->superClass();
|
||||
}
|
||||
|
||||
QMapIterator<QString, WrapFunc> i(this->wrapperRegistry);
|
||||
QString allQWrapperNames;
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
allQWrapperNames.append(i.key());
|
||||
allQWrapperNames.append(", ");
|
||||
}
|
||||
|
||||
qDebug() << "NodeGui: Unable to find wrapper for instance of C++ class "
|
||||
<< qobject->metaObject()->className()
|
||||
<< ". (The following C++ classes are recognized: "
|
||||
<< allQWrapperNames << ")";
|
||||
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a mapping from Qt Object to wrapper
|
||||
*
|
||||
* @param T - (template argument) The Qt class of the object being cached,
|
||||
* e.g. `QScreen`.
|
||||
@ -41,32 +115,24 @@ class DLL_EXPORT WrapperCache : public QObject {
|
||||
* `QScreenWrap`.
|
||||
* @param env = Napi environment
|
||||
* @param object - Pointer to the QObject for which a wrapper is required.
|
||||
* @return The JS wrapper object.
|
||||
* @param wrapper - The wrapper object matching `object`.
|
||||
*/
|
||||
template <class T, class W>
|
||||
Napi::Object get(Napi::Env env, T* object) {
|
||||
if (this->cache.contains(object)) {
|
||||
napi_value result = nullptr;
|
||||
napi_get_reference_value(env, this->cache[object].ref, &result);
|
||||
return Napi::Object(env, result);
|
||||
}
|
||||
|
||||
Napi::Object wrapper =
|
||||
W::constructor.New({Napi::External<T>::New(env, object)});
|
||||
|
||||
void store(Napi::Env env, uint64_t ptrHash, QObject* qobject,
|
||||
Napi::Object wrapper, bool isWeak) {
|
||||
napi_ref ref = nullptr;
|
||||
napi_create_reference(env, wrapper, 1, &ref);
|
||||
this->cache[object].env = napi_env(env);
|
||||
this->cache[object].ref = ref;
|
||||
|
||||
QObject::connect(object, &QObject::destroyed, this,
|
||||
napi_create_reference(env, wrapper, isWeak ? 0 : 1, &ref);
|
||||
this->cache[ptrHash].env = napi_env(env);
|
||||
this->cache[ptrHash].ref = ref;
|
||||
|
||||
QObject::connect(qobject, &QObject::destroyed, this,
|
||||
&WrapperCache::handleDestroyed);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
static Napi::Object init(Napi::Env env, Napi::Object exports) {
|
||||
exports.Set("WrapperCache_injectCallback",
|
||||
Napi::Function::New<injectDestroyCallback>(env));
|
||||
exports.Set("WrapperCache_store", Napi::Function::New<storeJS>(env));
|
||||
return exports;
|
||||
}
|
||||
|
||||
@ -77,11 +143,23 @@ class DLL_EXPORT WrapperCache : public QObject {
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
static Napi::Value storeJS(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
|
||||
Napi::Object objectWrapper = info[0].As<Napi::Object>();
|
||||
QObject* qobject = info[1].As<Napi::External<QObject>>().Data();
|
||||
|
||||
uint64_t ptrHash = extrautils::hashPointerTo53bit(qobject);
|
||||
instance.store(env, ptrHash, qobject, objectWrapper, false);
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
static Napi::FunctionReference destroyedCallback;
|
||||
|
||||
public Q_SLOTS:
|
||||
void handleDestroyed(const QObject* object) {
|
||||
if (!this->cache.contains(object)) {
|
||||
void handleDestroyed(const QObject* qobject) {
|
||||
uint64_t ptrHash = extrautils::hashPointerTo53bit(qobject);
|
||||
if (!this->cache.contains(ptrHash)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -90,14 +168,12 @@ class DLL_EXPORT WrapperCache : public QObject {
|
||||
if (destroyedCallback) {
|
||||
Napi::Env env = destroyedCallback.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
destroyedCallback.Call(
|
||||
env.Global(),
|
||||
{Napi::Value::From(env, extrautils::hashPointerTo53bit(object))});
|
||||
destroyedCallback.Call(env.Global(), {Napi::Value::From(env, ptrHash)});
|
||||
}
|
||||
|
||||
uint32_t result = 0;
|
||||
napi_reference_unref(this->cache[object].env, this->cache[object].ref,
|
||||
napi_reference_unref(this->cache[ptrHash].env, this->cache[ptrHash].ref,
|
||||
&result);
|
||||
this->cache.remove(object);
|
||||
this->cache.remove(ptrHash);
|
||||
}
|
||||
};
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
|
||||
#include "core/Component/component_wrap.h"
|
||||
#include "core/FlexLayout/flexutils.h"
|
||||
#include "core/YogaWidget/yogawidget.h"
|
||||
|
||||
bool extrautils::isNapiValueInt(Napi::Env& env, Napi::Value& num) {
|
||||
return env.Global()
|
||||
@ -101,12 +102,16 @@ QVariant* extrautils::convertToQVariant(Napi::Env& env, Napi::Value& value) {
|
||||
}
|
||||
|
||||
void* extrautils::configureComponent(void* component) { return component; }
|
||||
|
||||
void* extrautils::configureQObject(QObject* object) {
|
||||
return configureComponent(object);
|
||||
}
|
||||
void* extrautils::configureQWidget(QWidget* widget, YGNodeRef node,
|
||||
bool isLeafNode) {
|
||||
flexutils::configureFlexNode(widget, node, isLeafNode);
|
||||
|
||||
void* extrautils::configureQWidget(QWidget* widget, bool isLeafNode) {
|
||||
YogaWidget* yogaWidget = dynamic_cast<YogaWidget*>(widget);
|
||||
if (yogaWidget) {
|
||||
flexutils::configureFlexNode(widget, yogaWidget->getFlexNode(), isLeafNode);
|
||||
}
|
||||
return configureQObject(widget);
|
||||
}
|
||||
|
||||
|
||||
@ -45,6 +45,7 @@ Napi::Object QAbstractItemModelWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
QOBJECT_WRAPPED_METHODS_EXPORT_DEFINE(QAbstractItemModelWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
QOBJECT_REGISTER_WRAPPER(NAbstractItemModel, QAbstractItemModelWrap);
|
||||
return exports;
|
||||
}
|
||||
|
||||
@ -58,7 +59,21 @@ QAbstractItemModelWrap::~QAbstractItemModelWrap() {
|
||||
QAbstractItemModelWrap::QAbstractItemModelWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QAbstractItemModelWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
this->instance = new NAbstractItemModel();
|
||||
size_t argCount = info.Length();
|
||||
if (argCount == 0) {
|
||||
// --- Construct a new instance
|
||||
this->instance = new NAbstractItemModel();
|
||||
} else if (argCount == 1) {
|
||||
if (info[0].IsExternal()) {
|
||||
// --- Wrap a given C++ instance
|
||||
this->instance = info[0].As<Napi::External<NAbstractItemModel>>().Data();
|
||||
}
|
||||
} else {
|
||||
Napi::TypeError::New(env,
|
||||
"NodeGui: QAbstractItemModelWrap: Wrong number of "
|
||||
"arguments to constructor")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
}
|
||||
|
||||
Napi::Value QAbstractItemModelWrap::initNodeDispatcher(
|
||||
|
||||
@ -38,6 +38,7 @@ Napi::Object QItemSelectionModelWrap::init(Napi::Env env,
|
||||
QOBJECT_WRAPPED_METHODS_EXPORT_DEFINE(QItemSelectionModelWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
QOBJECT_REGISTER_WRAPPER(QItemSelectionModel, QItemSelectionModelWrap);
|
||||
return exports;
|
||||
}
|
||||
|
||||
@ -46,20 +47,33 @@ QItemSelectionModel* QItemSelectionModelWrap::getInternalInstance() {
|
||||
}
|
||||
|
||||
QItemSelectionModelWrap::~QItemSelectionModelWrap() {
|
||||
if (!this->disableDeletion) {
|
||||
extrautils::safeDelete(this->instance);
|
||||
}
|
||||
extrautils::safeDelete(this->instance);
|
||||
}
|
||||
|
||||
QItemSelectionModelWrap::QItemSelectionModelWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QItemSelectionModelWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
if (info.Length() == 0) {
|
||||
size_t argCount = info.Length();
|
||||
if (argCount == 0) {
|
||||
// --- Construct a new instance
|
||||
this->instance = new NItemSelectionModel();
|
||||
this->disableDeletion = false;
|
||||
} else if (argCount == 1) {
|
||||
if (info[0].IsExternal()) {
|
||||
// --- Wrap a given C++ instance
|
||||
this->instance = info[0].As<Napi::External<QItemSelectionModel>>().Data();
|
||||
} else {
|
||||
// --- Construct a new instance and pass a parent
|
||||
// Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
// QObjectWrap* parentObjectWrap =
|
||||
// Napi::ObjectWrap<QObjectWrap>::Unwrap(parentObject);
|
||||
// this->instance = new
|
||||
// NItemSelectionModel(parentObjectWrap->getInternalInstance());
|
||||
}
|
||||
} else {
|
||||
this->instance = info[0].As<Napi::External<QItemSelectionModel>>().Data();
|
||||
this->disableDeletion = true;
|
||||
Napi::TypeError::New(env,
|
||||
"NodeGui: QItemSelectionModelWrap: Wrong number of "
|
||||
"arguments to constructor")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
}
|
||||
Napi::Value QItemSelectionModelWrap::columnIntersectsSelection(
|
||||
|
||||
@ -10,7 +10,6 @@ Napi::Object QMimeDataWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
char CLASSNAME[] = "QMimeData";
|
||||
Napi::Function func =
|
||||
DefineClass(env, CLASSNAME,
|
||||
|
||||
{InstanceMethod("clear", &QMimeDataWrap::clear),
|
||||
InstanceMethod("hasColor", &QMimeDataWrap::hasColor),
|
||||
InstanceMethod("hasHtml", &QMimeDataWrap::hasHtml),
|
||||
@ -25,43 +24,31 @@ Napi::Object QMimeDataWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
InstanceMethod("setUrls", &QMimeDataWrap::setUrls),
|
||||
InstanceMethod("text", &QMimeDataWrap::text),
|
||||
InstanceMethod("urls", &QMimeDataWrap::urls),
|
||||
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QMimeDataWrap)});
|
||||
QOBJECT_WRAPPED_METHODS_EXPORT_DEFINE(QMimeDataWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
QOBJECT_REGISTER_WRAPPER(QMimeData, QMimeDataWrap);
|
||||
return exports;
|
||||
}
|
||||
|
||||
QMimeData* QMimeDataWrap::getInternalInstance() { return this->instance.get(); }
|
||||
QMimeData* QMimeDataWrap::getInternalInstance() { return this->instance; }
|
||||
|
||||
QMimeDataWrap::~QMimeDataWrap() { this->instance.reset(); }
|
||||
QMimeDataWrap::~QMimeDataWrap() { extrautils::safeDelete(this->instance); }
|
||||
|
||||
QMimeDataWrap::QMimeDataWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QMimeDataWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
if (info.Length() == 1) {
|
||||
Napi::External<QMimeData> eventObject =
|
||||
info[0].As<Napi::External<QMimeData>>();
|
||||
this->instance = std::make_unique<QMimeData>();
|
||||
// Copy data to our instance
|
||||
QMimeData* mimeReference = eventObject.Data();
|
||||
this->cloneFromMimeData(mimeReference);
|
||||
// foreach(QString format, mimeReference->formats())
|
||||
// {
|
||||
// // Retrieving data
|
||||
// QByteArray data = mimeReference->data(format);
|
||||
// // Checking for custom MIME types
|
||||
// if(format.startsWith("application/x-qt"))
|
||||
// {
|
||||
// // Retrieving true format name
|
||||
// int indexBegin = format.indexOf('"') + 1;
|
||||
// int indexEnd = format.indexOf('"', indexBegin);
|
||||
// format = format.mid(indexBegin, indexEnd - indexBegin);
|
||||
// }
|
||||
// this->instance->setData(format, data);
|
||||
// }
|
||||
size_t argCount = info.Length();
|
||||
if (argCount == 0) {
|
||||
// --- Construct a new instance
|
||||
this->instance = new QMimeData();
|
||||
} else if (argCount == 1 && info[0].IsExternal()) {
|
||||
// --- Wrap a given C++ instance
|
||||
this->instance = info[0].As<Napi::External<QMimeData>>().Data();
|
||||
} else {
|
||||
this->instance = std::make_unique<QMimeData>();
|
||||
Napi::TypeError::New(
|
||||
env, "NodeGui: QMimeDataWrap: Wrong number of arguments to constructor")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureComponent(this->getInternalInstance());
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#include "QtCore/QObject/qobject_wrap.h"
|
||||
|
||||
#include "Extras/Utils/nutils.h"
|
||||
#include "core/WrapperCache/wrappercache.h"
|
||||
|
||||
Napi::FunctionReference QObjectWrap::constructor;
|
||||
|
||||
@ -11,29 +12,31 @@ Napi::Object QObjectWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
env, CLASSNAME, {QOBJECT_WRAPPED_METHODS_EXPORT_DEFINE(QObjectWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
QOBJECT_REGISTER_WRAPPER(QObject, QObjectWrap);
|
||||
return exports;
|
||||
}
|
||||
|
||||
NObject* QObjectWrap::getInternalInstance() { return this->instance; }
|
||||
QObject* QObjectWrap::getInternalInstance() { return this->instance; }
|
||||
|
||||
QObjectWrap::~QObjectWrap() { extrautils::safeDelete(this->instance); }
|
||||
|
||||
QObjectWrap::QObjectWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QObjectWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
if (info.Length() == 1) {
|
||||
size_t argCount = info.Length();
|
||||
if (argCount == 1) {
|
||||
if (info[0].IsExternal()) {
|
||||
this->instance = info[0].As<Napi::External<NObject>>().Data();
|
||||
this->instance = info[0].As<Napi::External<QObject>>().Data();
|
||||
} else {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
QObjectWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<QObjectWrap>::Unwrap(parentObject);
|
||||
this->instance = new NObject(parentWidgetWrap->getInternalInstance());
|
||||
}
|
||||
} else if (info.Length() == 0) {
|
||||
} else if (argCount == 0) {
|
||||
this->instance = new NObject();
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
Napi::TypeError::New(env, "NodeGui: QObjectWrap: Wrong number of arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureQObject(this->getInternalInstance());
|
||||
|
||||
@ -41,13 +41,15 @@ Napi::Object QApplicationWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
QApplicationWrap::QApplicationWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QApplicationWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
if (info.Length() == 1) {
|
||||
size_t argCount = info.Length();
|
||||
if (argCount == 1) {
|
||||
this->instance = info[0].As<Napi::External<NApplication>>().Data();
|
||||
} else if (info.Length() == 0) {
|
||||
} else if (argCount == 0) {
|
||||
this->instance = new NApplication(qode::qode_argc, qode::qode_argv);
|
||||
this->_wasManuallyCreated = true;
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
Napi::TypeError::New(env,
|
||||
"NodeGui: QApplicationWrap: Wrong number of arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureComponent(this->getInternalInstance());
|
||||
@ -118,8 +120,7 @@ Napi::Value StaticQApplicationWrapMethods::clipboard(
|
||||
Napi::Env env = info.Env();
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
if (clipboard) {
|
||||
return WrapperCache::instance.get<QClipboard, QClipboardWrap>(env,
|
||||
clipboard);
|
||||
return WrapperCache::instance.getWrapper(env, clipboard, true);
|
||||
} else {
|
||||
return env.Null();
|
||||
}
|
||||
@ -163,7 +164,7 @@ Napi::Value StaticQApplicationWrapMethods::primaryScreen(
|
||||
Napi::Env env = info.Env();
|
||||
auto screen = QApplication::primaryScreen();
|
||||
if (screen) {
|
||||
return WrapperCache::instance.get<QScreen, QScreenWrap>(env, screen);
|
||||
return WrapperCache::instance.getWrapper(env, screen, true);
|
||||
} else {
|
||||
return env.Null();
|
||||
}
|
||||
@ -176,8 +177,7 @@ Napi::Value StaticQApplicationWrapMethods::screens(
|
||||
Napi::Array jsArray = Napi::Array::New(env, screens.size());
|
||||
for (int i = 0; i < screens.size(); i++) {
|
||||
QScreen* screen = screens[i];
|
||||
auto instance =
|
||||
WrapperCache::instance.get<QScreen, QScreenWrap>(env, screen);
|
||||
auto instance = WrapperCache::instance.getWrapper(env, screen, true);
|
||||
jsArray[i] = instance;
|
||||
}
|
||||
return jsArray;
|
||||
|
||||
@ -19,6 +19,7 @@ Napi::Object QClipboardWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
QOBJECT_WRAPPED_METHODS_EXPORT_DEFINE(QClipboardWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
QOBJECT_REGISTER_WRAPPER(QClipboard, QClipboardWrap);
|
||||
return exports;
|
||||
}
|
||||
|
||||
|
||||
@ -32,21 +32,33 @@ Napi::Object QDragWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
COMPONENT_WRAPPED_METHODS_EXPORT_DEFINE(QDragWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
QOBJECT_REGISTER_WRAPPER(QDrag, QDragWrap);
|
||||
return exports;
|
||||
}
|
||||
|
||||
NDrag* QDragWrap::getInternalInstance() { return this->instance; }
|
||||
QDrag* QDragWrap::getInternalInstance() { return this->instance; }
|
||||
|
||||
QDragWrap::QDragWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QDragWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
if (info.Length() == 1) {
|
||||
Napi::Object wrap0_0 = info[0].As<Napi::Object>();
|
||||
QObjectWrap* wrap0_1 = Napi::ObjectWrap<QObjectWrap>::Unwrap(wrap0_0);
|
||||
QObject* dragSource = wrap0_1->getInternalInstance();
|
||||
this->instance = new NDrag(dragSource);
|
||||
size_t argCount = info.Length();
|
||||
if (argCount == 0) {
|
||||
// --- Construct a new instance
|
||||
this->instance = new NDrag(nullptr);
|
||||
} else if (argCount == 1) {
|
||||
if (info[0].IsExternal()) {
|
||||
// --- Wrap a given C++ instance
|
||||
this->instance = info[0].As<Napi::External<QDrag>>().Data();
|
||||
} else {
|
||||
// --- Construct a new instance and pass a parent
|
||||
Napi::Object sourceObject = info[0].As<Napi::Object>();
|
||||
QObjectWrap* sourceObjectWrap =
|
||||
Napi::ObjectWrap<QObjectWrap>::Unwrap(sourceObject);
|
||||
this->instance = new NDrag(sourceObjectWrap->getInternalInstance());
|
||||
}
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
Napi::TypeError::New(
|
||||
env, "NodeGui: QDragWrap: Wrong number of arguments to constructor")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureComponent(this->getInternalInstance());
|
||||
|
||||
@ -42,21 +42,27 @@ QMovieWrap::~QMovieWrap() { extrautils::safeDelete(this->instance); }
|
||||
QMovieWrap::QMovieWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QMovieWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
if (info.Length() == 1) {
|
||||
if (info[0].IsExternal()) {
|
||||
this->instance = new NMovie(info[0].As<Napi::External<NMovie>>().Data());
|
||||
} else {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
QMovieWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<QMovieWrap>::Unwrap(parentObject);
|
||||
this->instance = new NMovie(parentWidgetWrap->getInternalInstance());
|
||||
}
|
||||
} else if (info.Length() == 0) {
|
||||
size_t argCount = info.Length();
|
||||
if (argCount == 0) {
|
||||
// --- Construct a new instance
|
||||
this->instance = new NMovie();
|
||||
} else if (argCount == 1) {
|
||||
if (info[0].IsExternal()) {
|
||||
// --- Wrap a given C++ instance
|
||||
this->instance = info[0].As<Napi::External<NMovie>>().Data();
|
||||
} else {
|
||||
// --- Construct a new instance and pass a parent
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
QObjectWrap* parentObjectWrap =
|
||||
Napi::ObjectWrap<QObjectWrap>::Unwrap(parentObject);
|
||||
this->instance = new NMovie(parentObjectWrap->getInternalInstance());
|
||||
}
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
Napi::TypeError::New(
|
||||
env, "NodeGui: QMovieWrap: Wrong number of arguments to constructor")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
QOBJECT_REGISTER_WRAPPER(QMovie, QMovieWrap);
|
||||
this->bufferDevice = QSharedPointer<QBuffer>(new QBuffer);
|
||||
this->rawData = extrautils::configureQObject(this->getInternalInstance());
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@ Napi::Object QScreenWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
QOBJECT_WRAPPED_METHODS_EXPORT_DEFINE(QScreenWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
QOBJECT_REGISTER_WRAPPER(QScreen, QScreenWrap);
|
||||
return exports;
|
||||
}
|
||||
|
||||
@ -25,7 +26,7 @@ QScreenWrap::QScreenWrap(const Napi::CallbackInfo& info)
|
||||
if (info[0].IsExternal()) {
|
||||
this->instance = info[0].As<Napi::External<QScreen>>().Data();
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Incorrect initialization of QScreenWrap")
|
||||
Napi::TypeError::New(env, "NodeGui: QScreenWrap: Incorrect initialization")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureComponent(this->getInternalInstance());
|
||||
|
||||
@ -25,7 +25,8 @@ QStyleWrap::QStyleWrap(const Napi::CallbackInfo& info)
|
||||
if (info[0].IsExternal()) {
|
||||
this->instance = info[0].As<Napi::External<QStyle>>().Data();
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Incorrect initialization of QStyleWrap")
|
||||
Napi::TypeError::New(
|
||||
env, "NodeGui: QStyleWrap: Incorrect initialization of QStyleWrap")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureComponent(this->getInternalInstance());
|
||||
|
||||
@ -25,6 +25,7 @@ Napi::Object QWindowWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
QOBJECT_WRAPPED_METHODS_EXPORT_DEFINE(QWindowWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
QOBJECT_REGISTER_WRAPPER(QWindow, QWindowWrap);
|
||||
return exports;
|
||||
}
|
||||
|
||||
@ -36,7 +37,8 @@ QWindowWrap::QWindowWrap(const Napi::CallbackInfo& info)
|
||||
if (info.Length() == 1 && info[0].IsExternal()) {
|
||||
this->instance = info[0].As<Napi::External<QWindow>>().Data();
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments to QWindow.")
|
||||
Napi::TypeError::New(env,
|
||||
"NodeGui: QWindowWrap: Bad arguments to constructor.")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureQObject(this->getInternalInstance());
|
||||
@ -55,8 +57,7 @@ void QWindowWrap::connectSignalsToEventEmitter() {
|
||||
this->instance.data(), &QWindow::screenChanged, [=](QScreen* screen) {
|
||||
Napi::Env env = this->emitOnNode.Env();
|
||||
Napi::HandleScope scope(env);
|
||||
auto instance =
|
||||
WrapperCache::instance.get<QScreen, QScreenWrap>(env, screen);
|
||||
auto instance = WrapperCache::instance.getWrapper(env, screen, true);
|
||||
this->emitOnNode.Call(
|
||||
{Napi::String::New(env, "screenChanged"), instance});
|
||||
});
|
||||
@ -81,7 +82,7 @@ Napi::Value QWindowWrap::screen(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
QScreen* screen = this->instance->screen();
|
||||
if (screen) {
|
||||
return WrapperCache::instance.get<QScreen, QScreenWrap>(env, screen);
|
||||
return WrapperCache::instance.getWrapper(env, screen, true);
|
||||
} else {
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
@ -34,44 +34,40 @@ Napi::Object QActionWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
QOBJECT_WRAPPED_METHODS_EXPORT_DEFINE(QActionWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
QOBJECT_REGISTER_WRAPPER(QAction, QActionWrap);
|
||||
return exports;
|
||||
}
|
||||
|
||||
NAction* QActionWrap::getInternalInstance() { return this->instance; }
|
||||
QAction* QActionWrap::getInternalInstance() { return this->instance; }
|
||||
|
||||
QActionWrap::QActionWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QActionWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
|
||||
this->disableDeletion = false;
|
||||
if (info.Length() > 0 && info[0].IsExternal()) {
|
||||
// --- if external ---
|
||||
this->instance = info[0].As<Napi::External<NAction>>().Data();
|
||||
if (info.Length() == 2) {
|
||||
this->disableDeletion = info[1].As<Napi::Boolean>().Value();
|
||||
size_t argCount = info.Length();
|
||||
if (argCount == 0) {
|
||||
// --- Construct a new instance
|
||||
this->instance = new NAction();
|
||||
} else if (argCount == 1) {
|
||||
if (info[0].IsExternal()) {
|
||||
// --- Wrap a given C++ instance
|
||||
this->instance = info[0].As<Napi::External<QAction>>().Data();
|
||||
} else {
|
||||
// --- Construct a new instance and pass a parent
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
QObjectWrap* parentObjectWrap =
|
||||
Napi::ObjectWrap<QObjectWrap>::Unwrap(parentObject);
|
||||
this->instance = new NAction(parentObjectWrap->getInternalInstance());
|
||||
}
|
||||
} else {
|
||||
// --- regular cases ---
|
||||
if (info.Length() == 1) {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
NodeWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance = new NAction(parentWidgetWrap->getInternalInstance());
|
||||
} else if (info.Length() == 0) {
|
||||
this->instance = new NAction();
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
Napi::TypeError::New(
|
||||
env, "NodeGui: QActionWrap: Wrong number of arguments to constructor")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
|
||||
this->rawData = extrautils::configureQObject(this->getInternalInstance());
|
||||
}
|
||||
|
||||
QActionWrap::~QActionWrap() {
|
||||
if (!this->disableDeletion) {
|
||||
extrautils::safeDelete(this->instance);
|
||||
}
|
||||
}
|
||||
QActionWrap::~QActionWrap() { extrautils::safeDelete(this->instance); }
|
||||
|
||||
Napi::Value QActionWrap::setText(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
|
||||
@ -27,16 +27,19 @@ Napi::Object QBoxLayoutWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
QLAYOUT_WRAPPED_METHODS_EXPORT_DEFINE(QBoxLayoutWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
QOBJECT_REGISTER_WRAPPER(QBoxLayout, QBoxLayoutWrap);
|
||||
return exports;
|
||||
}
|
||||
|
||||
NBoxLayout* QBoxLayoutWrap::getInternalInstance() { return this->instance; }
|
||||
QBoxLayout* QBoxLayoutWrap::getInternalInstance() { return this->instance; }
|
||||
|
||||
QBoxLayoutWrap::~QBoxLayoutWrap() { extrautils::safeDelete(this->instance); }
|
||||
|
||||
QBoxLayoutWrap::QBoxLayoutWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QBoxLayoutWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
if (info.Length() == 2) {
|
||||
size_t argCount = info.Length();
|
||||
if (argCount == 2) {
|
||||
QBoxLayout::Direction dir = static_cast<QBoxLayout::Direction>(
|
||||
info[0].As<Napi::Number>().Int32Value());
|
||||
Napi::Object parentObject = info[1].As<Napi::Object>();
|
||||
@ -44,12 +47,17 @@ QBoxLayoutWrap::QBoxLayoutWrap(const Napi::CallbackInfo& info)
|
||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance =
|
||||
new NBoxLayout(dir, parentWidgetWrap->getInternalInstance());
|
||||
} else if (info.Length() == 1) {
|
||||
QBoxLayout::Direction dir = static_cast<QBoxLayout::Direction>(
|
||||
info[0].As<Napi::Number>().Int32Value());
|
||||
this->instance = new NBoxLayout(dir);
|
||||
} else if (argCount == 1) {
|
||||
if (info[0].IsExternal()) {
|
||||
// --- Wrap a given C++ instance
|
||||
this->instance = info[0].As<Napi::External<QBoxLayout>>().Data();
|
||||
} else {
|
||||
QBoxLayout::Direction dir = static_cast<QBoxLayout::Direction>(
|
||||
info[0].As<Napi::Number>().Int32Value());
|
||||
this->instance = new NBoxLayout(dir);
|
||||
}
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
Napi::TypeError::New(env, "QBoxLayoutWrap: Wrong number of arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureQObject(this->getInternalInstance());
|
||||
|
||||
@ -27,25 +27,34 @@ Napi::Object QButtonGroupWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
QOBJECT_WRAPPED_METHODS_EXPORT_DEFINE(QButtonGroupWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
QOBJECT_REGISTER_WRAPPER(QButtonGroup, QButtonGroupWrap);
|
||||
return exports;
|
||||
}
|
||||
|
||||
NButtonGroup* QButtonGroupWrap::getInternalInstance() { return this->instance; }
|
||||
QButtonGroup* QButtonGroupWrap::getInternalInstance() { return this->instance; }
|
||||
|
||||
QButtonGroupWrap::QButtonGroupWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QButtonGroupWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
if (info.Length() == 1) {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
NodeWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance = new NButtonGroup(
|
||||
parentWidgetWrap
|
||||
->getInternalInstance()); // this sets the parent to current widget
|
||||
} else if (info.Length() == 0) {
|
||||
size_t argCount = info.Length();
|
||||
if (argCount == 0) {
|
||||
// --- Construct a new instance
|
||||
this->instance = new NButtonGroup();
|
||||
} else if (argCount == 1) {
|
||||
if (info[0].IsExternal()) {
|
||||
// --- Wrap a given C++ instance
|
||||
this->instance = info[0].As<Napi::External<QButtonGroup>>().Data();
|
||||
} else {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
NodeWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance =
|
||||
new NButtonGroup(parentWidgetWrap->getInternalInstance());
|
||||
}
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
Napi::TypeError::New(
|
||||
env,
|
||||
"NodeGui: QButtonGroupWrap: Wrong number of arguments to constructor")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureQObject(this->getInternalInstance());
|
||||
|
||||
@ -28,10 +28,11 @@ Napi::Object QCalendarWidgetWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QCalendarWidgetWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
QOBJECT_REGISTER_WRAPPER(QCalendarWidget, QCalendarWidgetWrap);
|
||||
return exports;
|
||||
}
|
||||
|
||||
NCalendarWidget *QCalendarWidgetWrap::getInternalInstance() {
|
||||
QCalendarWidget *QCalendarWidgetWrap::getInternalInstance() {
|
||||
return this->instance;
|
||||
}
|
||||
|
||||
@ -42,22 +43,31 @@ QCalendarWidgetWrap::~QCalendarWidgetWrap() {
|
||||
QCalendarWidgetWrap::QCalendarWidgetWrap(const Napi::CallbackInfo &info)
|
||||
: Napi::ObjectWrap<QCalendarWidgetWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
if (info.Length() == 1) {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
NodeWidgetWrap *parentWidgetWrap =
|
||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance = new NCalendarWidget(
|
||||
parentWidgetWrap
|
||||
->getInternalInstance()); // this sets the parent to current widget
|
||||
} else if (info.Length() == 0) {
|
||||
size_t argCount = info.Length();
|
||||
if (argCount == 0) {
|
||||
// --- Construct a new instance
|
||||
this->instance = new NCalendarWidget();
|
||||
} else if (argCount == 1) {
|
||||
if (info[0].IsExternal()) {
|
||||
// --- Wrap a given C++ instance
|
||||
this->instance = info[0].As<Napi::External<QCalendarWidget>>().Data();
|
||||
} else {
|
||||
// --- Construct a new instance and pass a parent
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
NodeWidgetWrap *parentWidgetWrap =
|
||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance =
|
||||
new NCalendarWidget(parentWidgetWrap->getInternalInstance());
|
||||
}
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
Napi::TypeError::New(env,
|
||||
"NodeGui: QCalendarWidgetWrap: Wrong number of "
|
||||
"arguments to constructor")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureQWidget(
|
||||
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
|
||||
true);
|
||||
|
||||
this->rawData =
|
||||
extrautils::configureQWidget(this->getInternalInstance(), true);
|
||||
}
|
||||
|
||||
Napi::Value QCalendarWidgetWrap::monthShown(const Napi::CallbackInfo &info) {
|
||||
|
||||
@ -17,44 +17,40 @@ Napi::Object QCheckBoxWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
QABSTRACTBUTTON_WRAPPED_METHODS_EXPORT_DEFINE(QCheckBoxWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
QOBJECT_REGISTER_WRAPPER(QCheckBox, QCheckBoxWrap);
|
||||
return exports;
|
||||
}
|
||||
|
||||
NCheckBox* QCheckBoxWrap::getInternalInstance() { return this->instance; }
|
||||
QCheckBox* QCheckBoxWrap::getInternalInstance() { return this->instance; }
|
||||
|
||||
QCheckBoxWrap::QCheckBoxWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QCheckBoxWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
this->disableDeletion = false;
|
||||
if (info.Length() > 0 && info[0].IsExternal()) {
|
||||
// --- if external ---
|
||||
this->instance = info[0].As<Napi::External<NCheckBox>>().Data();
|
||||
if (info.Length() == 2) {
|
||||
this->disableDeletion = info[1].As<Napi::Boolean>().Value();
|
||||
}
|
||||
} else {
|
||||
if (info.Length() == 1) {
|
||||
size_t argCount = info.Length();
|
||||
if (argCount == 0) {
|
||||
// --- Construct a new instance
|
||||
this->instance = new NCheckBox();
|
||||
} else if (argCount == 1) {
|
||||
if (info[0].IsExternal()) {
|
||||
// --- Wrap a given C++ instance
|
||||
this->instance = info[0].As<Napi::External<QCheckBox>>().Data();
|
||||
} else {
|
||||
// --- Construct a new instance and pass a parent
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
NodeWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance = new NCheckBox(parentWidgetWrap->getInternalInstance());
|
||||
} else if (info.Length() == 0) {
|
||||
this->instance = new NCheckBox();
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
} else {
|
||||
Napi::TypeError::New(
|
||||
env, "NodeGui: QCheckBoxWrap: Wrong number of arguments to constructor")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureQWidget(
|
||||
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
|
||||
true);
|
||||
this->rawData =
|
||||
extrautils::configureQWidget(this->getInternalInstance(), true);
|
||||
}
|
||||
|
||||
QCheckBoxWrap::~QCheckBoxWrap() {
|
||||
if (!this->disableDeletion) {
|
||||
extrautils::safeDelete(this->instance);
|
||||
}
|
||||
}
|
||||
QCheckBoxWrap::~QCheckBoxWrap() { extrautils::safeDelete(this->instance); }
|
||||
|
||||
Napi::Value QCheckBoxWrap::checkState(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
|
||||
@ -27,10 +27,11 @@ Napi::Object QColorDialogWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
QDIALOG_WRAPPED_METHODS_EXPORT_DEFINE(QColorDialogWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
QOBJECT_REGISTER_WRAPPER(QColorDialog, QColorDialogWrap);
|
||||
return exports;
|
||||
}
|
||||
|
||||
NColorDialog* QColorDialogWrap::getInternalInstance() { return this->instance; }
|
||||
QColorDialog* QColorDialogWrap::getInternalInstance() { return this->instance; }
|
||||
|
||||
QColorDialogWrap::~QColorDialogWrap() {
|
||||
extrautils::safeDelete(this->instance);
|
||||
@ -39,21 +40,30 @@ QColorDialogWrap::~QColorDialogWrap() {
|
||||
QColorDialogWrap::QColorDialogWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QColorDialogWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
if (info.Length() == 1) {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
NodeWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
|
||||
QWidget* parent = parentWidgetWrap->getInternalInstance();
|
||||
this->instance = new NColorDialog(parent);
|
||||
} else if (info.Length() == 0) {
|
||||
size_t argCount = info.Length();
|
||||
if (argCount == 0) {
|
||||
// --- Construct a new instance
|
||||
this->instance = new NColorDialog();
|
||||
} else if (argCount == 1) {
|
||||
if (info[0].IsExternal()) {
|
||||
// --- Wrap a given C++ instance
|
||||
this->instance = info[0].As<Napi::External<QColorDialog>>().Data();
|
||||
} else {
|
||||
// --- Construct a new instance and pass a parent
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
NodeWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance =
|
||||
new NColorDialog(parentWidgetWrap->getInternalInstance());
|
||||
}
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
Napi::TypeError::New(
|
||||
env,
|
||||
"NodeGui: QColorDialogWrap: Wrong number of arguments to constructor")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureQWidget(
|
||||
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
|
||||
false);
|
||||
this->rawData =
|
||||
extrautils::configureQWidget(this->getInternalInstance(), false);
|
||||
}
|
||||
|
||||
Napi::Value QColorDialogWrap::selectedColor(const Napi::CallbackInfo& info) {
|
||||
|
||||
@ -66,30 +66,39 @@ Napi::Object QComboBoxWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
QWIDGET_WRAPPED_METHODS_EXPORT_DEFINE(QComboBoxWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
QOBJECT_REGISTER_WRAPPER(QComboBox, QComboBoxWrap);
|
||||
return exports;
|
||||
}
|
||||
|
||||
NComboBox* QComboBoxWrap::getInternalInstance() { return this->instance; }
|
||||
QComboBox* QComboBoxWrap::getInternalInstance() { return this->instance; }
|
||||
|
||||
QComboBoxWrap::~QComboBoxWrap() { extrautils::safeDelete(this->instance); }
|
||||
|
||||
QComboBoxWrap::QComboBoxWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QComboBoxWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
if (info.Length() == 1) {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
NodeWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
|
||||
|
||||
this->instance = new NComboBox(parentWidgetWrap->getInternalInstance());
|
||||
} else if (info.Length() == 0) {
|
||||
size_t argCount = info.Length();
|
||||
if (argCount == 0) {
|
||||
// --- Construct a new instance
|
||||
this->instance = new NComboBox();
|
||||
} else if (argCount == 1) {
|
||||
if (info[0].IsExternal()) {
|
||||
// --- Wrap a given C++ instance
|
||||
this->instance = info[0].As<Napi::External<QComboBox>>().Data();
|
||||
} else {
|
||||
// --- Construct a new instance and pass a parent
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
NodeWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance = new NComboBox(parentWidgetWrap->getInternalInstance());
|
||||
}
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
Napi::TypeError::New(
|
||||
env, "NodeGui: QComboBoxWrap: Wrong number of arguments to constructor")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureQWidget(
|
||||
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
|
||||
true);
|
||||
this->rawData =
|
||||
extrautils::configureQWidget(this->getInternalInstance(), true);
|
||||
}
|
||||
|
||||
Napi::Value QComboBoxWrap::addItem(const Napi::CallbackInfo& info) {
|
||||
|
||||
@ -12,28 +12,37 @@ Napi::Object QDateEditWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
{QDATETIMEEDIT_WRAPPED_METHODS_EXPORT_DEFINE(QDateEditWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
QOBJECT_REGISTER_WRAPPER(QDateEdit, QDateEditWrap);
|
||||
return exports;
|
||||
}
|
||||
|
||||
NDateEdit* QDateEditWrap::getInternalInstance() { return this->instance; }
|
||||
QDateEdit* QDateEditWrap::getInternalInstance() { return this->instance; }
|
||||
|
||||
QDateEditWrap::QDateEditWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QDateEditWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
if (info.Length() == 1) {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
NodeWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance = new NDateEdit(parentWidgetWrap->getInternalInstance());
|
||||
} else if (info.Length() == 0) {
|
||||
size_t argCount = info.Length();
|
||||
if (argCount == 0) {
|
||||
// --- Construct a new instance
|
||||
this->instance = new NDateEdit();
|
||||
} else if (argCount == 1) {
|
||||
if (info[0].IsExternal()) {
|
||||
// --- Wrap a given C++ instance
|
||||
this->instance = info[0].As<Napi::External<QDateEdit>>().Data();
|
||||
} else {
|
||||
// --- Construct a new instance and pass a parent
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
NodeWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance = new NDateEdit(parentWidgetWrap->getInternalInstance());
|
||||
}
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
Napi::TypeError::New(
|
||||
env, "NodeGui: QDateEditWrap: Wrong number of arguments to constructor")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureQWidget(
|
||||
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
|
||||
true);
|
||||
this->rawData =
|
||||
extrautils::configureQWidget(this->getInternalInstance(), true);
|
||||
}
|
||||
|
||||
QDateEditWrap::~QDateEditWrap() { extrautils::safeDelete(this->instance); }
|
||||
|
||||
@ -12,30 +12,41 @@ Napi::Object QDateTimeEditWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
{QDATETIMEEDIT_WRAPPED_METHODS_EXPORT_DEFINE(QDateTimeEditWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
QOBJECT_REGISTER_WRAPPER(QDateTimeEdit, QDateTimeEditWrap);
|
||||
return exports;
|
||||
}
|
||||
|
||||
NDateTimeEdit* QDateTimeEditWrap::getInternalInstance() {
|
||||
QDateTimeEdit* QDateTimeEditWrap::getInternalInstance() {
|
||||
return this->instance;
|
||||
}
|
||||
|
||||
QDateTimeEditWrap::QDateTimeEditWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QDateTimeEditWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
if (info.Length() == 1) {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
NodeWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance = new NDateTimeEdit(parentWidgetWrap->getInternalInstance());
|
||||
} else if (info.Length() == 0) {
|
||||
size_t argCount = info.Length();
|
||||
if (argCount == 0) {
|
||||
// --- Construct a new instance
|
||||
this->instance = new NDateTimeEdit();
|
||||
} else if (argCount == 1) {
|
||||
if (info[0].IsExternal()) {
|
||||
// --- Wrap a given C++ instance
|
||||
this->instance = info[0].As<Napi::External<QDateTimeEdit>>().Data();
|
||||
} else {
|
||||
// --- Construct a new instance and pass a parent
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
NodeWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance =
|
||||
new NDateTimeEdit(parentWidgetWrap->getInternalInstance());
|
||||
}
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
Napi::TypeError::New(
|
||||
env,
|
||||
"NodeGui: QDateTimeEditWrap: Wrong number of arguments to constructor")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureQWidget(
|
||||
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
|
||||
true);
|
||||
this->rawData =
|
||||
extrautils::configureQWidget(this->getInternalInstance(), true);
|
||||
}
|
||||
|
||||
QDateTimeEditWrap::~QDateTimeEditWrap() {
|
||||
|
||||
@ -16,29 +16,37 @@ Napi::Object QDialWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
{QABSTRACTSLIDER_WRAPPED_METHODS_EXPORT_DEFINE(QDialWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
QOBJECT_REGISTER_WRAPPER(QDial, QDialWrap);
|
||||
return exports;
|
||||
}
|
||||
|
||||
NDial* QDialWrap::getInternalInstance() { return this->instance; }
|
||||
QDial* QDialWrap::getInternalInstance() { return this->instance; }
|
||||
|
||||
QDialWrap::QDialWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QDialWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
if (info.Length() == 1) {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
NodeWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance = new NDial(parentWidgetWrap->getInternalInstance());
|
||||
} else if (info.Length() == 0) {
|
||||
size_t argCount = info.Length();
|
||||
if (argCount == 0) {
|
||||
// --- Construct a new instance
|
||||
this->instance = new NDial();
|
||||
} else if (argCount == 1) {
|
||||
if (info[0].IsExternal()) {
|
||||
// --- Wrap a given C++ instance
|
||||
this->instance = info[0].As<Napi::External<QDial>>().Data();
|
||||
} else {
|
||||
// --- Construct a new instance and pass a parent
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
NodeWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance = new NDial(parentWidgetWrap->getInternalInstance());
|
||||
}
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
Napi::TypeError::New(
|
||||
env, "NodeGui: QDialWrap: Wrong number of arguments to constructor")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
|
||||
this->rawData = extrautils::configureQWidget(
|
||||
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
|
||||
true);
|
||||
this->rawData =
|
||||
extrautils::configureQWidget(this->getInternalInstance(), true);
|
||||
}
|
||||
|
||||
QDialWrap::~QDialWrap() { extrautils::safeDelete(this->instance); }
|
||||
|
||||
@ -11,33 +11,37 @@ Napi::Object QDialogWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
env, CLASSNAME, {QDIALOG_WRAPPED_METHODS_EXPORT_DEFINE(QDialogWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
QOBJECT_REGISTER_WRAPPER(QDialog, QDialogWrap);
|
||||
return exports;
|
||||
}
|
||||
|
||||
NDialog *QDialogWrap::getInternalInstance() { return this->instance; }
|
||||
QDialog *QDialogWrap::getInternalInstance() { return this->instance; }
|
||||
|
||||
QDialogWrap::~QDialogWrap() { extrautils::safeDelete(this->instance); }
|
||||
|
||||
QDialogWrap::QDialogWrap(const Napi::CallbackInfo &info)
|
||||
: Napi::ObjectWrap<QDialogWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
if (info.Length() == 1) {
|
||||
size_t argCount = info.Length();
|
||||
if (argCount == 0) {
|
||||
// --- Construct a new instance
|
||||
this->instance = new NDialog();
|
||||
} else if (argCount == 1) {
|
||||
if (info[0].IsExternal()) {
|
||||
this->instance =
|
||||
new NDialog(info[0].As<Napi::External<NDialog>>().Data());
|
||||
// --- Wrap a given C++ instance
|
||||
this->instance = info[0].As<Napi::External<QDialog>>().Data();
|
||||
} else {
|
||||
// --- Construct a new instance and pass a parent
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
QDialogWrap *parentWidgetWrap =
|
||||
Napi::ObjectWrap<QDialogWrap>::Unwrap(parentObject);
|
||||
NodeWidgetWrap *parentWidgetWrap =
|
||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance = new NDialog(parentWidgetWrap->getInternalInstance());
|
||||
}
|
||||
} else if (info.Length() == 0) {
|
||||
this->instance = new NDialog();
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
Napi::TypeError::New(
|
||||
env, "NodeGui: QDialogWrap: Wrong number of arguments to constructor")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureQWidget(
|
||||
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
|
||||
false);
|
||||
this->rawData =
|
||||
extrautils::configureQWidget(this->getInternalInstance(), false);
|
||||
}
|
||||
|
||||
@ -16,31 +16,41 @@ Napi::Object QDoubleSpinBoxWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
QABSTRACTSPINBOX_WRAPPED_METHODS_EXPORT_DEFINE(QDoubleSpinBoxWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
QOBJECT_REGISTER_WRAPPER(QDoubleSpinBox, QDoubleSpinBoxWrap);
|
||||
return exports;
|
||||
}
|
||||
|
||||
NDoubleSpinBox* QDoubleSpinBoxWrap::getInternalInstance() {
|
||||
QDoubleSpinBox* QDoubleSpinBoxWrap::getInternalInstance() {
|
||||
return this->instance;
|
||||
}
|
||||
|
||||
QDoubleSpinBoxWrap::QDoubleSpinBoxWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QDoubleSpinBoxWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
if (info.Length() == 1) {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
NodeWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance =
|
||||
new NDoubleSpinBox(parentWidgetWrap->getInternalInstance());
|
||||
} else if (info.Length() == 0) {
|
||||
size_t argCount = info.Length();
|
||||
if (argCount == 0) {
|
||||
// --- Construct a new instance
|
||||
this->instance = new NDoubleSpinBox();
|
||||
} else if (argCount == 1) {
|
||||
if (info[0].IsExternal()) {
|
||||
// --- Wrap a given C++ instance
|
||||
this->instance = info[0].As<Napi::External<QDoubleSpinBox>>().Data();
|
||||
} else {
|
||||
// --- Construct a new instance and pass a parent
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
NodeWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance =
|
||||
new NDoubleSpinBox(parentWidgetWrap->getInternalInstance());
|
||||
}
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
Napi::TypeError::New(
|
||||
env,
|
||||
"NodeGui: QDoubleSpinBoxWrap: Wrong number of arguments to constructor")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureQWidget(
|
||||
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
|
||||
true);
|
||||
this->rawData =
|
||||
extrautils::configureQWidget(this->getInternalInstance(), true);
|
||||
}
|
||||
|
||||
QDoubleSpinBoxWrap::~QDoubleSpinBoxWrap() {
|
||||
|
||||
@ -16,10 +16,11 @@ Napi::Object QErrorMessageWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
QDIALOG_WRAPPED_METHODS_EXPORT_DEFINE(QErrorMessageWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
QOBJECT_REGISTER_WRAPPER(QErrorMessage, QErrorMessageWrap);
|
||||
return exports;
|
||||
}
|
||||
|
||||
NErrorMessage* QErrorMessageWrap::getInternalInstance() {
|
||||
QErrorMessage* QErrorMessageWrap::getInternalInstance() {
|
||||
return this->instance;
|
||||
}
|
||||
|
||||
@ -30,21 +31,30 @@ QErrorMessageWrap::~QErrorMessageWrap() {
|
||||
QErrorMessageWrap::QErrorMessageWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QErrorMessageWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
if (info.Length() == 1) {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
NodeWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
|
||||
QWidget* parent = parentWidgetWrap->getInternalInstance();
|
||||
this->instance = new NErrorMessage(parent);
|
||||
} else if (info.Length() == 0) {
|
||||
size_t argCount = info.Length();
|
||||
if (argCount == 0) {
|
||||
// --- Construct a new instance
|
||||
this->instance = new NErrorMessage();
|
||||
} else if (argCount == 1) {
|
||||
if (info[0].IsExternal()) {
|
||||
// --- Wrap a given C++ instance
|
||||
this->instance = info[0].As<Napi::External<QErrorMessage>>().Data();
|
||||
} else {
|
||||
// --- Construct a new instance and pass a parent
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
NodeWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
|
||||
this->instance =
|
||||
new NErrorMessage(parentWidgetWrap->getInternalInstance());
|
||||
}
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
Napi::TypeError::New(
|
||||
env,
|
||||
"NodeGui: QErrorMessageWrap: Wrong number of arguments to constructor")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureQWidget(
|
||||
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
|
||||
false);
|
||||
this->rawData =
|
||||
extrautils::configureQWidget(this->getInternalInstance(), false);
|
||||
}
|
||||
|
||||
Napi::Value QErrorMessageWrap::showMessage(const Napi::CallbackInfo& info) {
|
||||
|
||||
@ -24,16 +24,19 @@ Napi::Object QFileDialogWrap::init(Napi::Env env, Napi::Object exports) {
|
||||
QDIALOG_WRAPPED_METHODS_EXPORT_DEFINE(QFileDialogWrap)});
|
||||
constructor = Napi::Persistent(func);
|
||||
exports.Set(CLASSNAME, func);
|
||||
QOBJECT_REGISTER_WRAPPER(QFileDialog, QFileDialogWrap);
|
||||
return exports;
|
||||
}
|
||||
|
||||
NFileDialog* QFileDialogWrap::getInternalInstance() { return this->instance; }
|
||||
QFileDialog* QFileDialogWrap::getInternalInstance() { return this->instance; }
|
||||
|
||||
QFileDialogWrap::~QFileDialogWrap() { extrautils::safeDelete(this->instance); }
|
||||
|
||||
QFileDialogWrap::QFileDialogWrap(const Napi::CallbackInfo& info)
|
||||
: Napi::ObjectWrap<QFileDialogWrap>(info) {
|
||||
Napi::Env env = info.Env();
|
||||
if (info.Length() == 4) {
|
||||
size_t argCount = info.Length();
|
||||
if (argCount == 4) {
|
||||
Napi::Object parentObject = info[0].As<Napi::Object>();
|
||||
NodeWidgetWrap* parentWidgetWrap =
|
||||
Napi::ObjectWrap<NodeWidgetWrap>::Unwrap(parentObject);
|
||||
@ -45,15 +48,15 @@ QFileDialogWrap::QFileDialogWrap(const Napi::CallbackInfo& info)
|
||||
QString filter =
|
||||
QString::fromUtf8(info[3].As<Napi::String>().Utf8Value().c_str());
|
||||
this->instance = new NFileDialog(parent, caption, directory, filter);
|
||||
} else if (info.Length() == 0) {
|
||||
} else if (argCount == 0) {
|
||||
this->instance = new NFileDialog();
|
||||
} else {
|
||||
Napi::TypeError::New(env, "Wrong number of arguments")
|
||||
Napi::TypeError::New(env,
|
||||
"NodeGui: QFileDialogWrap: Wrong number of arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
}
|
||||
this->rawData = extrautils::configureQWidget(
|
||||
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
|
||||
false);
|
||||
this->rawData =
|
||||
extrautils::configureQWidget(this->getInternalInstance(), false);
|
||||
}
|
||||
|
||||
Napi::Value QFileDialogWrap::supportedSchemes(const Napi::CallbackInfo& info) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user