本文整理汇总了C++中UiScriptBinding类的典型用法代码示例。如果您正苦于以下问题:C++ UiScriptBinding类的具体用法?C++ UiScriptBinding怎么用?C++ UiScriptBinding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UiScriptBinding类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readModuleApi
void TypeDescriptionReader::readModuleApi(UiObjectDefinition *ast)
{
ModuleApiInfo apiInfo;
for (UiObjectMemberList *it = ast->initializer->members; it; it = it->next) {
UiObjectMember *member = it->member;
UiScriptBinding *script = dynamic_cast<UiScriptBinding *>(member);
if (script) {
const QString name = toString(script->qualifiedId);
if (name == QLatin1String("uri")) {
apiInfo.uri = readStringBinding(script);
} else if (name == QLatin1String("version")) {
apiInfo.version = readNumericVersionBinding(script);
} else if (name == QLatin1String("name")) {
apiInfo.cppName = readStringBinding(script);
} else {
addWarning(script->firstSourceLocation(),
tr("Expected only uri, version and name script bindings."));
}
} else {
addWarning(member->firstSourceLocation(), tr("Expected only script bindings."));
}
}
if (!apiInfo.version.isValid()) {
addError(ast->firstSourceLocation(), tr("ModuleApi definition has no or invalid version binding."));
return;
}
if (_moduleApis)
_moduleApis->append(apiInfo);
}
示例2: readParameter
void TypeDescriptionReader::readParameter(UiObjectDefinition *ast, FakeMetaMethod *fmm)
{
QString name;
QString type;
for (UiObjectMemberList *it = ast->initializer->members; it; it = it->next) {
UiObjectMember *member = it->member;
UiScriptBinding *script = dynamic_cast<UiScriptBinding *>(member);
if (!script) {
addWarning(member->firstSourceLocation(), tr("Expected script binding."));
continue;
}
const QString id = toString(script->qualifiedId);
if (id == QLatin1String("name")) {
name = readStringBinding(script);
} else if (id == QLatin1String("type")) {
type = readStringBinding(script);
} else if (id == QLatin1String("isPointer")) {
// ### unhandled
} else if (id == QLatin1String("isReadonly")) {
// ### unhandled
} else if (id == QLatin1String("isList")) {
// ### unhandled
} else {
addWarning(script->firstSourceLocation(), tr("Expected only name and type script bindings."));
}
}
fmm->addParameter(name, type);
}
示例3: fmo
void TypeDescriptionReader::readComponent(UiObjectDefinition *ast)
{
FakeMetaObject::Ptr fmo(new FakeMetaObject);
for (UiObjectMemberList *it = ast->initializer->members; it; it = it->next) {
UiObjectMember *member = it->member;
UiObjectDefinition *component = dynamic_cast<UiObjectDefinition *>(member);
UiScriptBinding *script = dynamic_cast<UiScriptBinding *>(member);
if (component) {
QString name = toString(component->qualifiedTypeNameId);
if (name == "Property") {
readProperty(component, fmo);
} else if (name == "Method" || name == "Signal") {
readSignalOrMethod(component, name == "Method", fmo);
} else if (name == "Enum") {
readEnum(component, fmo);
} else {
addWarning(component->firstSourceLocation(), "Expected only Property, Method, Signal and Enum object definitions");
}
} else if (script) {
QString name = toString(script->qualifiedId);
if (name == "name") {
fmo->setClassName(readStringBinding(script));
} else if (name == "prototype") {
fmo->setSuperclassName(readStringBinding(script));
} else if (name == "defaultProperty") {
fmo->setDefaultPropertyName(readStringBinding(script));
} else if (name == "exports") {
readExports(script, fmo);
} else if (name == "exportMetaObjectRevisions") {
readMetaObjectRevisions(script, fmo);
} else if (name == "attachedType") {
fmo->setAttachedTypeName(readStringBinding(script));
} else {
addWarning(script->firstSourceLocation(),
"Expected only name, prototype, defaultProperty, attachedType, exports"
"and exportMetaObjectRevisions script bindings");
}
} else {
addWarning(member->firstSourceLocation(), "Expected only script bindings and object definitions");
}
}
if (fmo->className().isEmpty()) {
addError(ast->firstSourceLocation(), "Component definition is missing a name binding");
return;
}
// ### add implicit export into the package of c++ types
fmo->addExport(fmo->className(), QmlJS::CppQmlTypes::cppPackage, ComponentVersion());
_objects->insert(fmo->className(), fmo);
}
示例4: readSignalOrMethod
void TypeDescriptionReader::readSignalOrMethod(UiObjectDefinition *ast, bool isMethod, FakeMetaObject::Ptr fmo)
{
FakeMetaMethod fmm;
// ### confusion between Method and Slot. Method should be removed.
if (isMethod)
fmm.setMethodType(FakeMetaMethod::Slot);
else
fmm.setMethodType(FakeMetaMethod::Signal);
for (UiObjectMemberList *it = ast->initializer->members; it; it = it->next) {
UiObjectMember *member = it->member;
UiObjectDefinition *component = dynamic_cast<UiObjectDefinition *>(member);
UiScriptBinding *script = dynamic_cast<UiScriptBinding *>(member);
if (component) {
QString name = toString(component->qualifiedTypeNameId);
if (name == "Parameter") {
readParameter(component, &fmm);
} else {
addWarning(component->firstSourceLocation(), "Expected only Parameter object definitions");
}
} else if (script) {
QString name = toString(script->qualifiedId);
if (name == "name") {
fmm.setMethodName(readStringBinding(script));
} else if (name == "type") {
fmm.setReturnType(readStringBinding(script));
} else if (name == "revision") {
fmm.setRevision(readIntBinding(script));
} else {
addWarning(script->firstSourceLocation(), "Expected only name and type script bindings");
}
} else {
addWarning(member->firstSourceLocation(), "Expected only script bindings and object definitions");
}
}
if (fmm.methodName().isEmpty()) {
addError(ast->firstSourceLocation(), "Method or Signal is missing a name script binding");
return;
}
fmo->addMethod(fmm);
}
示例5: readProperty
void TypeDescriptionReader::readProperty(UiObjectDefinition *ast, FakeMetaObject::Ptr fmo)
{
QString name;
QString type;
bool isPointer = false;
bool isReadonly = false;
bool isList = false;
int revision = 0;
for (UiObjectMemberList *it = ast->initializer->members; it; it = it->next) {
UiObjectMember *member = it->member;
UiScriptBinding *script = dynamic_cast<UiScriptBinding *>(member);
if (!script) {
addWarning(member->firstSourceLocation(), "Expected script binding");
continue;
}
QString id = toString(script->qualifiedId);
if (id == "name") {
name = readStringBinding(script);
} else if (id == "type") {
type = readStringBinding(script);
} else if (id == "isPointer") {
isPointer = readBoolBinding(script);
} else if (id == "isReadonly") {
isReadonly = readBoolBinding(script);
} else if (id == "isList") {
isList = readBoolBinding(script);
} else if (id == "revision") {
revision = readIntBinding(script);
} else {
addWarning(script->firstSourceLocation(), "Expected only type, name, revision, isPointer, isReadonly and isList script bindings");
}
}
if (name.isEmpty() || type.isEmpty()) {
addError(ast->firstSourceLocation(), "Property object is missing a name or type script binding");
return;
}
fmo->addProperty(FakeMetaProperty(name, type, isList, !isReadonly, isPointer, revision));
}
示例6: readEnum
void TypeDescriptionReader::readEnum(UiObjectDefinition *ast, FakeMetaObject::Ptr fmo)
{
FakeMetaEnum fme;
for (UiObjectMemberList *it = ast->initializer->members; it; it = it->next) {
UiObjectMember *member = it->member;
UiScriptBinding *script = dynamic_cast<UiScriptBinding *>(member);
if (!script) {
addWarning(member->firstSourceLocation(), tr("Expected script binding."));
continue;
}
QString name = toString(script->qualifiedId);
if (name == QLatin1String("name"))
fme.setName(readStringBinding(script));
else if (name == QLatin1String("values"))
readEnumValues(script, &fme);
else
addWarning(script->firstSourceLocation(), tr("Expected only name and values script bindings."));
}
fmo->addEnum(fme);
}
示例7: fmo
void TypeDescriptionReader::readComponent(UiObjectDefinition *ast)
{
FakeMetaObject::Ptr fmo(new FakeMetaObject);
for (UiObjectMemberList *it = ast->initializer->members; it; it = it->next) {
UiObjectMember *member = it->member;
UiObjectDefinition *component = dynamic_cast<UiObjectDefinition *>(member);
UiScriptBinding *script = dynamic_cast<UiScriptBinding *>(member);
if (component) {
QString name = toString(component->qualifiedTypeNameId);
if (name == QLatin1String("Property"))
readProperty(component, fmo);
else if (name == QLatin1String("Method") || name == QLatin1String("Signal"))
readSignalOrMethod(component, name == QLatin1String("Method"), fmo);
else if (name == QLatin1String("Enum"))
readEnum(component, fmo);
else
addWarning(component->firstSourceLocation(),
tr("Expected only Property, Method, Signal and Enum object definitions, not \"%1\".")
.arg(name));
} else if (script) {
QString name = toString(script->qualifiedId);
if (name == QLatin1String("name")) {
fmo->setClassName(readStringBinding(script));
} else if (name == QLatin1String("prototype")) {
fmo->setSuperclassName(readStringBinding(script));
} else if (name == QLatin1String("defaultProperty")) {
fmo->setDefaultPropertyName(readStringBinding(script));
} else if (name == QLatin1String("exports")) {
readExports(script, fmo);
} else if (name == QLatin1String("exportMetaObjectRevisions")) {
readMetaObjectRevisions(script, fmo);
} else if (name == QLatin1String("attachedType")) {
fmo->setAttachedTypeName(readStringBinding(script));
} else if (name == QLatin1String("isSingleton")) {
fmo->setIsSingleton(readBoolBinding(script));
} else if (name == QLatin1String("isCreatable")) {
fmo->setIsCreatable(readBoolBinding(script));
} else if (name == QLatin1String("isComposite")) {
fmo->setIsComposite(readBoolBinding(script));
} else {
addWarning(script->firstSourceLocation(),
tr("Expected only name, prototype, defaultProperty, attachedType, exports "
"isSingleton, isCreatable, isComposite and exportMetaObjectRevisions "
"script bindings, not \"%1\".").arg(name));
}
} else {
addWarning(member->firstSourceLocation(), tr("Expected only script bindings and object definitions."));
}
}
if (fmo->className().isEmpty()) {
addError(ast->firstSourceLocation(), tr("Component definition is missing a name binding."));
return;
}
// ### add implicit export into the package of c++ types
fmo->addExport(fmo->className(), QmlJS::CppQmlTypes::cppPackage, ComponentVersion());
fmo->updateFingerprint();
_objects->insert(fmo->className(), fmo);
}