本文整理汇总了C++中QScriptEngine::globalObject方法的典型用法代码示例。如果您正苦于以下问题:C++ QScriptEngine::globalObject方法的具体用法?C++ QScriptEngine::globalObject怎么用?C++ QScriptEngine::globalObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScriptEngine
的用法示例。
在下文中一共展示了QScriptEngine::globalObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initEcma
// 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;
}
}
示例2: Register
void QOFile::Register(QScriptEngine& engine)
{
QScriptValue ctor = engine.newFunction(QOFile::New);
QScriptValue metaObject = engine.newQMetaObject(&QOFile::staticMetaObject, ctor);
engine.globalObject().setProperty("OFile", metaObject);
}
示例3: importSimplePlugin
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());
}
示例4: setCurrentIndex
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);
}
//.........这里部分代码省略.........
示例5: init
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;
}
//.........这里部分代码省略.........
示例6: init
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);
//.........这里部分代码省略.........
示例7: init
//.........这里部分代码省略.........
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;
}
}
示例8: init
// 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;
}
}
示例9: initEcma
//.........这里部分代码省略.........
// 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;
}
}
示例10: initEcma
//.........这里部分代码省略.........
/*
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;
}
}
示例11: initEcma
//.........这里部分代码省略.........
}
/*
*/
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;
}
}
示例12: initEcma
//.........这里部分代码省略.........
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;
}
}
示例13: init
//.........这里部分代码省略.........
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;
}
}
示例14: init
//.........这里部分代码省略.........
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;
}
}
示例15: attachAndDetach
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);
}
}