File indexing completed on 2024-05-19 11:43:18

0001 #include "QBrush_bind.h"
0002 #include <QBrush>
0003 #include <value_binding.h>
0004 #include <object_binding.h>
0005 
0006 using namespace KJSEmbed;
0007 
0008 // Temp - for building
0009 class QColorBinding
0010 {
0011 public: static const KJS::ClassInfo info;
0012 };
0013 class QPixmapBinding
0014 {
0015 public: static const KJS::ClassInfo info;
0016 };
0017 class QGradientBinding
0018 {
0019 public: static const KJS::ClassInfo info;
0020 };
0021 
0022 const KJS::ClassInfo QColorBinding::info = { "QColor", &VariantBinding::info, nullptr, nullptr };
0023 const KJS::ClassInfo QPixmapBinding::info = { "QPixmap", &VariantBinding::info, nullptr, nullptr };
0024 const KJS::ClassInfo QGradientBinding::info = { "QGradient", &ObjectBinding::info, nullptr, nullptr };
0025 
0026 const KJS::ClassInfo QBrushBinding::info = { "QBrush", &VariantBinding::info, nullptr, nullptr };
0027 QBrushBinding::QBrushBinding(KJS::ExecState *exec, const QBrush &value)
0028     : VariantBinding(exec, value)
0029 {
0030     StaticBinding::publish(exec, this, QBrushData::methods());
0031     StaticBinding::publish(exec, this, VariantFactory::methods());
0032 }
0033 
0034 namespace QBrushNS
0035 {
0036 //  style
0037 KJS::JSValue *style(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args)
0038 {
0039     Q_UNUSED(args);
0040     KJS::JSValue *result = KJS::jsNull();
0041     KJSEmbed::VariantBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::VariantBinding>(exec, self);
0042     if (!imp) {
0043         return KJS::throwError(exec, KJS::GeneralError, "No implementation? Huh?");
0044     }
0045 
0046     QBrush value = imp->value<QBrush>();
0047     if (args.size() == 0) {
0048         Qt::BrushStyle tmp = value.style();
0049         result = KJS::jsNumber(tmp);
0050         imp->setValue(QVariant::fromValue(value));
0051         return result;
0052     }
0053 
0054     return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list for QBrush.style");
0055 }
0056 
0057 //  setStyle
0058 KJS::JSValue *setStyle(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args)
0059 {
0060     Q_UNUSED(args);
0061     KJS::JSValue *result = KJS::jsNull();
0062     KJSEmbed::VariantBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::VariantBinding>(exec, self);
0063     if (!imp) {
0064         return KJS::throwError(exec, KJS::GeneralError, "No implementation? Huh?");
0065     }
0066 
0067     QBrush value = imp->value<QBrush>();
0068     if (args.size() == 1) {
0069         KJS::JSValue *value0 = args[0];
0070         KJS::JSObject *object0 = value0->toObject(exec);
0071         if (object0 && object0->isNumber()) {
0072             Qt::BrushStyle arg0 = KJSEmbed::extractInteger<Qt::BrushStyle>(exec, args, 0);
0073             value.setStyle(arg0);
0074             imp->setValue(QVariant::fromValue(value));
0075             return result;
0076         }
0077     }
0078 
0079     return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list for QBrush.setStyle");
0080 }
0081 
0082 //  texture
0083 KJS::JSValue *texture(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args)
0084 {
0085     Q_UNUSED(args);
0086     KJS::JSValue *result = KJS::jsNull();
0087     KJSEmbed::VariantBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::VariantBinding>(exec, self);
0088     if (!imp) {
0089         return KJS::throwError(exec, KJS::GeneralError, "No implementation? Huh?");
0090     }
0091 
0092     QBrush value = imp->value<QBrush>();
0093     if (args.size() == 0) {
0094         QPixmap tmp = value.texture();
0095         result = KJSEmbed::createVariant(exec, "QPixmap", tmp);
0096         imp->setValue(QVariant::fromValue(value));
0097         return result;
0098     }
0099 
0100     return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list for QBrush.texture");
0101 }
0102 
0103 //  setTexture
0104 KJS::JSValue *setTexture(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args)
0105 {
0106     Q_UNUSED(args);
0107     KJS::JSValue *result = KJS::jsNull();
0108     KJSEmbed::VariantBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::VariantBinding>(exec, self);
0109     if (!imp) {
0110         return KJS::throwError(exec, KJS::GeneralError, "No implementation? Huh?");
0111     }
0112 
0113     QBrush value = imp->value<QBrush>();
0114     if (args.size() == 1) {
0115         KJS::JSValue *value0 = args[0];
0116         KJS::JSObject *object0 = value0->toObject(exec);
0117         if (object0 && object0->inherits(&QPixmapBinding::info)) {
0118             QPixmap pixmap = KJSEmbed::extractVariant<QPixmap>(exec, args, 0);
0119             value.setTexture(pixmap);
0120             imp->setValue(QVariant::fromValue(value));
0121             return result;
0122         }
0123     }
0124 
0125     return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list for QBrush.setTexture");
0126 }
0127 
0128 //  color
0129 KJS::JSValue *color(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args)
0130 {
0131     Q_UNUSED(args);
0132     KJS::JSValue *result = KJS::jsNull();
0133     KJSEmbed::VariantBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::VariantBinding>(exec, self);
0134     if (!imp) {
0135         return KJS::throwError(exec, KJS::GeneralError, "No implementation? Huh?");
0136     }
0137 
0138     QBrush value = imp->value<QBrush>();
0139     if (args.size() == 0) {
0140         const QColor &tmp = value.color();
0141         result = KJSEmbed::createVariant(exec, "QColor", tmp);
0142         imp->setValue(QVariant::fromValue(value));
0143         return result;
0144     }
0145 
0146     return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list for QBrush.color");
0147 }
0148 
0149 //  setColor
0150 KJS::JSValue *setColor(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args)
0151 {
0152     Q_UNUSED(args);
0153     KJS::JSValue *result = KJS::jsNull();
0154     KJSEmbed::VariantBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::VariantBinding>(exec, self);
0155     if (!imp) {
0156         return KJS::throwError(exec, KJS::GeneralError, "No implementation? Huh?");
0157     }
0158 
0159     QBrush value = imp->value<QBrush>();
0160     if (args.size() == 1) {
0161         KJS::JSValue *value0 = args[0];
0162         KJS::JSObject *object0 = value0->toObject(exec);
0163         if (object0 && object0->inherits(&QColorBinding::info)) {
0164             QColor color = KJSEmbed::extractVariant<QColor>(exec, args, 0);
0165             value.setColor(color);
0166             imp->setValue(QVariant::fromValue(value));
0167             return result;
0168         }
0169         if (object0 && object0->isNumber()) {
0170             Qt::GlobalColor color = KJSEmbed::extractInteger<Qt::GlobalColor>(exec, args, 0);
0171             value.setColor(color);
0172             imp->setValue(QVariant::fromValue(value));
0173             return result;
0174         }
0175     }
0176 
0177     return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list for QBrush.setColor");
0178 }
0179 
0180 //  gradient
0181 KJS::JSValue *gradient(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args)
0182 {
0183     Q_UNUSED(args);
0184     KJS::JSValue *result = KJS::jsNull();
0185     KJSEmbed::VariantBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::VariantBinding>(exec, self);
0186     if (!imp) {
0187         return KJS::throwError(exec, KJS::GeneralError, "No implementation? Huh?");
0188     }
0189 
0190     QBrush value = imp->value<QBrush>();
0191     if (args.size() == 0) {
0192         const QGradient *tmp = value.gradient();
0193         result = KJSEmbed::createValue(exec, "const QGradient *", tmp);
0194         imp->setValue(QVariant::fromValue(value));
0195         return result;
0196     }
0197 
0198     return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list for QBrush.gradient");
0199 }
0200 
0201 //  isOpaque
0202 KJS::JSValue *isOpaque(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args)
0203 {
0204     Q_UNUSED(args);
0205     KJS::JSValue *result = KJS::jsNull();
0206     KJSEmbed::VariantBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::VariantBinding>(exec, self);
0207     if (!imp) {
0208         return KJS::throwError(exec, KJS::GeneralError, "No implementation? Huh?");
0209     }
0210 
0211     QBrush value = imp->value<QBrush>();
0212     if (args.size() == 0) {
0213         bool tmp = value.isOpaque();
0214         result = KJSEmbed::createVariant(exec, "bool", tmp);
0215         imp->setValue(QVariant::fromValue(value));
0216         return result;
0217     }
0218 
0219     return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list for QBrush.isOpaque");
0220 }
0221 
0222 }
0223 
0224 const Enumerator KJSEmbed::QBrushData::p_enums[] = {{nullptr, 0 }};
0225 
0226 NO_STATICS(KJSEmbed::QBrushData)
0227 const Constructor KJSEmbed::QBrushData::p_constructor =
0228 {"QBrush", 0, KJS::DontDelete | KJS::ReadOnly, nullptr, &QBrushData::ctorMethod, p_statics, p_enums, KJSEmbed::QBrushData::p_methods };
0229 KJS::JSObject *KJSEmbed::QBrushData::ctorMethod(KJS::ExecState *exec, const KJS::List &args)
0230 {
0231     if (args.size() == 0) {
0232         return new KJSEmbed::QBrushBinding(exec, QBrush());
0233     }
0234     if (args.size() == 1) {
0235         KJS::JSValue *value0 = args[0];
0236         KJS::JSObject *object0 = value0->toObject(exec);
0237         if (object0 && object0->isNumber()) {
0238             Qt::BrushStyle bs = KJSEmbed::extractInteger<Qt::BrushStyle>(exec, args, 0);
0239             return new KJSEmbed::QBrushBinding(exec, QBrush(bs));
0240         }
0241         if (object0 && object0->inherits(&QPixmapBinding::info)) {
0242             QPixmap pixmap = KJSEmbed::extractVariant<QPixmap>(exec, args, 0);
0243             return new KJSEmbed::QBrushBinding(exec, QBrush(pixmap));
0244         }
0245         if (object0 && object0->inherits(&QBrushBinding::info)) {
0246             QBrush brush = KJSEmbed::extractVariant<QBrush>(exec, args, 0);
0247             return new KJSEmbed::QBrushBinding(exec, QBrush(brush));
0248         }
0249         if (object0 && object0->inherits(&QGradientBinding::info)) {
0250             QGradient gradient = KJSEmbed::extractValue<QGradient>(exec, args, 0);
0251             return new KJSEmbed::QBrushBinding(exec, QBrush(gradient));
0252         }
0253     }
0254     if (args.size() == 2) {
0255         KJS::JSValue *value0 = args[0];
0256         KJS::JSObject *object0 = value0->toObject(exec);
0257         KJS::JSValue *value1 = args[1];
0258         KJS::JSObject *object1 = value1->toObject(exec);
0259         if (object0 && object0->inherits(&QColorBinding::info) && ((object1 && object1->isNumber()) || !object1)) {
0260             QColor color = KJSEmbed::extractVariant<QColor>(exec, args, 0);
0261             Qt::BrushStyle bs = KJSEmbed::extractInteger<Qt::BrushStyle>(exec, args, 1, Qt::SolidPattern);
0262             return new KJSEmbed::QBrushBinding(exec, QBrush(color, bs));
0263         }
0264         if (object0 && object0->isNumber() && ((object1 && object1->isNumber()) || !object1)) {
0265             Qt::GlobalColor color = KJSEmbed::extractInteger<Qt::GlobalColor>(exec, args, 0);
0266             Qt::BrushStyle bs = KJSEmbed::extractInteger<Qt::BrushStyle>(exec, args, 1, Qt::SolidPattern);
0267             return new KJSEmbed::QBrushBinding(exec, QBrush(color, bs));
0268         }
0269         if (object0 && object0->inherits(&QColorBinding::info) && object1 && object1->inherits(&QPixmapBinding::info)) {
0270             QColor color = KJSEmbed::extractVariant<QColor>(exec, args, 0);
0271             QPixmap pixmap = KJSEmbed::extractVariant<QPixmap>(exec, args, 1);
0272             return new KJSEmbed::QBrushBinding(exec, QBrush(color, pixmap));
0273         }
0274         if (object0 && object0->isNumber() && object1 && object1->inherits(&QPixmapBinding::info)) {
0275             Qt::GlobalColor color = KJSEmbed::extractInteger<Qt::GlobalColor>(exec, args, 0);
0276             QPixmap pixmap = KJSEmbed::extractVariant<QPixmap>(exec, args, 1);
0277             return new KJSEmbed::QBrushBinding(exec, QBrush(color, pixmap));
0278         }
0279     }
0280     return KJS::throwError(exec, KJS::SyntaxError, "Syntax error in parameter list for QBrush");
0281 }
0282 
0283 const Method KJSEmbed::QBrushData::p_methods[] = {
0284     { "style", 0, KJS::DontDelete | KJS::ReadOnly, &QBrushNS::style },
0285     { "setStyle", 1, KJS::DontDelete | KJS::ReadOnly, &QBrushNS::setStyle },
0286     { "texture", 0, KJS::DontDelete | KJS::ReadOnly, &QBrushNS::texture },
0287     { "setTexture", 1, KJS::DontDelete | KJS::ReadOnly, &QBrushNS::setTexture },
0288     { "color", 0, KJS::DontDelete | KJS::ReadOnly, &QBrushNS::color },
0289     { "setColor", 1, KJS::DontDelete | KJS::ReadOnly, &QBrushNS::setColor },
0290     { "gradient", 0, KJS::DontDelete | KJS::ReadOnly, &QBrushNS::gradient },
0291     { "isOpaque", 0, KJS::DontDelete | KJS::ReadOnly, &QBrushNS::isOpaque },
0292     {nullptr, 0, 0, nullptr }
0293 };
0294