Esempio n. 1
0
        // includes for base ecma wrapper classes
         void REcmaThread::initEcma(QScriptEngine& engine, QScriptValue* proto 
    
    ) 
    
    {

    bool protoCreated = false;
    if(proto == NULL){
        proto = new QScriptValue(engine.newVariant(qVariantFromValue(
                (RThread*) 0)));
        protoCreated = true;
    }

    
        // primary base class QThread:
        
            QScriptValue dpt = engine.defaultPrototype(
                qMetaTypeId<QThread*>());

            if (dpt.isValid()) {
                proto->setPrototype(dpt);
            }
          
        /*
        
        */
    

    QScriptValue fun;

    // toString:
    REcmaHelper::registerFunction(&engine, proto, toString, "toString");
    

    // destroy:
    REcmaHelper::registerFunction(&engine, proto, destroy, "destroy");
    
        // conversion for base class QThread
        REcmaHelper::registerFunction(&engine, proto, getQThread, "getQThread");
        

    // get class name
    REcmaHelper::registerFunction(&engine, proto, getClassName, "getClassName");
    

    // conversion to all base classes (multiple inheritance):
    REcmaHelper::registerFunction(&engine, proto, getBaseClasses, "getBaseClasses");
    

    // properties:
    

    // methods:
    
            REcmaHelper::registerFunction(&engine, proto, start, "start");
            
        engine.setDefaultPrototype(
            qMetaTypeId<RThread*>(), *proto);

        
                        qScriptRegisterMetaType<
                        RThread*>(
                        &engine, toScriptValue, fromScriptValue, *proto);
                    
    

    QScriptValue ctor = engine.newFunction(createEcma, *proto, 2);
    
    // static methods:
    
            REcmaHelper::registerFunction(&engine, &ctor, yieldCurrentThread, "yieldCurrentThread");
            
            REcmaHelper::registerFunction(&engine, &ctor, currentThreadAddress, "currentThreadAddress");
            
            REcmaHelper::registerFunction(&engine, &ctor, currentThreadName, "currentThreadName");
            
            REcmaHelper::registerFunction(&engine, &ctor, currentThread, "currentThread");
            

    // static properties:
    

    // enum values:
    

    // enum conversions:
    
        
    // init class:
    engine.globalObject().setProperty("RThread",
    ctor, QScriptValue::SkipInEnumeration);
    
    if( protoCreated ){
       delete proto;
    }
    
    }
Esempio n. 2
0
void QOFile::Register(QScriptEngine& engine)
{
    QScriptValue ctor = engine.newFunction(QOFile::New);
    QScriptValue metaObject = engine.newQMetaObject(&QOFile::staticMetaObject, ctor);
    engine.globalObject().setProperty("OFile", metaObject);
}
Esempio n. 3
0
void tst_QScriptExtensionPlugin::importSimplePlugin()
{
    QScriptEngine eng;
    QCoreApplication::addLibraryPath("plugins");

    QVERIFY(eng.importedExtensions().isEmpty());

    QStringList available = eng.availableExtensions();
    QVERIFY(available.contains("simple"));
    QVERIFY(available.contains("simple.foo"));
    QVERIFY(available.contains("simple.foo.bar"));

    QScriptValue extensionObject;
    {
        QVERIFY(eng.importExtension("simple").isUndefined());
        QCOMPARE(eng.importedExtensions().size(), 1);
        QCOMPARE(eng.importedExtensions().at(0), QString::fromLatin1("simple"));
        QVERIFY(eng.availableExtensions().contains("simple"));
        QVERIFY(eng.globalObject().property("pluginKey").equals("simple"));
        QVERIFY(eng.globalObject().property("package").isObject());
        extensionObject = eng.globalObject().property("simple");
        QVERIFY(extensionObject.isObject());
        QVERIFY(extensionObject.equals(eng.globalObject().property("package")));
    }

    {
        QVERIFY(eng.importExtension("simple.foo").isUndefined());
        QCOMPARE(eng.importedExtensions().size(), 2);
        QCOMPARE(eng.importedExtensions().at(1), QString::fromLatin1("simple.foo"));
        QVERIFY(eng.availableExtensions().contains("simple.foo"));
        QVERIFY(eng.globalObject().property("pluginKey").equals("simple.foo"));
        QVERIFY(eng.globalObject().property("package").isObject());
        QVERIFY(!extensionObject.equals(eng.globalObject().property("package")));
        QVERIFY(extensionObject.equals(eng.globalObject().property("simple")));
        QVERIFY(extensionObject.property("foo").isObject());
        QVERIFY(extensionObject.property("foo").equals(eng.globalObject().property("package")));
    }

    {
        QVERIFY(eng.importExtension("simple.foo.bar").isUndefined());
        QCOMPARE(eng.importedExtensions().size(), 3);
        QCOMPARE(eng.importedExtensions().at(2), QString::fromLatin1("simple.foo.bar"));
        QVERIFY(eng.availableExtensions().contains("simple.foo.bar"));
        QVERIFY(eng.globalObject().property("pluginKey").equals("simple.foo.bar"));
        QVERIFY(eng.globalObject().property("package").isObject());
        QVERIFY(!extensionObject.equals(eng.globalObject().property("package")));
        QVERIFY(extensionObject.equals(eng.globalObject().property("simple")));
        QVERIFY(extensionObject.property("foo").property("bar").isObject());
        QVERIFY(extensionObject.property("foo").property("bar").equals(eng.globalObject().property("package")));
    }

    // Extensions can't be imported multiple times.
    eng.globalObject().setProperty("pluginKey", QScriptValue());
    QVERIFY(eng.importExtension("simple").isUndefined());
    QCOMPARE(eng.importedExtensions().size(), 3);
    QVERIFY(!eng.globalObject().property("pluginKey").isValid());

    QVERIFY(eng.importExtension("simple.foo").isUndefined());
    QCOMPARE(eng.importedExtensions().size(), 3);
    QVERIFY(!eng.globalObject().property("pluginKey").isValid());

    QVERIFY(eng.importExtension("simple.foo.bar").isUndefined());
    QCOMPARE(eng.importedExtensions().size(), 3);
    QVERIFY(!eng.globalObject().property("pluginKey").isValid());
}
Esempio n. 4
0
void setup::setCurrentIndex(XTreeWidgetItem* item)
{
  QString uiName = item->data(0, Xt::RawRole).toString();
  QString label = "<span style=\" font-size:14pt; font-weight:600;\">%1</span></p></body></html>";

  if (_itemMap.contains(uiName) && _itemMap.value(uiName).index >= 0)
  {
    _stack->setCurrentIndex(_itemMap.value(uiName).index);
    _stackLit->setText(label.arg(item->text(0)));
    return;
  }
  else if (_itemMap.contains(uiName) && !item->isDisabled())
  {
    // First look for a class...
    QWidget *w = xtGetScreen(uiName, this);

    if (w)
      _itemMap[uiName].implementation = w;
    else
    {
      // No class, so look for an extension
      XSqlQuery screenq;
      screenq.prepare("SELECT * "
                      "  FROM uiform "
                      " WHERE((uiform_name=:uiform_name)"
                      "   AND (uiform_enabled))"
                      " ORDER BY uiform_order DESC"
                      " LIMIT 1;");
      screenq.bindValue(":uiform_name", uiName);
      screenq.exec();
      if (screenq.first())
      {     
        QUiLoader loader;
        QByteArray ba = screenq.value("uiform_source").toByteArray();
        QBuffer uiFile(&ba);
        if (!uiFile.open(QIODevice::ReadOnly))
          QMessageBox::critical(0, tr("Could not load UI"),
                                tr("<p>There was an error loading the UI Form "
                                   "from the database."));
        w = loader.load(&uiFile);
        w->setObjectName(uiName);
        uiFile.close();

        // Load scripts if applicable
        XSqlQuery scriptq;
        scriptq.prepare("SELECT script_source, script_order"
                        "  FROM script"
                        " WHERE((script_name=:script_name)"
                        "   AND (script_enabled))"
                        " ORDER BY script_order;");
        scriptq.bindValue(":script_name", uiName);
        scriptq.exec();

        QScriptEngine* engine = new QScriptEngine();
        if (_preferences->boolean("EnableScriptDebug"))
        {
          QScriptEngineDebugger* debugger = new QScriptEngineDebugger(this);
          debugger->attachTo(engine);
        }
        omfgThis->loadScriptGlobals(engine);
        QScriptValue mywindow = engine->newQObject(w);
        engine->globalObject().setProperty("mywindow", mywindow);

        while(scriptq.next())
        {
          QString script = scriptHandleIncludes(scriptq.value("script_source").toString());
          QScriptValue result = engine->evaluate(script, uiName);
          if (engine->hasUncaughtException())
          {
            int line = engine->uncaughtExceptionLineNumber();
            qDebug() << "uncaught exception at line" << line << ":" << result.toString();
          }
        }
        _itemMap[uiName].implementation = engine;
      }
    }

    if (w)
    {
      // Hide buttons out of context here
      QWidget* close = w->findChild<QWidget*>("_close");
      if (close)
        close->hide();
      QWidget* buttons = w->findChild<QDialogButtonBox*>();
      if (buttons)
        buttons->hide();

      //Set mode if applicable
      int mode = _itemMap.value(uiName).mode;
      if (mode && w->inherits("XDialog"))
      {
        XWidget* x = dynamic_cast<XWidget*>(w);
        ParameterList params;
        if (mode == cEdit)
          params.append("mode", "edit");
        else if (mode == cView)
          params.append("mode", "view");
        if (x)
          x->set(params);
      }
      int idx = _stack->count();
      _itemMap[uiName].index = idx;
      _stack->addWidget(w);
      _stack->setCurrentIndex(idx);

      _stackLit->setText(label.arg(item->text(0)));
      return;
    }
  }

  // Nothing here so try the next one
  XTreeWidgetItem* next = dynamic_cast<XTreeWidgetItem*>(_tree->itemBelow(item));
  if (next)
    setCurrentIndex(next);
}
                 void REcmaViewListenerAdapter::init(QScriptEngine& engine, QScriptValue* proto 
    
    ) 
    
    {

    bool protoCreated = false;
    if(proto == NULL){
        proto = new QScriptValue(engine.newVariant(qVariantFromValue(
                (RViewListenerAdapter*) 0)));
        protoCreated = true;
    }

    
        // primary base class QObject:
        
            QScriptValue dpt = engine.defaultPrototype(
                qMetaTypeId<QObject*>());

            if (dpt.isValid()) {
                proto->setPrototype(dpt);
            }
          
        /*
        REcmaViewListener::init(engine, proto);
          
        */
    

    QScriptValue fun;

    // toString:
    REcmaHelper::registerFunction(&engine, proto, toString, "toString");
    

    // destroy:
    REcmaHelper::registerFunction(&engine, proto, destroy, "destroy");
    
        // conversion for base class QObject
        REcmaHelper::registerFunction(&engine, proto, getQObject, "getQObject");
        
        // conversion for base class RViewListener
        REcmaHelper::registerFunction(&engine, proto, getRViewListener, "getRViewListener");
        

    // get class name
    REcmaHelper::registerFunction(&engine, proto, getClassName, "getClassName");
    

    // conversion to all base classes (multiple inheritance):
    REcmaHelper::registerFunction(&engine, proto, getBaseClasses, "getBaseClasses");
    

        // properties of secondary base class RViewListener:
        

        // methods of secondary base class RViewListener:
        

    // properties:
    

    // methods:
    
            REcmaHelper::registerFunction(&engine, proto, updateViews, "updateViews");
            
            REcmaHelper::registerFunction(&engine, proto, clearViews, "clearViews");
            
        engine.setDefaultPrototype(
            qMetaTypeId<RViewListenerAdapter*>(), *proto);

        
                        qScriptRegisterMetaType<
                        RViewListenerAdapter*>(
                        &engine, toScriptValue, fromScriptValue, *proto);
                    
    

    QScriptValue ctor = engine.newFunction(create, *proto, 2);
    
    // static methods:
    

    // static properties:
    

    // enum values:
    

    // enum conversions:
    
        
    // init class:
    engine.globalObject().setProperty("RViewListenerAdapter",
    ctor, QScriptValue::SkipInEnumeration);
    
    if( protoCreated ){
       delete proto;
    }
    
    }
Esempio n. 6
0
                 void REcmaSharedPointerAttributeData::init(QScriptEngine& engine, QScriptValue* proto 
    
    ) 
    
    {

    bool protoCreated = false;
    if(proto == NULL){
        proto = new QScriptValue(engine.newVariant(qVariantFromValue(
                (RAttributeDataPointer*) 0)));
        protoCreated = true;
    }

    
        // primary base class RTextBasedData:
        
            proto->setPrototype(engine.defaultPrototype(
            qMetaTypeId<RTextBasedDataPointer>()));
          
        /*
        
        */
    

    QScriptValue fun;

    // toString:
    REcmaHelper::registerFunction(&engine, proto, toString, "toString");
    
    // copy:
    REcmaHelper::registerFunction(&engine, proto, copy, "copy");
    
        // shared pointer support:
        REcmaHelper::registerFunction(&engine, proto, data, "data");
        

        REcmaHelper::registerFunction(&engine, proto, isNull, "isNull");
        

    // destroy:
    REcmaHelper::registerFunction(&engine, proto, destroy, "destroy");
    
        // conversion for base class RTextBasedData
        REcmaHelper::registerFunction(&engine, proto, getRTextBasedData, "getRTextBasedData");
        
        // conversion for base class REntityData
        REcmaHelper::registerFunction(&engine, proto, getREntityData, "getREntityData");
        
        // conversion for base class RPainterPathSource
        REcmaHelper::registerFunction(&engine, proto, getRPainterPathSource, "getRPainterPathSource");
        

    // get class name
    REcmaHelper::registerFunction(&engine, proto, getClassName, "getClassName");
    

    // conversion to all base classes (multiple inheritance):
    REcmaHelper::registerFunction(&engine, proto, getBaseClasses, "getBaseClasses");
    

    // properties:
    

    // methods:
    
            REcmaHelper::registerFunction(&engine, proto, getRenderedText, "getRenderedText");
            
            REcmaHelper::registerFunction(&engine, proto, getTag, "getTag");
            
            REcmaHelper::registerFunction(&engine, proto, setTag, "setTag");
            
            REcmaHelper::registerFunction(&engine, proto, getLinetypeId, "getLinetypeId");
            
            REcmaHelper::registerFunction(&engine, proto, getLineweight, "getLineweight");
            
            REcmaHelper::registerFunction(&engine, proto, getColor, "getColor");
            
        engine.setDefaultPrototype(
            qMetaTypeId<RAttributeDataPointer>(), *proto);
      
    

    QScriptValue ctor = engine.newFunction(create, *proto, 2);
    
    // static methods:
    

    // static properties:
    

    // enum values:
    

    // enum conversions:
    
        
    // init class:
    engine.globalObject().setProperty("RAttributeDataPointer",
    ctor, QScriptValue::SkipInEnumeration);
    
    if( protoCreated ){
       delete proto;
    }
    
    }
                 void REcmaSharedPointerDimRadialEntity::init(QScriptEngine& engine, QScriptValue* proto 
    
    ) 
    
    {

    bool protoCreated = false;
    if(proto == NULL){
        proto = new QScriptValue(engine.newVariant(qVariantFromValue(
                (RDimRadialEntityPointer*) 0)));
        protoCreated = true;
    }

    
        // primary base class RDimensionEntity:
        
            proto->setPrototype(engine.defaultPrototype(
            qMetaTypeId<RDimensionEntityPointer>()));
          
        /*
        
        */
    

    QScriptValue fun;

    // toString:
    REcmaHelper::registerFunction(&engine, proto, toString, "toString");
    
        // shared pointer support:
        REcmaHelper::registerFunction(&engine, proto, data, "data");
        

        REcmaHelper::registerFunction(&engine, proto, isNull, "isNull");
        

    // destroy:
    REcmaHelper::registerFunction(&engine, proto, destroy, "destroy");
    
        // conversion for base class RDimensionEntity
        REcmaHelper::registerFunction(&engine, proto, getRDimensionEntity, "getRDimensionEntity");
        
        // conversion for base class REntity
        REcmaHelper::registerFunction(&engine, proto, getREntity, "getREntity");
        
        // conversion for base class RObject
        REcmaHelper::registerFunction(&engine, proto, getRObject, "getRObject");
        

    // get class name
    REcmaHelper::registerFunction(&engine, proto, getClassName, "getClassName");
    

    // conversion to all base classes (multiple inheritance):
    REcmaHelper::registerFunction(&engine, proto, getBaseClasses, "getBaseClasses");
    

    // properties:
    

    // methods:
    
            REcmaHelper::registerFunction(&engine, proto, clone, "clone");
            
            REcmaHelper::registerFunction(&engine, proto, getType, "getType");
            
            REcmaHelper::registerFunction(&engine, proto, setProperty, "setProperty");
            
            REcmaHelper::registerFunction(&engine, proto, getProperty, "getProperty");
            
            REcmaHelper::registerFunction(&engine, proto, getData, "getData");
            
            REcmaHelper::registerFunction(&engine, proto, setData, "setData");
            
            REcmaHelper::registerFunction(&engine, proto, setChordPoint, "setChordPoint");
            
            REcmaHelper::registerFunction(&engine, proto, getChordPoint, "getChordPoint");
            
        engine.setDefaultPrototype(
            qMetaTypeId<RDimRadialEntityPointer>(), *proto);
      
    

    QScriptValue ctor = engine.newFunction(create, *proto, 2);
    
    // static methods:
    
            REcmaHelper::registerFunction(&engine, &ctor, init, "init");
            
            REcmaHelper::registerFunction(&engine, &ctor, getStaticPropertyTypeIds, "getStaticPropertyTypeIds");
            

    // static properties:
    
            ctor.setProperty("PropertyCustom",
                qScriptValueFromValue(&engine, RDimRadialEntity::PropertyCustom),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyHandle",
                qScriptValueFromValue(&engine, RDimRadialEntity::PropertyHandle),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyType",
                qScriptValueFromValue(&engine, RDimRadialEntity::PropertyType),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyBlock",
                qScriptValueFromValue(&engine, RDimRadialEntity::PropertyBlock),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyLayer",
                qScriptValueFromValue(&engine, RDimRadialEntity::PropertyLayer),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyLinetype",
                qScriptValueFromValue(&engine, RDimRadialEntity::PropertyLinetype),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyLineweight",
                qScriptValueFromValue(&engine, RDimRadialEntity::PropertyLineweight),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyColor",
                qScriptValueFromValue(&engine, RDimRadialEntity::PropertyColor),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyDrawOrder",
                qScriptValueFromValue(&engine, RDimRadialEntity::PropertyDrawOrder),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyMiddleOfTextX",
                qScriptValueFromValue(&engine, RDimRadialEntity::PropertyMiddleOfTextX),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyMiddleOfTextY",
                qScriptValueFromValue(&engine, RDimRadialEntity::PropertyMiddleOfTextY),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyMiddleOfTextZ",
                qScriptValueFromValue(&engine, RDimRadialEntity::PropertyMiddleOfTextZ),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyText",
                qScriptValueFromValue(&engine, RDimRadialEntity::PropertyText),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyUpperTolerance",
                qScriptValueFromValue(&engine, RDimRadialEntity::PropertyUpperTolerance),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyLowerTolerance",
                qScriptValueFromValue(&engine, RDimRadialEntity::PropertyLowerTolerance),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyMeasuredValue",
                qScriptValueFromValue(&engine, RDimRadialEntity::PropertyMeasuredValue),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyLinearFactor",
                qScriptValueFromValue(&engine, RDimRadialEntity::PropertyLinearFactor),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyAutoTextPos",
                qScriptValueFromValue(&engine, RDimRadialEntity::PropertyAutoTextPos),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyFontName",
                qScriptValueFromValue(&engine, RDimRadialEntity::PropertyFontName),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyCenterPointX",
                qScriptValueFromValue(&engine, RDimRadialEntity::PropertyCenterPointX),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyCenterPointY",
                qScriptValueFromValue(&engine, RDimRadialEntity::PropertyCenterPointY),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyCenterPointZ",
                qScriptValueFromValue(&engine, RDimRadialEntity::PropertyCenterPointZ),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyChordPointX",
                qScriptValueFromValue(&engine, RDimRadialEntity::PropertyChordPointX),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyChordPointY",
                qScriptValueFromValue(&engine, RDimRadialEntity::PropertyChordPointY),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyChordPointZ",
                qScriptValueFromValue(&engine, RDimRadialEntity::PropertyChordPointZ),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            

    // enum values:
    

    // enum conversions:
    
        
    // init class:
    engine.globalObject().setProperty("RDimRadialEntityPointer",
    ctor, QScriptValue::SkipInEnumeration);
    
    if( protoCreated ){
       delete proto;
    }
    
    }
Esempio n. 8
0
        // includes for base ecma wrapper classes
         void REcmaRuler::init(QScriptEngine& engine, QScriptValue* proto 
    
    ) 
    
    {

    bool protoCreated = false;
    if(proto == NULL){
        proto = new QScriptValue(engine.newVariant(qVariantFromValue(
                (RRuler*) 0)));
        protoCreated = true;
    }

    

    QScriptValue fun;

    // toString:
    REcmaHelper::registerFunction(&engine, proto, toString, "toString");
    

    // destroy:
    REcmaHelper::registerFunction(&engine, proto, destroy, "destroy");
    

    // get class name
    REcmaHelper::registerFunction(&engine, proto, getClassName, "getClassName");
    

    // conversion to all base classes (multiple inheritance):
    REcmaHelper::registerFunction(&engine, proto, getBaseClasses, "getBaseClasses");
    

    // properties:
    

    // methods:
    
            REcmaHelper::registerFunction(&engine, proto, setGraphicsView, "setGraphicsView");
            
            REcmaHelper::registerFunction(&engine, proto, getOrientation, "getOrientation");
            
            REcmaHelper::registerFunction(&engine, proto, setOrientation, "setOrientation");
            
            REcmaHelper::registerFunction(&engine, proto, paintTick, "paintTick");
            
            REcmaHelper::registerFunction(&engine, proto, getFont, "getFont");
            
        engine.setDefaultPrototype(
            qMetaTypeId<RRuler*>(), *proto);

        
    

    QScriptValue ctor = engine.newFunction(create, *proto, 2);
    
    // static methods:
    

    // static properties:
    

    // enum values:
    

    // enum conversions:
    
        
    // init class:
    engine.globalObject().setProperty("RRuler",
    ctor, QScriptValue::SkipInEnumeration);
    
    if( protoCreated ){
       delete proto;
    }
    
    }
Esempio n. 9
0
                 void REcmaMdiChildQt::initEcma(QScriptEngine& engine, QScriptValue* proto 
    
    ) 
    
    {

    bool protoCreated = false;
    if(proto == NULL){
        proto = new QScriptValue(engine.newVariant(qVariantFromValue(
                (RMdiChildQt*) 0)));
        protoCreated = true;
    }

    
        // primary base class QMdiSubWindow:
        
            QScriptValue dpt = engine.defaultPrototype(
                qMetaTypeId<QMdiSubWindow*>());

            if (dpt.isValid()) {
                proto->setPrototype(dpt);
            }
          
        /*
        REcmaModifiedListener::initEcma(engine, proto);
          
        */
    

    QScriptValue fun;

    // toString:
    REcmaHelper::registerFunction(&engine, proto, toString, "toString");
    

    // destroy:
    REcmaHelper::registerFunction(&engine, proto, destroy, "destroy");
    
        // conversion for base class QMdiSubWindow
        REcmaHelper::registerFunction(&engine, proto, getQMdiSubWindow, "getQMdiSubWindow");
        
        // conversion for base class RModifiedListener
        REcmaHelper::registerFunction(&engine, proto, getRModifiedListener, "getRModifiedListener");
        

    // get class name
    REcmaHelper::registerFunction(&engine, proto, getClassName, "getClassName");
    

    // conversion to all base classes (multiple inheritance):
    REcmaHelper::registerFunction(&engine, proto, getBaseClasses, "getBaseClasses");
    

        // properties of secondary base class RModifiedListener:
        

        // methods of secondary base class RModifiedListener:
        

    // properties:
    

    // methods:
    
            REcmaHelper::registerFunction(&engine, proto, setDocumentInterface, "setDocumentInterface");
            
            REcmaHelper::registerFunction(&engine, proto, getDocumentInterface, "getDocumentInterface");
            
            REcmaHelper::registerFunction(&engine, proto, getDocument, "getDocument");
            
            REcmaHelper::registerFunction(&engine, proto, getLastKnownViewWithFocus, "getLastKnownViewWithFocus");
            
            REcmaHelper::registerFunction(&engine, proto, updateModifiedListener, "updateModifiedListener");
            
            REcmaHelper::registerFunction(&engine, proto, setCloseEventRejected, "setCloseEventRejected");
            
            REcmaHelper::registerFunction(&engine, proto, setCloseEventAccepted, "setCloseEventAccepted");
            
            REcmaHelper::registerFunction(&engine, proto, isCloseEventAccepted, "isCloseEventAccepted");
            
        engine.setDefaultPrototype(
            qMetaTypeId<RMdiChildQt*>(), *proto);

        
                        qScriptRegisterMetaType<
                        RMdiChildQt*>(
                        &engine, toScriptValue, fromScriptValue, *proto);
                    
    

    QScriptValue ctor = engine.newFunction(create, *proto, 2);
    
    // static methods:
    

    // static properties:
    

    // enum values:
    

    // enum conversions:
    
        
    // init class:
    engine.globalObject().setProperty("RMdiChildQt",
    ctor, QScriptValue::SkipInEnumeration);
    
    if( protoCreated ){
       delete proto;
    }
    
    }
Esempio n. 10
0
                 void REcmaLineData::initEcma(QScriptEngine& engine, QScriptValue* proto 
    
    ) 
    
    {

    bool protoCreated = false;
    if(proto == NULL){
        proto = new QScriptValue(engine.newVariant(qVariantFromValue(
                (RLineData*) 0)));
        protoCreated = true;
    }

    
        // primary base class REntityData:
        
            QScriptValue dpt = engine.defaultPrototype(
                qMetaTypeId<REntityData*>());

            if (dpt.isValid()) {
                proto->setPrototype(dpt);
            }
          
        /*
        REcmaLine::initEcma(engine, proto);
          
        */
    

    QScriptValue fun;

    // toString:
    REcmaHelper::registerFunction(&engine, proto, toString, "toString");
    
    // copy:
    REcmaHelper::registerFunction(&engine, proto, copy, "copy");
    

    // destroy:
    REcmaHelper::registerFunction(&engine, proto, destroy, "destroy");
    
        // conversion for base class REntityData
        REcmaHelper::registerFunction(&engine, proto, getREntityData, "getREntityData");
        

    // get class name
    REcmaHelper::registerFunction(&engine, proto, getClassName, "getClassName");
    

    // conversion to all base classes (multiple inheritance):
    REcmaHelper::registerFunction(&engine, proto, getBaseClasses, "getBaseClasses");
    

    // properties:
    

    // methods:
    
            REcmaHelper::registerFunction(&engine, proto, getLine, "getLine");
            
            REcmaHelper::registerFunction(&engine, proto, getHull, "getHull");
            
            REcmaHelper::registerFunction(&engine, proto, getStartPoint, "getStartPoint");
            
            REcmaHelper::registerFunction(&engine, proto, getEndPoint, "getEndPoint");
            
            REcmaHelper::registerFunction(&engine, proto, getAngle, "getAngle");
            
            REcmaHelper::registerFunction(&engine, proto, getDirection1, "getDirection1");
            
            REcmaHelper::registerFunction(&engine, proto, getDirection2, "getDirection2");
            
            REcmaHelper::registerFunction(&engine, proto, reverse, "reverse");
            
            REcmaHelper::registerFunction(&engine, proto, getTrimEnd, "getTrimEnd");
            
            REcmaHelper::registerFunction(&engine, proto, trimStartPoint, "trimStartPoint");
            
            REcmaHelper::registerFunction(&engine, proto, trimEndPoint, "trimEndPoint");
            
            REcmaHelper::registerFunction(&engine, proto, getSideOfPoint, "getSideOfPoint");
            
            REcmaHelper::registerFunction(&engine, proto, getReferencePoints, "getReferencePoints");
            
            REcmaHelper::registerFunction(&engine, proto, moveReferencePoint, "moveReferencePoint");
            
            REcmaHelper::registerFunction(&engine, proto, castToShape, "castToShape");
            
            REcmaHelper::registerFunction(&engine, proto, getShapes, "getShapes");
            
        engine.setDefaultPrototype(
            qMetaTypeId<RLineData*>(), *proto);

        
                engine.setDefaultPrototype(qMetaTypeId<
                RLineData
                > (), *proto);
            
    

    QScriptValue ctor = engine.newFunction(create, *proto, 2);
    
    // static methods:
    

    // static properties:
    

    // enum values:
    

    // enum conversions:
    
        
    // init class:
    engine.globalObject().setProperty("RLineData",
    ctor, QScriptValue::SkipInEnumeration);
    
    if( protoCreated ){
       delete proto;
    }
    
    }
Esempio n. 11
0
                 void REcmaDimRadialData::initEcma(QScriptEngine& engine, QScriptValue* proto 
    
    ) 
    
    {

    bool protoCreated = false;
    if(proto == NULL){
        proto = new QScriptValue(engine.newVariant(qVariantFromValue(
                (RDimRadialData*) 0)));
        protoCreated = true;
    }

    
        // primary base class RDimensionData:
        
            QScriptValue dpt = engine.defaultPrototype(
                qMetaTypeId<RDimensionData*>());

            if (dpt.isValid()) {
                proto->setPrototype(dpt);
            }
          
        /*
        
        */
    

    QScriptValue fun;

    // toString:
    REcmaHelper::registerFunction(&engine, proto, toString, "toString");
    
    // copy:
    REcmaHelper::registerFunction(&engine, proto, copy, "copy");
    

    // destroy:
    REcmaHelper::registerFunction(&engine, proto, destroy, "destroy");
    
        // conversion for base class RDimensionData
        REcmaHelper::registerFunction(&engine, proto, getRDimensionData, "getRDimensionData");
        
        // conversion for base class REntityData
        REcmaHelper::registerFunction(&engine, proto, getREntityData, "getREntityData");
        

    // get class name
    REcmaHelper::registerFunction(&engine, proto, getClassName, "getClassName");
    

    // conversion to all base classes (multiple inheritance):
    REcmaHelper::registerFunction(&engine, proto, getBaseClasses, "getBaseClasses");
    

    // properties:
    

    // methods:
    
            REcmaHelper::registerFunction(&engine, proto, isValid, "isValid");
            
            REcmaHelper::registerFunction(&engine, proto, setCenter, "setCenter");
            
            REcmaHelper::registerFunction(&engine, proto, getCenter, "getCenter");
            
            REcmaHelper::registerFunction(&engine, proto, setChordPoint, "setChordPoint");
            
            REcmaHelper::registerFunction(&engine, proto, getChordPoint, "getChordPoint");
            
            REcmaHelper::registerFunction(&engine, proto, getReferencePoints, "getReferencePoints");
            
            REcmaHelper::registerFunction(&engine, proto, moveReferencePoint, "moveReferencePoint");
            
            REcmaHelper::registerFunction(&engine, proto, move, "move");
            
            REcmaHelper::registerFunction(&engine, proto, rotate, "rotate");
            
            REcmaHelper::registerFunction(&engine, proto, scale, "scale");
            
            REcmaHelper::registerFunction(&engine, proto, mirror, "mirror");
            
            REcmaHelper::registerFunction(&engine, proto, getShapes, "getShapes");
            
            REcmaHelper::registerFunction(&engine, proto, getMeasuredValue, "getMeasuredValue");
            
            REcmaHelper::registerFunction(&engine, proto, getAutoLabel, "getAutoLabel");
            
        engine.setDefaultPrototype(
            qMetaTypeId<RDimRadialData*>(), *proto);

        
                engine.setDefaultPrototype(qMetaTypeId<
                RDimRadialData
                > (), *proto);
            
    

    QScriptValue ctor = engine.newFunction(createEcma, *proto, 2);
    
    // static methods:
    

    // static properties:
    

    // enum values:
    

    // enum conversions:
    
        
    // init class:
    engine.globalObject().setProperty("RDimRadialData",
    ctor, QScriptValue::SkipInEnumeration);
    
    if( protoCreated ){
       delete proto;
    }
    
    }
Esempio n. 12
0
                 void REcmaDimLinearEntity::initEcma(QScriptEngine& engine, QScriptValue* proto 
    
    ) 
    
    {

    bool protoCreated = false;
    if(proto == NULL){
        proto = new QScriptValue(engine.newVariant(qVariantFromValue(
                (RDimLinearEntity*) 0)));
        protoCreated = true;
    }

    
        // primary base class RDimensionEntity:
        
            QScriptValue dpt = engine.defaultPrototype(
                qMetaTypeId<RDimensionEntity*>());

            if (dpt.isValid()) {
                proto->setPrototype(dpt);
            }
          
        /*
        
        */
    

    QScriptValue fun;

    // toString:
    REcmaHelper::registerFunction(&engine, proto, toString, "toString");
    

    // destroy:
    REcmaHelper::registerFunction(&engine, proto, destroy, "destroy");
    
        // conversion for base class RDimensionEntity
        REcmaHelper::registerFunction(&engine, proto, getRDimensionEntity, "getRDimensionEntity");
        
        // conversion for base class REntity
        REcmaHelper::registerFunction(&engine, proto, getREntity, "getREntity");
        
        // conversion for base class RObject
        REcmaHelper::registerFunction(&engine, proto, getRObject, "getRObject");
        

    // get class name
    REcmaHelper::registerFunction(&engine, proto, getClassName, "getClassName");
    

    // conversion to all base classes (multiple inheritance):
    REcmaHelper::registerFunction(&engine, proto, getBaseClasses, "getBaseClasses");
    

    // properties:
    

    // methods:
    
            REcmaHelper::registerFunction(&engine, proto, setProperty, "setProperty");
            
            REcmaHelper::registerFunction(&engine, proto, getProperty, "getProperty");
            
            REcmaHelper::registerFunction(&engine, proto, getData, "getData");
            
            REcmaHelper::registerFunction(&engine, proto, setExtensionPoint1, "setExtensionPoint1");
            
            REcmaHelper::registerFunction(&engine, proto, getExtensionPoint1, "getExtensionPoint1");
            
            REcmaHelper::registerFunction(&engine, proto, setExtensionPoint2, "setExtensionPoint2");
            
            REcmaHelper::registerFunction(&engine, proto, getExtensionPoint2, "getExtensionPoint2");
            
        engine.setDefaultPrototype(
            qMetaTypeId<RDimLinearEntity*>(), *proto);

        
    

    QScriptValue ctor = engine.newFunction(createEcma, *proto, 2);
    
    // static methods:
    
            REcmaHelper::registerFunction(&engine, &ctor, init, "init");
            

    // static properties:
    
            ctor.setProperty("PropertyCustom",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyCustom),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyHandle",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyHandle),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyProtected",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyProtected),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyType",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyType),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyBlock",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyBlock),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyLayer",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyLayer),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyLinetype",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyLinetype),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyLinetypeScale",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyLinetypeScale),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyLineweight",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyLineweight),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyColor",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyColor),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyDisplayedColor",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyDisplayedColor),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyDrawOrder",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyDrawOrder),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyMiddleOfTextX",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyMiddleOfTextX),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyMiddleOfTextY",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyMiddleOfTextY),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyMiddleOfTextZ",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyMiddleOfTextZ),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyText",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyText),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyUpperTolerance",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyUpperTolerance),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyLowerTolerance",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyLowerTolerance),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyMeasuredValue",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyMeasuredValue),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyLinearFactor",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyLinearFactor),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyDimScale",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyDimScale),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyAutoTextPos",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyAutoTextPos),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyFontName",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyFontName),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyDimensionLinePosX",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyDimensionLinePosX),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyDimensionLinePosY",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyDimensionLinePosY),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyDimensionLinePosZ",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyDimensionLinePosZ),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyExtensionPoint1X",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyExtensionPoint1X),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyExtensionPoint1Y",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyExtensionPoint1Y),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyExtensionPoint1Z",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyExtensionPoint1Z),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyExtensionPoint2X",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyExtensionPoint2X),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyExtensionPoint2Y",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyExtensionPoint2Y),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyExtensionPoint2Z",
                qScriptValueFromValue(&engine, RDimLinearEntity::PropertyExtensionPoint2Z),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            

    // enum values:
    

    // enum conversions:
    
        
    // init class:
    engine.globalObject().setProperty("RDimLinearEntity",
    ctor, QScriptValue::SkipInEnumeration);
    
    if( protoCreated ){
       delete proto;
    }
    
    }
                 void REcmaSharedPointerCircleEntity::init(QScriptEngine& engine, QScriptValue* proto 
    
    ) 
    
    {

    bool protoCreated = false;
    if(proto == NULL){
        proto = new QScriptValue(engine.newVariant(qVariantFromValue(
                (RCircleEntityPointer*) 0)));
        protoCreated = true;
    }

    
        // primary base class REntity:
        
            proto->setPrototype(engine.defaultPrototype(
            qMetaTypeId<REntityPointer>()));
          
        /*
        
        */
    

    QScriptValue fun;

    // toString:
    REcmaHelper::registerFunction(&engine, proto, toString, "toString");
    
        // shared pointer support:
        REcmaHelper::registerFunction(&engine, proto, data, "data");
        

        REcmaHelper::registerFunction(&engine, proto, isNull, "isNull");
        

    // destroy:
    REcmaHelper::registerFunction(&engine, proto, destroy, "destroy");
    
        // conversion for base class REntity
        REcmaHelper::registerFunction(&engine, proto, getREntity, "getREntity");
        
        // conversion for base class RObject
        REcmaHelper::registerFunction(&engine, proto, getRObject, "getRObject");
        

    // get class name
    REcmaHelper::registerFunction(&engine, proto, getClassName, "getClassName");
    

    // conversion to all base classes (multiple inheritance):
    REcmaHelper::registerFunction(&engine, proto, getBaseClasses, "getBaseClasses");
    

    // properties:
    

    // methods:
    
            REcmaHelper::registerFunction(&engine, proto, clone, "clone");
            
            REcmaHelper::registerFunction(&engine, proto, getType, "getType");
            
            REcmaHelper::registerFunction(&engine, proto, setProperty, "setProperty");
            
            REcmaHelper::registerFunction(&engine, proto, getProperty, "getProperty");
            
            REcmaHelper::registerFunction(&engine, proto, exportEntity, "exportEntity");
            
            REcmaHelper::registerFunction(&engine, proto, getData, "getData");
            
            REcmaHelper::registerFunction(&engine, proto, getCenter, "getCenter");
            
            REcmaHelper::registerFunction(&engine, proto, getRadius, "getRadius");
            
            REcmaHelper::registerFunction(&engine, proto, setRadius, "setRadius");
            
        engine.setDefaultPrototype(
            qMetaTypeId<RCircleEntityPointer>(), *proto);
      
    

    QScriptValue ctor = engine.newFunction(create, *proto, 2);
    
    // static methods:
    
            REcmaHelper::registerFunction(&engine, &ctor, init, "init");
            

    // static properties:
    
            ctor.setProperty("PropertyCustom",
                qScriptValueFromValue(&engine, RCircleEntity::PropertyCustom),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyHandle",
                qScriptValueFromValue(&engine, RCircleEntity::PropertyHandle),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyType",
                qScriptValueFromValue(&engine, RCircleEntity::PropertyType),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyBlock",
                qScriptValueFromValue(&engine, RCircleEntity::PropertyBlock),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyLayer",
                qScriptValueFromValue(&engine, RCircleEntity::PropertyLayer),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyLinetype",
                qScriptValueFromValue(&engine, RCircleEntity::PropertyLinetype),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyLineweight",
                qScriptValueFromValue(&engine, RCircleEntity::PropertyLineweight),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyColor",
                qScriptValueFromValue(&engine, RCircleEntity::PropertyColor),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyDrawOrder",
                qScriptValueFromValue(&engine, RCircleEntity::PropertyDrawOrder),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyCenterX",
                qScriptValueFromValue(&engine, RCircleEntity::PropertyCenterX),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyCenterY",
                qScriptValueFromValue(&engine, RCircleEntity::PropertyCenterY),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyCenterZ",
                qScriptValueFromValue(&engine, RCircleEntity::PropertyCenterZ),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyRadius",
                qScriptValueFromValue(&engine, RCircleEntity::PropertyRadius),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyDiameter",
                qScriptValueFromValue(&engine, RCircleEntity::PropertyDiameter),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyCircumference",
                qScriptValueFromValue(&engine, RCircleEntity::PropertyCircumference),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyArea",
                qScriptValueFromValue(&engine, RCircleEntity::PropertyArea),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            

    // enum values:
    

    // enum conversions:
    
        
    // init class:
    engine.globalObject().setProperty("RCircleEntityPointer",
    ctor, QScriptValue::SkipInEnumeration);
    
    if( protoCreated ){
       delete proto;
    }
    
    }
Esempio n. 14
0
        // includes for base ecma wrapper classes
         void REcmaTextRenderer::init(QScriptEngine& engine, QScriptValue* proto 
    
    ) 
    
    {

    bool protoCreated = false;
    if(proto == NULL){
        proto = new QScriptValue(engine.newVariant(qVariantFromValue(
                (RTextRenderer*) 0)));
        protoCreated = true;
    }

    

    QScriptValue fun;

    // toString:
    REcmaHelper::registerFunction(&engine, proto, toString, "toString");
    

    // destroy:
    REcmaHelper::registerFunction(&engine, proto, destroy, "destroy");
    

    // get class name
    REcmaHelper::registerFunction(&engine, proto, getClassName, "getClassName");
    

    // conversion to all base classes (multiple inheritance):
    REcmaHelper::registerFunction(&engine, proto, getBaseClasses, "getBaseClasses");
    

    // properties:
    

    // methods:
    
            REcmaHelper::registerFunction(&engine, proto, renderSimple, "renderSimple");
            
            REcmaHelper::registerFunction(&engine, proto, render, "render");
            
            REcmaHelper::registerFunction(&engine, proto, getPainterPaths, "getPainterPaths");
            
            REcmaHelper::registerFunction(&engine, proto, getBoundingBox, "getBoundingBox");
            
            REcmaHelper::registerFunction(&engine, proto, getHeight, "getHeight");
            
            REcmaHelper::registerFunction(&engine, proto, getWidth, "getWidth");
            
            REcmaHelper::registerFunction(&engine, proto, getRichText, "getRichText");
            
        engine.setDefaultPrototype(
            qMetaTypeId<RTextRenderer*>(), *proto);

        
    

    QScriptValue ctor = engine.newFunction(create, *proto, 2);
    
    // static methods:
    

    // static properties:
    
            ctor.setProperty("rxLineFeed",
                qScriptValueFromValue(&engine, RTextRenderer::rxLineFeed),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("rxParagraphFeed",
                qScriptValueFromValue(&engine, RTextRenderer::rxParagraphFeed),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("rxHeightChange",
                qScriptValueFromValue(&engine, RTextRenderer::rxHeightChange),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("rxStackedText",
                qScriptValueFromValue(&engine, RTextRenderer::rxStackedText),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("rxColorChangeIndex",
                qScriptValueFromValue(&engine, RTextRenderer::rxColorChangeIndex),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("rxColorChangeCustom",
                qScriptValueFromValue(&engine, RTextRenderer::rxColorChangeCustom),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("rxNonBreakingSpace",
                qScriptValueFromValue(&engine, RTextRenderer::rxNonBreakingSpace),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("rxOverlineOn",
                qScriptValueFromValue(&engine, RTextRenderer::rxOverlineOn),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("rxOverlineOff",
                qScriptValueFromValue(&engine, RTextRenderer::rxOverlineOff),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("rxUnderlineOn",
                qScriptValueFromValue(&engine, RTextRenderer::rxUnderlineOn),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("rxUnderlineOff",
                qScriptValueFromValue(&engine, RTextRenderer::rxUnderlineOff),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("rxWidthChange",
                qScriptValueFromValue(&engine, RTextRenderer::rxWidthChange),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("rxObliqueAngleChange",
                qScriptValueFromValue(&engine, RTextRenderer::rxObliqueAngleChange),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("rxTrackChange",
                qScriptValueFromValue(&engine, RTextRenderer::rxTrackChange),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("rxAlignmentChange",
                qScriptValueFromValue(&engine, RTextRenderer::rxAlignmentChange),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("rxFontChangeCad",
                qScriptValueFromValue(&engine, RTextRenderer::rxFontChangeCad),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("rxFontChangeTtf",
                qScriptValueFromValue(&engine, RTextRenderer::rxFontChangeTtf),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("rxBeginBlock",
                qScriptValueFromValue(&engine, RTextRenderer::rxBeginBlock),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("rxEndBlock",
                qScriptValueFromValue(&engine, RTextRenderer::rxEndBlock),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("rxBackslash",
                qScriptValueFromValue(&engine, RTextRenderer::rxBackslash),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("rxCurlyOpen",
                qScriptValueFromValue(&engine, RTextRenderer::rxCurlyOpen),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("rxCurlyClose",
                qScriptValueFromValue(&engine, RTextRenderer::rxCurlyClose),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("rxDegree",
                qScriptValueFromValue(&engine, RTextRenderer::rxDegree),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("escDegree",
                qScriptValueFromValue(&engine, RTextRenderer::escDegree),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("rxPlusMinus",
                qScriptValueFromValue(&engine, RTextRenderer::rxPlusMinus),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("escPlusMinus",
                qScriptValueFromValue(&engine, RTextRenderer::escPlusMinus),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("rxDiameter",
                qScriptValueFromValue(&engine, RTextRenderer::rxDiameter),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("escDiameter",
                qScriptValueFromValue(&engine, RTextRenderer::escDiameter),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("rxUnicode",
                qScriptValueFromValue(&engine, RTextRenderer::rxUnicode),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("rxAll",
                qScriptValueFromValue(&engine, RTextRenderer::rxAll),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("chDegree",
                qScriptValueFromValue(&engine, RTextRenderer::chDegree),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("chPlusMinus",
                qScriptValueFromValue(&engine, RTextRenderer::chPlusMinus),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("chDiameter",
                qScriptValueFromValue(&engine, RTextRenderer::chDiameter),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            

    // enum values:
    

    ctor.setProperty("PainterPaths",
    QScriptValue(RTextRenderer::PainterPaths),
    QScriptValue::ReadOnly);


    ctor.setProperty("RichText",
    QScriptValue(RTextRenderer::RichText),
    QScriptValue::ReadOnly);


    // enum conversions:
    
    qScriptRegisterMetaType<RTextRenderer::Target>(
        &engine,
        toScriptValueEnumTarget,
        fromScriptValueEnumTarget,
        ctor.property(QString::fromLatin1("prototype"))
    );

        
    // init class:
    engine.globalObject().setProperty("RTextRenderer",
    ctor, QScriptValue::SkipInEnumeration);
    
    if( protoCreated ){
       delete proto;
    }
    
    }
Esempio n. 15
0
void tst_QScriptEngineDebugger::attachAndDetach()
{
#if defined(Q_OS_WINCE) && _WIN32_WCE < 0x600
    QSKIP("skipped due to high mem usage until task 261062 is fixed", SkipAll);
#endif
    {
        QScriptEngineDebugger debugger;
        QCOMPARE(debugger.state(), QScriptEngineDebugger::SuspendedState);
        debugger.attachTo(0);
        QScriptEngine engine;
        debugger.attachTo(&engine);
        QCOMPARE(debugger.state(), QScriptEngineDebugger::SuspendedState);
    }
    {
        QScriptEngineDebugger debugger;
        QScriptEngine engine;
        QScriptValue oldPrint = engine.globalObject().property("print");
        QVERIFY(oldPrint.isFunction());
        QVERIFY(!engine.globalObject().property("__FILE__").isValid());
        QVERIFY(!engine.globalObject().property("__LINE__").isValid());

        debugger.attachTo(&engine);
        QVERIFY(engine.globalObject().property("__FILE__").isUndefined());
        QVERIFY(engine.globalObject().property("__LINE__").isNumber());
        QVERIFY(!engine.globalObject().property("print").strictlyEquals(oldPrint));

        debugger.detach();
        QVERIFY(engine.globalObject().property("print").strictlyEquals(oldPrint));
        QVERIFY(!engine.globalObject().property("__FILE__").isValid());
        QVERIFY(!engine.globalObject().property("__LINE__").isValid());
    }
    {
        QScriptEngineDebugger debugger;
        QScriptEngine engine;
        debugger.attachTo(&engine);
        debugger.detach();
        QScriptEngine engine2;
        debugger.attachTo(&engine2);
    }
    {
        QScriptEngineDebugger debugger;
        QScriptEngine engine;
        debugger.attachTo(&engine);
        debugger.detach();
        QScriptEngine engine2;
        debugger.attachTo(&engine2);
        debugger.detach();
    }
#ifndef Q_OS_WINCE // demands too much memory for WinCE
    {
        QScriptEngineDebugger debugger;
        QScriptEngine engine;
        debugger.attachTo(&engine);
        QScriptEngineDebugger debugger2;
        debugger2.attachTo(&engine);
    }
#endif
    {
        QScriptEngine *engine = new QScriptEngine;
        QScriptEngineDebugger debugger;
        debugger.attachTo(engine);
        delete engine;
        QScriptEngine engine2;
        debugger.attachTo(&engine2);
    }
}
Esempio n. 16
0
myObject.setProperty("name", "John Doe");
//! [0]


//! [1]
QScriptValue val(&myEngine, 123);
myObject.setProperty("myReadOnlyProperty", val, QScriptValue::ReadOnly);
//! [1]


//! [2]
QScriptEngine engine;
engine.evaluate("function fullName() { return this.firstName + ' ' + this.lastName; }");
engine.evaluate("somePerson = { firstName: 'John', lastName: 'Doe' }");

QScriptValue global = engine.globalObject();
QScriptValue fullName = global.property("fullName");
QScriptValue who = global.property("somePerson");
qDebug() << fullName.call(who).toString(); // "John Doe"

engine.evaluate("function cube(x) { return x * x * x; }");
QScriptValue cube = global.property("cube");
QScriptValueList args;
args << 3;
qDebug() << cube.call(QScriptValue(), args).toNumber(); // 27
//! [2]


//! [3]
QScriptValue myNativeFunction(QScriptContext *ctx, QScriptEngine *)
{
Esempio n. 17
0
                 void REcmaOrthoGrid::initEcma(QScriptEngine& engine, QScriptValue* proto 
    
    ) 
    
    {

    bool protoCreated = false;
    if(proto == NULL){
        proto = new QScriptValue(engine.newVariant(qVariantFromValue(
                (ROrthoGrid*) 0)));
        protoCreated = true;
    }

    
        // primary base class RGrid:
        
            QScriptValue dpt = engine.defaultPrototype(
                qMetaTypeId<RGrid*>());

            if (dpt.isValid()) {
                proto->setPrototype(dpt);
            }
          
        /*
        
        */
    

    QScriptValue fun;

    // toString:
    REcmaHelper::registerFunction(&engine, proto, toString, "toString");
    

    // destroy:
    REcmaHelper::registerFunction(&engine, proto, destroy, "destroy");
    
        // conversion for base class RGrid
        REcmaHelper::registerFunction(&engine, proto, getRGrid, "getRGrid");
        

    // get class name
    REcmaHelper::registerFunction(&engine, proto, getClassName, "getClassName");
    

    // conversion to all base classes (multiple inheritance):
    REcmaHelper::registerFunction(&engine, proto, getBaseClasses, "getBaseClasses");
    

    // properties:
    

    // methods:
    
            REcmaHelper::registerFunction(&engine, proto, clearCache, "clearCache");
            
            REcmaHelper::registerFunction(&engine, proto, snapToGrid, "snapToGrid");
            
            REcmaHelper::registerFunction(&engine, proto, update, "update");
            
            REcmaHelper::registerFunction(&engine, proto, paint, "paint");
            
            REcmaHelper::registerFunction(&engine, proto, paintMetaGrid, "paintMetaGrid");
            
            REcmaHelper::registerFunction(&engine, proto, paintGridLines, "paintGridLines");
            
            REcmaHelper::registerFunction(&engine, proto, paintGridPoints, "paintGridPoints");
            
            REcmaHelper::registerFunction(&engine, proto, paintCursor, "paintCursor");
            
            REcmaHelper::registerFunction(&engine, proto, paintRuler, "paintRuler");
            
            REcmaHelper::registerFunction(&engine, proto, getInfoText, "getInfoText");
            
            REcmaHelper::registerFunction(&engine, proto, getIdealSpacing, "getIdealSpacing");
            
            REcmaHelper::registerFunction(&engine, proto, isIsometric, "isIsometric");
            
            REcmaHelper::registerFunction(&engine, proto, setIsometric, "setIsometric");
            
            REcmaHelper::registerFunction(&engine, proto, getProjection, "getProjection");
            
            REcmaHelper::registerFunction(&engine, proto, setProjection, "setProjection");
            
        engine.setDefaultPrototype(
            qMetaTypeId<ROrthoGrid*>(), *proto);

        
    

    QScriptValue ctor = engine.newFunction(createEcma, *proto, 2);
    
    // static methods:
    
            REcmaHelper::registerFunction(&engine, &ctor, getIdealGridSpacing, "getIdealGridSpacing");
            
            REcmaHelper::registerFunction(&engine, &ctor, isFractionalFormat, "isFractionalFormat");
            

    // static properties:
    

    // enum values:
    

    // enum conversions:
    
        
    // init class:
    engine.globalObject().setProperty("ROrthoGrid",
    ctor, QScriptValue::SkipInEnumeration);
    
    if( protoCreated ){
       delete proto;
    }
    
    }
Esempio n. 18
0
// includes for base ecma wrapper classes
void REcmaPluginLoader::initEcma(QScriptEngine& engine, QScriptValue* proto

                                )

{

    bool protoCreated = false;
    if(proto == NULL) {
        proto = new QScriptValue(engine.newVariant(qVariantFromValue(
                                     (RPluginLoader*) 0)));
        protoCreated = true;
    }



    QScriptValue fun;

    // toString:
    REcmaHelper::registerFunction(&engine, proto, toString, "toString");


    // destroy:
    REcmaHelper::registerFunction(&engine, proto, destroy, "destroy");


    // get class name
    REcmaHelper::registerFunction(&engine, proto, getClassName, "getClassName");


    // conversion to all base classes (multiple inheritance):
    REcmaHelper::registerFunction(&engine, proto, getBaseClasses, "getBaseClasses");


    // properties:


    // methods:

    engine.setDefaultPrototype(
        qMetaTypeId<RPluginLoader*>(), *proto);




    QScriptValue ctor = engine.newFunction(createEcma, *proto, 2);

    // static methods:

    REcmaHelper::registerFunction(&engine, &ctor, getPluginSuffix, "getPluginSuffix");

    REcmaHelper::registerFunction(&engine, &ctor, getPluginFiles, "getPluginFiles");

    REcmaHelper::registerFunction(&engine, &ctor, loadPlugins, "loadPlugins");

    REcmaHelper::registerFunction(&engine, &ctor, unloadPlugins, "unloadPlugins");

    REcmaHelper::registerFunction(&engine, &ctor, unloadPlugin, "unloadPlugin");

    REcmaHelper::registerFunction(&engine, &ctor, postInitPlugins, "postInitPlugins");

    REcmaHelper::registerFunction(&engine, &ctor, countPlugins, "countPlugins");

    REcmaHelper::registerFunction(&engine, &ctor, getPluginInfo, "getPluginInfo");

    REcmaHelper::registerFunction(&engine, &ctor, getPluginsPath, "getPluginsPath");

    REcmaHelper::registerFunction(&engine, &ctor, hasPlugin, "hasPlugin");


    // static properties:


    // enum values:


    // enum conversions:


    // init class:
    engine.globalObject().setProperty("RPluginLoader",
                                      ctor, QScriptValue::SkipInEnumeration);

    if( protoCreated ) {
        delete proto;
    }

}
Esempio n. 19
0
void ScriptableWorker::run()
{
    MONITOR_LOG("starting");

    QScriptEngine engine;
    ScriptableProxy proxy(m_wnd);
    Scriptable scriptable(&proxy);
    scriptable.initEngine( &engine, QString::fromUtf8(m_args.at(Arguments::CurrentPath)),
                           m_args.at(Arguments::ActionId) );

    if (m_socket) {
        QObject::connect( &scriptable, SIGNAL(sendMessage(QByteArray,int)),
                          m_socket, SLOT(sendMessage(QByteArray,int)) );
        QObject::connect( m_socket, SIGNAL(messageReceived(QByteArray,int)),
                          &scriptable, SLOT(setInput(QByteArray)) );

        QObject::connect( m_socket, SIGNAL(disconnected()),
                          &scriptable, SLOT(abort()) );
        QObject::connect( &scriptable, SIGNAL(destroyed()),
                          m_socket, SLOT(deleteAfterDisconnected()) );

        if ( m_socket->isClosed() ) {
            MONITOR_LOG("terminated");
            return;
        }

        m_socket->start();
    }

    QObject::connect( &scriptable, SIGNAL(requestApplicationQuit()),
                      qApp, SLOT(quit()) );

    QByteArray response;
    int exitCode;

    if ( m_args.length() <= Arguments::Rest ) {
        MONITOR_LOG("Error: bad command syntax");
        exitCode = CommandBadSyntax;
    } else {
        const QString cmd = QString::fromUtf8( m_args.at(Arguments::Rest) );

        if ( hasLogLevel(LogDebug) ) {
            MONITOR_LOG("Client arguments:");
            for (int i = Arguments::Rest; i < m_args.length(); ++i)
                MONITOR_LOG( "    " + QString::fromUtf8(m_args.at(i)) );
        }

#ifdef HAS_TESTS
        if ( cmd == "flush" && m_args.length() == Arguments::Rest + 2 ) {
            MONITOR_LOG( "flush ID: " + QString::fromUtf8(m_args.at(Arguments::Rest + 1)) );
            scriptable.sendMessageToClient(QByteArray(), CommandFinished);
            return;
        }
#endif

        QScriptValue fn = engine.globalObject().property(cmd);
        if ( !fn.isFunction() ) {
            MONITOR_LOG("Error: unknown command");
            response = createLogMessage("CopyQ client",
                                        Scriptable::tr("Name \"%1\" doesn't refer to a function.")
                                        .arg(cmd),
                                        LogError).toUtf8();
            exitCode = CommandError;
        } else {
            QScriptValueList fnArgs;
            for ( int i = Arguments::Rest + 1; i < m_args.length(); ++i )
                fnArgs.append( scriptable.newByteArray(m_args.at(i)) );

            QScriptValue result = fn.call(QScriptValue(), fnArgs);

            if ( engine.hasUncaughtException() ) {
                const QString exceptionText = engine.uncaughtException().toString();
                MONITOR_LOG( QString("Error: exception in command \"%1\": %2")
                             .arg(cmd).arg(exceptionText) );
                response = createLogMessage("CopyQ client", exceptionText, LogError).toUtf8();
                exitCode = CommandError;
            } else {
                response = serializeScriptValue(result);
                exitCode = CommandFinished;
            }
        }
    }

    scriptable.sendMessageToClient(response, exitCode);

    MONITOR_LOG("finished");
}
Esempio n. 20
0
                 void REcmaSharedPointerBlock::initEcma(QScriptEngine& engine, QScriptValue* proto 
    
    ) 
    
    {

    bool protoCreated = false;
    if(proto == NULL){
        proto = new QScriptValue(engine.newVariant(qVariantFromValue(
                (RBlockPointer*) 0)));
        protoCreated = true;
    }

    
        // primary base class RObject:
        
            proto->setPrototype(engine.defaultPrototype(
            qMetaTypeId<RObjectPointer>()));
          
        /*
        
        */
    

    QScriptValue fun;

    // toString:
    REcmaHelper::registerFunction(&engine, proto, toString, "toString");
    
        // shared pointer support:
        REcmaHelper::registerFunction(&engine, proto, data, "data");
        

        REcmaHelper::registerFunction(&engine, proto, isNull, "isNull");
        

    // destroy:
    REcmaHelper::registerFunction(&engine, proto, destroy, "destroy");
    
        // conversion for base class RObject
        REcmaHelper::registerFunction(&engine, proto, getRObject, "getRObject");
        

    // get class name
    REcmaHelper::registerFunction(&engine, proto, getClassName, "getClassName");
    

    // conversion to all base classes (multiple inheritance):
    REcmaHelper::registerFunction(&engine, proto, getBaseClasses, "getBaseClasses");
    

    // properties:
    

    // methods:
    
            REcmaHelper::registerFunction(&engine, proto, getType, "getType");
            
            REcmaHelper::registerFunction(&engine, proto, clone, "clone");
            
            REcmaHelper::registerFunction(&engine, proto, getName, "getName");
            
            REcmaHelper::registerFunction(&engine, proto, setName, "setName");
            
            REcmaHelper::registerFunction(&engine, proto, isFrozen, "isFrozen");
            
            REcmaHelper::registerFunction(&engine, proto, setFrozen, "setFrozen");
            
            REcmaHelper::registerFunction(&engine, proto, isAnonymous, "isAnonymous");
            
            REcmaHelper::registerFunction(&engine, proto, setAnonymous, "setAnonymous");
            
            REcmaHelper::registerFunction(&engine, proto, setOrigin, "setOrigin");
            
            REcmaHelper::registerFunction(&engine, proto, getOrigin, "getOrigin");
            
            REcmaHelper::registerFunction(&engine, proto, getProperty, "getProperty");
            
            REcmaHelper::registerFunction(&engine, proto, setProperty, "setProperty");
            
            REcmaHelper::registerFunction(&engine, proto, isSelectedForPropertyEditing, "isSelectedForPropertyEditing");
            
        engine.setDefaultPrototype(
            qMetaTypeId<RBlockPointer>(), *proto);
      
    

    QScriptValue ctor = engine.newFunction(create, *proto, 2);
    
    // static methods:
    
            REcmaHelper::registerFunction(&engine, &ctor, init, "init");
            

    // static properties:
    
            ctor.setProperty("PropertyName",
                qScriptValueFromValue(&engine, RBlock::PropertyName),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyFrozen",
                qScriptValueFromValue(&engine, RBlock::PropertyFrozen),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("modelSpaceName",
                qScriptValueFromValue(&engine, RBlock::modelSpaceName),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            

    // enum values:
    

    // enum conversions:
    
        
    // init class:
    engine.globalObject().setProperty("RBlockPointer",
    ctor, QScriptValue::SkipInEnumeration);
    
    if( protoCreated ){
       delete proto;
    }
    
    }
Esempio n. 21
0
//! [35]
QScriptValue Person_prototype_toString(QScriptContext *context, QScriptEngine *engine)
{
  QString name = context->thisObject().property("name").toString();
  QString result = QString::fromLatin1("Person(name: %0)").arg(name);
  return result;
}
//! [35]


//! [36]
QScriptEngine engine;
QScriptValue ctor = engine.newFunction(Person_ctor);
ctor.property("prototype").setProperty("toString", engine.newFunction(Person_prototype_toString));
QScriptValue global = engine.globalObject();
global.setProperty("Person", ctor);
//! [36]


//! [37]
QScriptValue Employee_ctor(QScriptContext *context, QScriptEngine *engine)
{
  QScriptValue super = context->callee().property("prototype").property("constructor");
  super.call(context->thisObject(), QScriptValueList() << context->argument(0));
  context->thisObject().setProperty("salary", context->argument(1));
  return engine->undefinedValue();
}
//! [37]

Esempio n. 22
0
                 void REcmaAttributeEntity::init(QScriptEngine& engine, QScriptValue* proto 
    
    ) 
    
    {

    bool protoCreated = false;
    if(proto == NULL){
        proto = new QScriptValue(engine.newVariant(qVariantFromValue(
                (RAttributeEntity*) 0)));
        protoCreated = true;
    }

    
        // primary base class RTextBasedEntity:
        
            QScriptValue dpt = engine.defaultPrototype(
                qMetaTypeId<RTextBasedEntity*>());

            if (dpt.isValid()) {
                proto->setPrototype(dpt);
            }
          
        /*
        
        */
    

    QScriptValue fun;

    // toString:
    REcmaHelper::registerFunction(&engine, proto, toString, "toString");
    

    // destroy:
    REcmaHelper::registerFunction(&engine, proto, destroy, "destroy");
    
        // conversion for base class RTextBasedEntity
        REcmaHelper::registerFunction(&engine, proto, getRTextBasedEntity, "getRTextBasedEntity");
        
        // conversion for base class REntity
        REcmaHelper::registerFunction(&engine, proto, getREntity, "getREntity");
        
        // conversion for base class RObject
        REcmaHelper::registerFunction(&engine, proto, getRObject, "getRObject");
        

    // get class name
    REcmaHelper::registerFunction(&engine, proto, getClassName, "getClassName");
    

    // conversion to all base classes (multiple inheritance):
    REcmaHelper::registerFunction(&engine, proto, getBaseClasses, "getBaseClasses");
    

    // properties:
    

    // methods:
    
            REcmaHelper::registerFunction(&engine, proto, clone, "clone");
            
            REcmaHelper::registerFunction(&engine, proto, getType, "getType");
            
            REcmaHelper::registerFunction(&engine, proto, getData, "getData");
            
            REcmaHelper::registerFunction(&engine, proto, setData, "setData");
            
            REcmaHelper::registerFunction(&engine, proto, setProperty, "setProperty");
            
            REcmaHelper::registerFunction(&engine, proto, getProperty, "getProperty");
            
            REcmaHelper::registerFunction(&engine, proto, exportEntity, "exportEntity");
            
            REcmaHelper::registerFunction(&engine, proto, getTag, "getTag");
            
            REcmaHelper::registerFunction(&engine, proto, setTag, "setTag");
            
        engine.setDefaultPrototype(
            qMetaTypeId<RAttributeEntity*>(), *proto);

        
    

    QScriptValue ctor = engine.newFunction(create, *proto, 2);
    
    // static methods:
    
            REcmaHelper::registerFunction(&engine, &ctor, init, "init");
            

    // static properties:
    
            ctor.setProperty("PropertyCustom",
                qScriptValueFromValue(&engine, RAttributeEntity::PropertyCustom),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyHandle",
                qScriptValueFromValue(&engine, RAttributeEntity::PropertyHandle),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyType",
                qScriptValueFromValue(&engine, RAttributeEntity::PropertyType),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyBlock",
                qScriptValueFromValue(&engine, RAttributeEntity::PropertyBlock),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyLayer",
                qScriptValueFromValue(&engine, RAttributeEntity::PropertyLayer),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyLinetype",
                qScriptValueFromValue(&engine, RAttributeEntity::PropertyLinetype),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyLineweight",
                qScriptValueFromValue(&engine, RAttributeEntity::PropertyLineweight),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyColor",
                qScriptValueFromValue(&engine, RAttributeEntity::PropertyColor),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyDrawOrder",
                qScriptValueFromValue(&engine, RAttributeEntity::PropertyDrawOrder),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyAngle",
                qScriptValueFromValue(&engine, RAttributeEntity::PropertyAngle),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyBold",
                qScriptValueFromValue(&engine, RAttributeEntity::PropertyBold),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyFontName",
                qScriptValueFromValue(&engine, RAttributeEntity::PropertyFontName),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyHAlign",
                qScriptValueFromValue(&engine, RAttributeEntity::PropertyHAlign),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyHeight",
                qScriptValueFromValue(&engine, RAttributeEntity::PropertyHeight),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyItalic",
                qScriptValueFromValue(&engine, RAttributeEntity::PropertyItalic),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyLineSpacingFactor",
                qScriptValueFromValue(&engine, RAttributeEntity::PropertyLineSpacingFactor),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyPositionX",
                qScriptValueFromValue(&engine, RAttributeEntity::PropertyPositionX),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyPositionY",
                qScriptValueFromValue(&engine, RAttributeEntity::PropertyPositionY),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyPositionZ",
                qScriptValueFromValue(&engine, RAttributeEntity::PropertyPositionZ),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyTag",
                qScriptValueFromValue(&engine, RAttributeEntity::PropertyTag),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyText",
                qScriptValueFromValue(&engine, RAttributeEntity::PropertyText),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            
            ctor.setProperty("PropertyVAlign",
                qScriptValueFromValue(&engine, RAttributeEntity::PropertyVAlign),
                QScriptValue::SkipInEnumeration | QScriptValue::ReadOnly);
            

    // enum values:
    

    // enum conversions:
    
        
    // init class:
    engine.globalObject().setProperty("RAttributeEntity",
    ctor, QScriptValue::SkipInEnumeration);
    
    if( protoCreated ){
       delete proto;
    }
    
    }
Esempio n. 23
0
                 void REcmaSharedPointerRay::initEcma(QScriptEngine& engine, QScriptValue* proto 
    
    ) 
    
    {

    bool protoCreated = false;
    if(proto == NULL){
        proto = new QScriptValue(engine.newVariant(qVariantFromValue(
                (RRayPointer*) 0)));
        protoCreated = true;
    }

    
        // primary base class RXLine:
        
            proto->setPrototype(engine.defaultPrototype(
            qMetaTypeId<RXLinePointer>()));
          
        /*
        
        */
    

    QScriptValue fun;

    // toString:
    REcmaHelper::registerFunction(&engine, proto, toString, "toString");
    
    // copy:
    REcmaHelper::registerFunction(&engine, proto, copy, "copy");
    
        // shared pointer support:
        REcmaHelper::registerFunction(&engine, proto, data, "data");
        

        REcmaHelper::registerFunction(&engine, proto, isNull, "isNull");
        

    // destroy:
    REcmaHelper::registerFunction(&engine, proto, destroy, "destroy");
    
        // conversion for base class RXLine
        REcmaHelper::registerFunction(&engine, proto, getRXLine, "getRXLine");
        
        // conversion for base class RShape
        REcmaHelper::registerFunction(&engine, proto, getRShape, "getRShape");
        
        // conversion for base class RDirected
        REcmaHelper::registerFunction(&engine, proto, getRDirected, "getRDirected");
        

    // get class name
    REcmaHelper::registerFunction(&engine, proto, getClassName, "getClassName");
    

    // conversion to all base classes (multiple inheritance):
    REcmaHelper::registerFunction(&engine, proto, getBaseClasses, "getBaseClasses");
    

    // properties:
    

    // methods:
    
            REcmaHelper::registerFunction(&engine, proto, clone, "clone");
            
            REcmaHelper::registerFunction(&engine, proto, trimEndPoint, "trimEndPoint");
            
            REcmaHelper::registerFunction(&engine, proto, getPointsWithDistanceToEnd, "getPointsWithDistanceToEnd");
            
            REcmaHelper::registerFunction(&engine, proto, reverse, "reverse");
            
            REcmaHelper::registerFunction(&engine, proto, getClippedLine, "getClippedLine");
            
            REcmaHelper::registerFunction(&engine, proto, getVectorTo, "getVectorTo");
            
            REcmaHelper::registerFunction(&engine, proto, stretch, "stretch");
            
        engine.setDefaultPrototype(
            qMetaTypeId<RRayPointer>(), *proto);
      
    

    QScriptValue ctor = engine.newFunction(createEcma, *proto, 2);
    
    // static methods:
    

    // static properties:
    

    // enum values:
    

    // enum conversions:
    
        
    // init class:
    engine.globalObject().setProperty("RRayPointer",
    ctor, QScriptValue::SkipInEnumeration);
    
    if( protoCreated ){
       delete proto;
    }
    
    }
Esempio n. 24
0
QString QtRPT::sectionField(QString value, bool exp, bool firstPass) {
    QString tmpStr;
    QStringList res;
    bool aggregate = false;

    for (int i = 0; i < value.size(); ++i) {
        if (value.at(i) != '[' && value.at(i) != ']' &&
            value.at(i) != '<' && value.at(i) != '>' && !aggregate)
            tmpStr += value.at(i);
        else if ((value.at(i) == '[' || value.at(i) == ']') && aggregate)
             tmpStr += value.at(i);
        else if (value.at(i) != '<' && value.at(i) != '>' && aggregate)
             tmpStr += value.at(i);
        else {
            if (exp && (value.at(i) == '<' || value.at(i) == '>') )
                tmpStr += value.at(i);
            if (value.at(i) == ']' && !aggregate) {
                tmpStr += value.at(i);
                res << tmpStr;
                tmpStr.clear();
            }
            if (value.at(i) == '[' && !aggregate) {
                if (!tmpStr.isEmpty())
                    res << tmpStr;
                tmpStr.clear();
                tmpStr += value.at(i);
            }
            if (!exp && value.at(i) == '<') {
                aggregate = true;
                if (!tmpStr.isEmpty())
                    res << tmpStr;
                tmpStr.clear();
                tmpStr += value.at(i);
            }
            if (!exp && value.at(i) == '>') {
                aggregate = false;
                tmpStr += value.at(i);
                res << tmpStr;
                tmpStr.clear();
            }
        }
    }
    if (!tmpStr.isEmpty()) res << tmpStr;    

    tmpStr.clear();
    for (int i = 0; i < res.size(); ++i) {
        if (res.at(i).contains("[") && res.at(i).contains("]") && !res.at(i).contains("<") ) {
            QString tmp = sectionValue(res.at(i));
            bool ok;
            if (exp) { //Process highlighting and visibility
                tmp.toDouble(&ok);
                if (!ok) tmp.toFloat(&ok);
                if (!ok) tmp.toInt(&ok);
                if (!ok)
                    tmpStr += "'"+tmp+"'";
                else
                    tmpStr += tmp;
            } else { //Process usuall field
                if (firstPass) { //Process during first pass to calculate aggregate values
                    double v = tmp.toDouble(&ok);
                    if (ok) {
                        AggregateValues av;
                        av.paramName = res.at(i);
                        av.paramValue = v;
                        av.lnNo = m_recNo;
                        bool founded = false;
                        for (int j = 0; j < listOfPair.size(); ++j) {
                            if (listOfPair.at(j).lnNo == av.lnNo && listOfPair.at(j).paramName == av.paramName)
                                founded = true;
                        }
                        if (!founded)
                            listOfPair.append(av);
                    }
                }
                tmpStr += tmp;
            }
        } else {
            if (res[i].contains("<Date>"))
                res[i] = res[i].replace("<Date>",processFunctions("Date").toString());
            if (res[i].contains("<Time>"))
                res[i] = res[i].replace("<Time>",QTime::currentTime().toString());
            if (res[i].contains("<Page>"))
                res[i] = res[i].replace("<Page>",QString::number(curPage));
            if (res[i].contains("<TotalPages>"))
                res[i] = res[i].replace("<TotalPages>",QString::number(totalPage));
            if (res[i].contains("<LineNo>"))
                res[i] = res[i].replace("<LineNo>",QString::number(m_recNo+1));

            if (res[i].contains("<") && res[i].contains(">")) {
                QString formulaStr=res[i];
                QScriptEngine myEngine;

                QStringList tl = splitValue(formulaStr);
                for (int j = 1; j < tl.size(); ++j) {
                    if (tl.at(j).contains("[") &&
                        tl.at(j).contains("]") &&
                        !tl.at(j-1).toUpper().contains("SUM") &&
                        !tl.at(j-1).toUpper().contains("AVG") &&
                        !tl.at(j-1).toUpper().contains("COUNT")
                    )
                        formulaStr.replace(tl.at(j), sectionValue(tl.at(j)));
                }

                QScriptValue fun = myEngine.newFunction(funcAggregate);
                myEngine.globalObject().setProperty("Sum", fun);

                formulaStr = formulaStr.replace("Sum(","Sum(0,", Qt::CaseInsensitive);
                formulaStr = formulaStr.replace("Avg(","Sum(1,", Qt::CaseInsensitive);
                formulaStr = formulaStr.replace("Count(","Sum(2,", Qt::CaseInsensitive);
                formulaStr = formulaStr.replace("[","'[");
                formulaStr = formulaStr.replace("]","]'");
                formulaStr = formulaStr.replace("<","");
                formulaStr = formulaStr.replace(">","");

                QScriptValue result  = myEngine.evaluate(formulaStr);
                res[i] = result.toString();
            }

            tmpStr += res.at(i);
        }
    }

    return tmpStr;
}
Esempio n. 25
0
                 void REcmaLeaderData::init(QScriptEngine& engine, QScriptValue* proto 
    
    ) 
    
    {

    bool protoCreated = false;
    if(proto == NULL){
        proto = new QScriptValue(engine.newVariant(qVariantFromValue(
                (RLeaderData*) 0)));
        protoCreated = true;
    }

    
        // primary base class REntityData:
        
            QScriptValue dpt = engine.defaultPrototype(
                qMetaTypeId<REntityData*>());

            if (dpt.isValid()) {
                proto->setPrototype(dpt);
            }
          
        /*
        REcmaPolyline::init(engine, proto);
          
        */
    

    QScriptValue fun;

    // toString:
    REcmaHelper::registerFunction(&engine, proto, toString, "toString");
    

    // destroy:
    REcmaHelper::registerFunction(&engine, proto, destroy, "destroy");
    
        // conversion for base class REntityData
        REcmaHelper::registerFunction(&engine, proto, getREntityData, "getREntityData");
        

    // get class name
    REcmaHelper::registerFunction(&engine, proto, getClassName, "getClassName");
    

    // conversion to all base classes (multiple inheritance):
    REcmaHelper::registerFunction(&engine, proto, getBaseClasses, "getBaseClasses");
    

    // properties:
    

    // methods:
    
            REcmaHelper::registerFunction(&engine, proto, castToShape, "castToShape");
            
            REcmaHelper::registerFunction(&engine, proto, getDimasz, "getDimasz");
            
            REcmaHelper::registerFunction(&engine, proto, getDimscale, "getDimscale");
            
            REcmaHelper::registerFunction(&engine, proto, setArrowHead, "setArrowHead");
            
            REcmaHelper::registerFunction(&engine, proto, hasArrowHead, "hasArrowHead");
            
            REcmaHelper::registerFunction(&engine, proto, getEndPoint, "getEndPoint");
            
            REcmaHelper::registerFunction(&engine, proto, getStartPoint, "getStartPoint");
            
            REcmaHelper::registerFunction(&engine, proto, countVertices, "countVertices");
            
            REcmaHelper::registerFunction(&engine, proto, countSegments, "countSegments");
            
            REcmaHelper::registerFunction(&engine, proto, appendVertex, "appendVertex");
            
            REcmaHelper::registerFunction(&engine, proto, getReferencePoints, "getReferencePoints");
            
            REcmaHelper::registerFunction(&engine, proto, moveReferencePoint, "moveReferencePoint");
            
            REcmaHelper::registerFunction(&engine, proto, getExploded, "getExploded");
            
            REcmaHelper::registerFunction(&engine, proto, getShapes, "getShapes");
            
            REcmaHelper::registerFunction(&engine, proto, getArrowShape, "getArrowShape");
            
        engine.setDefaultPrototype(
            qMetaTypeId<RLeaderData*>(), *proto);

        
    

    QScriptValue ctor = engine.newFunction(create, *proto, 2);
    
    // static methods:
    

    // static properties:
    

    // enum values:
    

    // enum conversions:
    
        
    // init class:
    engine.globalObject().setProperty("RLeaderData",
    ctor, QScriptValue::SkipInEnumeration);
    
    if( protoCreated ){
       delete proto;
    }
    
    }
Esempio n. 26
0
        // includes for base ecma wrapper classes
         void REcmaWebView::initEcma(QScriptEngine& engine, QScriptValue* proto 
    
    ) 
    
    {

    bool protoCreated = false;
    if(proto == NULL){
        proto = new QScriptValue(engine.newVariant(qVariantFromValue(
                (RWebView*) 0)));
        protoCreated = true;
    }

    
        // primary base class QWebView:
        
            QScriptValue dpt = engine.defaultPrototype(
                qMetaTypeId<QWebView*>());

            if (dpt.isValid()) {
                proto->setPrototype(dpt);
            }
          
        /*
        
        */
    

    QScriptValue fun;

    // toString:
    REcmaHelper::registerFunction(&engine, proto, toString, "toString");
    

    // destroy:
    REcmaHelper::registerFunction(&engine, proto, destroy, "destroy");
    
        // conversion for base class QWebView
        REcmaHelper::registerFunction(&engine, proto, getQWebView, "getQWebView");
        

    // get class name
    REcmaHelper::registerFunction(&engine, proto, getClassName, "getClassName");
    

    // conversion to all base classes (multiple inheritance):
    REcmaHelper::registerFunction(&engine, proto, getBaseClasses, "getBaseClasses");
    

    // properties:
    

    // methods:
    
            REcmaHelper::registerFunction(&engine, proto, sizeHint, "sizeHint");
            
            REcmaHelper::registerFunction(&engine, proto, minimumSizeHint, "minimumSizeHint");
            
            REcmaHelper::registerFunction(&engine, proto, installEventFilter, "installEventFilter");
            
            REcmaHelper::registerFunction(&engine, proto, setAttribute, "setAttribute");
            
            REcmaHelper::registerFunction(&engine, proto, parent, "parent");
            
        engine.setDefaultPrototype(
            qMetaTypeId<RWebView*>(), *proto);

        
                        qScriptRegisterMetaType<
                        RWebView*>(
                        &engine, toScriptValue, fromScriptValue, *proto);
                    
    

    QScriptValue ctor = engine.newFunction(createEcma, *proto, 2);
    
    // static methods:
    

    // static properties:
    

    // enum values:
    

    // enum conversions:
    
        
    // init class:
    engine.globalObject().setProperty("RWebView",
    ctor, QScriptValue::SkipInEnumeration);
    
    if( protoCreated ){
       delete proto;
    }
    
    }
Esempio n. 27
0
        // includes for base ecma wrapper classes
         void REcmaFileExporterRegistry::initEcma(QScriptEngine& engine, QScriptValue* proto 
    
    ) 
    
    {

    bool protoCreated = false;
    if(proto == NULL){
        proto = new QScriptValue(engine.newVariant(qVariantFromValue(
                (RFileExporterRegistry*) 0)));
        protoCreated = true;
    }

    

    QScriptValue fun;

    // toString:
    REcmaHelper::registerFunction(&engine, proto, toString, "toString");
    

    // destroy:
    REcmaHelper::registerFunction(&engine, proto, destroy, "destroy");
    

    // get class name
    REcmaHelper::registerFunction(&engine, proto, getClassName, "getClassName");
    

    // conversion to all base classes (multiple inheritance):
    REcmaHelper::registerFunction(&engine, proto, getBaseClasses, "getBaseClasses");
    

    // properties:
    

    // methods:
    
        engine.setDefaultPrototype(
            qMetaTypeId<RFileExporterRegistry*>(), *proto);

        
    

    QScriptValue ctor = engine.newFunction(create, *proto, 2);
    
    // static methods:
    
            REcmaHelper::registerFunction(&engine, &ctor, registerFileExporter, "registerFileExporter");
            
            REcmaHelper::registerFunction(&engine, &ctor, unregisterFileExporter, "unregisterFileExporter");
            
            REcmaHelper::registerFunction(&engine, &ctor, getFileExporter, "getFileExporter");
            
            REcmaHelper::registerFunction(&engine, &ctor, getFilterStrings, "getFilterStrings");
            

    // static properties:
    

    // enum values:
    

    // enum conversions:
    
        
    // init class:
    engine.globalObject().setProperty("RFileExporterRegistry",
    ctor, QScriptValue::SkipInEnumeration);
    
    if( protoCreated ){
       delete proto;
    }
    
    }
Esempio n. 28
0
bool testPlayerScript(QString path, int player, int difficulty)
{
	QScriptEngine *engine = new QScriptEngine();
	QFile input(path);
	input.open(QIODevice::ReadOnly);
	QString source(QString::fromUtf8(input.readAll()));
	input.close();
	QScriptSyntaxCheckResult syntax = QScriptEngine::checkSyntax(source);
	if (syntax.state() != QScriptSyntaxCheckResult::Valid)
	{
		fprintf(stderr, "Syntax error in %s line %d: %s\n", path.toAscii().constData(), syntax.errorLineNumber(), syntax.errorMessage().toAscii().constData());
		return false;
	}
	QScriptValue result = engine->evaluate(source, path);
	if (engine->hasUncaughtException())
	{
		int line = engine->uncaughtExceptionLineNumber();
		fprintf(stderr, "Uncaught exception at line %d, file %s: %s\n", line, path.toAscii().constData(), result.toString().toAscii().constData());
		return false;
	}
	// Special functions
	engine->globalObject().setProperty("setTimer", engine->newFunction(js_setTimer));
	engine->globalObject().setProperty("queue", engine->newFunction(js_queue));
	engine->globalObject().setProperty("removeTimer", engine->newFunction(js_removeTimer));
	engine->globalObject().setProperty("include", engine->newFunction(js_include));

	// Special global variables
	engine->globalObject().setProperty("me", player, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("gameTime", 2, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("difficulty", difficulty, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("mapName", "Test", QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("baseType", CAMP_BASE, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("alliancesType", ALLIANCES_TEAMS, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("powerType", LEV_MED, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("maxPlayers", 4, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("scavengers", true, QScriptValue::ReadOnly | QScriptValue::Undeletable);

	engine->globalObject().setProperty("_", engine->newFunction(js_translate));

	// General functions -- geared for use in AI scripts
	engine->globalObject().setProperty("debug", engine->newFunction(js_debug));
	engine->globalObject().setProperty("console", engine->newFunction(js_console));
	engine->globalObject().setProperty("structureIdle", engine->newFunction(js_structureIdle));
	engine->globalObject().setProperty("buildDroid", engine->newFunction(js_buildDroid));
	engine->globalObject().setProperty("enumStruct", engine->newFunction(js_enumStruct));
	engine->globalObject().setProperty("enumDroid", engine->newFunction(js_enumDroid));
	engine->globalObject().setProperty("enumGroup", engine->newFunction(js_enumGroup));
	engine->globalObject().setProperty("distBetweenTwoPoints", engine->newFunction(js_distBetweenTwoPoints));
	engine->globalObject().setProperty("newGroup", engine->newFunction(js_newGroup));
	engine->globalObject().setProperty("groupAddArea", engine->newFunction(js_groupAddArea));
	engine->globalObject().setProperty("groupAddDroid", engine->newFunction(js_groupAddDroid));
	engine->globalObject().setProperty("groupSize", engine->newFunction(js_groupSize));
	engine->globalObject().setProperty("orderDroidLoc", engine->newFunction(js_orderDroidLoc));
	engine->globalObject().setProperty("playerPower", engine->newFunction(js_playerPower));
	engine->globalObject().setProperty("isStructureAvailable", engine->newFunction(js_isStructureAvailable));

	// Functions that operate on the current player only
	engine->globalObject().setProperty("centreView", engine->newFunction(js_centreView));
	engine->globalObject().setProperty("playSound", engine->newFunction(js_playSound));
	engine->globalObject().setProperty("gameOverMessage", engine->newFunction(js_gameOverMessage));

	// Global state manipulation -- not for use with skirmish AI (unless you want it to cheat, obviously)
	engine->globalObject().setProperty("setStructureLimits", engine->newFunction(js_setStructureLimits));
	engine->globalObject().setProperty("applyLimitSet", engine->newFunction(js_applyLimitSet));
	engine->globalObject().setProperty("setMissionTime", engine->newFunction(js_setMissionTime));
	engine->globalObject().setProperty("setReinforcementTime", engine->newFunction(js_setReinforcementTime));
	engine->globalObject().setProperty("completeResearch", engine->newFunction(js_completeResearch));
	engine->globalObject().setProperty("enableResearch", engine->newFunction(js_enableResearch));
	engine->globalObject().setProperty("setPower", engine->newFunction(js_setPower));
	engine->globalObject().setProperty("addReticuleButton", engine->newFunction(js_addReticuleButton));
	engine->globalObject().setProperty("enableStructure", engine->newFunction(js_enableStructure));
	engine->globalObject().setProperty("makeComponentAvailable", engine->newFunction(js_makeComponentAvailable));
	engine->globalObject().setProperty("enableComponent", engine->newFunction(js_enableComponent));
	engine->globalObject().setProperty("allianceExistsBetween", engine->newFunction(js_allianceExistsBetween));

	// Set some useful constants
	engine->globalObject().setProperty("DORDER_ATTACK", 0, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("DORDER_MOVE", 0, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("DORDER_SCOUT", 0, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("DORDER_BUILD", 0, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("mapWidth", 64, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("mapHeight", 64, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("COMMAND", 0, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("OPTIONS", 0, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("BUILD", 0, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("MANUFACTURE", 0, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("RESEARCH", 0, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("INTELMAP", 0, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("DESIGN", 0, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("CANCEL", 0, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("CAMP_CLEAN", CAMP_CLEAN, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("CAMP_BASE", CAMP_BASE, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("CAMP_WALLS", CAMP_WALLS, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("NO_ALLIANCES", NO_ALLIANCES, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("ALLIANCES", ALLIANCES, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("ALLIANCES_TEAMS", ALLIANCES_TEAMS, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("BEING_BUILT", SS_BEING_BUILT, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("BUILT", SS_BUILT, QScriptValue::ReadOnly | QScriptValue::Undeletable);
	engine->globalObject().setProperty("BEING_DEMOLISHED", SS_BEING_DEMOLISHED, QScriptValue::ReadOnly | QScriptValue::Undeletable);

	// Call init
	callFunction(engine, "eventGameInit", QScriptValueList());

	// Now set gameTime to something proper
	engine->globalObject().setProperty("gameTime", 10101, QScriptValue::ReadOnly | QScriptValue::Undeletable);

	callFunction(engine, "eventStartLevel", QScriptValueList());

	// Call other events
	{
		QScriptValueList args;
		args += convDroid(engine);
		args += convStructure(engine);
		callFunction(engine, "eventDroidBuilt", args);
	}
	{
		QScriptValueList args;
		args += convStructure(engine);
		args += convObj(engine);
		callFunction(engine, "eventStructureAttacked", args);
	}

	// Now test timers
	// TODO -- implement object parameters
	QMutableListIterator<timerNode> iter(timers);
	while (iter.hasNext())
	{
		timerNode node = iter.next();
		callFunction(node.engine, node.function, QScriptValueList());
	}

	// Clean up
	delete engine;
	timers.clear();

	return true;
}
Esempio n. 29
0
                 void REcmaSnapEnd::initEcma(QScriptEngine& engine, QScriptValue* proto 
    
    ) 
    
    {

    bool protoCreated = false;
    if(proto == NULL){
        proto = new QScriptValue(engine.newVariant(qVariantFromValue(
                (RSnapEnd*) 0)));
        protoCreated = true;
    }

    
        // primary base class RSnapEntityBase:
        
            QScriptValue dpt = engine.defaultPrototype(
                qMetaTypeId<RSnapEntityBase*>());

            if (dpt.isValid()) {
                proto->setPrototype(dpt);
            }
          
        /*
        
        */
    

    QScriptValue fun;

    // toString:
    REcmaHelper::registerFunction(&engine, proto, toString, "toString");
    

    // destroy:
    REcmaHelper::registerFunction(&engine, proto, destroy, "destroy");
    
        // conversion for base class RSnapEntityBase
        REcmaHelper::registerFunction(&engine, proto, getRSnapEntityBase, "getRSnapEntityBase");
        
        // conversion for base class RSnap
        REcmaHelper::registerFunction(&engine, proto, getRSnap, "getRSnap");
        

    // get class name
    REcmaHelper::registerFunction(&engine, proto, getClassName, "getClassName");
    

    // conversion to all base classes (multiple inheritance):
    REcmaHelper::registerFunction(&engine, proto, getBaseClasses, "getBaseClasses");
    

    // properties:
    

    // methods:
    
        engine.setDefaultPrototype(
            qMetaTypeId<RSnapEnd*>(), *proto);

        
    

    QScriptValue ctor = engine.newFunction(createEcma, *proto, 2);
    
    // static methods:
    

    // static properties:
    

    // enum values:
    

    // enum conversions:
    
        
    // init class:
    engine.globalObject().setProperty("RSnapEnd",
    ctor, QScriptValue::SkipInEnumeration);
    
    if( protoCreated ){
       delete proto;
    }
    
    }
Esempio n. 30
0
        // includes for base ecma wrapper classes
         void REcmaMessageHandler::initEcma(QScriptEngine& engine, QScriptValue* proto 
    
    ) 
    
    {

    bool protoCreated = false;
    if(proto == NULL){
        proto = new QScriptValue(engine.newVariant(qVariantFromValue(
                (RMessageHandler*) 0)));
        protoCreated = true;
    }

    

    QScriptValue fun;

    // toString:
    REcmaHelper::registerFunction(&engine, proto, toString, "toString");
    

    // destroy:
    REcmaHelper::registerFunction(&engine, proto, destroy, "destroy");
    

    // get class name
    REcmaHelper::registerFunction(&engine, proto, getClassName, "getClassName");
    

    // conversion to all base classes (multiple inheritance):
    REcmaHelper::registerFunction(&engine, proto, getBaseClasses, "getBaseClasses");
    

    // properties:
    

    // methods:
    
            REcmaHelper::registerFunction(&engine, proto, handleUserMessage, "handleUserMessage");
            
            REcmaHelper::registerFunction(&engine, proto, handleUserInfo, "handleUserInfo");
            
            REcmaHelper::registerFunction(&engine, proto, handleUserWarning, "handleUserWarning");
            
            REcmaHelper::registerFunction(&engine, proto, handleUserCommand, "handleUserCommand");
            
        engine.setDefaultPrototype(
            qMetaTypeId<RMessageHandler*>(), *proto);

        
    

    QScriptValue ctor = engine.newFunction(createEcma, *proto, 2);
    
    // static methods:
    

    // static properties:
    

    // enum values:
    

    // enum conversions:
    
        
    // init class:
    engine.globalObject().setProperty("RMessageHandler",
    ctor, QScriptValue::SkipInEnumeration);
    
    if( protoCreated ){
       delete proto;
    }
    
    }