[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/runtime/plasma/scriptengines/javascript/simplebindings
From:       Aaron J. Seigo <aseigo () kde ! org>
Date:       2009-11-27 3:03:49
Message-ID: 1259291029.392017.8422.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1054898 by aseigo:

fix color api


 M  +29 -41    color.cpp  


--- trunk/KDE/kdebase/runtime/plasma/scriptengines/javascript/simplebindings/color.cpp #1054897:1054898
@@ -55,59 +55,51 @@
 static QScriptValue red(QScriptContext *ctx, QScriptEngine *eng)
 {
     DECLARE_SELF(QColor, red);
+
+    if (ctx->argumentCount() > 0) {
+        QScriptValue arg = ctx->argument(0);
+        self->setRed(arg.toInt32());
+    }
+
     return QScriptValue(eng, self->red());
 }
 
-static QScriptValue setRed(QScriptContext *ctx, QScriptEngine *)
-{
-    DECLARE_SELF(QColor, setRed);
-    QScriptValue arg = ctx->argument(0);
-    self->setRed(arg.toInt32());
-    return arg;
-}
-
 static QScriptValue green(QScriptContext *ctx, QScriptEngine *eng)
 {
     DECLARE_SELF(QColor, green);
+
+    if (ctx->argumentCount() > 0) {
+        QScriptValue arg = ctx->argument(0);
+        self->setGreen(arg.toInt32());
+    }
+
     return QScriptValue(eng, self->green());
 }
 
-static QScriptValue setGreen(QScriptContext *ctx, QScriptEngine *)
-{
-    DECLARE_SELF(QColor, setGreen);
-    QScriptValue arg = ctx->argument(0);
-    self->setGreen(arg.toInt32());
-    return arg;
-}
-
 static QScriptValue blue(QScriptContext *ctx, QScriptEngine *eng)
 {
     DECLARE_SELF(QColor, blue);
+
+    if (ctx->argumentCount() > 0) {
+        QScriptValue arg = ctx->argument(0);
+        self->setBlue(arg.toInt32());
+    }
+
     return QScriptValue(eng, self->blue());
 }
 
-static QScriptValue setBlue(QScriptContext *ctx, QScriptEngine *)
-{
-    DECLARE_SELF(QColor, setBlue);
-    QScriptValue arg = ctx->argument(0);
-    self->setBlue(arg.toInt32());
-    return arg;
-}
-
 static QScriptValue alpha(QScriptContext *ctx, QScriptEngine *eng)
 {
     DECLARE_SELF(QColor, alpha);
+
+    if (ctx->argumentCount() > 0) {
+        QScriptValue arg = ctx->argument(0);
+        self->setAlpha(arg.toInt32());
+    }
+
     return QScriptValue(eng, self->alpha());
 }
 
-static QScriptValue setAlpha(QScriptContext *ctx, QScriptEngine *)
-{
-    DECLARE_SELF(QColor, setAlpha);
-    QScriptValue arg = ctx->argument(0);
-    self->setAlpha(arg.toInt32());
-    return arg;
-}
-
 static QScriptValue isValid(QScriptContext *ctx, QScriptEngine *eng)
 {
     DECLARE_SELF(QColor, isValid);
@@ -119,15 +111,11 @@
     QScriptValue proto = qScriptValueFromValue(eng, QColor());
     QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
     QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter;
-    proto.setProperty("red", eng->newFunction(red), getter);
-    proto.setProperty("setRed", eng->newFunction(setRed));
-    proto.setProperty("green", eng->newFunction(green), getter);
-    proto.setProperty("setGreen", eng->newFunction(setGreen));
-    proto.setProperty("blue", eng->newFunction(blue), getter);
-    proto.setProperty("setBlue", eng->newFunction(setBlue));
-    proto.setProperty("alpha", eng->newFunction(alpha, getter));
-    proto.setProperty("setAlpha", eng->newFunction(setAlpha));
-    proto.setProperty("isValid", eng->newFunction(red), getter);
+    proto.setProperty("red", eng->newFunction(red), getter | setter);
+    proto.setProperty("green", eng->newFunction(green), getter | setter);
+    proto.setProperty("blue", eng->newFunction(blue), getter | setter);
+    proto.setProperty("alpha", eng->newFunction(alpha), getter | setter);
+    proto.setProperty("isValid", eng->newFunction(isValid), getter);
 
     eng->setDefaultPrototype(qMetaTypeId<QColor>(), proto);
     eng->setDefaultPrototype(qMetaTypeId<QColor*>(), proto);
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic